note 34920 deleted from function.opendir by rioter

From: Date: Tue, 12 Aug 2003 03:33:56 +0000
Subject: note 34920 deleted from function.opendir by rioter
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-53933@lists.php.net to get a copy of this message
Note Submitter: Ultimatedbz ---- How can i disable this function and not allow the user to look at the files above his folder he uses the following script: <html> <head> <title>Explorer</title> </head> <body style='font-size: 10px; line-height: 12px; font-family: Verdana, Arial, Sans-Serif'> <p> <? if ($_GET['dir']) $folder = $_GET['dir']; else $folder ='.'; $num=0; $path = $folder."/"; if ($handle = opendir($path)) { while (false !== ($file = readdir($handle))) { $num++; $files[$num] = $file; } } closedir($handle); print " <table width=400 cellspacing=0 style='font-size: 10px; line-height: 12px; font-family: Verdana, Arial, Sans-Serif'> <tr style='background-color: #BBBBCF;'> <td style='padding: 2px'>Filename ($num files)</td> <td width=80 align=center>Size</td> </tr> <tr> <td colspan=3 height=2></td> </tr> "; while (list ($key, $val) = each ($files)) { $extension = str_replace(".", "",strrchr($val,'.')); if (is_dir($path.$val)) $o = "?dir="; else $o = ''; if (is_dir($path.$val)) $img = 'dir'; elseif (is_file("ext/$extension.gif")) $img = $extension; else $img = "no"; print "<tr> <td><img width=15 height=15 alt='$extension' src=ext/$img.gif> <a href='$o$path$val'>$val</a></td><td align=right>".fsize($path.$val)."</td> </tr>\n"; } print " <tr> <td colspan=3 height=2></td> </tr> <tr style='background-color: #BBBBCF;'> <td colspan=3 height=2></td> </tr> </table> "; ?> </body> </html> <? function fsize($file) { $a = array("b", "Kb", "Mb", "Gb", "Tb", "Pb"); $pos = 1; $size = filesize($file); $size /= 1024; return round($size,0)." ".$a[$pos]; } ?> </html>

« previous php.notes (#53933) next »