@@ -21,6 +21,7 @@ |
||
21 | 21 | * |
22 | 22 | * @var array &$aURL The URL data |
23 | 23 | * @var string $sKey The key in the $_SERVER array |
24 | + * @param string $sKey |
|
24 | 25 | */ |
25 | 26 | private static function getHostFromServer(array &$aURL, $sKey) |
26 | 27 | { |
@@ -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,16 +46,16 @@ 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 | 53 | } |
54 | 54 | |
55 | 55 | // Fill in the empty values |
56 | - if(empty($aURL['scheme'])) |
|
56 | + if (empty($aURL['scheme'])) |
|
57 | 57 | { |
58 | - if(!empty($_SERVER['HTTP_SCHEME'])) |
|
58 | + if (!empty($_SERVER['HTTP_SCHEME'])) |
|
59 | 59 | { |
60 | 60 | $aURL['scheme'] = $_SERVER['HTTP_SCHEME']; |
61 | 61 | } |
@@ -68,24 +68,24 @@ discard block |
||
68 | 68 | self::getHostFromServer($aURL, 'HTTP_X_FORWARDED_HOST'); |
69 | 69 | self::getHostFromServer($aURL, 'HTTP_HOST'); |
70 | 70 | self::getHostFromServer($aURL, 'SERVER_NAME'); |
71 | - if(empty($aURL['host'])) |
|
71 | + if (empty($aURL['host'])) |
|
72 | 72 | { |
73 | 73 | throw new \Jaxon\Exception\URI(); |
74 | 74 | } |
75 | 75 | |
76 | - if(empty($aURL['port']) && !empty($_SERVER['SERVER_PORT'])) |
|
76 | + if (empty($aURL['port']) && !empty($_SERVER['SERVER_PORT'])) |
|
77 | 77 | { |
78 | 78 | $aURL['port'] = $_SERVER['SERVER_PORT']; |
79 | 79 | } |
80 | 80 | |
81 | - if(!empty($aURL['path']) && strlen(basename($aURL['path'])) == 0) |
|
81 | + if (!empty($aURL['path']) && strlen(basename($aURL['path'])) == 0) |
|
82 | 82 | { |
83 | 83 | unset($aURL['path']); |
84 | 84 | } |
85 | 85 | |
86 | - if(empty($aURL['path'])) |
|
86 | + if (empty($aURL['path'])) |
|
87 | 87 | { |
88 | - if(!empty($_SERVER['PATH_INFO'])) |
|
88 | + if (!empty($_SERVER['PATH_INFO'])) |
|
89 | 89 | { |
90 | 90 | $sPath = parse_url($_SERVER['PATH_INFO']); |
91 | 91 | } |
@@ -93,61 +93,61 @@ discard block |
||
93 | 93 | { |
94 | 94 | $sPath = parse_url($_SERVER['PHP_SELF']); |
95 | 95 | } |
96 | - if(isset($sPath['path'])) |
|
96 | + if (isset($sPath['path'])) |
|
97 | 97 | { |
98 | - $aURL['path'] = str_replace(['"',"'",'<','>'], ['%22','%27','%3C','%3E'], $sPath['path']); |
|
98 | + $aURL['path'] = str_replace(['"', "'", '<', '>'], ['%22', '%27', '%3C', '%3E'], $sPath['path']); |
|
99 | 99 | } |
100 | 100 | unset($sPath); |
101 | 101 | } |
102 | 102 | |
103 | - if(empty($aURL['query']) && !empty($_SERVER['QUERY_STRING'])) |
|
103 | + if (empty($aURL['query']) && !empty($_SERVER['QUERY_STRING'])) |
|
104 | 104 | { |
105 | 105 | $aURL['query'] = $_SERVER['QUERY_STRING']; |
106 | 106 | } |
107 | 107 | |
108 | - if(!empty($aURL['query'])) |
|
108 | + if (!empty($aURL['query'])) |
|
109 | 109 | { |
110 | - $aURL['query'] = '?'.$aURL['query']; |
|
110 | + $aURL['query'] = '?' . $aURL['query']; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | // Build the URL: Start with scheme, user and pass |
114 | - $sURL = $aURL['scheme'].'://'; |
|
115 | - if(!empty($aURL['user'])) |
|
114 | + $sURL = $aURL['scheme'] . '://'; |
|
115 | + if (!empty($aURL['user'])) |
|
116 | 116 | { |
117 | - $sURL.= $aURL['user']; |
|
118 | - if(!empty($aURL['pass'])) |
|
117 | + $sURL .= $aURL['user']; |
|
118 | + if (!empty($aURL['pass'])) |
|
119 | 119 | { |
120 | - $sURL.= ':'.$aURL['pass']; |
|
120 | + $sURL .= ':' . $aURL['pass']; |
|
121 | 121 | } |
122 | - $sURL.= '@'; |
|
122 | + $sURL .= '@'; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | // Add the host |
126 | - $sURL.= $aURL['host']; |
|
126 | + $sURL .= $aURL['host']; |
|
127 | 127 | |
128 | 128 | // Add the port if needed |
129 | - if(!empty($aURL['port']) |
|
129 | + if (!empty($aURL['port']) |
|
130 | 130 | && (($aURL['scheme'] == 'http' && $aURL['port'] != 80) |
131 | 131 | || ($aURL['scheme'] == 'https' && $aURL['port'] != 443))) |
132 | 132 | { |
133 | - $sURL.= ':'.$aURL['port']; |
|
133 | + $sURL .= ':' . $aURL['port']; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | // Add the path and the query string |
137 | - $sURL.= $aURL['path'].@$aURL['query']; |
|
137 | + $sURL .= $aURL['path'] . @$aURL['query']; |
|
138 | 138 | |
139 | 139 | // Clean up |
140 | 140 | unset($aURL); |
141 | 141 | |
142 | 142 | $aURL = explode("?", $sURL); |
143 | 143 | |
144 | - if(1 < count($aURL)) |
|
144 | + if (1 < count($aURL)) |
|
145 | 145 | { |
146 | 146 | $aQueries = explode("&", $aURL[1]); |
147 | 147 | |
148 | - foreach($aQueries as $sKey => $sQuery) |
|
148 | + foreach ($aQueries as $sKey => $sQuery) |
|
149 | 149 | { |
150 | - if("jxnGenerate" == substr($sQuery, 0, 11)) |
|
150 | + if ("jxnGenerate" == substr($sQuery, 0, 11)) |
|
151 | 151 | unset($aQueries[$sKey]); |
152 | 152 | } |
153 | 153 |
@@ -29,8 +29,7 @@ discard block |
||
29 | 29 | if(strpos($_SERVER[$sKey], ':') > 0) |
30 | 30 | { |
31 | 31 | list($aURL['host'], $aURL['port']) = explode(':', $_SERVER[$sKey]); |
32 | - } |
|
33 | - else |
|
32 | + } else |
|
34 | 33 | { |
35 | 34 | $aURL['host'] = $_SERVER[$sKey]; |
36 | 35 | } |
@@ -58,8 +57,7 @@ discard block |
||
58 | 57 | if(!empty($_SERVER['HTTP_SCHEME'])) |
59 | 58 | { |
60 | 59 | $aURL['scheme'] = $_SERVER['HTTP_SCHEME']; |
61 | - } |
|
62 | - else |
|
60 | + } else |
|
63 | 61 | { |
64 | 62 | $aURL['scheme'] = ((!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') ? 'https' : 'http'); |
65 | 63 | } |
@@ -88,8 +86,7 @@ discard block |
||
88 | 86 | if(!empty($_SERVER['PATH_INFO'])) |
89 | 87 | { |
90 | 88 | $sPath = parse_url($_SERVER['PATH_INFO']); |
91 | - } |
|
92 | - else |
|
89 | + } else |
|
93 | 90 | { |
94 | 91 | $sPath = parse_url($_SERVER['PHP_SELF']); |
95 | 92 | } |
@@ -147,8 +144,9 @@ discard block |
||
147 | 144 | |
148 | 145 | foreach($aQueries as $sKey => $sQuery) |
149 | 146 | { |
150 | - if("jxnGenerate" == substr($sQuery, 0, 11)) |
|
151 | - unset($aQueries[$sKey]); |
|
147 | + if("jxnGenerate" == substr($sQuery, 0, 11)) { |
|
148 | + unset($aQueries[$sKey]); |
|
149 | + } |
|
152 | 150 | } |
153 | 151 | |
154 | 152 | $sQueries = implode("&", $aQueries); |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | { |
130 | 130 | $xDefault = $this->xConfig->getOption('upload.default.' . $sProperty); |
131 | 131 | $aAllowed = $this->xConfig->getOption('upload.files.' . $sName . '.' . $sProperty, $xDefault); |
132 | - if(is_array($aAllowed) && !in_array($sValue, $aAllowed)) |
|
132 | + if (is_array($aAllowed) && !in_array($sValue, $aAllowed)) |
|
133 | 133 | { |
134 | 134 | $this->sErrorMessage = $this->xTranslator->trans('errors.upload.' . $sField, [$sField = $sValue]); |
135 | 135 | return false; |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | { |
151 | 151 | $xDefault = $this->xConfig->getOption('upload.default.' . $sProperty, 0); |
152 | 152 | $iSize = $this->xConfig->getOption('upload.files.' . $sName . '.' . $sProperty, $xDefault); |
153 | - if($iSize > 0 && ( |
|
153 | + if ($iSize > 0 && ( |
|
154 | 154 | ($sProperty == 'max-size' && $iFileSize > $iSize) || |
155 | 155 | ($sProperty == 'min-size' && $iFileSize < $iSize))) |
156 | 156 | { |
@@ -172,25 +172,25 @@ discard block |
||
172 | 172 | { |
173 | 173 | $this->sErrorMessage = ''; |
174 | 174 | // Verify the file extension |
175 | - if(!$this->validateFileProperty($sName, $aUploadedFile['type'], 'types', 'type')) |
|
175 | + if (!$this->validateFileProperty($sName, $aUploadedFile['type'], 'types', 'type')) |
|
176 | 176 | { |
177 | 177 | return false; |
178 | 178 | } |
179 | 179 | |
180 | 180 | // Verify the file extension |
181 | - if(!$this->validateFileProperty($sName, $aUploadedFile['extension'], 'extensions', 'extension')) |
|
181 | + if (!$this->validateFileProperty($sName, $aUploadedFile['extension'], 'extensions', 'extension')) |
|
182 | 182 | { |
183 | 183 | return false; |
184 | 184 | } |
185 | 185 | |
186 | 186 | // Verify the max size |
187 | - if(!$this->validateFileSize($sName, $aUploadedFile['size'], 'max-size')) |
|
187 | + if (!$this->validateFileSize($sName, $aUploadedFile['size'], 'max-size')) |
|
188 | 188 | { |
189 | 189 | return false; |
190 | 190 | } |
191 | 191 | |
192 | 192 | // Verify the min size |
193 | - if(!$this->validateFileSize($sName, $aUploadedFile['size'], 'min-size')) |
|
193 | + if (!$this->validateFileSize($sName, $aUploadedFile['size'], 'min-size')) |
|
194 | 194 | { |
195 | 195 | return false; |
196 | 196 | } |