|
Участник форума
Регистрация: 30.07.2008
Сообщений: 152
С нами:
9358231
Репутация:
34
|
|
To heretic1990:
PHP код:
<?php
function error( $error = false )
{
header( "Expires: Thu, 19 Feb 1998 13:24:18 GMT" );
header( "Last-Modified: ".gmdate( "D, d M Y H:i:s" )." GMT" );
header( "Cache-Control: no-cache, must-revalidate" );
header( "Cache-Control: post-check=0, pre-cache=0" );
header( "Cache-Control: max-age=0" );
header( "Pragma: no-cache" );
header( "Content-Type: text/html; charset=windows-1251" );
$rand = mt_rand( 0, 99999 );
echo "<html>\r\n
<head>\r\n
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1251\" />
<title>Накрутка хостов</title>\r\n
</head>\r\n
<body>\r\n
<form action=\"test.php\" method=\"post\">\r\n";
if ( $error == "agents" )
{
echo "<b>Файл с браузерами недоступен или пуст!</b><br/>\n";
}
if ( $error == "proxys" )
{
echo "<b>Файл с прокси адресами недоступен или пуст!</b><br/>\n";
}
echo "Количество хостов:<br/>\n";
if ( $error == "kol" )
{
echo "Мин:1 Макс:10000<br/>\n";
}
echo "<input name=\"kol\" type=\"text\" value=\"100\" maxlength=\"5\" size=\"5\" /><br/>\r\nАдрес:<br/>\n";
if ( $error == "link" )
{
echo "Не корректно!<br/>\n";
}
echo "<input name=\"link\" type=\"text\" value=\"http://\" maxlength=\"100\" /><br/>\r\nМакс. время соединений (секунд):<br/>\n";
if ( $error == "time" )
{
echo "Мин:1 Макс:30<br/>\n";
}
echo "<input name=\"time\" type=\"text\" value=\"10\" maxlength=\"2\" size=\"2\" /><br/>\r\nМетод передачи:<br/>\n";
if ( $error == "method" )
{
echo "GET или POST<br/>\n";
}
echo "<select name=\"method\">\r\n
<option value=\"GET\">GET</option>\r\n
<option value=\"POST\">POST</option>\r\n
</select><br/>\r\nПротокол передачи:<br/>\n";
if ( $error == "protokol" )
{
echo "HTTP/1.0 или HTTP/1.1<br/>\n";
}
echo "<select name=\"protokol\">\r\n
<option value=\"HTTP/1.0\">HTTP/1.0</option>\r\n
<option value=\"HTTP/1.1\">HTTP/1.1</option>\r\n
</select><br/>\r\nСоединение:<br/>\n";
if ( $error == "connection" )
{
echo "Close или Keep-Alive<br/>\n";
}
echo "<select name=\"connection\">\r\n
<option value=\"Close\">Close</option>\r\n
<option value=\"Keep-Alive\">Keep-Alive</option>\r\n
</select><br/>\r\nВыбор телефона:<br/>\n";
if ( $error == "agent" )
{
echo "случайно или по порядку<br/>\n";
}
echo "<select name=\"agent\">\r\n
<option value=\"1\">случайно</option>\r\n
<option value=\"2\">по порядку</option>\r\n
</select><br/>\r\nВыбор прокси:<br/>\n";
if ( $error == "proxy" )
{
echo "случайно или по порядку<br/>\n";
}
echo "<select name=\"proxy\">\r\n
<option value=\"1\">случайно</option>\r\n
<option value=\"2\">по порядку</option>\r\n
</select><br/>\r\n<input name=\"submit\" type=\"submit\" name=\"start\" value=\"Крутить\">\r\n
</form>\r\n
</body>\r\n
</html>\n";
}
error_reporting( 0 );
$kol = intval( $_POST['kol'] );
$link = $_POST['link'];
$time = intval( $_POST['time'] );
$method = $_POST['method'];
$protokol = $_POST['protokol'];
$connection = $_POST['connection'];
$agent = intval( $_POST['agent'] );
$proxy = intval( $_POST['proxy'] );
$agents = array( );
$proxys = array( );
$agents = file( "agents.txt" );
$proxys = file( "proxys.txt" );
$cagents = count( $agents );
$cproxys = count( $proxys );
if ( empty( $kol ) || empty( $link ) || empty( $time ) || empty( $method ) || empty( $protokol ) || empty( $connection ) )
{
error( );
}
else if ( $kol < 1 || 10000 < $kol )
{
error( "kol" );
}
else if ( strlen( $link ) < 15 || 100 < strlen( $link ) || substr( $link, 0, 7 ) !== "http://" )
{
error( "link" );
}
else if ( $time < 1 || 30 < $time )
{
error( "time" );
}
else if ( $method < 1 || 2 < $method )
{
error( "method" );
}
else if ( $protokol < 1 || 2 < $protokol )
{
error( "protokol" );
}
else if ( $connection < 1 || 2 < $connection )
{
error( "connection" );
}
else if ( $agent < 1 || 2 < $agent )
{
error( "agent" );
}
else if ( $proxy < 1 || 2 < $proxy )
{
error( "proxy" );
}
else if ( $cagents < 1 )
{
error( "agents" );
}
else if ( $cproxys < 1 )
{
error( "proxys" );
}
else
{
$na = -1;
$np = -1;
$link = substr( $link, 7 );
$host = strtok( $link, "/" );
if ( $host == false )
{
$host = $link;
}
if ( $method == 1 )
{
$method = "GET";
}
else
{
$method = "POST";
}
if ( $protokol == 1 )
{
$protokol = "HTTP/1.0";
}
else
{
$protokol = "HTTP/1.1";
}
if ( $connection == 1 )
{
$connection = "Close";
}
else
{
$connection = "Keep-Alive";
}
$i = 0;
for ( ; $i < $kol; ++$i )
{
if ( $agent == 1 )
{
$na = mt_rand( 0, $cagents - 1 );
}
else
{
++$na;
}
if ( $proxy == 1 )
{
$np = mt_rand( 0, $cproxys - 1 );
}
else
{
++$np;
}
if ( $cagents <= $na )
{
$na = 0;
}
if ( $cproxys <= $np )
{
$np = 0;
}
$a = trim( $agents[$na] );
$p = trim( $proxys[$np] );
if ( empty( $a ) || empty( $p ) )
{
}
else
{
}
}
$text = "";
while ( !feof( $fo ) )
{
$text .= fgets( $fo, 1024 );
}
$hd = substr( $text, 0, strpos( $text, "\r\n\r\n" ) );
$text = substr( $text, strpos( $text, "\r\n\r\n" ) + 4 );
if ( $powered = strtok( strstr( $hd, "X-Powered-By:" ), "\r\n" ) )
{
header( $powered );
}
if ( $cache = strtok( strstr( $hd, "Cache-Control:" ), "\r\n" ) )
{
header( $cache );
}
if ( $expires = strtok( strstr( $hd, "Expires:" ), "\r\n" ) )
{
header( $expires );
}
if ( $pragma = strtok( strstr( $hd, "Pragma:" ), "\r\n" ) )
{
header( $pragma );
}
if ( $modified = strtok( strstr( $hd, "Last-Modified:" ), "\r\n" ) )
{
header( $modified );
}
if ( $type = strtok( strstr( $hd, "Content-Type:" ), "\r\n" ) )
{
header( $type );
}
if ( $disposition = strtok( strstr( $hd, "Content-Disposition:" ), "\r\n" ) )
{
header( $disposition );
}
if ( $etag = strtok( strstr( $hd, "ETag:" ), "\r\n" ) )
{
header( $etag );
}
if ( $ranges = strtok( strstr( $hd, "Accept-Ranges:" ), "\r\n" ) )
{
header( $ranges );
}
exit( $text );
}
if($_POST['link']) {
$str=str_replace("http://", "", $link);
$srv=substr($str,0,strpos($str,"/"));
for($i=0; $i<$kol; $i++) {
$fp = fsockopen($srv, '80', $er1, $er2, $time);
if ($fp)
{
$hd = "".$method." ".$link." ".$protokol."\n";
$hd .= "Content-Length: 0\n\n";
$hd .= "Proxy-Connection: $connection\r\n";
$hd .= "User-Agent: Win98, MSIE\r\n\r\n";
fwrite($fp, $hd);
$line='';
while (!feof($fp))
{
$line .= fgets($fp, 1024);
}
fclose($fp);
}
}
}
?>
Код просто ппц. Я чуть руки не сломал себе. Вообще не могу понять, как ты его писал? Сначала пишем, потом проверяем? Там столько трабл, то можно сделать вывод, что ты толком скрипт и не тестил, тупо отстрочил, а потом "что у меня не работает". Мой тебе совет: перепиши код, не позорься. Столько глупых затей реализовал, совершенно непонятных. Например: нафига при выборе той или иной функции, ты присваивал ей число (1 или 0), потом ещё делал распознание, что там там значит единица, что нолик, когда можно было бы сразу вставлять в отсылку заголовоков полученный результат? В общем, я плакаль. С таким кодом не каждый хочет иметь дело, так что тебе ОЧЕНЬ повезло.
Последний раз редактировалось sNt; 17.07.2009 в 15:58..
|