改进Request类

This commit is contained in:
thinkphp
2016-05-20 16:14:22 +08:00
parent d4993fa37c
commit 1ad2f7af31

View File

@@ -218,8 +218,12 @@ class Request
$this->url = $url;
return;
} elseif (!$this->url) {
if (IS_CLI) {
$this->url = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : '';
} else {
$this->url = $_SERVER[Config::get('url_request_uri')];
}
}
return true === $url ? $this->domain() . $this->url : $this->url;
}
@@ -252,6 +256,8 @@ class Request
$this->baseFile = $file;
return;
} elseif (!$this->baseFile) {
$url = '';
if (!IS_CLI) {
$script_name = basename($_SERVER['SCRIPT_FILENAME']);
if (basename($_SERVER['SCRIPT_NAME']) === $script_name) {
$url = $_SERVER['SCRIPT_NAME'];
@@ -264,6 +270,7 @@ class Request
} elseif (isset($_SERVER['DOCUMENT_ROOT']) && strpos($_SERVER['SCRIPT_FILENAME'], $_SERVER['DOCUMENT_ROOT']) === 0) {
$url = str_replace('\\', '/', str_replace($_SERVER['DOCUMENT_ROOT'], '', $_SERVER['SCRIPT_FILENAME']));
}
}
$this->baseFile = $url;
}
return true === $file ? $this->domain() . $this->baseFile : $this->baseFile;