Directory Listing Exclusion...

Guys,

I hope you’re able to help me out.

I’m a total newbie (I’m actually a designer) and got the code below originally from this site, to list the files on my ftp server. The problem is though that the code also lists the index.php file itself. Can anyone tell me how to stop this code from listing itself (the more specific the better…)?

Thanks very much in advance,
Christian.

[php]<? $handle = opendir(‘I Put My FTP Address Here’);
while (false !== ($file = readdir($handle))) { $user = strtolower($user);
if ($file != “.” && $file != “…” && $file != “.htaccess” && !is_dir($file) && $file != “index.htm” && $file != ($user.".php")) { $num=count($file); for ($a=0; $a < $num; $a++) { $file_size = filesize($file); $last_mod = date(“m/d/Y G:i:s”, filectime($file));
echo ("

>>  
$file "); echo ("$file_size"); echo ("$last_mod "); } } } closedir($handle); echo “”; ?> [/php]

Hi csaunders,

Don’t know if it could help, 'cause i’m a newbie too ( :-? ) but i think you could just add ’ && $file != “index.php” ’ at the end of your first “if” statement (with the other $file != “…” ).

Friendly, Lucifer Christ

Thanks a lot - this works fantastic!

Appreciate it.

-Christian

Sponsor our Newsletter | Privacy Policy | Terms of Service