View Full Version : .TXT Search Engine
GSimpson
01-20-2007, 10:59 PM
Hey Everyone,
I recently got a bit motivated to make a music tablature website and It's gonna be a bit like google, but I want it to search for .txt files.
I have a folder named "browse" that I would like it to search in along with all it's sub folders.
It's set out like
Browse
-Guitar
--D
---Disturbed
----Bound.txt
I'm trying my hardest to not use mysql but it's just not working.
CAn someone set me in the right direction.
Mwnciau
01-21-2007, 01:03 AM
You can probably do something with glob and opendir.
$folders[] = glob ("*", GLOB_ONLYDIR);
$files = glob("*.*");
$foldersleft = sizeof($folders[0]);
$i = 0;
while ($foldersleft > 0){
foreach ($folders[$i] as $key => $folder){
$i++;
$dir = opendir($folder);
$folders[$i] = glob ("*", GLOB_ONLYDIR);
foreach ($folders as $key2 => $value){
$folders[$i][$key2] = $folder . '/' . $folders[$i][$key2];
}
$temp = glob("*.*");
foreach ($temp as $key2 => $value){
$files[] = $folder . '/' . $value;
}
closedir($dir);
}
$foldersleft = sizeof($folders[$key+1]);
}
Though I'm guessing your going to have to edit that code a bit. Not even sure just the wildcard on it's own in glob works.
mattd8752
01-21-2007, 01:26 PM
You could index the directory in a formated text file, (quite simple if you find a directory listing script), and from there you would open each file, put it all into one file (separated with something that php can recognize and is not in any of your files) and I believe you would have to find someway to use wild cards, you would then replace spaces with wild cards if they were searching anything with any of the words anywhere, but also you would be able to just put a wild card before and after if they were searching for a whole text string.
GSimpson
01-21-2007, 09:12 PM
Thanks for you responses,
I have a new approach to the situation, I'm going to give into mysql however that would mean searching mysql, how would i go about something like that?
Thanks Heaps!
kehers
01-22-2007, 08:58 AM
There are a goody ways to achieve this with mysql...However, to save yourself some headache, take a look at the mysql fulltext (http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html) function ;)
GSimpson
01-26-2007, 05:14 AM
Yeah i found a basic mysql search script. Might re-write it then post it here. cool, thanks guys.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.