File Browsing With PHP?

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
mikeypengelly
Forum Newbie
Posts: 7
Joined: Tue Jun 08, 2004 5:15 am

File Browsing With PHP?

Post by mikeypengelly »

I have 2 servers running red hat 9 and php called www2 and www3.
I am trying to run a file search script that will simply run hrough a directory and search for occurrances of a keyword.

The script works on www2 but not on www3. PHP works on both. both php.ini files are identical after chaning one value to on but it still doesnt seem to work.

I would imaging it would be a configuration issue rather than a code issue but i am open to any suggestions if anyone has any ideas.

Thanks in advance.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

You want PHP to do the job?

A nudge in the right direction would be:

Code: Select all

<?php
function get_directory_contents($path){
	$mydirectory = opendir($path);
	while($entryname=readdir($mydirectory)){
		switch (true){
			case ($entryname==".")               : break;
			case ($entryname=="..")              : break;
			case (is_dir($path."/".$entryname))  : $return["dir"][]=$entryname; break;
			default                              : $return["file"][]=$entryname;
		}
	}
	closedir($mydirectory);
	return $return;
}

echo "<h3>directory contents</h3><pre>";
print_r(get_directory_contents("./"));
echo"</pre>";
?>
That'll return subdirectories and files in a directory. If you filter the array it returns with a search-function, you should get what you need.
Post Reply