diff --git a/boot.php b/boot.php index 782b2e798d..57d265711d 100644 --- a/boot.php +++ b/boot.php @@ -655,12 +655,13 @@ class App { $this->scheme = 'http'; - if ((x($_SERVER,'HTTPS') && $_SERVER['HTTPS']) || + /// @TODO x() should be better used here ... + if ((x($_SERVER, 'HTTPS') && $_SERVER['HTTPS']) || (x($_SERVER['HTTP_FORWARDED']) && preg_match("/proto=https/", $_SERVER['HTTP_FORWARDED'])) || (x($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') || (x($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') || (x($_SERVER['FRONT_END_HTTPS']) && $_SERVER['FRONT_END_HTTPS'] == 'on') || - (x($_SERVER,'SERVER_PORT') && (intval($_SERVER['SERVER_PORT']) == 443)) // XXX: reasonable assumption, but isn't this hardcoding too much? + (x($_SERVER, 'SERVER_PORT') && (intval($_SERVER['SERVER_PORT']) == 443)) // XXX: reasonable assumption, but isn't this hardcoding too much? ) { $this->scheme = 'https'; } @@ -692,22 +693,26 @@ class App { $_SERVER["argc"] --; } - if ((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,9) === "pagename=") { + if ((x($_SERVER, 'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 9) === "pagename=") { $this->query_string = substr($_SERVER['QUERY_STRING'],9); // removing trailing / - maybe a nginx problem - if (substr($this->query_string, 0, 1) == "/") + /// @TODO can be shortened by trim($str, '/') ! + if (substr($this->query_string, 0, 1) == "/") { $this->query_string = substr($this->query_string, 1); - } elseif ((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) === "q=") { + } + } elseif ((x($_SERVER, 'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 2) === "q=") { $this->query_string = substr($_SERVER['QUERY_STRING'],2); // removing trailing / - maybe a nginx problem - if (substr($this->query_string, 0, 1) == "/") + /// @TODO can be shortened by trim($str, '/') ! + if (substr($this->query_string, 0, 1) == "/") { $this->query_string = substr($this->query_string, 1); + } } - if (x($_GET,'pagename')) { - $this->cmd = trim($_GET['pagename'],'/\\'); - } elseif (x($_GET,'q')) { - $this->cmd = trim($_GET['q'],'/\\'); + if (x($_GET, 'pagename')) { + $this->cmd = trim($_GET['pagename'], '/\\'); + } elseif (x($_GET, 'q')) { + $this->cmd = trim($_GET['q'], '/\\'); } @@ -715,9 +720,8 @@ class App { $this->query_string = str_replace($this->cmd."&",$this->cmd."?", $this->query_string); // unix style "homedir" - - if (substr($this->cmd,0,1) === '~') { - $this->cmd = 'profile/' . substr($this->cmd,1); + if (substr($this->cmd, 0, 1) === '~') { + $this->cmd = 'profile/' . substr($this->cmd, 1); } // Diaspora style profile url