$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;}