public function login() { // 已登录 if (service('Passport')->isLogged()) { U('home/Space/index', '', true); } unset($_SESSION['sina'], $_SESSION['key'], $_SESSION['douban'], $_SESSION['open_platform_type']); //验证码 $opt_verify = model('Xdata')->lget('siteopt'); $opt_verify = $opt_verify['site_verify']; $opt_verify = in_array('login', $opt_verify); if ($opt_verify) { $this->assign('register_verify_on', 1); } $data['email'] = t($_REQUEST['email']); $data['uid'] = t($_REQUEST['uid']); $data['list'] = D('Operate', 'weibo')->getIndex(3); // 豆瓣登陆 include_once SITE_PATH . '/addons/plugins/login/douban.class.php'; $douban = new douban(); $this->assign('doubanurl', $douban->getUrl()); // 新浪登陆 include_once SITE_PATH . '/addons/plugins/login/sina.class.php'; $sina = new sina(); $this->assign('sinaurl', $sina->getUrl()); $this->assign($data); $this->assign('regInfo', model('Xdata')->lget('register')); $this->display(); }
public function public_head() { echo '<script>function after_publish_weibo(feed_id){ $.post(U("public/Widget/addonsRequest",["addon=Login","hook=ajax_after_publish_weibo"]),{feed_id:feed_id},function(){}) }</script>'; //判断新浪微博绑定是否过期,每天一次 $uid = $_SESSION['mid']; if (!($login = S('user_login_' . $mid))) { $login = M('login')->where("uid='{$uid}' AND type='sina'")->find(); S('user_login_' . $mid, $login); } if ($login) { $this->_loadTypeLogin('sina'); $sina = new sina(); $return = $sina->getTokenInfo($login['oauth_token']); if (isset($return['create_at']) && isset($return['expire_in']) && $return['create_at'] + $return['expire_in'] < time()) { $url = $sina->getUrl(); $text = '<dl class="pop_sync"><dt></dt>您绑定的' . $type . '帐号已过期,请<dd><a class="btn-att-green" href="' . $url . '">重新绑定</a></dd></dl>'; echo "<script>ui.box.show('{$text}', '绑定帐号')</script>"; } } }
public function login_sina() { include_once DOC_ROOT_PATH . 'Addons/plugins/login/sina.class.php'; $sina = new sina(); $login_url = $sina->getUrl(); redirect($login_url); }