Completed
Push — master ( aab372...a42924 )
by Thierry
01:47
created
src/Utils/URI.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -25,16 +25,16 @@  discard block
 block discarded – undo
25 25
     {
26 26
         $aURL = [];
27 27
         // Try to get the request URL
28
-        if(!empty($_SERVER['REQUEST_URI']))
28
+        if (!empty($_SERVER['REQUEST_URI']))
29 29
         {
30
-            $_SERVER['REQUEST_URI'] = str_replace(array('"',"'",'<','>'), array('%22','%27','%3C','%3E'), $_SERVER['REQUEST_URI']);
30
+            $_SERVER['REQUEST_URI'] = str_replace(array('"', "'", '<', '>'), array('%22', '%27', '%3C', '%3E'), $_SERVER['REQUEST_URI']);
31 31
             $aURL = parse_url($_SERVER['REQUEST_URI']);
32 32
         }
33 33
 
34 34
         // Fill in the empty values
35
-        if(empty($aURL['scheme']))
35
+        if (empty($aURL['scheme']))
36 36
         {
37
-            if(!empty($_SERVER['HTTP_SCHEME']))
37
+            if (!empty($_SERVER['HTTP_SCHEME']))
38 38
             {
39 39
                 $aURL['scheme'] = $_SERVER['HTTP_SCHEME'];
40 40
             }
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
             }
45 45
         }
46 46
 
47
-        if(empty($aURL['host']))
47
+        if (empty($aURL['host']))
48 48
         {
49
-            if(!empty($_SERVER['HTTP_X_FORWARDED_HOST']))
49
+            if (!empty($_SERVER['HTTP_X_FORWARDED_HOST']))
50 50
             {
51
-                if(strpos($_SERVER['HTTP_X_FORWARDED_HOST'], ':') > 0)
51
+                if (strpos($_SERVER['HTTP_X_FORWARDED_HOST'], ':') > 0)
52 52
                 {
53 53
                     list($aURL['host'], $aURL['port']) = explode(':', $_SERVER['HTTP_X_FORWARDED_HOST']);
54 54
                 }
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
                     $aURL['host'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
58 58
                 }
59 59
             }
60
-            elseif(!empty($_SERVER['HTTP_HOST']))
60
+            elseif (!empty($_SERVER['HTTP_HOST']))
61 61
             {
62
-                if(strpos($_SERVER['HTTP_HOST'], ':') > 0)
62
+                if (strpos($_SERVER['HTTP_HOST'], ':') > 0)
63 63
                 {
64 64
                     list($aURL['host'], $aURL['port']) = explode(':', $_SERVER['HTTP_HOST']);
65 65
                 }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
                     $aURL['host'] = $_SERVER['HTTP_HOST'];
69 69
                 }
70 70
             }
71
-            elseif(!empty($_SERVER['SERVER_NAME']))
71
+            elseif (!empty($_SERVER['SERVER_NAME']))
72 72
             {
73 73
                 $aURL['host'] = $_SERVER['SERVER_NAME'];
74 74
             }
@@ -78,19 +78,19 @@  discard block
 block discarded – undo
78 78
             }
79 79
         }
80 80
 
81
-        if(empty($aURL['port']) && !empty($_SERVER['SERVER_PORT']))
81
+        if (empty($aURL['port']) && !empty($_SERVER['SERVER_PORT']))
82 82
         {
83 83
             $aURL['port'] = $_SERVER['SERVER_PORT'];
84 84
         }
85 85
 
86
-        if(!empty($aURL['path']) && strlen(basename($aURL['path'])) == 0)
86
+        if (!empty($aURL['path']) && strlen(basename($aURL['path'])) == 0)
87 87
         {
88 88
             unset($aURL['path']);
89 89
         }
90 90
 
91
-        if(empty($aURL['path']))
91
+        if (empty($aURL['path']))
92 92
         {
93
-            if(!empty($_SERVER['PATH_INFO']))
93
+            if (!empty($_SERVER['PATH_INFO']))
94 94
             {
95 95
                 $sPath = parse_url($_SERVER['PATH_INFO']);
96 96
             }
@@ -98,61 +98,61 @@  discard block
 block discarded – undo
98 98
             {
99 99
                 $sPath = parse_url($_SERVER['PHP_SELF']);
100 100
             }
101
-            if(isset($sPath['path']))
101
+            if (isset($sPath['path']))
102 102
             {
103
-                $aURL['path'] = str_replace(array('"',"'",'<','>'), array('%22','%27','%3C','%3E'), $sPath['path']);
103
+                $aURL['path'] = str_replace(array('"', "'", '<', '>'), array('%22', '%27', '%3C', '%3E'), $sPath['path']);
104 104
             }
105 105
             unset($sPath);
106 106
         }
107 107
 
108
-        if(empty($aURL['query']) && !empty($_SERVER['QUERY_STRING']))
108
+        if (empty($aURL['query']) && !empty($_SERVER['QUERY_STRING']))
109 109
         {
110 110
             $aURL['query'] = $_SERVER['QUERY_STRING'];
111 111
         }
112 112
 
113
-        if(!empty($aURL['query']))
113
+        if (!empty($aURL['query']))
114 114
         {
115
-            $aURL['query'] = '?'.$aURL['query'];
115
+            $aURL['query'] = '?' . $aURL['query'];
116 116
         }
117 117
 
118 118
         // Build the URL: Start with scheme, user and pass
119
-        $sURL = $aURL['scheme'].'://';
120
-        if(!empty($aURL['user']))
119
+        $sURL = $aURL['scheme'] . '://';
120
+        if (!empty($aURL['user']))
121 121
         {
122
-            $sURL.= $aURL['user'];
123
-            if(!empty($aURL['pass']))
122
+            $sURL .= $aURL['user'];
123
+            if (!empty($aURL['pass']))
124 124
             {
125
-                $sURL.= ':'.$aURL['pass'];
125
+                $sURL .= ':' . $aURL['pass'];
126 126
             }
127
-            $sURL.= '@';
127
+            $sURL .= '@';
128 128
         }
129 129
 
130 130
         // Add the host
131
-        $sURL.= $aURL['host'];
131
+        $sURL .= $aURL['host'];
132 132
 
133 133
         // Add the port if needed
134
-        if(!empty($aURL['port'])
134
+        if (!empty($aURL['port'])
135 135
                 && (($aURL['scheme'] == 'http' && $aURL['port'] != 80)
136 136
                         || ($aURL['scheme'] == 'https' && $aURL['port'] != 443)))
137 137
         {
138
-            $sURL.= ':'.$aURL['port'];
138
+            $sURL .= ':' . $aURL['port'];
139 139
         }
140 140
 
141 141
         // Add the path and the query string
142
-        $sURL.= $aURL['path'].@$aURL['query'];
142
+        $sURL .= $aURL['path'] . @$aURL['query'];
143 143
 
144 144
         // Clean up
145 145
         unset($aURL);
146 146
 
147 147
         $aURL = explode("?", $sURL);
148 148
 
149
-        if(1 < count($aURL))
149
+        if (1 < count($aURL))
150 150
         {
151 151
             $aQueries = explode("&", $aURL[1]);
152 152
 
153
-            foreach($aQueries as $sKey => $sQuery)
153
+            foreach ($aQueries as $sKey => $sQuery)
154 154
             {
155
-                if("jxnGenerate" == substr($sQuery, 0, 11))
155
+                if ("jxnGenerate" == substr($sQuery, 0, 11))
156 156
                     unset($aQueries[$sKey]);
157 157
             }
158 158
 
Please login to merge, or discard this patch.