• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

功能控制完备的PHP上载程序(2)_php

php 搞代码 7年前 (2018-06-21) 178次浏览 已收录 0个评论

 

$canshuZoneId=1;

}else{

if($canshuZoneId==0) {

http://www.gaodaima.com/47440.html功能控制完备的php上载程序(2)_php

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

欢迎大家阅读《功能控制完备的PHP上载程序(2)_php》,跪求各位点评,若觉得好的话请收藏本文,by 搞代码


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:功能控制完备的PHP上载程序(2)_php

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址