ListMenu.php 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <?php
  2. define('EmpireCMSAdmin','1');
  3. require("../../class/connect.php");
  4. require("../../class/db_sql.php");
  5. require("../../class/functions.php");
  6. $link=db_connect();
  7. $empire=new mysqlquery();
  8. $editor=1;
  9. //验证用户
  10. $lur=is_login();
  11. $logininid=$lur['userid'];
  12. $loginin=$lur['username'];
  13. $loginrnd=$lur['rnd'];
  14. $loginlevel=$lur['groupid'];
  15. $loginadminstyleid=$lur['adminstyleid'];
  16. //ehash
  17. $ecms_hashur=hReturnEcmsHashStrAll();
  18. //验证权限
  19. CheckLevel($logininid,$loginin,$classid,"menu");
  20. //增加菜单
  21. function AddMenu($add,$userid,$username){
  22. global $empire,$dbtbpre;
  23. $classid=(int)$add['classid'];
  24. if(!$classid||!$add[menuname]||!$add[menuurl])
  25. {
  26. printerror("EmptyMenu","history.go(-1)");
  27. }
  28. //验证权限
  29. CheckLevel($userid,$username,$classid,"menu");
  30. $myorder=(int)$add['myorder'];
  31. $add['menuname']=hRepPostStr($add['menuname'],1);
  32. $add['menuurl']=hRepPostStr($add['menuurl'],1);
  33. $add['addhash']=(int)$add['addhash'];
  34. $sql=$empire->query("insert into {$dbtbpre}enewsmenu(menuname,menuurl,myorder,classid,addhash) values('".$add[menuname]."','".$add[menuurl]."','$myorder','$classid','$add[addhash]');");
  35. $lastid=$empire->lastid();
  36. if($sql)
  37. {
  38. //操作日志
  39. insert_dolog("classid=$classid<br>menuid=".$lastid."&menuname=".$add[menuname]);
  40. printerror("AddMenuSuccess","ListMenu.php?classid=$classid".hReturnEcmsHashStrHref2(0));
  41. }
  42. else
  43. {printerror("DbError","history.go(-1)");}
  44. }
  45. //修改菜单
  46. function EditMenu($add,$userid,$username){
  47. global $empire,$dbtbpre;
  48. $classid=(int)$add['classid'];
  49. $menuid=$add['menuid'];
  50. $delmenuid=$add['delmenuid'];
  51. $menuname=$add['menuname'];
  52. $menuurl=$add['menuurl'];
  53. $myorder=$add['myorder'];
  54. $addhash=$add['addhash'];
  55. $count=count($menuid);
  56. if(!$classid||!$count)
  57. {
  58. printerror("EmptyMenu","history.go(-1)");
  59. }
  60. //验证权限
  61. CheckLevel($userid,$username,$classid,"menu");
  62. //删除
  63. $del=0;
  64. $ids='';
  65. $delcount=count($delmenuid);
  66. if($delcount)
  67. {
  68. $dh='';
  69. for($j=0;$j<$delcount;$j++)
  70. {
  71. $ids.=$dh.intval($delmenuid[$j]);
  72. $dh=',';
  73. }
  74. $empire->query("delete from {$dbtbpre}enewsmenu where menuid in (".$ids.")");
  75. $del=1;
  76. }
  77. //修改
  78. for($i=0;$i<$count;$i++)
  79. {
  80. $menuid[$i]=(int)$menuid[$i];
  81. if(strstr(','.$ids.',',','.$menuid[$i].','))
  82. {
  83. continue;
  84. }
  85. $myorder[$i]=(int)$myorder[$i];
  86. $menuname[$i]=hRepPostStr($menuname[$i],1);
  87. $menuurl[$i]=hRepPostStr($menuurl[$i],1);
  88. $addhash[$i]=(int)$addhash[$i];
  89. $empire->query("update {$dbtbpre}enewsmenu set menuname='".$menuname[$i]."',menuurl='".$menuurl[$i]."',myorder='".$myorder[$i]."',addhash='".$addhash[$i]."' where menuid='".$menuid[$i]."'");
  90. }
  91. //操作日志
  92. insert_dolog("classid=$classid&del=$del");
  93. printerror("EditMenuSuccess","ListMenu.php?classid=$classid".hReturnEcmsHashStrHref2(0));
  94. }
  95. $enews=$_POST['enews'];
  96. if(empty($enews))
  97. {$enews=$_GET['enews'];}
  98. if($enews)
  99. {
  100. hCheckEcmsRHash();
  101. }
  102. if($enews=="AddMenu")//增加菜单
  103. {
  104. AddMenu($_POST,$logininid,$loginin);
  105. }
  106. elseif($enews=="EditMenu")//修改菜单
  107. {
  108. EditMenu($_POST,$logininid,$loginin);
  109. }
  110. else
  111. {}
  112. $classid=(int)$_GET['classid'];
  113. if(!$classid)
  114. {
  115. printerror("ErrorUrl","history.go(-1)");
  116. }
  117. $cr=$empire->fetch1("select classid,classname,issys,classtype,groupids from {$dbtbpre}enewsmenuclass where classid='$classid'");
  118. if(!$cr['classid'])
  119. {
  120. printerror("ErrorUrl","history.go(-1)");
  121. }
  122. $classtype='';
  123. if($cr['classtype']==1)
  124. {
  125. $classtype='常用操作';
  126. }
  127. elseif($cr['classtype']==2)
  128. {
  129. $classtype='插件菜单';
  130. }
  131. elseif($cr['classtype']==3)
  132. {
  133. $classtype='扩展菜单';
  134. }
  135. $menuclassname=$classtype.":".$cr['classname'];
  136. $sql=$empire->query("select menuid,menuname,menuurl,myorder,addhash from {$dbtbpre}enewsmenu where classid='$classid' order by myorder,menuid");
  137. //用户组
  138. $gline=6;
  139. $gno=0;
  140. $group='';
  141. $groupsql=$empire->query("select groupid,groupname from {$dbtbpre}enewsgroup order by groupid");
  142. while($groupr=$empire->fetch($groupsql))
  143. {
  144. $gno++;
  145. $br='';
  146. if($gno%$gline==0)
  147. {
  148. $br='<br>';
  149. }
  150. $select='';
  151. if(strstr($cr[groupids],','.$groupr[groupid].','))
  152. {
  153. $select=' checked';
  154. }
  155. $group.="<input name='groupid[]' type='checkbox' id='groupid[]' value='".$groupr[groupid]."'".$select.">".$groupr[groupname]."&nbsp;&nbsp;".$br;
  156. }
  157. ?>
  158. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  159. <html>
  160. <head>
  161. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  162. <title>管理菜单</title>
  163. <link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
  164. <script>
  165. function CheckAll(form)
  166. {
  167. for (var i=0;i<form.elements.length;i++)
  168. {
  169. var e = form.elements[i];
  170. if (e.name != 'chkall')
  171. e.checked = form.chkall.checked;
  172. }
  173. }
  174. </script>
  175. </head>
  176. <body>
  177. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  178. <tr>
  179. <td>位置:<a href="MenuClass.php<?=$ecms_hashur['whehref']?>">管理菜单</a>&nbsp;>&nbsp;<a href="ListMenu.php?classid=<?=$classid?><?=$ecms_hashur['ehref']?>"><?=$menuclassname?></a>&nbsp;>&nbsp;菜单列表
  180. <div align="right"> </div></td>
  181. </tr>
  182. </table>
  183. <br>
  184. <table width="100%" border="0" cellpadding="3" cellspacing="1" class="tableborder">
  185. <form name="form2" method="post" action="ListMenu.php" onsubmit="return confirm('确认要提交?');">
  186. <?=$ecms_hashur['form']?>
  187. <tr class="header">
  188. <td width="7%"><div align="center">删除</div></td>
  189. <td width="7%">显示顺序</td>
  190. <td width="20%" height="25">菜单名称</td>
  191. <td width="66%" height="25">链接地址</td>
  192. </tr>
  193. <?php
  194. while($r=$empire->fetch($sql))
  195. {
  196. ?>
  197. <tr bgcolor="#FFFFFF" onmouseout="this.style.backgroundColor='#ffffff'" onmouseover="this.style.backgroundColor='#DBEAF5'">
  198. <td><div align="center">
  199. <input name="delmenuid[]" type="checkbox" id="delmenuid[]" value="<?=$r[menuid]?>">
  200. </div></td>
  201. <td> <input name="myorder[]" type="text" id="myorder[]" value="<?=$r[myorder]?>" size="4">
  202. </td>
  203. <td height="25"> <input name="menuname[]" type="text" id="menuname[]" value="<?=$r[menuname]?>">
  204. <input name="menuid[]" type="hidden" id="menuid[]" value="<?=$r[menuid]?>">
  205. </td>
  206. <td height="25"><input name="menuurl[]" type="text" id="menuurl[]" value="<?=$r[menuurl]?>" size="42">
  207. <select name="addhash[]" id="addhash[]">
  208. <option value="0"<?=$r[addhash]==0?' selected':''?>>普通链接</option>
  209. <option value="1"<?=$r[addhash]==1?' selected':''?>>刺猬模式链接</option>
  210. <option value="2"<?=$r[addhash]==2?' selected':''?>>金刚模式链接</option>
  211. </select></td>
  212. </tr>
  213. <?php
  214. }
  215. ?>
  216. <tr bgcolor="#FFFFFF">
  217. <td><div align="center">
  218. <input type=checkbox name=chkall value=on onclick=CheckAll(this.form)>
  219. </div></td>
  220. <td height="25" colspan="3"><input type="submit" name="Submit2" value="提交">
  221. <input name="enews" type="hidden" id="enews" value="EditMenu">
  222. <input name="classid" type="hidden" id="classid" value="<?=$classid?>">
  223. &nbsp; &nbsp; <font color="#666666">(说明:顺序值越小显示越前面) </font></td>
  224. </tr>
  225. <tr bgcolor="#FFFFFF">
  226. <td height="25" colspan="4">&nbsp;</td>
  227. </tr>
  228. </form>
  229. </table>
  230. <br>
  231. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  232. <form name="form1" method="post" action="ListMenu.php">
  233. <?=$ecms_hashur['form']?>
  234. <tr class="header">
  235. <td height="25">增加菜单:
  236. <input name=enews type=hidden id="enews" value=AddMenu> <input name="classid" type="hidden" id="classid" value="<?=$classid?>">
  237. </td>
  238. </tr>
  239. <tr>
  240. <td height="25" bgcolor="#FFFFFF"> 菜单名称:
  241. <input name="menuname" type="text" id="menuname">
  242. 显示顺序:
  243. <input name="myorder" type="text" id="myorder" value="0" size="4">
  244. 链接地址:
  245. <input name="menuurl" type="text" id="menuurl" size="42">
  246. <select name="addhash" id="addhash">
  247. <option value="0">普通链接</option>
  248. <option value="1">刺猬模式链接</option>
  249. <option value="2">金刚模式链接</option>
  250. </select>
  251. <input type="submit" name="Submit" value="增加">
  252. </td>
  253. </tr>
  254. <tr>
  255. <td height="25" bgcolor="#FFFFFF"><font color="#666666">说明:链接地址从后台算起,比如后台首页链接地址是:main.php</font></td>
  256. </tr>
  257. </form>
  258. </table>
  259. <br>
  260. <br>
  261. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  262. <form name="form2" method="post" action="MenuClass.php">
  263. <?=$ecms_hashur['form']?>
  264. <tr class="header">
  265. <td height="25">显示本分类菜单的用户组权限:
  266. <input name=enews type=hidden id="enews" value=EditMenuClassGroup>
  267. <input name="classid" type="hidden" id="classid" value="<?=$classid?>"> </td>
  268. </tr>
  269. <tr>
  270. <td height="25" bgcolor="#FFFFFF"><?=$group?></td>
  271. </tr>
  272. <tr>
  273. <td height="25" bgcolor="#FFFFFF"><input type="submit" name="Submit3" value="设置">
  274. <font color="#666666">(说明:不选为不限制。)</font></td>
  275. </tr>
  276. </form>
  277. </table>
  278. </body>
  279. </html>
  280. <?php
  281. db_close();
  282. $empire=null;
  283. ?>