<?

include_once '../sys/inc/start.php';

include_once '../sys/inc/compress.php';

include_once '../sys/inc/sess.php';

include_once '../sys/inc/home.php';

include_once '../sys/inc/settings.php';

include_once '../sys/inc/db_connect.php';

include_once '../sys/inc/ipua.php';

include_once '../sys/inc/fnc.php';

include_once '../sys/inc/user.php';

$set['title']='Поиск файлов'; // заголовок страницы

include_once '../sys/inc/thead.php';

title();

aut();



$search=NULL;

if (isset($_SESSION['search']))$search=$_SESSION['search'];

if (isset($_POST['search']))$search=$_POST['search'];

$_SESSION['search']=$search;



$search=preg_replace("#( ){2,}#"," ",$search);

$search=preg_replace("#^( ){1,}|( ){1,}$#","",$search);







if (isset($_GET['go']) && $search!=NULL)

{

$search_a=explode(' ', $search);



for($i=0;$i<count($search_a);$i++)

{

$search_a2[$i]='<span class="search_c">'.stripcslashes(htmlspecialchars($search_a[$i])).'</span>';

$search_a[$i]=stripcslashes(htmlspecialchars($search_a[$i]));

}



$q_search=str_replace('%','',$search);

$q_search=str_replace(' ','%',$q_search);

$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `obmennik_files` WHERE `opis` like '%".mysql_escape_string($q_search)."%'"),0);

$k_page=k_page($k_post,$set['p_str']);

$page=page($k_page);

$start=$set['p_str']*$page-$set['p_str'];

if ($k_post==0)echo "<div class=\"p_t\">\nНет результатов</div>\n";

$q=mysql_query("SELECT * FROM `obmennik_files` WHERE `opis` like '%".mysql_escape_string($q_search)."%' ORDER BY `time` DESC LIMIT $start, $set[p_str]");

$i=0;

while ($post = mysql_fetch_assoc($q))

{

$ras=$post['ras'];

$file=H."sys/obmen/files/$post[id].dat";

$name=$post['name'];

$size=$post['size'];

$dir = mysql_fetch_array(mysql_query("SELECT * FROM `obmennik_dir` WHERE `id` = '$post[id_dir]' LIMIT 1"));

echo "<table class='post'>\n";

if ($set['set_show_icon']==2){

echo "  <td class='icon48' rowspan='2'>\n";

include 'inc/icon48.php';

echo "  </td>\n";

}

elseif ($set['set_show_icon']==1)

{

echo "  <td class='icon14'>\n";

include 'inc/icon14.php';

echo "  </td>\n";

}



echo "  <td class='p_t'>\n";







if ($set['echo_rassh']==1)$ras=".$post[ras]";else $ras=NULL;



echo "<a href='/obmen$dir[dir]$post[name].$post[ras]?showinfo'>$post[name]$ras</a><br />\n";



echo "  </td>\n";

echo "   </tr>\n";

echo "   <tr>\n";

if ($set['set_show_icon']==1)echo "  <td class='p_m' colspan='2'>\n"; else echo "  <td class='p_m'>\n";



include 'inc/opis.php';



echo ' Папка: <a href="/obmen'.$dir['dir'].'?">'.$dir['name'].'</a>';



echo "</table>\n";



}

if ($k_page>1){str("search.php?go&amp;",$k_page,$page);

print'<br>';} // Вывод страниц

}

else

echo"<div class='foot'>";

echo " Поиск файлов";

echo'</div>';

echo "<form method=\"post\" action=\"search.php?go\" class=\"search\">\n";

$search=stripcslashes(htmlspecialchars($search));

echo "<input type=\"text\" name=\"search\" maxlength=\"64\" value=\"$search\" /><br />\n";

echo "<input type=\"submit\" value=\"Поиск\" />\n";

echo "</form>\n";



echo "<div class='foot'>";

echo "&laquo;<a href='/obmen/'>Обменник</a><br />\n";

echo "</div>\n";



include_once '../sys/inc/tfoot.php';

?>