<?
require_once("admin/config.php");
if($_POST['search_word']) $search = $_POST['search_word'];
$search = strip_tags($search);
$search = trim($search);
if ($search == "" || strlen($search) < 3 || strlen($search) > 64) die ("<br>Вернитесь <a href='javascript:history.back(1)'>назад</a> и введите искомое выражение, с количеством символов не менее 3 и не более 64");
else
{
	require_once("inc/meta.inc.php");
	require_once ("inc/head.inc.php");
	require_once ("inc/head_menu.inc.php");
	?>
	<br /><table width=950 cellpadding=0 cellspacing=0 border=0 align=center><tr valign=top><td width=326>
	<?
	require_once ("inc/category.inc.php");
	require_once ("inc/cart.inc.php");
	require_once ("inc/razdely.inc.php");
	require_once ("inc/new_items.inc.php");
	?>
	</td><td width=624><center><h2>Поиск товаров по каталогу</h2></center><div style="padding-left:20px">
	<?
	if (!get_magic_quotes_gpc()) $search = mysql_escape_string($search);else $search = str_replace("'","`",$search);
	$query = mysql_query("SELECT * FROM jshop_cat WHERE name LIKE '%".$search."%' OR short_review LIKE '%".$search."%' OR full_review LIKE '%".$search."%' OR price LIKE '%".$search."%' OR info1 LIKE '%".$search."%' OR info2 LIKE '%".$search."%'");
	if ($query) $count_rows = mysql_num_rows ($query);
	if (@$count_rows)
	{	
		echo "<center><h4>Вы искали \"".$search."\". Найдено позиций: [<strong>".$count_rows."</strong>]</h4></center>";
		while($message = mysql_fetch_assoc($query))
		{	
			$message['name'] = eregi_replace($search, "<font color=\"red\"><strong>$search</strong></font>", $message['name']);
			echo "&rarr; <a href =\"".$h."/cat/".$message['category']."/item/".$message['id']."/\">".$message['name']."</a><br />";
		}
	}
	else echo "<h4>По Вашему запросу \"<strong>".$search."</strong>\" ничего не найдено.</h4>";
	echo "</div></td></tr></table>";
	require_once ("inc/foot.inc.php");
	echo "</body></html>";
}
?>