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

來源:互聯網
上載者:User

 

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



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.