/*
Traverse folders; Function: (a) Deleteable files (b) Editable text, web page files (c) Deleteable folders, provided that the If the folder is empty (d) you can create files, folders, and modify the folder name;
Original by lost63.com, please indicate the source for reprinting. Communication QQ: 35501547
*/
$path=$DOCUMENT_ROOT ;
$path=str_replace("/","\",$path);
//Specify the folder
$path=$path."\";
if($_GET[ 'folder'])
{
$path.=$_GET['folder']."\";
}
//The path of this page will be used when returning below;
$url=$_SERVER['PHP_SELF'];
//If it is a folder, a link will be added;
function folder($path,$str)
{
if(filetype ($path.$str)=="dir")
{
return "
$str";
}else{
return $str;
}
}
switch($_GET['action'])
{
case "del";
if($_GET['type']=="file")
{
unlink($_GET['path']);
}else{
rmdir($_GET['path']);
}
echo "";
break;
case "edit";
if($_GET['type']=="file")
{
$file=fopen($_GET['path'],"r");
while(!feof($file))
{
$result.=fgets($file,9999) ;
}
fclose($file);
echo '
';
}else{
echo '
';
}
break;
case "editsave";
$file=fopen($_GET['path'],"w");
fwrite($file,$_POST['textarea']);
fclose($file);
echo "";
break;
case "addfile";
echo '
';
break;
case "filesave";
//包含点则建立文件,否则建立文件夹
if(strpos($_POST['filename'],"."))
{
$file=fopen($_POST['filename'],"w");
fwrite($file,$_POST['textarea']);
fclose($file);
}else{
//文件夹若存在则退出,不存在则建立!
if(file_exists($_POST['filename']))
{
exit;
}else{
mkdir($_POST['filename']);
}
}
echo "";
break;
case "dir_rename";
rename($_GET['path'],$_POST['filename']);
echo "";
break;
default:
$s=explode("n",trim(`dir/b/o:gn $path`));
echo '
>> 文件管理 > 建立文件 > 返回 |
文件/文件夹 |
文件属性 |
文件大小 |
操作 |
';
foreach($s as $value)
{
echo '
'.folder($path,$value).' |
'.filetype($path.$value).' |
'.round(filesize($path.$value)/1024).'kb |
编辑 | 删除 |
';
}
echo "
";
break;
}
?>