Home > php教程 > php手册 > body text

功能控制完备的PHP上载程序(3)

WBOY
Release: 2016-06-21 09:02:19
Original
986 people have browsed it

 

get_config($configureFile,$actionid,"upload");

?>





文件管理





() { //v3.0

 var i, args=MM_goToURL.arguments; document.MM_returnValue = false;

 for (i=0; ii+=2) eval(args[i]+".location='"+args[i+1]+"'");

}

function mydelfun(fileName) {

answer=confirm('您确定要删除'+fileName+'文件吗?');

if(answer == 1){

MM_goToURL('parent','upfile.php?actid= echo $actionid;?>&username= echo $username;?>&filename='+fileName+'&sec= echo $password;?>');return document.MM_returnValue;}

else{



}

}

//-->



bgcolor
="#FFFFFF">

cellspacing="0" cellpadding="1" align="center">

 tr>

   

 tr>

 tr>

   

 tr>

 tr>

   

 tr>

 tr>

   

 tr>

 tr>

   

 tr>

  操作IDactionid;?> 用户名: 当前目录:targetDir?>  


cellspacing="0" cellpadding="4" align="center">

 tr bgcolor="#000066">

   

   

   

   

 tr>

文件名称 文件大小 创建时间 有关操作


cellspacing="0" cellpadding="3" align="center">



$handle=opendir($targetDir."/");

$maxLength=1;

while ($file = readdir($handle)) {

if(is_file($targetDir."/".$file)){

   if($maxLength%2) {$mbgc="#CCCCCC";}else{$mbgc="#ffffff";}

$maxLength++;

echo "tr bgcolor="$mbgc">

   tr>";

}

}

closedir($handle);

?>

$file ";

echo filesize($targetDir."/".$file);

echo "
";

$filemod = filemtime($targetDir."/".$file);

$filemodtime = date("Y-m-d H:i:s", $filemod);

print($filemodtime);

echo "
href=javascript:mydelfun('$file');>删除


cellspacing="0" cellpadding="0" align="center">

 tr>

   

 tr>

 tr align="center">

   

tr>

  本操作ID href=upfile.php?actid= echo $actionid?>&type=up" target="_blank">上传日志 href=upfile.php?actid= echo $actionid?>&type=del" target="_blank">管理日志










exit;

};

##删除管理完毕

##
删除文件操作

if($sec){//

get_config($configureFile,$actid,"upload");

unlink($targetDir."/".$filename);

$message=date("Y-m-d H:i:s")." remote_ip:".$REMOTE_ADDR." UserName:".$username." delete FileName:".$filename."";

putLog($actid,$message,"b");

header("location:upfile.php?username=$username&actionid=$actid&actiontype=del&password=$sec");

exit;

}



if($type){}else{exit;};

function showLog($actid,$flag="a"){

$logfile="./log/".$actid.$flag.".log";

if(!file_exists($logfile)){echo "
该操作ID暂时没有任何日志!";};

$logarray=file($logfile);

while (list($key,$value) = each($logarray)) {

echo $value."br
>";

}

}

if(trim($type)=="del"){showLog($actid,$flag="b");}else{showLog($actid);};

//主程序结束

?>

   ■
配置文件 config.inc.php



####################################################################
#Project Name: Test
#Author :lanf
#Home Page: http://lanf.yeah.net
#E-mail:imbusy@263.net
#Time: 2001 . 9
####################################################################


[table up]

#id dir user max(kb) type check limit callback

fa001 /home/lanf/upload * 1900 * * * ./
#
这就是说,标志为fa001的上传中,目标路径是/home/lanf/upload(当然这需要赋予php在这个目录下写的权限),限定的操作用户是*(表示任何人,当然你也可以限制为lanf,yy等等),每次上传的大小限制为1900KB,类型为任何类型(*,当然你也可以限制为gif,jpg等后缀,用逗号分隔。如果限制是gif或者jpg的话,系统自动读取若干字节检查文件类型是否为伪冒check项为是否调用外部程序检验上传文件真伪,若不调用,直接写*,调用直接写该文件绝对路径。limit项是针对调用页的限制,不限制可以写*,限制的话,填写该主机域名或者ip地址,可以支持192.*.*.*等区域授权方式。最后一项是返回页面,上传文件后调用哪个URL(注意,填写的是url,确保系统路径不被泄漏)



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template