@@ -24,9 +24,9 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | private static function getHostFromServer(array &$aURL, $sKey) |
| 26 | 26 | { |
| 27 | - if(empty($aURL['host']) && !empty($_SERVER[$sKey])) |
|
| 27 | + if (empty($aURL['host']) && !empty($_SERVER[$sKey])) |
|
| 28 | 28 | { |
| 29 | - if(strpos($_SERVER[$sKey], ':') > 0) |
|
| 29 | + if (strpos($_SERVER[$sKey], ':') > 0) |
|
| 30 | 30 | { |
| 31 | 31 | list($aURL['host'], $aURL['port']) = explode(':', $_SERVER[$sKey]); |
| 32 | 32 | } |
@@ -46,20 +46,20 @@ discard block |
||
| 46 | 46 | { |
| 47 | 47 | $aURL = []; |
| 48 | 48 | // Try to get the request URL |
| 49 | - if(!empty($_SERVER['REQUEST_URI'])) |
|
| 49 | + if (!empty($_SERVER['REQUEST_URI'])) |
|
| 50 | 50 | { |
| 51 | - $_SERVER['REQUEST_URI'] = str_replace(['"',"'",'<','>'], ['%22','%27','%3C','%3E'], $_SERVER['REQUEST_URI']); |
|
| 51 | + $_SERVER['REQUEST_URI'] = str_replace(['"', "'", '<', '>'], ['%22', '%27', '%3C', '%3E'], $_SERVER['REQUEST_URI']); |
|
| 52 | 52 | $aURL = parse_url($_SERVER['REQUEST_URI']); |
| 53 | - if(!is_array($aURL)) |
|
| 53 | + if (!is_array($aURL)) |
|
| 54 | 54 | { |
| 55 | 55 | $aURL = []; |
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | // Fill in the empty values |
| 60 | - if(empty($aURL['scheme'])) |
|
| 60 | + if (empty($aURL['scheme'])) |
|
| 61 | 61 | { |
| 62 | - if(!empty($_SERVER['HTTP_SCHEME'])) |
|
| 62 | + if (!empty($_SERVER['HTTP_SCHEME'])) |
|
| 63 | 63 | { |
| 64 | 64 | $aURL['scheme'] = $_SERVER['HTTP_SCHEME']; |
| 65 | 65 | } |
@@ -72,24 +72,24 @@ discard block |
||
| 72 | 72 | self::getHostFromServer($aURL, 'HTTP_X_FORWARDED_HOST'); |
| 73 | 73 | self::getHostFromServer($aURL, 'HTTP_HOST'); |
| 74 | 74 | self::getHostFromServer($aURL, 'SERVER_NAME'); |
| 75 | - if(empty($aURL['host'])) |
|
| 75 | + if (empty($aURL['host'])) |
|
| 76 | 76 | { |
| 77 | 77 | throw new \Jaxon\Exception\URI(); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - if(empty($aURL['port']) && !empty($_SERVER['SERVER_PORT'])) |
|
| 80 | + if (empty($aURL['port']) && !empty($_SERVER['SERVER_PORT'])) |
|
| 81 | 81 | { |
| 82 | 82 | $aURL['port'] = $_SERVER['SERVER_PORT']; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - if(!empty($aURL['path']) && strlen(basename($aURL['path'])) == 0) |
|
| 85 | + if (!empty($aURL['path']) && strlen(basename($aURL['path'])) == 0) |
|
| 86 | 86 | { |
| 87 | 87 | unset($aURL['path']); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - if(empty($aURL['path'])) |
|
| 90 | + if (empty($aURL['path'])) |
|
| 91 | 91 | { |
| 92 | - if(!empty($_SERVER['PATH_INFO'])) |
|
| 92 | + if (!empty($_SERVER['PATH_INFO'])) |
|
| 93 | 93 | { |
| 94 | 94 | $sPath = parse_url($_SERVER['PATH_INFO']); |
| 95 | 95 | } |
@@ -97,61 +97,61 @@ discard block |
||
| 97 | 97 | { |
| 98 | 98 | $sPath = parse_url($_SERVER['PHP_SELF']); |
| 99 | 99 | } |
| 100 | - if(isset($sPath['path'])) |
|
| 100 | + if (isset($sPath['path'])) |
|
| 101 | 101 | { |
| 102 | - $aURL['path'] = str_replace(['"',"'",'<','>'], ['%22','%27','%3C','%3E'], $sPath['path']); |
|
| 102 | + $aURL['path'] = str_replace(['"', "'", '<', '>'], ['%22', '%27', '%3C', '%3E'], $sPath['path']); |
|
| 103 | 103 | } |
| 104 | 104 | unset($sPath); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - if(empty($aURL['query']) && !empty($_SERVER['QUERY_STRING'])) |
|
| 107 | + if (empty($aURL['query']) && !empty($_SERVER['QUERY_STRING'])) |
|
| 108 | 108 | { |
| 109 | 109 | $aURL['query'] = $_SERVER['QUERY_STRING']; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - if(!empty($aURL['query'])) |
|
| 112 | + if (!empty($aURL['query'])) |
|
| 113 | 113 | { |
| 114 | - $aURL['query'] = '?'.$aURL['query']; |
|
| 114 | + $aURL['query'] = '?' . $aURL['query']; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | // Build the URL: Start with scheme, user and pass |
| 118 | - $sURL = $aURL['scheme'].'://'; |
|
| 119 | - if(!empty($aURL['user'])) |
|
| 118 | + $sURL = $aURL['scheme'] . '://'; |
|
| 119 | + if (!empty($aURL['user'])) |
|
| 120 | 120 | { |
| 121 | - $sURL.= $aURL['user']; |
|
| 122 | - if(!empty($aURL['pass'])) |
|
| 121 | + $sURL .= $aURL['user']; |
|
| 122 | + if (!empty($aURL['pass'])) |
|
| 123 | 123 | { |
| 124 | - $sURL.= ':'.$aURL['pass']; |
|
| 124 | + $sURL .= ':' . $aURL['pass']; |
|
| 125 | 125 | } |
| 126 | - $sURL.= '@'; |
|
| 126 | + $sURL .= '@'; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | // Add the host |
| 130 | - $sURL.= $aURL['host']; |
|
| 130 | + $sURL .= $aURL['host']; |
|
| 131 | 131 | |
| 132 | 132 | // Add the port if needed |
| 133 | - if(!empty($aURL['port']) |
|
| 133 | + if (!empty($aURL['port']) |
|
| 134 | 134 | && (($aURL['scheme'] == 'http' && $aURL['port'] != 80) |
| 135 | 135 | || ($aURL['scheme'] == 'https' && $aURL['port'] != 443))) |
| 136 | 136 | { |
| 137 | - $sURL.= ':'.$aURL['port']; |
|
| 137 | + $sURL .= ':' . $aURL['port']; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | // Add the path and the query string |
| 141 | - $sURL.= $aURL['path'].@$aURL['query']; |
|
| 141 | + $sURL .= $aURL['path'] . @$aURL['query']; |
|
| 142 | 142 | |
| 143 | 143 | // Clean up |
| 144 | 144 | unset($aURL); |
| 145 | 145 | |
| 146 | 146 | $aURL = explode("?", $sURL); |
| 147 | 147 | |
| 148 | - if(1 < count($aURL)) |
|
| 148 | + if (1 < count($aURL)) |
|
| 149 | 149 | { |
| 150 | 150 | $aQueries = explode("&", $aURL[1]); |
| 151 | 151 | |
| 152 | - foreach($aQueries as $sKey => $sQuery) |
|
| 152 | + foreach ($aQueries as $sKey => $sQuery) |
|
| 153 | 153 | { |
| 154 | - if("jxnGenerate" == substr($sQuery, 0, 11)) |
|
| 154 | + if ("jxnGenerate" == substr($sQuery, 0, 11)) |
|
| 155 | 155 | unset($aQueries[$sKey]); |
| 156 | 156 | } |
| 157 | 157 | |