Файл: search.php
Строк: 154
<?php
#-----------------------------------------------------#
# ============ЗАГРУЗ-ЦЕНТР============= #
# Автор : Sea #
# E-mail : x-sea-x@ya.ru #
# ICQ : 355152215 #
# Вы не имеете права распространять данный скрипт. #
# По всем вопросам пишите в ICQ. #
#-----------------------------------------------------#
// mod Gemorroj
require 'moduls/config.php';
require 'moduls/header.php';
###############Если поиск выключен###############
if (!$setup['search_change']) {
error('Not found');
}
###############Проверка переменных###############
$title .= $_SESSION['language']['search'];
$out = '';
$banner='';
$onpage = get2ses('onpage');
if ($onpage < 3) {
$onpage = $setting['onpage'];
}
$prew = get2ses('prew');
if ($prew != 0 && $prew != 1) {
$prew = $setup['preview'];
}
$id = isset($_GET['id']) ? abs($_GET['id']) : 0;
$page = isset($_GET['page']) ? abs($_GET['page']) : 1;
if ($page < 1) {
$page = 1;
}
$Reklames = new Reklames(); // Создаем экземпляр класса Reklames
$banner.= $Reklames->Bottom();
$banner.=$Reklames->Banner();
###############Проверка переменных###############
if (isset($_GET['act'])) {
if ($_REQUEST['word'] == '') {
error($_SESSION['language']['do not fill in the required fields'],$banner);
}
$word = mysql_real_escape_string($_REQUEST['word'], $mysql);
$start = ($onpage * $page) - $onpage;
if(!empty($_GET['cat'])){
$result=mysql_result(mysql_query("SELECT `path` FROM `files` WHERE `id`='".(int)@$_GET['cat']."' LIMIT 1",$mysql),0);
$nomm='`t1`.`path` LIKE "'.$result.'%" AND ';
}else{
$nomm='';
}
if ($_SESSION['langpack'] == 'russian') {
$sql = mysql_query('
SELECT SQL_CALC_FOUND_ROWS `t1`.`id`,
`t1`.`dir`,
`t1`.`dir_count`,
`t1`.`path`,
`t1`.`infolder`,
`t1`.`rus_name` AS `name`,
`t1`.`size`,
`t1`.`loads`,
`t1`.`timeupload`,
`t1`.`yes`,
`t1`.`no`,
`t2`.`id` AS `back`
FROM `files` AS `t1`
LEFT JOIN `files` AS `t2` ON `t2`.`path` = `t1`.`infolder`
WHERE '.$nomm.'`t1`.`rus_name` LIKE "%' . str_replace(array('%', '_'), array('%', '_'), $word) . '%" AND `t1`.`hidden` = "0" AND `t1`.`dir`="0" AND `t1`.`fileid`="0"
LIMIT ' . $start . ', ' . $onpage,
$mysql);
} else {
$sql = mysql_query('
SELECT SQL_CALC_FOUND_ROWS `t1`.`id`,
`t1`.`dir`,
`t1`.`dir_count`,
`t1`.`path`,
`t1`.`infolder`,
`t1`.`name`,
`t1`.`size`,
`t1`.`loads`,
`t1`.`timeupload`,
`t1`.`yes`,
`t1`.`no`,
`t2`.`id` AS `back`
FROM `files` AS `t1`
LEFT JOIN `files` AS `t2` ON `t2`.`path` = `t1`.`infolder`
WHERE '.$nomm.'`t1`.`name` LIKE "%' . str_replace(array('%', '_'), array('%', '_'), $word) . '%" AND `t1`.`hidden` = "0" AND `t1`.`dir`="0" AND `t1`.`fileid`="0"
LIMIT ' . $start . ', ' . $onpage,
$mysql);
}
$all = mysql_result(mysql_query('SELECT FOUND_ROWS();', $mysql), 0);
$out.='<div class="mainzag">' . $_SESSION['language']['find files'] . '</div>';
if ($onpage) {
$pages = ceil($all / $onpage);
if (!$pages) {
$pages = 1;
}
} else {
$pages = 1;
}
$out.= $Reklames->Top();
$out .= '<div class="row"><img src="' . DIRECTORY . 'dis/load.png" alt=""/> ' . str_replace(array('%word%', '%all%'), array(htmlspecialchars($word, ENT_NOQUOTES), $all), $_SESSION['language']['upon request']) . '</div>';
if (!$all) {
$out .= '<div class="row2">' . $_SESSION['language']['your search found nothing'] . '</div>';
}
$bool = true;
$new = 86400 * $setup['day_new'];
while ($v = mysql_fetch_assoc($sql)) {
$bool != $bool;
if ($bool) {
$out .= '<div class="row">';
} else {
$out .= '<div class="row2">';
}
if ($v['dir']) {
//Иконка к папке
if (file_exists($v['path'] . 'folder.png')) {
$out .= '<img src="' . DIRECTORY . htmlspecialchars($v['path']) . 'folder.png" alt=""/>';
} else {
$out .= '<img src="' . DIRECTORY . 'ext/dir.png" alt=""/>';
}
$out .= ' <a href="' . DIRECTORY . $v['id'] . '">' . htmlspecialchars(str_ireplace($word, '<span class="yes">' . $word . '</span>', $v['name']), ENT_NOQUOTES) . '</a>(' . $v['dir_count'] . ')<br/></div>';
} else {
$ext = strtolower(pathinfo($v['path'], PATHINFO_EXTENSION));
//Новизна файла
if (($v['timeupload'] + $new) >= $_SERVER['REQUEST_TIME'] && $setup['day_new']) {
$new_info = ' <span class="yes">' . $_SESSION['language']['new'] . '</span>';
} else {
$new_info = '';
}
//Красивый размер
$v['size'] = '(' . size($v['size']) . ')';
//Предосмотр
$pre = '';
if ($prew) {
$prev_pic = str_replace('/', '--', iconv_substr(strstr($v['path'], '/'), 1));
if ($setup['screen_change'] && ($ext == 'gif' || $ext == 'jpeg' || $ext == 'jpg' || $ext == 'png' || $ext == 'bmp')) {
if (file_exists($setup['picpath'] . '/' . $prev_pic . '.gif')){
$pre .= '<img style="margin: 1px;" src="' . DIRECTORY . $setup['picpath'] . '/' . htmlspecialchars($prev_pic) . '.gif" alt=""/><br/>';
} else {
$pre .= '<img style="margin: 1px;" src="' . DIRECTORY . 'im/' . $v['id'] . '" alt=""/><br/>';
}
} else if ($setup['screen_change'] && ($ext == 'avi' || $ext == '3gp' || $ext == 'mp4' || $ext == 'flv') && extension_loaded('ffmpeg')) {
$wh = explode('*', $setup['prev_size']);
if (file_exists($setup['ffmpegpath'] . '/' . $prev_pic . '_frame_' . $setup['ffmpeg_frame'] . '.gif')) {
$pre .= '<img style="margin: 1px; width:' . $wh[0] . '; height:' . $wh[1] . ';" src="' . DIRECTORY . $setup['ffmpegpath'] . '/' . htmlspecialchars($prev_pic) . '_frame_' . $setup['ffmpeg_frame'] . '.gif" alt=""/><br/>';
} else {
$pre .= '<img style="margin: 1px; width:' . $wh[0] . '; height:' . $wh[1] . ';" src="' . DIRECTORY . 'ffmpeg/' . $v['id'] . '" alt=""/><br/>';
}
} else if($setup['screen_change'] && ($ext == 'thm' || $ext == 'nth' || $ext == 'utz' || $ext == 'sdt' || $ext == 'scs')) {
if (file_exists($setup['tpath'] . '/' . $prev_pic . '.gif')) {
$pre .= '<img style="margin: 1px;" src="' . DIRECTORY . $setup['tpath'] . '/' . htmlspecialchars($prev_pic) . '.gif" alt=""/><br/>';
} else if ($setup['swf_change'] && file_exists($setup['tpath'] . '/' . $prev_pic . '.gif.swf')) {
$pre .= '<object style="width:128px; height:128px;"><param name="movie" value="' . DIRECTORY . $setup['tpath'] . '/' . htmlspecialchars($prev_pic) . '.gif.swf"><embed src="' . DIRECTORY . $setup['tpath'] . '/' . htmlspecialchars($prev_pic) . '.gif.swf" style="width:128px; height:128px;"></embed></param></object><br/>';
} else if (!file_exists($setup['tpath'] . '/' . $prev_pic . '.gif.swf')) {
$pre .= '<img style="margin: 1px;" src="' . DIRECTORY . 'theme/' . $v['id'] . '" alt=""/><br/>';
}
} else if ($setup['jar_change'] && $ext == 'jar') {
if (file_exists($setup['ipath'] . '/' . $prev_pic . '.png')) {
$pre .= '<img style="margin: 1px;" src="' . DIRECTORY . $setup['ipath'] . '/' . htmlspecialchars($prev_pic) . '.png" width="16" height="16" alt=""/>';
} else if (jar_ico($v['path'], $setup['ipath'] . '/' . $prev_pic . '.png')) {
$pre .= '<img style="margin: 1px;" src="' . DIRECTORY . $setup['ipath'] . '/' . htmlspecialchars($prev_pic) . '.png" width="16" height="16" alt=""/>';
}
} else if ($setup['apk_change'] && $ext == 'apk') {
if (file_exists($setup['apkpath'] . '/' . $prev_pic . '.png')) {
$pre .= '<img style="margin: 1px;" src="' . DIRECTORY . $setup['apkpath'] . '/' . htmlspecialchars($prev_pic) . '.png" width="16" height="16" alt=""/>';
} else if (apk_ico($v['path'], $setup['apkpath'] . '/' . $prev_pic . '.png')) {
$pre .= '<img style="margin: 1px;" src="' . DIRECTORY . $setup['apkpath'] . '/' . htmlspecialchars($prev_pic) . '.png" width="16" height="16" alt=""/>';
}
} else if ($setup['swf_change'] && $ext == 'swf') {
$pre .= '<object style="width:128px; height:128px;"><param name="movie" value="' . DIRECTORY . htmlspecialchars($v['v']) . '"><embed src="' . DIRECTORY . htmlspecialchars($v['v']) . '" style="width:128px; height:128px;"></embed></param></object><br/>';
}
}
//Иконка к файлу
if (!$pre && file_exists('ext/' . $ext . '.png')) {
$ico = '<img src="' . DIRECTORY . 'ext/' . $ext . '.png" alt=""/> ';
} elseif(!$pre && !file_exists('ext/' . $ext . '.png')) {
$ico = '<img src="' . DIRECTORY . 'ext/stand.png" alt=""/> ';
}elseif($pre && file_exists('ext/' . $ext . '.png')){
$ico = '';
}
//Собсвенно вывод
$out .= $pre . ' ' . $ico . ' <a href="' . DIRECTORY . 'view/' . $v['id'] . '">' . str_ireplace(htmlspecialchars($word, ENT_NOQUOTES), '<span class="yes">' . htmlspecialchars($word, ENT_NOQUOTES) . '</span>', htmlspecialchars($v['name'], ENT_NOQUOTES)) . '</a> ' .$v['size'] . $new_info.'</div>';
}
}
//------------------------------------------------------------------------------------------
$word = rawurlencode($_REQUEST['word']);
if ($pages > 1) {
if(!empty($_GET['cat'])) $cate=(int)@$_GET['cat'].'/'; else $cate='';
$out .= '<div class="row">' . $_SESSION['language']['pages'] . ': ';
$asd = $page - 2;
$asd2 = $page + 3;
if ($asd < $all && $asd > 0 && $page > 3) {
$out .= '<a href="' . DIRECTORY . 'search/1/' . $onpage . '/' . $prew . '/' . $cate . $word . '">1</a> ... ';
}
for ($i = $asd; $i < $asd2; ++$i) {
if ($i < $all && $i > 0) {
if ($i > $pages) {
break;
}
if ($page == $i) {
$out .= '<strong>' . $i . '</strong>, ';
} else {
$out .= '<a href="' . DIRECTORY . 'search/' . $i . '/' . $onpage . '/' . $prew . '/' . $cate . $word . '">' . $i . '</a>, ';
}
}
}
if ($i <= $pages) {
if ($asd2 < $all) {
$out .= ' ... <a href="' . DIRECTORY . 'search/' . $pages . '/' . $onpage . '/' . $prew . '/' . $cate . $word . '">' . $pages . '</a>';
}
}
$out .= '<br/></div>';
}
$out .= '<div class="foot"><a href="' . DIRECTORY . '">' . $_SESSION['language']['downloads'] . '</a> |</div>';
} else {
$cate = isset($_GET['cat']) ? '&cat='.int($_GET['cat']) : $cate='';
// Форма ввода слова
$out .= '<form action="' . DIRECTORY . 'search.php?act=search'.$cate.'" method="post"><div class="row">' . $_SESSION['language']['enter the name of the file you are'] . '</div><div class="row"><input class="enter" name="word" type="text"/> <input class="buttom" type="submit" value="' . $_SESSION['language']['go'] . '"/></div></form>
<div class="foot"><a href="' . DIRECTORY . '">' . $_SESSION['language']['downloads'] . '</a> |</div>';
}
echo $out.$banner;
require 'moduls/foot.php';
?>