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

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

论坛退出提示 “Access denied for agent changed” 处理方案及排查思路

[复制链接]
evenzhou 发表于 2012-7-24 14:18:43 | 显示全部楼层 |阅读模式
本帖最后由 evenzhou 于 2012-7-24 15:05 编辑

问题现象:
退出提示 “Access denied for agent changed”

排查思路:
这是与 uc请求的时候出问题导致。具体报错部分是uc_server/mode/user.php中的function init_input 函数部分的 ,对$agent进行了判断。
  1. if(($getagent && $getagent != $this->input['agent']) || (!$getagent && md5($_SERVER['HTTP_USER_AGENT']) != $agent)) {
  2.                                 exit('Access denied for agent changed');
  3.                         }
复制代码
下面我们来简单分析下退出的时候是怎么uc请求的,打开 class_member.php 找到 on_logout 函数部分 $ucsynlogout = $this->setting['allowsynlogin'] ? uc_user_synlogout() : ''; 这这么一行代码,这是判断程序是否开启了同步登录。如果开启了同步登录  uc_user_synlogout() 会执行请求
接下来,分析下uc_user_synlogout( 这些函数的调用是来自loaducenter()) 。打开 uc_client/client.php
  1. function uc_user_synlogout() {
  2.         if(@include UC_ROOT.'./data/cache/apps.php') {
  3.                 if(count($_CACHE['apps']) > 1) {
  4.                         $return = uc_api_post('user', 'synlogout', array());
  5.                 } else {
  6.                         $return = '';
  7.                 }
  8.         }
  9.         return $return;
  10. }
复制代码
使用post方式请求uc。 大家可以阅读下 uc_api_post  是怎么处理的 。uc_api_post中有 uc_api_requestdata 这么个函数
再看下  uc_api_input 函数。这个函数就是对输入内容进行处理 使用 uc_authcode进行加密处理,其中的UC_key 是咱们熟悉的config_ucenter.php中的 UC_KEY。 到此,大家应该对请求部分大体上有个了解,下面我们来看 uc_server端的接收

我们看到 uc_api_requestdata函数中的部分
  1. $post = "m=$module&a=$action&inajax=2&release=".UC_CLIENT_RELEASE."&input=$input&appid=".UC_APPID.$extra;
复制代码
然后使用 uc_fopen2(此函数原理,大家自行阅读在此不做介绍) 去请求。

打开uc_server/index.php文件
  1. if(in_array($m, array('app', 'frame', 'user', 'pm', 'pm_client', 'tag', 'feed', 'friend', 'domain', 'credit', 'mail', 'version'))) {

  2.         if(file_exists(UC_ROOT.RELEASE_ROOT."control/$m.php")) {
  3.                 include UC_ROOT.RELEASE_ROOT."control/$m.php";
  4.         } else {
  5.                 include UC_ROOT."control/$m.php";
  6.         }

  7.         $classname = $m.'control';
  8.         $control = new $classname();
  9.         $method = 'on'.$a;
  10.         if(method_exists($control, $method) && $a{0} != '_') {
  11.                 $data = $control->$method();
  12.                 echo is_array($data) ? $control->serialize($data, 1) : $data;
  13.                 exit;
  14.         } elseif(method_exists($control, '_call')) {
  15.                 $data = $control->_call('on'.$a, '');
  16.                 echo is_array($data) ? $control->serialize($data, 1) : $data;
  17.                 exit;
  18.         } else {
  19.                 exit('Action not found!');
  20.         }

  21. }
复制代码
会对用请求的内容进行处理,然后找到对应的模块就行响应请求。  退出的时候,程序会进入到 uc_server/model/base.php文件中的 init_input() 函数 $input = $this->authcode($input, 'DECODE', $this->app['authkey']); 如果这里的解压有问题。那么,就会导致出现 ‘Access denied for agent changed’ 这样的错误。

解决方法:
现在我们来分析下原因: 在这个请求的过程中,牵涉的到加密和解密两个部分,如果两个其中有一方的key不一样都会导致出现问题,用户要仔细检查 config_ucenter.php 中 UC_KEY 和 UC_APPID 是否与 uc_server/data/cache/apps.php中的 authkey和 appid (这里key 和appid 有时候会出现与ucenter中心的不一样问题,一般是文件权限导致)是否对应。 其次,有时候 域名有uc_api中的uc访问路径有问题的时候,请配置下 config_ucenter.php中的UC_IP







评分

1

查看全部评分

dicky57 发表于 2012-7-24 14:21:05 | 显示全部楼层
沙發支持下
感謝您的分享
回复

使用道具 举报

 楼主| evenzhou 发表于 2012-7-24 14:22:37 | 显示全部楼层
dicky57 发表于 2012-7-24 14:21
沙發支持下
感謝您的分享

神速
回复

使用道具 举报

装逼挨打扔潇洒 发表于 2012-7-24 14:24:21 | 显示全部楼层
我去  牛逼啊!
回复

使用道具 举报

otherbank 发表于 2012-7-24 14:26:49 | 显示全部楼层
不错
回复

使用道具 举报

m.king 发表于 2012-7-24 14:30:13 | 显示全部楼层
{:soso_e113:}  好厉害哈!!!!
回复

使用道具 举报

北北″ 发表于 2012-7-24 14:40:56 | 显示全部楼层
回复

使用道具 举报

ARCHY` 发表于 2012-7-24 14:41:23 | 显示全部楼层
前排支持了
回复

使用道具 举报

babyfacer 发表于 2012-7-24 14:41:26 | 显示全部楼层
dicky57 发表于 2012-7-24 14:21
沙發支持下
感謝您的分享

好快的呢
回复

使用道具 举报

64243354 发表于 2012-7-24 14:54:18 | 显示全部楼层
前排支持了
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-25 02:54 , Processed in 0.117432 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

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