$canshuzoneid=1;
}else{
if($canshuzoneid==0) {
continue;
}else{
break;
}
}
}else{
if($canshuzoneid==0) continue;
}//區域選擇結束
$id_temp=substr($value,0,$keylength);
if($id_temp==$actionid){
//開始取參數
$callback=trim(strrchr($value, " "));
$value=trim(substr($value,0,strlen($value)-strlen($callback)));
$limitsite=trim(strrchr($value, " "));
$value=trim(substr($value,0,strlen($value)-strlen($limitsite)));
$checkfile=trim(strrchr($value, " "));
$value=trim(substr($value,0,strlen($value)-strlen($checkfile)));
$filetype=trim(strrchr($value, " "));
$value=trim(substr($value,0,strlen($value)-strlen($filetype)));
$maxlength=trim(strrchr($value, " "));
$value=trim(substr($value,0,strlen($value)-strlen($maxlength)));
$user=trim(strrchr($value, " "));
$value=trim(substr($value,0,strlen($value)-strlen($user)));
$targetdir=trim(strrchr($value, " "));
$value=trim(substr($value,0,strlen($value)-strlen($targetdir)));
return true;
}else{
continue;
}
}//while結束,能運行到這一步說明沒有找到匹配的id
return false;
}elseif($actiontype=="del"){
//如果是刪除文件操作
while (list($key,$value) = each($filearray)) {
$value=trim($value);
//判斷參數區域,將參數提取限制在 刪除 文件設置區
$zone_temp=substr($value,0,1);
if($zone_temp=="["){//開始一個參數區域
if(strstr($value, "del")){
$canshuzoneid=1;
}else{
if($canshuzoneid==0) {
continue;
}else{
break;
}
}
}else{
if($canshuzoneid==0) continue;
}//區域選擇結束
$id_temp=substr($value,0,$keylength);
if($id_temp==$actionid){
//開始取參數
$user=trim(strrchr($value, " "));
return true;
}else{
continue;
}
}//while結束,能運行到這一步說明沒有找到匹配的id
return false;
}else{//既不是up,也不是del
return false;
};
return false;
}
##取配置文件參數函數結束
//主程序
$configurefile="config.inc.php";
$actiontype=trim($actiontype);
##上傳文件
if($actiontype=="upload"){
if(!($actionid && $username && $password && $userfile_name)) {
echo "<html>操作id、用戶名、密碼、上傳文件缺一不可!<a href=javascript:window.history.back()>點這里返回修改</a></html>";
exit;
}
if(!get_config($configurefile,$actionid,$actiontype)){echo "<html>不合法的操作id。<a href=javascript:window.history.back()>點這里返回修改</a></html>";exit;}
if($userfile_size>$maxlength*1024){echo "<html>上傳的文件超過規定大小的上限。<a href=javascript:window.history.back()>點這里返回修改</a></html>";exit;}
if(!getuserright($username,$user) && !getfiletype($userfile_name,$filetype)){exit;} //可調整
if($limitsite!="*") if(checkfromsiteerr($http_referer,$limitsite)) exit;
if($checkfile!="*") {
$cmd_return_var=passthru($checkfile." ".$userfile_name);//命令行參數要求問檢查文件名 + 空格 + 上傳文件名
//$cmd_return_var=true;//程序開發的時候使用,請刪除
if(!$cmd_return_var){
echo "<html>您上傳的文件沒有通過我們的檢查,請上傳符合要求的文件。<a href=javascript:window.history.back()>點這里返回修改</a></html>";
exit;
}
};//調用外部程序檢查,不符合要求的文件返回 false,符合要求返回true;
if(""==trim($newname)){$newname=$userfile_name;};//處理文件名
$targetfilename=$targetdir."/".$newname;
if(file_exists($targetfilename)){
$oldtargetsize=filesize($targetfilename);
if($userfile_size<=$oldtargetsize ){
echo "<html>您要上傳的目標文件已經存在。上傳動作被取消。<a href=javascript:window.history.back()>點這里返回修改</a></html>";
exit;
}
};
copy($userfile,$targetfilename) or die;
chmod($targetfilename,0666);//110110110
//日志信息
$message=date("y-m-d h:i:s")." remote_ip:".$remote_addr." username:".$username." filename:".$newname."";
putlog($actionid,$message);
header("location:".$callback);
exit;
};
##上傳完畢
##刪除管理
if($actiontype=="del"){
if(!($actionid && $username && $password )) {
echo "<html>操作id、用戶名、密碼缺一不可!<a href=javascript:window.history.back()>點這里返回修改</a></html>";
exit;
}
if(!get_config($configurefile,$actionid,$actiontype)){echo "<html>不合法的操作id。<a href=javascript:window.history.back()>點這里返回修改</a></html>";exit;}
if(!getuserright($username,$user)){exit;}
新聞熱點
疑難解答