wrathican Posted November 3, 2008 Share Posted November 3, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/131184-adding-a-site-search/ Share on other sites More sharing options...
Adam Posted November 3, 2008 Share Posted November 3, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/131184-adding-a-site-search/#findComment-681089 Share on other sites More sharing options...
wrathican Posted November 3, 2008 Author Share Posted November 3, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/131184-adding-a-site-search/#findComment-681106 Share on other sites More sharing options...
Adam Posted November 3, 2008 Share Posted November 3, 2008 Ha right err.. Just go with a file search then ??? Up to them if they choose to save that extra bit of money but for what it would cost for your services i should imagine would be far more beneficial to them to have a speedy search.. Quote Link to comment https://forums.phpfreaks.com/topic/131184-adding-a-site-search/#findComment-681208 Share on other sites More sharing options...
laffin Posted November 3, 2008 Share Posted November 3, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/131184-adding-a-site-search/#findComment-681216 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.