register.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. class register_c extends Control
  3. {
  4. function __construct()
  5. {
  6. parent::Control();
  7. $this->load_model("user");
  8. }
  9. function register_c()
  10. {
  11. $this->__construct();
  12. }
  13. function index_f()
  14. {
  15. if($_SESSION["oauthuser_info"])
  16. {
  17. $oauthuser_info=$_SESSION["oauthuser_info"];
  18. if(!$this->sys_config["reg_status"])
  19. {
  20. $message = $this->sys_config["close_reg"] ? $this->sys_config["close_reg"] : "No register!";
  21. error($message,$this->url());
  22. }
  23. if($_SESSION["user_id"])
  24. {
  25. error('',$this->url('index'));
  26. }
  27. //print_r($this->url('login'));
  28. $sitetitle = $this->lang["register"];
  29. $this->tpl->assign("oauthuserName",$oauthuser_info->nickname);
  30. $this->tpl->assign("regdfPwd","2015123");
  31. $this->tpl->assign("sitetitle",$sitetitle);
  32. $array[0]["title"] = $this->lang["register"];
  33. $this->tpl->assign("leader",$array);
  34. $this->tpl->display("register.".$this->tpl->ext);
  35. }else{
  36. error('',$this->url('home'));
  37. }
  38. }
  39. //存储个人信息
  40. function setok_f()
  41. {
  42. if(!$this->sys_config["reg_status"])
  43. {
  44. $message = $this->sys_config["close_reg"] ? $this->sys_config["close_reg"] : "No register!";
  45. echo $message;
  46. exit;
  47. }
  48. if($_SESSION["user_id"])
  49. {
  50. error('',$this->url('home'));
  51. }
  52. $myRecommendUID=$_SESSION["Recommend_UID"];//$this->trans_lib->safe("ruid");
  53. $myRecommendName="";
  54. if(!$myRecommendUID)
  55. {
  56. $myRecommendUID=0;
  57. }else if($myRecommendUID>0){
  58. $myRecommend=$this->user_m->user_from_id_one($myRecommendUID);
  59. if($myRecommend){
  60. $myRecommendName=$myRecommend["username"];
  61. }
  62. }
  63. //echo "1*".$myRecommendUID."*".$myRecommendName."*";
  64. //exit;
  65. $oauthuser_info=false;
  66. if($_SESSION["oauthuser_info"])
  67. {
  68. $oauthuser_info=$_SESSION["oauthuser_info"];
  69. }else{
  70. echo "微信授权失败";
  71. exit;
  72. }
  73. $array = array();
  74. $array["username"] = $this->trans_lib->safe("name");
  75. $array["phone"] = $this->trans_lib->safe("phone");
  76. $newpass = $this->trans_lib->safe("password");
  77. $array["job"] = $this->trans_lib->safe("job");
  78. $array["company"] = $this->trans_lib->safe("company");
  79. if($myRecommend){
  80. $array["Recommend"] = $myRecommendUID;
  81. $array["RecommendName"] = $myRecommendName;
  82. }
  83. $array["wxopenid"] = $oauthuser_info->openid;
  84. $array["wxthumb"] = $oauthuser_info->headimgurl;
  85. if(!$newpass)
  86. {
  87. echo $this->lang["empty_pass"];
  88. exit;
  89. }
  90. $array["pass"] = sys_md5($newpass);
  91. $checkphone = $this->checkphone($array["phone"]);
  92. if($checkphone != "0")
  93. {
  94. echo $chkname;
  95. exit;
  96. }
  97. $array["regdate"] = $this->system_time;
  98. $array["status"] = 1;
  99. //会员组
  100. $this->load_model("usergroup");
  101. $group_rs = $this->usergroup_m->get_default();
  102. $array["groupid"] = $group_rs["id"];
  103. $user_id = $this->user_m->save($array);
  104. //会员注册成功,模拟登录
  105. $_SESSION["user_id"] = $user_id;
  106. $_SESSION["user_name"] = $array["username"];
  107. $_SESSION["group_id"] = $array["groupid"];
  108. $tmp_array = $array;
  109. $tmp_array["id"] = $user_id;
  110. $_SESSION["user_rs"] = $tmp_array;
  111. //发送欢迎信息
  112. if($this->sys_config["smtp_reg"])
  113. {
  114. $this->load_lib("email");
  115. $this->email_lib->regInform($user_id);
  116. }
  117. echo "1";
  118. exit;
  119. }
  120. //检测手机号是否存在
  121. function checkphone_f()
  122. {
  123. $phone = $this->trans_lib->safe("phone");
  124. exit($this->checkphone($phone));
  125. }
  126. function checkphone($phone)
  127. {
  128. if(!$phone)
  129. {
  130. return "1";
  131. }
  132. $rs = $this->user_m->user_from_phone($phone);
  133. if($rs)
  134. {
  135. return "1";
  136. }
  137. else
  138. {
  139. return "0";
  140. }
  141. }
  142. }
  143. ?>