tpupload.php 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?
  2. include("../config/conn.php");
  3. include("../config/function.php");
  4. include("../config/tpclass.php");
  5. AdminSes_audit();
  6. $bh=returndeldian($_GET[bh]);
  7. if(!preg_match("/^[-a-zA-Z0-9]*$/",$bh)){exit;}
  8. $sj=date("Y-m-d H:i:s");
  9. $admin=intval($_GET[admin]);
  10. if($_GET[action]=="update"){ //上传
  11. if($admin==1){ //商品B
  12. if(!strstr($adminqx,",0,") && !strstr($adminqx,",0101,")){Audit_alert("权限不够","default.php");}
  13. while1("*","yjcode_pro where bh='".$bh."'");if(!$row1=mysql_fetch_array($res1)){Audit_alert("来源错误","./","parent.");}
  14. $targetFolder = "upload/".$row1[userid]."/".$bh."/";
  15. createDir("../".$targetFolder);
  16. $total = count($_FILES['inp1']['tmp_name']);
  17. for($k=0; $k<$total; $k++) {
  18. if(returncount("yjcode_tp where bh='".$bh."'")<7){
  19. if(is_uploaded_file($_FILES['inp1']['tmp_name'][$k])){
  20. $sj=date("Y-m-d H:i:s");
  21. $mbh=str_replace(" ","",microtime()."tp".$row1[userid]);
  22. $mbh=str_replace(".","",$mbh);
  23. $targetFile = "../".$targetFolder.$mbh.".jpg";
  24. move_uploaded_file($_FILES['inp1']['tmp_name'][$k],$targetFile);
  25. $cm=new CreatMiniature();
  26. $bw=800;$bg=0;$sw=500;$sh=500;$zw=200;$zh=200;
  27. $imgsrc="../".$targetFolder.$mbh.".jpg";
  28. list($width, $height) = getimagesize(weburl.$targetFolder.$mbh.".jpg");$bgv=intval($height/($width/$bw));
  29. $cm->SetVar($imgsrc,"file");if($width>$bw){$cm->BackFill($imgsrc,$bw,$bgv);}
  30. imageWaterMark($imgsrc,websypos,"../img/shuiyin.png","","","","",0,0);
  31. if($sw>$width){$sw=$width;}if($sh>$height){$sh=$height;}
  32. if(empty($rowcontrol[picys])){$cm->Cut("../".$targetFolder.$mbh."-1.jpg",$sw,$sh);}else{$cm->BackFill("../".$targetFolder.$mbh."-1.jpg",$sw,$sh);}
  33. if($zw>$width){$zw=$width;}if($zh>$height){$zh=$height;}
  34. if(empty($rowcontrol[picys])){$cm->Cut("../".$targetFolder.$mbh."-2.jpg",$zw,$zh);}else{$cm->BackFill("../".$targetFolder.$mbh."-2.jpg",$zw,$zh);}
  35. $wjv=$targetFolder.$mbh.".jpg";
  36. $nxh=returnxh("yjcode_tp"," and bh='".$bh."'");
  37. //OSSB
  38. if(check_in("a2a",$rowcontrol[aliosskg])){
  39. $upty=1;
  40. include('../config/alioss/Common.php');
  41. $bucket = Common::getBucketName();
  42. $ossClient = Common::getOssClient();
  43. if(!is_null($ossClient)){;
  44. $ossClient->setTimeout(3600);
  45. $ossClient->setConnectTimeout(3600);
  46. $ossClient->createObjectDir($bucket, $targetFolder);
  47. $ossClient->uploadFile($bucket,$targetFolder.$mbh.".jpg",$targetFile);
  48. $ossClient->uploadFile($bucket,$targetFolder.$mbh."-1.jpg","../".$targetFolder.$mbh."-1.jpg");
  49. $ossClient->uploadFile($bucket,$targetFolder.$mbh."-2.jpg","../".$targetFolder.$mbh."-2.jpg");
  50. delFile($targetFile);
  51. delFile("../".$targetFolder.$mbh."-1.jpg");
  52. delFile("../".$targetFolder.$mbh."-2.jpg");
  53. $alioss=preg_split("/,/",$rowcontrol[alioss]);
  54. $wjv="https://".$alioss[3].".".$alioss[2]."/".$targetFolder.$mbh.".jpg";
  55. }
  56. }
  57. //OSSE
  58. intotable("yjcode_tp","bh,tp,type1,sj,userid,xh,upty","'".$bh."','".$wjv."','商品','".$sj."',".$row1[userid].",".$nxh.",".intval($upty)."");
  59. }
  60. }
  61. }
  62. }elseif($admin==6){ //资讯
  63. if(!strstr($adminqx,",0,") && !strstr($adminqx,",0201,")){Audit_alert("权限不够","default.php");}
  64. while1("*","yjcode_news where bh='".$bh."'");if(!$row1=mysql_fetch_array($res1)){Audit_alert("来源错误","./","parent.");}
  65. createDir("../upload/news/".dateYMDN($row1[sj])."/");
  66. $targetFolder="upload/news/".dateYMDN($row1[sj])."/".$bh."/";
  67. createDir("../".$targetFolder);
  68. $total = count($_FILES['inp1']['tmp_name']);
  69. for($k=0; $k<$total; $k++) {
  70. if(returncount("yjcode_tp where bh='".$bh."'")<1){
  71. if(is_uploaded_file($_FILES['inp1']['tmp_name'][$k])){
  72. $sj=date("Y-m-d H:i:s");
  73. $mbh=str_replace(" ","",microtime()."tp".$row1[userid]);
  74. $mbh=str_replace(".","",$mbh);
  75. $targetFile = "../".$targetFolder.$mbh.".jpg";
  76. move_uploaded_file($_FILES['inp1']['tmp_name'][$k],$targetFile);
  77. $cm=new CreatMiniature();
  78. $bw=600;$bg=500;$sw=200;$sh=160;
  79. $imgsrc="../".$targetFolder.$mbh.".jpg";
  80. list($width, $height) = getimagesize(weburl.$targetFolder.$mbh.".jpg");$bgv=intval($height/($width/$bw));
  81. $cm->SetVar($imgsrc,"file");if($width>$bw){$cm->Cut($imgsrc,$bw,$bgv);}
  82. imageWaterMark($imgsrc,websypos,"../img/shuiyin.png","","","","",0,0);
  83. if($width>$sw){$cm->Cut("../".$targetFolder.$mbh."-1.jpg",$sw,$sh);}else{copy($imgsrc,"../".$targetFolder.$mbh."-1.jpg");}
  84. $wjv=$targetFolder.$mbh.".jpg";
  85. $nxh=returnxh("yjcode_tp"," and bh='".$bh."'");
  86. intotable("yjcode_tp","bh,tp,type1,iffm,sj,userid,xh","'".$bh."','".$wjv."','资讯',1,'".$sj."',".returnjgdw($row1[userid],"",0).",".$nxh."");
  87. }
  88. }
  89. }
  90. }elseif($admin==7){ //服务
  91. if(!strstr($adminqx,",0,") && !strstr($adminqx,",0101,")){Audit_alert("权限不够","default.php");}
  92. while1("*","yjcode_server where bh='".$bh."'");if(!$row1=mysql_fetch_array($res1)){Audit_alert("来源错误","./","parent.");}
  93. $targetFolder = "upload/".$row1[userid]."/".$bh."/";
  94. createDir("../".$targetFolder);
  95. $total = count($_FILES['inp1']['tmp_name']);
  96. for($k=0; $k<$total; $k++) {
  97. if(returncount("yjcode_tp where bh='".$bh."'")<7){
  98. if(is_uploaded_file($_FILES['inp1']['tmp_name'][$k])){
  99. $sj=date("Y-m-d H:i:s");
  100. $mbh=str_replace(" ","",microtime()."tp".$row1[userid]);
  101. $mbh=str_replace(".","",$mbh);
  102. $targetFile = "../".$targetFolder.$mbh.".jpg";
  103. move_uploaded_file($_FILES['inp1']['tmp_name'][$k],$targetFile);
  104. $cm=new CreatMiniature();
  105. $bw=800;$bg=0;$sw=300;$sh=200;
  106. $imgsrc="../".$targetFolder.$mbh.".jpg";
  107. list($width, $height) = getimagesize(weburl.$targetFolder.$mbh.".jpg");$bgv=intval($height/($width/$bw));
  108. $cm->SetVar($imgsrc,"file");if($width>$bw){$cm->BackFill($imgsrc,$bw,$bgv);}
  109. imageWaterMark($imgsrc,websypos,"../img/shuiyin.png","","","","",0,0);
  110. if($sw>$width){$sw=$width;}if($sh>$height){$sh=$height;}
  111. if(empty($rowcontrol[picys])){$cm->Cut("../".$targetFolder.$mbh."-1.jpg",$sw,$sh);}else{$cm->BackFill("../".$targetFolder.$mbh."-1.jpg",$sw,$sh);}
  112. $wjv=$targetFolder.$mbh.".jpg";
  113. $nxh=returnxh("yjcode_tp"," and bh='".$bh."'");
  114. intotable("yjcode_tp","bh,tp,type1,sj,userid,xh,upty","'".$bh."','".$wjv."','服务','".$sj."',".$row1[userid].",".$nxh.",".intval($upty)."");
  115. }
  116. }
  117. }
  118. }
  119. php_toheader("tpupload.php?bh=".$bh."&admin=".$admin."&t=suc");
  120. }
  121. ?>
  122. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  123. <html xmlns="http://www.w3.org/1999/xhtml">
  124. <head>
  125. <meta http-equiv="x-ua-compatible" content="ie=7" />
  126. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  127. <title>图片上传</title>
  128. <style type="text/css">
  129. body{margin:0;font-size:12px;color:#333;}
  130. *{margin:0 auto;padding:0;}
  131. ul{list-style-type:none;margin:0;padding:0;}
  132. .main{float:left;width:150px;height:33px;cursor:pointer;}
  133. #upload input{position: relative;border:solid transparent;opacity: 0;filter:alpha(opacity=0); cursor: pointer;float:left;width:150px;height:33px;z-index:2;}
  134. #upload .inptp{position:relative;overflow: hidden;display:inline-block;*display:inline;padding:6px 0 0 0;height:27px;text-align:center;cursor:pointer;width:150px;float:left;color:#fff;background-color:#00B7EE;font-family:"Microsoft YaHei",微软雅黑,"MicrosoftJhengHei",华文细黑,STHeiti,MingLiu;font-size:14px;margin-top:-33px;z-index:1;}
  135. @media screen and (-webkit-min-device-pixel-ratio:0) {
  136. #upload .inptp{margin-top:-39px;}
  137. }
  138. #uping{float:left;padding:5px 0 0 0;height:26px;text-align:center;width:148px;border:#00B7EE dotted 1px;font-family:"Microsoft YaHei",微软雅黑,"MicrosoftJhengHei",华文细黑,STHeiti,MingLiu;font-size:14px;color:#ff6600;background-color:#f2f2f2;}
  139. </style>
  140. <script language="javascript">
  141. function filecha(){
  142. document.getElementById("upload").style.display="none";
  143. document.getElementById("uping").style.display="";
  144. tpf.submit();
  145. }
  146. </script>
  147. </head>
  148. <body>
  149. <div class="main">
  150. <!--等待上传开始-->
  151. <form method="post" name="tpf" enctype="multipart/form-data" action="tpupload.php?bh=<?=$bh?>&admin=<?=$admin?>&action=update">
  152. <div id="upload">
  153. <input type="file" onchange="filecha()" multiple="multiple" name="inp1[]" size="25" accept=".jpg,.gif,.jpeg,.png">
  154. <span class="inptp">选择图片上传</span>
  155. </div>
  156. <input type="hidden" value="upload" name="yjcode" />
  157. </form>
  158. <!--等待上传结束-->
  159. <!--正在上传-->
  160. <div id="uping" style="display:none;">正在处理图片……</div>
  161. <!--正在上传-->
  162. </div>
  163. <? if($_GET[t]=="suc"){?>
  164. <script language="javascript">
  165. parent.xgtread("<?=$bh?>");
  166. </script>
  167. <? }?>
  168. </body>
  169. </html>