先看下边回答胡乱一串的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>qazz.sseuu.com - System Error</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="ROBOTS" content="NOINDEX,NOFOLLOW,NOARCHIVE" /> <style type="text/css"> <!-- body { background-color: white; color: black; font: 9pt/11pt verdana, arial, sans-serif;} #container { width: 1024px; } #message { width: 1024px; color: black; } .red {color: red;} a:link { font: 9pt/11pt verdana, arial, sans-serif; color: red; } a:visited { font: 9pt/11pt verdana, arial, sans-serif; color: #4e4e4e; } h1 { color: #FF0000; font: 18pt "Verdana"; margin-bottom: 0.5em;} .bg1{ background-color: #FFFFCC;} .bg2{ background-color: #EEEEEE;} .table {background: #AAAAAA; font: 11pt Menlo,Consolas,"Lucida Console"} .info { background: none repeat scroll 0 0 #F3F3F3; border: 0px solid #aaaaaa; border-radius: 10px 10px 10px 10px; color: #000000; font-size: 11pt; line-height: 160%; margin-bottom: 1em; padding: 1em; } .help { background: #F3F3F3; border-radius: 10px 10px 10px 10px; font: 12px verdana, arial, sans-serif; text-align: center; line-height: 160%; padding: 1em; } .sql { background: none repeat scroll 0 0 #FFFFCC; border: 1px solid #aaaaaa; color: #000000; font: arial, sans-serif; font-size: 9pt; line-height: 160%; margin-top: 1em; padding: 4px; } --> </style> </head> <body> <div id="container"> <h1>Discuz! System Error</h1> <div class='info'><li>您当前的访问请求当中含有非法字符,已经被系统拒绝</li></div> <div class="info"><p><strong>PHP Debug</strong></p><table cellpadding="5" cellspacing="1" width="100%" class="table"><tr><td><ul><li>[Line: 0022]66.php(discuz_application->init)</li><li>[Line: 0072]source/class/discuz/discuz_application.php(discuz_application->_init_misc)</li><li>[Line: 0596]source/class/discuz/discuz_application.php(discuz_application->_xss_check)</li><li>[Line:
----------------------------------------------------------------------------------------------------
Discuz!您当前的访问请求当中含有非法字符,已经被系统拒绝解决方案
转 http://www.xckey.com/1173.html
关于Discuz!中“您当前的访问请求当中含有非法字符,已经被系统拒绝”的问题,在添加或更新文章的时候经常出现,经测试发现出现这种情况更多的在使用工具(如火车头采集器)批量发布文章时出现,仔细分析发现,当发布的正文内容出现特殊符号(&,/,<,>等)时出现这样的错误提示。
出现这样的错误主要是因为Discuz!系统的_xss_check()函数原本的意义是为了论坛安全,防止XSS攻击,一般网站使用是不会出现什么问题的,但是有些网站要接入第三方接口,当第三方接口向本站post数据的时候就会报”您当前的访问请求当中含有非法字符,已经被系统拒绝”,本文介绍一种简单的修改方法避免此错误。
解决方案如下:
\source\class\discuz的discuz_application.php
查找如下代码(在360行左右),并替换
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 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; } |
替换为:
PHP
1 2 3 4 5 6 7 | 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; } |