啦啦啦,今天發現discuzx的一個真正意義上的BUG!!!

bug位置function_core.php第2114行的ipbanned函數,估計是涉及到discuzx的所有版本啦:

function ipbanned($onlineip) {
	global $_G;

	if($_G['setting']['ipaccess'] && !ipaccess($onlineip, $_G['setting']['ipaccess'])) {
		return TRUE;
	}

	loadcache('ipbanned');
	if(empty($_G['cache']['ipbanned'])) {
		return FALSE;
	} else {
		if($_G['cache']['ipbanned']['expiration'] < TIMESTAMP) {
			require_once libfile('function/cache');
			updatecache('ipbanned');
		}

		//modify by zhangwenbo at 2011-11-03 10:37
		$onlineip = str_replace('.', '\\.', $onlineip);
		if(strpos($_G['cache']['ipbanned']['regexp'], $onlineip) === false) {
			return false;
		}

		return true;
		//return preg_match("/^(".$_G['cache']['ipbanned']['regexp'].")$/", $onlineip);
	}
}


錯誤原因:preg_match的第一個參數只能接受40066個字節的字符串,否則將出現“Warning: preg_match(): Compilation failed: regular expression is too large at offset 40066 in E:\www\test\test.php on line 6”,但對於一些大站來講,這40066個字節是遠遠不夠用的,因此我改如上。當然,一般的小站肯定是不會碰到這種問題的啦,呵呵...

發佈了65 篇原創文章 · 獲贊 57 · 訪問量 18萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章