
16.07.2009, 15:53
|
|
Постоянный
Регистрация: 02.07.2008
Сообщений: 472
С нами:
9399011
Репутация:
444
|
|
вобще делаю скрипт накрутки хостов. но он чегото не работает, я вроде всё сделал правильно. в чём ошибка? поправте пожалуйста!
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=\"index.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=\"1\">GET</option>\r\n
<option value=\"2\">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=\"protoko\">\r\n
<option value=\"1\">HTTP/1.0</option>\r\n
<option value=\"2\">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=\"1\">Close</option>\r\n
<option value=\"2\">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\" 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 = intval( $_POST['method'] );
$protokol = intval( $_POST['protokol'] );
$connection = intval( $_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
{
$hd = "{$method} http://{$link} {$protokol}\r\n";
$hd .= "Host: {$host}\r\n";
$hd .= "Proxy-Connection: {$connection}\r\n";
$hd .= "User-Agent: {$a}\r\n\r\n";
$p = explode( ":", $p );
$sock = trim( $p['0'] );
$port = trim( $p['1'] );
if ( empty( $sock ) || empty( $port ) )
{
}
else
{
$fo = fsockopen( $sock, $port, $er1, $er2, $time );
fputs( $fo, $hd );
}
}
}
$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 );
}
?>
|
|
|