Файл: klubwm_ru_krutilka/go.php
Строк: 71
<?php
error_reporting(0);
set_time_limit(3000);
ignore_user_abort(1);
header('Content-type: text/plain; charset=utf-8');
if ($_POST) {
preg_match('~^http://(www.)?[0-9a-z.-]+.[a-z]{2,6}[0-9a-zA-Z/?.~&_=/%-:#]*$~', $_POST['url']) or die('Неверно указан адрес!');
if ($_POST['referer'] != '') preg_match('~^http://(www.)?[0-9a-z.-]+.[a-z]{2,6}[0-9a-zA-Z/?.~&_=/%-:#]*$~', $_POST['referer']) or die('Неверно указан реферер!');
if ($_POST['ua'] == '2') $ua = '2';
else if ($_POST['ua'] == '1') $ua = '1';
else $ua = '0';
$min = ctype_digit($_POST['min']) && $_POST['min'] > 0 ? $_POST['min'] : '1';
$max = ctype_digit($_POST['max']) && $_POST['min'] < 100 ? $_POST['max'] : '5';
if ($min >= $max) $max = $min + 4;
file_put_contents('data/cfg.dat', serialize(array('redirect' => $_POST['redirect'] == '1' ? '1' : '0', 'ip' => $_POST['ip'] == '1' ? '1' : '0', 'ua' => $ua, 'url' => $_POST['url'], 'referer' => $_POST['referer'], 'count' => ctype_digit($_POST['count']) && $_POST['count'] < 1000 ? $_POST['count'] : '10', 'min' => $min, 'max' => $max, 'proxy' => $_POST['proxy'] == '1' ? '1' : '0'))) or die('Неудалось сохранить настройки!');
}
$cfg = unserialize(file_get_contents('data/cfg.dat'));
if ($cfg['ua'] == '2') $agent = file('data/mobile_user_agent.dat');
else if ($cfg['ua'] == '1') $agent = file('data/user_agent.dat');
else $agent = array_merge(file('data/mobile_user_agent.dat'), file('data/user_agent.dat'));
if ($cfg['proxy'] == '1') $proxy = file('data/proxy.dat');
if (count($proxy) == 0) $cfg['proxy'] = '0';
$httpheader = array('Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', 'Cache-Control: max-age=0', 'Connection: close', 'Accept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1', 'Accept-Language: ru-RU,ru;q=0.9,en;q=0.8', 'Pragma: no-cache');
for ($n = 0; $n < $cfg['count']; $n++) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, false);
curl_setopt($ch, CURLOPT_URL, $cfg['url']);
if ($cfg['referer'] != '') curl_setopt($ch, CURLOPT_REFERER, $cfg['referer']);
curl_setopt($ch, CURLOPT_USERAGENT, trim($agent[array_rand($agent)]));
if ($cfg['ip'] == '1') $httpheader[] = 'X-Forwarded-For: '.mt_rand(1, 255).'.'.mt_rand(1, 255).'.'.mt_rand(1, 255).'.'.mt_rand(1, 255);
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
if ($cfg['proxy'] == '1' && count($proxy) > 0) {
$proxy_rand = array_rand($proxy);
curl_setopt($ch, CURLOPT_PROXY, trim($proxy[$proxy_rand]));
}
$result = curl_exec($ch);
if (!$result) {
if ($cfg['proxy'] == '1' && count($proxy) > 0) unset($proxy[$proxy_rand]);
} else if ($cfg['redirect'] == '1') {
for ($i = 0; $i < 3; $i++) {
$redirect = preg_match_all('~Location:[s]*([^rn]+)~i', $result, $url);
if (!$redirect) $redirect = preg_match_all('~url[s]*=[s]*([^"]+)~i', $result, $url);
if (!$redirect) break;
$url = parse_url(array_pop($url[1]));
$last_url = parse_url(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL));
curl_setopt($ch, CURLOPT_URL, ($url['scheme'] ? $url['scheme'] : $last_url['scheme']).'://'.($url['host'] ? $url['host'] : $last_url['host']).($url['path'] ? $url['path'] : $last_url['path']).($url['query'] ? '?'.$url['query'] : ''));
curl_setopt($ch, CURLOPT_REFERER, $last_url['scheme'].'://'.$last_url['host'].$last_url['path'].($last_url['query'] ? '?'.$last_url['query'] : ''));
preg_match_all('~Set-Cookie:[s]*([^;rn]+)~i', $result, $cookie);
if (count($cookie[1]) > 0) curl_setopt($ch, CURLOPT_COOKIE, implode('; ', $cookie[1]));
$result = curl_exec($ch);
}
}
curl_close($ch);
sleep(mt_rand($cfg['min'], $cfg['max']));
}
if ($cfg['proxy'] == '1') file_put_contents('data/proxy.dat', implode('', $proxy));
die('Накрутка закончена!');
?>