public function save_user_info($user_info, $account, $ckb_cookie = 1, $login_type = 0, $auto_login = 0, $oauth_login = 0)
 {
     global $kekezu, $_K, $handlekey;
     global $_lang;
     $_SESSION['uid'] = $user_info['uid'];
     $_SESSION['username'] = $user_info['username'];
     $_SESSION['last_login_time'] = $user_info['last_login_time'];
     $this->add_login_time(0);
     $login_type = $this->_login_type;
     if ($auto_login == '1') {
         $c = array();
         $c[0] = base64_encode($user_info['uid']);
         $c[1] = base64_encode($account);
         $c[2] = base64_encode($user_info['uid'] . '|' . $user_info['password'] . '|' . $account);
         setcookie('keke_auto_login', serialize($c), time() + 3600 * 24 * 30);
     }
     if ($_K['refer']) {
         //登录之后不同身份跳转到各自管理页面
         $user_obj = new keke_user_class();
         $user_type = $user_obj->get_user_type($user_info['uid']);
         if ($user_type['user_type'] == 2) {
             $r_url = '?do=user&view=wk';
         } elseif ($user_type['user_type'] == 1) {
             $r_url = '?do=user&view=gz';
         }
         $r = $_K['refer'] . $r_url;
     } else {
         $r = 'index.php';
     }
     if ($login_type) {
         $r = 'index.php';
     }
     if ($oauth_login) {
         $r = 'index.php';
     }
     if ($this->_sys_config['user_intergration'] == 2) {
         $synhtml = keke_user_class::user_synlogin($user_info['uid'], $this->_password);
     }
     $synhtml = isset($synhtml) ? $synhtml : "";
     $user_obj = new Keke_witkey_space_class();
     $user_obj->setLast_login_time(time());
     $user_obj->setWhere("uid = '{$user_info['uid']}'");
     $user_obj->edit_keke_witkey_space();
     $black_obj = new Keke_witkey_member_black_class();
     $black_obj->setWhere("uid = '{$user_info['uid']}'");
     $black_obj->del_keke_witkey_member_black();
     db_factory::execute(sprintf("update %switkey_member_oltime set last_op_time=%d where uid = %d", TABLEPRE, time(), $user_info['uid']));
     if (isset($_COOKIE['prom']) && $_COOKIE['prom']) {
         $prom_obj = keke_prom_class::get_instance();
         $url_data = $prom_obj->extract_prom_cookie();
         $url_data['p'] == 'reg' or $prom_obj->create_prom_relation($user_info['uid'], $user_info['username'], $url_data, '2');
     }
     if ($login_type == 1) {
         if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
             $this->show_msg($_lang['login_success'] . "{$synhtml}", 1, $r);
         } elseif (strtolower($_SERVER['REQUEST_METHOD']) == 'get') {
             echo "{$synhtml}<script>window.location.href='{$r}';</script>";
             die;
         }
     } else {
         if ($login_type == 3 || $login_type == 4) {
             $info = $user_info;
             $return_info['uid'] = $info['uid'];
             $return_info['username'] = $info['username'];
             $return_info['balance'] = intval($info['balance']);
             $return_info['credit'] = intval($info['credit']);
             $return_info['pic'] = keke_user_class::get_user_pic($user_info['uid']);
             $return_info['syn'] = $synhtml;
             $user_info['uid'] == ADMIN_UID || $user_info['group_id'] > 0 and $return_info['is_admin'] = 1;
             $return_info['g_pic'] = unserialize($info['buyer_level']);
             $return_info['s_pic'] = unserialize($info['seller_level']);
             $this->show_msg($_lang['login_success'], 1, $return_info);
             die;
         } elseif ($login_type == 2) {
             return true;
         } else {
             $this->show_msg($_lang['login_success'] . "{$synhtml}", 1, $r);
         }
     }
 }
Beispiel #2
0
 function init_user()
 {
     if ($_SESSION['uid']) {
         $this->_uid = $_SESSION['uid'];
         $this->_username = $_SESSION['username'];
         $userinfo = keke_user_class::get_user_info($this->_uid);
         if (!$userinfo['last_login_time']) {
             db_factory::execute(' update ' . TABLEPRE . 'witkey_space set last_login_time=' . time() . ' where uid=' . $this->_uid);
             $userinfo['last_login_time'] = time();
         }
         $userinfo['last_login_time'] = $_SESSION['last_login_time'] ? $_SESSION['last_login_time'] : time();
         $this->_userinfo = $userinfo;
         $this->_user_group = $this->_userinfo['group_id'];
         $user_obj = new keke_user_class();
         $user_type = $user_obj->get_user_type($this->_uid);
         $this->_user_type = $user_type['user_type'];
         //用户身份类型
     } elseif ($_COOKIE['keke_auto_login']) {
         $loginInfo = unserialize($_COOKIE['keke_auto_login']);
         $pwdInfo = explode('|', base64_decode($loginInfo[2]));
         $uInfo = kekezu::get_table_data('*', 'witkey_space', " username='******'2']}' and password = '******'1']}'", '', '');
         if ($uInfo[0]['uid'] == $pwdInfo[0]) {
             $_SESSION['uid'] = $uInfo[0]['uid'];
             $_SESSION['username'] = $uInfo[0]['username'];
             $this->_uid = $_SESSION['uid'];
             $this->_username = $uInfo[0]['username'];
         }
     }
 }