public static function getLoginUser() { //获取OJ登录名 if (OJLoginInterface::isLogin()) { return session('uname'); } else { return null; } }
protected function logincheck() { //检测是否本系统已登录,并进行相应处理 if (\OJLoginInterface::isLogin()) { //OJ已登录 if (!(session('goldbirds_islogin') && session('goldbirds_oj') == \OJLoginInterface::getLoginUser())) { //OJ登录后首次访问本系统,加载登录信息到session $personDB = M('Person'); $condition['ojaccount'] = \OJLoginInterface::getLoginUser(); $user = $personDB->where($condition)->find(); //查询关联该OJ的用户信息 if ($user) { session('goldbirds_islogin', 1); session('goldbirds_uid', $user['uid']); session('goldbirds_group', $user['group']); session('goldbirds_oj', \OJLoginInterface::getLoginUser()); return 2; //OJ登录且关联用户 } else { session('goldbirds_islogin', null); session('goldbirds_uid', null); session('goldbirds_group', null); session('goldbirds_oj', null); return 1; //OJ登录但无关联用户 } } else { return 2; } } else { //OJ未登录或已登出,清空本系统session session('goldbirds_islogin', null); session('goldbirds_uid', null); session('goldbirds_group', null); session('goldbirds_oj', null); return 0; } }
public function ajax_save_regdata() { //提交注册信息 if ($this->logincheck() == 0) { $this->myajaxReturn(null, '[错误]请先登录OJ。', 5); } //未登录,非法操作 $aid = I('post.aid'); if ($aid <= 0) { $this->myajaxReturn(null, '[错误]无效的AID参数。', 1); } $activitylistDB = M('Activitylist'); $activity = $activitylistDB->where('aid = ' . $aid)->find(); //合法性检查 if (!$activity) { $this->myajaxReturn(null, '[错误]无效的AID参数。', 1); } if ($activity['isinner'] == 1 && $this->logincheck() != 2) { $this->myajaxReturn(null, '[错误]没有权限。', 6); } //内部活动,非法操作 if (time() > strtotime($activity['deadline'])) { $this->myajaxReturn(null, '[错误]报名时间已截止。', 2); } //时间已截止 $activitydataDB = M('Activitydata'); $regdata = $activitydataDB->where('aid = ' . $aid . ' AND ojaccount = "' . \OJLoginInterface::getLoginUser() . '"')->find(); if (!$regdata) { //注册 $postdata = I('post.regdata', false, ''); //传进的是数组 $datastr = ''; if (count($postdata) < 1) { $this->myajaxReturn(null, '[错误]无效的请求数据。', 3); } //调用自定义类进行输入数据合法性校验 $rule = $this->explain_reg_rule($activity['form']); if ($rule === null) { $this->myajaxReturn(null, '[错误]系统错误,无效的活动规则字符串。', 9); } if ($rule[0]['classname'] != null) { Vendor('ActivityFormClass.activity'); $checkres = null; if (!class_exists($rule[0]['classname']) || !method_exists($rule[0]['classname'], 'checkdata') || false === eval('$checkres = ' . $rule[0]['classname'] . '::checkdata($postdata);') || !is_string($checkres) && !is_array($checkres)) { $this->myajaxReturn(null, '[错误]系统错误,无效的自定义活动类。', 7); } //自定义类不合法 if (is_string($checkres)) { $this->myajaxReturn(null, $checkres, 8); } else { $postdata = $checkres; } } for ($i = 0; $i < count($postdata); $i++) { if ($i == 0) { $datastr .= base64_encode($postdata[$i]); } else { $datastr = $datastr . ',' . base64_encode($postdata[$i]); } } $d['aid'] = $aid; $d['ojaccount'] = \OJLoginInterface::getLoginUser(); $d['data'] = $datastr; if ($activity['isneedreview'] == 1) { $d['state'] = 0; } else { $d['state'] = 2; } $d['regtime'] = date('Y-m-d H:i:s', time()); if ($activitydataDB->add($d)) { $this->myajaxReturn(null, '[成功]报名活动成功!', 0); } else { $this->myajaxReturn(null, '[错误]报名活动失败!', 4); } } else { //修改 if ($activity['isneedreview'] == 1 && $regdata['state'] == 2) { $this->myajaxReturn(null, '[错误]你已通过审核,无法修改报名信息。如果确实需要修改,请联系管理员。', 7); } $adid = $regdata['adid']; $postdata = I('post.regdata', false, ''); //传进的是数组 $datastr = ''; if (count($postdata) < 1) { $this->myajaxReturn(null, '[错误]无效的请求数据。', 3); } //调用自定义类进行输入数据合法性校验 $rule = $this->explain_reg_rule($activity['form']); if ($rule === null) { $this->myajaxReturn(null, '[错误]系统错误,无效的活动规则字符串。', 9); } if ($rule[0]['classname'] != null) { Vendor('ActivityFormClass.activity'); $checkres = null; if (!class_exists($rule[0]['classname']) || !method_exists($rule[0]['classname'], 'checkdata') || false === eval('$checkres = ' . $rule[0]['classname'] . '::checkdata($postdata);') || !is_string($checkres) && !is_array($checkres)) { $this->myajaxReturn(null, '[错误]系统错误,无效的自定义活动类。', 7); } //自定义类不合法 if (is_string($checkres)) { $this->myajaxReturn(null, $checkres, 8); } else { $postdata = $checkres; } } for ($i = 0; $i < count($postdata); $i++) { if ($i == 0) { $datastr .= base64_encode($postdata[$i]); } else { $datastr = $datastr . ',' . base64_encode($postdata[$i]); } } $d['data'] = $datastr; if ($activity['isneedreview'] == 1) { $d['state'] = 0; } else { $d['state'] = 2; } $result = $activitydataDB->where('adid = ' . $adid . ' AND ojaccount = "' . \OJLoginInterface::getLoginUser() . '"')->save($d); if ($result !== false) { $this->myajaxReturn(null, '[成功]修改活动报名信息成功!', 0); } else { $this->myajaxReturn(null, '[错误]修改活动报名信息失败!', 4); } } }
private function buildtalk_perhtml($idx) { //生成每条talk的html return '<a style="color:black" href="?z=talk-msg-tid-' . $this->talk_arr[$idx]['tid'] . '">' . htmlspecialchars($this->talk_arr[$idx]['title']) . '</a> <small style="display:inline">(<span class="text-warning"><strong>' . intval($this->talk_arr[$idx]['l']) . 'B</strong></span>) BY <strong>' . (\OJLoginInterface::getUserUrl($this->talk_arr[$idx]['ojaccount']) == null ? '<span class="text-primary">' . htmlspecialchars($this->talk_arr[$idx]['ojaccount']) . '</span>' : '<a href="' . \OJLoginInterface::getUserUrl($this->talk_arr[$idx]['ojaccount']) . '"><span class="text-primary">' . htmlspecialchars($this->talk_arr[$idx]['ojaccount']) . '</span></a>') . '</strong> @ <span class="text-muted">' . $this->talk_arr[$idx]['createtime'] . '</span>' . ($this->talk_arr[$idx]['problemid'] ? ' IN <strong>' . (\OJLoginInterface::getProblemUrl($this->talk_arr[$idx]['problemid']) == null ? '<span class="text-danger">Problem ' . $this->talk_arr[$idx]['problemid'] . '</span>' : '<a href="' . \OJLoginInterface::getProblemUrl($this->talk_arr[$idx]['problemid']) . '"><span class="text-danger">Problem ' . $this->talk_arr[$idx]['problemid'] . '</span></a>') . '</strong>' : '') . (time() - strtotime($this->talk_arr[$idx]['createtime']) <= TalkController::$var_newlogo_second ? ' <span class="label label-warning">New</span>' : '') . '</small>'; }
public function contacts() { $this->commonassign(); if ($this->logincheck() == 0) { //未登录处理 $this->assign('url', \OJLoginInterface::getLoginURL()); $this->display('nologin'); return; } if ($this->logincheck() == 1) { //无权限处理 $this->display('noallow'); return; } $personDB = M('Person'); $teacher = $personDB->field('chsname, sex, email, phone, introduce')->where('`group` = 2')->order('uid ASC')->select(); $data = $personDB->field('chsname, sex, email, phone, grade, address, introduce')->where('`group` < 2 AND uid > 0')->select(); for ($i = 0; $i < count($teacher); $i++) { $teacher[$i]['email'] = htmlspecialchars($teacher[$i]['email']); $teacher[$i]['introduce'] = htmlspecialchars($teacher[$i]['introduce']); } for ($i = 0; $i < count($data); $i++) { $data[$i]['email'] = htmlspecialchars($data[$i]['email']); $data[$i]['address'] = htmlspecialchars($data[$i]['address']); $data[$i]['introduce'] = htmlspecialchars($data[$i]['introduce']); } $this->assign('teacher', $teacher); $this->assign('data', $data); $this->display('contacts'); }