功能控制完備的PHP上傳程式(3)

來源:互聯網
上載者:User

 

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

?>

<html>

<head>

<title>檔案管理</title>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

</head>

<SCRIPT LANGUAGE="JavaScript">

<!--

function MM_goToURL() { //v3.0

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

 for (i=0; i<(args.length-1); i+=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{



}

}

//-->

</SCRIPT>

<body bgcolor="#FFFFFF">

<table width="80%" border="0" cellspacing="0" cellpadding="1" align="center">

 <tr>

   <td width="25%"> </td>

 </tr>

 <tr>

   <td width="25%">操作ID:<?echo $actionid;?></td>

 </tr>

 <tr>

   <td width="25%">使用者名稱:<?echo $username;?></td>

 </tr>

 <tr>

   <td width="25%">目前的目錄:<?echo $targetDir?></td>

 </tr>

 <tr>

   <td width="25%"> </td>

 </tr>

</table>

<table width="95%" border="0" cellspacing="0" cellpadding="4" align="center">

 <tr bgcolor="#000066">

   <td width="46%"><font color="#FFFFFF">檔案名稱</font></td>

   <td width="20%"><font color="#FFFFFF">檔案大小</font></td>

   <td width="22%"><font color="#FFFFFF">建立時間</font></td>

   <td width="12%" align="center"><font color="#FFFFFF">有關操作</font></td>

 </tr>

</table>

<table width="95%" border="0" 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"><td width="46%">$file</td>

   <td width="20%">";

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

echo "</td><td width="22%">";

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

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

print($filemodtime);

echo "</td><td width="12%" align="center"><a href=javascript:mydelfun('$file');>刪除</a></td></tr>";

}

}

closedir($handle);

?>

</table>

<table width="80%" border="0" cellspacing="0" cellpadding="0" align="center">

 <tr>

   <td> </td>

 </tr>

 <tr align="center">

   <td>本操作ID的 <a href=upfile.php?actid=<? echo $actionid?>&type=up" target="_blank">上傳日誌</a> <a href=upfile.php?actid=<? echo $actionid?>&type=del" target="_blank">管理日誌</a></td>

</tr>

</table>

</body>

</html>



<?

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,確保系統路徑不被泄漏)



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.