View file downs/search.php

File size: 3.97Kb
<?php

$title='Поиск файлов';
require"../system/config.php";
require"../system/func";
require"../system/head.php";
require"../system/error.php";

echo'<div class="i">'.$title.'<br></div>';
switch($_GET['act']){
case 'go':
echo'<form action="search.php?" method="get">Введите,что исчите:<br />
<input name="see" type="text" size="18"  class="form" value=""/><br />Искать:<br><select name="g" class="form"><option value="1">В описание</option><option value="2">В название</option></select><br>
<input type="submit" value="Искать" class="but"></form>';
break;
default:
$g=check((int)$_GET['g']);

$see=check($_GET['see']);
if($g==0 or $g=="" or $see==""){echo'Произошла ошибка'; require"../system/foot.php"; exit;}

if($g==1 or $g==2){}else{echo'Произошла ошибка'; require"../system/foot.php"; exit;}


if(isset($_GET['st'])){$st=cifry($_GET['st']);}else{$st=0;}

if(isset($_POST['str'])){$str=cifry($_POST['str']);}else{$str=0;}


if(!empty($str)){$st=$str*10-10;}
if(empty($st) or $st<0){$st=0;}
$num=10;
if($g==1){
$ptt='file';
$adata=mysql_query("SELECT * FROM `down_files` WHERE  `opis` LIKE '%".$see."%' AND `typer`='$ptt'");
$sdata=mysql_query("SELECT * FROM `down_files` WHERE  `opis` LIKE '%".$see."%' AND `typer`='$ptt' ORDER BY `id_file` DESC LIMIT $st,$num");}
if($g==2){

$ptt='file';
$adata=mysql_query("SELECT * FROM `down_files` WHERE  `name` LIKE '%".$see."%' AND `typer`='$ptt'");
$sdata=mysql_query("SELECT * FROM `down_files` WHERE  `name` LIKE '%".$see."%' AND `typer`='$ptt' ORDER BY `id_file` DESC LIMIT $st,$num");}
$kol=mysql_num_rows($adata);

if($st>$kol){echo'Не верный номер страници'; require"../system/foot.php"; exit;}
if($kol==0){
echo'<div class="p">
По вашему запросу, ничего не найдено..<br>
</div>';
}else{ echo'<div class="i">Результатов '.$kol.'<br></div>';
while($ofile=mysql_fetch_array($sdata)){

 $newcolor=mysql_num_rows(mysql_query("SELECT * FROM `down_files` WHERE `dobav`>'".(time()-86400*3)."' AND `typer`!='dir' AND `id_file`='".$ofile['id_file']."'")); 
$dokuda='../down/'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format']; #Путь до файла
$vesma=round(filesize($dokuda)/1024); #Вес файла
if($vesma==0){$vesma='Менее 1';}
echo'<div class="p">';
if(empty($ofile['name'])){
$ofile['name']=$ofile['nastna'].'.'.$ofile['format'];
}

echo'<b>Имя:</b> <a href="'.$ofile['id_file'].'.info">'; if($newcolor==1){echo'<font color="red">';}
 echo $ofile['name'];
 
 if($newcolor==1){echo'</font>';}
 
 echo'</a><br><b>Описание: </b>'; if($ofile['opis']==""){echo'нет';}else{echo mb_substr($ofile['opis'],0,300,'UTF-8');} echo'<br>
<small>Скачали: '.$ofile['loads'].' раз<br></small>
<a href="load.php?id_load='.$ofile['id_file'].'&amp;'.$s.'">Скачать</a> ['.strtoupper($ofile['format']).'] ['.$vesma.'Кб]<br>
';
$koments=mysql_num_rows(mysql_query("select * from koments where type='downs' and id_kogo='".$ofile['id_file']."'"));

$koments=mysql_num_rows(mysql_query("select * from koments where type='downs' and id_kogo='".$ofile['id_file']."'"));
echo'<a href="../pages/koments.php?id_wm='.$ofile['id_file'].'&amp;type=downs&amp;'.$s.'">Комментарии</a> ['.$koments.']<br>
</div>';


}}


if($st!=0){
echo'<div class="p"><img src="../design/default/act.gif" alt="-"> <a href="search.php?st='.($st-$num).'&amp;day='.$day.'&amp;'.$s.'">Назад</a><br></div>';
}
if($kol>$st+$num){
echo'<div class="p"><img src="../design/default/act.gif" alt="-"> <a href="searh.php?st='.($st+$num).'&amp;day='.$day.'&amp;'.$s.'">Вперед</a><br></div>';}

if($kol>10){
echo'<div class="p">
<form action="searh.php?day='.$day.'&amp;'.$s.'" method="post">
На страницу (1-'.ceil(($kol/10)).'):<br>
<input type="text" name="str" maxlength="4" class="form" size="3" value="'.ceil(($kol/10)).'">
<input type="submit" value="ОК"  class="but"><br>
</form></div>';}

break;
} require"../system/foot.php";
?>