[backcolor=rgb(255, 0, 255)]本文档适用于:
微信机器人 3.2.1 DZ建站学习研究分享
https://www.cgzz8.cn/t-11615-1-1.html
(出处: 草根吧)
更新论坛版本后机器人完全不回复的,请按本帖自行修改解决。是由于自己论坛升级时导致文件source/class/discuz/discuz_application.php的_xss_check()函数修改了导致的。
推荐大家到微信公众平台中,修改开发模式的接口网址为微信机器人的新接口
即网站地址后接source/plugin/wuxin_qqrobot/wxapi.php
使用此接口后,可不需要修改论坛文件,以下内容可忽略。
新版本的函数如下
private function _xss_check() {
static $check = array('\"', '>', '<', '\'', '(', ')', 'CONTENT-TRANSFER-ENCODING');
if(isset($_GET['formhash']) && $_GET['formhash'] !== formhash()) {
system_error('request_tainting');
}
if($_SERVER['REQUEST_METHOD'] == 'GET' ) {
$temp = $_SERVER['REQUEST_URI'];
} elseif(empty ($_GET['formhash'])) {
$temp = $_SERVER['REQUEST_URI'].file_get_contents('php://input');
} else {
$temp = '';
}
if(!empty($temp)) {
$temp = strtoupper(urldecode(urldecode($temp)));
foreach ($check as $str) {
if(strpos($temp, $str) !== false) {
system_error('request_tainting');
}
}
}
return true;
}
解决办法是将上面中的这一行[backcolor=rgb(247, 247, 247)] static $check = array('"', '>', '<', '\'', '(', ')', 'CONTENT-TRANSFER-ENCODING');
改成
[backcolor=rgb(247, 247, 247)]static $check = array('"', '\'', '(', ')', 'CONTENT-TRANSFER-ENCODING');
顺便说一句,该函数同样会导致很多手机客户端及插件工作不正常,如果你升级后,出现类似于
您当前的访问请求当中含有非法字符,已经被系统拒绝
的提示,同样可用本帖所说的办法解决。
有部分网站,可能仍然会有错误,那可以将此函数改成最老版本的写法
private function _xss_check() {
$temp = strtoupper(urldecode(urldecode($_SERVER['REQUEST_URI'])));
if(strpos($temp, '<') !== false || strpos($temp, '\"') !== false || strpos($temp, 'CONTENT-TRANSFER-ENCODING') !== false) {
system_error('request_tainting');
}
return true;
}