牛骨文教育服务平台(让学习变的简单)
博文笔记

discuz使用其它单点登录

创建时间:2016-11-02 投稿人: 浏览次数:197
  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. ?>  

声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。