public function user_edit($id = 0) { try { $user = new User(0 + $id); $info = $user->getInfo(); $info['avatar'] = $user->getAvatarSql(); //修正头像选项 $this->__view("Control/user_edit.php", ["info" => $info]); } catch (\Exception $ex) { echo "<h3 class='text-danger'>用户信息加载失败:</h3><p>" . $ex->getMessage() . "</p>"; } }
/** * 用户注册 */ 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方式提交'; } }
/** * 登录限制 * @param null $rt * @param User $user * @return null */ public function message_login_restrictions($rt, $user) { try { if (!$this->notice($user->getId(), 'message', 'login_restrictions')) { return $rt; } $mt = new MailTemplate("message_notice/login_restrictions.md"); $mt->setUserInfo($user->getInfo()); c_lib()->load('input'); $input = new Input(); $mt->setValues(['login_ip' => $input->getRealIP(), 'login_ua' => $input->getUA(), 'login_count' => $user->getErrorLoginCount()]); $this->message->addNoticeMsg($mt->getTitle(), $mt->getContent(), $user->getId()); } catch (\Exception $ex) { Log::write(_("NoticeApply message_login_restrictions create a Exception.") . "EX:[" . $ex->getCode() . "]:" . $ex->getMessage(), Log::NOTICE); } return $rt; }
/** * 发送邮件给新的邮箱地址 * @param User $user * @param string $email * @param string $password * @throws \Exception */ public function edit_email_send_mail($user, $email, $password) { lib()->load('UserCheck', 'MailTemplate'); $email = strtolower(trim($email)); if ($user->getPassword() !== UserCheck::CreatePassword($password, $user->getSalt())) { $this->throwMsg(-10); } $email_check = UserCheck::CheckEmail($email); if ($email_check !== true) { throw new \Exception($email_check); } $meta = ['edit_email_add' => $email, 'edit_email_time' => date("Y-m-d H:i:s"), 'edit_email_code' => salt_hash($email . $user->getEmail(), salt())]; $user->getMeta()->set($meta); $mt = new MailTemplate("edit_email.html"); $mt->setUserInfo($user->getInfo()); $mt->setValues(['verify_code' => $meta['edit_email_code']]); $mt->mailSend($user->getName(), $email); }