Размер файла: 9.81Kb
<?php
include_once("connect.php");
include_once("config.php");
include_once("functions.php");
include_once("users.php");
list($msec,$sec)=explode(chr(32),microtime());
$headtime=$sec+$msec;
if(empty($_GET['q']))
{
if($version == "wml")
{
header("Content-type: text/vnd.wap.wml; charset=utf-8");
echo(doctype("Поиск").'
'.$tag.'Что ищем:'.$tagC.' <br />
<input type="text" name="q" /><br />
'.$tag.'Где ищем:'.$tagC.'<br />
<select name="w">
<option value="1">В авторах тем</option>
<option value="2">В авторах сообщений</option>
<option value="3">В названиях тем</option>
<option value="4">В сообщениях</option>
</select><br />
<anchor>[Искать]
<go href="search.php?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="./?v=wml&sid='.$sid.'">Форум</a>
'.$tagC.'
</p></card></wml>');
} elseif($version == "xhtml")
{
header("Content-type: text/html; charset=utf-8");
echo('<html>
<head>
<title>Поиск</title>
</head>
<body bgcolor="'.$style['background'].'" link="'.$style['link'].'" vlink="'.$style['link'].'" text="#000000">
<form action="search.php" method="get">
<table align="center" border="0" cellspacing="1" cellpadding="5" width="350">
<tr><td align="center" bgcolor="'.$style['title'].'" colspan="2">
<font color="#FFFFFF"><b>Поиск</b></font>
</td></tr>
<tr><td bgcolor="'.$style['bottom'].'" colspan="2"></td></tr>
<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="1">В авторах тем</option>
<option value="2">В авторах сообщений</option>
<option value="3">В названиях тем</option>
<option value="4">В сообщениях</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><br /><input type="checkbox" name="f" value="all"/> Везде</td></tr>
');
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="hidden" name="sid" value="'.$sid.'" />
<input type="hidden" name="v" value="xhtml" />
<input type="submit" value="Искать" />
</td></tr>
<tr bgcolor="'.$style['bottom'].'"><td colspan="2">
'.$tag.'<a href="./?v=xhtml&sid='.$sid.'">Форум</a> '.$tagC.'
</td></tr></table>
</form>
</body></html>');
}
} else
{
$query = htmlspecialchars(sql(trim(chop($_GET['q']))));
$logic = $_GET['l'];
$where = intval($_GET['w']);
$forums = $_GET['f'];
$WHERE = "WHERE ";
$SQL = "";
if($logic =! "or" or $logic != "and")
{
$logic = "and";
}
if($forums != "all")
{
$WHERE .= "id_forum=".intval($forums)." AND ";
}
if($logic == "or")
{
}
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 posts.*, themes.* FROM posts
LEFT JOIN themes ON posts.id_theme=themes.id " . $WHERE . " post LIKE '%" . $query . "%' AND del != 1";
$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 = 1700;
}
else
{
$thisPageSize = 750;
}
if(!$count OR strlen($query) < 3)
{
if($version == "wml")
{
header("Content-type: text/vnd.wap.wml; charset=utf-8");
echo(doctype("Поиск").$tag.'
Вы искали '.$wh.' <b>'.stripslashes($query).'</b> <br />
По Вашему запросу ничего не найдено!<br />
- - -<br />
<a href="search.php?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");
echo('<html>
<head>
<title>Поиск</title>
</head>
<body bgcolor="'.$style['background'].'" link="'.$style['link'].'" vlink="'.$style['link'].'" text="#000000">
<form action="search.php" 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="search.php?v=xhtml&sid='.$sid.'&">Искать еще</a><br />
<a href="./?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");
echo(doctype("Поиск").$tag.'
Вы искали '.$wh.' <b>'.stripslashes($query)."</b> <br />\r\n
Найдено соответствий <b>".$count."</b>!<br />\r\n");
while($link = mysql_fetch_array($que))
{
static $s;
echo(date('d m H:i', $link['time']).' ');
if(!$authorize)
{
echo("<b>".$link['name']."</b><br />\r\n");
} else
{
echo('<b><a href="index.php?mode=user&id='.UserName2id($link['name']).'&v='.$version.'&sid='.$sid.'">'.$link['name']."</a></b><br />\r\n");
}
echo("<a href=\"index.php?v=wml&sid=".$sid."&mode=posts&p=".$link['id']."\">".$link['tname']."</a><br />\r\n");
echo(nl2br(str_replace($query, "<u>".$query."</u>", $link['post']))."<br />\r\n");
$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=\"".$_SERVER['REQUEST_URI']."&s=".$next."\">Дальше</a><br />\r\n");
}
echo('<a href="search.php?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");
echo('<html>
<head>
<title>Поиск</title>
</head>
<body bgcolor="'.$style['background'].'" link="'.$style['link'].'" vlink="'.$style['link'].'" text="#000000">
<form action="search.php" 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']).' ');
if(!$authorize)
{
echo('<b>'.$link['name']."</b><br />\r\n");
} else
{
echo('<b><a href="index.php?mode=user&id='.UserName2id($link['name']).'&v=xhtml&sid='.$sid.'">'.$link['name']."</a></b><br />\r\n");
}
echo("<a href=\"index.php?v=xhtml&sid=".$sid."&mode=posts&p=".$link['id']."\">".$link['tname']."</a><br />\r\n");
echo(nl2br(str_replace($query, "<u>".$query."</u>", $link['post']))."<br />\r\n");
$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=\"".$_SERVER['REQUEST_URI']."&s=".$next."\">Дальше</a><br />\r\n");
}
echo('<a href="search.php?v=xhtml&sid='.$sid.'&">Искать еще</a><br />
<a href="./?v=xhtml&sid='.$sid.'">Форумы</a>
'.$tagC.'</td></tr>
</table>
</body></html>');
}
}
}
}
list($msec,$sec)=explode(chr(32),microtime());
echo("\r\n<!--".round(($sec+$msec)-$headtime,4)."-->");
?>