Пример #1
0
 public function check_member()
 {
     global $_W;
     if ($this->_member) {
         return true;
     }
     // 开启登录
     if ($this->_set_info['login_flag'] > 0) {
         header('Location:' . $this->createMobileUrl('login'));
     }
     $sql = 'SELECT * FROM ' . tablename('ewei_exam_member') . ' WHERE `weid` = :weid AND `from_user` = :from_user';
     $params = array(':weid' => $this->_weid, ':from_user' => $this->_from_user);
     $member = pdo_fetch($sql, $params);
     if ($member) {
         if ($member['status'] < 1) {
             message('帐号被禁用,请联系管理员', '', 'error');
         }
     } else {
         if (empty($_W['fans']['openid'])) {
             message('请先关注公众号再来参加考试吧!');
         }
         $member = array('weid' => $this->_weid, 'from_user' => $this->_from_user, 'createtime' => TIMESTAMP, 'status' => 1);
         pdo_insert('ewei_exam_member', $member);
         $member['id'] = pdo_insertid();
     }
     exam_set_userinfo(0, $member);
 }
Пример #2
0
 public function check_member()
 {
     global $_W, $_GPC;
     $weid = $this->_weid;
     $member = exam_get_userinfo();
     $username = $this->_member['username'];
     $set = $this->_set_info;
     $login_flag = $set['login_flag'];
     //修正登录开关不同状态下的用户取值方法
     if ($login_flag == 1) {
         $user_info = pdo_fetch("SELECT * FROM " . tablename('ewei_exam_member') . " WHERE username = :username and weid = :weid limit 1", array(':username' => $username, ':weid' => $weid));
         if (empty($user_info['username']) || empty($user_info['userid'])) {
             //用户帐号不存在或者用户第一次登录,没有录入姓名 用户名,用户进入登录页
             $url = $this->createMobileUrl('login');
             header("Location: {$url}");
             exit;
         } else {
             if ($user_info['status'] == 0) {
                 message('帐号被禁用,请联系管理员', '', 'error');
                 exit;
             }
         }
     } else {
         //修正取值方法
         $user_info = pdo_fetch("SELECT * FROM " . tablename('ewei_exam_member') . " WHERE from_user = :from_user and weid = :weid limit 1", array(':from_user' => $_W['fans']['from_user'], ':weid' => $weid));
         if (empty($user_info['id'])) {
             //用户不存在,自动添加一个用户
             $member = array();
             $member['weid'] = $weid;
             //修正from_user取值
             $member['from_user'] = $_W['fans']['from_user'];
             $member['createtime'] = time();
             $member['status'] = 1;
             pdo_insert('ewei_exam_member', $member);
             $member['id'] = pdo_insertid();
             //自动添加成功,将用户信息放入cookie
             exam_set_userinfo(0, $member);
         } else {
             if ($user_info['status'] == 0) {
                 message('帐号被禁用,请联系管理员', '', 'error');
                 exit;
             }
         }
     }
 }