Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[展示] 新浪微博授权链接到UCHOME开源下载!

[复制链接]
strangebank 发表于 2010-9-20 16:05:32 | 显示全部楼层 |阅读模式
UCHome插件
语言编码: GBK简体 UTF8简体 
插件名称: 喵咪咪网新浪授权
插件作者: 喵咪咪网
适用版本: UCHome 2.0
本帖最后由 strangebank 于 2011-8-2 10:13 编辑

说明: 文件中包含的类文件大部分内容来自互联网。版权归原创者所有,也感谢他们的分享精神。
          类以外文件不做版权说明。代码没有做优化,需要的朋友可根据自己实际情况优化,有金币的给个金币没金币的也可以下载!有不明白的地方,请留言,me不定期答疑。
官方演示地址 http://www.miaomimi.com/index.php注意: 文件中的编码需要特别注意。如果是非utf-8的请注意修改函数 showmessage()。
P.S :希望大家关注流浪猫or其他小动物,有身边喜欢猫的朋友也欢迎推荐。
        喜欢的朋友 http://t.sina.com.cn/miaomimi  粉丝下吧!

文件 weibooauth.php 到 http://code.google.com/p/libweibo/下载

  1. <?php
  2. header("Content-type:text/html;charset=utf-8");
  3. define( "WB_AKEY" , '' );
  4. define( "WB_SKEY" , '' );
  5. include_once("../../common.php");
  6. include_once('function.php');
  7. ?>
复制代码
以上两个  KEY 到官方申请
  1. <?php
  2. if($_GET['debug=1']) {phpinfo();exit;}
  3. session_start();
  4. #if( isset($_SESSION['last_key']) ) header("Location: weibolist.php");
  5. include_once( 'config.php' );
  6. include_once( 'weibooauth.php' );
  7. $o = new WeiboOAuth( WB_AKEY , WB_SKEY  );
  8. $keys = $o->getRequestToken();
  9. $aurl = $o->getAuthorizeURL( $keys['oauth_token'] ,false , 'http://www.miaomimi.com/plugins/sinablog/callback.php');
  10. $_SESSION['keys'] = $keys;
  11. if($aurl){
  12.         #header("Location: $aurl");
  13.         #exit();
  14. }
  15. ?>
  16. <a href="<?=$aurl?>"><img src="http://i3.dpfile.com/s/res/sina_t_btn.v3.png" alt="新浪微博登录" /></a>
复制代码

  1. <?php
  2. session_start();
  3. include_once( 'config.php' );
  4. include_once( 'weibooauth.php' );
  5. $c = new WeiboClient( WB_AKEY , WB_SKEY , $_SESSION['last_key']['oauth_token'] , $_SESSION['last_key']['oauth_token_secret']  );
  6. $msg = $c->verify_credentials();
  7. $jumpurl = $app?"userapp.php?id=$app&my_extra=invitedby_bi_{$uid}_{$code}&my_suffix=Lw%3D%3D":'space.php?do=home';
  8. #print_r($msg);

  9. if ($msg === false || $msg === null){
  10.         echo "Error occured";
  11.         return false;
  12. }else{
  13.         $step = $_GET['m']?$_GET['m']:'continue';
  14.         if(!@include_once S_ROOT.'./uc_client/client.php') {
  15.                         showmessage('system_error');
  16.                 }
  17.         if($step =='continue'){
  18.                 #continue
  19.                 #print_r($msg);
  20.                 #die();
  21.         }elseif($step=='bind'){
  22.                 $password = $_POST['password'];
  23.                 $username = trim($_POST['username']);
  24.                 //同步获取用户源
  25.                 if(!$passport = getpassport($username, $password)) {
  26.                         showmessage('login_failure_please_re_login', 'do.php?ac='.$_SCONFIG['login_action']);
  27.                 }
  28.                 $newuid=$uid = $passport['uid'];
  29.         }
  30.         
  31.         foreach($msg as $k=>$v){
  32.                 if($k=='verified')break;
  33.                 $k =iconv('utf-8','gbk',$v);
  34.         }
  35.         $note =$msg->status->text;//['text'];
  36.         $sql = "select openuid,brageid from uc_open_api_members where brageid!=0 and  openuid = '$id'";
  37.         $queryc = $_SGLOBAL['db']->query($sql);
  38.         if($now =$_SGLOBAL['db']->fetch_array($queryc)) {
  39.                 #登录过了
  40.                 $brageid  = $now['brageid'];
  41.                 $username= $name;
  42.                 $password = trim('miao'.$id);
  43.                 //同步获取用户源
  44.                 if(!$passport = getpassport($username, $password)) {
  45.                         showmessage('login_failure_please_re_login', 'do.php?ac='.$_SCONFIG['login_action']);
  46.                 }
  47.                 $setarr = array(
  48.                 'uid' => $passport['uid'],
  49.                 'username' => addslashes($passport['username']),
  50.                 'password' => md5("$passport[uid]|$_SGLOBAL[timestamp]")//本地密码随机生成
  51.                 );

  52.                 include_once(S_ROOT.'./source/function_space.php');
  53.                 //开通空间
  54.                 $query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('space')." WHERE uid='$setarr[uid]'");
  55.                 if(!$space = $_SGLOBAL['db']->fetch_array($query)) {
  56.                         $space = space_open($setarr['uid'], $setarr['username'], 0, $passport['email']);
  57.                 }

  58.                 $_SGLOBAL['member'] = $space;

  59.                 //实名
  60.                 realname_set($space['uid'], $space['username'], $space['name'], $space['namestatus']);

  61.                 //检索当前用户
  62.                 $query = $_SGLOBAL['db']->query("SELECT password FROM ".tname('member')." WHERE uid='$setarr[uid]'");
  63.                 if($value = $_SGLOBAL['db']->fetch_array($query)) {
  64.                         $setarr['password'] = addslashes($value['password']);
  65.                 } else {
  66.                         //更新本地用户库
  67.                         inserttable('member', $setarr, 0, true);
  68.                 }

  69.                 //清理在线session
  70.                 insertsession($setarr);

  71.                 ssetcookie('auth', authcode("$setarr[password]\t$setarr[uid]", 'ENCODE'), 2592000);
  72.                 ssetcookie('loginuser', $passport['username'], 31536000);
  73.                 ssetcookie('_refer', '');

  74.                 //同步登录
  75.                 if($_SCONFIG['uc_status']) {
  76.                         include_once S_ROOT.'./uc_client/client.php';
  77.                         $ucsynlogin = uc_user_synlogin($setarr['uid']);
  78.                 } else {
  79.                         $ucsynlogin = '';
  80.                 }
  81.                 $_SGLOBAL['supe_uid'] = $space['uid'];


  82.                 if(empty($_POST['refer'])) {
  83.                         $_POST['refer'] = 'space.php?do=home';
  84.                 }
  85.                          header("Location: http://www.miaomimi.com/space.php?do=home&ref=sianminiblog");

  86.         }else{
  87.                 $username = trim($name);
  88.                 $password = 'miao'.$id;
  89.                 $email = $domain.'@miaomimi.com';
  90.                 $newuid = uc_user_register($username, $password, $email);
  91.                 if($newuid <= 0) {
  92.                         if($newuid == -1) {
  93.                                 showmessage('user_name_is_not_legitimate');
  94.                         } elseif($newuid == -2) {
  95.                                 showmessage('include_not_registered_words');
  96.                         } elseif($newuid == -3) {
  97.                                 showmessage('user_name_already_exists');
  98.                         } elseif($newuid == -4) {
  99.                                 showmessage('email_format_is_wrong');
  100.                         } elseif($newuid == -5) {
  101.                                 showmessage('email_not_registered');
  102.                         } elseif($newuid == -6) {
  103.                                 showmessage('email_has_been_registered');
  104.                         } else {
  105.                                 showmessage('register_error');
  106.                         }
  107.                 } else {
  108.                         $setarr = array(
  109.                         'uid' => $newuid,
  110.                         'username' => $username,
  111.                         'password' => md5("$newuid|$_SGLOBAL[timestamp]")//本地密码随机生成
  112.                         );
  113.                         //更新本地用户库
  114.                         inserttable('member', $setarr, 0, true);
  115.                         $image = str_replace('/50/','/180/',$profile_image_url);
  116.                         $mpath= str_replace('http://miaomimi.com/','../../',avatar_path($newuid,'big',true));
  117.                         $path= getImage($image,'test',0);
  118.                         rmkdir($mpath,'777');
  119.                         $them = array('big'=>array(180,180),
  120.                         'small'=>array(50,50),
  121.                         'middle'=>array(100,100));
  122.                         
  123.                         foreach($them as $k=>$v){
  124.                                 $image= str_replace('http://miaomimi.com/','../../',avatar($newuid,$k,true));
  125.                                 makethumb($path,$image,$v[0],$v[1]);
  126.                         }
  127.                         //开通空间
  128.                         include_once(S_ROOT.'./source/function_space.php');
  129.                         $space = space_open($newuid, $username, 0, $email);
  130.                         #修改头像状态 和 用户资料
  131.                         updatetable('space', array('avatar'=>1,'name'=>$name), array('uid'=>$newuid));
  132.                         $s = split(' ',$location);

  133.                         updatetable('spacefield', array('birthprovince'=>$s[0],'birthcity'=>$s[1],'resideprovince'=>$s[0],'residecity'=>$s[1],'spacenote'=>$description, 'note'=>$note), array('uid'=>$newuid));
  134.                                        
  135.                         //在线session
  136.                         insertsession($setarr);
  137.                         //设置cookie
  138.                         ssetcookie('auth', authcode("$setarr[password]\t$setarr[uid]", 'ENCODE'), 2592000);
  139.                         ssetcookie('loginuser', $username, 31536000);
  140.                         ssetcookie('_refer', '');

  141.                         //变更记录
  142.                         if($_SCONFIG['my_status']) inserttable('userlog', array('uid'=>$newuid, 'action'=>'add', 'dateline'=>$_SGLOBAL['timestamp']), 0, true);

  143.                         $sql = "INSERT INTO uc_open_api_members (
  144.                                                                                                           `openuid` ,
  145.                                                                                                           `screen_name` ,
  146.                                                                                                           `name` ,
  147.                                                                                                           `province` ,
  148.                                                                                                           `city` ,
  149.                                                                                                           `location` ,
  150.                                                                                                           `description` ,
  151.                                                                                                           `url` ,
  152.                                                                                                           `profile_image_url` ,
  153.                                                                                                           `domain` ,
  154.                                                                                                           `brageid` ,
  155.                                                                                                           `addtime`
  156.                                                                                                           )
  157.                                                                                                           VALUES (
  158.                                                                                                           '".$id."',
  159.                                                                                                           '".$screen_name."',
  160.                                                                                                           '".$name."',
  161.                                                                                                           '".$province."',
  162.                                                                                                           '".$city."',
  163.                                                                                                           '".$location."',
  164.                                                                                                           '".$description."',
  165.                                                                                                           '".$url."',
  166.                                                                                                           '".$profile_image_url."',
  167.                                                                                                           '".$domain."',
  168.                                                                                                           '".$newuid."',
  169.                                                                                                           'now()'
  170.                                                                                                           );";
  171.                         $_SGLOBAL['db']->query($sql);
  172.                         #showmessage('registered', $jumpurl);
  173.                          header("Location: http://www.miaomimi.com/space.php?do=home'");
  174.                 }
  175.         }
  176.         exit();
  177. }
  178. ?>
复制代码


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
 楼主| strangebank 发表于 2010-9-20 16:19:50 | 显示全部楼层
回复

使用道具 举报

 楼主| strangebank 发表于 2010-9-20 16:21:25 | 显示全部楼层
编辑器好垃圾阿。无法打入汉字  uc_open_api_members  这个表根据插入语句自己创建吧。
回复

使用道具 举报

woodmj 发表于 2010-9-20 16:35:40 | 显示全部楼层
看不见。。。
回复

使用道具 举报

 楼主| strangebank 发表于 2010-9-21 12:10:12 | 显示全部楼层
是不是现在没人用uchome了?
回复

使用道具 举报

mels 发表于 2010-9-21 13:35:58 | 显示全部楼层
這樣要錢喔?
回复

使用道具 举报

 楼主| strangebank 发表于 2010-9-21 16:48:34 | 显示全部楼层
回复 mels 的帖子

不要钱的阿。 免费下的阿。
回复

使用道具 举报

ilei365 发表于 2010-9-21 21:14:00 | 显示全部楼层
支持个吧。
回复

使用道具 举报

zzy9941 发表于 2010-9-22 20:13:06 | 显示全部楼层
这个是好东西,用上了 谢谢
回复

使用道具 举报

 楼主| strangebank 发表于 2010-9-25 11:23:58 | 显示全部楼层
回复

使用道具 举报

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

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-5-19 06:41 , Processed in 0.101674 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表