Файл: include/search.php
Строк: 281
<?php
if(empty($_POST['q']) and empty($_GET['q']))
{
if($version == "wml")
{
header("Content-type: text/vnd.wap.wml; charset=utf-8");
header("Cache-Control: no-cache");
$sa = intval($_GET['sa']);
if(!$sa)
{
echo(doctype("Поиск").'
'.$tag.'<a href="./?p=20&v='.$version.'&sa=1&sid='.$sid.'">Поиск автора</a>'.$tagC.' <br />
'.$tag.'Что ищем:'.$tagC.' <br />
<input type="text" name="q" /><br />
'.$tag.'Где ищем:'.$tagC.'<br />
<select name="w">
<option value="4">В сообщениях</option>
<option value="3">В названиях тем</option>
</select><br />
'.$tag.'В подфорумах:'.$tagC.'<br />
<select multiple="multiple" name="f">');
$f = mysql_query("SELECT `id`, `name` FROM `forums`");
while($fids = mysql_fetch_array($f))
{
echo('<option value="'.$fids['id'].'">'.$fids['name'].'</option>');
}
echo('</select><br /><input type="checkbox" name="f" value="all"/> Везде<br />
<anchor>[Искать]
<go href="./?p=20&v=wml&sid='.$sid.'" method="get">
<postfield name="q" value="$(q)" />
<postfield name="w" value="$(w)" />
<postfield name="f" value="$(f)" />
<postfield name="l" value="$(l)" />
</go></anchor><br />
'.$tag.'
- - - - <br />
<a href="./?p=0&v=wml&sid='.$sid.'">Форум</a>
'.$tagC.'
</p></card></wml>');
}
else
{
echo(doctype("Поиск автора").'
'.$tag.'Автор:'.$tagC.' <br />
<input type="text" name="q" /><br />
<select name="w">
<option value="2">Автор сообщений</option>
<option value="1">Автор тем</option></select><br />
'.$tag.'В подфорумах:'.$tagC.'<br />
<select multiple="multiple" name="f">');
$f = mysql_query("SELECT `id`, `name` FROM `forums`");
while($fids = mysql_fetch_array($f))
{
echo('<option value="'.$fids['id'].'">'.$fids['name'].'</option>');
}
echo('
</select><br /><input type="checkbox" name="f" value="all"/> Везде<br />
<anchor>[Искать]
<go href="./?p=20&v=wml&sid='.$sid.'" method="get">
<postfield name="q" value="$(q)" />
<postfield name="w" value="$(w)" />
<postfield name="f" value="$(f)" />
<postfield name="l" value="$(l)" />
</go></anchor><br />
'.$tag.'
- - - - <br />
<a href="./?p=0&v=wml&sid='.$sid.'">Форум</a>
'.$tagC.'
</p></card></wml>');
}
} elseif($version == "xhtml")
{
header("Content-type: text/html; charset=utf-8");
header("Last-Modified:".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-relative");
$sa = intval($_GET['sa']);
echo('<html>
<head>
<title>');
if(!$sa)
{
echo('Поиск');
}
else
{
echo('Поиск автора');
}
echo('</title>
</head>
<body bgcolor="'.$style['background'].'" link="'.$style['link'].'" vlink="'.$style['link'].'" text="#000000">
<form action="./?p=20&sid='.$sid.'&v='.$version.'&sa='.$sa.'" method="post">
<table align="center" border="0" cellspacing="1" cellpadding="5" width="350">
<tr><td align="center" bgcolor="'.$style['title'].'" colspan="2">
<font color="#FFFFFF">');
if(!$sa)
{
echo('<b>Поиск</b>');
}
else
{
echo('<b>Поиск автора</b>');
}
echo('
</font>
</td></tr>
<tr><td bgcolor="'.$style['bottom'].'" colspan="2">');
if($sa!=1)
{
echo('<a href="./?p=20&v='.$version.'&sa=1&sid='.$sid.'">Поиск автора</a><br />');
}
echo('</td></tr>');
if($sa==1)
{
echo('
<tr bgcolor="'.$style['text'].'"><td>
'.$tag.'Автор:'.$tagC.'</td><td><input type="text" name="q" /><br /><select name="w">
<option value="2">Автор сообщений</option>
<option value="1">Автор тем</option></select></td></tr>
');
}
if(!$sa)
{
echo('
<tr bgcolor="'.$style['text'].'"><td>
'.$tag.'Что ищем:'.$tagC.'</td><td><input type="text" name="q" /></td></tr>
<tr bgcolor="'.$style['text'].'"><td>
'.$tag.'Где ищем:'.$tagC.'</td><td>
<select name="w">
<option value="4">В сообщениях</option>
<option value="3">В названиях тем</option>
</select></td></tr>');
}
echo('
<tr bgcolor="'.$style['text'].'"><td>
'.$tag.'В подфорумах:'.$tagC.'</td><td>
<select multiple="multiple" name="f">');
$f = mysql_query("SELECT `id`, `name` FROM `forums`");
while($fids = mysql_fetch_array($f))
{
echo('<option value="'.$fids['id'].'">'.$fids['name'].'</option>');
}
echo('</select></td></tr>
');
if(!$sa)
{
echo('
<tr bgcolor="'.$style['text'].'"><td>
'.$tag.'Искать слова:'.$tagC.'</td><td>
<select name="l">
<option value="and">все</option>
<option value="or">любые</option>
</select>
</td></tr>');
}
echo('
<tr bgcolor="'.$style['text'].'"><td align="center" colspan="2">
<input type="submit" value="Искать" />
</td></tr>
<tr bgcolor="'.$style['bottom'].'"><td colspan="2">
'.$tag.'<a href="./?p=0&v=xhtml&sid='.$sid.'">Форум</a> '.$tagC.'
</td></tr></table>
</form>
</body></html>');
}
} else
{
if (empty($_GET['q']))
{
$query = htmlspecialchars(sql(trim(chop(translatenick($_POST['q'])))));
}
else
{
$query = urldecode(htmlspecialchars(sql(trim(chop(translatenick($_GET['q']))))));
}
if (empty($_GET['w']))
{
$where = htmlspecialchars(sql(trim(chop(translatenick($_POST['w'])))));
}
else
{
$where = htmlspecialchars(sql(trim(chop(translatenick($_GET['w'])))));
}
if (empty($_GET['f']))
{
$forums = htmlspecialchars(sql(trim(chop(translatenick($_POST['f'])))));
}
else
{
$forums = htmlspecialchars(sql(trim(chop(translatenick($_GET['f'])))));
}
if (empty($_GET['l']))
{
$logic = htmlspecialchars(sql(trim(chop(translatenick($_POST['l'])))));
}
else
{
$logic = htmlspecialchars(sql(trim(chop(translatenick($_GET['l'])))));
}
$WHERE = "WHERE ";
$SQL = "";
if($logic =! "or" or $logic != "and")
{
$logic = "and";
}
if(!empty($forums))
{
$WHERE .= "id_forum=".intval($forums)." AND ";
}
if($where == 1)
{
$SQL .= "SELECT * FROM themes " . $WHERE . " name='".$query."' AND del != 1 ";
$wh = "в авторах тем";
} elseif($where == 2)
{
$SQL .= "SELECT posts.*, themes.* FROM posts
LEFT JOIN themes ON posts.id_theme=themes.id " . $WHERE . " posts.name='".$query."' AND del != 1 ";
$wh = "в авторах сообщений";
} elseif($where == 3)
{
$SQL .= "SELECT * FROM `themes` " . $WHERE . " `tname` LIKE '%".$query."%' AND del != 1 ";
$wh = "в названиях тем";
} elseif($where == 4)
{
$SQL .= "SELECT * FROM `posts` " . $WHERE . " `post` LIKE '%" . $query . "%' ";
$wh = "в сообщениях";
}
if($query != NULL)
{
$count = mysql_num_rows(mysql_query($SQL));
$start = intval($_GET['s']);
if(!empty($start))
{
$limit = "LIMIT ".$start.", ".abs($count - $start);
$int = $start;
}
else
{
$int = 0;
}
if($version == "xhtml")
{
$thisPageSize = 1000;
}
else
{
$thisPageSize = 750;
}
if(!$count OR strlen($query) < 3)
{
if($version == "wml")
{
header("Content-type: text/vnd.wap.wml; charset=utf-8");
header("Cache-Control: no-cache");
echo(doctype("Поиск").$tag.'
Вы искали '.$wh.' <b>'.stripslashes($query).'</b> <br />
По Вашему запросу ничего не найдено!<br />
- - -<br />
<a href="./?p=20&v=wml&sid='.$sid.'">Искать еще</a><br />
<a href="./?p=0&v=wml&sid='.$sid.'">Форумы</a>
'.$tagC.'
</p></card></wml>');
} elseif($version == "xhtml")
{
header("Content-type: text/html; charset=utf-8");
header("Last-Modified:".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-relative");
echo('<html>
<head>
<title>Поиск</title>
</head>
<body bgcolor="'.$style['background'].'" link="'.$style['link'].'" vlink="'.$style['link'].'" text="#000000">
<form action="" method="get">
<table align="center" border="0" cellspacing="1" cellpadding="5" width="350">
<tr><td align="center" bgcolor="'.$style['title'].'">
<font color="#FFFFFF"><b>Поиск</b></font>
</td></tr>
<tr><td bgcolor="'.$style['bottom'].'"></td></tr>
<tr bgcolor="'.$style['text'].'"><td>'.$tag.'
Вы искали '.$wh.' <b>'.stripslashes($query).'</b><br />
По Вашему запросу ничего не найдено.
'.$tagC.'</td></tr>
<tr><td bgcolor="'.$style['bottom'].'"> '.$tag.'
<a href="./?p=20&v=xhtml&sid='.$sid.'&">Искать еще</a><br />
<a href="./?p=0&v=xhtml&sid='.$sid.'">Форумы</a>
'.$tagC.'</td></tr>
</table>
</body></html>');
}
} else
{
$que = mysql_query($SQL.$limit);
if($version == "wml")
{
header("Content-type: text/vnd.wap.wml; charset=utf-8");
header("Cache-Control: no-cache");
echo(doctype("Поиск").$tag.'
Вы искали '.$wh.' <b>'.stripslashes($query)."</b> <br />rn
Найдено соответствий <b>".$count."</b>!<br />rn");
while($link = mysql_fetch_array($que))
{
static $s;
//echo(date('d/m H:i', $link['time']).']');
$authoriz = mysql_query("SELECT * FROM `users` WHERE `username`='".$username."' AND `password`='".$password."'");
$Sauthoriz = mysql_fetch_array($authoriz);
if(!$authorize || $Sauthoriz['private'] == "off" || mysql_result(mysql_query("SELECT * FROM `users` WHERE `username`='".$link['name']."'"), 0) == 0)
{
echo("<b>".$link['name']."</b>]rn");
} elseif($Sauthoriz['private'] == "private")
{
echo('<b><a href="./?p=24&uid='.UserName2id($link['name']).'&v='.$version.'&sid='.$sid.'&d=1">'.$link['name']."</a></b>]rn");
}
elseif($Sauthoriz['private'] == "user")
{
echo('<b><a href="./?p=6&id='.UserName2id($link['name']).'&v='.$version.'&th='.$color.'">'.$link['name']."</a></b>]rn");
}
echo("<a href="./?p=4&v=wml&sid=".$sid."&t=".$link['id']."">".$link['tname']."</a><br />rn");
echo(nl2br(str_replace($query, "<u>".$query."</u>", $link['post']))."<br />rn");
$int++;
$s += strlen($link['time'].$link['name'].$link['tname'].$link['post']);
if($s + $thisPageSize + (110 * abs($int - $start)) > $pageSize)
{
if($int != $count)
{
$next = $int;
}
break;
}
}
echo('- - -<br />');
if(!empty($next))
{
echo("<a href="".$forumdir."q=".$q."&w=".$w."&f=".$f."&l=".$l."&sa=".$sa."&p=20&sid=".$sid."&v=".$version."&s=".$next."">Дальше</a><br />rn");
}
echo('
<a href="./?p=20&v=wml&sid='.$sid.'">Искать еще</a><br />
<a href="./?v=wml&sid='.$sid.'">Форумы</a>
'.$tagC.'</p></card></wml>');
} elseif($version == "xhtml")
{
header("Content-type: text/html; charset=utf-8");
header("Last-Modified:".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-relative");
echo('<html>
<head>
<title>Поиск</title>
</head>
<body bgcolor="'.$style['background'].'" link="'.$style['link'].'" vlink="'.$style['link'].'" text="#000000">
<form action="" method="get">
<table align="center" border="0" cellspacing="1" cellpadding="5" width="350">
<tr><td align="center" bgcolor="'.$style['title'].'">
<font color="#FFFFFF"><b>Поиск</b></font>
</td></tr>
<tr><td bgcolor="'.$style['bottom'].'">'.$tag.'
Вы искали '.$wh.' <b>'.stripslashes($query).'</b><br />
Найдено соответствий: '.$count.'
'.$tagC.'</td></tr>
<tr bgcolor="'.$style['text'].'"><td>'.$tag);
while($link = mysql_fetch_assoc($que))
{
static $s;
//echo(date('d/m H:i', $link['time']).']');
$authoriz = mysql_query("SELECT * FROM `users` WHERE `username`='".$username."' AND `password`='".$password."'");
$Sauthoriz = mysql_fetch_array($authoriz);
if(!$authorize || $Sauthoriz['private'] == "off" || mysql_result(mysql_query("SELECT * FROM `users` WHERE `username`='".$link['name']."'"), 0) == 0)
{
echo("<b>".$link['name']."</b>]rn");
} elseif($Sauthoriz['private'] == "private")
{
echo('<b><a href="./?p=24&uid='.UserName2id($link['name']).'&v='.$version.'&sid='.$sid.'&d=1">'.$link['name']."</a></b>]rn");
}
elseif($Sauthoriz['private'] == "user")
{
echo('<b><a href="./?p=6&id='.UserName2id($link['name']).'&v='.$version.'&th='.$color.'">'.$link['name']."</a></b>]rn");
}
echo("<a href="./?p=4&v=xhtml&sid=".$sid."&t=".$link['id']."">".$link['tname']."</a><br />rn");
echo(nl2br(str_replace($query, "<u>".$query."</u>", $link['post']))."<br />rn");
$int++;
$s += strlen($link['time'].$link['name'].$link['tname'].$link['post']);
if($s + $thisPageSize + (110 * abs($int - $start)) > $pageSize)
{
if($int != $count)
{
$next = $int;
}
break;
}
}
echo($tagC.'</td></tr>
<tr bgcolor="'.$style['bottom'].'"><td>'.$tag);
if(!empty($next))
{
echo("<a href="".$forumdir."q=".$query."&w=".$where."&f=".$forums."&l=".$logic."&sa=".$sa."&p=20&sid=".$sid."&v=".$version."&s=".$next."">Дальше</a><br />rn");
}
echo('
<a href="./?p=20&v=xhtml&sid='.$sid.'">Искать еще</a><br />
<a href="./?p=0&v=xhtml&sid='.$sid.'">Форумы</a>
'.$tagC.'</td></tr>
</table>
</body></html>');
}
}
}
}
?>