Commit d972e2e0 authored by mikeytown2's avatar mikeytown2

Issue #1878454 by mikeytown2: Fix httprl_build_url_self when called from the command line.

parent 5c3ee552
......@@ -204,7 +204,7 @@ function httprl_build_url_self($path = '', $detect_schema = FALSE) {
// $_SERVER['SCRIPT_NAME'] can, in contrast to $_SERVER['PHP_SELF'], not
// be modified by a visitor.
if ($dir = trim(dirname($_SERVER['SCRIPT_NAME']), '\,/')) {
$base_path = "/$dir/";
$root_path = "/$dir/";
}
else {
$root_path = '/';
......@@ -217,8 +217,9 @@ function httprl_build_url_self($path = '', $detect_schema = FALSE) {
$root_path = '/';
}
// If ran from the command line SCRIPT_NAME contains the working directory.
elseif (!empty($_SERVER['PWD'])) {
$root_path = str_replace($_SERVER['PWD'] . '/', '', $root_path);
elseif (isset($_SERVER['argc']) || isset($_SERVER['argv'])) {
$cwd = isset($_SERVER['PWD']) ? $_SERVER['PWD'] : getcwd();
$root_path = str_replace($cwd . '/', '', $root_path);
}
// Server auth.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment