$name ] = 0";exit(-1);} $mas = array(); while(($r = mysql_fetch_assoc($a)) != false) { $mas[] = $r[$name]; } mysql_free_result($a); return $mas; } function get_rand_param($mas,$maxp) { return $mas[mt_rand(0,$maxp-1)]; } function save_mas_to_file($fname,$mas,$len) { $f = fopen($fname,"wb"); if($len<0){ $i=0; while(isset($mas[$i])) { fwrite($f,$mas[$i]); fwrite($f,"\r\n"); $i++; } } else { for($i=0;$i<$len;$i++) { fwrite($f,$mas[$i]); fwrite($f,"\r\n"); } } fclose($f); } function make_proxy_file($fnameproxy) { global $rdir,$cmdprog; //echo "Start test...
\n"; chdir($rdir); $n8 = get_mas_param("sp2_proxy","ip",$r8); ////////////////////////////////////////////// //save_mas_to_file($fnameproxy,$n8,$r8); $fproxy = fopen("proxy.txt","wb"); if($r8 <= 0){echo "No proxy";exit(0);} $is_proxy=0; for($i=0;$i<$r8;$i++){ $f = @fopen($n8[$i],"r"); if($f==FALSE) { $val = trim($n8[$i]); if($val=='')continue; if(strlen($val)>10 && strlen($val)<25 && strstr($val,":")!=FALSE && strstr($val,".")!=FALSE && (int)$val != 0) { //echo "proxy=$val
"; fwrite($fproxy,$val); fwrite($fproxy,"\r\n"); $is_proxy++; } continue; } while (!feof ($f)) { $buffer = fgets($f); $buffer = trim($buffer); if(strstr($buffer,"
")!=FALSE) {//echo "BBBRRR"; $sb = explode("
",$buffer); foreach($sb as $key=>$val) { $val = trim($val); if($val=='')continue; if(strlen($val)>10 && strlen($val)<25 && strstr($val,":")!=FALSE && strstr($val,".")!=FALSE && (int)$val != 0) { //echo "proxy=$val
"; fwrite($fproxy,$val); fwrite($fproxy,"\r\n"); $is_proxy++; } } } else {//echo "NOBBRR"; if(strlen($buffer)>10 && strlen($buffer)<25 && strstr($buffer,":")!=FALSE && strstr($buffer,".")!=FALSE && (int)$buffer != 0){ //echo "proxy=$buffer
"; fwrite($fproxy,$buffer); fwrite($fproxy,"\r\n"); $is_proxy++; } } } fclose($f); } fclose($fproxy); if($is_proxy <= 0){echo "No proxy";exit(0);} echo "Chislo proxey = $is_proxy
"; } ///////////////////////// //START ///////////////////////// echo "Start...\r\n"; chdir($rdir); function is_run() { $fe = fopen("existp.txt","r"); if($fe!=0) { $s = fgets($fe); fclose($fe); } else { $s = "0"; } $s = trim($s); $s = (int)$s; $tim = time(); echo "Read time = $s; Current time = $tim
\r\n"; if($tim - $s < 20)return 1; return 0; } if(is_run() == 0) {// т.е. не запущено, то можно убить несуществующий процесс )) system("killall -HUP $cmd_name"); sleep(5);//еще раз проверяем... если запущено, то выходим if(is_run() != 0){echo "Program Is Run!!!";exit(0);} } else {echo "Program Is Run!!!";exit(0);} $s = "echo ".time()." > existp.txt"; system($s); $iii = 0; @unlink("logg.htm"); do{ $s = "echo ".time()." > existp.txt";system($s); @unlink("input.txt"); //Удаляем файл задания if(file_exists("input.txt")){echo "Process is run";exit(0);} make_proxy_file("proxy.txt"); //Составляем список проксей ////////////////////////////////Запускаем то что надо... $q2 = "SELECT * FROM sp2_options "; $a2 = mysql_query($q2); $r2 = mysql_fetch_assoc($a2); mysql_free_result($a2); if($r2['pause']!=0){echo "pause enable!!!";exit(0);} $nthreads = $r2['threads']; $s = $cmdprog; $s .= add_param($nthreads); $s .= add_param($r2['no_proxy']); @copy("log3.htm","log4.htm"); @copy("log2.htm","log3.htm"); @copy("log1.htm","log2.htm"); system($s." > log1.htm",$res); echo "
Resultlog=$res
"; system ("echo \"Resutlog=$res
\r\n\" >> logg.htm"); if(($res==0 && $iii>2)||$res==111)exit(0); $s = "echo ".time()." > existp.txt";system($s); $iii++; }while(1); ?>