Discuz教程网

Discuz论坛退出提示Access denied for agent changed解决方法

[复制链接]
authicon dly 发表于 2012-7-24 19:53:48 | 显示全部楼层 |阅读模式
论坛退出提示 “Access denied for agent changed” 与 uc请求的时候出问题导致。之前在UC通信问题故障解决方法中已经说过解决方法,今天在站帮网分析下:具体报错部分是uc_server/mode/user.php中的
function init_input 函数部分的
  1. if(($getagent && $getagent != $this->input['agent']) || (!$getagent && md5($_SERVER['HTTP_USER_AGENT']) != $agent)) {
  2. exit('Access denied for agent changed');
  3. }
复制代码

对$agent进行了判断。

下面我们来简单分析下退出的时候。是怎么uc请求的

打开 class_member.php 找到 on_lo**t 函数部分
  1. $ucsynlo**t = $this->setting['allowsynlogin'] ? uc_user_synlo**t() : '';
复制代码

这这么一行代码,这是判断程序是否开启了同步登录。如果开启了同步登录  uc_user_synlo**t() 会执行请求
接下来,分析下uc_user_synlo**t( 这些函数的调用是来自loaducenter()) 。

打开 uc_client/client.php
  1. function uc_user_synlo**t() {
  2. if(@include UC_ROOT.'./data/cache/apps.php') {
  3. if(count($_CACHE['apps']) > 1) {
  4. $return = uc_api_post('user', 'synlo**t', 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’ 这样的错误。

现在我们来分析下退出提示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



上一篇:后台登陆不进去怎么办?
下一篇:Dvbbs 转换到 Discuz X2.5 专用转换工具---XConvert_for_dvbbs【20120604】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2025-5-2 12:56

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

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