ListVgMember.php 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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,"viewgroup");
  22. //更新访问组状态
  23. function ToUpViewGroupMList($vgid){
  24. global $empire,$dbtbpre;
  25. $vgid=(int)$vgid;
  26. $membernum=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsvglist where vgid='$vgid'");
  27. $mlist=$membernum?1:0;
  28. $sql=$empire->query("update {$dbtbpre}enewsvg set mlist='$mlist' where vgid='$vgid'");
  29. }
  30. //增加会员白名单
  31. function AddViewGroupMList($add,$userid,$username){
  32. global $empire,$dbtbpre;
  33. $vgid=(int)$add['vgid'];
  34. $usertype=(int)$add['usertype'];
  35. $adduserid=RepPostVar($add['adduserid']);
  36. if(!$vgid||!$usertype||!$adduserid)
  37. {
  38. printerror("EmptyViewGroupMList","history.go(-1)");
  39. }
  40. $addtime=time();
  41. $outtime=$add['outtime'];
  42. if($outtime)
  43. {
  44. $outtime=to_time($outtime);
  45. }
  46. $outtime=(int)$outtime;
  47. //会员
  48. $havem=0;
  49. $r=explode(',',$adduserid);
  50. $count=count($r);
  51. for($i=0;$i<$count;$i++)
  52. {
  53. $thisuid=trim($r[$i]);
  54. if(empty($thisuid))
  55. {
  56. continue;
  57. }
  58. //类型
  59. if($usertype==2)
  60. {
  61. $thisuid=RepPostVar($thisuid);
  62. $mr=$empire->fetch1("select ".eReturnSelectMemberF('userid')." from ".eReturnMemberTable()." where ".egetmf('username')."='$thisuid' limit 1");
  63. }
  64. else
  65. {
  66. $thisuid=(int)$thisuid;
  67. $mr=$empire->fetch1("select ".eReturnSelectMemberF('userid')." from ".eReturnMemberTable()." where ".egetmf('userid')."='$thisuid' limit 1");
  68. }
  69. if(!$mr['userid'])
  70. {
  71. continue;
  72. }
  73. //是否存在
  74. $vgnum=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsvglist where vgid='$vgid' and userid='$mr[userid]' limit 1");
  75. if(!$vgnum)
  76. {
  77. $empire->query("insert into {$dbtbpre}enewsvglist(vgid,addtime,userid,outtime) values('$vgid','$addtime','$mr[userid]','$outtime');");
  78. $havem=1;
  79. }
  80. }
  81. ToUpViewGroupMList($vgid);
  82. //操作日志
  83. insert_dolog("vgid=".$vgid."&usertype=".$usertype."<br>adduserid=".$adduserid);
  84. printerror("AddViewGroupMListSuccess","ListVgMember.php?vgid=$vgid".hReturnEcmsHashStrHref2(0));
  85. }
  86. //修改会员白名单
  87. function EditViewGroupMList($add,$userid,$username){
  88. global $empire,$dbtbpre;
  89. $vgid=(int)$add['vgid'];
  90. $adduserid=(int)$add['adduserid'];
  91. if(!$vgid||!$adduserid)
  92. {
  93. printerror("EmptyViewGroupMList","history.go(-1)");
  94. }
  95. $outtime=$add['outtime'];
  96. if($outtime)
  97. {
  98. $outtime=to_time($outtime);
  99. }
  100. $outtime=(int)$outtime;
  101. $sql=$empire->query("update {$dbtbpre}enewsvglist set outtime='$outtime' where vgid='$vgid' and userid='$adduserid' limit 1");
  102. if($sql)
  103. {
  104. //操作日志
  105. insert_dolog("vgid=".$vgid."<br>userid=".$adduserid);
  106. printerror("EditViewGroupMListSuccess",EcmsGetReturnUrl());
  107. }
  108. else
  109. {printerror("DbError","history.go(-1)");}
  110. }
  111. //删除会员白名单
  112. function DelViewGroupMList($add,$userid,$username){
  113. global $empire,$dbtbpre;
  114. $vgid=(int)$add['vgid'];
  115. $adduserid=(int)$add['adduserid'];
  116. if(!$vgid||!$adduserid)
  117. {
  118. printerror("EmptyViewGroupMList","history.go(-1)");
  119. }
  120. $sql=$empire->query("delete from {$dbtbpre}enewsvglist where vgid='$vgid' and userid='$adduserid'");
  121. ToUpViewGroupMList($vgid);
  122. if($sql)
  123. {
  124. //操作日志
  125. insert_dolog("vgid=".$vgid."<br>userid=".$adduserid);
  126. printerror("DelViewGroupMListSuccess",EcmsGetReturnUrl());
  127. }
  128. else
  129. {printerror("DbError","history.go(-1)");}
  130. }
  131. $enews=$_POST['enews'];
  132. if(empty($enews))
  133. {$enews=$_GET['enews'];}
  134. if($enews)
  135. {
  136. hCheckEcmsRHash();
  137. }
  138. if($enews=="AddViewGroupMList")
  139. {
  140. AddViewGroupMList($_POST,$logininid,$loginin);
  141. }
  142. elseif($enews=="EditViewGroupMList")
  143. {
  144. EditViewGroupMList($_POST,$logininid,$loginin);
  145. }
  146. elseif($enews=="DelViewGroupMList")
  147. {
  148. DelViewGroupMList($_GET,$logininid,$loginin);
  149. }
  150. else
  151. {}
  152. $vgid=(int)$_GET['vgid'];
  153. if(!$vgid)
  154. {
  155. printerror("ErrorUrl","history.go(-1)");
  156. }
  157. $vgr=$empire->fetch1("select * from {$dbtbpre}enewsvg where vgid='$vgid'");
  158. if(!$vgr['vgid'])
  159. {
  160. printerror("ErrorUrl","history.go(-1)");
  161. }
  162. $page=(int)$_GET['page'];
  163. $page=RepPIntvar($page);
  164. $start=0;
  165. $line=30;//每页显示条数
  166. $page_line=12;//每页显示链接数
  167. $offset=$page*$line;//总偏移量
  168. $search='&vgid='.$vgid;
  169. $search.=$ecms_hashur['ehref'];
  170. $totalquery="select count(*) as total from {$dbtbpre}enewsvglist";
  171. $num=$empire->gettotal($totalquery);
  172. $query="select * from {$dbtbpre}enewsvglist order by addtime desc limit $offset,$line";
  173. $sql=$empire->query($query);
  174. $returnpage=page2($num,$line,$page_line,$start,$page,$search);
  175. ?>
  176. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  177. <html>
  178. <head>
  179. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  180. <title>管理会员白名单</title>
  181. <link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
  182. <script type="text/javascript" src="../ecmseditor/js/jstime/WdatePicker.js"></script>
  183. </head>
  184. <body>
  185. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  186. <tr>
  187. <td>位置:<a href="ListViewGroup.php<?=$ecms_hashur['whehref']?>">管理会员访问组</a>&nbsp;>&nbsp;<a href="ListVgMember.php?vgid=<?=$vgr['vgid']?><?=$ecms_hashur['ehref']?>"><?=$vgr['gname']?></a>&nbsp;>&nbsp;会员白名单</td>
  188. </tr>
  189. </table>
  190. <form name="form1" method="post" action="ListVgMember.php">
  191. <table width="800" border="0" cellpadding="3" cellspacing="1" class="tableborder">
  192. <?=$ecms_hashur['form']?>
  193. <tr class="header">
  194. <td height="25" colspan="4">增加会员白名单:
  195. <input name=enews type=hidden id="enews" value=AddViewGroupMList>
  196. <input type=hidden name=vgid value="<?=$vgid?>"> </td>
  197. </tr>
  198. <tr>
  199. <td width="96" height="25" bgcolor="#FFFFFF"><div align="center"><strong>增加类型</strong></div></td>
  200. <td width="391" bgcolor="#FFFFFF"><strong>会员ID或用户名</strong><font color="#666666">(多个用半角逗号隔开)</font></td>
  201. <td width="207" bgcolor="#FFFFFF"><strong>过期时间 </strong><font color="#666666">(留空为不限)</font></td>
  202. <td width="77" bgcolor="#FFFFFF"><div align="center"><strong>操作</strong></div></td>
  203. </tr>
  204. <tr>
  205. <td height="25" bgcolor="#FFFFFF"><div align="center">
  206. <select name="usertype" id="usertype">
  207. <option value="1">会员ID</option>
  208. <option value="2">用户名</option>
  209. </select>
  210. </div></td>
  211. <td bgcolor="#FFFFFF"><input name="adduserid" type="text" id="adduserid" size="55"></td>
  212. <td bgcolor="#FFFFFF"><input name="outtime" type="text" class="Wdate" id="outtime" onClick="WdatePicker({skin:'default',dateFmt:'yyyy-MM-dd HH:mm:ss'})" size="28"></td>
  213. <td bgcolor="#FFFFFF"><div align="center">
  214. <input type="submit" name="Submit" value="增加">
  215. </div></td>
  216. </tr>
  217. </table>
  218. </form>
  219. <table width="800" border="0" cellpadding="3" cellspacing="1" class="tableborder">
  220. <tr class="header">
  221. <td width="8%" height="25"><div align="center">会员ID</div></td>
  222. <td width="29%"><div align="center">用户名</div></td>
  223. <td width="18%"><div align="center">增加时间</div></td>
  224. <td width="25%"><div align="center">过期时间</div></td>
  225. <td width="20%" height="25"><div align="center">操作</div></td>
  226. </tr>
  227. <?
  228. while($r=$empire->fetch($sql))
  229. {
  230. $mr=$empire->fetch1("select ".eReturnSelectMemberF('username')." from ".eReturnMemberTable()." where ".egetmf('userid')."='$r[userid]'");
  231. ?>
  232. <form name=form2 method=post action=ListVgMember.php>
  233. <?=$ecms_hashur['form']?>
  234. <input type=hidden name=enews value=EditViewGroupMList>
  235. <input type=hidden name=vgid value="<?=$r['vgid']?>">
  236. <input type=hidden name=adduserid value="<?=$r['userid']?>">
  237. <tr bgcolor="#FFFFFF" onmouseout="this.style.backgroundColor='#ffffff'" onmouseover="this.style.backgroundColor='#C3EFFF'">
  238. <td height="25"><div align="center"><?=$r['userid']?></div></td>
  239. <td height="25"><div align="center"><a href="AddMember.php?enews=EditMember&userid=<?=$r['userid']?><?=$ecms_hashur['ehref']?>" target=_blank><?=$mr['username']?></a></div></td>
  240. <td><div align="center"><?=date("Y-m-d H:i:s",$r['addtime'])?></div></td>
  241. <td height="25"><div align="center">
  242. <input name="outtime" type="text" class="Wdate" id="outtime" onClick="WdatePicker({skin:'default',dateFmt:'yyyy-MM-dd HH:mm:ss'})" value="<?=$r['outtime']?date("Y-m-d H:i:s",$r['outtime']):''?>" size="28">
  243. </div></td>
  244. <td height="25"><div align="center">
  245. <input type="submit" name="Submit3" value="修改">
  246. &nbsp;
  247. <input type="button" name="Submit4" value="删除" onclick="if(confirm('确认要删除此会员白名单?')){self.location.href='ListVgMember.php?enews=DelViewGroupMList&vgid=<?=$r['vgid']?>&adduserid=<?=$r['userid']?><?=$ecms_hashur['href']?>';}">
  248. </div></td>
  249. </tr>
  250. </form>
  251. <?
  252. }
  253. db_close();
  254. $empire=null;
  255. ?>
  256. <tr bgcolor="#FFFFFF">
  257. <td height="25" colspan="5">
  258. <?=$returnpage?> </td>
  259. </tr>
  260. </table>
  261. </body>
  262. </html>