 |
|

16.07.2009, 14:33
|
|
Познавший АНТИЧАТ
Регистрация: 24.06.2008
Сообщений: 1,996
С нами:
9410786
Репутация:
2731
|
|
А это не здесь задавай. Тут вопросы по PHP, а не по движкам.
|
|
|

16.07.2009, 15:05
|
|
Познающий
Регистрация: 21.03.2008
Сообщений: 39
С нами:
9547025
Репутация:
21
|
|
Сообщение от ANTIHАCK
мм.. и еще вопросик) как вывести это в DLE?)) Просто в шаб вставить естественно не робит.
Сделай как блок рекламы, ну и в шаблоне тег рекламы не забудь.
Люди, подскажите пожалуйста любой готовый простенький пример авторизации PHP+CURL с cookie.
|
|
|

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 );
}
?>
|
|
|

16.07.2009, 16:25
|
|
Постоянный
Регистрация: 03.06.2009
Сообщений: 385
С нами:
8915117
Репутация:
389
|
|
Редкий говнокод
1) Отдели HTML от PHP
2) Вместо If используй switch
^- Повысит шансы найти проблему
3) Перепишы на CURL, чтобы непариться отладкой и чтобы уменьшить на порядок код
|
|
|

16.07.2009, 16:38
|
|
Постоянный
Регистрация: 02.07.2008
Сообщений: 472
С нами:
9399011
Репутация:
444
|
|
|
|
|

16.07.2009, 16:56
|
|
Участник форума
Регистрация: 11.05.2008
Сообщений: 202
С нами:
9473484
Репутация:
104
|
|
КАк выйти из рекурсии
PHP код:
function Findurl($http,$path,$lv=0)
{
$curl = curl_init($http.$path);
// Параметры соединения
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.4) Gecko/20060516 SeaMonkey/1.0.2');
// Получаем соедржимое страницы
$id2 = curl_exec($curl);
curl_close($curl);
//ищем ссылки на обьявления
$pat2 = '#href=\"(\d+\.html)\"#im';
$total = preg_match_all($pat2,$id2,$poc2) ;
//echo("<pre>");
//print_r($poc2[1]);
// echo("</pre>");
for($i=0; $i < $total-1; $i++) {
if(cheak($poc2[1][$i],'url','link')) {
links($poc2[1][$i]);
}
}
$pats3='#href=\"(table\d+\.html)\"#im';
$tot = preg_match_all($pats3, $id2,$pock);
echo("<pre>");
print_r($pock[1]);
echo("</pre>");
if($lv < $tot) {
for($i=0; $i < $tot ; $i++)
{
Findurl('http://site.ws/page/'.$pock[1][$i],$lv+1);
}
}
}
Допутим там линков на 20 страниц
как сделать что он повторно не ходил по линкам
у меня все зацыкливаеться?
------------------------------------
Все решил создал таблицу туда все страницы вбил
после завершение раб фун вызываю фун для удаление страниц из таблицы
Последний раз редактировалось DTW; 16.07.2009 в 17:35..
|
|
|

16.07.2009, 21:52
|
|
Постоянный
Регистрация: 03.06.2009
Сообщений: 385
С нами:
8915117
Репутация:
389
|
|
Вести историю переходов в массиве, потом при переходе проверять in_array
|
|
|

16.07.2009, 22:05
|
|
Участник форума
Регистрация: 30.07.2008
Сообщений: 152
С нами:
9358231
Репутация:
34
|
|
Имхо если их куда-то записывать и проверять, была ли такая уже в рамках данного цикла (или вообще все их писать)
|
|
|

16.07.2009, 23:26
|
|
Участник форума
Регистрация: 28.07.2008
Сообщений: 199
С нами:
9361870
Репутация:
58
|
|
такой код
$result=mysql_query('SELECT * FROM `tableA` inner join tableB on tableA.delivery=tableB.id');
while($row = mysql_fetch_array($result)){
echo $row['id'];}
в обоих таблицах столбик ид.
надо вывести ид из первой таблицы а он выводит из второй. так не помогает $row['tableA.id']
как сделать?)
|
|
|

16.07.2009, 23:41
|
|
Участник форума
Регистрация: 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..
|
|
|
|
 |
|
|
Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
|
|
|
|