public function init($config)
{
// Fill in default request info when the script is run in command line
if (php_sapi_name() === 'cli') {
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['SERVER_NAME'] = 'localhost';
$_SERVER['SERVER_PORT'] = 80;
$_SERVER['HTTP_USER_AGENT'] = '';
}
// Info about server variables:
// PHP_SELF contains real URI (w/ path info, w/o query string)
// SCRIPT_NAME is the real URI for the requested script (w/o path info and query string)
// QUERY_STRING is the string following the '?' in the ur (eg the a=x part in http://foo/bar?a=x)
// REQUEST_URI contains the URI part entered in the browser address bar
// SCRIPT_FILENAME is the file path to the executing script
if (isset($_SERVER['REQUEST_URI'])) {
$this->_requestUri = $_SERVER['REQUEST_URI'];
} else {
// TBD: in this case, SCRIPT_NAME need to be escaped
$this->_requestUri = $_SERVER['SCRIPT_NAME'] . (empty($_SERVER['QUERY_STRING']) ? '' : '?' . $_SERVER['QUERY_STRING']);
}
if ($this->_cgiFix & self::CGIFIX__PATH_INFO && isset($_SERVER['ORIG_PATH_INFO'])) {
$this->_pathInfo = substr($_SERVER['ORIG_PATH_INFO'], strlen($_SERVER['SCRIPT_NAME']));
} elseif (isset($_SERVER['PATH_INFO'])) {
$this->_pathInfo = $_SERVER['PATH_INFO'];
} else {
if (strpos($_SERVER['PHP_SELF'], $_SERVER['SCRIPT_NAME']) === 0 && $_SERVER['PHP_SELF'] !== $_SERVER['SCRIPT_NAME']) {
$this->_pathInfo = substr($_SERVER['PHP_SELF'], strlen($_SERVER['SCRIPT_NAME']));
} else {
$this->_pathInfo = '';
}
}
if (get_magic_quotes_gpc()) {
if (isset($_GET)) {
$_GET = $this->stripSlashes($_GET);
}
if (isset($_POST)) {
$_POST = $this->stripSlashes($_POST);
}
if (isset($_REQUEST)) {
$_REQUEST = $this->stripSlashes($_REQUEST);
}
if (isset($_COOKIE)) {
$_COOKIE = $this->stripSlashes($_COOKIE);
}
}
$this->getApplication()->setRequest($this);
}