<?
include '../config.php';
include '../func.php';
head();
ban();
if($error){ echo $error;
}else{
    mysql_query("UPDATE `profile` SET `online` = 'forum' WHERE `id` = '".$id_session."'");
/////////////////////////////////
echo "<div class=\"head\"><b>Поиск по форуму</b></div><div class=\"main\">";   


if($_POST['in'] == 1)
{
	$query = mysql_query("SELECT * FROM `forum_themes` WHERE `name` LIKE '%".html(urldecode($_POST['query']))."%'");
	$total = mysql_result(mysql_query('SELECT FOUND_ROWS()'), 0);
	if($total == 0)
	{
		echo katalog . 'Совпадений не найдено' . div;
	}
	else
	{
	   echo katalog . '<b>Результаты поиска:</b><br/ >';
		while($row = mysql_fetch_assoc($query))
		{
			
			
			echo '<img src="../style/'.$icon.'/dot.gif" alt="" /> <a href="theme.php?razdel='.$row['razdel_id'].'&pod_forum='.$row['pod_forum'].'&theme='.$row['id'].'">'.$row['name'].'</a><br/ >';
		}
        echo '<br/ ><img src="../style/'.$icon.'/dot.gif" alt="" /> <a href="index.php?search">Повторить запрос</a>';
        echo div;
	
	}
}

if($_POST['in'] == 2)
{
	$query = mysql_query("SELECT SQL_CALC_FOUND_ROWS * FROM `forum_msg` WHERE `msg` LIKE '%".html(urldecode($_POST['query']))."%'");
	$total = mysql_result(mysql_query('SELECT FOUND_ROWS()'), 0);
	if($total == 0)
	{
		echo katalog . 'Совпадений не найдено' . div;
	}
	else
	{
        echo katalog;
		while($row = mysql_fetch_assoc($query))
		{
			
			$topic = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_themes` WHERE `id` = '".$row['theme']."'"));
			echo '<img src="../style/'.$icon.'/dot.gif" alt="" /> <b>Тема:</b> <a href="theme.php?razdel='.$topic['razdel_id'].'&pod_forum='.$topic['pod_forum'].'&theme='.$topic['id'].'">'.$topic['name'].'</a><br/ >';
            echo '<img src="../style/'.$icon.'/dot.gif" alt="" /> <b>Пост:</b> '.smile(adminbb(parsebb($row['msg']))).'<hr>';
		}
        echo '<br/ ><img src="../style/'.$icon.'/dot.gif" alt="" /> <a href="index.php?search">Повторить запрос</a>';
        echo div;
        

	}
}

if ( empty($_POST['in']) ) {
    
    header('Location: index.php');
    
}



/////////////////////////////////
}

navig();
foot();
?>