85 lines
3.4 KiB
PHP
85 lines
3.4 KiB
PHP
|
<?php
|
||
|
$_SERVER['SERVER_NAME']='tk-ligat.ru';
|
||
|
require_once('/home/cloud/core/set/tk-ligat.ru.php');
|
||
|
require_once('/home/cloud/core/api/php/db.php');
|
||
|
require_once('/home/cloud/core/api/php/json.php');
|
||
|
|
||
|
function findtxt($txt, $str){
|
||
|
$pos1 = stripos($txt, $str);
|
||
|
if ($pos1 === false) return 0;
|
||
|
else
|
||
|
return 1;
|
||
|
}
|
||
|
|
||
|
function leopak ($text) {
|
||
|
$old1 = array("http://market.leopak.ru");
|
||
|
$new1 = array("");
|
||
|
$text = str_replace($old1, $new1, $text);
|
||
|
return $text;
|
||
|
}
|
||
|
|
||
|
|
||
|
function add_link($html){
|
||
|
preg_match_all("/<[Aa][\s]{1}[^>]*[Hh][Rr][Ee][Ff][^=]*=[ '\"\s]*([^ \"'>\s#]+)[^>]*>/", $html, $matches);
|
||
|
$urls = $matches[1]; // Берём то место, где сама ссылка (благодаря группирующим скобкам в регулярном выражении)
|
||
|
/* Выводим все ссылки */
|
||
|
for ($j = 0; $j < count($urls); $j++){
|
||
|
unset($a);
|
||
|
$a['link']=$urls[$j];
|
||
|
if ( findtxt ( $urls[$j], 'https://market.leopak.ru' )==0 )
|
||
|
$link = 'https://market.leopak.ru' . $urls[$j];
|
||
|
else
|
||
|
$link=$urls[$j];
|
||
|
$link=leopak($link);
|
||
|
$id=DB::getValue("SELECT `id` FROM `donorLinks` WHERE `link`=?", $link);
|
||
|
if (!$id && findtxt($link, 'yandex.ru')==0) DB::add("INSERT INTO `donorLinks` (`link`) VALUES(?)", $link);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function get_page($link){
|
||
|
$agent = 'Mozilla/5.0 (compatible; YandexBot/3.0)';
|
||
|
if (findtxt($link, 'ruhtttp')==0){
|
||
|
$ch = curl_init($link);
|
||
|
curl_setopt($ch, CURLOPT_REFERER, 'https://www.samsonopt.ru');
|
||
|
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
|
||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||
|
$dir = dirname(__FILE__);
|
||
|
$config['cookie_file'] = $dir . '/cookies/' . md5(@$_SERVER['REMOTE_ADDR']) . '.txt';
|
||
|
curl_setopt($ch, CURLOPT_COOKIEFILE, $config['cookie_file']);
|
||
|
curl_setopt($ch, CURLOPT_COOKIEJAR, $config['cookie_file']);
|
||
|
curl_setopt($ch, CURLOPT_COOKIE, "PMBC=96152e8e9a0168a731539c5e52c6b39a; PHPSESSID=jl0i13pn3157qca807jgp0jqa7; ServerName=WoW+Circle+3.3.5a+x5; serverId=1");
|
||
|
// curl_setopt($ch, CURLOPT_PROXY, 'localhost:9050'); // Use if proxy have username and password
|
||
|
// curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
|
||
|
$response_data['html'] = curl_exec($ch);
|
||
|
$http_code = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
|
||
|
$response_data['code']=$http_code;
|
||
|
curl_close($ch);
|
||
|
return $response_data;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
function gp($number){
|
||
|
$arr = array('1','2','3','4','5','6','7','8','9','0');
|
||
|
$pass = "";
|
||
|
for($i = 0; $i < $number; $i++){
|
||
|
$index = rand(0, count($arr) - 1);
|
||
|
$pass .= $arr[$index];
|
||
|
}
|
||
|
return $pass;
|
||
|
}
|
||
|
//shestakov-tc
|
||
|
for ($i=0; $i<5000; $i++){
|
||
|
$link = 'https://market.leopak.ru/products/' . strval(gp(rand(1, 6))) . '-' . strval(gp(rand(1, 6)));
|
||
|
$m=get_page($link);
|
||
|
//Узнаем код, если 200 - смотрим, есть ли ссылка в БД, если нет - добавляем
|
||
|
if ($m['code']==200){
|
||
|
$id=DB::getValue("SELECT `id` FROM `donorLinks` WHERE `link`=?", $link);
|
||
|
if (!$id)DB::add("INSERT INTO `donorLinks` (`link`, `html`, `code`) VALUES (?, ?, ?)", array($link, base64_encode ( gzcompress ( $m['html'], 9) ), $m['code'] ) );
|
||
|
add_link($m['html']);
|
||
|
}
|
||
|
sleep(1);
|
||
|
}
|
||
|
|
||
|
//exec ("php /home/cloud/core/parcer/s2.php &");
|
||
|
?>
|