馬上注冊,結(jié)交更多好友,享用更多功能,讓你輕松玩轉(zhuǎn)社區(qū)
您需要 登錄 才可以下載或查看,沒有賬號?立即注冊
×
Discuz!系統(tǒng)的_xss_check()函數(shù)原本的意義是為了論壇安全,防止XSS攻擊,一般網(wǎng)站使用是不會出現(xiàn)什么問題的,但是有些網(wǎng)站要使用設(shè)置遠(yuǎn)程變量或私人變量的API,當(dāng)API向本站post數(shù)據(jù)的時候就會報"您當(dāng)前的訪問請求當(dāng)中含有非法字符,已經(jīng)被系統(tǒng)拒絕",本文介紹一種簡單的修改方法避免此錯誤。
解決方案如下:
\source\class\discuz的discuz_application.php 查找 [PHP] 純文本查看 復(fù)制代碼 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] 純文本查看 復(fù)制代碼 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;
}
轉(zhuǎn)載請注明來源于:新秀網(wǎng)絡(luò)驗證論壇
|