tpupload.php 9.2 KB

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