Размер файла: 5.85Kb
<?
include '../include/path.php';
if($config['accforum']==1 || (isset($user) && ($rank&32)==32))
{
if(isset($_POST['query']) && isset($_POST['type']) && isset($_POST['cats']) && strlen($_POST['query'])>=4)
{
$query='';
if($_POST['type']==2) $query.='`post`LIKE"%'.filtr($_POST['query']).'%"'; else
if($_POST['type']==0)
{
$_POST['query']=explode(' ', $_POST['query']);
foreach($_POST['query'] as $value) $words[]='`post`LIKE"%'.filtr($value).'%"';
$query.=implode(' AND ', $words);
}else
{
$_POST['query']=explode(' ', $_POST['query']);
foreach($_POST['query'] as $value) $words[]='`post`LIKE"%'.filtr($value).'%"';
$query.=implode(' OR ', $words);
}
if($_POST['cats'][0]!='all')
{
foreach($_POST['cats'] as $cat)
if(strpos($cat, 'f')) $f[]='`f`='.intval(str_replace('f', '', $cat)); else $c[]='`c`='.intval(str_replace('c', '', $cat));
$cats=sql_query('SELECT `id` FROM `'.PRE.'forum_cats` WHERE '.implode(' OR ', $f).' ORDER BY `id` ASC');
while($cats_=mysql_fetch_assoc($cats)) $c[]='`c`='.$cats_['id'];
unset($cats,$f);
$query.=' AND '.implode(' AND ', $c);
}
$results_a=sql_query('SELECT * FROM `'.PRE.'forum_posts` WHERE ('.$query.') ORDER BY `ltime` DESC');
while($data=mysql_fetch_assoc($results_a)){ $results[]=$data; $t_id[]='`id`='.($results[count($results)-1]['id_thm']==0)?$results[count($results)-1]['id']:$results[count($results)-1]['id_thm']; }
if(isset($t_id))
{
$results_t=sql_query('SELECT `id`,`llogin`,`login`,`time`,`ltime`,`posts`,`c`,`name` FROM `'.PRE.'forum_posts` WHERE `name`!="" AND ('.implode(' OR ', $t_id).') ORDER BY `ltime` DESC');
while($results_tt=mysql_fetch_assoc($results_t)) $result_t[$results_tt['id']]=$results_tt;
}
function put_content()
{
global $results,$result_t;
echo '<div class="title">Результатов поиска: '.count($results).'</div>';
if(isset($results) && count($results)!=0)
{
foreach($results as $result)
{
echo '<div class="header"><a href="index.php?c='.$result_t[(($result['id_thm']!=0)?$result['id_thm']:$result['id'])]['c'].'&t='.$result_t[(($result['id_thm']!=0)?$result['id_thm']:$result['id'])]['id'].'&'.SID.'">'.$result_t[(($result['id_thm']!=0)?$result['id_thm']:$result['id'])]['name'].'</a> ['.$result_t[(($result['id_thm']!=0)?$result['id_thm']:$result['id'])]['posts'].'] (<a href="../whois.php?login='.MyEncode($result_t[(($result['id_thm']!=0)?$result['id_thm']:$result['id'])]['llogin']).'&'.SID.'">'.$result_t[(($result['id_thm']!=0)?$result['id_thm']:$result['id'])]['llogin'].'</a>) <a href="index.php?c='.$result_t[(($result['id_thm']!=0)?$result['id_thm']:$result['id'])]['c'].'&t='.$result_t[(($result['id_thm']!=0)?$result['id_thm']:$result['id'])]['id'].'&p=9999&'.SID.'">»</a></div>'.bbc($result['post']).'<br>';
}
} else echo 'Ничего не найдено.<br>';
echo '<br><a href="search.php?'.SID.'">К поиску</a>';
echo '<div class="nav"><a href="../index.php?'.SID.'">На главную</a></div>';
}
}
else
{
function put_content()
{
global $user;
echo '<div class="title">Поиск по форуму</div>';
echo '<form ation="search.php?'.SID.'" method="POST">
Что ищем<br>
<input type="text" name="query"><br>
<select name="type">
<option value=0>И</option>
<option value=1>ИЛИ</option>
<option value=2>ТОЧНОЕ СОВПАДЕНИЕ</option>
</select>
<br>
Где ищем<br>
<select multiple style="width: 95%" name="cats[]">
<option selected value="all">Все имющиеся</option>
';
$forums=sql_query('SELECT * FROM `'.PRE.'forum_forums` WHERE `rank`<='.$user['rank'].' ORDER BY `id` ASC');
$all_cats=sql_query('SELECT * FROM `'.PRE.'forum_cats` WHERE `rank`<='.$user['rank'].' ORDER BY `id` ASC');
while($cats[]=mysql_fetch_assoc($all_cats)){}
while($forum=mysql_fetch_assoc($forums))
{
echo '<option value="f'.$forum['id'].'">'.$forum['name'].'</option>';
foreach($cats as $cat) if($cat['f']===$forum['id']) echo '<option value="c'.$cat['id'].'"> -'.$cat['name'].'</option>';
}
echo'</select><br>
<input type="submit" value="Искать">
</form>';
echo '<div class="nav"><a href="index.php?'.SID.'">В форум</a></div>';
echo '<div class="nav"><a href="../index.php?'.SID.'">На главную</a></div>';
}
}
}else{
function put_content()
{
$link = '10; URL=../?'.SID;
function put_content()
{
echo '- Доступ запрещен администрацией сайта<br><br>';
echo '<a href="../?'.SID.'">далее...</a>';
}
}
}
// подключение дизайна
design();
?>