本文整理汇总了PHP中path::isInWebfolder方法的典型用法代码示例。如果您正苦于以下问题:PHP path::isInWebfolder方法的具体用法?PHP path::isInWebfolder怎么用?PHP path::isInWebfolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类path
的用法示例。
在下文中一共展示了path::isInWebfolder方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
// include some initial assertions on current context providing minimum
// set of expected information
assert('$_SERVER["HTTP_HOST"]');
assert('$_SERVER["DOCUMENT_ROOT"]');
assert('$_SERVER["SCRIPT_FILENAME"]');
/*
* PHASE 1: Detect basic pathnames and URL components
*/
$this->frameworkPathname = dirname(dirname(__FILE__));
$this->installationPathname = dirname($this->frameworkPathname);
$this->isHTTPS = $_SERVER['HTTPS'] != false || $_SERVER['HTTP_X_HTTPS'] != false;
// analyse special case of working behind reverse proxy
if (array_key_exists('HTTP_X_ORIGINAL_URL', $_SERVER)) {
$url = parse_url($_SERVER['HTTP_X_ORIGINAL_URL']);
$this->hostname = $url['host'];
$proxyPrefix = $url['path'];
} else {
$proxyPrefix = false;
}
if (trim($this->hostname) === '') {
$this->hostname = $_SERVER['HTTP_HOST'];
}
/*
* PHASE 2: Validate and detect current application
*/
// validate location of processing script ...
// ... must be inside document root
if (path::isInWebfolder($_SERVER['SCRIPT_FILENAME']) === false) {
throw new \InvalidArgumentException('script is not part of webspace');
}
// ... must be inside installation folder of TXF
$this->scriptPathname = path::relativeToAnother($this->installationPathname, realpath($_SERVER['SCRIPT_FILENAME']));
if ($this->scriptPathname === false) {
throw new \InvalidArgumentException('script is not part of TXF installation');
}
// derive URL's path prefix to select folder containing TXF installation
$this->prefixPathname = path::relativeToAnother(realpath(static::getDocumentRoot()), $this->installationPathname);
if ($this->prefixPathname === false) {
// installation's folder might be linked into document root using symlink
// --> comparing pathname of current script with document root will fail then
// --> try alternative method to find prefix pathname
$this->prefixPathname = path::relativeToAnother(static::getDocumentRoot(), dirname($_SERVER['SCRIPT_FILENAME']));
}
// running behind reverse proxy?
if ($proxyPrefix) {
// detect prefix used to control that reverse proxy
$request = implode('/', $this->getRequestedScriptUri($dummy));
$split = strpos($proxyPrefix, $request);
if ($split >= 0) {
// extract prefix required by reverse proxy
$proxyPrefix = substr($proxyPrefix, 0, $split);
// prepend extracted prefix of reverse proxy to previously
// detected prefix used to address installation of TXF locally
$this->prefixPathname = path::glue($proxyPrefix, $this->prefixPathname);
}
}
// cache some derivable names
list($this->applicationPathname, $this->applicationScriptPathname) = path::stripCommonPrefix($this->scriptPathname, $this->prefixPathname, null);
// compile base URL of current installation
$this->url = path::glue(($this->isHTTPS ? 'https://' : 'http://') . $this->hostname, $this->prefixPathname);
// detect current application
$this->application = application::current($this);
}