ListMAdminGroup.php 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <?php
  2. define('EmpireCMSAdmin','1');
  3. require("../../class/connect.php");
  4. require("../../class/db_sql.php");
  5. require("../../class/functions.php");
  6. require("../../member/class/user.php");
  7. require "../".LoadLang("pub/fun.php");
  8. $link=db_connect();
  9. $empire=new mysqlquery();
  10. $editor=1;
  11. //验证用户
  12. $lur=is_login();
  13. $logininid=$lur['userid'];
  14. $loginin=$lur['username'];
  15. $loginrnd=$lur['rnd'];
  16. $loginlevel=$lur['groupid'];
  17. $loginadminstyleid=$lur['adminstyleid'];
  18. //ehash
  19. $ecms_hashur=hReturnEcmsHashStrAll();
  20. //验证权限
  21. CheckLevel($logininid,$loginin,$classid,"madmingroup");
  22. //增加会员管理组
  23. function AddMAdminGroup($add,$userid,$username){
  24. global $empire,$dbtbpre;
  25. if(empty($add['agname']))
  26. {
  27. printerror('EmptyMAdminGroup','history.go(-1)');
  28. }
  29. $add['agname']=hRepPostStr($add['agname'],1);
  30. $add['isadmin']=(int)$add['isadmin'];
  31. $sql=$empire->query("insert into {$dbtbpre}enewsag(agname,isadmin,auids) values('$add[agname]','$add[isadmin]','');");
  32. if($sql)
  33. {
  34. $agid=$empire->lastid();
  35. //更新缓存
  36. GetConfig();
  37. GetMemberLevel();
  38. insert_dolog("agid=$agid&agname=$add[agname]");//操作日志
  39. printerror("AddMAdminGroupSuccess","AddMAdminGroup.php?enews=AddMAdminGroup".hReturnEcmsHashStrHref2(0));
  40. }
  41. else
  42. {
  43. printerror("DbError","history.go(-1)");
  44. }
  45. }
  46. //修改会员管理组
  47. function EditMAdminGroup($add,$userid,$username){
  48. global $empire,$dbtbpre;
  49. $agid=intval($add['agid']);
  50. if(empty($add['agname'])||!$agid)
  51. {
  52. printerror('EmptyMAdminGroup','history.go(-1)');
  53. }
  54. $add['agname']=hRepPostStr($add['agname'],1);
  55. $add['isadmin']=(int)$add['isadmin'];
  56. $addupdate='';
  57. if($agid==1||$agid==2)
  58. {
  59. $addupdate='';
  60. }
  61. else
  62. {
  63. $addupdate=",isadmin='$add[isadmin]'";
  64. }
  65. $sql=$empire->query("update {$dbtbpre}enewsag set agname='$add[agname]'".$addupdate." where agid='$agid'");
  66. //更新缓存
  67. GetConfig();
  68. GetMemberLevel();
  69. if($sql)
  70. {
  71. insert_dolog("agid=$agid&agname=$add[agname]");//操作日志
  72. printerror("EditMAdminGroupSuccess","ListMAdminGroup.php".hReturnEcmsHashStrHref2(1));
  73. }
  74. else
  75. {
  76. printerror("DbError","history.go(-1)");
  77. }
  78. }
  79. //删除会员管理组
  80. function DelMAdminGroup($add,$userid,$username){
  81. global $empire,$dbtbpre;
  82. $agid=intval($add['agid']);
  83. if(!$agid)
  84. {
  85. printerror('EmptyMAdminGroupid','history.go(-1)');
  86. }
  87. $r=$empire->fetch1("select agid,agname from {$dbtbpre}enewsag where agid='$agid'");
  88. if(!$r['agid'])
  89. {
  90. printerror('EmptyMAdminGroupid','history.go(-1)');
  91. }
  92. if($agid==1||$agid==2)
  93. {
  94. printerror('NotDelSysMAdminGroupid','history.go(-1)');
  95. }
  96. $sql=$empire->query("delete from {$dbtbpre}enewsag where agid='$agid'");
  97. $empire->query("update ".eReturnMemberTable()." set ".egetmf('agid')."=0 where ".egetmf('agid')."='$agid'");
  98. //更新缓存
  99. GetConfig();
  100. GetMemberLevel();
  101. if($sql)
  102. {
  103. insert_dolog("agid=$gid&agname=$r[agname]");//操作日志
  104. printerror("DelMAdminGroupSuccess","ListMAdminGroup.php".hReturnEcmsHashStrHref2(1));
  105. }
  106. else
  107. {
  108. printerror("DbError","history.go(-1)");
  109. }
  110. }
  111. //增加会员管理员
  112. function AddMAgUser($add,$userid,$username){
  113. global $empire,$dbtbpre;
  114. $agid=(int)$add['agid'];
  115. $adduserid=(int)$add['adduserid'];
  116. $addusername=RepPostVar($add['addusername']);
  117. if(!$agid||!$adduserid||!$addusername)
  118. {
  119. printerror("EmptyMAgUser","history.go(-1)");
  120. }
  121. $magr=$empire->fetch1("select * from {$dbtbpre}enewsag where agid='$agid'");
  122. if(!$magr['agid'])
  123. {
  124. printerror("EmptyMAgUser","history.go(-1)");
  125. }
  126. $mr=$empire->fetch1("select ".eReturnSelectMemberF('userid')." from ".eReturnMemberTable()." where ".egetmf('userid')."='$adduserid' and ".egetmf('username')."='$addusername' limit 1");
  127. if(!$mr['userid'])
  128. {
  129. printerror("ErrorMAgUser","history.go(-1)");
  130. }
  131. //是否存在
  132. if(strstr($magr['auids'],','.$adduserid.','))
  133. {
  134. printerror("HaveMAgUser","history.go(-1)");
  135. }
  136. $num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsag where auids like '%,".$adduserid.",%' limit 1");
  137. if($num)
  138. {
  139. printerror("HaveMAgUser","history.go(-1)");
  140. }
  141. if($magr['auids'])
  142. {
  143. $new_auids=$magr['auids'].$adduserid.',';
  144. }
  145. else
  146. {
  147. $new_auids=','.$adduserid.',';
  148. }
  149. $sql=$empire->query("update {$dbtbpre}enewsag set auids='$new_auids' where agid='$agid' limit 1");
  150. $empire->query("update ".eReturnMemberTable()." set ".egetmf('agid')."='$agid' where ".egetmf('userid')."='$adduserid'");
  151. //更新缓存
  152. GetConfig();
  153. GetMemberLevel();
  154. if($sql)
  155. {
  156. //操作日志
  157. insert_dolog("agid=".$agid."<br>userid=".$adduserid."&username=".$addusername);
  158. printerror("AddMAgUserSuccess","ListMAgUser.php?agid=$agid".hReturnEcmsHashStrHref2(0));
  159. }
  160. else
  161. {printerror("DbError","history.go(-1)");}
  162. }
  163. //删除会员管理员
  164. function DelMAgUser($add,$userid,$username){
  165. global $empire,$dbtbpre;
  166. $agid=(int)$add['agid'];
  167. $adduserid=(int)$add['adduserid'];
  168. if(!$agid||!$adduserid)
  169. {
  170. printerror("EmptyMAgUser","history.go(-1)");
  171. }
  172. $magr=$empire->fetch1("select * from {$dbtbpre}enewsag where agid='$agid'");
  173. if(!$magr['agid'])
  174. {
  175. printerror("EmptyMAgUser","history.go(-1)");
  176. }
  177. $new_auids=str_replace(",".$adduserid.",",",",$magr['auids']);
  178. if($new_auids==',')
  179. {
  180. $new_auids='';
  181. }
  182. $sql=$empire->query("update {$dbtbpre}enewsag set auids='$new_auids' where agid='$agid' limit 1");
  183. $empire->query("update ".eReturnMemberTable()." set ".egetmf('agid')."=0 where ".egetmf('userid')."='$adduserid'");
  184. //更新缓存
  185. GetConfig();
  186. GetMemberLevel();
  187. if($sql)
  188. {
  189. //操作日志
  190. insert_dolog("agid=".$agid."<br>userid=".$adduserid);
  191. printerror("DelMAgUserSuccess","ListMAgUser.php?agid=$agid".hReturnEcmsHashStrHref2(0));
  192. }
  193. else
  194. {printerror("DbError","history.go(-1)");}
  195. }
  196. $enews=$_POST['enews'];
  197. if(empty($enews))
  198. {$enews=$_GET['enews'];}
  199. if($enews)
  200. {
  201. hCheckEcmsRHash();
  202. }
  203. if($enews=="AddMAdminGroup")
  204. {
  205. AddMAdminGroup($_POST,$logininid,$loginin);
  206. }
  207. elseif($enews=="EditMAdminGroup")
  208. {
  209. EditMAdminGroup($_POST,$logininid,$loginin);
  210. }
  211. elseif($enews=="DelMAdminGroup")
  212. {
  213. DelMAdminGroup($_GET,$logininid,$loginin);
  214. }
  215. elseif($enews=="AddMAgUser")
  216. {
  217. AddMAgUser($_POST,$logininid,$loginin);
  218. }
  219. elseif($enews=="DelMAgUser")
  220. {
  221. DelMAgUser($_GET,$logininid,$loginin);
  222. }
  223. $search=$ecms_hashur['ehref'];
  224. $page=(int)$_GET['page'];
  225. $page=RepPIntvar($page);
  226. $start=0;
  227. $line=50;//每页显示条数
  228. $page_line=25;//每页显示链接数
  229. $offset=$page*$line;//总偏移量
  230. $query="select * from {$dbtbpre}enewsag";
  231. $totalquery="select count(*) as total from {$dbtbpre}enewsag";
  232. $num=$empire->gettotal($totalquery);//取得总条数
  233. $query=$query." order by agid desc limit $offset,$line";
  234. $sql=$empire->query($query);
  235. $returnpage=page2($num,$line,$page_line,$start,$page,$search);
  236. ?>
  237. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  238. <html>
  239. <head>
  240. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  241. <link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
  242. <title>会员管理组</title>
  243. </head>
  244. <body>
  245. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  246. <tr>
  247. <td width="50%" height="25">位置:<a href="ListMAdminGroup.php<?=$ecms_hashur['whehref']?>">管理会员管理组</a></td>
  248. <td><div align="right" class="emenubutton">
  249. <input type="button" name="Submit5" value="增加会员管理组" onclick="self.location.href='AddMAdminGroup.php?enews=AddMAdminGroup<?=$ecms_hashur['ehref']?>';">
  250. </div></td>
  251. </tr>
  252. </table>
  253. <br>
  254. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  255. <tr class="header">
  256. <td width="5%" height="25"> <div align="center">ID</div></td>
  257. <td width="32%" height="25"> <div align="center">组名称</div></td>
  258. <td width="26%"><div align="center">管理级别</div></td>
  259. <td width="21%"><div align="center">成员列表</div></td>
  260. <td width="16%" height="25"> <div align="center">操作</div></td>
  261. </tr>
  262. <?php
  263. while($r=$empire->fetch($sql))
  264. {
  265. $color="#ffffff";
  266. $movejs=' onmouseout="this.style.backgroundColor=\'#ffffff\'" onmouseover="this.style.backgroundColor=\'#C3EFFF\'"';
  267. $membernum=0;
  268. if($r['auids'])
  269. {
  270. $mr=explode(",",$r['auids']);
  271. $membernum=count($mr)-2;
  272. }
  273. if($r['isadmin']==9)
  274. {
  275. $isadminname='管理员';
  276. }
  277. elseif($r['isadmin']==5)
  278. {
  279. $isadminname='版主';
  280. }
  281. elseif($r['isadmin']==1)
  282. {
  283. $isadminname='实习版主';
  284. }
  285. else
  286. {
  287. $isadminname='';
  288. }
  289. ?>
  290. <tr bgcolor="<?=$color?>"<?=$movejs?>>
  291. <td height="25"> <div align="center">
  292. <?=$r[agid]?>
  293. </div></td>
  294. <td height="25"> <div align="center">
  295. <?=$r[agname]?>
  296. </div></td>
  297. <td><div align="center"><?=$isadminname?></div></td>
  298. <td><div align="center"><a href="ListMAgUser.php?agid=<?=$r['agid']?><?=$ecms_hashur['ehref']?>" target="_blank">管理成员列表 (<strong><?=$membernum?></strong>)</a></div></td>
  299. <td height="25"> <div align="center"> [<a href="AddMAdminGroup.php?enews=EditMAdminGroup&agid=<?=$r[agid]?><?=$ecms_hashur['ehref']?>">修改</a>]&nbsp;[<a href="ListMAdminGroup.php?enews=DelMAdminGroup&agid=<?=$r[agid]?><?=$ecms_hashur['href']?>" onclick="return confirm('确认要删除?');">删除</a>]</div></td>
  300. </tr>
  301. <?
  302. }
  303. ?>
  304. <tr bgcolor="#FFFFFF">
  305. <td height="25" colspan="5">&nbsp;&nbsp;&nbsp;
  306. <?=$returnpage?> </td>
  307. </tr>
  308. </table>
  309. </body>
  310. </html>
  311. <?
  312. db_close();
  313. $empire=null;
  314. ?>