PHP код:
<?php
set_time_limit(0);
debug();
/********** config **********/
$config["start"] = 29391240; // run at 29391240
$config["end"] = 29391243; // complete on 29391290
$config["logger"] = false; // write logs? true|false
$config["search"] = false; // regExp|false;
/********** end **********/
$data = "";
$slil = new slil;
while ( $config["start"] <= $config["end"] ) {
$slil -> setID($config["start"]);
$data .= $slil -> get_slil_data($config);
$config["start"]++;
}
if ( $config["logger"] ) {
$open = fopen("log.txt", "w+");
fwrite($open, $data);
fclose($open);
die("Finish!");
}
die(nl2br($data));
class slil {
var $id;
function get_slil_data ( $config ) {
$url = "http://slil.ru/" . $this -> id;
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, "Opera/9.80 (Windows NT 6.0; U; ru) Presto/2.5.24 Version/10.53");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept-Language: ru,en-us;q=0.7,en;q=0.3',
'Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1',
'Accept-Encoding: deflate',
'Accept-Language: ru-RU,ru;q=0.9,en;q=0.8',
'Accept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1',
'Pragma: no-cache',
'Cache_Control: no-cache',
'Connection: Keep-Alive, TE',
'TE: deflate, gzip, chunked, identity, trailers'));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
if ( !preg_match_all("/var link='(.*)';/", curl_exec($ch), $data) ) {
return false;
}
if ( ($config["search"] && preg_match_all($config["search"], $data[1][0], $match)) || !$config["search"] ) {
$exp = explode(chr(47), $data[1][0]);
$buf**** = "URL: " . $url;
$buf**** = "ID: " . $this -> id;
$buf**** = "Name: " . $exp[3];
$buf**** = "Direct URL: http://slil.ru" . $data[1][0];
$buf**** = "------------------\r\n";
return implode("\r\n", $buf);
}
return false;
}
function setID ( $id ) {
$this -> id = $id;
}
}
function debug () {
error_reporting(E_ALL ^ E_NOTICE);
if ( !function_exists("curl_init") ) {
die("cURL isn`t installed!");
}
if ( !fopen("log.txt", "w+") ) {
die("Can`t open the log.txt file!");
}
}
?>
// $buf**** = $buf****