user.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <?php
  2. class user_c extends Control
  3. {
  4. function __construct()
  5. {
  6. parent::Control();
  7. $this->load_model("user");
  8. $this->load_model("usergroup");
  9. $this->load_model("module");
  10. }
  11. //兼容PHP4的写法
  12. function user_c()
  13. {
  14. $this->__construct();
  15. }
  16. //会员列表
  17. function index_f()
  18. {
  19. sys_popedom("user:list","tpl");
  20. $pageid = $this->trans_lib->int(SYS_PAGEID);
  21. $offset = $pageid>0 ? ($pageid-1)*SYS_PSIZE : 0;
  22. $condition = " 1=1 ";
  23. $startdate = $this->trans_lib->safe("startdate");
  24. $page_url = $this->url("user");
  25. if($startdate)
  26. {
  27. $this->tpl->assign("startdate",$startdate);
  28. $condition .= " AND regdate>='".strtotime($startdate)."'";
  29. $page_url .= "startdate=".rawurlencode($startdate)."&";
  30. }
  31. $enddate = $this->trans_lib->safe("enddate");
  32. if($enddate)
  33. {
  34. $this->tpl->assign("enddate",$enddate);
  35. $condition .= " AND regdate<='".strtotime($enddate)."'";
  36. $page_url .= "enddate=".rawurlencode($enddate)."&";
  37. }
  38. $status = $this->trans_lib->int("status");
  39. if($status)
  40. {
  41. $this->tpl->assign("status",$status);
  42. $condition .= " AND status='".($status == 1 ? 1 : 0)."'";
  43. $page_url .= "status=".$status."&";
  44. }
  45. $fxstatus = $this->trans_lib->int("fxstatus");
  46. if($fxstatus)
  47. {
  48. $this->tpl->assign("fxstatus",$fxstatus);
  49. $condition .= " AND fxstatus='".($fxstatus == 1 ? 1 : 0)."'";
  50. $page_url .= "fxstatus=".$fxstatus."&";
  51. }
  52. $keytype = $this->trans_lib->safe("keytype");
  53. $keywords = $this->trans_lib->safe("keywords");
  54. if($keytype && $keywords)
  55. {
  56. $this->tpl->assign("keytype",$keytype);
  57. $this->tpl->assign("keywords",$keywords);
  58. if($keytype=="Recommended"){
  59. $condition .= " AND (SELECT username from ".$this->db->prefix."user where id=u.Recommend) LIKE '%".$keywords."%' ";
  60. }else{
  61. $condition .= " AND ".$keytype." LIKE '%".$keywords."%' ";
  62. }
  63. $page_url .= "keytype=".rawurlencode($keytype)."&keywords=".rawurlencode($keywords)."&";
  64. }
  65. $total = $this->user_m->get_count($condition);
  66. $rslist = $this->user_m->get_list($offset,$condition);
  67. $this->tpl->assign("total",$total);
  68. $this->tpl->assign("rslist",$rslist);
  69. $pagelist = $this->page_lib->page($page_url,$total);
  70. $this->tpl->assign("pagelist",$pagelist);
  71. $grouplist = $this->usergroup_m->get_all();
  72. $this->tpl->assign("grouplist",$grouplist);
  73. $this->tpl->display("user/list.html");
  74. }
  75. function set_f()
  76. {
  77. $id = $this->trans_lib->int("id");
  78. $groupid = $this->trans_lib->int("groupid");
  79. if($id)
  80. {
  81. sys_popedom("user:modify","tpl");
  82. $rs = $this->user_m->get_one($id);
  83. $this->tpl->assign("rs",$rs);
  84. if(!$groupid) $groupid = $rs["groupid"];
  85. }
  86. else
  87. {
  88. sys_popedom("user:add","tpl");
  89. }
  90. if(!$groupid)
  91. {
  92. $group_rs = $this->usergroup_m->get_default();
  93. $groupid = $group_rs["id"];
  94. }
  95. if(!$groupid)
  96. {
  97. error("没有获取到用户组!");
  98. }
  99. $this->tpl->assign("groupid",$groupid);
  100. $grouplist = $this->usergroup_m->get_all();
  101. $this->tpl->assign("grouplist",$grouplist);
  102. $this->tpl->display("user/set.html");
  103. }
  104. function chk_f()
  105. {
  106. $id = $this->trans_lib->int("id");
  107. $phone = $this->trans_lib->safe("phone");
  108. if(!$phone)
  109. {
  110. exit("error: 电话不允许为空");
  111. }
  112. $rs_phone = $this->user_m->chk_phone($phone,$id);
  113. if($rs_phone)
  114. {
  115. exit("error:会员账号已经存在");
  116. }
  117. exit("ok");
  118. }
  119. //存储信息
  120. function setok_f()
  121. {
  122. $id = $this->trans_lib->int("id");
  123. if($id)
  124. {
  125. sys_popedom("user:modify","tpl");
  126. }
  127. else
  128. {
  129. sys_popedom("user:add","tpl");
  130. }
  131. $array = array();
  132. $array["username"] = $this->trans_lib->safe("username");
  133. $pass = $this->trans_lib->safe("pass");
  134. if($pass)
  135. {
  136. $array["pass"] = sys_md5($pass);
  137. }
  138. else
  139. {
  140. if(!$id)
  141. {
  142. $array["pass"] = sys_md5("123456");
  143. }
  144. }
  145. $array["phone"] = $this->trans_lib->safe("phone");//模板目录
  146. $array["job"] = $this->trans_lib->safe("job");//模板目录
  147. $array["company"] = $this->trans_lib->safe("company");//模板目录
  148. $regdate = $this->trans_lib->safe("regdate");
  149. $array["regdate"] = $regdate ? strtotime($regdate) : $this->system_time;
  150. $array["thumb_id"] = $this->trans_lib->int("thumb_id");//存储图像
  151. $array["groupid"] = $this->trans_lib->int("groupid");//存储会员组
  152. $array["fxstatus"] = $this->trans_lib->int("fxstatus");//存储会员组
  153. $array["bankAccount"] = $this->trans_lib->safe("bankAccount");//存储会员组
  154. $array["cardCode"] = $this->trans_lib->safe("cardCode");//存储会员组
  155. $array["bankName"] = $this->trans_lib->safe("bankName");//存储会员组
  156. //存储扩展表信息
  157. $insert_id = $this->user_m->save($array,$id);
  158. error("会员信息添加/存储成功",site_url("user"));
  159. }
  160. function ajax_status_f()
  161. {
  162. $id = $this->trans_lib->int("id");
  163. if(!$id)
  164. {
  165. exit("error:没有指定ID");
  166. }
  167. sys_popedom("user:check","ajax");
  168. $rs = $this->user_m->get_one($id);
  169. $status = $rs["status"] ? 0 : 1;
  170. $this->user_m->set_status($id,$status);
  171. exit("ok");
  172. }
  173. function ajax_del_f()
  174. {
  175. $id = $this->trans_lib->int("id");
  176. if(!$id)
  177. {
  178. exit("error:没有指定ID");
  179. }
  180. sys_popedom("user:delete","ajax");
  181. $this->user_m->del($id);
  182. exit("ok");
  183. }
  184. function view_f()
  185. {
  186. $id = $this->trans_lib->int("id");
  187. if(!$id)
  188. {
  189. error("error: 操作错误");
  190. }
  191. $rs = $this->user_m->get_one($id);
  192. $this->tpl->assign("rs",$rs);
  193. $this->tpl->display("user/view.html");
  194. }
  195. function pl_status_f()
  196. {
  197. sys_popedom("user:check","ajax");
  198. $id = $this->trans_lib->safe("id");
  199. $status = $this->trans_lib->int("status");
  200. $this->user_m->status($id,$status);
  201. exit("ok");
  202. }
  203. function del_f()
  204. {
  205. sys_popedom("user:delete","ajax");
  206. $id = $this->trans_lib->safe("id");
  207. if(!$id)
  208. {
  209. exit("操作错误,没有指定ID!");
  210. }
  211. $this->user_m->del($id);
  212. exit("ok");
  213. }
  214. function pl_del_f()
  215. {
  216. sys_popedom("user:delete","ajax");
  217. $id = $this->trans_lib->safe("id");
  218. if(!$id)
  219. {
  220. exit("操作错误,没有指定ID!");
  221. }
  222. $this->user_m->pl_del($id);
  223. exit("ok");
  224. }
  225. }
  226. ?>