查看文件: market_add.php
大小: 11.91 KB
类型: application/octet-stream
<?php require('system/login.php'); ?> <?php require_once('../Connections/BE2.php'); ?> <?php 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) { $str01=str_replace($letter,"",$a1); //$flag = true; $str02=$letter ; } } return $a1; } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { if((mb_strlen($_POST['city'])>1)&&(mb_strlen($_POST['mname'])>2) && ($_POST['mind']>0)) { $savepath = '/www2/skybni/submarket/images/'; $tfile1="fileToUpload1"; if($_FILES[$tfile1]["name"]<>''){ $vimg=date('Ymdhis',time()).'.png' ; $ext1= explode('.',$_FILES[$tfile1]['name']) ; $imgext1=strtolower($ext1[count($ext1)-1]); //取最後一 if($imgext1=='png'){ $vimg=date('Ymdhis',time()).'.png' ; $pic1=$savepath.$vimg; move_uploaded_file($_FILES[$tfile1]["tmp_name"],$pic1); } } else{ $vimg=''; $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']; //1段單號 $str03 ='網店商城'; 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"); } } $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){ $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("INSERT INTO marketstreet(mname,mcounty,maddress_id,mside,maddress_name,mpic,mind)VALUES(%s,%s,%s,%s,%s,%s,%s)", GetSQLValueString($_POST['mname'], "text"), GetSQLValueString($_POST['city'], "text"), GetSQLValueString($_POST['maddress_id'], "int"), GetSQLValueString($_POST['mside'], "text"), GetSQLValueString($_POST['maddress_name'], "text"), GetSQLValueString($vimg, "text"), GetSQLValueString($_POST['mind'], "int")); mysql_select_db($database_BE2, $BE2); mysql_query($updateSQL, $BE2) or die(mysql_error()); // echo $upSQL; //main.php?act=market_list&selkid=b商圈 $updateGoTo ='main.php?act=market_list&selkid='.$_POST['mname'] ;//$_POST['url']; echo "<script>alert('上傳完成 ..');location.href='".$updateGoTo."';</script>"; } else { $updateGoTo =$_POST['url']; echo "<script>alert('請選取城市..');location.href='".$updateGoTo."';</script>"; } } $mname=''; if (isset($_GET['mname'])) { $mname = $_GET['mname']; } $city='-1'; if (isset($_GET['city'])) { $city = $_GET['city']; } 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",$city); $Rat2 = mysql_query($query_Rat2, $BE2) or die(mysql_error()); $row_Rat2 = mysql_fetch_assoc($Rat2); $totalRows_Rat2 = mysql_num_rows($Rat2); $district=$row_Rat2['district']; 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",$city, $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="50%" align="center"> <tr valign="baseline"> <th height="38" colspan="3" align="center" valign="middle" nowrap="nowrap"> </th> </tr> <tr valign="baseline"> <th width="24%" height="42" align="center" valign="middle" nowrap="nowrap"><span class="font2">商圈名稱說明:</span></th> <td width="64%" valign="middle"><span class="col-md-8"> <input name="mname" type="text" id="mname" value="<?= $mname?>" maxlength="24" /> <br> 字符串不要包含符号</span></td> <td width="12%" rowspan="9" valign="baseline"> </td> </tr> <tr valign="baseline"> <th height="42" align="center" valign="middle" nowrap="nowrap">城市:</th> <td valign="middle"><? $address_name= $city.',';?><select name="city" id="city" class="form-control placeholder col-xs-12 col-sm-4 mb-4" onchange="Selectcity()"> <option value=""></option> <? do { ?> <option value="<?= $row_Rot2['county']; ?>" <?= ($row_Rot2['county']==$city)?'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();"> <? $address_name .= $row_Rat2['district'].','; 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()"> <? $address_id=$row_Rbt2['address_id']; $address_name .= $row_Rbt2['street']; do { ?> <option value="<?= $row_Rbt2['address_id']; ?>" ><?= $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="單號">單號</option> <option value="雙號">雙號</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="10" size="12" maxlength="5" /> 排序請>0</span></td> </tr> <tr valign="baseline"> <td height="40" align="center" valign="middle" nowrap="nowrap">自定圖:</td> <td height="40" align="left" valign="middle" nowrap="nowrap"><input name="fileToUpload1" type="file" id="fileToUpload1" /> 300x300 png</td> </tr> <tr valign="baseline"> <td height="40" colspan="2" 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="<?= isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:''; ?>" /> <span class="col-md-8"> <input id="maddress_id" name="maddress_id" type="hidden" value="<?= $address_id ?>" readonly="readonly" /> </span> <span class="col-md-8"> <input id="maddress_name" name="maddress_name" type="hidden" value="<?= $address_name ?>" 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); ?>
保存
取消
返回文件列表