كود PHP:
// الحروف المسموح بها
$chars = array('ا','أ','إ','ئ','ء','ب','ت','ث','ج','ح','خ','د','ذ','ر','ز','ش','ص','ض','ط','ظ','ع','غ','ف','ق','ك','ل','م','ن','ه','و','ي','ـ',' ','ؤ','آ','لإ','ُ','َ','ِ','_','لأ','ى','ة','ظ','ر','ز','ه','خ','ح','ج','1','2','3','4','5','6','7','8','9','10','11','12','13','1000','0','2009','2010','1429','1430');
// تخطي الأكواد
$T = strip_tags($T);// I Take It From Ashraf Alsmhorry , swalif.net
if (preg_match('/[^'. preg_quote(implode($chars)) .']/si', $T)) {
$MSG = $lang['Bad_T'];
$smarty->assign("MSG",$MSG);
$show_header = 1;
include("common_up.php");
$smarty->display("search.htm");
}
else
{// إحضار رقم القسم
$section = strip_tags($_POST['section_id']);
// إحضار نوع الخدمات
$type = strip_tags($_POST['type']);
// إحضار النجوم
$stars = strip_tags($_POST['stars']);// التأكد من ان خانة البحث ليست فارغه , او اقل من 3 حروف
if($T == "" OR strlen($T) < 3){
$show_header = 1;
include("common_up.php");
$M = $lang['under_3'];
$smarty->assign("MSG",$M);
$smarty->display("search.htm");
}
else
{
$smarty->assign("Num",$Num);
$smarty->assign("T",urlencode($T));
$smarty->assign("type",$type);
$smarty->assign("C",$section);
$smarty->assign("S",$stars);
$smarty->display("search_wait.htm");echo"<meta http-equiv = refresh content=4;url=search.php?results=found&T=".urlencode($T)."&type=$type&C=$section&S=$stars&page=1>";}
}
هذه صفحة التحويل بعد إدخال الكلمة في مربع البحث
كود PHP:
// إحضار نص البحث
$T = trim($_GET['T']);
$T = strip_tags($T);
$Tx = addslashes($T);
$T = urldecode($Tx);
$T_T = urlencode($Tx);
$text = $T;
// إحضار رقم القسم المراد البحث به
$C = trim($_GET['C']);
$C = strip_tags($C);
$C = addslashes($C);
if(! is_numeric($C)){ $C = 'all'; }
//إحضار نوع الخدمه
$type = trim(strip_tags($_GET['type']));
$type = addslashes($type);
$type_array= array('hotel','apartemnt','em','other','all');
if(! in_array("$type",$type_array)){ $type = 'all'; }
// إحضار النجوم
$stars = trim(strip_tags($_GET['S']));
$stars_array = array('1','2','3','4','5','all');
if(! in_array("$stars",$stars_array)) { $stars = 'all'; }// I Take It From Ashraf Alsmhorry , swalif.net
if (preg_match('/[^'. preg_quote(implode($chars)) .']/si', $T)) {
$MSG = $lang['Bad_T'];
$smarty->assign("MSG",$MSG);
$smarty->display("search.htm");
}
else
{if($C != 'all'){ if(mysql_num_rows(mysql_query("SELECT `id` FROM `table_section` WHERE `id`='$C'")) == 0){ $C='all'; } }
// إستخراج الأقسام
$Sec = mysql_query("SELECT `id`,`title` FROM `table_section` ORDER BY `level`");
while ($row=mysql_fetch_array($Sec)){ $SEC[] = $row; }
$smarty->assign("SectionList",$SEC);
// التأكد من ان خانة البحث ليست فارغه , او اقل من 3 حروف
if($T == "" OR strlen($T) < 3){
$M = $lang['under_3'];
$smarty->assign("MSG",$M);
$smarty->display("search.htm");
}
else
{
if($C == 'all'){ $sec_include = ""; } else { $sec_include = "AND `section_id`='".intval($section)." '"; }
if($type == 'all') { $type_include = ""; } else { $type_include = "AND `type`='".addslashes($type)." '"; }
if($S == 'all'){ $stars_include = ""; } else { $srats_include= "AND `stars`='".intval($stars)." '"; }
// إستعلام البحث
$Query=@mysql_query("SELECT * FROM `table_table` WHERE `name` LIKE '%$text%' OR `desc` LIKE '%$text%' OR `text` LIKE '%$text%' OR `meta_open` LIKE '%$text%' ". addslashes($sec_include)." ". addslashes($type_include)." ". addslashes($stars_include)." LIMIT $start,$max_results");
طبعاً هذا بعض من الكود فقط ...