1 頁 (共 1 頁)

[問題]關於common.php裡面的unset…

發表於 : 2007-06-13 16:52
dinobot14
●架設主機作業系統:freesco
●您的 phpBB2 版本:phpBB 2.0.22
●您的上網方式:中華電信adsl
(因為不是我自己架的,使用的程式我不太清楚,連結網址亦無,我都打ip,是變動的)

因為希望能夠藉由phpbb來更加了解php的應用
所以決定好好的看看phpbb是怎麼寫的
但是才看到common.php就搞不懂了 ˊˋ

目前看到這一段

代碼: 選擇全部

if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on')
{
	// PHP4+ path
	$not_unset = array('HTTP_GET_VARS', 'HTTP_POST_VARS', 'HTTP_COOKIE_VARS', 'HTTP_SERVER_VARS', 'HTTP_SESSION_VARS', 'HTTP_ENV_VARS', 'HTTP_POST_FILES', 'phpEx', 'phpbb_root_path');

	// Not only will array_merge give a warning if a parameter
	// is not an array, it will actually fail. So we check if
	// HTTP_SESSION_VARS has been initialised.
	if (!isset($HTTP_SESSION_VARS) || !is_array($HTTP_SESSION_VARS))
	{
		$HTTP_SESSION_VARS = array();
	}

	// Merge all into one extremely huge array; unset
	// this later
	$input = array_merge($HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS, $HTTP_SERVER_VARS, $HTTP_SESSION_VARS, $HTTP_ENV_VARS, $HTTP_POST_FILES);

	unset($input['input']);
	unset($input['not_unset']);

	while (list($var,) = @each($input))
	{
		if (in_array($var, $not_unset))
		{
			die('Hacking attempt!');
		}
		unset($$var);
	}

	unset($input);
}
我看得懂他每一行要幹的事情
但是我真是不懂他這一段組合起來的意義
為什麼要弄not_unset這個array
然後input在array_merge裡面並沒有merge到input跟not_unset啊
為什麼還要unset $input['input']) 跟 $input['not_unset']呢
還有while那邊檢查的東西
為什麼if (in_array... 成立的話就die了 @@"
我真的是不懂啊 > < 請問有人知道嗎 拜託教教我吧 <(_ _)>