javascript - 修改 sphider search.php 文件并帮助我

标签 javascript php jquery html mysql

我遇到了 sphider 网站索引和搜索脚本的 search.php 文件的问题。我需要你的帮助。 其实我想把 sphider 搜索脚本放在我的网站上,用关键字搜索页面。但我有一个问题。我在网站的每一页都附加了一个搜索框,现在我想将 sphider 的 search.php 文件放入表单操作中。但是当我检查时,我得到了它;没有搜索结果,但在它旁边显示了 search.php 文件中的搜索框,当我输入任何关键字并按回车键时,它会显示结果。所以我的问题是。如何从此 search.php 文件中删除此搜索框并仅获取搜索结果。

' search.php?query= [---这里是输入框中输入的搜索关键词--] &search=1'

这是在从 search.php 搜索框输入后显示的 URL,但是当把所有细节都放在我的页面搜索引擎中时,它没有做任何事情,只要求搜索那个框...所以大家请帮助我....

<?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']))
	$query = $_GET['query'];
if (isset($_GET['search']))
	$search = $_GET['search'];
if (isset($_GET['domain'])) 
	$domain = $_GET['domain'];
if (isset($_GET['type'])) 
	$type = $_GET['type'];
if (isset($_GET['catid'])) 
	$catid = $_GET['catid'];
if (isset($_GET['category'])) 
	$category = $_GET['category'];
if (isset($_GET['results'])) 
	$results = $_GET['results'];
if (isset($_GET['start'])) 
	$start = $_GET['start'];
if (isset($_GET['adv'])) 
	$adv = $_GET['adv'];
	
	
$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") { 
	$type = "and";
}

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


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

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

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

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



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

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

if ($count_level0) {
	$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 () {
	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')";
	mysql_query($query);
                    
	echo mysql_error();
                        
}

switch ($search) {
	case 1:

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

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.. 

最佳答案

看看这一行:

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

这是从 searchfuncs.php 上面包含的文件调用的函数我想在您自己的搜索栏中使用 Sphider 搜索功能,请执行以下操作(假设使用 MVC 模式) :

  1. 在您的搜索栏 Controller 中包含 searchfunc.php
  2. 将搜索栏中的关键字设置为符合 Sphider 约定的格式,并为第 3 步准备所需的参数
  3. 从您的自定义 Controller 调用 get_search_results() 函数
  4. 现在您已经获得了结果,您可能想要创建一个自定义 View 来处理搜索结果,或者引用 sphider/templates/standard/search_results.html 以获取默认所需的 HTML蜘蛛结果。

关于javascript - 修改 sphider search.php 文件并帮助我,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27764529/

相关文章:

javascript - 为什么量词不起作用

javascript - 使用 "in"检查字符串是否在数组中

javascript - 如何通过索引选择表格单元格?

jquery - 使用 jquery 更改屏幕的大小或分辨率

javascript - 基于另一个 div 设置父 div 的样式

javascript - 如何在 HTML5 中制作具有 4 种状态的选项 slider ?

php - MySQL 平均每 4 行

php - 如果表单未在我自己的网站上提交,如何显示错误?

javascript - html 我需要用图形代替 vcr 控件的文本来控制数据库中的状态

jquery - 使用jquery删除类后如何使css不忽略转换函数