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