View file sea/search.php

File size: 6.35Kb
<?
#-----------------------------------------------------#
#     ============ЗАГРУЗ-ЦЕНТР=============           #
#             	 Автор  :  Sea                   	  #
#               E-mail  :  [email protected]              #
#                  ICQ  :  355152215                   #
#   Вы не имеете права распространять данный скрипт.  #
#   		По всем вопросам пишите в ICQ.            #
#-----------------------------------------------------#
include 'moduls/ini.php';
include 'moduls/head.php';
include 'moduls/fun.php';
include 'moduls/connect.php';
include 'moduls/header.php';
###############Если поиск выключен###############
if($setup['search_change'] == 0) die("Not found");
###############Проверка переменных###############
$onpage = get2ses('onpage');
$prew   = get2ses('prew');
$sort   = get2ses('sort');
is_num($id,'id');
is_num($onpage,'onpage');
is_num($page,'page');
is_num($prew,'prew');
if(!isset($prew) or $prew != 0 and $prew != 1) $prew = $setup['preview'];
###############Форма ввода слова###############
if(!$_GET['act'])
{
echo "
<div class=\"mblock\"><img src='dis/s.png' alt=''> Поиск файлов</div><div class=\"mainzag\">
<form name=\"sfiles\" action=\"search.php?act=search\" method=\"post\">
Введите часть имени файла<br/>
или имя файла целиком:</div><div class=\"row\">
<input class=enter name=\"word\" type=\"text\" maxlength=\"20\" value=\"\"><br/><br>
<input class=buttom type=\"submit\" value=\"Поиск!\">
</form></div><div class=\"iblock\">
<a href='index.php'>Загрузки</a> <br/>
<a href='$setup[site_url]'>На главную</a><br>
</div>";
include 'moduls/foot.php';
}
###############Проверка переменных###############
if($_GET['act']=="search")
{
	if($word=="") die ("Ошибка.Не заполнено поле.");
	$word = cut($word,15);
	$word = del($word);
	$word = clean($word);
	$word_search_query = mysql_query("SELECT * FROM `files` WHERE `name` LIKE '%".$word."%' AND `size` > '0'");
	$i = 0;
	while($result = mysql_fetch_array($word_search_query)) $array_id[] = $result['id'];
	$all = count($array_id);
	if(!isset($page)) $page=1;
	$n = 0;
	$pages = ceil($all/$onpage);
	if(!$pages) $pages = 1;
	if ($page) $n = ($onpage*$page)-$onpage;
	echo "<div class=\"mblock\"><img src='dis/in.png' alt=''>По запросу \"$word\" найдено $all файла(ов)</div>";
	if ($all == 0) echo "По запросу ничего не найдено :(";
	for ($i = 1; $i<=$onpage; $i++)
	{
		if (!isset($array_id[$n]))
		{
			$n++;
			continue;
		}
		if(is_integer($n / 2)) $row = "<div class='row'>"; else $row = "<div class='mainzag'>";
		$file_info = mysql_fetch_array(mysql_query("SELECT * FROM `files` WHERE `id` = '".$array_id[$n]."'"));
		$backdir = @mysql_fetch_array(mysql_query("SELECT * FROM `files` WHERE `path` = '".$file_info['infolder']."'"));
		$basename = basename($file_info['path']);
		$ex = pathinfo($file_info['path']);
		$ex = $ex['extension'];
		$ext = strtolower($ex);
		$name_file = str_replace(".".$ex,"",$basename);
		//Транслит
		if(strpos($basename , "!") !== false) $name_file = trans($name_file);
		if(strpos($basename , "!") === false) $name_file = trans2($name_file);
		//Красивый размер
		if($file_info['size'] < 1024) $file_info['size'] = "(".$file_info['size']."b)";
		if($file_info['size'] < 1048576 and $file_info['size'] >= 1024) $file_info['size'] = "(".round($file_info['size']/1024, 2)."Kb)";
		if($file_info['size'] > 1048576) $file_info['size'] = "(".round($file_info['size']/1024/1024, 2)."Mb)";
		//Новизна файла
		$new_info="";
		$filtime2 = $file_info['timeupload']+(3600*24*$setup['day_new']);
		if($filtime2>=$time){ $new_info = "[<font color=#FFFF00>New</font>]";}
		//Предосмотр
		$pre = "";
		if ($prew==1)
		{
			if ($ext == 'bmp') $pre = "Предосмотр невозможен <br/>";
			if ($ext == 'gif' or $ext == 'jpeg' or $ext == 'jpg' or $ext == 'png') $pre = "<img style='margin: 1px;' src='im.php?id=".$file_info['id']."' alt=\"\"/> <br/>";
		}
		//Иконка к файлу
		if(!file_exists("ext/$ext.png")) $ico = "<img src='ext/stand.png' alt=''>"; else $ico = "<img src='ext/$ext.png' alt=''>";
		if($setup['ext']==1) $extension = "($ex)"; else $extension = '';
//Собсвенно вывод
	 	echo $row;
		echo "$pre ".$ico."<a href='view.php?id=".$file_info['id']."'><b>".$name_file."</b></a>".$extension.$file_info['size']."[<a href='index.php?id=$backdir[id]'>В категорию</a>]<br/>";
		echo "</div>";
		$n++;
	}
	//------------------------------------------------------------------------------------------
	echo "</div><div class=iblock>Страницы: ";
	$asd= $page - 2;
	$asd2= $page + 3;
	if($asd<$all && $asd>0 && $page>3) echo "<a href=\"search.php?act=search&amp;page=1&amp;onpage=$onpage&amp;prew=$prew&amp;word=$word\">1</a> ... ";
	for($i=$asd; $i<$asd2;$i++)
	{
		if($i<$all && $i>0)
			{
				if ($i > $pages )  break;
				if ($page==$i) 	echo "<b>[$i]</b> ";
                else echo "<a href=\"search.php?act=search&amp;page=$i&amp;onpage=$onpage&amp;prew=$prew&amp;word=$word\">$i</a> ";
            }
	}
	if ($i <= $pages)
	{
		if($asd2<$all) echo " ... <a href=\"search.php?act=search&amp;page=$pages&amp;onpage=$onpage&amp;prew=$prew&amp;word=$word\">$pages</a>";
	}
	echo "<br/>";
	//------------------------------------------------------------------------------------------
	if ($pages>$setup['pagehand'] and $setup['pagehand_change'] == 1)
	{
 		echo "Страница $page из $pages:<br/>";
 		echo '<form action="search.php?act=search&amp;word='.$word.'" method="post">';
 		echo '<input class=enter name="page" type="text" maxlength="4" size="8" value="">';
 		echo '&nbsp;<input class=buttom type="submit" value="Перейти">';
 		echo '</form>';
	}
	//------------------------------------------------------------------------------------------
	echo "</div><div class=iblock>";
	//------------------------------------------------------------------------------------------
	echo "- <a href=\"index.php?onpage=$onpage&amp;prew=$prew\">Загрузки</a><br/>
- <a href=\"$site_url\">На главную</a></div>";
	include 'moduls/foot.php';
}
?>