ListViewGroup.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <?php
  2. define('EmpireCMSAdmin','1');
  3. require("../../class/connect.php");
  4. require("../../class/db_sql.php");
  5. require("../../class/functions.php");
  6. require "../".LoadLang("pub/fun.php");
  7. $link=db_connect();
  8. $empire=new mysqlquery();
  9. $editor=1;
  10. //验证用户
  11. $lur=is_login();
  12. $logininid=$lur['userid'];
  13. $loginin=$lur['username'];
  14. $loginrnd=$lur['rnd'];
  15. $loginlevel=$lur['groupid'];
  16. $loginadminstyleid=$lur['adminstyleid'];
  17. //ehash
  18. $ecms_hashur=hReturnEcmsHashStrAll();
  19. //验证权限
  20. CheckLevel($logininid,$loginin,$classid,"viewgroup");
  21. //返回会员组
  22. function ReturnAddViewMemberGroup($membergroup){
  23. $count=count($membergroup);
  24. if($count==0)
  25. {
  26. return '';
  27. }
  28. $mg='';
  29. for($i=0;$i<$count;$i++)
  30. {
  31. $mg.=intval($membergroup[$i]).',';
  32. }
  33. if($mg)
  34. {
  35. $mg=','.$mg;
  36. }
  37. return $mg;
  38. }
  39. //增加会员访问组
  40. function AddViewGroup($add,$userid,$username){
  41. global $empire,$dbtbpre;
  42. if(empty($add['gname']))
  43. {
  44. printerror('EmptyViewGroup','history.go(-1)');
  45. }
  46. $gname=hRepPostStr($add['gname'],1);
  47. $gids=ReturnAddViewMemberGroup($add['membergroup']);
  48. $ingids=ReturnAddViewMemberGroup($add['ingroup']);
  49. $agids=ReturnAddViewMemberGroup($add['madmingroup']);
  50. $sql=$empire->query("insert into {$dbtbpre}enewsvg(gname,gids,ingids,agids,mlist) values('$gname','$gids','$ingids','$agids',0);");
  51. if($sql)
  52. {
  53. $vgid=$empire->lastid();
  54. insert_dolog("vgid=$vgid&gname=$gname");//操作日志
  55. printerror("AddViewGroupSuccess","AddViewGroup.php?enews=AddViewGroup".hReturnEcmsHashStrHref2(0));
  56. }
  57. else
  58. {
  59. printerror("DbError","history.go(-1)");
  60. }
  61. }
  62. //修改会员访问组
  63. function EditViewGroup($add,$userid,$username){
  64. global $empire,$dbtbpre;
  65. $vgid=intval($add['vgid']);
  66. if(empty($add['gname'])||!$vgid)
  67. {
  68. printerror('EmptyViewGroup','history.go(-1)');
  69. }
  70. $gname=hRepPostStr($add['gname'],1);
  71. $gids=ReturnAddViewMemberGroup($add['membergroup']);
  72. $ingids=ReturnAddViewMemberGroup($add['ingroup']);
  73. $agids=ReturnAddViewMemberGroup($add['madmingroup']);
  74. //会员白名单
  75. $membernum=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsvglist where vgid='$vgid'");
  76. $mlist=$membernum?1:0;
  77. $sql=$empire->query("update {$dbtbpre}enewsvg set gname='$gname',gids='$gids',ingids='$ingids',agids='$agids',mlist='$mlist' where vgid='$vgid'");
  78. if($sql)
  79. {
  80. insert_dolog("vgid=$vgid&gname=$gname");//操作日志
  81. printerror("EditViewGroupSuccess","ListViewGroup.php".hReturnEcmsHashStrHref2(1));
  82. }
  83. else
  84. {
  85. printerror("DbError","history.go(-1)");
  86. }
  87. }
  88. //删除会员访问组
  89. function DelViewGroup($add,$userid,$username){
  90. global $empire,$dbtbpre;
  91. $vgid=intval($add['vgid']);
  92. if(!$vgid)
  93. {
  94. printerror('EmptyViewGroupid','history.go(-1)');
  95. }
  96. $r=$empire->fetch1("select vgid,gname from {$dbtbpre}enewsvg where vgid='$vgid'");
  97. if(!$r['vgid'])
  98. {
  99. printerror('EmptyViewGroupid','history.go(-1)');
  100. }
  101. $sql=$empire->query("delete from {$dbtbpre}enewsvg where vgid='$vgid'");
  102. $msql=$empire->query("delete from {$dbtbpre}enewsvglist where vgid='$vgid'");
  103. if($sql)
  104. {
  105. insert_dolog("vgid=$vgid&gname=$r[gname]");//操作日志
  106. printerror("DelViewGroupSuccess","ListViewGroup.php".hReturnEcmsHashStrHref2(1));
  107. }
  108. else
  109. {
  110. printerror("DbError","history.go(-1)");
  111. }
  112. }
  113. $enews=$_POST['enews'];
  114. if(empty($enews))
  115. {$enews=$_GET['enews'];}
  116. if($enews)
  117. {
  118. hCheckEcmsRHash();
  119. }
  120. if($enews=="AddViewGroup")
  121. {
  122. AddViewGroup($_POST,$logininid,$loginin);
  123. }
  124. elseif($enews=="EditViewGroup")
  125. {
  126. EditViewGroup($_POST,$logininid,$loginin);
  127. }
  128. elseif($enews=="DelViewGroup")
  129. {
  130. DelViewGroup($_GET,$logininid,$loginin);
  131. }
  132. $search=$ecms_hashur['ehref'];
  133. $page=(int)$_GET['page'];
  134. $page=RepPIntvar($page);
  135. $start=0;
  136. $line=16;//每页显示条数
  137. $page_line=25;//每页显示链接数
  138. $offset=$page*$line;//总偏移量
  139. $query="select * from {$dbtbpre}enewsvg";
  140. $totalquery="select count(*) as total from {$dbtbpre}enewsvg";
  141. $num=$empire->gettotal($totalquery);//取得总条数
  142. $query=$query." order by vgid desc limit $offset,$line";
  143. $sql=$empire->query($query);
  144. $returnpage=page2($num,$line,$page_line,$start,$page,$search);
  145. ?>
  146. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  147. <html>
  148. <head>
  149. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  150. <link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
  151. <title>会员访问组</title>
  152. </head>
  153. <body>
  154. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  155. <tr>
  156. <td width="50%" height="25">位置:<a href="ListViewGroup.php<?=$ecms_hashur['whehref']?>">管理会员访问组</a></td>
  157. <td><div align="right" class="emenubutton">
  158. <input type="button" name="Submit5" value="增加会员访问组" onclick="self.location.href='AddViewGroup.php?enews=AddViewGroup<?=$ecms_hashur['ehref']?>';">
  159. </div></td>
  160. </tr>
  161. </table>
  162. <br>
  163. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  164. <tr class="header">
  165. <td width="6%" height="25"> <div align="center">ID</div></td>
  166. <td width="39%" height="25"> <div align="center">组名称</div></td>
  167. <td width="38%"><div align="center">允许会员白名单</div></td>
  168. <td width="17%" height="25"> <div align="center">操作</div></td>
  169. </tr>
  170. <?php
  171. while($r=$empire->fetch($sql))
  172. {
  173. $color="#ffffff";
  174. $movejs=' onmouseout="this.style.backgroundColor=\'#ffffff\'" onmouseover="this.style.backgroundColor=\'#C3EFFF\'"';
  175. $membernum=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsvglist where vgid='$r[vgid]'");
  176. ?>
  177. <tr bgcolor="<?=$color?>"<?=$movejs?>>
  178. <td height="25"> <div align="center">
  179. <?=$r['vgid']?>
  180. </div></td>
  181. <td height="25"> <div align="center">
  182. <?=$r['gname']?>
  183. </div></td>
  184. <td><div align="center"><a href="ListVgMember.php?vgid=<?=$r['vgid']?><?=$ecms_hashur['ehref']?>" target="_blank">管理会员白名单(数量:<strong><?=$membernum?></strong>)</a></div></td>
  185. <td height="25"> <div align="center"> [<a href="AddViewGroup.php?enews=EditViewGroup&vgid=<?=$r['vgid']?><?=$ecms_hashur['ehref']?>">修改</a>]&nbsp;[<a href="ListViewGroup.php?enews=DelViewGroup&vgid=<?=$r['vgid']?><?=$ecms_hashur['href']?>" onclick="return confirm('确认要删除?');">删除</a>]</div></td>
  186. </tr>
  187. <?
  188. }
  189. ?>
  190. <tr bgcolor="#FFFFFF">
  191. <td height="25" colspan="4">&nbsp;&nbsp;&nbsp;
  192. <?=$returnpage?> </td>
  193. </tr>
  194. </table>
  195. </body>
  196. </html>
  197. <?
  198. db_close();
  199. $empire=null;
  200. ?>