コード例 #1
0
 public static function getInstance($config)
 {
     if (!isset(self::$_instance)) {
         $c = __CLASS__;
         self::$_instance = new $c($config);
     }
     return self::$_instance;
 }
コード例 #2
0
 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();
         }
     }
 }