Discuz! 您当前的访问请求当中含有非法字符-Discuz教程下载

Discuz! 您当前的访问请求当中含有非法字符

开通本站Svip会员,全站资源免费下
Discuz!系统的_xss_check()函数原本的意义是为了论坛安全,防止XSS攻击,一般网站使用是不会出现什么问题的,但是有些网站要接入第三方接口,当第三方接口向本站post数据的时候就会报"您当前的访问请求当中含有非法字符,已经被系统拒绝",本文介绍一种简单的修改方法避免此错误。

解决方案如下:

\source\class\discuz的discuz_application.php
查找
  1. private function _xss_check() {
  2.         static $check = array('"', '>', '<', '\'', '(', ')', 'CONTENT-TRANSFER-ENCODING');
  3.         if(isset($_GET['formhash']) && $_GET['formhash'] !== formhash()) {
  4.                         system_error('request_tainting');
  5.         }
  6.         if($_SERVER['REQUEST_METHOD'] == 'GET' ) {
  7.                         $temp = $_SERVER['REQUEST_URI'];
  8.         } elseif(empty ($_GET['formhash'])) {
  9.                         $temp = $_SERVER['REQUEST_URI'].file_get_contents('php://input');
  10.         } else {
  11.                         $temp = '';
  12.         }
  13.         if(!empty($temp)) {
  14.                 $temp = strtoupper(urldecode(urldecode($temp)));
  15.                 foreach ($check as $str) {
  16.                                 if(strpos($temp, $str) !== false) {
  17.                                                 system_error('request_tainting');
  18.                                 }
  19.                 }
  20.         }
  21.         return true;
  22. }
复制代码
替换为:

  1. private function _xss_check() {
  2.         $temp = strtoupper(urldecode(urldecode($_SERVER['REQUEST_URI'])));
  3.         if(strpos($temp, '<') !== false || strpos($temp, '"') !== false || strpos($temp, 'CONTENT-TRANSFER-ENCODING') !== false) {
  4.                         system_error('request_tainting');
  5.         }
  6.         return true;
  7. }
复制代码
Discuz!系统的_xss_check()函数原本的意义是为了论坛安全,防止XSS攻击,一般网站使用是不会出现什么问题的,但是有些网站要接入第三方接口,当第三方接口向本站post数据的时候就会报”您当前的访问请求当中含有非法字符,已经被系统拒绝”,本文介绍一种简单的修改方法避免此错误。
解决方案如下:\source\class\discuz的discuz_application.php
查找
  1. private function _xss_check() {
  2.         static $check = array('"', '>', '<', '\'', '(', ')', 'CONTENT-TRANSFER-ENCODING');
  3.         if(isset($_GET['formhash']) && $_GET['formhash'] !== formhash()) {
  4.                         system_error('request_tainting');
  5.         }
  6.         if($_SERVER['REQUEST_METHOD'] == 'GET' ) {
  7.                         $temp = $_SERVER['REQUEST_URI'];
  8.         } elseif(empty ($_GET['formhash'])) {
  9.                         $temp = $_SERVER['REQUEST_URI'].file_get_contents('php://input');
  10.         } else {
  11.                         $temp = '';
  12.         }
  13.         if(!empty($temp)) {
  14.                 $temp = strtoupper(urldecode(urldecode($temp)));
  15.                 foreach ($check as $str) {
  16.                                 if(strpos($temp, $str) !== false) {
  17.                                                 system_error('request_tainting');
  18.                                 }
  19.                 }
  20.         }
  21.         return true;
  22. }
复制代码
替换为:
  1. private function _xss_check() {
  2.         $temp = strtoupper(urldecode(urldecode($_SERVER['REQUEST_URI'])));
  3.         if(strpos($temp, '<') !== false || strpos($temp, '"') !== false || strpos($temp, 'CONTENT-TRANSFER-ENCODING') !== false) {
  4.                         system_error('request_tainting');
  5.         }
  6.         return true;
  7. }
复制代码

全部评论 0

您需要登录后才可以回帖 立即登录
登录
0
0
0
返回顶部