Файл: public_html/ex/search.php
Строк: 91
<?php
require_once('functions.php');
require 'config.php';
$title = 'Поиск';
require_once('head.php');
function find_files($str){
if(preg_match('#По вашему запросу ничего не найдено#si', $str)){
return false;
}else{
return true;
}
}
function fined_files($str){
preg_match('#Найдено <b>([0-9]+)</b>#si', $str, $c);
return $c[1];
}
function koecurl($url, $post='', $mode=array()) {
$defaultmode = array('charset' => 'utf-8', 'ssl' => 1, 'cookie' => 1, 'headers' => 1, 'useragent' => 'Opera/9.80 (Windows NT 5.1; U; ru) Presto/2.10.229 Version/11.61', 'referer' => 'google.com');
foreach ($defaultmode as $k => $v) {
if (!isset($mode[$k]) ) {
$mode[$k] = $v;
}
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, $mode['headers']);
curl_setopt($ch, CURLOPT_REFERER, $mode['referer']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $mode['useragent']);
curl_setopt($ch, CURLOPT_ENCODING, $mode['charset']);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 200);
if ($post) {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
if ($mode['cookie']) {
curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__).'/sess.txt');
curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__).'/sess.txt');
}
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
if ($mode['ssl']) {
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
}
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
echo '<div class="phdr">Поиск</div>';
echo '<div class="menu">
<form action="search.php" method="get">
Запрос:<br />
<input type="text" name="q" value="'.$_GET['q'].'" /><br />
<select name="type">
<option value="all" selected="selected">Все типы</option>
<option value="1">Картинки</option>
<option value="2">Аудио</option>
<option value="3">Видео</option>
<option value="4">Программы</option>
</select><br />
<select name="where">
<option value="all" selected="selected">По имени и описании</option>
<option value="1">По имени</option>
<option value="2">По описании</option>
</select><br />
<select name="all">
<option value="0">Вся фраза</option>
<option value="2">Одно из слов</option>
</select><br />
18+<input type="checkbox" name="porno" value="1">
<br />
<input type="submit" value="Искать" />
</form>
</div>';
if(isset($_GET['q']) && isset($_GET['where']) && isset($_GET['type']) && isset($_GET['all'])){
$post = array(
'request' => $_GET['q'],
'exwhere' => $_GET['where'],
'extype' => $_GET['type'],
'exall' => intval($_GET['all']),
'porno' => intval($_GET['porno'])
);
$p = isset($_GET['page'])?intval($_GET['page'])*10-10: '';
$text = koecurl('http://7ba.ru/ex/search/'.$p, $post, array('referer' => 'http://7ba.ru/ex', 'ssl' => 0, 'headers' => 1));
if(find_files($text)){
echo '<div class="rmenu"><center><b>Найдено: '.fined_files($text).'</b></center></div>';
preg_match_all('#onclick="location.href='/ex/showfile/(.*?)/(.*?).html';">#si', $text, $href);
preg_match_all('#<div class="shadow">(.*?)</div>#si', $text, $div);
preg_match_all('#class="fileimg" src="(.*?)"/>#si', $text, $img);
preg_match_all('#<a href="(.*?).html">(.*?)</a>((.*?))<br/>#si', $text, $name);
//print_r($div);
for($i=0; $i<count($href[1]); $i++){
preg_match('#<a href="(.*?).html">(.*?)</a>((.*?))<br/>#si', $div[1][$i], $name);
$scr = ($img[1][$i] == 'http://7ba.ru/bbpic.php?file=http://7ba.ru/includes/img/noimage.gif' ? '/'.$papka.'/no_image.png' : $img[1][$i]);
echo '<a href="file/'.$href[1][$i].'"><div class="menu"><img src="'.$scr.'" /><br />
<a href="file/'.$href[1][$i].'">'.$name[2].' ('.$name[3].')</div></a>';
}
$kmess = 10;
$start = isset($_GET['page']) ? intval($_GET['page']) * $kmess - $kmess : 0;
echo '<div class="menu"><table width="100%"><tr>';
$total = (fined_files($text) > 1000 ? 1000 : fined_files($text));
echo '<center>'.pagenav('search.php?q='.htmlspecialchars($_GET['q']).'&where='.$_GET['where'].'&type='.$_GET['type'].'&all='.$_GET['all'].'&porno='.intval($_GET['porno']).'&page=', $start, $total, $kmess).'
</center>';
echo '</tr></table></div>';
}else{
echo '<div class="rmenu">Не найдено!</div>';
}
}
require_once('foot.php');
?>