Файл: ka4ka/install.php
Строк: 73
<?
set_time_limit(0);
include 'sys/bd.php';
include 'sys/func.php';
include 'sys/conf.php';
include 'head.php';
switch($_GET['m']){
default:
echo '<div id="cont">
<div id="raz">Шаг 1</div>
<div id="con">Начало парсинга в мускул. </div>';
$q = @mysql_query('SELECT id FROM parser');
if($q) {
echo '<div id="links">
<a href="'.$domain.'install.php?m=pars">Панеслась душа в рай</a>
</div>';
}else{
echo '<div id="con"><b>ЭЙ РУКОЖОП ! ТАБЛИЦЫ ЗАЛЕЙ ТО, А ПОТОМ ИНСТАЛ ЗАПУСКАЙ....</b></div>';
}
echo '</div>';
break;
case 'pars':
echo '<div id="cont">
<div id="raz">Шаг 2</div>';
$q = @mysql_query('SELECT id FROM parser');
if($q) {
for ($x=0; $x++<700;)
{
ini_set('display_errors',0); ini_set ('register_globals', 0);
session_name('SID'); session_start();
$host= 'ka4ka.ru'; $path='/info/anekdots/index.php/?page='.$x.'';
$fp=fsockopen($host,80,$errno, $errstr,10);
if(!$fp) { echo "$errstr ($errno)<br/>n"; }else{
$data = "";$post=0; foreach($_POST as $key=>$value){
$post=1; $data.="&$key=$value";} if($data)$data=substr ($data,1);
if($post) $headers = "POST $path HTTP/1.0rn";else
$headers = "GET $path HTTP/1.0rn"; $headers.= "Host: $hostrn";
$headers.= "Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif,image/x-bitmap, */*;q=0.1rn";
$headers.= "Accept-Charset: utf-8;q=0.6 windows-1251;q=0.1*;q=0.1rn";
$headers.= "Accept-Encoding: utf-8rn";
$headers.= "Accept-Language: ru, en;q=0.9rn";
$headers.= "User-Agent: ".$_SERVER ['HTTP_USER_AGENT']."rn";
if($post){ $headers.= "Content-type: application/x-www-form-urlencodedrn";
$headers.= "Content-Length: ".strlen ($data)."rn";
$headers.= "rn"; $headers.= $data;}else $headers.="rn";
@fwrite($fp, $headers); while($filez != "rn") $filez = @fgets($fp, 128);
$filez = ''; while(!feof($fp)) $filez.= @fgets($fp, 4096); @fclose($fp); }
preg_match_all('#<div class="item-no-marker">(.*)<b style="#sU', $filez, $anek);
$anek[1] =preg_replace('|<(.*?)>|is', '',$anek[1]);
if($anek[1]){
for($is = 0; $is<count($anek[1]); $is++)
{
$logs = mysql_fetch_array(mysql_query('select * from `parser` where `text` = "'.mysql_real_escape_string($anek[1][$is]).'" limit 1'));
if($logs != 0) {
$err = true;
echo '<div id="con"><b>Есть '.$anek[1][$is].'</b></div>';
}else{
mysql_query("INSERT INTO `parser` SET
`text` = '".mysql_real_escape_string($anek[1][$is])."',
`date` = '".time()."'
");
echo '<div id="con"><b>Добавлено в БД '.$anek[1][$is].'</b></div>';
}}
}}
echo '</div>';
}else{
echo '<div id="con"><b>ЭЙ РУКОЖОП ! ТАБЛИЦЫ ЗАЛЕЙ ТО, А ПОТОМ ИНСТАЛ ЗАПУСКАЙ....</b></div>
</div>';
}
}
include 'foot.php';
?>