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

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[求助] UC 1.6与PHPCMS 2008 Sp4通信失败

[复制链接]
而特瑞特瑞特 发表于 2011-12-18 21:08:45 | 显示全部楼层 |阅读模式
本帖最后由 而特瑞特瑞特 于 2011-12-18 21:09 编辑

之前用DZ7.2, UC1.5的时候整合没问题,升级到X2和UC1.6通信就失败了,请问是不是PHPCMS的UC接口文件不匹配导致的,

PC的接口文件如下:

  1. <?php
  2. define('UC_VERSION', '1.0.0');  //UCenter 版本标识

  3. define('API_DELETEUSER', 1);  //用户删除 API 接口开关
  4. define('API_RENAMEUSER', 1);  //用户改名 API 接口开关
  5. define('API_UPDATEPW', 1);  //用户改密码 API 接口开关
  6. define('API_GETTAG', 1);  //获取标签 API 接口开关
  7. define('API_SYNLOGIN', 1);  //同步登录 API 接口开关
  8. define('API_SYNLOGOUT', 1);  //同步登出 API 接口开关
  9. define('API_UPDATEBADWORDS', 1); //更新关键字列表 开关
  10. define('API_UPDATEHOSTS', 1);  //更新域名解析缓存 开关
  11. define('API_UPDATEAPPS', 1);  //更新应用列表 开关
  12. define('API_UPDATECLIENT', 1);  //更新客户端缓存 开关
  13. define('API_UPDATECREDIT', 1);  //更新用户积分 开关
  14. define('API_GETCREDITSETTINGS', 1); //向 UCenter 提供积分设置 开关
  15. define('API_UPDATECREDITSETTINGS', 1); //更新应用积分设置 开关
  16. define('API_RETURN_SUCCEED', '1');
  17. define('API_RETURN_FAILED', '-1');
  18. define('API_RETURN_FORBIDDEN', '-2');
  19. include '../include/common.inc.php';
  20. if(!$PHPCMS['uc'])  exit('Ucenter client disabled !');
  21. require PHPCMS_ROOT.'member/include/common.inc.php';
  22. require PHPCMS_ROOT.'member/api/client/client.php';
  23. parse_str(uc_authcode($code, 'DECODE', UC_KEY), $arr) ;
  24. if(TIME - intval($arr['time']) > 3600)  exit('Authracation has expiried');
  25. if(empty($arr)) exit('Invalid Request');
  26. $action = $arr['action'];
  27. if ($action=='test')  exit('1');
  28. if ($action=='deleteuser')
  29. {
  30. $touserid = intval(substr($arr['ids'],1,-1));
  31. $r = $member->get_by_touserid($touserid,'userid');
  32. $userid = $r['userid'];
  33. $member->delete($userid);
  34. exit(API_RETURN_SUCCEED);
  35. }
  36. if($action=='updatepw')
  37. {
  38. !API_UPDATEPW && exit(API_RETURN_FORBIDDEN);
  39. //更改用户密码
  40. exit(API_RETURN_SUCCEED);
  41. }
  42. if($action == 'synlogin')
  43. {
  44. $userid = $member->get_userid($arr['username']);
  45. $userinfo = $member->get($userid);
  46. if(!$userinfo){
  47.   $uc_userinfo=uc_call('uc_get_user',array($arr['username'],0));
  48.   if($uc_userinfo[0]>0){
  49.    require_once MOD_ROOT.'api/member_api.class.php';
  50.    $member_api = new member_api();
  51.    $arr_member['touserid'] = $uc_userinfo[0];
  52.    $arr_member['registertime'] = TIME;
  53.    $arr_member['lastlogintime'] = TIME;
  54.    $arr_member['username'] = $uc_userinfo[1];
  55.    $arr_member['password'] = md5(PASSWORD_KEY.$password) ;
  56.    $arr_member['email'] = $uc_userinfo[2];
  57.    $arr_member['modelid'] = 10;
  58.    $member_api->add($arr_member);
  59.    $userid = $member->get_userid($arr['username']);
  60.    $userinfo = $member->get($userid);
  61.   }
  62. }
  63. if(!$userinfo){exit(0);}
  64. extract($userinfo);
  65. if(!$cookietime) $get_cookietime = 86400 * 365;
  66. $_cookietime = $cookietime ? intval($cookietime) : ($get_cookietime ? $get_cookietime : 0);
  67. $cookietime = $_cookietime ? TIME + $_cookietime : 0;
  68. $phpcms_auth_key = md5(AUTH_KEY.$_SERVER['HTTP_USER_AGENT']);
  69. $phpcms_auth = phpcms_auth($userid."\t".$password, 'ENCODE', $phpcms_auth_key);
  70.     ob_clean() ;
  71.     header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
  72. set_cookie('auth', $phpcms_auth, $cookietime);
  73. set_cookie('username', $member->escape($arr['username']), $cookietime);
  74. set_cookie('cookietime', $_cookietime, $cookietime);
  75. exit('1');
  76. }
  77. if($action=='updatecredit')
  78. {
  79. $arr_credit = array(
  80.         1 => '`point`',
  81.         2 => '`amount`',
  82. );
  83. $credit = $arr['credit'];
  84. $creditField = $arr_credit[$credit];
  85. $amount=intval($arr['amount']);
  86. $uid = intval($arr['uid']);
  87. $userinfo = $member->get_by_touserid($uid);
  88. $username = $userinfo['username'];
  89. if(!$username || !$amount)  exit(API_RETURN_SUCCEED);
  90. $db->query("update ".DB_PRE."member set $creditField=$creditField+$amount where username='$username' ");
  91. $db->query("update ".DB_PRE."member_cache set $creditField=$creditField+$amount where username='$username' ");
  92. exit('1');
  93. }
  94. if($action=='synlogout')
  95. {
  96.     header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
  97. set_cookie('auth', '', -3600);
  98. set_cookie('username', '', -3600);
  99. }
  100. if($action == 'getcreditsettings')
  101. {
  102. !API_GETCREDITSETTINGS && exit(API_RETURN_FORBIDDEN);
  103. $credits = array(
  104.         1 => array('点数', '点'),
  105.         2 => array('金钱', '元'),
  106. );
  107. echo uc_serialize($credits);
  108. }
  109. if($action == 'updateapps')
  110. {
  111. if(!API_UPDATEAPPS) {
  112.   return API_RETURN_FORBIDDEN;
  113. }
  114. include_once PHPCMS_ROOT.'member/api/client/lib/xml.class.php';
  115. $post = xml_unserialize(file_get_contents('php://input'));
  116. $cachefile = PHPCMS_ROOT.'member/api/client/data/cache/apps.php';
  117. $fp = fopen($cachefile, 'w');
  118. $s = "<?php\r\n";
  119. $s .= '$_CACHE[\'apps\'] = '.var_export($post, TRUE).";\r\n";
  120. fwrite($fp, $s);
  121. fclose($fp);
  122. exit(API_RETURN_SUCCEED);
  123. }
  124. if($action == 'updatecreditsettings') {
  125. !API_UPDATECREDITSETTINGS && exit(API_RETURN_FORBIDDEN);
  126. $outextcredits = array();
  127. foreach($arr['credit'] as $appid => $credititems) {
  128.   if($appid == UC_APPID) {
  129.    foreach($credititems as $value) {
  130.     $outextcredits[$value['appiddesc'].'|'.$value['creditdesc']] = array(
  131.      'creditsrc' => $value['creditsrc'],
  132.      'title' => $value['title'],
  133.      'unit' => $value['unit'],
  134.      'ratio' => $value['ratio']
  135.     );
  136.    }
  137.   }
  138. }
  139. cache_write('creditsettings.php', $outextcredits);
  140. exit('1');
  141. }
  142. ?>
复制代码
小弟不懂程序,还请版主和管理员看看到底是怎么回事。
BJ现在开始 发表于 2011-12-21 16:05:17 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

 楼主| 而特瑞特瑞特 发表于 2011-12-23 21:19:05 | 显示全部楼层
没人帮助么?
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-12-24 01:16 , Processed in 0.025832 second(s), 4 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

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