tpupload.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <?
  2. include("../config/conn.php");
  3. include("../config/function.php");
  4. include("../config/tpclass.php");
  5. if(empty($_SESSION[SHOPUSER])){Audit_alert("登录超时","../reg/","parent.");}
  6. $userid=returnuserid($_SESSION[SHOPUSER]);
  7. $bh=returndeldian($_GET[bh]);
  8. if(!preg_match("/^[-a-zA-Z0-9]*$/",$bh)){exit;}
  9. $admin=intval($_GET[admin]);
  10. if($_GET[action]=="update"){ //上传
  11. $sj=date("Y-m-d H:i:s");
  12. if($admin==1){ //商品B
  13. $targetFolder = "upload/".$userid."/".$bh."/";
  14. createDir("../".$targetFolder);
  15. $total = count($_FILES['inp1']['tmp_name']);
  16. //OSSB
  17. if(check_in("a2a",$rowcontrol[aliosskg])){
  18. $upty=1;
  19. include('../config/alioss/Common.php');
  20. $bucket = Common::getBucketName();
  21. $ossClient = Common::getOssClient();
  22. }
  23. //OSSE
  24. for($k=0; $k<$total; $k++) {
  25. if(returncount("yjcode_tp where bh='".$bh."'")<7){
  26. if(is_uploaded_file($_FILES['inp1']['tmp_name'][$k])){
  27. $sj=date("Y-m-d H:i:s");
  28. $mbh=str_replace(" ","",microtime()."tp".$userid);
  29. $mbh=str_replace(".","",$mbh);
  30. $targetFile = "../".$targetFolder.$mbh.".jpg";
  31. move_uploaded_file($_FILES['inp1']['tmp_name'][$k],$targetFile);
  32. $cm=new CreatMiniature();
  33. $bw=800;$bg=0;$sw=500;$sh=500;$zw=200;$zh=200;
  34. $imgsrc="../".$targetFolder.$mbh.".jpg";
  35. list($width, $height) = getimagesize(weburl.$targetFolder.$mbh.".jpg");$bgv=intval($height/($width/$bw));
  36. $cm->SetVar($imgsrc,"file");if($width>$bw){$cm->BackFill($imgsrc,$bw,$bgv);}
  37. imageWaterMark($imgsrc,websypos,"../img/shuiyin.png","","","","",0,0);
  38. if($sw>$width){$sw=$width;}if($sh>$height){$sh=$height;}
  39. if(empty($rowcontrol[picys])){$cm->Cut("../".$targetFolder.$mbh."-1.jpg",$sw,$sh);}else{$cm->BackFill("../".$targetFolder.$mbh."-1.jpg",$sw,$sh);}
  40. if($zw>$width){$zw=$width;}if($zh>$height){$zh=$height;}
  41. if(empty($rowcontrol[picys])){$cm->Cut("../".$targetFolder.$mbh."-2.jpg",$zw,$zh);}else{$cm->BackFill("../".$targetFolder.$mbh."-2.jpg",$zw,$zh);}
  42. $wjv=$targetFolder.$mbh.".jpg";
  43. $nxh=returnxh("yjcode_tp"," and bh='".$bh."'");
  44. //OSSB
  45. if(check_in("a2a",$rowcontrol[aliosskg])){
  46. if(!is_null($ossClient)){;
  47. $ossClient->setTimeout(3600);
  48. $ossClient->setConnectTimeout(3600);
  49. $ossClient->createObjectDir($bucket, $targetFolder);
  50. $ossClient->uploadFile($bucket,$targetFolder.$mbh.".jpg",$targetFile);
  51. $ossClient->uploadFile($bucket,$targetFolder.$mbh."-1.jpg","../".$targetFolder.$mbh."-1.jpg");
  52. $ossClient->uploadFile($bucket,$targetFolder.$mbh."-2.jpg","../".$targetFolder.$mbh."-2.jpg");
  53. delFile($targetFile);
  54. delFile("../".$targetFolder.$mbh."-1.jpg");
  55. delFile("../".$targetFolder.$mbh."-2.jpg");
  56. $alioss=preg_split("/,/",$rowcontrol[alioss]);
  57. $wjv="https://".$alioss[3].".".$alioss[2]."/".$targetFolder.$mbh.".jpg";
  58. }
  59. }
  60. //OSSE
  61. intotable("yjcode_tp","bh,tp,type1,sj,userid,xh,upty","'".$bh."','".$wjv."','商品','".$sj."',".$userid.",".$nxh.",".intval($upty)."");
  62. }
  63. }
  64. }
  65. }elseif($admin==2){ //评价B
  66. while1("*","yjcode_order where orderbh='".$bh."' and userid=".$userid);if(!$row1=mysql_fetch_array($res1)){Audit_alert("登录超时","../reg/","parent.");}
  67. $targetFolder = "upload/".$userid."/".$bh."/";
  68. createDir("../".$targetFolder);
  69. $total = count($_FILES['inp1']['tmp_name']);
  70. for($k=0; $k<$total; $k++) {
  71. if(returncount("yjcode_tp where bh='".$bh."'")<7){
  72. if(is_uploaded_file($_FILES['inp1']['tmp_name'][$k])){
  73. $sj=date("Y-m-d H:i:s");
  74. $mbh=str_replace(" ","",microtime()."tp".$userid);
  75. $mbh=str_replace(".","",$mbh);
  76. $targetFile = "../".$targetFolder.$mbh.".jpg";
  77. move_uploaded_file($_FILES['inp1']['tmp_name'][$k],$targetFile);
  78. $cm=new CreatMiniature();
  79. $bw=800;$bg=0;$sw=350;$sh=350;
  80. $imgsrc="../".$targetFolder.$mbh.".jpg";
  81. list($width, $height) = getimagesize(weburl.$targetFolder.$mbh.".jpg");$bgv=intval($height/($width/$bw));
  82. $cm->SetVar($imgsrc,"file");if($width>$bw){$cm->BackFill($imgsrc,$bw,$bgv);}
  83. imageWaterMark($imgsrc,websypos,"../img/shuiyin.png","","","","",0,0);
  84. if($sw>$width){$sw=$width;}if($sh>$height){$sh=$height;}
  85. $cm->Cut("../".$targetFolder.$mbh."-1.jpg",$sw,$sh);
  86. $wjv=$targetFolder.$mbh.".jpg";
  87. $nxh=returnxh("yjcode_tp"," and bh='".$bh."'");
  88. intotable("yjcode_tp","bh,tp,type1,sj,userid,xh","'".$bh."','".$wjv."','评价','".$sj."',".$userid.",".$nxh."");
  89. }
  90. }
  91. }
  92. }elseif($admin==6){ //资讯
  93. while1("*","yjcode_news where bh='".$bh."' and userid=".$userid);if(!$row1=mysql_fetch_array($res1)){Audit_alert("登录超时","../reg/","parent.");}
  94. createDir("../upload/news/".dateYMDN($row1[sj])."/");
  95. $targetFolder="upload/news/".dateYMDN($row1[sj])."/".$bh."/";
  96. createDir("../".$targetFolder);
  97. $total = count($_FILES['inp1']['tmp_name']);
  98. for($k=0; $k<$total; $k++) {
  99. if(returncount("yjcode_tp where bh='".$bh."'")<7){
  100. if(is_uploaded_file($_FILES['inp1']['tmp_name'][$k])){
  101. $sj=date("Y-m-d H:i:s");
  102. $mbh=str_replace(" ","",microtime()."tp".$userid);
  103. $mbh=str_replace(".","",$mbh);
  104. $targetFile = "../".$targetFolder.$mbh.".jpg";
  105. move_uploaded_file($_FILES['inp1']['tmp_name'][$k],$targetFile);
  106. $cm=new CreatMiniature();
  107. $bw=600;$bg=500;$sw=200;$sh=160;
  108. $imgsrc="../".$targetFolder.$mbh.".jpg";
  109. list($width, $height) = getimagesize(weburl.$targetFolder.$mbh.".jpg");$bgv=intval($height/($width/$bw));
  110. $cm->SetVar($imgsrc,"file");if($width>$bw){$cm->BackFill($imgsrc,$bw,$bgv);}
  111. imageWaterMark($imgsrc,websypos,"../img/shuiyin.png","","","","",0,0);
  112. if($sw>$width){$sw=$width;}if($sh>$height){$sh=$height;}
  113. $cm->Cut("../".$targetFolder.$mbh."-1.jpg",$sw,$sh);
  114. $wjv=$targetFolder.$mbh.".jpg";
  115. $nxh=returnxh("yjcode_tp"," and bh='".$bh."'");
  116. intotable("yjcode_tp","bh,tp,type1,sj,userid,xh","'".$bh."','".$wjv."','资讯','".$sj."',".$userid.",".$nxh."");
  117. }
  118. }
  119. }
  120. }elseif($admin==7){ //服务
  121. $targetFolder = "upload/".$userid."/".$bh."/";
  122. createDir("../".$targetFolder);
  123. $total = count($_FILES['inp1']['tmp_name']);
  124. for($k=0; $k<$total; $k++) {
  125. if(returncount("yjcode_tp where bh='".$bh."'")<7){
  126. if(is_uploaded_file($_FILES['inp1']['tmp_name'][$k])){
  127. $sj=date("Y-m-d H:i:s");
  128. $mbh=str_replace(" ","",microtime()."tp".$userid);
  129. $mbh=str_replace(".","",$mbh);
  130. $targetFile = "../".$targetFolder.$mbh.".jpg";
  131. move_uploaded_file($_FILES['inp1']['tmp_name'][$k],$targetFile);
  132. $cm=new CreatMiniature();
  133. $bw=800;$bg=0;$sw=300;$sh=200;
  134. $imgsrc="../".$targetFolder.$mbh.".jpg";
  135. list($width, $height) = getimagesize(weburl.$targetFolder.$mbh.".jpg");$bgv=intval($height/($width/$bw));
  136. $cm->SetVar($imgsrc,"file");if($width>$bw){$cm->BackFill($imgsrc,$bw,$bgv);}
  137. imageWaterMark($imgsrc,websypos,"../img/shuiyin.png","","","","",0,0);
  138. if($sw>$width){$sw=$width;}if($sh>$height){$sh=$height;}
  139. if(empty($rowcontrol[picys])){$cm->Cut("../".$targetFolder.$mbh."-1.jpg",$sw,$sh);}else{$cm->BackFill("../".$targetFolder.$mbh."-1.jpg",$sw,$sh);}
  140. $wjv=$targetFolder.$mbh.".jpg";
  141. $nxh=returnxh("yjcode_tp"," and bh='".$bh."'");
  142. intotable("yjcode_tp","bh,tp,type1,sj,userid,xh,upty","'".$bh."','".$wjv."','服务','".$sj."',".$userid.",".$nxh.",".intval($upty)."");
  143. }
  144. }
  145. }
  146. }elseif($admin==8){ //服务评价B
  147. while1("*","yjcode_serverorder where orderbh='".$bh."' and userid=".$userid);if(!$row1=mysql_fetch_array($res1)){Audit_alert("登录超时","../reg/","parent.");}
  148. $targetFolder = "upload/".$userid."/".$bh."/";
  149. createDir("../".$targetFolder);
  150. $total = count($_FILES['inp1']['tmp_name']);
  151. for($k=0; $k<$total; $k++) {
  152. if(returncount("yjcode_tp where bh='".$bh."'")<7){
  153. if(is_uploaded_file($_FILES['inp1']['tmp_name'][$k])){
  154. $sj=date("Y-m-d H:i:s");
  155. $mbh=str_replace(" ","",microtime()."tp".$userid);
  156. $mbh=str_replace(".","",$mbh);
  157. $targetFile = "../".$targetFolder.$mbh.".jpg";
  158. move_uploaded_file($_FILES['inp1']['tmp_name'][$k],$targetFile);
  159. $cm=new CreatMiniature();
  160. $bw=800;$bg=0;$sw=350;$sh=350;
  161. $imgsrc="../".$targetFolder.$mbh.".jpg";
  162. list($width, $height) = getimagesize(weburl.$targetFolder.$mbh.".jpg");$bgv=intval($height/($width/$bw));
  163. $cm->SetVar($imgsrc,"file");if($width>$bw){$cm->BackFill($imgsrc,$bw,$bgv);}
  164. imageWaterMark($imgsrc,websypos,"../img/shuiyin.png","","","","",0,0);
  165. if($sw>$width){$sw=$width;}if($sh>$height){$sh=$height;}
  166. $cm->Cut("../".$targetFolder.$mbh."-1.jpg",$sw,$sh);
  167. $wjv=$targetFolder.$mbh.".jpg";
  168. $nxh=returnxh("yjcode_tp"," and bh='".$bh."'");
  169. intotable("yjcode_tp","bh,tp,type1,sj,userid,xh","'".$bh."','".$wjv."','服务评价','".$sj."',".$userid.",".$nxh."");
  170. }
  171. }
  172. }
  173. }
  174. php_toheader("tpupload.php?bh=".$bh."&admin=".$admin."&t=suc");
  175. }
  176. ?>
  177. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  178. <html xmlns="http://www.w3.org/1999/xhtml">
  179. <head>
  180. <meta http-equiv="x-ua-compatible" content="ie=7" />
  181. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  182. <title>图片上传</title>
  183. <style type="text/css">
  184. body{margin:0;font-size:12px;color:#333;}
  185. *{margin:0 auto;padding:0;}
  186. ul{list-style-type:none;margin:0;padding:0;}
  187. .main{float:left;width:150px;height:33px;cursor:pointer;margin:1px 0 0 0;}
  188. #upload input{position: relative;border:solid transparent;opacity: 0;filter:alpha(opacity=0); cursor: pointer;float:left;width:150px;height:33px;z-index:2;}
  189. #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;}
  190. @media screen and (-webkit-min-device-pixel-ratio:0) {
  191. #upload .inptp{margin-top:-39px;}
  192. }
  193. #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;}
  194. </style>
  195. <script language="javascript">
  196. function filecha(){
  197. document.getElementById("upload").style.display="none";
  198. document.getElementById("uping").style.display="";
  199. tpf.submit();
  200. }
  201. </script>
  202. </head>
  203. <body>
  204. <div class="main">
  205. <!--等待上传开始-->
  206. <form method="post" name="tpf" enctype="multipart/form-data" action="tpupload.php?bh=<?=$bh?>&admin=<?=$admin?>&action=update">
  207. <div id="upload">
  208. <input type="file" onchange="filecha()" multiple="multiple" name="inp1[]" size="25" accept=".jpg,.gif,.jpeg,.png">
  209. <span class="inptp">选择图片上传</span>
  210. </div>
  211. <input type="hidden" value="upload" name="yjcode" />
  212. </form>
  213. <!--等待上传结束-->
  214. <!--正在上传-->
  215. <div id="uping" style="display:none;">正在处理图片……</div>
  216. <!--正在上传-->
  217. </div>
  218. <? if($_GET[t]=="suc"){?>
  219. <script language="javascript">
  220. parent.xgtread("<?=$bh?>");
  221. </script>
  222. <? }?>
  223. </body>
  224. </html>