= "4.2.0"){ // Checking for correct PHP-Version $i = 1; function get_perms($file) { // this Function is copied from PHP.net $p_bin = substr(decbin(fileperms($file)), -9) ; $p_arr = explode(".", substr(chunk_split($p_bin, 1,"."), 0, 17)) ; $perms = ""; $i = 0; foreach ($p_arr as $this) { $p_char = ( $i%3==0 ? "r" : ( $i%3==1 ? "w":"x" ) ); $perms .= ( $this=="1" ? $p_char : "-" ) . ($i%3==2 ? " " : "" ); $i++; } return $perms; } if(!isset($_GET["opendir"])) $_GET["opendir"] = ""; // Directoryhandling if (!isset($_GET["path"])){ $strOpenDir = $_SERVER["DOCUMENT_ROOT"]; $strPath = $_SERVER["DOCUMENT_ROOT"]; }else{ $strDir = $_GET["opendir"]; $strOpenDir = $_GET["path"]."/".$strDir; if($strDir != "..") $strOpenDir = $_GET["path"]."/".$strDir; else $strOpenDir = strrev(substr(strrev($_GET["path"]),strpos(strrev($_GET["path"]),"/")+1,strlen($_GET["path"]))); // getting path of a directory above current one $strPath = $strOpenDir; } if(@chdir($strOpenDir) == 0) echo "No such Directory dude. (connot open : $strOpenDir)"; echo "current Path: $strOpenDir
"; if(isset($_GET['openfile'])) echo "current File: $_GET[openfile]"; // Reading directories and files from current dir. if ($handle = @opendir($strOpenDir)) { echo " "; while (false !== ($file = readdir($handle))) { if($i%2 != 0) $bg = "white"; else $bg = "#FFCC99"; // Hintergrund der Zeile if ($file != ".") { if($file != ".."){ $intFilefilesize = round(filesize($file)/1024,2) ; $strfileperms = get_perms($file);// set file parameters $intFilectime = date("d.m.y G:i:s",filectime($file)); // set last changed date $intFileatime = date("d.m.y",fileatime($file)); // set last accessed date }else{ $intFilefilesize = "" ; $strfileperms = ""; $intFilectime = ""; $intFileatime = ""; } $self = $_SERVER['PHP_SELF']; if(is_file($file)) echo ""; else echo ""; } $i++; } // while closedir($handle); } // if // Fileviewing / handling if(isset($_GET["openfile"])) $file = $_GET["openfile"]; // Writing to file if(isset($_GET["save"])){ $dat = fopen($_GET["path"]."/".$_GET["opendir"]."/".$file,"w"); if($data = fwrite($dat,$_GET["modifi"])){ echo "Modification written to file.

"; unset($_GET["openfile"]); }else echo "Error while writing to file !"; } // Reading the file if(isset($_GET["openfile"])){ echo "Filecontent

"; if(is_writable($file)){ $mod = "r+"; $submit = ""; }else{ $mod = "r"; $submit = ""; } $dat = fopen($file,$mod); echo " $submit "; }// isset }else{ $intPhpVersion = phpversion(); echo "wrong PHP Version. Can not execute DirFilebrowse with this version (PHP Version $intPhpVersion)"; } ?>
Name Permissions last changed last accessed Size
$file $strfileperms $intFilectime $intFileatime $intFilefilesize kb
$file $strfileperms $intFilectime $intFileatime