Functional Control Complete PHP upload Program (2)

Source: Internet
Author: User
Tags exit command line continue modify strlen trim

$canshuZoneId = 1;

}else{

if ($canshuZoneId ==0) {

Continue

}else{

Break

}

}

}else{

if ($canshuZoneId ==0) continue;

}//Zone Selection End





$id _temp=substr ($value, 0, $keylength);

if ($id _temp== $actionID) {

Start taking parameters

$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 end, can run to this step shows that no matching IDs were found

return false;



}elseif ($actionType = = "Del") {



If you are deleting a file operation

while (the list ($key, $value) = each ($fileArray)) {

$value =trim ($value);

To determine the parameter range, restrict parameter extraction to the delete file Settings area

$Zone _temp=substr ($value, 0, 1);

if ($Zone _temp== "[") {//start a parameter area

if (Strstr ($value, "Del")) {

$canshuZoneId = 1;

}else{

if ($canshuZoneId ==0) {

Continue

}else{

Break

}

}

}else{

if ($canshuZoneId ==0) continue;

}//Zone Selection End





$id _temp=substr ($value, 0, $keylength);

if ($id _temp== $actionID) {

Start taking parameters

$user =trim (STRRCHR ($value, ""));



return true;

}else{

Continue

}



}//while end, can run to this step shows that no matching IDs were found



return false;

}else{//is neither up nor Del

return false;

};



return false;

}

# #取配置文件参数函数结束



Main program

$configureFile = "config.inc.php";

$actiontype =trim ($actiontype);



# #上传文件

if ($actiontype = = "Upload") {

if (!) ( $actionid && $username && $password && $userfile _name)) {

echo "
Exit

}



if (!get_config ($configureFile, $actionid, $actiontype)) {echo


if ($userfile _size> $maxLength *1024) {echo


if (!getuserright ($username, $user) &&!getfiletype ($userfile _name, $fileType)) {exit;}//Adjustable



if ($limitSite!= "*") if (Checkfromsiteerr ($HTTP _referer, $limitSite) exit;



if ($checkFile!= "*") {

$cmd _return_var=passthru ($checkFile.) ". $userfile _name);//Command line parameters ask to check file name + space + upload filename

$cmd _return_var=true;//program to be used when developing, please delete
if (! $cmd _return_var) {

echo "
Exit

}

};//calls the external program check, does not meet the requirements of the file return False, meet the requirements return true;



if ("" ==trim ($newname)) {$newname = $userfile _name;};/ /process file name

$targetFileName = $targetDir. " /". $newname;



if (file_exists ($targetFileName)) {

$oldTargetSize =filesize ($targetFileName);

if ($userfile _size<= $oldTargetSize) {

echo
Exit

}

};



Copy ($userfile, $targetFileName) or die;

chmod ($targetFileName, 0666);//110110110





Log information

$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 "
Exit

}



if (!get_config ($configureFile, $actionid, $actiontype)) {echo


if (!getuserright ($username, $user)) {exit;}



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.