查看文件: market_edit.php
大小: 13.23 KB
类型: application/octet-stream
<?php require('system/login.php'); ?> <?php require_once('../Connections/BE2.php'); ?> <?php //$globals = $GLOBALS; function wf_to_nf($strs ){ //全形半形轉換 $wft = array( '一段', '二段', '三段', '四段', '五段', '六段', '七段', '八段', '九段', "大道"); $nft = array( "1段", "2段", "3段", "4段", "5段", "6段", "7段", "8段", "9段", "大道"); //return str_replace($wft,$nft,$strs); //半形到全形 global $str01 ; global $str02 ; $a1=str_replace($nft,$wft,$strs); //半形到全形 $str01=$a1 ; foreach ($wft as $letter) { if (strpos($a1, $letter) !== false) { //$flag = true; $str01=str_replace($letter,"",$a1); $str02=$letter ; } } return $a1; } function nf_to_wf($strs ){ //全形半形轉換 $wft = array( '一段', '二段', '三段', '四段', '五段', '六段', '七段', '八段', '九段', "大道"); $nft = array( "1段", "2段", "3段", "4段", "5段", "6段", "7段", "8段", "9段", "大道"); //return str_replace($wft,$nft,$strs); //半形到全形 $a1=str_replace($wft,$nft,$strs); //半形到全形 return $a1; } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1") && ($_POST['mind']>0)) { $vimg=$_POST['mpic']; $tfile1="fileToUpload1"; if($_FILES[$tfile1]["name"]<>''){ $ext1= explode('.',$_FILES[$tfile1]['name']) ; $imgext1=strtolower($ext1[count($ext1)-1]); //取最後一 if($imgext1=='png'){ $vimg=date('Ymdhis',time()).'.png' ; $savepath = '/www2/skybni/submarket/images/'; $pic1=$savepath.$vimg; move_uploaded_file($_FILES[$tfile1]["tmp_name"],$pic1); } }else { if($_POST["old_addr"]<>$_POST['maddress_id']){ $vimg=date('Ymdhis',time()).'.png' ; $savepath = '/www2/skybni/submarket/images/'; $background="/www2/skybni/test007/bb.png"; $myfont="/www2/skybni/fonts/wt009.ttf"; $im = imagecreatefrompng($background); $white = ImageColorAllocate($im, 255,255,255); $point_y=array(105,165,225,285);//high $point_4x=40; $doc1=explode(",",$_POST['maddress_name']); $str01=''; $str02=''; $doc1[2]= wf_to_nf($doc1[2]); //台北市 南港區 南港路1段 單號 $str02 .= $_POST['mside']; if(mb_strlen($str01)==5){ //五谷王 南街單號 if(mb_strlen($str02)==2){ $str02=mb_substr($str01,3,2,"utf-8").$str02; $str01=mb_substr($str01,0,3,"utf-8"); }else if( $str01=='光明六路東'){ $str02=mb_substr($str01,4,1,"utf-8").$str02; $str01=mb_substr($str01,0,4,"utf-8"); $str02=nf_to_wf($str02); } } //1段單號 $str03 ='網店商城'; $drawstr=array($str01,$str02,'網店商城'); for ($i=0;$i<3;$i++){ $l=mb_strlen($drawstr[$i]); if($l==2){ $word=mb_substr( $drawstr[$i],0,1,"utf-8"); ;//'南港路' ;//substr($authnum,$c,1); ImageTTFText($im,40,0,40,$point_y[$i], $white,$myfont,$word); $word=mb_substr( $drawstr[$i],1,1,"utf-8") ;//'南港路' ;//substr($authnum,$c,1); ImageTTFText($im,40,0,200,$point_y[$i], $white,$myfont,$word); }else if($l==3){ $word=mb_substr( $drawstr[$i],0,1,"utf-8"); ;//'南港路' ;//substr($authnum,$c,1); ImageTTFText($im,40,0,40,$point_y[$i], $white,$myfont,$word); $word=mb_substr( $drawstr[$i],1,1,"utf-8") ;//'南港路' ;//substr($authnum,$c,1); ImageTTFText($im,40,0,120,$point_y[$i], $white,$myfont,$word); $word=mb_substr( $drawstr[$i],2,1,"utf-8") ;//'南港路' ;//substr($authnum,$c,1); ImageTTFText($im,40,0,200,$point_y[$i], $white,$myfont,$word); }else if($l==4){ $word=$drawstr[$i]; ImageTTFText($im,40,0,40,$point_y[$i], $white,$myfont,$word); }else if($l==5) { if($str01=='光明六路'){ $word=$drawstr[$i]; ImageTTFText($im,38,0,32,$point_y[$i], $white,$myfont,$word); }else{ $word=$drawstr[$i]; ImageTTFText($im,34,0,32,$point_y[$i], $white,$myfont,$word); } } } $vimg=date('Ymdhis',time()).'.png' ; ImagePNG($im, $savepath.$vimg); ImageDestroy($im); } } $updateSQL = sprintf("UPDATE marketstreet set mname=%s,mcounty=%s,maddress_id=%s,maddress_name=%s,mside=%s,mind=%s,mpic=%s WHERE mid=%s", GetSQLValueString($_POST['mname'], "text"), GetSQLValueString($_POST['city'], "text"), GetSQLValueString($_POST['maddress_id'], "int"), GetSQLValueString($_POST['maddress_name'], "text"), GetSQLValueString($_POST['mside'], "text"), GetSQLValueString($_POST['mind'], "int"), GetSQLValueString($vimg, "text"), GetSQLValueString($_POST['mid'], "int")); mysql_select_db($database_BE2, $BE2); mysql_query($updateSQL, $BE2) or die(mysql_error()); // echo $upSQL; $updateGoTo =$_POST['url']; echo "<script>alert('更新完成 ..');location.href='".$updateGoTo."';</script>"; } $id = '-1'; if (isset($_GET['id'])) { $id = $_GET['id']; } mysql_select_db($database_BE2, $BE2); $query_Rt2 = sprintf("SELECT * FROM marketstreet where mid='%s'",$id); $Rt2 = mysql_query($query_Rt2, $BE2) or die(mysql_error()); $row_Rt2 = mysql_fetch_assoc($Rt2); mysql_select_db($database_BE2, $BE2); // address_id county district street $query_Rot2 = "SELECT distinct(county) FROM address where 1 order by address_id"; $Rot2 = mysql_query($query_Rot2, $BE2) or die(mysql_error()); $row_Rot2 = mysql_fetch_assoc($Rot2); $totalRows_Rot2 = mysql_num_rows($Rot2); mysql_select_db($database_BE2, $BE2); // address_id county district street $query_Rat2 = sprintf("SELECT distinct(district) FROM address where county='%s' order by district",$row_Rt2['mcounty']); $Rat2 = mysql_query($query_Rat2, $BE2) or die(mysql_error()); $row_Rat2 = mysql_fetch_assoc($Rat2); $totalRows_Rat2 = mysql_num_rows($Rat2); $ar=explode(",",$row_Rt2['maddress_name']); $district=$ar[1]; mysql_select_db($database_BE2, $BE2); // address_id county district street $query_Rbt2 = sprintf("SELECT address_id,street FROM address where county='%s' AND district='%s' order by street",$row_Rt2['mcounty'], $district); $Rbt2 = mysql_query($query_Rbt2, $BE2) or die(mysql_error()); $row_Rbt2 = mysql_fetch_assoc($Rbt2); $totalRows_Rbt2 = mysql_num_rows($Rbt2); ?> <div class="row"> <div class="col-md-12"> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title">街道網店商城-新增</h3> </div> <form action="" method="post" name="form1" id="form1" enctype="multipart/form-data"> <table width="55%" align="center"> <tr valign="baseline"> <th height="38" colspan="3" align="center" valign="middle" nowrap="nowrap"> </th> </tr> <tr valign="baseline"> <th width="20%" height="42" align="center" valign="middle" nowrap="nowrap"><span class="font2">商圈名稱說明:</span></th> <td width="43%" valign="middle"><span class="col-md-8"> <input name="mname" type="text" id="si5" value="<?= $row_Rt2['mname']?>" maxlength="24" /> <br> 字符串不要包含符号</span></td> <td width="37%" rowspan="7" align="center" valign="middle"><? if($row_Rt2['mpic']<>''){?><img name="" src="/submarket/images/<?=$row_Rt2['mpic']?>" width="150" alt="" /><? }else{ echo ' ';}?></td> </tr> <tr valign="baseline"> <th height="42" align="center" valign="middle" nowrap="nowrap">城市:</th> <td valign="middle"><select name="city" id="city" class="form-control placeholder col-xs-12 col-sm-4 mb-4" onchange="Selectcity()"> <? do { ?> <option value="<?= $row_Rot2['county']; ?>" <?= ($row_Rot2['county']==$ar[0])?'selected="selected"':""; ?> ><?= $row_Rot2['county']; ?></option> <?php } while ($row_Rot2 = mysql_fetch_assoc($Rot2)); ?> </select></td> </tr> <tr valign="baseline"> <th height="42" align="center" valign="middle" nowrap="nowrap"><span class="font2">街道區域</span>:</th> <td valign="middle"><select name="district" id="district" class="form-control placeholder col-xs-12 col-sm-4 mb-4" onchange="Selectstreet();"> <? do { ?> <option value="<?= $row_Rat2['district']; ?>" <?= ($row_Rat2['district']==$district)?'selected="selected"':""; ?>><?= $row_Rat2['district']; ?></option> <? } while ($row_Rat2 = mysql_fetch_assoc($Rat2)); ?> </select></td> </tr> <tr valign="baseline"> <th height="42" align="center" valign="middle" nowrap="nowrap">路段:</th> <td valign="middle"><select name="street" id="street" class="form-control placeholder col-xs-12 col-sm-4 mb-4" onchange="show_id()"> <? do { ?> <option value="<?= $row_Rbt2['address_id']; ?>" <?= ($row_Rbt2['address_id']==$row_Rt2['maddress_id'])?'selected="selected"':""; ?> ><?= $row_Rbt2['street']; ?></option> <? } while ($row_Rbt2 = mysql_fetch_assoc($Rbt2)); ?> </select> </td> </tr> <tr valign="baseline"> <th height="42" align="center" valign="middle" nowrap="nowrap"> </th> <td valign="middle"><select name="mside" id="mside" class="form-control placeholder col-xs-12 col-sm-4 mb-4" onchange="show_id()"> <option value="單號" <?= ($row_Rt2['mside']=='單號')?'selected="selected"':""; ?>>單號</option> <option value="雙號" <?= ($row_Rt2['mside']=='雙號')?'selected="selected"':""; ?>>雙號</option> </select></td> </tr> <tr valign="baseline"> <th height="42" align="center" valign="middle" nowrap="nowrap">排序:</th> <td valign="middle"><span class="col-md-8"> <input name="mind" type="text" id="mind" value="<?= $row_Rt2['mind'] ?>" size="12" maxlength="5" /> 排序請>0</span></td> </tr> <tr valign="baseline"> <th height="42" align="center" valign="middle" nowrap="nowrap">自定圖:</th> <td valign="middle"><input name="fileToUpload1" type="file" id="fileToUpload1" /> 300x300 png</td> </tr> <tr valign="baseline"> <td height="40" colspan="3" align="center" valign="middle" nowrap="nowrap"><input type="submit" value="更新" /></td> </tr> </table> <input type="hidden" name="MM_update" id="MM_update" value="form1" /> <input name="url" type="hidden" id="url" value="<?= $_SERVER['HTTP_REFERER']; ?>" /> <span class="col-md-8"> <input id="maddress_id" name="maddress_id" type="hidden" value="<?= $row_Rt2['maddress_id'] ?>" readonly="readonly" /> </span> <span class="col-md-8"> <input id="maddress_name" name="maddress_name" type="hidden" value="<?= $row_Rt2['maddress_name'] ?>" readonly="readonly" /> </span> <input name="mid" type="hidden" id="mid" value="<?= $row_Rt2['mid'] ?>" /> <span class="col-md-8"> <input id="mpic" name="mpic" type="hidden" value="<?= $row_Rt2['mpic'] ?>" readonly="readonly" /> </span><span class="col-md-8"> <input id="old_addr" name="old_addr" type="hidden" value="<?= $row_Rt2['maddress_id'] ?>" readonly="readonly" /> </span> </form> <div class="clearfix"> </div> <div id="back" ><a href="javascript:history.back();"><img src="images/back.gif" alt="回上一頁" title="回上一頁" width="115" height="32" border="0"></a></div> </div> </div> </div> <script type="text/javascript"> function Selectstreet() { var county= $("#city").val(); // $(city).find(':selected')[0].id; var district = $("#district").val(); //.find(':selected')[0].id; $.ajax({ type: 'POST', url: 'SelectstreetApi.php', data: { 'county': county,'district':district }, success: function (data) { // the next thing you want to do var $street = $('#street'); $street.empty(); $("select#street").html(data); show_id(); } }); } function Selectcity() { var county= $("#city").val(); // $(city).find(':selected')[0].id; $.ajax({ type: 'POST', url: 'SelectcityApi.php', data: {'county': county}, success: function (data) { // the next thing you want to do var $street = $('#street'); $street.empty(); var $district = $('#district'); $district.empty(); $("select#district").html(data); Selectstreet(); } }); } function show_id(){ var s=$('#city').val()+","+$('#district').val()+","+$.trim($('#street').find(":selected").text()); $('#maddress_id').val($('#street').val()); $('#maddress_name').val(s); // alert(1); } </script> <? mysql_free_result($Rot2); mysql_free_result($Rat2); mysql_free_result($Rbt2); ?>
保存
取消
返回文件列表