Exemplo n.º 1
0
 function qqcallback()
 {
     $o_qq = Oauth_qq::getInstance($this->_configs['qq']);
     $o_qq->callback();
     if ($openid = $o_qq->get_openid()) {
         $oauth_model =& m("oauth");
         $user = $oauth_model->get("qq_openid = '{$openid}'");
         //登录
         if ($user && 0 < $user['u_id']) {
             $this->_do_login($user['u_id']);
             $this->show_message(Lang::get('login_successed') . $synlogin, 'back_before_login', rawurldecode($_POST['ret_url']), 'enter_member_center', 'index.php?app=member');
             exit;
         }
         //记录openid
         if (!$user) {
             /*   $data = array(
                        'qq_openid' => $openid,
                        'add_time'  => gmtime(),
                     );
             
                     $oauth_model->add($data, ture); */
         }
         //去绑定帐号
         header('Location:index.php?module=oauth&act=login&ret_url=' . rawurlencode($_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']));
         return;
     } else {
         return;
     }
 }
 function qqcallback()
 {
     import('ORG.Util.Qqlogin');
     $lasturl = urlencode(htmlspecialchars('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']));
     $o_qq = Oauth_qq::getInstance($this->qqconfig);
     $o_qq->callback();
     $qid = $o_qq->get_openid();
     if ($qid != '') {
         $info = M('member')->where("qid='{$qid}'")->find();
         if ($info) {
             //已经绑定帐号
             $_SESSION['dami_uid'] = $info['id'];
             $_SESSION['dami_username'] = $info['username'];
             $_SESSION['dami_usericon'] = $info['icon'];
             if (!empty($_REQUEST['lasturl'])) {
                 $this->assign('jumpUrl', urldecode(htmlspecialchars($_REQUEST['lasturl'])));
             } else {
                 $this->assign('jumpUrl', U('Member/main'));
             }
             $this->success('登录成功~');
         } else {
             //首次绑定
             $userinfo = $o_qq->get_user_info();
             //print_r($userinfo);
             $this->assign('userinfo', $userinfo);
             $this->assign('qid', $qid);
             $this->display();
         }
     }
 }