public function ajaxSubmitAction() { $setId = Request::getPOST('set-id'); $title = trim(Request::getPOST('title')); $refreshAt = strtotime(trim(Request::getPOST('refresh-at'))); if (empty($setId)) { $this->renderError('参数错误!'); } if (empty($title) || mb_strlen($title, 'utf8') > 50) { $this->renderError('标题必填,限制50个字以内!'); } $currentDay = intval(time() / 86400) * 86400 + 86400; if (empty($refreshAt) || $refreshAt > $currentDay) { $this->renderError('刷新时间不能超过今天!'); } $setInfo = OjProblemSetInterface::getById(array('id' => $setId)); if (empty($setInfo)) { $this->renderError('专题不存在!'); } // 属主验证 if ($setInfo['user_id'] != $this->loginUserInfo['id']) { $this->renderError('你没有修改权限!'); } $data = array('id' => $setId, 'title' => $title, 'refresh_at' => $refreshAt); OjProblemSetInterface::save($data); $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '修改成功!'); $this->renderAjax(0); }
public function ajaxSubmitAction() { // 获取参数 $globalId = Request::getPOST('global-id'); $language = Request::getPOST('language'); $code = Request::getPOST('code', '', true); // 校验 if (strlen($code) < 50 || strlen($code) > 65535) { $this->renderError('代码长度超出范围,请限制为50-65535(BYTE)!'); } $problemInfo = OjProblemInterface::getById(array('id' => $globalId)); if (empty($problemInfo)) { $this->renderError('题目不存在!'); } if (!array_key_exists($language, StatusVars::$LANGUAGE_SUPPORT[$problemInfo['remote']])) { $this->renderError('编译器不支持!'); } // 非法字符判断 if ($problemInfo['remote'] == StatusVars::REMOTE_HDU) { if (false === iconv('UTF-8', 'GBK', $code)) { $this->renderError('代码中存在非法字符!'); } } OjJudgeInterface::save(array('problem_id' => $problemInfo['problem_id'], 'language' => $language, 'source' => $code, 'user_id' => $this->loginUserInfo['id'])); // judge $this->renderAjax(0); }
public function ajaxChangeStatusAction() { $applyId = Request::getPOST('apply-id'); $op = Request::getPOST('op'); if (!in_array($op, array(1, 2)) || empty($applyId)) { $this->renderError('参数错误!'); } $applyInfo = OjContestApplyInterface::getById(array('id' => $applyId)); if (empty($applyInfo)) { $this->renderError('报名信息不存在!'); } // 只能处理自己竞赛下的报名 $where = array(array('user_id', '=', $this->loginUserInfo['id']), array('is_diy', '=', 1)); $contestHash = OjContestInterface::getList(array('where' => $where)); $contestHash = Arr::listToHash('id', $contestHash); $contestIds = array_keys($contestHash); if (!in_array($applyInfo['contest_id'], $contestIds)) { $this->renderError('你没有权限操作!'); } if ($op == 1 && $applyInfo['status'] == ContestVars::APPLY_ACCEPTED || $op == 2 && $applyInfo['status'] == ContestVars::APPLY_REJECTED) { $msg = $op == 1 ? '已经通过!' : '已经拒绝!'; $this->renderError($msg); } if ($op == 1) { OjContestApplyInterface::accept(array('id' => $applyId)); } else { OjContestApplyInterface::reject(array('id' => $applyId)); } $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '操作成功!'); $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 function ajaxApplyAction() { if (empty($this->loginUserInfo)) { $this->renderError('请登录!'); } $contestId = (int) Request::getPOST('contest-id'); $realName = trim(Request::getPOST('real-name')); $xuehao = trim(Request::getPOST('xuehao')); $xueyuan = (int) Request::getPOST('xueyuan'); $sex = (int) Request::getPOST('sex'); // 校验 if (empty($realName) || empty($xuehao) || empty($xueyuan) || empty($sex) || !array_key_exists($xueyuan, ContestVars::$XUEYUAN) || !in_array($sex, array(1, 2)) || mb_strlen($realName, 'utf8') < 2 || mb_strlen($realName, 'utf8') > 4) { $this->renderError('参数错误!'); } $contestInfo = OjContestInterface::getById(array('id' => $contestId)); if (empty($contestInfo)) { $this->renderError('比赛不存在!'); } if ($contestInfo['type'] != ContestVars::TYPE_APPLY) { $this->renderError('比赛不需要报名!'); } if ($contestInfo['end_time'] < time()) { $this->renderError('比赛已经结束!'); } $applyInfo = OjContestApplyInterface::getDetail(array('contest_id' => $contestId, 'user_id' => $this->loginUserInfo['id'])); if (!empty($applyInfo) && $applyInfo['status'] == ContestVars::APPLY_ACCEPTED) { $this->renderError('报名已通过,无法修改!'); } $data = array('contest_id' => $contestId, 'user_id' => $this->loginUserInfo['id'], 'real_name' => $realName, 'xuehao' => $xuehao, 'xueyuan' => $xueyuan, 'sex' => $sex); OjContestApplyInterface::save($data); $this->renderAjax(0); }
public function ajaxAddProblemAction() { $problemJson = Request::getPOST('problem-json'); $problemList = json_decode($problemJson); if (empty($problemList)) { $this->renderError('参数错误2!'); } $dataList = array(); foreach ($problemList as $problemInfo) { $problemInfo = (array) $problemInfo; // 如果title为空,那么不插入 if (empty($problemInfo['problem_id']) || empty($problemInfo['problem_code']) || empty($problemInfo['title'])) { continue; } $data = array(); $data['remote'] = $problemInfo['remote']; $data['problem_id'] = $problemInfo['problem_id']; $data['problem_code'] = $problemInfo['problem_code']; $data['title'] = $problemInfo['title']; $data['source'] = $problemInfo['source']; $data['user_id'] = $this->loginUserInfo['id']; $data['hidden'] = empty($data['title']) ? 1 : 0; $dataList[] = $data; } OjProblemInterface::insertAll($dataList); $this->renderAjax(0); }
public function ajaxSubmitAction() { // 获取参数 $language = (int) Request::getPOST('language'); $code = Request::getPOST('code', '', true); $problemHash = Request::getPOST('problem-hash'); $userId = $this->loginUserInfo['id']; $globalId = array_search($problemHash, $this->contestInfo['problem_hash']); if (empty($globalId)) { $this->renderError('竞赛中无此题!'); } // 校验 if (strlen($code) < 50 || strlen($code) > 65535) { $this->renderError('代码长度超出范围,请限制为50-65535(BYTE)!'); } $problemInfo = OjProblemInterface::getById(array('id' => $globalId)); if (empty($problemInfo) || $problemInfo['hidden']) { $this->renderError('题目不存在!'); } if (!array_key_exists($language, StatusVars::$LANGUAGE_SUPPORT[$problemInfo['remote']])) { $this->renderError('编译器不支持!'); } if (OjSolutionInterface::submitAlready(array('user_id' => $userId))) { $this->renderError('提交频繁!'); } // 非法字符判断 if ($problemInfo['remote'] == StatusVars::REMOTE_HDU) { if (false === iconv('UTF-8', 'GBK', $code)) { $this->renderError('代码中存在非法字符!'); } } OjSolutionInterface::save(array('global_id' => $globalId, 'user_id' => $userId, 'language' => $language, 'source' => $code, 'contest_id' => $this->contestInfo['id'])); $this->renderAjax(0); }
public function ajaxDeleteAction() { $path = Request::getPOST('path', ''); if (empty($path)) { $this->renderAjax(1, '参数错误!'); } RootRelationInterface::deleteByPath(array('path' => $path)); $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '操作成功!'); $this->renderAjax(0); }
public function ajaxSubmitAction() { $id = Request::getPOST('permission-id'); $description = trim(Request::getPOST('description')); if (empty($id) || empty($description)) { $this->renderAjax(1, '参数不能为空!'); } RootPermissionInterface::save(array('id' => $id, 'description' => $description)); $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '修改成功!'); $this->renderAjax(0); }
public function ajaxSubmitAction() { // 获取参数 $contestId = (int) Request::getPOST('contest-id'); $title = trim(Request::getPOST('title')); $type = Request::getPOST('type'); $password = trim(Request::getPOST('password')); $notice = trim(Request::getPOST('notice')); $beginTime = strtotime(trim(Request::getPOST('begin-time'))); $endTime = strtotime(trim(Request::getPOST('end-time'))); $description = Request::getPOST('description', '', true); $problemHidden = Request::getPOST('problem-hidden', 0); // 参数校验1 if (empty($title) || mb_strlen($title, 'utf8') > 50) { $this->renderError('标题必填,限制50个字以内!'); } if (mb_strlen($notice, 'utf8') > 100) { $this->renderError('提示限制100个字以内!'); } if (!preg_match('/^[A-Za-z0-9_]{0,20}$/', $password)) { $this->renderError('密码格式不合法!'); } if ($type == ContestVars::TYPE_PASSWORD && empty($password)) { $this->renderError('密码不能为空!'); } if (empty($type) || !array_key_exists($type, ContestVars::$TYPE_FORMAT)) { $this->renderError('请选择比赛访问权限!'); } // 竞赛是否存在 $contestInfo = OjContestInterface::getById(array('id' => $contestId)); if (empty($contestInfo)) { $this->renderError('竞赛不存在!'); } // 权限 if ($contestInfo['user_id'] != $this->loginUserInfo['id']) { $this->renderError('你没有权限操作!'); } // 参数校验2 if ($contestInfo['is_active']) { $beginTime = $contestInfo['begin_time']; } if (empty($beginTime) || empty($endTime) || $beginTime >= $endTime) { $this->renderError('比赛时间不合法!'); } // 时间不能超过1年 if ($endTime - $beginTime > 366 * 86400) { $this->renderError('比赛时间不能超过1年!'); } $data = array('id' => $contestId, 'title' => $title, 'type' => $type, 'password' => $password, 'notice' => $notice, 'begin_time' => $beginTime, 'end_time' => $endTime, 'description' => $description, 'problem_hidden' => $problemHidden ? 1 : 0); OjContestInterface::save($data); $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '操作成功!'); $this->renderAjax(0); }
public function ajaxRejudgeAction() { // 获取参数 $judgeId = Request::getPOST('judge-id'); // 只能重判自己的solution $judgeInfo = OjJudgeInterface::getById(array('id' => $judgeId)); if (empty($judgeInfo)) { $this->renderError('judgeInfo不存在!'); } // rejudge OjJudgeInterface::rejudge(array('id' => $judgeId)); $this->renderAjax(0); }
public function ajaxStickCancelAction() { $setId = Request::getPOST('set-id'); $setInfo = OjProblemSetInterface::getById(array('id' => $setId)); if (empty($setInfo)) { $this->renderError('专题不存在!'); } if (!$setInfo['listing_status']) { $this->renderError('已取消置顶!'); } OjProblemSetInterface::cancelStick(array('id' => $setId)); $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '操作成功!'); $this->renderAjax(0); }
public function ajaxHideAction() { $docId = (int) Request::getPOST('doc-id'); $docInfo = DocInterface::getById(array('id' => $docId)); if (empty($docInfo)) { $this->renderError('文章不存在!'); } if ($docInfo['hidden']) { $this->renderError('文章已经隐藏!'); } DocInterface::hide(array('id' => $docId)); $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '操作成功'); $this->renderAjax(0); }
public function ajaxHideAction() { $contestId = Request::getPOST('contest-id'); $contestInfo = OjContestInterface::getById(array('id' => $contestId)); if (empty($contestInfo)) { $this->renderError('竞赛不存在!'); } if ($contestInfo['hidden']) { $this->renderError('竞赛已经隐藏!'); } OjContestInterface::hide(array('id' => $contestId)); $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '隐藏成功!'); $this->renderAjax(0); }
public function ajaxRejudgeAction() { // 获取参数 $solutionId = (int) Request::getPOST('solution-id'); $solutionInfo = OjSolutionInterface::getById(array('id' => $solutionId)); if (empty($solutionInfo)) { $this->renderError('Solution不存在!'); } // 竞赛管理员才可以重判,或者timeout if (!$this->isContestAdmin && $solutionInfo['result'] != StatusVars::TIME_OUT) { $this->renderError('你没有权限重判!'); } // 重判 OjSolutionInterface::rejudge(array('id' => $solutionId)); $this->renderAjax(0); }
public function ajaxRemoveProblemAction() { $contestId = (int) Request::getPOST('contest-id'); $globalId = (int) Request::getPOST('global-id'); $problemInfo = OjProblemInterface::getById(array('id' => $globalId)); if (empty($problemInfo)) { $this->renderError('题目不存在!'); } $contestInfo = OjContestInterface::getById(array('id' => $contestId)); if (empty($contestInfo)) { $this->renderError('竞赛不存在!'); } // 更新数据 OjContestInterface::removeProblem(array('id' => $contestId, 'global_id' => $globalId)); $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '移除成功!'); $this->renderAjax(0); }
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 ajaxDeleteAction() { $ids = Request::getPOST('ids'); // 过滤 $ids = json_decode($ids, true); foreach ($ids as $i => $id) { if (!is_numeric($id) || $id <= 0) { unset($ids[$i]); continue; } } // 校验 if (empty($ids)) { $this->renderAjax(1, '参数错误!'); } RootPermissionInterface::deleteMultiByIds(array('ids' => $ids)); $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '删除成功!'); $this->renderAjax(0); }
public function ajaxRemoveProblemAction() { $setId = (int) Request::getPOST('set-id'); $globalId = (int) Request::getPOST('global-id'); if (empty($setId) || empty($globalId)) { $this->renderError('参数错误!'); } $setInfo = OjProblemSetInterface::getById(array('id' => $setId)); if (empty($setInfo)) { $this->renderError('专题不存在!'); } // 属主验证 if ($this->loginUserInfo['id'] != $setInfo['user_id']) { $this->renderError('你没有权限操作!'); } OjProblemSetInterface::removeProblem(array('id' => $setId, 'global_id' => $globalId)); $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '操作成功'); $this->renderAjax(0); }
public function ajaxSubmitAction() { // 获取参数 $globalId = (int) Request::getPOST('global-id'); $title = trim(Request::getPOST('title')); $source = trim(Request::getPOST('source')); $timeLimit = max(1, Request::getPOST('time-limit')); $memoryLimit = max(32, Request::getPOST('memory-limit')); $description = Request::getPOST('description', '', true); $input = Request::getPOST('input', '', true); $output = Request::getPOST('output', '', true); $sampleInput = Request::getPOST('sample-input', '', true); $sampleOutput = Request::getPOST('sample-output', '', true); $hint = Request::getPOST('hint', '', true); if (!in_array($timeLimit, StatusVars::$TIME_LIMIT) || !in_array($memoryLimit, StatusVars::$MEMORY_LIMIT)) { $this->renderError('参数错误!'); } // 校验 if (mb_strlen($title, 'utf8') > 50) { $this->renderError('标题限制50个字以内!'); } if (mb_strlen($source, 'utf8') > 50) { $this->renderError('来源限制50个字以内!'); } // 校验problem $problemInfo = OjProblemInterface::getById(array('id' => $globalId)); if (empty($problemInfo) || !$problemInfo['hidden'] || $problemInfo['user_id'] != $this->loginUserInfo['id']) { $this->renderError('你没有操作权限!'); } // 更新 $data = array('id' => $globalId, 'title' => $title, 'source' => str_replace(',', ',', $source), 'time_limit' => $timeLimit * 1000, 'memory_limit' => $memoryLimit * 1024, 'description' => $description, 'input' => $input, 'output' => $output, 'sample_input' => $sampleInput, 'sample_output' => $sampleOutput, 'hint' => $hint); OjProblemInterface::save($data); // 记录编辑历史 if ($problemInfo['remote'] == StatusVars::REMOTE_HQU) { $dateTime = date('Y-m-d H:i:s', time()); $history = "<p>{$dateTime} 用户{$this->loginUserInfo['username']}编辑了题目</p>"; OjProblemInterface::auditHistory(array('problem_id' => $problemInfo['problem_id'], 'append_history' => $history)); } $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '编辑成功!'); $this->renderAjax(0); }
public function ajaxSubmitAction() { $code = trim(Request::getPOST('code')); $description = trim(Request::getPOST('description')); // 校验 if (empty($code) || empty($description)) { $this->renderAjax(1, '参数不能为空!'); } $ret = RootPermissionInterface::isValidCode(array('code' => $code)); if (false === $ret) { $this->renderAjax(1, '权限码不合法!'); } $ret = RootPermissionInterface::testMakeCode(array('code' => $code)); if (false === $ret) { $this->renderAjax(1, '权限已经存在,无法创建权限!'); } // 保存 RootPermissionInterface::save(array('description' => $description, 'code' => $code)); $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '添加成功!'); $this->renderAjax(0); }
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 ajaxRemoveAction() { $managerId = Request::getPOST('manager-id', 0); $path = Request::getPOST('path', ''); if (empty($managerId) || empty($path)) { $this->renderAjax(1, '参数错误!'); } if (!RootPermissionInterface::isValidPath(array('path' => $path))) { $this->renderAjax(1, '路径不合法!'); } // 路径不存在 $where = array(array('manager_id', '=', $managerId), array('path', '=', $path)); $rowInfo = RootRelationInterface::getRow(array('where' => $where)); if (empty($rowInfo)) { $this->renderAjax(1, '管理员权限路径不存在!'); } // 删除 RootRelationInterface::deleteById(array('id' => $rowInfo['id'])); $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '移除权限成功!'); $this->renderAjax(0); }
public function ajaxRejudgeAction() { // 获取参数 $judgeId = Request::getPOST('judge-id'); // 只能重判自己的solution $judgeInfo = OjJudgeInterface::getById(array('id' => $judgeId)); if (empty($judgeInfo)) { $this->renderError('judgeInfo不存在!'); } if ($judgeInfo['solution_id'] > 0 || $judgeInfo['user_id'] != $this->loginUserInfo['id']) { $this->renderError('你没有权限重判!'); } // 获取题目 $problemInfo = OjProblemInterface::getDetail(array('remote' => StatusVars::REMOTE_HQU, 'problem_id' => $judgeInfo['problem_id'])); if ($problemInfo['user_id'] != $this->loginUserInfo['id']) { $this->renderError('你没有权限重判他人的题目!'); } // rejudge OjJudgeInterface::rejudge(array('id' => $judgeId)); $this->renderAjax(0); }
public function ajaxAddAction() { $loginName = Request::getPOST('login-name'); if (empty($loginName)) { $this->renderAjax(1, '请填写登录名!'); } // 校验一个用户 $userInfo = UserCommonInterface::getByLoginName(array('login_name' => $loginName)); if (empty($userInfo)) { $this->renderAjax(1, "用户 {$loginName} 不存在!"); } // 是否已经添加 $managerInfo = RootManagerInterface::getByField(array('user_id' => $userInfo['id'])); if (!empty($managerInfo)) { $this->renderAjax(1, "用户 {$loginName} 已经是管理员!"); } // 添加用户到管理员 RootManagerInterface::save(array('login_name' => $loginName)); $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '添加成功!'); $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); }
public function ajaxHideAction() { // 获取参数 $setId = Request::getPOST('set-id'); if (empty($setId)) { $this->renderError('参数错误!'); } $setInfo = OjProblemSetInterface::getById(array('id' => $setId)); if (empty($setInfo)) { $this->renderError('专题不存在!'); } // 属主验证 if ($this->loginUserInfo['id'] != $setInfo['user_id']) { $this->renderError('你没有权限操作!'); } if ($setInfo['hidden']) { $this->renderError('已经隐藏!'); } // 更新数据 OjProblemSetInterface::hide(array('id' => $setId)); $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '操作成功!'); $this->renderAjax(0); }
public function ajaxChangeStatusAction() { $applyId = Request::getPOST('apply-id'); $op = Request::getPOST('op'); if (!in_array($op, array(1, 2)) || empty($applyId)) { $this->renderError('参数错误!'); } $applyInfo = OjContestApplyInterface::getById(array('id' => $applyId)); if (empty($applyInfo)) { $this->renderError('报名信息不存在!'); } if ($op == 1 && $applyInfo['status'] == ContestVars::APPLY_ACCEPTED || $op == 2 && $applyInfo['status'] == ContestVars::APPLY_REJECTED) { $msg = $op == 1 ? '已经通过!' : '已经拒绝!'; $this->renderError($msg); } if ($op == 1) { OjContestApplyInterface::accept(array('id' => $applyId)); } else { OjContestApplyInterface::reject(array('id' => $applyId)); } $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '操作成功!'); $this->renderAjax(0); }
public function ajaxSubmitAction() { $email = Request::getPOST('email'); $checkCode = Request::getPOST('check-code'); $verify = Request::getPOST('verify'); if (empty($email) || empty($verify) || empty($checkCode)) { $this->renderAjax(1, '请填写信息!'); } // 校验验证码 $imgCode = Session::get('check_code'); if (strtolower($verify) != $imgCode) { $this->renderAjax(2, '图片验证码错误!'); } $check = UcAuthInterface::checkEmailCode(array('email' => $email, 'code' => $checkCode)); if (false === $check) { $this->renderAjax(1, '邮箱验证码错误!'); } // 删除email code UcAuthInterface::deleteEmailCode(array('email' => $email)); // reset ticket $resetTicket = UcAuthInterface::makeResetTicket(array('login_name' => $email)); $this->renderAjax(0, 'Success', array('resetTicket' => $resetTicket)); }