Просмотр файла forum/forum/search.php

Размер файла: 8.21Kb
<?php
require_once"../template/start.php";
require_once"../template/regglobals.php";
require_once"../template/config.php";
require_once"../template/functions.php";
require_once"../template/antidos.php";
require_once"../template/cookies.php";
require_once"../template/gzip.php";
require_once"../template/header.php";
require_once"../template/referer.php";
include_once"../themes/$config_themes/index.php";
include_once"../template/isset.php";
include_once"../template/db.php";
include_once"fnc.php";







if ($_REQUEST['chto'] != NULL || $_REQUEST['who'] !=NULL || $_REQUEST['wh'] != NULL){



$chto = checkus($_REQUEST['chto']);
$whos = checkus($_REQUEST['who']);
$wh = (int)$_REQUEST['wh'];}
$who = substr($whos, 2);
$substrw = $whos{0}; 

if (strlen($chto) < '3'){echo '<br><div><img src="'.$config_home.'/forum/img/err.gif" alt=""> <small>Слишком маленький запрос!</small></div><br><hr><div>';
echo ': <a href="'.$config_home.'/forum/search">Поиск</a><br>';
echo ':: <a href="'.$config_home.'/forum/">В форум</a><br>';
echo '::: <a href="'.$config_home.'/index.php">На главную</a>';
echo '</div><div style="margin: 0px 0px -5px 0px"><img src="'.$config_home.'/forum/img/byforum.gif" alt=""></div>';
include_once"../themes/$config_themes/foot.php"; exit;}

if (strlen($chto) > '32'){echo '<br><div><img src="'.$config_home.'/forum/img/err.gif" alt=""> <small>Слишком большой запрос!</small></div><br><hr><div>';
echo ': <a href="'.$config_home.'/forum/search">Поиск</a><br>';
echo ':: <a href="'.$config_home.'/forum/">В форум</a><br>';
echo '::: <a href="'.$config_home.'/index.php">На главную</a>';
echo '</div><div style="margin: 0px 0px -5px 0px"><img src="'.$config_home.'/forum/img/byforum.gif" alt=""></div>';
include_once"../themes/$config_themes/foot.php"; exit;}

echo '<div class="b"> Поиск по форуму</div>';


//////////////////////////////////////////////////////////////////
// elseif ($wh=='1'){
// if ($who != '0'){
// if ($substrw =='f'){
// $sqlresult = "SELECT * FROM `posts` WHERE `msg` LIKE '%".$chto."%' AND `forums` LIKE '%".$who."%' LIMIT $start, 10";
// }else{
// $sqlresult = "SELECT * FROM `posts` WHERE `msg` LIKE '%".$chto."%' AND `under` LIKE '%".$who."%' LIMIT $start, 10";}
// }else{$sqlresult = "SELECT * FROM `posts` WHERE `msg` LIKE '%".$chto."%' LIMIT $start, 10";}
//////////////////////////////////////////////////////////////////
if ($wh == '0'){

if ($who !='0'){
if ($substrw =='f'){
$sqlresult = "SELECT * FROM `theme` WHERE `name` LIKE '%".$chto."%' AND `forums` LIKE '".$who."' LIMIT $start, 10";
}else{
$sqlresult = "SELECT * FROM `theme` WHERE `name` LIKE '%".$chto."%' AND `under` LIKE '".$who."' LIMIT $start, 10";}
}else{$sqlresult = "SELECT * FROM `theme` WHERE `name` LIKE '%".$chto."%' LIMIT $start, 10";}


$sar = mysql_query($sqlresult);
if (mysql_num_rows($sar)) {

function pages($start, $total, $onpage, $config_home){
if ($start != 0) 
echo '<a href="'.$config_home.'/forum/search/'.($start - $onpage).'">&lt;-Назад</a> ';
else echo '&lt;-Назад';
echo ' | ';
if ($total > $start + $onpage)
echo ' <a href="'.$config_home.'/forum/search/'.($start + $onpage).'">Далее-&gt;</a>';
else echo 'Далее-&gt;';
if ($total > 0) {
$ba = ceil($total / $onpage);
$ba2 = $ba * $onpage - $onpage;
echo '<br/>Страницы:';
$asd = $start - ($onpage * 3);
$asd2 = $start + ($onpage * 4);
if ($asd < $total && $asd > 0) 
echo ' <a href="'.$config_home.'/forum/search">1</a> ... ';
for($i = $asd; $i < $asd2;) {
if ($i < $total && $i >= 0) {
$ii = floor(1 + $i / $onpage);
if ($start == $i) echo ' <b>[' . $ii . ']</b>';
else echo ' <a href="'.$config_home.'/forum/search/'.$i.'">' . $ii . '</a>';} 
$i = $i + $onpage;} 
if ($asd2 < $total) echo ' ... <a href="'.$config_home.'/forum/themes/'.$id.'/'.$ba2.'">' . $ba . '</a>';}} 
if ($who !='0'){
$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `theme` WHERE `name` LIKE '%".$chto."%' AND `under` LIKE '%".$who."%'"),0);
}else{
$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `theme` WHERE `name` LIKE '%".$chto."%' "),0);}
$start = isset($_GET['start']) ? abs((int)$_GET['start']) : 0;
if ($start > $total) $start = 0;
if ($total < $start + 10) $end = $total;
else $end = $start + 10;


while ($src = mysql_fetch_array($sar)) {
echo '<div><img src="'.$config_home.'/forum/img/t.gif" alt=""> ';
echo '<a href="'.$config_home.'/forum/posts/'.$src['id'].'"><b>'.$src['name'].'</b></a><br>';

echo '<small>Создал: '.lognik($src['author']).' <br>';
if($src['description']){echo 'Кратко: '.$src['description'].' <br>';}
echo 'Последний: '.lognik($src['last']).' <br>';
echo '</small><hr></div>';}
}else{ echo '<br><div><img src="'.$config_home.'/forum/img/err.gif" alt=""> <small>По вашему запросу ничего не найдено!</small></div><br><hr>';}}

elseif ($wh=='1'){

if ($who != '0'){

if ($substrw =='f'){
$sqlresult = "SELECT * FROM `posts` WHERE `forums` = '".$who."' AND `msg` LIKE '%".$chto."%'  LIMIT $start, 10";
}else{
$sqlresult = "SELECT * FROM `posts` WHERE `under` = '".$who."' AND `msg` LIKE '%".$chto."%' LIMIT $start, 10";}


}else{$sqlresult = "SELECT * FROM `posts` WHERE `msg` LIKE '%".$chto."%' LIMIT $start, 10";}

$sar = mysql_query($sqlresult);
if (mysql_num_rows($sar)) {

function pages($start, $total, $onpage, $config_home){
if ($start != 0) 
echo '<a href="'.$config_home.'/forum/search/'.($start - $onpage).'">&lt;-Назад</a> ';
else echo '&lt;-Назад';
echo ' | ';
if ($total > $start + $onpage)
echo ' <a href="'.$config_home.'/forum/search/'.($start + $onpage).'">Далее-&gt;</a>';
else echo 'Далее-&gt;';
if ($total > 0) {
$ba = ceil($total / $onpage);
$ba2 = $ba * $onpage - $onpage;
echo '<br/>Страницы:';
$asd = $start - ($onpage * 3);
$asd2 = $start + ($onpage * 4);
if ($asd < $total && $asd > 0) 
echo ' <a href="'.$config_home.'/forum/search">1</a> ... ';
for($i = $asd; $i < $asd2;) {
if ($i < $total && $i >= 0) {
$ii = floor(1 + $i / $onpage);
if ($start == $i) echo ' <b>[' . $ii . ']</b>';
else echo ' <a href="'.$config_home.'/forum/search/'.$i.'">' . $ii . '</a>';} 
$i = $i + $onpage;} 
if ($asd2 < $total) echo ' ... <a href="'.$config_home.'/forum/themes/'.$id.'/'.$ba2.'">' . $ba . '</a>';}} 
if ($who !='0'){
$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `posts` WHERE `msg` LIKE '%".$chto."%' AND `under` LIKE '%".$who."%'"),0);
}else{
$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `posts` WHERE `msg` LIKE '%".$chto."%' "),0);}

$start = isset($_GET['start']) ? abs((int)$_GET['start']) : 0;
if ($start > $total) $start = 0;
if ($total < $start + 10) $end = $total;
else $end = $start + 10;


while ($src = mysql_fetch_array($sar)) {
$thms = mysql_query("SELECT * FROM `theme` WHERE `id` = '".$src['theme']."' ");
$thm = mysql_fetch_array($thms);
echo '<div><img src="'.$config_home.'/forum/img/t.gif" alt=""> ';
echo '<a href="'.$config_home.'/forum/posts/'.$thm['id'].'"><b>'.$thm['name'].'</b></a><br>';



if (strlen($src['msg']) > '1000') {
echo 'Сообщение: '.antimat(bb_code(check2(utf8_substr($src['msg'])))).' <br>';
echo '<a href="'.$config_home.'/forum/poste/'.$src['theme'].'/'.$src['id'].'">Читать все >></a><br>';
}else{
echo 'Сообщение: '.antimat(bb_code(check2($src['msg']))).' <br>';
}

echo '<small>Написал: ';
if ($post['author_n'] != NULL){
echo '<b>'.$src['author_n'].'</b>';
}else{
echo '<b>'.$src['author'].'</b>';}
echo ' ('.dfixe($src['time']).')</small><hr></div>';}
}else{ echo '<br><div><img src="'.$config_home.'/forum/img/err.gif" alt="">'.$substrw.' <small>По вашему запросу ничего не найдено!</small></div><br>';}}






echo '<div>';
if ($total > '10'){ pages($start, $total, 10, $config_home); echo '<hr>';}

echo ': <a href="'.$config_home.'/forum/search">Поиск</a><br>';
echo ':: <a href="'.$config_home.'/forum/">В форум</a><br>';
echo '::: <a href="'.$config_home.'/">На главную</a><br>';

echo '<br><img src="'.$config_home.'/forum/img/byforum.gif" alt=""></div>';
include_once"../themes/$config_themes/foot.php";
?>