Forum Moderators: coopster
I want to get a search system on my website so that users can find some content in my .php/.html files. Is there a good php solution available? Is php any good for that sorta thing or I should go for something else?
waiting for your suggestions...
my webserver supports php, cgi, perl... but I'd really like a php solution!
but the links to the various html documents about the sales are generated by php from the database (each entry in the database has a field with filename.html ... or empty if there's no text)
you can see the actual site here if you want to have a better idea of what i mean
<snip>
site is in french, but you'll get the idea...
when you click on the date, you get the html text file.
[edited by: jatar_k at 6:55 pm (utc) on Aug. 13, 2003]
[edit reason] no urls thanks [/edit]
However, it doesn't care about any of the meta tags, just the page content. So I made a quick and dirty script to fetch that stuff and put it in a text file
<?php
$conn = @mysql_connect('thehost','username','password');
$db = @mysql_select_db('phpdig_database');
$sql = "SELECT file,path FROM spider";
$result = @mysql_query($sql,$conn);
while ($row=@mysql_fetch_array($result))
{
$url='inserturlhere'.$row[1].$row[0];
$html=@join('',@file($url));
$html = str_replace("\n","",$html);
$html = str_replace("\r","",$html);
preg_match('/<title>(.*)<\/title>/Usi', $html, $title);
$thistitle = $title[1];
$keys = @get_meta_tags($url);
echo $url."\t".$thistitle."\t".$keys['keywords']."\t".$keys['description']."\n";
}
@mysql_free_result($result);
@mysql_close($conn);
?>
just do something like
php -q fetchmeta.php > meta.txt
this could probably be better integrated right into phpdig, but i didn't have the time or inclination for the report.
also, you might check out aspseek.
it is reasonably good with fast results. i had trouble with the php modules provided, ended up dumping them, and used a system call to the cgi from my php script- seemed to work ok for my project.
take care,
A MySQL query is probably going to be a lot faster than opening up a whole directory of HTML files... not to mention that it wont put as much strain on your server.
-panic