View file mforum/search.php

File size: 6.85Kb
<?php
	header("Pragma: no-cache");
	$act=$HTTP_POST_VARS["act"];
	$search_terms=$HTTP_POST_VARS["search_terms"];
	if (!isset($search_terms)) $search_terms="intopics";
	$search_line=$HTTP_POST_VARS["search_line"];
	require "inc.php";
	$db=mysql_connect($dbhost, $dbuser, $dbpass);
	mysql_select_db($dbname,$db);
echo"
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
<html>
<head>
<title></title>
<meta name=\"description\" content=\"\">
<meta name=\"keywords\" content=\"\">
</head>
<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#006699\" vlink=\"#006699\" alink=\"#006699\">
<STYLE type=\"text/css\">
A {text-decoration: none;}
body
{
margin-left: 1%;
margin-right: 1%;
font-family: Arial, Helvetica, sans-serif;
font-size: 10pt;
background-color: #F0F0F0;
}
#otstup
{
	position:absolute;
	left: 5%;
	right: 5%;	
}
</STYLE>";
include "top.php";
echo"
<FONT size=2 color=\"#000000\" face=\"Arial\">
	<DIV>
		<TABLE width=100% bgcolor=\"#F0F0F0\" border=0 cellpadding=5 bordercolor=\"#000000\" cellspacing=1>
			<TR valign=top>
				<TD></TD>
				<TD>
					<FONT size=2 color=\"#000000\" face=\"Arial\"><DIV align=\"right\"><a href=\"#\"></a></DIV></FONT>
				</TD>
			</TR>
		</TABLE>
		<form method=\"post\" action=\"search.php\">
  			<FONT size=2 color=\"#000000\" face=\"Arial\">
  				<TABLE width=100% border=1 cellpadding=1 bordercolor=\"#222288\" cellspacing=0>
    				<TR valign=top>
      					<TD>
    						<FONT size=2 color=\"#000000\" face=\"Arial\">
        						<DIV>
          							<TABLE width=100% bgcolor=\"#FFFFFF\" border=0 cellpadding=5 bordercolor=\"#000000\" cellspacing=0>
            							<TR valign=top>
              								<TD colspan=\"4\" bgcolor=\"#8B93A0\">
												<FONT size=2 color=\"#000000\" face=\"Arial\">
                									<DIV align=\"center\"><strong>Search</strong></DIV>
              									</FONT>
    										</TD>
            							</TR>
            							<TR valign=top>
              								<TD height=16 bgcolor=\"#D5DAEA\"></TD>
              								<TD height=16 bgcolor=\"#D5DAEA\"></TD>
              								<TD height=16 bgcolor=\"#D5DAEA\">
    											<div align=\"justify\">
                									<input name=\"search_line\" type=\"text\" size=\"70\" maxlength=\"50\" value=\"".$search_line."\">
                									<input type=\"submit\" name=\"Submit\" value=\"Search\">
                									<a href=\"index.php\"><input type=\"button\" name=\"cancel\" value=\"Cancel\"></a>
              									</div>
    										</TD>
              								<TD height=16 bgcolor=\"#D5DAEA\"></TD>
            							</TR>
            							<TR valign=top>
              								<TD height=16 bgcolor=\"#D5DAEA\"></TD>
              								<TD height=16 bgcolor=\"#D5DAEA\"></TD>
              								<TD height=16 bgcolor=\"#D5DAEA\">
                								<div align=\"justify\">
    												<FONT size=2 color=\"#000000\" face=\"Arial\">
														<input type=\"radio\" name=\"search_terms\" value=\"intopics\" ";if($search_terms=="intopics")echo"checked=\"checked\"";echo"/>In topics<br/>
														<input type=\"radio\" name=\"search_terms\" value=\"inposts\" ";if($search_terms=="inposts")echo"checked=\"checked\"";echo"/>In posts<br/>
														<input type=\"radio\" name=\"search_terms\" value=\"all\" ";if($search_terms=="all")echo"checked=\"checked\"";echo"/>All<br/>
													</FONT>
												</div>
											</TD>
											<TD height=16 bgcolor=\"#D5DAEA\"></TD>
            							</TR>
										<TR valign=top>
											<TD width=\"10%\" height=16 bgcolor=\"#D5DAEA\"></TD>
											<TD width=\"15%\" height=16 bgcolor=\"#D5DAEA\"></TD>
											<TD width=\"65%\" height=16 bgcolor=\"#D5DAEA\">                
												<div align=\"justify\">
													<font color=\"#000000\" size=\"2\" face=\"Arial\">
														<input type=\"hidden\" name=\"act\" value=\"post\">
													</font>
												</div>
											</TD>
											<TD width=\"10%\" height=16 bgcolor=\"#D5DAEA\"></TD>
										</TR>";
if ($act=="post")
{
echo"
										<tr>
											<td bgcolor=\"#E6EBFB\" colspan=\"4\"><div>
												<font color=\"#000000\" size=\"2\" face=\"Arial\">
													<strong>Search results:</strong><br/><br/>";
	$res1=mysql_query("select * from forum where topic like '%".$search_line."%'");
	$n1=mysql_num_rows($res1);
	//$result=mysql_fetch_array($res);

	$res2=mysql_query("select * from forum where post like '%".$search_line."%'");
	$n2=mysql_num_rows($res2);
	//$result=mysql_fetch_array($res);
		
	$res3=mysql_query("select * from replies where messg like '%".$search_line."%'");
	$n3=mysql_num_rows($res3);
		
	if ($search_terms=="intopics")
	{
		if ($n1==0) echo "Line &quot;$search_line&quot; not found";
		$i=1;
		while($result=mysql_fetch_array($res1))
		{
			echo "<strong>$i.</strong> <a href=\"viewtop.php?pid=$result[pid]\">".ereg_replace(chr(13),'<br/>',$result[topic])."</a><br/>";
			echo substr(ereg_replace(chr(13),'<br/>',$result[post]),0,500)."<br/><br/>";
			$i++;
		}
	}else
	if ($search_terms=="inposts")
	{
		if (($n2+$n3)==0) echo "Line &quot;$search_line&quot; not found";
		$i=1;
		while($result=mysql_fetch_array($res2))
		{
			echo "<strong>$i.</strong> <a href=\"viewtop.php?pid=$result[pid]\">".ereg_replace(chr(13),'<br/>',$result[topic])."</a><br/>";
			echo substr(ereg_replace(chr(13),'<br/>',$result[post]),0,500)."<br/><br/>";
			$i++;
		}
		while($result=mysql_fetch_array($res3))
		{
			echo "<strong>$i.</strong> <a href=\"viewtop.php?pid=$result[pid]\">...</a><br/>";
			echo substr(ereg_replace(chr(13),'<br/>',$result[messg]),0,500)."<br/><br/>";
			$i++;
		}
	}else
	if ($search_terms=="all")
	{
		if (($n1+$n2+$n3)==0) echo "Line &quot;$search_line&quot; not found";
		$i=1;
		while($result=mysql_fetch_array($res1))
		{
			echo "<strong>$i.</strong> <a href=\"viewtop.php?pid=$result[pid]\">".ereg_replace(chr(13),'<br/>',$result[topic])."</a><br/>";
			echo substr(ereg_replace(chr(13),'<br/>',$result[post]),0,500)."<br/><br/>";
			$i++;
		}
		while($result=mysql_fetch_array($res2))
		{
			echo "<strong>$i.</strong> <a href=\"viewtop.php?pid=$result[pid]\">".ereg_replace(chr(13),'<br/>',$result[topic])."</a><br/>";
			echo substr(ereg_replace(chr(13),'<br/>',$result[post]),0,500)."<br/><br/>";
			$i++;
		}
		while($result=mysql_fetch_array($res3))
		{
			echo "<strong>$i.</strong> <a href=\"viewtop.php?pid=$result[pid]\">...</a><br/>";
			echo substr(ereg_replace(chr(13),'<br/>',$result[messg]),0,500)."<br/><br/>";
			$i++;
		}
	}
echo"
												</font></div>
											</td>
										</tr>
";
}
echo"
									</table>
								</div>
							</font>
						</TD>
					</TR>
				</TABLE>
			</FONT>
		</form>
	</DIV>
</FONT>";
include "bottom.php";
echo"
</body>
</html>";
?>