protected static function documentRoot()
{
$strDocumentRoot = '';
$arrUriSegments = array();
$scriptName = static::get('scriptName');
$scriptFilename = static::get('scriptFilename');
// Fallback to DOCUMENT_ROOT if SCRIPT_FILENAME and SCRIPT_NAME point to different files
if (basename($scriptName) != basename($scriptFilename)) {
return str_replace('//', '/', strtr(realpath($_SERVER['DOCUMENT_ROOT']), '\\', '/'));
}
if (substr($scriptFilename, 0, 1) == '/') {
$strDocumentRoot = '/';
}
$arrSnSegments = explode('/', strrev($scriptName));
$arrSfnSegments = explode('/', strrev($scriptFilename));
foreach ($arrSfnSegments as $k => $v) {
if (@$arrSnSegments[$k] != $v) {
$arrUriSegments[] = $v;
}
}
$strDocumentRoot .= strrev(implode('/', $arrUriSegments));
if (strlen($strDocumentRoot) < 2) {
$strDocumentRoot = substr($scriptFilename, 0, -(strlen($strDocumentRoot) + 1));
}
return str_replace('//', '/', strtr(realpath($strDocumentRoot), '\\', '/'));
}