Jump to content

Recommended Posts

Heya people.

I have a client and they have decided that they want site search functionality. The problem is that I am not their website developer. They use an internal guy (he's the kinda guy that thinks "I know what HTML stands for! I can make websites!") but needless to say, they have asked me to intergrate this functionality. Their current site is all HTML based and they have 50+ html files.

 

I have an idea on how to do this but wanted some advice.

 

They way i have thought about doing it is:

user submits a search query to a script.

the script runs recursivley through a directory using file_get_contents to load the contents of a file into a variable.

use a regex to find the body tags and see if the stuff between it contains the search query.

if the file contains the query then add the filename to an array for output later.

finish up, output results.

 

I can see this being largly inefficient and it taking a long while to run through each file, especially if a file has alot of content.

 

Can you see anything wrong with the way i plan on doing it? have a better suggestion? let me know ;)

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/131184-adding-a-site-search/
Share on other sites

the best way I can think of is to allow the users to search a database rather than the files. Would be much easier and faster...

 

To get all the information from the files to a database, you could create a small purpose built search bot that would run through the files and save the key information.. then setup a cron job to index the files say once a day? or you could set it up as a script so it will index the files at the owners request...

 

Adam

Link to comment
https://forums.phpfreaks.com/topic/131184-adding-a-site-search/#findComment-681089
Share on other sites

well, cron jobs are out of the question and I'm not sure about client reliability (whether or not they would remember to index the site).

 

I would have used a database, but they are insistant that they keep their current 'web' guy and they aren't going to pay for my time sorting things out so that their site is actually searchable.

Link to comment
https://forums.phpfreaks.com/topic/131184-adding-a-site-search/#findComment-681106
Share on other sites

Now if this is web based, ya can take a huge shortcut.

and google Google Site Search

 

as for a custom made one as u define will be very slow if the search has to do this everytime. yer best bet is to use mysql or similar db (ya might get away with sqlite v3) and use text matching for the searches, this is after u strip out the html tags. If the pages are located in the same dir, ya can do a checksum of the pages and their content as well.

 

Anyways good luck

Link to comment
https://forums.phpfreaks.com/topic/131184-adding-a-site-search/#findComment-681216
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.