$BASE_DIR = "."; $BASE_URL = "."; $BASE_EDITABLE = 0; // 0/1 $DATE_FORMAT = "Y-m-d"; $TIME_FORMAT = "H:i"; //"H:i:s"; $UNKNOWN_FILE_FORMAT = " "; //"Unknown"; $describe_ext = array( 'htm' => 'htm', 'html' => 'htm', 'txt' => 'txt', 'text' => 'txt', 'csv' => 'txt', 'css' => 'css', 'js' => 'js', 'php' => 'php', 'php3' => 'php', 'php4' => 'php', 'phtm' => 'phtm', 'phtml' => 'phtm', 'chtm' => 'chtm', 'chtml' => 'chtm', 'shtm' => 'shtm', 'shtml' => 'shtm', 'asp' => 'asp', 'aspx' => 'asp', 'xml' => 'xml', 'xsl' => 'xml', 'xslt' => 'xml', 'dtd' => 'xml', 'wml' => 'wml', 'wmls' => 'wml', 'hdml' => 'wml', 'c' => 'c', 'cpp' => 'c', 'cxx' => 'c', 'cc' => 'c', 'pl' => 'c', 'bas' => 'c', 'tcl' => 'c', 'pas' => 'c', 'java' => 'c', 'inc' => 'c', 'bat' => 'c', 'sh' => 'c', 'htaccess' => 'htaccess', 'htpasswd' => 'htaccess', 'jpg' => 'pic', 'jpeg' => 'pic', 'jif' => 'pic', 'png' => 'pic', 'gif' => 'pic', 'swf' => 'swf', 'class'=> 'class', 'jar' => 'class', 'zip' => 'zip', 'arj' => 'zip', 'tar' => 'zip', 'gz' => 'zip', 'bz2' => 'zip', 'uu' => 'zip', 'uue' => 'zip', 'doc' => 'doc', 'xls' => 'doc', 'ppt' => 'doc', 'pdf' => 'doc', 'sxw' => 'doc', 'sxc' => 'doc', 'sxi' => 'doc', 'sxd' => 'doc', 'mpg' => 'vid', 'mpeg' => 'vid', 'ram' => 'vid', 'rm' => 'vid', 'avi' => 'vid', // changed "mp3" to "aud" (audio), for more general description 'mp3' => 'aud', 'mid' => 'aud', 'midi' => 'aud', 'wav' => 'aud', 'bak' => 'bak' ); $describe_type = array( // add 0 as "Unknown" file type 0 => $UNKNOWN_FILE_FORMAT, 'htm' => "HTML file", 'txt' => "Text file", 'css' => "Style Sheet", 'js' => "Java Script source code", 'php' => "PHP source code", 'phtm' => "PHP or ePerl source code", 'chtm' => "CGI_Core source code", 'shtm' => "Server parced HTML file", 'asp' => "Active server pages", 'xml' => "XML / XSLT / DTD file", 'wml' => "WML / HDML file for mobile internet", 'c' => "Program or script source code", 'htaccess' => "Apache security configuration file", 'pic' => "Picture", 'swf' => "Macromedia Flash object", 'class' => "Java class file", // change from "Java applet file" to "Java class file" 'zip' => "Archive", 'doc' => "Office document or similar file", 'vid' => "Video file", 'aud' => "Audio file", // change from "Music file" to "Audio file", more generic. 'bak' => "Backup copy" ); $describe_op = array( 'htm' => "e", 'txt' => "e", 'css' => "e", 'js' => "e", 'php' => "e", 'phtm' => "e", 'chtm' => "e", 'shtm' => "e", 'asp' => "e", 'xml' => "e", 'wml' => "e", 'c' => "e", 'htaccess' => "e", ); function HTMLdecode($s){ $o = ""; for ($i=0; $i < strlen($s); $i++){ switch ($s[$i]){ case "<": $o = $o."<"; break; case ">": $o = $o.">"; break; case "&": $o = $o."&"; break; case "\"": $o = $o."""; break; default: $o = $o.$s[$i]; } } return $o; } function dirmessage($s){ } function message($s){ echo "$s"; } function goheader($res, $msg){ header("location: ?".($res ? "" : "msg=".urlencode($msg) ) ); } // does $op already declared?, if not declare it if (!isset($op)) $op = ""; if ($op=='cd'){ // does $dir1 already declared?, if not declare it if(!isset($dir1)) $dir1 = ""; SetCookie("dir1", "$dir1/$file"); goheader(1, ""); } $BASE_DIR=realpath($BASE_DIR); // do $dir and $dir1 already declared?, if not declare them if (!isset($dir)) $dir = ""; if (!isset($dir1)) $dir1 = ""; $dir=realpath("$BASE_DIR/$dir1"); if ( strpos("x".$dir, $BASE_DIR) != 1 ){ $dir = $BASE_DIR; SetCookie("dir1", ""); } @chdir($dir); //used to show to the users (chroot-like).... $shdir=substr($dir, strlen($BASE_DIR))."/"; $url=$BASE_URL.substr($dir, strlen($BASE_DIR))."/"; if ($op){ switch ($op){ case 'del': $file=basename($file); if (is_dir($file)) $res=@rmdir ($file); else $res=@unlink($file); goheader($res, "Delete failed. If this is a directory, be sure is empty."); break; case 'ren': $file = basename($file); $newfile = basename($newfile ); $res = @rename($file, $newfile); goheader($res, "Rename failed."); break; case 'mkdir': $file = basename($file); $res = 0; if ($BASE_EDITABLE){ $res = @mkdir($file, 0755); } goheader($res, "Create directory failed."); break; case 'mkfile': $mkfile = basename($file); $fd = 0; if ($BASE_EDITABLE){ $fd = @fopen($file, "w+"); @fclose($fd); } goheader($fd, "Create file failed."); break; case 'newfile': $file_name = basename($file_name); $res = 0; if ($BASE_EDITABLE){ $res = move_uploaded_file($file, $file_name); } goheader($res, "File upload failed."); break; case 'newedit': $file = basename($file); $res = 0; if ($BASE_EDITABLE){ $fd=fopen($file, "w+"); fwrite($fd, $content); fclose($fd); } goheader($fd, "Edit upload failed."); break; } // switch } // if ($op) function describe($f){ global $describe_ext; $m = explode(".", $f); $size = (sizeof($m)-1); $ext = strtolower($m[$size]); if ( filetype($f) != 'file' && $size == 0 ) return 0; // check if $ext is a "known" file type if (isset($describe_ext[$ext])) return $describe_ext[$ext]; // if yes, return its describe_ext return 0; // if not, return as "unknown" } function printfile($f){ global $describe_type, $describe_op, $url, $DATE_FORMAT, $TIME_FORMAT; if($f == "." || $f == "..") return; $type = filetype($f); $size = $type != 'file' ? filetype($f) : round(filesize($f) / 1024)." KB"; $descr = $type != 'file' ? " " : $describe_type[describe($f)]; echo "
| Name | Size | Date | Time | [refresh] | |
|---|---|---|---|---|---|
| .. | dir | ||||