public function ajaxSendEmailAction() { $email = Request::getPOST('email'); $verify = Request::getPOST('verify'); if (empty($verify)) { $this->renderAjax(1, '请输入图片验证码!'); } if (empty($email)) { $this->renderAjax(1, '请填写邮箱!'); } // 校验验证码 $imgCode = Session::get('check_code'); if (strtolower($verify) != $imgCode) { $this->renderAjax(2, '图片验证码错误!'); } if (!Regex::match($email, RegexVars::EMAIL)) { $this->renderAjax(1, '邮箱格式错误!'); } // 是否存在 $userInfo = UcUserInterface::getByLoginName(array('login_name' => $email)); if (empty($userInfo)) { $this->renderAjax(1, '用户邮箱不存在!'); } $code = UcAuthInterface::sendEmailCode(array('email' => $email, 'repeat_at' => time() + 60)); if (false === $code) { $this->renderAjax(1, '服务器繁忙,请1分钟后重试!'); } $this->renderAjax(0); }
public function ajaxSubmitAction() { $username = Request::getPOST('username'); $password = Request::getPOST('password'); $verify = Request::getPOST('verify'); if (!Regex::match($username, RegexVars::USERNAME)) { $this->renderAjax(1, '用户名格式不正确!'); } // 校验密码格式 if (!Regex::match($password, RegexVars::PASSWORD)) { $this->renderAjax(1, '密码长度为6-20位!'); } // 校验验证码 $code = Session::get('check_code'); if (strtolower($verify) != $code) { $this->renderAjax(1, '验证码错误,请重试!'); } // 过滤用户名 if (false !== strpos(strtolower($username), 'admin')) { $this->renderAjax(1, '用户已经存在!'); } // 校验用户是否存在 $userInfo = UcUserInterface::getByLoginName(array('login_name' => $username)); if (!empty($userInfo)) { $this->renderAjax(1, '用户名已经被占用!'); } // 保存 $data = array('username' => $username, 'password' => $password, 'reg_ip' => Http::getClientIp()); UcUserInterface::save($data); $this->renderAjax(0); }
public static function getUserInfoByResetTicket($resetTicket) { $memcached = MemcachedPool::getMemcached(MemcachedConfig::$SERVER_COMMON); $key = MemcachedKeys::UC_RESET_TICKET_ . $resetTicket; $loginName = $memcached->get($key); if (false === $loginName) { return array(); } $userInfo = UcUserInterface::getByLoginName(array('login_name' => $loginName)); return $userInfo; }
public function ajaxLoginAction() { $loginName = Request::getPOST('login-name'); $password = Request::getPOST('password'); $backUrl = Request::getPOST('back-url', '//www.hqoj.net/'); if (empty($loginName) || empty($password)) { $this->renderAjax(1, '请填写信息!'); } $retInfo = UcUserInterface::login(array('login_name' => $loginName, 'password' => $password)); $ret = $retInfo['ret']; if ($ret === false) { $this->renderAjax(1, $retInfo['msg']); } $this->renderAjax(0, '登陆成功!', array('backUrl' => $backUrl)); }
public function ajaxSubmitAction() { $resetTicket = Request::getPOST('reset-ticket'); $password = Request::getPOST('password'); if (empty($password) || empty($resetTicket)) { $this->renderAjax(1, '参数错误!'); } if (strlen($password) < 6 || strlen($password) > 30) { $this->renderAjax(1, '密码长度为6-30位!'); } $userInfo = UcAuthInterface::getUserInfoByResetTicket(array('reset_ticket' => $resetTicket)); if (empty($userInfo)) { $this->renderAjax(1, '你的操作已经过期,请重新操作!'); } // 修改密码 UcUserInterface::save(array('id' => $userInfo['id'], 'password' => $password)); // 删除reset ticket UcAuthInterface::deleteResetTicket(array('reset_ticket' => $resetTicket)); UcUserInterface::logout(); $this->renderAjax(0); }
public function defaultAction() { $backUrl = Request::getGET('back-url', '//www.hqoj.net/'); UcUserInterface::logout(); Url::redirect($backUrl); }
public static function logout() { UcUserInterface::logout(); }