PDA

View Full Version : Search in specific directory


laurentxav
01-07-2004, 08:54 AM
Hello,

I've a problem searching with PhpDig...
I'm working on a very big website which is subdivised into 7 departments. Is it possible to limit the search to a single department ? (wich is located in a specific directory)

For example :

http://www.mywebsite.com/ is the main website

the departments are located in :

http://www.mywebsite.com/Dep1/
http://www.mywebsite.com/Dep2/
http://www.mywebsite.com/Dep3/
...

and PhpDig is located in :
http://www.mywebsite.com/PhpDig/

How to search Dep2 ?

Many thanks.

Laurent

Charter
01-07-2004, 01:51 PM
Hi. You can set a robots.txt file with the following content:

# http://www.mywebsite.com/robots.txt

User-agent: PhpDig
Disallow: /Dep1
Disallow: /Dep3
Disallow: /Dep4

# and so forth

If you already crawled these directories, you can exlude and delete them from the control panel.

laurentxav
01-07-2004, 06:38 PM
Ok, but it's not the problem... Sorry but my english isn't very perfect, I'm french-speaking ! ;)

Mywebsite is a complete site including all departments. PhpDig must crawl all available departments. But, when a visitor is surfing department 2 and use PhpDig for searching for something, I would like PhpDig return results located only into the department surfed by the visitor (the 2nd in this case).

So, for example, if the search query has results in many departments but the visitor is surfing department 2, i'd like to shown results for department 2 only.

A solution would be to install PhpDig in each directory, to create databases as much as necessary and to index and crawl each directory (department) separately. But this is a little complicated. Is there another possibility to ask PhpDig returning results in selected directory and not in the full indexed site ?

Thanks

Charter
01-08-2004, 01:16 AM
Hi. Perhaps you could dynamically create the search form and among the input tags of type hidden use the following:

<input type='hidden' name='site' value='NUMBER'/>
<input type='hidden' name='path' value='REL/PATH/'/>
<input type='hidden' name='refine' value='1'/>

Depending on what page a user in on, dynamicaly replace NUMBER with the site number, dynamically replace REL/PATH/ with the relative path to a department, and keep the refine hidden tag with value one unchanged. The NUMBER can be found in the site_id column of the sites table.

laurentxav
01-08-2004, 02:34 AM
Hi!

It works perfectly.

But we must be carefull, if I want to search the directory and all subdirectories, I must add a "%".
So, for example, the code is :


<input type='hidden' name='site' value='1'>
<input type='hidden' name='path' value='Dep2/%'>
<input type='hidden' name='refine' value='1'>


So PhpDig'll show all result in "Dep2" directory and all sub-directories.

This problem is solved. Thanks a lot ! :D

zaartix
05-05-2004, 10:30 PM
<input type='hidden' name='path' value='Dep2/%'>

this is dangerous string. What if "hacker" add into this string code:

<input type='hidden' name='path' value='Dep2/%"; drop table ha-ha; "'> or something else

Charter
12-08-2004, 01:13 PM
Update: With PhpDig 1.8.3+ you can crawl within a certain directory if LIMIT_TO_DIRECTORY is set to true in the config file, so only crawl those directories you want to search. Note the comments in the config file when using this option. Also, if you do not want the dropdown on the search menu, then set DISPLAY_DROPDOWN to false in the config file.

JunkMale
01-04-2005, 09:34 AM
<input type='hidden' name='path' value='Dep2/%'>

this is dangerous string. What if "hacker" add into this string code:

<input type='hidden' name='path' value='Dep2/%"; drop table ha-ha; "'> or something else

I would expect the PhpDig code to contain an AddSlashes to avoid such a problem.