查看文件: setmenu.php
大小: 11.23 KB
类型: application/octet-stream
<?php require_once('../Connections/BE2.php'); ?> <?php $_SERVER['PHP_SELF'] = "main.php?act=setmenu";//$_SERVER['PHP_SELF']; if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { switch ($_POST['ck1']) { case 0: $updateSQL = sprintf("UPDATE jscookmenu SET cid=%s, title=%s, link=%s, link_tag=%s,flag=%s, idx=%s WHERE mid=%s", GetSQLValueString($_POST['cid'], "int"), GetSQLValueString($_POST['title'], "text"), GetSQLValueString($_POST['link'], "text"), GetSQLValueString($_POST['link_tag'], "text"), GetSQLValueString($_POST['flag'], "text"), GetSQLValueString($_POST['idx'], "int"), GetSQLValueString($_POST['mid'], "int")); mysql_select_db($database_BE2, $BE2); $Result1 = mysql_query($updateSQL, $BE2) or die(mysql_error()); if($_POST['pmid']>0 && $_POST['pid']>0 ){ $updateSQL2 = sprintf("UPDATE adpage SET pdoc=%s ,plink=%s WHERE pid=%s AND pmid=%s", GetSQLValueString($_POST['title'], "text"), GetSQLValueString($_POST['link'], "text"), GetSQLValueString($_POST['pid'], "int"), GetSQLValueString($_POST['pmid'], "int")); mysql_select_db($database_BE2, $BE2); $Result2= mysql_query($updateSQL2, $BE2) or die(mysql_error()); // echo $updateSQL2; } break; case 1:$updateSQL = sprintf("INSERT INTO jscookmenu (cid,title,link,link_tag,flag,idx) VALUES ( %s , %s, %s, %s, %s, %s)", GetSQLValueString(0, "int"), GetSQLValueString($_POST['title'], "text"), GetSQLValueString($_POST['link'], "text"), GetSQLValueString($_POST['link_tag'], "text"), GetSQLValueString($_POST['flag'], "text"), GetSQLValueString($_POST['idx'], "int")); mysql_select_db($database_BE2, $BE2); $Result1 = mysql_query($updateSQL, $BE2) or die(mysql_error()); break; case 2:$updateSQL = sprintf("INSERT INTO jscookmenu (cid,title,link,link_tag,flag,idx) VALUES ( %s , %s, %s, %s, %s, %s)", GetSQLValueString($_POST['cid'], "int"), GetSQLValueString($_POST['title'], "text"), GetSQLValueString($_POST['link'], "text"), GetSQLValueString($_POST['link_tag'], "text"), GetSQLValueString($_POST['flag'], "text"), GetSQLValueString($_POST['idx'], "int")); mysql_select_db($database_BE2, $BE2); $Result1 = mysql_query($updateSQL, $BE2) or die(mysql_error()); break; case 3:$updateSQL = sprintf("INSERT INTO jscookmenu (cid,title,link,link_tag,flag,idx) VALUES ( %s , %s, %s, %s, %s, %s)", GetSQLValueString($_POST['mid'], "int"), GetSQLValueString($_POST['title'], "text"), GetSQLValueString($_POST['link'], "text"), GetSQLValueString($_POST['link_tag'], "text"), GetSQLValueString($_POST['flag'], "text"), GetSQLValueString($_POST['idx'], "int") ); mysql_select_db($database_BE2, $BE2); $Result1 = mysql_query($updateSQL, $BE2) or die(mysql_error()); break; case 4: $updateSQL = sprintf("DELETE FROM jscookmenu WHERE mid = %s ", GetSQLValueString($_POST['mid'], "int")); mysql_select_db($database_BE2, $BE2); $Result1 = mysql_query($updateSQL, $BE2) or die(mysql_error()); break; } } function sel($cid){ require('../Connections/BE2.php'); mysql_select_db($database_BE2, $BE2); $query_R2 = "SELECT * FROM jscookmenu WHERE cid = $cid ORDER BY idx ASC"; $R2 = mysql_query($query_R2, $BE2) or die(mysql_error()); $row_R2 = mysql_fetch_assoc($R2); $totalRows_R2 = mysql_num_rows($R2); $arr1=array(); $i=1; do { $arr1[$i][0]=$row_R2['mid']; $arr1[$i][1]=$row_R2['cid']; $arr1[$i][2]="(".$row_R2['idx'].")".$row_R2['title']; $arr1[$i][3]=$_SERVER['PHP_SELF']."&mid=".$row_R2['mid'];//$row_R2['link']; $arr1[$i][4]="_self";//$row_R2['link_tag']; $i++; } while ($row_R2 = mysql_fetch_assoc($R2)); if (count($arr1)<1 ){return 0; }else{return $arr1;} } mysql_select_db($database_BE2, $BE2); $query_R1 = "SELECT * FROM jscookmenu WHERE cid = 0 ORDER BY idx ASC"; $R1 = mysql_query($query_R1, $BE2) or die(mysql_error()); $row_R1 = mysql_fetch_assoc($R1); $totalRows_R1 = mysql_num_rows($R1); $arr2=array(); $mycc=0; $c=0; $menutxt=''; $menutxt .= '<script language="JavaScript" type="text/javascript"> var myMenu = ['; do { $c++; $chkc=$c; $str1=$_SERVER['PHP_SELF']."&mid=".$row_R1['mid'];//$row_R1['link']<>''?"'".$row_R1['link']."'" :'null'; $str2="_self";//$row_R1['link_tag']<>''?"'".$row_R1['link_tag']."'" :'null'; //if ($c<>0){ $menutxt .= '], _cmSplit,'."\n"; } $str0=$row_R1['pic']<>''?'\'<img name="" src="'.$row_R1['pic'].'" width="36" height="20" alt="" />\'':'null'; $menutxt .= "[".$str0.", '(".$row_R1['idx'].")".$row_R1['title']."', '".$str1 ."','". $str2 ."', null "; $re2=($row_R1['mid']<>"")?sel($row_R1['mid']) :0; if ((count($re2)>0 )&&($re2[1][0]<>"")){ $menutxt .=","; for($i=1;$i<=count($re2);$i++){ if($re2[$i][0]<>""){ $c++; $str1=$re2[$i][3]<>''?"'".$re2[$i][3]."'" :'null'; $str2=$re2[$i][4]<>''?"'".$re2[$i][4]."'" :'null'; $menutxt .= "[null, '".$re2[$i][2]."', ". $str1 .",". $str2 .", null"; $re3=sel($re2[$i][0]); if ((count($re3)>0 )&&($re3[1][0]<>"")){ $menutxt .=","; for($j=1;$j<=count($re3);$j++){ if($re3[$j][0]<>""){ $str1=$re3[$j][3]<>''?"'".$re3[$j][3]."'" :'null'; $str2=$re3[$j][4]<>''?"'".$re3[$j][4]."'" :'null'; $menutxt .= "[null, '".$re3[$j][2]."',". $str1 .",". $str2 .", null "; $re4=sel($re3[$j][0]) ; if ((count($re4)>0 )&&($re4[1][0]<>"")){ $menutxt .=","; for($k=1;$k<=count($re4);$k++){ if($re4[$k][0]<>""){ $str1=$re4[$k][3]<>''?"'".$re4[$k][3]."'" :'null'; $str2=$re4[$k][4]<>''?"'".$re4[$k][4]."'" :'null'; $menutxt .= "[null, '".$re4[$k][2]."',". $str1 .",". $str2 .", null "; } $menutxt .="],\n"; } } $menutxt .="],\n"; } } } $menutxt .="],\n"; } } } $menutxt .= "], _cmSplit, \n"; } while ($row_R1 = mysql_fetch_assoc($R1)); $colname_Rt3 = "-1"; if (isset($_GET['mid'])) { $colname_Rt3 = $_GET['mid']; } mysql_select_db($database_BE2, $BE2); $query_Rt3 = sprintf("SELECT a.*,b.pid,b.pmid FROM jscookmenu as a left join adpage as b on a.mid=b.pmid WHERE mid = %s", GetSQLValueString($colname_Rt3, "int")); $Rt3 = mysql_query($query_Rt3, $BE2) or die(mysql_error()); $row_Rt3 = mysql_fetch_assoc($Rt3); $totalRows_Rt3 = mysql_num_rows($Rt3); mysql_free_result($R1); ?> <div class="row"> <div class="col-md-12"> <div class="panel panel-default"> <div class="panel-heading"> <h2 class="panel-title">選單設計</h2> </div> <table width="644" height="300" border="0" align="center"> <tr> <td width="177" valign="top"><div ID=myMenuID></div></td> <td width="457" valign="top"> <form id="form1" name="form1" method="POST" action=""> <table width="456" border="0"> <tr> <td width="49" class="font_blank_12x">位置</td> <td colspan="2" class="font_blank_12x"> <label><?php echo $row_Rt3['title']; ?></label></td> </tr> <tr> <td width="49" class="font_blank_12x">說明</td> <td colspan="2" class="font_blank_12x"><input name="title" type="text" id="title" value="<?php echo $row_Rt3['title']; ?>" /></td> </tr> <tr> <td class="font_blank_12x">連結</td> <td colspan="2" class="font_blank_12x"><label> <input name="link" type="text" id="link" value="<?php echo $row_Rt3['link']; ?>" size="50" /> </label></td> </tr> <tr> <td class="font_blank_12x"> </td> <td colspan="2" class="font_blank_12x"><label> <select name="link_tag" id="link_tag"> <option value="_blank" <?php if (!(strcmp("_blank", $row_Rt3['link_tag']))) {echo "selected=\"selected\"";} ?>>開新視窗</option> <option value="_self" <?php if (!(strcmp("_self", $row_Rt3['link_tag']))) {echo "selected=\"selected\"";} ?>>無</option> </select> <input name="mid" type="hidden" id="mid" value="<?php echo $row_Rt3['mid']; ?>" /> <input name="cid" type="hidden" id="cid" value="<?php echo $row_Rt3['cid']; ?>" /> <input name="pid" type="hidden" id="pid" value="<?php echo $row_Rt3['pid']; ?>" /> <input name="pmid" type="hidden" id="pmid" value="<?php echo $row_Rt3['pmid']; ?>" /> </label></td> </tr> <tr> <td class="font_blank_12x"> </td> <td width="159" class="font_blank_12x"><label> <input name="ck1" type="radio" id="radio" value="0" checked="checked" /> 修正此選單 </label></td> <td width="234" class="font_blank_12x"><input type="radio" name="ck1" id="radio2" value="1" /> 新增為根選單 </td> </tr> <tr> <td class="font_blank_12x"> </td> <td class="font_blank_12x"><input name="ck1" type="radio" id="radio3" value="2" /> 新增為平行選單 </td> <td class="font_blank_12x"><input type="radio" name="ck1" id="radio4" value="3" /> 新增為子選單</td> </tr> <tr> <td class="font_blank_12x"> </td> <td class="font_blank_12x"><input type="radio" name="ck1" id="radio5" value="4" /> 刪除此選單 </td> <td class="font_blank_12x"><label for="flag"></label> <select name="flag" id="flag"> <option value="Y" <?php if (!(strcmp("Y", $row_Rt3['flag']))) {echo "selected=\"selected\"";} ?>>使用中</option> <option value="N" <?php if (!(strcmp("N", $row_Rt3['flag']))) {echo "selected=\"selected\"";} ?>>暫停使用</option> </select></td> </tr> <tr> <td class="font_blank_12x">排列</td> <td colspan="2" class="font_blank_12x"><label> <input name="idx" type="text" id="idx" value="<?php echo $row_Rt3['idx']; ?>" size="8" maxlength="3" /> 排列順序的編號 </label></td> </tr> <tr> <td class="font_blank_12x"> </td> <td colspan="2" class="font_blank_12x"><label> <div align="center"> <input type="submit" name="button" id="button" value="送出" /> </div> </label></td> </tr> </table> <input type="hidden" name="MM_update" value="form1" /> </form> </td> </tr> </table> </div> </div> </div> <? //echo count($arr2)."<br>"; echo $menutxt .=" ] ;"; echo "cmDraw ('myMenuID', myMenu, 'vbr', cmThemeOffice, 'ThemeOffice');</script>"; ?> <? mysql_free_result($Rt3); ?>
保存
取消
返回文件列表