very light search.php.

This forum is now closed as part of retiring phpBB2.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
Post Reply
User avatar
loquita
Registered User
Posts: 37
Joined: Sat Oct 21, 2006 11:52 am

very light search.php.

Post by loquita »

m.php :

<html>

<head>

<title>phpbbsearchalpha</title>

</head>



<body>



<form method="post" action="mo.php">



<input type="text" name="rsearch"><br>

<center>

<input type="submit" name="search" value="search">

</center>



</form>


mo.php
<?
$sql_server="xxxxxxxxxxxxxxxxxxxxxxxxxxx";
$sql_user="xxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$sql_pass="mynameisloquitaandthisisnotmyrealpassword";
$sql_bdd="xxxxxxxxxxxxxxxxxxxxxxxxxxxx";
mysql_connect("$sql_server","$sql_user","$sql_pass")
or die("ERROR");
mysql_select_db("$sql_bdd") or die("ERROR");
if(isset($_POST['search']) && isset($_POST['rsearch']) )
{
}
elseif (!isset($_POST['rsearch']))
{
echo "SEARCH NOTHING ?";
}
$_POST['rsearch']=strtolower($_POST['rsearch']);
$words = str_replace("+", " ", trim($_POST['rsearch']));
$words = str_replace("\"", " ", $words);
$words = str_replace(",", " ", $words);
$words = str_replace(":", " ", $words);
$tab=explode(" " , $words);
$nb_words=count($tab);
$sql = "select t.post_subject, t.post_text, a.post_id from phpbb_posts a, phpbb_posts_text t where (t.post_text like '%$tab[0]%' OR t.post_subject like '%$tab[0]%') AND t.post_id=a.post_id ORDER BY a.post_id DESC limit 1000";

$result = mysql_db_query($sql_bdd,$sql);
$display ="<ul>";

while ($row = mysql_fetch_array($result)) {

$id = $row['post_id'];

$f_name = $row['post_subject'];
$f_txt = $row['post_text'];

$display .= "<li><a target=\"center\" href=\"viewtopic.php?p=$id\">$f_name</a> <a>$f_txt</a>";

}

$display .="</ul>";

echo $display



?>
</body>

</html>


just for information, but should not replace the original search.php for security reasons.

User avatar
Marnboorapa
Registered User
Posts: 84
Joined: Sat Jan 08, 2005 3:19 pm
Location: Thailand
Contact:

Post by Marnboorapa »

why not make you Lsearch.php to another file and when you want to use it just

<?php include("Lsearch.php") ?>

and use this code for conect with phpBB DB

Code: Select all

define('IN_PHPBB', true);

$phpbb_root_path = './';

include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
( config file included with common.php )

Post Reply

Return to “[2.0.x] MOD Writers Discussion”