Просмотр файла games/poisk.php

Размер файла: 3.12Kb
<?
define('SECURED', true);
include 'ini.php';
include 'inc/func_validate.php';
include 'inc/func_pages.php';

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']='ТОП-100 игр';
include_once '../sys/inc/thead.php';
title();
err();
aut();




$search_string = (!empty($_POST['search_string']) ? $_POST['search_string'] : $_SESSION['search_string2']);
$search_string = val($search_string);
$search_string = str_replace('%', null, $search_string);

if(!isset($_GET['go']))
{
	echo'<div class="menu"> Введите ключевое слово или фразу(из названия/описания игры):</div>';
	echo'<form enctype="multipart/form-data" action="'.$_SERVER['PHP_SELF'].'?go&amp;'.SID.'" method="post">';
	echo'<input type="text" name="search_string"/><br/>';
	echo'<input type="submit" name="submit" value="Искать"/>';
	echo'</form>';
}
else
{
	$_SESSION['search_string2']=$search_string;
	$base_url=$_SERVER['PHP_SELF']."?go&amp;";
	$num_items=mysql_result(mysql_query("select count(id) from `games` where `name` like '%$search_string%' or `description` like '%$search_string%';"),0);
	$pages = ceil($num_items/$config['files_on_page']);
	if(!empty($_REQUEST['page']))
	{
		$page = intval($_REQUEST['page']);
		if($page<=0) $page=1; 
		if($page>=$pages) $page=$pages; 
	} else
	{
		$page = 1;
	}
	$start = $page * $config['files_on_page'] - $config['files_on_page'];	

	$max=$start + $config['files_on_page'];
	if($max>$num_items) $max=$num_items;
	$total_files = $start + 1;
	if($num_items==0) $total_files=0;
	echo '<div class="menu"><b>Найдено '.$total_files.'-'.$max.' из '.$num_items.'</b></div>';

	if($num_items==0) echo'<div class="menu">Поиск не дал результатов.</div>';
	
	$q=mysql_query("select * from `games` where `name` like '%$search_string%' or `description` like '%$search_string%' order by `added` desc limit $start,".$config['files_on_page'].";");
	while($file=mysql_fetch_array($q))
	{
		list($cat_name)=mysql_fetch_array(mysql_query("select `name` from `categorys` where `id`='".$file['cat_id']."';"));
		echo'<div class="menu">';
		echo' • <a href="game.php?ID='.$file['id'].'">'.$file['name'].'</a> [скачано: '.$file['downloads'].']<br/>';
		echo 'Добавлен: '.date("d-m-y",$file['added']).'<br/>';
		echo 'Жанкр: <a href="'.$_SERVER['PHP_SELF'].'?ID='.$file['cat_id'].'&amp;'.SID.'">'.$cat_name.'</a></div>';
	}
		
	echo pages($base_url, $pages, $page);
	echo'<div class="menu"><a href="poisk.php?'.SID.'">Начать новый поиск</a></div>';
}
	

	echo'<div class="menu">&#171;&#160;<a href="/games/">Назад</a></div>';
	if (($link=file("".$config['count']."")) == true) {
$LinkCount=count($link); 
$NL=rand(0, $LinkCount-1);
echo $link[$NL];
}
include_once '../sys/inc/tfoot.php';
?>