/** * 用户注册 */ public function register() { $req = req()->_plain(); if ($req->is_post()) { lib()->load('UserRegister', 'User'); $ur = new UserRegister(); $this->rt_msg['code'] = $ur->Register($req->post('email'), $req->post('password'), $req->post('name'), $req->post('captcha')); if ($this->rt_msg['code'] <= 0) { $this->rt_msg['msg'] = $ur->CodeMsg($this->rt_msg['code']); } else { $this->rt_msg['status'] = true; $user = new User($this->rt_msg['code']); $this->rt_msg['content'] = $user->getInfo(); } } else { $this->rt_msg['msg'] = '必须以POST方式提交'; } }
public function user_add() { $req = req()->_plain(); if ($req->is_post()) { lib()->load("UserRegister", "UserCheck"); try { $ur = new UserRegister(); hook()->add('UserRegister_Captcha', function () { //通过钩子去掉用户注册验证码 return true; }); $id = $ur->Register($req->post('email'), UserCheck::MakeHashChar($req->post('password')), $req->post('name'), "ADMIN"); if ($id > 0) { $this->rt_msg['status'] = true; $this->rt_msg['content'] = $id; } else { $this->rt_msg['msg'] = $ur->CodeMsg($id); } } catch (\Exception $ex) { $this->rt_msg['msg'] = $ex->getMessage(); } } else { $this->rt_msg['msg'] = "必须以POST方式提交数据"; } }