星期三, 九月 27, 2006

对外界环境进行兼容设置 learn wordpress (5)

对外界环境进行兼容设置

// Fix for IIS, which doesn't set REQUEST_URI
# 如果没有设定 REQUEST_URI 则根据其他参数进行设定 REQUEST_URI="SCRIPT_NAME?QUERY_STRING";
if ( empty( $_SERVER['REQUEST_URI'] ) ) {
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']; // Does this work under CGI?

// Append the query string if it exists and isn't null
if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
$_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
}
}

// Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests
# 如果是通过CGI来处理的则将SCRIPT_FILENAME重定义为最终的处理文件 SCRIPT_FILENAME="PATH_TRANSLATED";

if ( isset($_SERVER['SCRIPT_FILENAME']) && ( strpos($_SERVER['SCRIPT_FILENAME'], 'php.cgi') == strlen($_SERVER['SCRIPT_FILENAME']) - 7 ) )
$_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];

// Fix for Dreamhost and other PHP as CGI hosts
if ( strstr( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) )
unset($_SERVER['PATH_INFO']);

// Fix empty PHP_SELF
# 构建PHP_SELF
$PHP_SELF = $_SERVER['PHP_SELF'];
if ( empty($PHP_SELF) )
$_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace("/(\?.*)?$/",'',$_SERVER["REQUEST_URI"]);

-- wp-settings.php
其实所谓兼容就是不同的外部环境给定的变量有些差异。
这些我没有用过姑且留之。

没有评论: