数据载入中,请稍后......
 
展开
懒人码库客户端 点击或扫描下载
欢迎来到懒人码库!懒人码库QQ群:19651313
欢迎来到懒人码库!懒人码库QQ群:19651313  
当前位置:懒人码库 > 开源系统 > Discuz!

discuzX3.2 通过url传值 保存cookie 登录接口API

2016-11-23 09:55 来源:www.lanrenmaku.com / 作者:懒人 已被阅读:次 分类:Discuz! 上一篇:ucenter1.6网站接口示例 下一篇:没有了

discuzX3.2 通过url传值 保存cookie 登录接口API:

  1. <?php 
  2. require './source/class/class_core.php'
  3.  
  4. $discuz = C::app(); 
  5. $discuz->init(); 
  6.  
  7. $username = $_GET['username']; 
  8.  
  9. if($_GET['action'] == 'login_' && $username) {  
  10.      
  11.     $formUsername = $username;  
  12.     $formPassword = '';  
  13.  
  14.      
  15.     $member = DB::fetch_first("SELECT * FROM pre_common_member WHERE username='$formUsername'"); 
  16.  
  17.     if($member){ 
  18.     //$uc_member = DB::fetch_first("SELECT * FROM pre_ucenter_members WHERE username='$formUsername'"); 
  19.  
  20.     $Md5_formPassword = md5(md5($formPassword).$uc_member['salt']); 
  21.  
  22.     //if($uc_member['password'] == $Md5_formPassword){ //密码:rst12341 
  23.         dsetcookie('auth', authcode("{$member['password']}\t{$member['uid']}"'ENCODE'), '1234243'); 
  24.          //} 
  25.     }else
  26.          
  27.         $cone = DB::insert('common_member',array('username' => $username,'password' => '44ac7c7bf457011cf165e5fd06e9b479','credits' => '0','timeoffset' => '9999'),true); 
  28.          
  29.         if($cone){ 
  30.  
  31.             DB::insert('common_member_count',array('uid' => $cone,'extcredits2' => 0)); 
  32.             DB::insert('common_member_field_forum',array('uid' => $cone)); 
  33.             DB::insert('common_member_field_home',array('uid' => $cone)); 
  34.             DB::insert('common_member_newprompt',array('uid' => $cone,'data' => 'a:1:{s:6:"system";i:2;}')); 
  35.             DB::insert('common_member_profile',array('uid' => $cone)); 
  36.             $cone1 = DB::insert('ucenter_members',array('username' => $username,'password' => 'f90fb1b289fca49b2272dd8376d5e454','salt' => '2a67f0'),true); 
  37.             DB::insert('ucenter_memberfields',array('uid' => $cone1)); 
  38.  
  39.             $member = DB::fetch_first("SELECT * FROM pre_common_member WHERE username='$username'"); 
  40.             dsetcookie('auth', authcode("{$member['password']}\t{$member['uid']}"'ENCODE'), '1234243'); 
  41.         } 
  42.     } 
  43.  
  44.        header("location:/forum.php"); 
  45.  
  46.  
  47. ?> 

<?php

require './source/class/class_core.php';

 

$discuz = C::app();

$discuz->init();

 

$username = $_GET['username'];

 

if($_GET['action'] == 'login_' && $username) { 

    

$formUsername = $username; 

    $formPassword = ''; 

 

    

$member = DB::fetch_first("SELECT * FROM pre_common_member WHERE username='$formUsername'");

 

if($member){

    //$uc_member = DB::fetch_first("SELECT * FROM pre_ucenter_members WHERE username='$formUsername'");

 

$Md5_formPassword = md5(md5($formPassword).$uc_member['salt']);

 

    //if($uc_member['password'] == $Md5_formPassword){ //密码:rst12341

   dsetcookie('auth', authcode("{$member['password']}\t{$member['uid']}", 'ENCODE'), '1234243');

         //}

}else{

$cone = DB::insert('common_member',array('username' => $username,'password' => '44ac7c7bf457011cf165e5fd06e9b479','credits' => '0','timeoffset' => '9999'),true);

if($cone){

 

DB::insert('common_member_count',array('uid' => $cone,'extcredits2' => 0));

DB::insert('common_member_field_forum',array('uid' => $cone));

DB::insert('common_member_field_home',array('uid' => $cone));

DB::insert('common_member_newprompt',array('uid' => $cone,'data' => 'a:1:{s:6:"system";i:2;}'));

DB::insert('common_member_profile',array('uid' => $cone));

$cone1 = DB::insert('ucenter_members',array('username' => $username,'password' => 'f90fb1b289fca49b2272dd8376d5e454','salt' => '2a67f0'),true);

DB::insert('ucenter_memberfields',array('uid' => $cone1));

 

$member = DB::fetch_first("SELECT * FROM pre_common_member WHERE username='$username'");

dsetcookie('auth', authcode("{$member['password']}\t{$member['uid']}", 'ENCODE'), '1234243');

}

}

 

  header("location:/forum.php");

 

}

 

?>

微信登录:

  1. <?php 
  2. require './source/class/class_core.php'
  3.  
  4. $discuz = C::app(); 
  5. $discuz->init(); 
  6.  
  7. $appid  = "wx4559744beda84132";  
  8.     $secret = "e8a4871da7c04532a233a7e6dae65821";  
  9.   
  10.     $code = $_GET['code'];  
  11.   
  12.     $url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=".$appid."&secret=".$secret."&code=".$code."&grant_type=authorization_code";  
  13.   
  14.     $content = file_get_contents($url);  
  15.     $arr = json_decode($content);  
  16.     $access_token = $arr->access_token;  
  17.     $refresh_token = $arr->refresh_token;  
  18.     $openid = $arr->openid;  
  19.   
  20.     $url = "https://api.weixin.qq.com/sns/userinfo?access_token=".$access_token."&openid=".$openid."&lang=zh_CN";  
  21.     $userObj = json_decode(file_get_contents($url));  
  22.     $headImg = $userObj->headimgurl; 
  23.  
  24.      
  25.  
  26. $username = $userObj->openid; 
  27.  
  28. // if($_GET['action'] == 'login_' && $username) {  
  29.      
  30.     $formUsername = $username;  
  31.     $formPassword = '';  
  32.  
  33.      
  34.     $member = DB::fetch_first("SELECT * FROM pre_common_member WHERE username='$formUsername'"); 
  35.  
  36.     if($member){ 
  37.     //$uc_member = DB::fetch_first("SELECT * FROM pre_ucenter_members WHERE username='$formUsername'"); 
  38.  
  39.     $Md5_formPassword = md5(md5($formPassword).$uc_member['salt']); 
  40.  
  41.     //if($uc_member['password'] == $Md5_formPassword){ //密码:rst12341 
  42.         dsetcookie('auth', authcode("{$member['password']}\t{$member['uid']}"'ENCODE'), '1234243'); 
  43.          //} 
  44.     }else
  45.          
  46.         $cone = DB::insert('common_member',array('username' => $username,'password' => '44ac7c7bf457011cf165e5fd06e9b479','credits' => '0','timeoffset' => '9999','avatarurl' => $headImg),true); 
  47.          
  48.         if($cone){ 
  49.  
  50.             DB::insert('common_member_count',array('uid' => $cone,'extcredits2' => 0)); 
  51.             DB::insert('common_member_field_forum',array('uid' => $cone)); 
  52.             DB::insert('common_member_field_home',array('uid' => $cone)); 
  53.             DB::insert('common_member_newprompt',array('uid' => $cone,'data' => 'a:1:{s:6:"system";i:2;}')); 
  54.             DB::insert('common_member_profile',array('uid' => $cone,'realname' => $userObj->nickname)); 
  55.             $cone1 = DB::insert('ucenter_members',array('username' => $username,'password' => 'f90fb1b289fca49b2272dd8376d5e454','salt' => '2a67f0'),true); 
  56.             DB::insert('ucenter_memberfields',array('uid' => $cone1)); 
  57.  
  58.             $member = DB::fetch_first("SELECT * FROM pre_common_member WHERE username='$username'"); 
  59.             dsetcookie('auth', authcode("{$member['password']}\t{$member['uid']}"'ENCODE'), '1234243'); 
  60.         } 
  61.     } 
  62.  
  63.        header("location:/forum.php"); 
  64.  
  65. // } 
  66.  
  67. ?> 


 

小贴士:懒人码库 为网页前端人员提供建站常用的广告代码和网页特效,内容涵盖焦点图,导航菜单,jQuery代码,图片特效,对联广告,日历控件,在线客服等。