admin.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <?php
  2. class admin_c extends Control
  3. {
  4. var $module_sign = "admin";//权限标识
  5. function __construct()
  6. {
  7. parent::Control();
  8. $this->load_model("admin");
  9. $this->load_model("module");
  10. }
  11. //兼容PHP4的写法
  12. function admin_c()
  13. {
  14. $this->__construct();
  15. }
  16. function index_f()
  17. {
  18. sys_popedom($this->module_sign.":list","tpl");
  19. $pageid = $this->trans_lib->int(SYS_PAGEID);
  20. $page_url = site_url("admin");
  21. $condition = "";
  22. $admin_rs = $this->admin_m->get_one($_SESSION["admin_id"]);
  23. if(!$admin_rs["if_system"])
  24. {
  25. $condition = " if_system='0' ";
  26. }
  27. $rslist = $this->admin_m->get_list($pageid,$condition);
  28. $this->tpl->assign("rslist",$rslist);
  29. $count = $this->admin_m->get_count($condition);
  30. $this->tpl->assign("total",$count);
  31. $this->tpl->display("admin/list.html");
  32. }
  33. function set_f()
  34. {
  35. $id = $this->trans_lib->int("id");
  36. if($id)
  37. {
  38. if($id == $_SESSION["admin_id"])
  39. {
  40. error("对不起,您不能修改自己的信息",site_url("admin"));
  41. }
  42. sys_popedom($this->module_sign.":modify","tpl");
  43. $rs = $this->admin_m->get_one($id);
  44. $popedom = $rs["popedom"] ? sys_id_list($rs["popedom"]) : array("0:0");
  45. $this->tpl->assign("rs",$rs);
  46. $lang_popedom = $rs["langid"] ? sys_id_list($rs["langid"]) : array();
  47. $this->tpl->assign("lang_popedom",$lang_popedom);
  48. }
  49. else
  50. {
  51. sys_popedom($this->module_sign.":add","tpl");
  52. $popedom = array("0:0");
  53. $lang_popedom = $rs["langid"] ? sys_id_list($rs["langid"]) : array();
  54. $this->tpl->assign("lang_popedom",$lang_popedom);
  55. }
  56. $this->tpl->assign("popedom",$popedom);
  57. //读取所有可以配置权限的模块
  58. $mlist = $this->module_m->all_module();
  59. $this->tpl->assign("mlist",$mlist);
  60. $this->load_model("identifier");
  61. $plist = $this->identifier_m->popedom_list();
  62. $this->tpl->assign("plist",$plist);
  63. //读取所有可以配置的语言
  64. $this->load_model("lang");
  65. $langlist = $this->lang_m->get_list();
  66. $this->tpl->assign("langlist",$langlist);
  67. $this->tpl->display("admin/set.html");
  68. }
  69. function chk_f()
  70. {
  71. $id = $this->trans_lib->int("id");
  72. $email = $this->trans_lib->safe("email");
  73. if(!$email)
  74. {
  75. exit("error: 管理员邮箱不允许为空");
  76. }
  77. $name = $this->trans_lib->safe("name");
  78. if(!$name)
  79. {
  80. exit("error: 管理员账号不允许为空");
  81. }
  82. $rs_name = $this->admin_m->chk_name($name,$id);
  83. if($rs_name)
  84. {
  85. exit("error:管理员账号已经存在");
  86. }
  87. $rs_email = $this->admin_m->chk_email($email,$id);
  88. if($rs_email)
  89. {
  90. exit("error:管理员邮箱已经存在");
  91. }
  92. exit("ok");
  93. }
  94. //存储信息
  95. function setok_f()
  96. {
  97. $id = $this->trans_lib->int("id");
  98. if($id)
  99. {
  100. sys_popedom($this->module_sign.":modify","tpl");
  101. }
  102. else
  103. {
  104. sys_popedom($this->module_sign.":add","tpl");
  105. }
  106. $array = array();
  107. $array["name"] = $this->trans_lib->safe("name");
  108. $pass = $this->trans_lib->safe("pass");
  109. if($pass)
  110. {
  111. $array["pass"] = sys_md5($pass);
  112. }
  113. else
  114. {
  115. if(!$id)
  116. {
  117. $array["pass"] = sys_md5("123456");
  118. }
  119. }
  120. $array["email"] = $this->trans_lib->safe("email");//模板目录
  121. $array["if_system"] = $this->trans_lib->int("if_system");
  122. if(!$array["if_system"])
  123. {
  124. $popedom = $this->trans_lib->safe("popedom");
  125. $array["popedom"] = $popedom ? implode(",",$popedom) : "";
  126. }
  127. else
  128. {
  129. $array["popedom"] = "";
  130. }
  131. $mylangid = $this->trans_lib->safe("mylangid");
  132. $array["langid"] = sys_id_string($mylangid);
  133. //存储分类信息
  134. $this->admin_m->save($array,$id);
  135. error("管理员信息添加/存储成功",site_url("admin"));
  136. }
  137. function ajax_status_f()
  138. {
  139. $id = $this->trans_lib->int("id");
  140. if(!$id)
  141. {
  142. exit("error:没有指定ID");
  143. }
  144. if($id == $_SESSION["admin_id"])
  145. {
  146. exit("对不起,你不能锁定自己!");
  147. }
  148. sys_popedom($this->module_sign.":check","ajax");
  149. $rs = $this->admin_m->get_one($id);
  150. $status = $rs["status"] ? 0 : 1;
  151. $this->admin_m->set_status($id,$status);
  152. exit("ok");
  153. }
  154. function ajax_del_f()
  155. {
  156. $id = $this->trans_lib->int("id");
  157. if(!$id)
  158. {
  159. exit("error:没有指定ID");
  160. }
  161. $module_id = $this->trans_lib->int("module_id");
  162. if(!$module_id)
  163. {
  164. exit("error: 无法读取模块ID");
  165. }
  166. if($id == $_SESSION["admin_id"])
  167. {
  168. exit("error: 管理员不能删除自己!");
  169. }
  170. sys_popedom($this->module_sign.":delete","ajax");
  171. $this->admin_m->del($id);
  172. exit("ok");
  173. }
  174. }
  175. ?>