public function ajaxUpdatePasswordAction() { // 获取参数 $oldPassword = Request::getPOST('old-password'); $password = trim(Request::getPOST('password')); if (!Regex::match($password, RegexVars::PASSWORD)) { $this->renderError('新密码限制为6-20位!'); } $encryptPassword = UserCommonInterface::encryptPassword(array('password' => $oldPassword)); if ($encryptPassword != $this->loginUserInfo['password']) { $this->renderError('旧密码不正确!'); } $data = array('id' => $this->loginUserInfo['id'], 'password' => $password); UserCommonInterface::save($data); UserCommonInterface::logout(); $this->renderAjax(0); }
public function ajaxSubmitAction() { $sex = Request::getPOST('sex'); $share = Request::getPOST('share'); $motto = trim(Request::getPOST('motto')); $nickname = trim(Request::getPOST('nickname')); if (empty($nickname)) { $this->renderError('昵称不能为空!'); } if (!in_array($share, array(0, 1)) || !in_array($sex, array(1, 2))) { $this->renderError('请填写信息!'); } if (mb_strlen($motto, 'utf8') > 100) { $this->renderError('签名不能超过100个字!'); } if (mb_strlen($nickname, 'utf8') > 16) { $this->renderError('昵称长度16个字符以内!'); } $data = array('id' => $this->loginUserInfo['id'], 'nickname' => $nickname, 'motto' => $motto, 'sex' => $sex, 'share' => $share); UserCommonInterface::save($data); $this->renderAjax(0); }
public function ajaxSubmitAction() { $email = Request::getPOST('email'); $checkCode = Request::getPOST('check-code'); if (empty($email) || empty($checkCode)) { $this->renderError('请填写信息!'); } // 是否已经被绑定 $userInfo = UserCommonInterface::getByLoginName(array('login_name' => $email)); if (!empty($userInfo)) { $this->renderError('该邮箱已经被绑定!'); } $check = AuthCommonInterface::checkEmailCode(array('email' => $email, 'code' => $checkCode)); if (false === $check) { $this->renderError('邮箱验证码错误!'); } // 删除email code AuthCommonInterface::deleteEmailCode(array('email' => $email)); // 修改用户 UserCommonInterface::save(array('id' => $this->loginUserInfo['id'], 'email' => $email)); $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '绑定邮箱成功!'); $this->renderAjax(0); }
private static function updateResult($id, $result, $trans = null) { $solutionInfo = self::getById($id); if (empty($solutionInfo)) { throw new InterfaceException('solution不存在!'); } $innerTrans = $trans; if (null == $trans) { $innerTrans = new Trans(DbConfig::$SERVER_TRANS); $innerTrans->begin(); } $solutionModel = new OjSolutionModel($innerTrans); $remote = $solutionInfo['remote']; $globalId = $solutionInfo['problem_global_id']; $userId = $solutionInfo['user_id']; $contestId = $solutionInfo['contest_id']; // 如果状态从 非AC -> AC,那么修改user表和problem表,竞赛状态下不改变 if (0 == $contestId && $result == StatusVars::ACCEPTED && $solutionInfo['result'] != StatusVars::ACCEPTED) { // 判断是否没有AC过 $where = array(array('problem_global_id', '=', $globalId), array('user_id', '=', $userId), array('result', '=', StatusVars::ACCEPTED), array('contest_id', '=', 0)); $count = self::getCount($where); if (0 == $count) { $userInfo = UserCommonInterface::getById(array('id' => $userId)); $problemInfo = OjProblemInterface::getById(array('id' => $globalId)); $remoteStr = strtolower(StatusVars::$REMOTE_SCHOOL[$remote]); UserCommonInterface::save(array('trans' => $innerTrans, 'id' => $userId, 'solved_all' => $userInfo['solved_all'] + 1, "solved_{$remoteStr}" => $userInfo["solved_{$remoteStr}"] + 1)); OjProblemInterface::save(array('trans' => $innerTrans, 'id' => $globalId, 'solved' => $problemInfo['solved'] + 1)); } } // 如果状态从 AC -> 非AC,那么修改user表和problem表,竞赛状态下不改变 if (0 == $contestId && $result != StatusVars::ACCEPTED && $solutionInfo['result'] == StatusVars::ACCEPTED) { // 判断是否只AC过一次 $where = array(array('problem_global_id', '=', $globalId), array('user_id', '=', $userId), array('result', '=', StatusVars::ACCEPTED), array('contest_id', '=', 0)); $count = self::getCount($where); if (1 == $count) { $userInfo = UserCommonInterface::getById(array('id' => $userId)); $problemInfo = OjProblemInterface::getById(array('id' => $globalId)); $remoteStr = strtolower(StatusVars::$REMOTE_SCHOOL[$remote]); UserCommonInterface::save(array('trans' => $innerTrans, 'id' => $userId, 'solved_all' => $userInfo['solved_all'] - 1, "solved_{$remoteStr}" => $userInfo["solved_{$remoteStr}"] - 1)); OjProblemInterface::save(array('trans' => $innerTrans, 'id' => $globalId, 'solved' => $problemInfo['solved'] - 1)); } } // 更新solution $affects = $solutionModel->updateById($id, array('result' => $result)); if (null == $trans && null != $innerTrans) { // 没有外部事务,并且存在内部事务 $innerTrans->commit(); } return $affects; }