📄 explorer.php
字号:
<?
############################################################
#
# SETUP:::
# Edit $basedir = "/PATH/TO/YOUR/DIR"; to reflect your site
#
############################################################
############### Set up some variables and functions
############### CHANGE THIS TO YOUR DESIRED ROOT DIRECTORY
############### Add a slash at the start of the line. NO slash at the end.
$basedir = "/usr/local/etc/";
$ROdir = "http://";
$pages = "";
$webname = "";
$updatecheck = "no";
$enable_css = "yes";
$enable_logout = "yes";
$allow_move = "yes";
$allow_download = "yes";
$allow_copy = "yes";
$allow_touch = "yes";
$allow_rename = "yes";
$allow_edit = "yes";
$allow_chmod = "yes";
$allow_delete = "yes";
$allow_upload = "yes";
$allow_create_dir = "yes";
$allow_create_file = "yes";
$allow_display_env = "no";
$not_allowed = "This action is not allowed. Consult your system administrator.";
$version = "2.0";
############### Size for textarea
if($enable_css == "yes")
{
$textrows = "27";
$textcols = "90";
}
else
{
$textrows = "20";
$textcols = "90";
}
############### If $wdir (working directory) isn't specified, set it as a slash (/)
if(!$wdir) $wdir="/";
############### HTML ender
$html_ender = "</td></tr></table></body></html>";
############### Calculate image size
function imagesize()
{
$size = GetImageSize("$image");
}
############### HTML header
function html_header(){
global $basedir;
global $pages;
global $wdir;
global $lastaction;
global $version;
global $HTTP_REFERER;
global $action;
global $webname;
global $display;
global $file;
global $browse;
global $raw;
global $image;
global $fileurl;
global $enable_css;
global $allow_display_env;
global $enable_logout;
echo "<html style=\"font: 6 pt 'MS Shell Dlg', Helvetica, sans-serif; width: 500px; height: 510px; \">";
echo "";
echo "<HEAD>";
echo "<TITLE>(Dsm) Light $version ($webname)</TITLE>
<script language=\"Javascript1.2\"><!-- // load htmlarea
_editor_url = \"\"; // URL to htmlarea files
_editor_field = \"\";
var win_ie_ver = parseFloat(navigator.appVersion.split(\"MSIE\")[1]);
if (navigator.userAgent.indexOf('Mac') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Opera') >= 0) { win_ie_ver = 0; }
if (win_ie_ver >= 5.5) {
document.write('<scr' + 'ipt src=\"' +_editor_url+ 'editor.js\"');
document.write(' language=\"Javascript1.2\"></scr' + 'ipt>');
} else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
// --></script>
";
############### Cascaded Style Sheets
if($enable_css == "yes")
{
?>
<STYLE TYPE="text/css">
<!--
BODY {
background: background : ButtonFace;
color: windowtext;
font: 8pt 'MS Shell Dlg', arial, sans-serif;
}
td {
font: 7pt
}
input
{
font-family : Arial, Helvetica;
font-size : 8;
color : #000033;
font-weight : normal;
border-color : #999999;
border-width : 1;
background-color : #FFFFFF;
}
textarea
{
font-family : Arial, Helvetica;
font-size : 10;
color : #000033;
font-weight : normal;
border-color : #999999;
border-width : 1;
background-color : #FFFFFF;
}
.tditem {
font-size: 8px;
text-decoration: none;
color: gray;
}
-->
</style>
<?
}
echo "<meta HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=windows-1255\">";
echo "</HEAD>";
echo "<BODY style='background : ButtonFace; color: windowtext; margin: 10px; BORDER-STYLE: none' font-size: 7px;\" link=\"#626262\" vlink=\"#626262\" alink=\"#626262\">";
echo "<fieldset align=\"center\" width=\"290\">
<legend align=\"left\">(Dsm) Light - $version</legend>";
echo "<table border=\"0\" align=\"center\" cellspacing=\"2\" cellpadding=\"2\" width=\"100%\"><tr>";
echo "<td>";
echo " <A HREF=\"$PHP_SELF?action=help&wdir=$wdir\"><img src=\"../images/help.gif\" alt=\"Help for DsM light\" border=\"0\" width=\"16\" height=\"16\"></A> ";
if($allow_display_env == "yes")
{
echo " <A HREF=\"$PHP_SELF?action=env&wdir=$wdir\"><img src=\"../images/env.gif\" alt=\"Environment\" border=\"0\" width=\"16\" height=\"15\"></A> ";
}
if($enable_logout == "yes")
{
echo " <A onclick=\"self.close()\" HREF=\"$PHP_SELF?action=logout\"><img src=\"../images/DsM_explorer_close.gif\" width=\"18\" height=\"17\" alt=\"Logout and close Window\" border=\"0\"></A> ";
}
echo "</td>";
echo "<td align=\"right\"><A HREF=\"$PHP_SELF?wdir=$wdir\" title=\"Refresh current dir\">$wdir</font><img src=\"../images/refresh.gif\" border=\"0\" width=\"16\" height=\"16\" align=\"absmiddle\" hspace=\"2\"></a> <A HREF=\"$PHP_SELF?action=root\"><img src=\"../images/home.gif\" width=\"14\" height=\"14\" alt=\"Back to Main Dir\" border=\"0\" align=\"absmiddle\" hspace=\"2\"></a></td>
";
echo "</tr></table></fieldset>";
############ We want a BACK link when viewing pictures and raw text.
if($action == "show")
{
echo "<br><a href=\"$HTTP_REFERER\" title=\"Back to previous page\"><img src=\"../images/back.gif\" width=\"20\" height=\"22\" alt=\"Back\" border=\"0\"></a> ";
echo "$lastaction<br><br>";
}
############ We dont want a BACK link
else
{
echo "<br>$lastaction</font></b><br>";
}
}
############ File size calculations
function display_size($file){
$file_size = filesize($file);
if($file_size >= 1073741824)
{
$file_size = round($file_size / 1073741824 * 100) / 100 . "g";
}
elseif($file_size >= 1048576)
{
$file_size = round($file_size / 1048576 * 100) / 100 . "m";
}
elseif($file_size >= 1024)
{
$file_size = round($file_size / 1024 * 100) / 100 . "k";
}
else{
$file_size = $file_size . "b";
}
return $file_size;
}
############ List the files function
function list_files()
{
global $basedir;
global $pages;
global $wdir;
global $single;
global $key;
global $allow_move;
global $allow_chmod;
global $allow_create_file;
global $allow_create_dir;
global $allow_upload;
global $allow_touch;
global $allow_delete;
################## Load directory into array
$handle=opendir(".");
while ($file = readdir($handle))
{
if(is_file($file)) $filelist[] = $file;
}
closedir($handle);
############### List files
if($filelist)
{
############### Sort the filelist alphabetically
asort($filelist);
while (list ($key, $file) = each ($filelist))
{
############### Registered filetypes. You can add more filetypes here at wish..
############### Check what fileformat it is and give it the correct icon and attributes
$ext = strrchr ( $file , "." );
############### gif
if(!strcasecmp ($ext, ".gif"))
{
$icon = "<IMG SRC=\"../images/gif.gif\" alt=\"gif file\" border=\"0\" width=\"20\" height=\"20\">";
$browse = "1";
$raw = "0";
$image = "1";
}
############### png
elseif(!strcasecmp ($ext, ".png"))
{
$icon = "<IMG SRC=\"../images/png.gif\" alt=\"PNG file\" border=\"0\" width=\"16\" height=\"16\">";
$browse = "1";
$raw = "0";
$image = "1";
}
############### bmp
elseif(!strcasecmp ($ext, ".bmp"))
{
$icon = "<IMG SRC=\"../images/bmp.gif\" alt=\"BMP file\" border=\"0\" width=\"20\" height=\"20\">";
$browse = "1";
$raw = "0";
$image = "1";
}
############### CSS
elseif(!strcasecmp ($ext, ".css"))
{
$icon = "<IMG SRC=\"../images/css.gif\" alt=\"CSS file\" border=\"0\" width=\"20\" height=\"20\">";
$browse = "1";
$raw = "1";
$image = "0";
}
############### PPT
elseif(!strcasecmp ($ext, ".ppt"))
{
$icon = "<IMG SRC=\"../images/ppt.gif\" alt=\"Power point file\" border=\"0\" width=\"19\" height=\"19\">";
$browse = "1";
$raw = "0";
$image = "0";
}
############### Excel
elseif((!strcasecmp ($ext, ".xls")) || (!strcasecmp ($ext, ".csv")))
{
$icon = "<IMG SRC=\"../images/xls.gif\" alt=\"Excel file\" border=\"0\" width=\"17\" height=\"17\">";
$browse = "1";
$raw = "0";
$image = "0";
}
############### Flash
elseif((!strcasecmp ($ext, ".fla")) || (!strcasecmp ($ext, ".swf")))
{
$icon = "<IMG SRC=\"../images/fla.gif\" alt=\"FLASH file\" border=\"0\" width=\"19\" height=\"19\">";
$browse = "1";
$raw = "0";
$image = "0";
}
############### PSD
elseif(!strcasecmp ($ext, ".psd"))
{
$icon = "<IMG SRC=\"../images/psd.gif\" alt=\"psd file\" border=\"0\" width=\"19\" height=\"19\">";
$browse = "1";
$raw = "0";
$image = "0";
}
############### WORD
elseif(!strcasecmp ($ext, ".doc"))
{
$icon = "<IMG SRC=\"../images/word.gif\" alt=\"WORD file\" border=\"0\" width=\"17\" height=\"17\">";
$browse = "1";
$raw = "0";
$image = "0";
}
############### php
elseif((!strcasecmp ($ext, ".php")) || (!strcasecmp ($ext, ".php3")) || (!strcasecmp ($ext, ".phtml")) || (!strcasecmp ($ext, ".php4")) || (!strcasecmp ($ext, ".phps")))
{
$icon = "<IMG SRC=\"../images/php.gif\" alt=\"BMP file\" border=\"0\" width=\"20\" height=\"20\">";
$browse = "1";
$raw = "1";
$image = "0";
}
############### jpg
elseif((!strcasecmp ($ext, ".jpg")) || (!strcasecmp ($ext, ".jpeg")))
{
$icon = "<IMG SRC=\"../images/jpg.gif\" alt=\"JPG file\" border=\"0\" width=\"20\" height=\"20\">";
$browse = "1";
$raw = "0";
$image = "1";
}
############### Textfile
elseif(!strcasecmp ($ext, ".txt"))
{
$icon = "<IMG SRC=\"../images/text.gif\" alt=\"Text\" border=\"0\" width=\"13\" height=\"16\">";
$browse = "1";
$raw = "1";
$image = "0";
}
############### Audiofile
elseif((!strcasecmp ($ext, ".wav")) || (!strcasecmp ($ext, ".mp2")) || (!strcasecmp ($ext, ".mp3")) || (!strcasecmp ($ext, ".mp4")) || (!strcasecmp ($ext, ".vqf")) || (!strcasecmp ($ext, ".midi")) || (!strcasecmp ($ext, ".mid")))
{
$icon = "<IMG SRC=\"../images/audio.gif\" alt=\"Audio\" border=\"0\" width=\"16\" height=\"16\">";
$browse = "1";
$raw = "0";
$image = "0";
}
############### REAL Audio file
elseif((!strcasecmp ($ext, ".ra")) || (!strcasecmp ($ext, ".ram")))
{
$icon = "<IMG SRC=\"../images/real.gif\" alt=\"Real Audio\" border=\"0\" width=\"19\" height=\"19\">";
$browse = "1";
$raw = "0";
$image = "0";
}
############### Media Player file
elseif((!strcasecmp ($ext, ".asf")) || (!strcasecmp ($ext, ".aifc")) || (!strcasecmp ($ext, ".asx")) || (!strcasecmp ($ext, ".mp2v")) || (!strcasecmp ($ext, ".mpeg")) || (!strcasecmp ($ext, ".mpg")) || (!strcasecmp ($ext, ".mpe")) || (!strcasecmp ($ext, ".wma")) || (!strcasecmp ($ext, ".wmv")) || (!strcasecmp ($ext, ".wvx")))
{
$icon = "<IMG SRC=\"../images/asf.gif\" alt=\"Real Audio\" border=\"0\" width=\"19\" height=\"19\">";
$browse = "1";
$raw = "0";
$image = "0";
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -