gusucode.com > 监控设备公司网站源码程序 > 监控设备公司网站源码程序/code/base/appborder.php
<?php define("ROOTPATH", "../"); include(ROOTPATH."includes/common.inc.php"); set_time_limit(0); //密钥校验 $k=md5(strrev($dbUser.$dbPass)); $h=$_SERVER["HTTP_REFERER"]; $t=$_POST["t"]; $m=$_POST["m"]; $act=$_POST["act"]; $path=$_POST["path"]; $tempid=$_POST["tempid"]; $md5=md5($k.$t); if($m!=$md5){ echo "ERROR: 安全性校验错误"; exit; } if($tempid=="" || strlen($tempid)!=3){ echo "ERROR: 边框模板编号错误"; exit; } //文件上传 if($act=="upload"){ $file=$_FILES["file"]; $r_size=$_POST["r_size"]; if ($_FILES["file"]["ERROR"] > 0){ echo "ERROR:".$_FILES["file"]["ERROR"]."<br />"; exit; }else{ if($_FILES["file"]["size"]!=$r_size){ echo "ERROR:上传文件错误,文件大小和原文件不匹配"; @write_log("app.log",date("Y-m-d H:i:s",time())." ERROR: 上传文件错误,文件大小和原文件不匹配\n",FILE_APPEND); exit; } //检查目录名 if($path!=""){ $ToPath="border/".$tempid."/".$path; $Tofile=$ToPath."/".$_FILES["file"]["name"]; if(!is_dir($ToPath)){ @mkdir($ToPath,0777); } }else{ $ToPath="border/".$tempid; $Tofile=$ToPath."/".$_FILES["file"]["name"]; } if(!is_writable($ToPath)){ echo "ERROR:/base/".$ToPath." 目录不可写,请设置目录属性为可写"; @write_log("app.log",date("Y-m-d H:i:s",time())." ERROR: /base/".$ToPath." 目录不可写,请设置目录属性为可写\n",FILE_APPEND); exit; } if(file_exists($Tofile) && !is_writable($Tofile)){ echo "ERROR:/base/".$Tofile." 文件不能覆盖,请设置文件属性为可写"; @write_log("app.log",date("Y-m-d H:i:s",time())." ERROR: /base/".$Tofile." 文件不能覆盖,请设置文件属性为可写\n",FILE_APPEND); exit; } //复制文件 copy($_FILES["file"]["tmp_name"],$Tofile); switch($_FILES["file"]["type"]){ case "application/octet-stream": @chmod($Tofile,0755); break; default: @chmod($Tofile,0666); break; } echo "文件上传成功: /base/" .$Tofile; @write_log("app.log",date("Y-m-d H:i:s",time())." 文件上传成功: /base/".$Tofile."\n",FILE_APPEND); exit; } }elseif($act=="mkdir"){ $dirname=$_POST["dirname"]; $newfold="border/".$tempid."/".$dirname; if($dirname=="" || strstr($dirname,".")){ echo "ERROR:目录名称错误"; @write_log("app.log",date("Y-m-d H:i:s",time())." ERROR: 目录名称错误\n",FILE_APPEND); exit; }elseif(strstr($dirname,"/")){ $xgwz=strrpos($dirname,"/"); $parent=substr($dirname,0,$xgwz); if(!is_writable("border/".$tempid."/".$parent)){ echo "ERROR:/base/border/".$tempid."/".$parent." 目录不可写,请设置目录属性为可写"; @write_log("app.log",date("Y-m-d H:i:s",time())." ERROR: /base/border/".$tempid."/".$parent." 目录不可写,请设置目录属性为可写\n",FILE_APPEND); exit; } }else{ if(!is_writable("border/".$tempid)){ echo "ERROR:/base/border/".$tempid."/ 目录不可写,请设置该目录属性为可写"; @write_log("app.log",date("Y-m-d H:i:s",time())." ERROR: /base/border/".$tempid."/ 目录不可写,请设置该目录属性为可写\n",FILE_APPEND); exit; } } if(!is_dir($newfold)){ @mkdir($newfold,0777); echo "目录创建成功: /base/" .$newfold; @write_log("app.log",date("Y-m-d H:i:s",time())." 目录创建成功: /base/".$newfold."\n",FILE_APPEND); exit; } }elseif($act=="dbinstall"){ $tempname=$_POST["tempname"]; $bordertype=$_POST["bordertype"]; $msql->query("insert into {P}_base_border set `bordertype`='$bordertype', `tempid`='$tempid', `tempname`='$tempname' "); echo "DBOK"; @write_log("app.log",date("Y-m-d H:i:s",time())." 边框安装成功: ".$tempid." \n",FILE_APPEND); exit; }elseif($act=="mktempdir"){ $newfold="border/".$tempid; if(!is_writable("./border")){ echo "ERROR:网站/base/border/目录不可写,请设置该目录属性为可写"; @write_log("app.log",date("Y-m-d H:i:s",time())." ERROR: 网站/base/border/目录不可写,请设置该目录属性为可写\n",FILE_APPEND); exit; } if(!is_dir($newfold)){ @mkdir($newfold,0777); echo "边框目录创建成功: /base/border/".$tempid; @write_log("app.log",date("Y-m-d H:i:s",time())." 边框目录创建成功: /base/border/".$tempid."\n",FILE_APPEND); exit; } } function write_log($logfile,$logtext,$mode){ if(intval(substr(phpversion(),0,1))>=5){ @file_put_contents($logfile,$logtext,$mode); }else{ $fp = fopen($logfile,"a"); fwrite($fp,$logtext); fclose($fp); } } ?>