- * zj53hao 20140418 外部程序单点登录到discuz(同步注册和登录到discuz) http://blog.csdn.net/zj53hao
- */
- define('NOROBOT', FALSE);
- define('ADMINSCRIPT', basename(__FILE__));
- define('CURSCRIPT', 'admin');
- define('HOOKTYPE', 'hookscript');
- define('APPTYPEID', 0);
- //define('CURMODULE', $mod);
- require './source/class/class_core.php';
- $discuz = C::app();
- $discuz->init();
- require libfile('function/member');
- require libfile('class/member');
- runhooks();
- $newusername = trim($_GET['newusername']);
- $newpassword = 'www.xxxx.com';//trim($_GET['newpassword']);
- $newemail = isset($_GET['newemail'])? strtolower(trim($_GET['newemail'])):$newusername.'@xxx.com';
- if(!$newusername || !$newemail) {
- showmessage('您目前未登录xxx网,暂时以游客身份只读访问论坛');
- }
- // 以下几句防止第3方伪造
- $time= (int)($_GET["time"]);
- $curdate= time();
- $seckey=$time.$newusername.'www.xxx.com';
- $seckey= md5($seckey);
- if($curdate-$time>1200 || $seckey!=$_GET['code']){
- showmessage('submit_invalid');
- }
- $_G['uid']='';
- $userid=C::t('common_member')->fetch_uid_by_username($newusername);
- $_SERVER['REQUEST_METHOD'] = 'POST';//注册需要模拟POST防止2次校验不通过
- $_GET['formhash'] = formhash();// 防止 2次校验不通过
- $_G['group']['seccode']='';// 防止 2次校验不通过
- if(!$userid){// 没有找到对应用户则调用注册
- $_GET['regsubmit']='yes';
- $_GET['infloat']='yes';
- $_GET['lssubmit']='yes';
- $ctl_obj = new register_ctl();
- $ctl_obj->setting = $_G['setting'];
- $ctl_obj->template = 'member/register';
- $_GET[''.$ctl_obj->setting['reginput']['username']]=$newusername;
- $_GET[''.$ctl_obj->setting['reginput']['password']]= $newpassword;
- $_GET[''.$ctl_obj->setting['reginput']['password2']]= $newpassword;
- $_GET[''.$ctl_obj->setting['reginput']['email']] =$newemail;
- $ctl_obj->on_register();
- }
- //uc_user_synlogout();
- $_G['groupid'] = $_G['member']['groupid'] = 7;
- $_G['uid'] = $_G['member']['uid'] = 0;
- $_G['username'] = $_G['member']['username'] = $_G['member']['password'] = '';
- // 登陆
- $_GET['loginsubmit']='yes';
- $_GET['lssubmit']='';
- $_GET['username']=$newusername;
- $_GET['password']= $newpassword;
- $ctl_obj = new logging_ctl();
- $ctl_obj->setting = $_G['setting'];
- $ctl_obj->template = 'member/login';
- $ctl_obj->on_login();
- ?>
discuz使用其它单点登录
最新推荐文章于 2024-04-01 16:57:31 发布