21-09-2008, 13:08
|
|
|
חבר מתאריך: 26.08.03
הודעות: 46
|
|
מנוע חיפוש - אי אפשר לחפש בעברית
שלום לכולם וצהריים טובים.
לפני מס' חודשים עברתי לשרת חדש, ומאז התעוררה בעיה במנוע החיפוש - המערכת לא מציגה תוצאות כאשר מחפשים מילים בעברית. יש לציין שכאשר מחפשים מילים באנגלית, המערכת כן מציגה תוצאות.
מה עשויה להיות הבעיה?
מצ"ב הקוד:
קוד PHP:
<?php require ("dbc.php"); function showLine($words, $text){ $lines = Array(); for ($i=0; $i<count($words); $i++){ $pattern = "/(\S+\s?){0,5}".$words[$i]."(\S+\s?){0,5}/"; //preg_match_all($pattern, $text, $out, PREG_PATTERN_ORDER); preg_match($pattern, $text, $out, PREG_OFFSET_CAPTURE); if (isset($out[0][0])){ $lines[] = $out[0][0]; } } return $lines; } function boldWords($words, $text){ for ($i=0; $i<count($words); $i++){ $text = str_replace($words[$i], '<font color="red"><b>'.$words[$i].'</b></font>', $text); } return $text; } if (isset($_GET['q'])){ $keysB = $_GET['q']; $q = $_GET['q']; //if (get_magic_quotes_gpc()){ $q = stripslashes ($q); $keysB = stripslashes ($keysB); //} $q = str_replace("'","\'",$q); $keys = explode(" ", $q); } if (isset($_GET['q']) && $keys[0] != ""){ //if (get_magic_quotes_gpc()){ $_GET['q'] = stripslashes ($_GET['q']); //} $_GET['q'] = str_replace("'","\'",$_GET['q']); $keys = explode(" ", $_GET['q']); if ((!isset($_GET['where']) && isset($_GET['q'])) || @$_GET['where'] == "articles"){ $_GET['where'] = "articles"; $searchQuery = "SELECT * FROM `articels` WHERE"; for ($i=0; $i<count($keys); $i++){ $searchQuery .= " `date` LIKE BINARY '%".$keys[$i]."%' OR `title` LIKE BINARY '%".$keys[$i]."%' OR `des` LIKE BINARY '%".$keys[$i]."%' OR `body` LIKE BINARY '%".$keys[$i]."%' OR `auther` LIKE BINARY '%".$keys[$i]."%' OR `picDes` LIKE BINARY '%".$keys[$i]."%'"; if (($i+1) < count($keys)){ $searchQuery .= " OR"; } } $searchQuery .= " ORDER BY `id` DESC"; } else if (@$_GET['where'] == "news"){ $searchQuery = "SELECT * FROM `news` WHERE"; for ($i=0; $i<count($searchQuery); $i++){ $searchQuery .= " `date` LIKE BINARY '%".$keys[$i]."%' OR `title` LIKE BINARY '%".$keys[$i]."%' OR `body` LIKE BINARY '%".$keys[$i]."%' OR `auther` LIKE BINARY '%".$keys[$i]."%'"; if (($i+1) < count($searchQuery)){ $searchQuery .= " OR"; } } $searchQuery .= " ORDER BY `id` DESC"; } } ?>
|