Exemple #1
0
 /**
  * synLogin  同步登陆
  * @param $get
  * @author:xjw129xjt(肖骏涛) xjt@ourstu.com
  */
 function synLogin($get)
 {
     $uid = $get['uid'];
     $username = $get['username'];
     $password = $get['password'];
     header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
     session_start();
     $check_user = $this->db->getOne("SELECT * FROM `" . $this->tablePre . "member` WHERE uid=" . $uid);
     if ($check_user) {
         require_once $this->dirpath . 'OcApi/OCenter/OCenter.php';
         $OCApi = new OCApi();
         $user = $OCApi->ocGetUserInfo("id=" . $uid . " AND password='******'");
         //验证用户
         if ($user) {
             $auth = array('uid' => $user['uid'], 'username' => $user['username'], 'last_login_time' => $user['last_login_time']);
             if ($this->thisConfig['SESSION_PREFIX']) {
                 $_SESSION[$this->thisConfig['SESSION_PREFIX']]['user_auth'] = $auth;
                 $_SESSION[$this->thisConfig['SESSION_PREFIX']]['user_auth_sign'] = data_auth_sign($auth);
             } else {
                 $_SESSION['user_auth'] = $auth;
                 $_SESSION['user_auth_sign'] = data_auth_sign($auth);
             }
         }
     }
 }
 public function logout()
 {
     //调用退出登录的API
     D('Member')->logout();
     $html = '';
     if (UC_SYNC && is_login() != 1) {
         include_once './api/uc_client/client.php';
         $html = uc_user_synlogout();
     }
     $oc_config = (include_once './OcApi/oc_config.php');
     if ($oc_config['SSO_SWITCH']) {
         include_once './OcApi/OCenter/OCenter.php';
         $OCApi = new \OCApi();
         $html = $OCApi->ocSynLogout();
     }
     exit(json_encode(array('message' => L('_SUCCESS_LOGOUT_') . L('_PERIOD_'), 'url' => U('Home/Index/index'), 'html' => $html)));
     //显示页面
     //$this->success($result['message'], U('Home/Index/index'));
 }
 public function logout()
 {
     //调用退出登录的API
     D('Common/Member')->logout();
     $html = '';
     if (UC_SYNC && is_login() != 1) {
         // include_once './api/uc_client/client.php';
         $Ucenter = new \Common\Model\UcenterModel();
         $html = $Ucenter->uc_user_synlogout();
     }
     $oc_config = (include_once './OcApi/oc_config.php');
     if ($oc_config['SSO_SWITCH']) {
         include_once './OcApi/OCenter/OCenter.php';
         $OCApi = new \OCApi();
         $html .= $OCApi->ocSynLogout();
     }
     exit(json_encode(array('message' => '退出登陆成功。', 'url' => U('Home/Index/index'), 'html' => $html)));
     //显示页面
     //$this->success($result['message'], U('Home/Index/index'));
 }
 public function doLogin()
 {
     $aUsername = $username = I('post.username', '', 'op_t');
     $aPassword = I('post.password', '', 'op_t');
     $aVerify = I('post.verify', '', 'op_t');
     $aRemember = I('post.remember', 0, 'intval');
     /* 检测验证码 */
     if (check_verify_open('login')) {
         if (!check_verify($aVerify)) {
             $res['info'] = "验证码输入错误。";
             return $res;
         }
     }
     /* 调用UC登录接口登录 */
     check_username($aUsername, $email, $mobile, $aUnType);
     if (!check_reg_type($aUnType)) {
         $res['info'] = "该类型未开放登录。";
     }
     $uid = UCenterMember()->login($username, $aPassword, $aUnType);
     if (0 < $uid) {
         //UC登录成功
         /* 登录用户 */
         $Member = D('Member');
         $args['uid'] = $uid;
         $args = array('uid' => $uid, 'nickname' => $username);
         check_and_add($args);
         if ($Member->login($uid, $aRemember == 1)) {
             //登录用户
             //TODO:跳转到登录前页面
             if (UC_SYNC && $uid != 1) {
                 //同步登录到UC
                 $ref = M('ucenter_user_link')->where(array('uid' => $uid))->find();
                 $html = '';
                 $html = uc_user_synlogin($ref['uc_uid']);
             }
             $oc_config = (include_once './OcApi/oc_config.php');
             if ($oc_config['SSO_SWITCH']) {
                 include_once './OcApi/OCenter/OCenter.php';
                 $OCApi = new \OCApi();
                 $html = $OCApi->ocSynLogin($uid);
             }
             $res['status'] = 1;
             $res['info'] = $html;
             //$this->success($html, get_nav_url(C('AFTER_LOGIN_JUMP_URL')));
         } else {
             $res['info'] = $Member->getError();
         }
     } else {
         //登录失败
         switch ($uid) {
             case -1:
                 $res['info'] = '用户不存在或被禁用!';
                 break;
                 //系统级别禁用
             //系统级别禁用
             case -2:
                 $res['info'] = '密码错误!';
                 break;
             default:
                 $res['info'] = $uid;
                 break;
                 // 0-接口参数错误(调试阶段使用)
         }
     }
     return $res;
 }
 public function doLogin()
 {
     $aUsername = $username = I('post.username', '', 'op_t');
     $aPassword = I('post.password', '', 'op_t');
     $aVerify = I('post.verify', '', 'op_t');
     $aRemember = I('post.remember', 0, 'intval');
     /* 检测验证码 */
     if (check_verify_open('login')) {
         if (!check_verify($aVerify)) {
             $res['info'] = L('_INFO_VERIFY_CODE_INPUT_ERROR_') . L('_PERIOD_');
             return $res;
         }
     }
     /* 调用UC登录接口登录 */
     check_username($aUsername, $email, $mobile, $aUnType);
     if (!check_reg_type($aUnType)) {
         $res['info'] = L('_INFO_TYPE_NOT_OPENED_') . L('_PERIOD_');
     }
     $uid = UCenterMember()->login($username, $aPassword, $aUnType);
     if (0 < $uid) {
         //UC登录成功
         /* 登录用户 */
         $Member = D('Member');
         $args['uid'] = $uid;
         $args = array('uid' => $uid, 'nickname' => $username);
         check_and_add($args);
         if ($Member->login($uid, $aRemember == 1)) {
             //登录用户
             //TODO:跳转到登录前页面
             $html_uc = '';
             if (UC_SYNC && $uid != 1) {
                 include_once './api/uc_client/client.php';
                 //同步登录到UC
                 $ref = M('ucenter_user_link')->where(array('uid' => $uid))->find();
                 $html_uc = uc_user_synlogin($ref['uc_uid']);
             }
             $oc_config = (include_once './OcApi/oc_config.php');
             if ($oc_config['SSO_SWITCH']) {
                 include_once './OcApi/OCenter/OCenter.php';
                 $OCApi = new \OCApi();
                 $html_oc = $OCApi->ocSynLogin($uid);
             }
             $html = empty($html_oc) ? $html_uc : $html_oc;
             $res['status'] = 1;
             $res['info'] = $html;
             //$this->success($html, get_nav_url(C('AFTER_LOGIN_JUMP_URL')));
         } else {
             $res['info'] = $Member->getError();
         }
     } else {
         //登录失败
         switch ($uid) {
             case -1:
                 $res['info'] = L('_INFO_USER_FORBIDDEN_');
                 break;
                 //系统级别禁用
             //系统级别禁用
             case -2:
                 $res['info'] = L('_INFO_PW_ERROR_') . L('_EXCLAMATION_');
                 break;
             default:
                 $res['info'] = $uid;
                 break;
                 // 0-接口参数错误(调试阶段使用)
         }
     }
     return $res;
 }