discuz使用其它单点登录

  1. *     zj53hao 20140418 外部程序单点登录到discuz(同步注册和登录到discuz) http://blog.csdn.net/zj53hao  
  2.  */  
  3.   
  4. define('NOROBOT', FALSE);  
  5. define('ADMINSCRIPT'basename(__FILE__));  
  6. define('CURSCRIPT''admin');  
  7. define('HOOKTYPE''hookscript');  
  8. define('APPTYPEID', 0);  
  9. //define('CURMODULE', $mod);  
  10.   
  11. require './source/class/class_core.php';  
  12.   
  13. $discuz = C::app();  
  14. $discuz->init();  
  15.   
  16. require libfile('function/member');  
  17. require libfile('class/member');  
  18. runhooks();  
  19.   
  20. $newusername = trim($_GET['newusername']);  
  21. $newpassword = 'www.xxxx.com';//trim($_GET['newpassword']);  
  22. $newemail = isset($_GET['newemail'])? strtolower(trim($_GET['newemail'])):$newusername.'@xxx.com';  
  23.   
  24. if(!$newusername || !$newemail) {  
  25.     showmessage('您目前未登录xxx网,暂时以游客身份只读访问论坛');  
  26. }  
  27.   
  28. // 以下几句防止第3方伪造  
  29. $time= (int)($_GET["time"]);  
  30. $curdate= time();  
  31. $seckey=$time.$newusername.'www.xxx.com';  
  32. $seckey=  md5($seckey);  
  33. if($curdate-$time>1200 || $seckey!=$_GET['code']){  
  34.     showmessage('submit_invalid');  
  35. }  
  36.   
  37.                   
  38. $_G['uid']='';  
  39. $userid=C::t('common_member')->fetch_uid_by_username($newusername);  
  40.   
  41.     $_SERVER['REQUEST_METHOD'] = 'POST';//注册需要模拟POST防止2次校验不通过  
  42.     $_GET['formhash'] = formhash();// 防止 2次校验不通过  
  43.     $_G['group']['seccode']='';// 防止 2次校验不通过  
  44.    
  45. if(!$userid){// 没有找到对应用户则调用注册  
  46.     $_GET['regsubmit']='yes';  
  47.     $_GET['infloat']='yes';  
  48.     $_GET['lssubmit']='yes';  
  49.     $ctl_obj = new register_ctl();  
  50.     $ctl_obj->setting = $_G['setting'];  
  51.     $ctl_obj->template = 'member/register';  
  52.       
  53.     $_GET[''.$ctl_obj->setting['reginput']['username']]=$newusername;  
  54.     $_GET[''.$ctl_obj->setting['reginput']['password']]= $newpassword;  
  55.     $_GET[''.$ctl_obj->setting['reginput']['password2']]= $newpassword;  
  56.     $_GET[''.$ctl_obj->setting['reginput']['email']] =$newemail;  
  57.      
  58.     $ctl_obj->on_register();  
  59. }  
  60.   
  61. //uc_user_synlogout();  
  62. $_G['groupid'] = $_G['member']['groupid'] = 7;  
  63. $_G['uid'] = $_G['member']['uid'] = 0;  
  64. $_G['username'] = $_G['member']['username'] = $_G['member']['password'] = '';  
  65.                   
  66. // 登陆             
  67. $_GET['loginsubmit']='yes';  
  68. $_GET['lssubmit']='';  
  69. $_GET['username']=$newusername;  
  70. $_GET['password']= $newpassword;         
  71. $ctl_obj = new logging_ctl();  
  72. $ctl_obj->setting = $_G['setting'];  
  73. $ctl_obj->template = 'member/login';  
  74. $ctl_obj->on_login();  
  75.   
  76. ?>  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值