UserClass.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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,"user");
  20. //增加部门
  21. function AddUserClass($add,$userid,$username){
  22. global $empire,$dbtbpre;
  23. if(!$add[classname])
  24. {
  25. printerror("EmptyUserClass","history.go(-1)");
  26. }
  27. //验证权限
  28. CheckLevel($userid,$username,$classid,"user");
  29. $add[classname]=hRepPostStr($add[classname],1);
  30. $sql=$empire->query("insert into {$dbtbpre}enewsuserclass(classname) values('".$add[classname]."');");
  31. $lastid=$empire->lastid();
  32. if($sql)
  33. {
  34. //操作日志
  35. insert_dolog("classid=".$lastid."<br>classname=".$add[classname]);
  36. printerror("AddUserClassSuccess","UserClass.php".hReturnEcmsHashStrHref2(1));
  37. }
  38. else
  39. {printerror("DbError","history.go(-1)");}
  40. }
  41. //修改部门
  42. function EditUserClass($add,$userid,$username){
  43. global $empire,$dbtbpre;
  44. $classid=(int)$add[classid];
  45. if(!$add[classname]||!$classid)
  46. {
  47. printerror("EmptyUserClass","history.go(-1)");
  48. }
  49. //验证权限
  50. CheckLevel($userid,$username,$classid,"user");
  51. $add[classname]=hRepPostStr($add[classname],1);
  52. $sql=$empire->query("update {$dbtbpre}enewsuserclass set classname='".$add[classname]."' where classid='$classid'");
  53. if($sql)
  54. {
  55. //操作日志
  56. insert_dolog("classid=".$classid."<br>classname=".$add[classname]);
  57. printerror("EditUserClassSuccess","UserClass.php".hReturnEcmsHashStrHref2(1));
  58. }
  59. else
  60. {printerror("DbError","history.go(-1)");}
  61. }
  62. //删除部门
  63. function DelUserClass($classid,$userid,$username){
  64. global $empire,$dbtbpre;
  65. $classid=(int)$classid;
  66. if(!$classid)
  67. {
  68. printerror("NotDelUserClassid","history.go(-1)");
  69. }
  70. //验证权限
  71. CheckLevel($userid,$username,$classid,"user");
  72. $r=$empire->fetch1("select classname from {$dbtbpre}enewsuserclass where classid='$classid'");
  73. $sql=$empire->query("delete from {$dbtbpre}enewsuserclass where classid='$classid'");
  74. if($sql)
  75. {
  76. //操作日志
  77. insert_dolog("classid=".$classid."<br>classname=".$r[classname]);
  78. printerror("DelUserClassSuccess","UserClass.php".hReturnEcmsHashStrHref2(1));
  79. }
  80. else
  81. {printerror("DbError","history.go(-1)");}
  82. }
  83. $enews=$_POST['enews'];
  84. if(empty($enews))
  85. {$enews=$_GET['enews'];}
  86. if($enews)
  87. {
  88. hCheckEcmsRHash();
  89. }
  90. if($enews=="AddUserClass")//增加部门
  91. {
  92. AddUserClass($_POST,$logininid,$loginin);
  93. }
  94. elseif($enews=="EditUserClass")//修改部门
  95. {
  96. EditUserClass($_POST,$logininid,$loginin);
  97. }
  98. elseif($enews=="DelUserClass")//删除部门
  99. {
  100. $classid=$_GET['classid'];
  101. DelUserClass($classid,$logininid,$loginin);
  102. }
  103. else
  104. {}
  105. $sql=$empire->query("select classid,classname from {$dbtbpre}enewsuserclass order by classid desc");
  106. ?>
  107. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  108. <html>
  109. <head>
  110. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  111. <title></title>
  112. <link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
  113. </head>
  114. <body>
  115. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  116. <tr>
  117. <td><p>位置:<a href="ListUser.php<?=$ecms_hashur['whehref']?>">管理用户</a> &gt; <a href="UserClass.php<?=$ecms_hashur['whehref']?>">管理部门</a></p>
  118. </td>
  119. </tr>
  120. </table>
  121. <form name="form1" method="post" action="UserClass.php">
  122. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  123. <?=$ecms_hashur['form']?>
  124. <tr class="header">
  125. <td height="25">增加部门:
  126. <input name=enews type=hidden id="enews" value=AddUserClass>
  127. </td>
  128. </tr>
  129. <tr>
  130. <td height="25" bgcolor="#FFFFFF"> 部门名称:
  131. <input name="classname" type="text" id="classname">
  132. <input type="submit" name="Submit" value="增加">
  133. <input type="reset" name="Submit2" value="重置"></td>
  134. </tr>
  135. </table>
  136. </form>
  137. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  138. <tr class="header">
  139. <td width="10%"><div align="center">ID</div></td>
  140. <td width="59%" height="25"><div align="center">部门名称</div></td>
  141. <td width="31%" height="25"><div align="center">操作</div></td>
  142. </tr>
  143. <?
  144. while($r=$empire->fetch($sql))
  145. {
  146. ?>
  147. <form name=form2 method=post action=UserClass.php>
  148. <?=$ecms_hashur['form']?>
  149. <input type=hidden name=enews value=EditUserClass>
  150. <input type=hidden name=classid value=<?=$r[classid]?>>
  151. <tr bgcolor="#FFFFFF" onmouseout="this.style.backgroundColor='#ffffff'" onmouseover="this.style.backgroundColor='#C3EFFF'">
  152. <td><div align="center"><?=$r[classid]?></div></td>
  153. <td height="25"> <div align="center">
  154. <input name="classname" type="text" id="classname" value="<?=$r[classname]?>">
  155. </div></td>
  156. <td height="25"><div align="center">
  157. <input type="submit" name="Submit3" value="修改">
  158. &nbsp;
  159. <input type="button" name="Submit4" value="删除" onclick="if(confirm('确认要删除?')){self.location.href='UserClass.php?enews=DelUserClass&classid=<?=$r[classid]?><?=$ecms_hashur['href']?>';}">
  160. </div></td>
  161. </tr>
  162. </form>
  163. <?
  164. }
  165. db_close();
  166. $empire=null;
  167. ?>
  168. </table>
  169. </body>
  170. </html>