PHP Multi Threads

Discussion in 'PHP' started by krakiuN, Sep 13, 2012.

  1. #1
    hello,
    Anybody i can help me to edit this php script in multi thread !
    Please i very need.

    <?php
    
    $imput  = file("$argv[1]");
    $output = $argv[2];
    
    
    foreach ($imput as $nr => $line) {
    $line = trim($line);
    print ("$nr - check :" . $line . "\r\n");
    
    $check = ia_continutul($line); 
    
    if (strpos($check,'wordpress') !== false) {
    
    	$SaveFile = fopen($output, "a");
    	fwrite($SaveFile, "$line\r\n");
    	fclose($SaveFile);
    	}
    }
    print "The END !\r\n";
    
    function ia_continutul($url) {  
        $ch = curl_init();  
        $timeout = 3;  
        curl_setopt($ch,CURLOPT_URL,$url);  
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);  
        curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
    	curl_setopt($ch, CURLOPT_TIMEOUT, 5);  
        $data = curl_exec($ch);  
        curl_close($ch);  
        return $data;  
    }
    ?>
    PHP:
     
    krakiuN, Sep 13, 2012 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    What are you trying to do?
     
    jestep, Sep 13, 2012 IP
  3. Presnus

    Presnus Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You should check out supervisord on linux. This allows you to run multiple processes at same time and restart one if it stopped. Hope it helps.
     
    Presnus, Sep 15, 2012 IP