All pastes #405069 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-03-21 14:16 UTC
rendered paste body
<?php
@set_time_limit(0);
@ini_set('max_execution_time',0);
include_once("placeholder.php");
include_once("config.php");
include_once("init.php");

chdir($rdir);
$cmdprog = "./".$cmd_name." ";
if($system_name == "win32")$cmdprog = $cmd_name." ";

function add_param($param)
{
return "\"$param\" ";
}


function get_mas_param($table,$name,&$rows)
{
$q = "SELECT $name FROM $table";
$a = mysql_query($q);
$rows = mysql_num_rows($a);
if($rows==0){echo "Error!!! rows[ $table -> $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...<BR>\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 <BR>";
			fwrite($fproxy,$val);	
			fwrite($fproxy,"\r\n");
			$is_proxy++;
			}
	continue;
	}
	
while (!feof ($f)) {
    $buffer = fgets($f);
    $buffer = trim($buffer);
	if(strstr($buffer,"<br>")!=FALSE)
	{//echo "BBBRRR";
	$sb = explode("<br>",$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 <BR>";
			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 <BR>";
		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<BR>";

}


















/////////////////////////
//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 <br>\r\n";
if($tim - $s < 20)return 1;
return 0;
}



if(is_run() == 0)
{// &#1090;.&#1077;. &#1085;&#1077; &#1079;&#1072;&#1087;&#1091;&#1097;&#1077;&#1085;&#1086;, &#1090;&#1086; &#1084;&#1086;&#1078;&#1085;&#1086; &#1091;&#1073;&#1080;&#1090;&#1100; &#1085;&#1077;&#1089;&#1091;&#1097;&#1077;&#1089;&#1090;&#1074;&#1091;&#1102;&#1097;&#1080;&#1081; &#1087;&#1088;&#1086;&#1094;&#1077;&#1089;&#1089; ))
system("killall -HUP $cmd_name");
sleep(5);//&#1077;&#1097;&#1077; &#1088;&#1072;&#1079; &#1087;&#1088;&#1086;&#1074;&#1077;&#1088;&#1103;&#1077;&#1084;... &#1077;&#1089;&#1083;&#1080; &#1079;&#1072;&#1087;&#1091;&#1097;&#1077;&#1085;&#1086;, &#1090;&#1086; &#1074;&#1099;&#1093;&#1086;&#1076;&#1080;&#1084;
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");         //&#1059;&#1076;&#1072;&#1083;&#1103;&#1077;&#1084; &#1092;&#1072;&#1081;&#1083; &#1079;&#1072;&#1076;&#1072;&#1085;&#1080;&#1103;
	if(file_exists("input.txt")){echo "Process is run";exit(0);}
	make_proxy_file("proxy.txt"); //&#1057;&#1086;&#1089;&#1090;&#1072;&#1074;&#1083;&#1103;&#1077;&#1084; &#1089;&#1087;&#1080;&#1089;&#1086;&#1082; &#1087;&#1088;&#1086;&#1082;&#1089;&#1077;&#1081;
	////////////////////////////////&#1047;&#1072;&#1087;&#1091;&#1089;&#1082;&#1072;&#1077;&#1084; &#1090;&#1086; &#1095;&#1090;&#1086; &#1085;&#1072;&#1076;&#1086;...
	$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 "<BR>Resultlog=$res<BR>";
	system ("echo \"Resutlog=$res <BR>\r\n\" >> logg.htm");
	if(($res==0 && $iii>2)||$res==111)exit(0);



$s = "echo ".time()." > existp.txt";system($s);
$iii++;
}while(1);



?>