请选择 进入手机版 | 继续访问电脑版
 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 2144|回复: 0

discuz调用函数实现同步登录与退出核心代码

[复制链接]

2588

主题

2588

帖子

7694

积分

论坛元老

Rank: 8Rank: 8

积分
7694
发表于 2018-2-13 20:53:39 | 显示全部楼层 |阅读模式

这个问题折磨了好久,今天特意抽出一些时间来看看discuz的源代码,将部分代码抽取出来,写成函数,这样以后登录与退出只要调用一下这两个函数就可以了。
复制代码代码如下:
//退出Discuz账号
function discuz_logout(){
require './bbs/source/class/class_core.php'; //引入系统核心文件
$discuz = & discuz_core::instance(); //以下代码为创建及初始化对象
$discuz->cachelist = $cachelist;
$discuz->init();
require libfile('function/member');
require libfile('class/member');
$_GET['formhash'] = $_G['formhash'];
$ctl_obj = new logging_ctl();
$ctl_obj->setting = $_G['setting'];
$method = 'on_logout';
//$ctl_obj->template = 'member/login';
$ctl_obj->$method();
echo "成功退出!".time();
}
//登录Discuz账号
function discuz_login($username,$password){
require 'E:/ku25.com/wwwroot/bbs/source/class/class_core.php'; //引入系统核心文件
$discuz = & discuz_core::instance(); //以下代码为创建及初始化对象
$discuz->cachelist = $cachelist;
$discuz->init();
require libfile('function/member');
require libfile('class/member');
$_GET['formhash'] = $_G['formhash'];
$_GET['from'] = 1;
$_GET['loginsubmit'] = $_GET['infloat'] = 'yes';
$_GET['cookietime'] = '2592000';
$_GET['username'] = $username;
$_GET['password'] = $password;
$ctl_obj = new logging_ctl();
$ctl_obj->setting = $_G['setting'];
$method = 'on_login';
//$ctl_obj->template = 'member/login';
$ctl_obj->$method();
echo "成功登录!".time();
}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

用户反馈
客户端