Wednesday, August 25, 2010

How to Integrate Sphider Search to the Website.


Sphider is the php-based search engine which allows anyone to modify and manage the searching index and eliminate the logo advertisement like google or yahoo. To set up the Sphider tool is more or less difficult but requires a little patience and time if you follow my instruction below.

Preset
I) Suppose your web directory is c:\xampp\htdocs\
II) That means your index.php must be put in this directory.
III) Then download source code here, Sphider. IV) Copy the whole Sphider folder to the directory mentioned earlier. Now you're to add the Sphider power to your webpage
(index.php).

1) Create new php file and name it, say,
mysearch.php and paste it at the same directory as index.php

2) Open file
index.php to edit and paste this following code to where you would like to place search box

<form action="mysearch.php" method="get">
<input name="query" id="query" size="20" value="" type="text">
<input value="Search" type="submit">
<input name="search" value="1" type="hidden">
</form>


3) Open file search.php which locates at c:\xampp\htdocs\sphider\

4) Copy the whole code from this file (search.php) to mysearch.php
(locate the code where you would like to show the search result) and we have to alternate some variables in this file as follows.


mysearch.php
from $include_dir = "./include";
to $include_dir = "./sphider/include";


From $include_dir = "./include";
$template_dir = "./templates";
$settings_dir = "./settings";
$language_dir = "./languages";

To $include_dir = "./sphider/include";
$template_dir = "./sphider/templates";
$settings_dir = "./sphider/settings";
$language_dir = "./sphider/languages";


5) Open commonfuncs.php file which stays at c:\xampp\htdocs\sphider\include and add some texts to array $include as below.

From
$includes = array('./include', 'include', '../include');
To
$includes = array('./include', 'include', '../include','sphider/include', './sphider/include', '../sphider/include');


6) Open file search_results.html which is C:\xampp\htdocs\sphider\templates\standard and adjust the php action at line8 as below.

From

To



7) At the same directory (C:\xampp\htdocs\sphider\templates\standard), open search_form.html file and edit the line 6 as follows.

From
<form action="search.php" method="get">
To
<form action="mysearch.php" method="get">

8) Almost done, let's create the database for it. So, go to ,in this case, PhpMyAdmin and create sql database ,say, "spider" (please refer to sql document of how to create a database)

9) Use exit to exit MySQL and in C:\xampp\htdocs\sphider\settings, edit database.php file and change $database, $mysql_user, $mysql_password and $mysql_host to correct values (if you don't know what $mysql_host should be, it should probably stay as it is - 'localhost').




10. Open install.php script (admin directory) in your browser(i.e. http://localhost/sphider/admin/install.php), which will create the tables necessary for Sphider to operate.






11. Open admin/admin.php in browser and start indexing. (i.e. http://localhost/sphider/admin/admin.php) Remark: Default username/password is admin/admin







12) Click add site and fill in the required information in correspondence with your web parameters. And click add button when complete it.





13) Click Options to start indexing



14) Click side menu at "Index"




15) Change the depth of indexing and accept the setting by pressing "Start indexing" button




16) At column "Last indexed" will be stamped the date. It implies that configuration is complete.



17) Now you're ready to use the Sphider Power! Start the index.php and test the function.


Remark: I also upload all changed files in Sphider folder and the finished index.php and mysearch.php that you can compare the configuration in between.

1 comment:

Philip said...

Thanks buddy..It helped me a lot building a site for my client.