]> git.mxchange.org Git - friendica.git/commitdiff
added spaces/curly braces and TODO for better using trim()
authorRoland Haeder <roland@mxchange.org>
Sat, 25 Mar 2017 11:53:01 +0000 (12:53 +0100)
committerRoland Haeder <roland@mxchange.org>
Sat, 25 Mar 2017 11:53:48 +0000 (12:53 +0100)
Signed-off-by: Roland Haeder <roland@mxchange.org>
boot.php

index 782b2e798d012955dde45f53cfe7762f8d459b78..57d265711d6a6d19ff1663d6fa1a694009f2151a 100644 (file)
--- 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