2015-01-04 39 views
1

我遇到了sphider網站索引和搜索腳本的search.php文件的問題。我需要你的幫助。 其實我想把我的網站上的sphider搜索腳本用關鍵字搜索頁面。但我有一個問題。我在網站的每個頁面都附加了一個搜索框,現在我想在表單動作中放置sphider的search.php文件。但是,當我檢查我得到了它,沒有搜索結果,但在它旁邊顯示search.php文件中的搜索框,當我輸入任何關鍵字,然後按Enter鍵,然後顯示結果。所以我的問題是。如何從這個search.php文件中刪除這個搜索框,並只獲取搜索結果。修改sphider search.php文件並幫助我請

「的search.php?查詢= [---這裏進來box--輸入搜索關鍵詞] &搜索= 1」

這是URL從擊球的search.php搜索框中輸入之後,顯示但把就在我的網頁搜索引擎的所有細節時,它不會做任何事情,只要求通過框搜索......所以,請你們幫我....

<?php 
 
/******************************************* 
 
* Sphider Version 1.3.x 
 
* This program is licensed under the GNU GPL. 
 
* By Ando Saabas   ando(a t)cs.ioc.ee 
 
********************************************/ 
 
//error_reporting(E_ALL^E_NOTICE^E_WARNING); 
 
error_reporting(E_ALL); 
 
$include_dir = "./include"; 
 
include ("$include_dir/commonfuncs.php"); 
 
//extract(getHttpVars()); 
 

 
if (isset($_GET['query'])) 
 
\t $query = $_GET['query']; 
 
if (isset($_GET['search'])) 
 
\t $search = $_GET['search']; 
 
if (isset($_GET['domain'])) 
 
\t $domain = $_GET['domain']; 
 
if (isset($_GET['type'])) 
 
\t $type = $_GET['type']; 
 
if (isset($_GET['catid'])) 
 
\t $catid = $_GET['catid']; 
 
if (isset($_GET['category'])) 
 
\t $category = $_GET['category']; 
 
if (isset($_GET['results'])) 
 
\t $results = $_GET['results']; 
 
if (isset($_GET['start'])) 
 
\t $start = $_GET['start']; 
 
if (isset($_GET['adv'])) 
 
\t $adv = $_GET['adv']; 
 
\t 
 
\t 
 
$include_dir = "./include"; 
 
$template_dir = "./templates"; 
 
$settings_dir = "./settings"; 
 
$language_dir = "./languages"; 
 

 

 
require_once("$settings_dir/database.php"); 
 
require_once("$language_dir/en-language.php"); 
 
require_once("$include_dir/searchfuncs.php"); 
 
require_once("$include_dir/categoryfuncs.php"); 
 

 

 
include "$settings_dir/conf.php"; 
 

 
include "$template_dir/$template/header.html"; 
 
include "$language_dir/$language-language.php"; 
 

 

 
if ($type != "or" && $type != "and" && $type != "phrase") { 
 
\t $type = "and"; 
 
} 
 

 
if (preg_match("/[^a-z0-9-.]+/", $domain)) { 
 
\t $domain=""; 
 
} 
 

 

 
if ($results != "") { 
 
\t $results_per_page = $results; 
 
} 
 

 
if (get_magic_quotes_gpc()==1) { 
 
\t $query = stripslashes($query); 
 
} 
 

 
if (!is_numeric($catid)) { 
 
\t $catid = ""; 
 
} 
 

 
if (!is_numeric($category)) { 
 
\t $category = ""; 
 
} 
 

 

 

 
if ($catid && is_numeric($catid)) { 
 

 
\t $tpl_['category'] = sql_fetch_all('SELECT category FROM '.$mysql_table_prefix.'categories WHERE category_id='.(int)$_REQUEST['catid']); 
 
} 
 
\t 
 
$count_level0 = sql_fetch_all('SELECT count(*) FROM '.$mysql_table_prefix.'categories WHERE parent_num=0'); 
 
$has_categories = 0; 
 

 
if ($count_level0) { 
 
\t $has_categories = $count_level0[0][0]; 
 
} 
 

 

 

 
require_once("$template_dir/$template/search_form.html"); 
 

 

 
function getmicrotime(){ 
 
    list($usec, $sec) = explode(" ",microtime()); 
 
    return ((float)$usec + (float)$sec); 
 
    } 
 

 

 

 
function poweredby() { 
 
\t global $sph_messages; 
 
    //If you want to remove this, please donate to the project at http://www.sphider.eu/donate.php 
 
    print $sph_messages['Powered by'];?> <a href="http://www.sphider.eu/"><img src="sphider-logo.png" border="0" style="vertical-align: middle" alt="Sphider"></a> 
 

 
    <?php 
 
} 
 

 

 
function saveToLog ($query, $elapsed, $results) { 
 
     global $mysql_table_prefix; 
 
    if ($results =="") { 
 
     $results = 0; 
 
    } 
 
    $query = "insert into ".$mysql_table_prefix."query_log (query, time, elapsed, results) values ('$query', now(), '$elapsed', '$results')"; 
 
\t mysql_query($query); 
 
        
 
\t echo mysql_error(); 
 
         
 
} 
 

 
switch ($search) { 
 
\t case 1: 
 

 
\t \t if (!isset($results)) { 
 
\t \t \t $results = ""; 
 
\t \t } 
 
\t \t $search_results = get_search_results($query, $start, $category, $type, $results, $domain); 
 
\t \t require("$template_dir/$template/search_results.html"); 
 
\t break; 
 
\t default: 
 
\t \t if ($show_categories) { 
 
\t \t \t if ($_REQUEST['catid'] && is_numeric($catid)) { 
 
\t \t \t \t $cat_info = get_category_info($catid); 
 
\t \t \t } else { 
 
\t \t \t \t $cat_info = get_categories_view(); 
 
\t \t \t } 
 
\t \t \t require("$template_dir/$template/categories.html"); 
 
\t \t } 
 
\t break; 
 
\t } 
 

 
include "$template_dir/$template/footer.html"; 
 
?> 
 
//* 
 

 
I have removed 
 
require_once("$template_dir/$template/search_form.html"); 
 
and checked whether it work. But no it didn't work. So i'm getting frustrated.. 
 
Somebody please help me..

回答

0

取看看 在這條線:

$search_results = get_search_results($query, $start, $category, $type, $results, $domain); 

這是一個功能正在從包括上述searchfuncs.php一個名爲我你想使用自己的搜索欄中Sphider搜索功能做以下(假設MVC模式時):

  1. 包括在你的控制器searchfunc.php您的搜索欄
  2. 格式從搜索欄的關鍵字,以適應約定Sphider和步驟#3
  3. 調用準備所需的參數get_search_results()函數從您的自定義控制器
  4. 既然您正在獲得結果,您可能需要創建一個自定義視圖來處理搜索結果,或者返回sphider/templates/standard/search_results.html以獲取默認Sphider結果所需的HTML。