Ejemplo n.º 1
0
 function __construct()
 {
     global $_W;
     $this->_weid = $_W['uniacid'];
     $this->_member = exam_get_userinfo();
     $this->_from_user = $_W['fans']['openid'];
     $this->_set_info = get_ewei_exam_sysset();
     $init_param = get_init_param();
     $this->_types_config = $init_param['types_config'];
     $this->_answer_array = $init_param['answer_array'];
 }
Ejemplo n.º 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;
             }
         }
     }
 }