@@ -230,7 +230,7 @@ |
||
230 | 230 | * @param string $user persistent identifier of the user who triggered the action |
231 | 231 | * @param string $category type of modification, from the fixed vocabulary: "NEW", "OWN", "MOD", "DEL" |
232 | 232 | * @param string $message message to log into the audit log |
233 | - * @return boolean TRUE if successful. Will terminate script execution on failure. |
|
233 | + * @return boolean|null TRUE if successful. Will terminate script execution on failure. |
|
234 | 234 | */ |
235 | 235 | public static function writeAudit($user, $category, $message) { |
236 | 236 | switch ($category) { |
@@ -74,14 +74,16 @@ discard block |
||
74 | 74 | |
75 | 75 | if (CAT::$RELEASE_VERSION) { |
76 | 76 | $temp_version = "CAT-".CAT::$VERSION_MAJOR.".".CAT::$VERSION_MINOR; |
77 | - if (CAT::$VERSION_PATCH != 0) |
|
78 | - $temp_version .= ".".CAT::$VERSION_PATCH; |
|
79 | - if (CAT::$VERSION_EXTRA != "") |
|
80 | - $temp_version .= "-".CAT::$VERSION_EXTRA; |
|
77 | + if (CAT::$VERSION_PATCH != 0) { |
|
78 | + $temp_version .= ".".CAT::$VERSION_PATCH; |
|
79 | + } |
|
80 | + if (CAT::$VERSION_EXTRA != "") { |
|
81 | + $temp_version .= "-".CAT::$VERSION_EXTRA; |
|
82 | + } |
|
81 | 83 | CAT::$VERSION = sprintf(_("Release %s"), $temp_version ); |
84 | + } else { |
|
85 | + CAT::$VERSION = _("Unreleased SVN Revision"); |
|
82 | 86 | } |
83 | - else |
|
84 | - CAT::$VERSION = _("Unreleased SVN Revision"); |
|
85 | 87 | } |
86 | 88 | |
87 | 89 | /** |
@@ -170,16 +172,18 @@ discard block |
||
170 | 172 | // we need to map stuff manually |
171 | 173 | $thelang = $try_lang; |
172 | 174 | |
173 | - foreach (Config::$LANGUAGES as $language => $value) |
|
174 | - if (preg_match("/^" . $language . ".*/", $try_lang)) { |
|
175 | + foreach (Config::$LANGUAGES as $language => $value) { |
|
176 | + if (preg_match("/^" . $language . ".*/", $try_lang)) { |
|
175 | 177 | $thelang = $value['locale']; |
178 | + } |
|
176 | 179 | $lang_index = $language; |
177 | 180 | } |
178 | 181 | |
179 | 182 | // echo "Trying to set language to $thelang..."; |
180 | 183 | // putenv("LC_ALL=$thelang"); |
181 | - if (setlocale(LC_ALL, $thelang)) |
|
182 | - break; |
|
184 | + if (setlocale(LC_ALL, $thelang)) { |
|
185 | + break; |
|
186 | + } |
|
183 | 187 | } |
184 | 188 | putenv("LC_ALL=" . $thelang); |
185 | 189 | debug(4, "selected lang:$lang_index:$thelang\n"); |
@@ -191,8 +195,9 @@ discard block |
||
191 | 195 | * gets the language setting in CAT |
192 | 196 | */ |
193 | 197 | static public function get_lang() { |
194 | - if(self::$LANG === '') |
|
195 | - list(self::$LANG, $xx) = self::set_lang(); |
|
198 | + if(self::$LANG === '') { |
|
199 | + list(self::$LANG, $xx) = self::set_lang(); |
|
200 | + } |
|
196 | 201 | return self::$LANG; |
197 | 202 | } |
198 | 203 |
@@ -87,6 +87,7 @@ discard block |
||
87 | 87 | /** |
88 | 88 | * executes a query and triggers logging to the SQL audit log if it's not a SELECT |
89 | 89 | * @param string $querystring the query to be executed |
90 | + * @param string $db |
|
90 | 91 | * @return mixed the query result as mysqli_result object; or TRUE on non-return-value statements |
91 | 92 | */ |
92 | 93 | public static function exec($db, $querystring) { |
@@ -134,6 +135,8 @@ discard block |
||
134 | 135 | /** |
135 | 136 | * Checks if a raw data pointer is public data (return value FALSE) or if |
136 | 137 | * yes who the authorised admins to view it are (return array of user IDs) |
138 | + * @param string $table |
|
139 | + * @param string $row |
|
137 | 140 | */ |
138 | 141 | public static function isDataRestricted($table, $row) { |
139 | 142 | if ($table != "institution_option" && $table != "profile_option" && $table != "federation_option") |
@@ -175,6 +178,7 @@ discard block |
||
175 | 178 | |
176 | 179 | /** |
177 | 180 | * Retrieves the last auto-id of an INSERT. Needs to be called immediately after the corresponding exec() call |
181 | + * @param string $db |
|
178 | 182 | * @return int the last autoincrement-ID |
179 | 183 | */ |
180 | 184 | public static function lastID($db) { |
@@ -106,8 +106,9 @@ discard block |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | // log exact query to audit log, if it's not a SELECT |
109 | - if (preg_match("/^SELECT/i", $querystring) == 0) |
|
110 | - CAT::writeSQLAudit("[DB: " . strtoupper($db) . "] " . $querystring); |
|
109 | + if (preg_match("/^SELECT/i", $querystring) == 0) { |
|
110 | + CAT::writeSQLAudit("[DB: " . strtoupper($db) . "] " . $querystring); |
|
111 | + } |
|
111 | 112 | return $result; |
112 | 113 | } |
113 | 114 | |
@@ -120,14 +121,17 @@ discard block |
||
120 | 121 | */ |
121 | 122 | public static function fetchRawDataByIndex($table, $row) { |
122 | 123 | // only for select tables! |
123 | - if ($table != "institution_option" && $table != "profile_option" && $table != "federation_option") |
|
124 | - return FALSE; |
|
124 | + if ($table != "institution_option" && $table != "profile_option" && $table != "federation_option") { |
|
125 | + return FALSE; |
|
126 | + } |
|
125 | 127 | $blob_query = DBConnection::exec("INST", "SELECT option_value from $table WHERE row = $row"); |
126 | - while ($a = mysqli_fetch_object($blob_query)) |
|
127 | - $blob = $a->option_value; |
|
128 | + while ($a = mysqli_fetch_object($blob_query)) { |
|
129 | + $blob = $a->option_value; |
|
130 | + } |
|
128 | 131 | |
129 | - if (!isset($blob)) |
|
130 | - return FALSE; |
|
132 | + if (!isset($blob)) { |
|
133 | + return FALSE; |
|
134 | + } |
|
131 | 135 | return $blob; |
132 | 136 | } |
133 | 137 | |
@@ -136,13 +140,17 @@ discard block |
||
136 | 140 | * yes who the authorised admins to view it are (return array of user IDs) |
137 | 141 | */ |
138 | 142 | public static function isDataRestricted($table, $row) { |
139 | - if ($table != "institution_option" && $table != "profile_option" && $table != "federation_option") |
|
140 | - return []; // better safe than sorry: that's an error, so assume nobody is authorised to act on that data |
|
143 | + if ($table != "institution_option" && $table != "profile_option" && $table != "federation_option") { |
|
144 | + return []; |
|
145 | + } |
|
146 | + // better safe than sorry: that's an error, so assume nobody is authorised to act on that data |
|
141 | 147 | switch ($table) { |
142 | 148 | case "profile_option": |
143 | 149 | $blob_query = DBConnection::exec("INST", "SELECT profile_id from $table WHERE row = $row"); |
144 | - while ($a = mysqli_fetch_object($blob_query)) // only one row |
|
150 | + while ($a = mysqli_fetch_object($blob_query)) { |
|
151 | + // only one row |
|
145 | 152 | $blobprofile = $a->profile_id; |
153 | + } |
|
146 | 154 | // is the profile in question public? |
147 | 155 | $profile = new Profile($blobprofile); |
148 | 156 | if ($profile->getShowtime() == TRUE) { // public data |
@@ -154,8 +162,10 @@ discard block |
||
154 | 162 | break; |
155 | 163 | case "institution_option": |
156 | 164 | $blob_query = DBConnection::exec("INST", "SELECT institution_id from $table WHERE row = $row"); |
157 | - while ($a = mysqli_fetch_object($blob_query)) // only one row |
|
165 | + while ($a = mysqli_fetch_object($blob_query)) { |
|
166 | + // only one row |
|
158 | 167 | $blobinst = $a->institution_id; |
168 | + } |
|
159 | 169 | $inst = new IdP($blobinst); |
160 | 170 | // if at least one of the profiles belonging to the inst is public, the data is public |
161 | 171 | if ($inst->isOneProfileShowtime()) { // public data |
@@ -209,8 +219,9 @@ discard block |
||
209 | 219 | exit(1); |
210 | 220 | } |
211 | 221 | |
212 | - if ($db == "EXTERNAL" && Config::$CONSORTIUM['name'] == "eduroam" && isset(Config::$CONSORTIUM['deployment-voodoo']) && Config::$CONSORTIUM['deployment-voodoo'] == "Operations Team") |
|
213 | - mysqli_query($this->connection, "SET NAMES 'latin1'"); |
|
222 | + if ($db == "EXTERNAL" && Config::$CONSORTIUM['name'] == "eduroam" && isset(Config::$CONSORTIUM['deployment-voodoo']) && Config::$CONSORTIUM['deployment-voodoo'] == "Operations Team") { |
|
223 | + mysqli_query($this->connection, "SET NAMES 'latin1'"); |
|
224 | + } |
|
214 | 225 | } |
215 | 226 | |
216 | 227 | } |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * named the same as device_id. The second option takes precedence. |
173 | 173 | * |
174 | 174 | * @param string $source_name The source file name |
175 | - * @param string $output_name The destination file name |
|
175 | + * @param integer $output_name The destination file name |
|
176 | 176 | * |
177 | 177 | * @return bool result of the copy operation |
178 | 178 | * @final not to be redefined |
@@ -216,8 +216,7 @@ discard block |
||
216 | 216 | * named the same as device_id. The second option takes precedence. |
217 | 217 | * |
218 | 218 | * @param string $source_name The source file name |
219 | - * @param string $output_name The destination file name |
|
220 | - * @param int $use_win_cp Set Windows charset if non-zero |
|
219 | + * @param integer $output_name The destination file name |
|
221 | 220 | * |
222 | 221 | * @final not to be redefined |
223 | 222 | */ |
@@ -262,8 +261,6 @@ discard block |
||
262 | 261 | * The second optional parameter, if nonzero, should be the character set understood by iconv |
263 | 262 | * This is required by the Windows installer and is expected to go away in the future. |
264 | 263 | * |
265 | - * @param string $source_name The source file name |
|
266 | - * @param int $use_win_cp Set Windows charset if non-zero |
|
267 | 264 | * |
268 | 265 | * @final not to be redefined |
269 | 266 | */ |
@@ -107,8 +107,9 @@ discard block |
||
107 | 107 | $CAs = []; |
108 | 108 | if(isset($this->attributes['eap:ca_file'])) { |
109 | 109 | foreach ($this->attributes['eap:ca_file'] as $ca) { |
110 | - if($c = X509::processCertificate($ca)) |
|
111 | - $CAs[] = $c; |
|
110 | + if($c = X509::processCertificate($ca)) { |
|
111 | + $CAs[] = $c; |
|
112 | + } |
|
112 | 113 | } |
113 | 114 | $this->attributes['internal:CAs'][0]=$CAs; |
114 | 115 | } |
@@ -116,9 +117,10 @@ discard block |
||
116 | 117 | $this->attributes['internal:info_file'][0] = |
117 | 118 | $this->saveInfoFile($this->attributes['support:info_file'][0]); |
118 | 119 | } |
119 | - if(isset($this->attributes['general:logo_file'])) |
|
120 | - $this->attributes['internal:logo_file'] = |
|
120 | + if(isset($this->attributes['general:logo_file'])) { |
|
121 | + $this->attributes['internal:logo_file'] = |
|
121 | 122 | $this->saveLogoFile($this->attributes['general:logo_file']); |
123 | + } |
|
122 | 124 | $this->attributes['internal:SSID'] = $this->getSSIDs()['add'];; |
123 | 125 | $this->attributes['internal:remove_SSID'] = $this->getSSIDs()['del'];; |
124 | 126 | $this->attributes['internal:consortia'] = $this->getConsortia(); |
@@ -130,8 +132,9 @@ discard block |
||
130 | 132 | $this->support_url_substitute = sprintf(_("your local %s support page"),Config::$CONSORTIUM['name']); |
131 | 133 | CAT::set_locale($olddomain); |
132 | 134 | |
133 | - if($this->signer && $this->options['sign']) |
|
134 | - $this->sign = CAT::$root . '/signer/'. $this->signer; |
|
135 | + if($this->signer && $this->options['sign']) { |
|
136 | + $this->sign = CAT::$root . '/signer/'. $this->signer; |
|
137 | + } |
|
135 | 138 | $this->installerBasename = $this->getInstallerBasename(); |
136 | 139 | } |
137 | 140 | |
@@ -178,22 +181,24 @@ discard block |
||
178 | 181 | * @final not to be redefined |
179 | 182 | */ |
180 | 183 | final protected function copyFile($source_name, $output_name = 0) { |
181 | - if ( $output_name === 0) |
|
182 | - $output_name = $source_name; |
|
184 | + if ( $output_name === 0) { |
|
185 | + $output_name = $source_name; |
|
186 | + } |
|
183 | 187 | |
184 | 188 | debug(4,"fileCopy($source_name, $output_name)\n"); |
185 | - if(is_file($this->module_path.'/Files/'.$this->device_id.'/'.$source_name)) |
|
186 | - $source = $this->module_path.'/Files/'.$this->device_id.'/'.$source_name; |
|
187 | - elseif(is_file($this->module_path.'/Files/'.$source_name)) |
|
188 | - $source = $this->module_path.'/Files/'.$source_name; |
|
189 | - else { |
|
189 | + if(is_file($this->module_path.'/Files/'.$this->device_id.'/'.$source_name)) { |
|
190 | + $source = $this->module_path.'/Files/'.$this->device_id.'/'.$source_name; |
|
191 | + } elseif(is_file($this->module_path.'/Files/'.$source_name)) { |
|
192 | + $source = $this->module_path.'/Files/'.$source_name; |
|
193 | + } else { |
|
190 | 194 | debug(2,"fileCopy:reqested file $source_name does not exist\n"); |
191 | 195 | return(FALSE); |
192 | 196 | } |
193 | 197 | debug(4,"Copying $source to $output_name\n"); |
194 | 198 | $result = copy($source,"$output_name"); |
195 | - if(! $result ) |
|
196 | - debug(2,"fileCopy($source_name, $output_name) failed\n"); |
|
199 | + if(! $result ) { |
|
200 | + debug(2,"fileCopy($source_name, $output_name) failed\n"); |
|
201 | + } |
|
197 | 202 | return($result); |
198 | 203 | } |
199 | 204 | |
@@ -223,28 +228,33 @@ discard block |
||
223 | 228 | */ |
224 | 229 | |
225 | 230 | final protected function translateFile($source_name, $output_name = 0, $encoding = 0) { |
226 | - if(Config::$NSIS_VERSION >= 3) |
|
227 | - $encoding = 0; |
|
228 | - if ( $output_name === 0) |
|
229 | - $output_name = $source_name; |
|
231 | + if(Config::$NSIS_VERSION >= 3) { |
|
232 | + $encoding = 0; |
|
233 | + } |
|
234 | + if ( $output_name === 0) { |
|
235 | + $output_name = $source_name; |
|
236 | + } |
|
230 | 237 | |
231 | 238 | debug(4,"translateFile($source_name, $output_name, $encoding)\n"); |
232 | 239 | ob_start(); |
233 | 240 | debug(4,$this->module_path.'/Files/'.$this->device_id.'/'.$source_name."\n"); |
234 | - if(is_file($this->module_path.'/Files/'.$this->device_id.'/'.$source_name)) |
|
235 | - $source = $this->module_path.'/Files/'.$this->device_id.'/'.$source_name; |
|
236 | - elseif(is_file($this->module_path.'/Files/'.$source_name)) |
|
237 | - $source = $this->module_path.'/Files/'.$source_name; |
|
241 | + if(is_file($this->module_path.'/Files/'.$this->device_id.'/'.$source_name)) { |
|
242 | + $source = $this->module_path.'/Files/'.$this->device_id.'/'.$source_name; |
|
243 | + } elseif(is_file($this->module_path.'/Files/'.$source_name)) { |
|
244 | + $source = $this->module_path.'/Files/'.$source_name; |
|
245 | + } |
|
238 | 246 | include($source); |
239 | 247 | $output = ob_get_clean(); |
240 | 248 | if($encoding) { |
241 | 249 | $output_c = iconv('UTF-8',$encoding.'//TRANSLIT',$output); |
242 | - if($output_c) |
|
243 | - $output = $output_c; |
|
250 | + if($output_c) { |
|
251 | + $output = $output_c; |
|
252 | + } |
|
244 | 253 | } |
245 | 254 | $f = fopen("$output_name","w"); |
246 | - if(! $f) |
|
247 | - debug(2,"translateFile($source, $output_name, $encoding) failed\n"); |
|
255 | + if(! $f) { |
|
256 | + debug(2,"translateFile($source, $output_name, $encoding) failed\n"); |
|
257 | + } |
|
248 | 258 | fwrite($f,$output); |
249 | 259 | fclose($f); |
250 | 260 | debug(4,"translateFile($source, $output_name, $encoding) end\n"); |
@@ -269,16 +279,19 @@ discard block |
||
269 | 279 | */ |
270 | 280 | |
271 | 281 | final protected function translateString($source_string,$encoding = 0) { |
272 | - if(Config::$NSIS_VERSION >= 3) |
|
273 | - $encoding = 0; |
|
274 | - if($encoding) |
|
275 | - $output_c = iconv('UTF-8',$encoding.'//TRANSLIT',$source_string); |
|
276 | - else |
|
277 | - $output_c = $source_string; |
|
278 | - if($output_c) |
|
279 | - $source_string = str_replace('"','$\\"',$output_c); |
|
280 | - else |
|
281 | - debug(2,"Failed to convert string $source_string\n"); |
|
282 | + if(Config::$NSIS_VERSION >= 3) { |
|
283 | + $encoding = 0; |
|
284 | + } |
|
285 | + if($encoding) { |
|
286 | + $output_c = iconv('UTF-8',$encoding.'//TRANSLIT',$source_string); |
|
287 | + } else { |
|
288 | + $output_c = $source_string; |
|
289 | + } |
|
290 | + if($output_c) { |
|
291 | + $source_string = str_replace('"','$\\"',$output_c); |
|
292 | + } else { |
|
293 | + debug(2,"Failed to convert string $source_string\n"); |
|
294 | + } |
|
282 | 295 | return $source_string; |
283 | 296 | } |
284 | 297 | |
@@ -299,15 +312,19 @@ discard block |
||
299 | 312 | $i = 0; |
300 | 313 | $CA_files = []; |
301 | 314 | $ca_array = $this->attributes['internal:CAs'][0]; |
302 | - if(! $ca_array) |
|
303 | - return(FALSE); |
|
315 | + if(! $ca_array) { |
|
316 | + return(FALSE); |
|
317 | + } |
|
304 | 318 | foreach ($ca_array as $CA) { |
305 | 319 | $f = fopen("cert-$i.crt","w"); |
306 | - if(! $f) die("problem opening the file\n"); |
|
307 | - if($format == "pem") |
|
308 | - fwrite($f,$CA['pem']); |
|
309 | - else |
|
310 | - fwrite($f,$CA['der']); |
|
320 | + if(! $f) { |
|
321 | + die("problem opening the file\n"); |
|
322 | + } |
|
323 | + if($format == "pem") { |
|
324 | + fwrite($f,$CA['pem']); |
|
325 | + } else { |
|
326 | + fwrite($f,$CA['der']); |
|
327 | + } |
|
311 | 328 | fclose($f); |
312 | 329 | $C = []; |
313 | 330 | $C['file'] = "cert-$i.crt"; |
@@ -340,8 +357,9 @@ discard block |
||
340 | 357 | $Inst_a = explode('_',$inst); |
341 | 358 | if(count($Inst_a) > 2) { |
342 | 359 | $inst = ''; |
343 | - foreach($Inst_a as $i) |
|
344 | - $inst .= $i[0]; |
|
360 | + foreach($Inst_a as $i) { |
|
361 | + $inst .= $i[0]; |
|
362 | + } |
|
345 | 363 | } |
346 | 364 | $c_name = iconv("UTF-8", "US-ASCII//TRANSLIT", preg_replace($replace_pattern, '_', Config::$CONSORTIUM['name'])); |
347 | 365 | if($this->attributes['internal:profile_count'][0] > 1) { |
@@ -356,10 +374,12 @@ discard block |
||
356 | 374 | |
357 | 375 | private function getDeviceId() { |
358 | 376 | $d_id = $this->device_id; |
359 | - if(isset($this->options['device_id'])) |
|
360 | - $d_id = $this->options['device_id']; |
|
361 | - if($d_id !== '') |
|
362 | - $d_id .= '-'; |
|
377 | + if(isset($this->options['device_id'])) { |
|
378 | + $d_id = $this->options['device_id']; |
|
379 | + } |
|
380 | + if($d_id !== '') { |
|
381 | + $d_id .= '-'; |
|
382 | + } |
|
363 | 383 | return $d_id; |
364 | 384 | } |
365 | 385 | |
@@ -369,9 +389,9 @@ discard block |
||
369 | 389 | $S['del']=[]; |
370 | 390 | if (isset(Config::$CONSORTIUM['ssid'])) { |
371 | 391 | foreach (Config::$CONSORTIUM['ssid'] as $ssid) { |
372 | - if(isset(Config::$CONSORTIUM['tkipsupport']) && Config::$CONSORTIUM['tkipsupport'] == TRUE) |
|
373 | - $S['add'][$ssid] = 'TKIP'; |
|
374 | - else { |
|
392 | + if(isset(Config::$CONSORTIUM['tkipsupport']) && Config::$CONSORTIUM['tkipsupport'] == TRUE) { |
|
393 | + $S['add'][$ssid] = 'TKIP'; |
|
394 | + } else { |
|
375 | 395 | $S['add'][$ssid] = 'AES'; |
376 | 396 | $S['del'][$ssid] = 'TKIP'; |
377 | 397 | } |
@@ -380,18 +400,21 @@ discard block |
||
380 | 400 | if(isset($this->attributes['media:SSID'])) { |
381 | 401 | $SSID = $this->attributes['media:SSID']; |
382 | 402 | |
383 | - foreach($SSID as $ssid) |
|
384 | - $S['add'][$ssid] = 'AES'; |
|
403 | + foreach($SSID as $ssid) { |
|
404 | + $S['add'][$ssid] = 'AES'; |
|
405 | + } |
|
385 | 406 | } |
386 | 407 | if(isset($this->attributes['media:SSID_with_legacy'])) { |
387 | 408 | $SSID = $this->attributes['media:SSID_with_legacy']; |
388 | - foreach($SSID as $ssid) |
|
389 | - $S['add'][$ssid] = 'TKIP'; |
|
409 | + foreach($SSID as $ssid) { |
|
410 | + $S['add'][$ssid] = 'TKIP'; |
|
411 | + } |
|
390 | 412 | } |
391 | 413 | if(isset($this->attributes['media:remove_SSID'])) { |
392 | 414 | $SSID = $this->attributes['media:remove_SSID']; |
393 | - foreach($SSID as $ssid) |
|
394 | - $S['del'][$ssid] = 'DEL'; |
|
415 | + foreach($SSID as $ssid) { |
|
416 | + $S['del'][$ssid] = 'DEL'; |
|
417 | + } |
|
395 | 418 | } |
396 | 419 | return $S; |
397 | 420 | } |
@@ -399,9 +422,10 @@ discard block |
||
399 | 422 | private function getConsortia() { |
400 | 423 | $OIs = []; |
401 | 424 | $OIs = array_merge($OIs, Config::$CONSORTIUM['interworking-consortium-oi']); |
402 | - if (isset($this->attributes['media:consortium_OI'])) |
|
403 | - foreach ($this->attributes['media:consortium_OI'] as $new_oi) |
|
425 | + if (isset($this->attributes['media:consortium_OI'])) { |
|
426 | + foreach ($this->attributes['media:consortium_OI'] as $new_oi) |
|
404 | 427 | $OIs[] = $new_oi; |
428 | + } |
|
405 | 429 | return $OIs; |
406 | 430 | } |
407 | 431 | |
@@ -421,10 +445,11 @@ discard block |
||
421 | 445 | foreach ($Logos as $blob) { |
422 | 446 | $finfo = new finfo(FILEINFO_MIME_TYPE); |
423 | 447 | $mime = $finfo->buffer($blob); |
424 | - if(preg_match('/^image\/(.*)/',$mime,$m)) |
|
425 | - $ext = $m[1]; |
|
426 | - else |
|
427 | - $ext = 'unsupported'; |
|
448 | + if(preg_match('/^image\/(.*)/',$mime,$m)) { |
|
449 | + $ext = $m[1]; |
|
450 | + } else { |
|
451 | + $ext = 'unsupported'; |
|
452 | + } |
|
428 | 453 | debug(4,"saveLogoFile: $mime : $ext\n"); |
429 | 454 | $f_name = 'logo-'.$i.'.'.$ext; |
430 | 455 | $f = fopen($f_name,"w"); |
@@ -447,7 +472,9 @@ discard block |
||
447 | 472 | $ext = isset($this->mime_extensions[$mime]) ? $this->mime_extensions[$mime] : 'usupported'; |
448 | 473 | debug(4,"saveInfoFile: $mime : $ext\n"); |
449 | 474 | $f = fopen('local-info.'.$ext,"w"); |
450 | - if(! $f) die("problem opening the file\n"); |
|
475 | + if(! $f) { |
|
476 | + die("problem opening the file\n"); |
|
477 | + } |
|
451 | 478 | fwrite($f,$blob); |
452 | 479 | fclose($f); |
453 | 480 | return(['name'=>'local-info.'.$ext,'mime'=>$ext]); |
@@ -661,7 +661,7 @@ |
||
661 | 661 | * This function retrieves the federation attributes. If called with the optional parameter, only attribute values for the attribute |
662 | 662 | * name in $option_name are retrieved; otherwise, all attributes are retrieved. |
663 | 663 | * |
664 | - * @param string $option_name optionally, the name of the attribute that is to be retrieved |
|
664 | + * @param integer $option_name optionally, the name of the attribute that is to be retrieved |
|
665 | 665 | * @return array of arrays of attributes which were set for this IdP |
666 | 666 | */ |
667 | 667 | public function getAttributes($option_name = 0) { |
@@ -73,8 +73,9 @@ discard block |
||
73 | 73 | $timestamp = date("Y-m-d") . "T" . date("H:i:s"); |
74 | 74 | |
75 | 75 | $retstring = ""; |
76 | - if (!$astablerows) |
|
77 | - $retstring .= "<federation id='" . ( $federationid == NULL ? "ALL" : $federationid ) . "' ts='$timestamp'>\n"; |
|
76 | + if (!$astablerows) { |
|
77 | + $retstring .= "<federation id='" . ( $federationid == NULL ? "ALL" : $federationid ) . "' ts='$timestamp'>\n"; |
|
78 | + } |
|
78 | 79 | |
79 | 80 | foreach (Devices::listDevices() as $index => $device_array) { |
80 | 81 | $query = "SELECT SUM(downloads_admin) AS admin, SUM(downloads_user) AS user FROM downloads, profile, institution WHERE device_id = '$index' AND downloads.profile_id = profile.profile_id AND profile.inst_id = institution.inst_id "; |
@@ -84,8 +85,9 @@ discard block |
||
84 | 85 | $retstring .= ($astablerows ? "<tr>" : " <device name='" . $device_array['display'] . "'>\n"); |
85 | 86 | $admin_query = DBConnection::exec("INST", $query); |
86 | 87 | while ($a = mysqli_fetch_object($admin_query)) { |
87 | - if ($astablerows) |
|
88 | - $retstring .= "<td>" . $device_array['display'] . "</td>"; |
|
88 | + if ($astablerows) { |
|
89 | + $retstring .= "<td>" . $device_array['display'] . "</td>"; |
|
90 | + } |
|
89 | 91 | $retstring .= ($astablerows ? "<td>" : " <downloads group='admin'>"); |
90 | 92 | $retstring .= ( $a->admin === NULL ? "0" : $a->admin); |
91 | 93 | $retstring .= ($astablerows ? "</td><td>" : "</downloads>\n <downloads group='user'>"); |
@@ -97,16 +99,18 @@ discard block |
||
97 | 99 | $retstring .= ($astablerows ? "</tr>" : " </device>\n"); |
98 | 100 | } |
99 | 101 | $retstring .= ($astablerows ? "<tr>" : " <total>\n"); |
100 | - if ($astablerows) |
|
101 | - $retstring .= "<td><strong>TOTAL</ts>"; |
|
102 | + if ($astablerows) { |
|
103 | + $retstring .= "<td><strong>TOTAL</ts>"; |
|
104 | + } |
|
102 | 105 | $retstring .= ($astablerows ? "<td><strong>" : " <downloads group='admin'>"); |
103 | 106 | $retstring .= $gross_admin; |
104 | 107 | $retstring .= ($astablerows ? "</strong></td><td><strong>" : "</downloads>\n <downloads group='user'>"); |
105 | 108 | $retstring .= $gross_user; |
106 | 109 | $retstring .= ($astablerows ? "</strong></td>" : "</downloads>\n"); |
107 | 110 | $retstring .= ($astablerows ? "</tr>" : " </total>\n"); |
108 | - if (!$astablerows) |
|
109 | - $retstring .= "</federation>\n"; |
|
111 | + if (!$astablerows) { |
|
112 | + $retstring .= "</federation>\n"; |
|
113 | + } |
|
110 | 114 | |
111 | 115 | return $retstring; |
112 | 116 | } |
@@ -437,8 +441,9 @@ discard block |
||
437 | 441 | $level = DBConnection::escape_value(Federation::$DB_TYPE, $level); |
438 | 442 | $mail = DBConnection::escape_value(Federation::$DB_TYPE, $mail); |
439 | 443 | |
440 | - if ($owner_id != "PENDING") |
|
441 | - DBConnection::exec(Federation::$DB_TYPE, "INSERT INTO ownership (user_id,institution_id, blesslevel, orig_mail) VALUES('$owner_id', $identifier, '$level', '$mail')"); |
|
444 | + if ($owner_id != "PENDING") { |
|
445 | + DBConnection::exec(Federation::$DB_TYPE, "INSERT INTO ownership (user_id,institution_id, blesslevel, orig_mail) VALUES('$owner_id', $identifier, '$level', '$mail')"); |
|
446 | + } |
|
442 | 447 | return $identifier; |
443 | 448 | } |
444 | 449 | |
@@ -485,13 +490,16 @@ discard block |
||
485 | 490 | |
486 | 491 | public function listFederationAdmins() { |
487 | 492 | $returnarray = []; |
488 | - if (Config::$CONSORTIUM['name'] == "eduroam" && isset(Config::$CONSORTIUM['deployment-voodoo']) && Config::$CONSORTIUM['deployment-voodoo'] == "Operations Team") // SW: APPROVED |
|
493 | + if (Config::$CONSORTIUM['name'] == "eduroam" && isset(Config::$CONSORTIUM['deployment-voodoo']) && Config::$CONSORTIUM['deployment-voodoo'] == "Operations Team") { |
|
494 | + // SW: APPROVED |
|
489 | 495 | $admins = DBConnection::exec("USER", "SELECT eptid as user_id FROM view_admin WHERE role = 'fedadmin' AND realm = '" . strtolower($this->identifier) . "'"); |
490 | - else |
|
491 | - $admins = DBConnection::exec("USER", "SELECT user_id FROM user_options WHERE option_name = 'user:fedadmin' AND option_value = '" . strtoupper($this->identifier) . "'"); |
|
496 | + } else { |
|
497 | + $admins = DBConnection::exec("USER", "SELECT user_id FROM user_options WHERE option_name = 'user:fedadmin' AND option_value = '" . strtoupper($this->identifier) . "'"); |
|
498 | + } |
|
492 | 499 | |
493 | - while ($a = mysqli_fetch_object($admins)) |
|
494 | - $returnarray[] = $a->user_id; |
|
500 | + while ($a = mysqli_fetch_object($admins)) { |
|
501 | + $returnarray[] = $a->user_id; |
|
502 | + } |
|
495 | 503 | return $returnarray; |
496 | 504 | } |
497 | 505 | |
@@ -499,10 +507,11 @@ discard block |
||
499 | 507 | $returnarray = []; |
500 | 508 | $countrysuffix = ""; |
501 | 509 | |
502 | - if ($this->identifier != "") |
|
503 | - $countrysuffix = " WHERE country = '" . strtolower($this->identifier) . "'"; |
|
504 | - else |
|
505 | - $countrysuffix = ""; |
|
510 | + if ($this->identifier != "") { |
|
511 | + $countrysuffix = " WHERE country = '" . strtolower($this->identifier) . "'"; |
|
512 | + } else { |
|
513 | + $countrysuffix = ""; |
|
514 | + } |
|
506 | 515 | |
507 | 516 | if (Config::$CONSORTIUM['name'] == "eduroam" && isset(Config::$CONSORTIUM['deployment-voodoo']) && Config::$CONSORTIUM['deployment-voodoo'] == "Operations Team") { // SW: APPROVED |
508 | 517 | $usedarray = []; |
@@ -515,15 +524,18 @@ discard block |
||
515 | 524 | WHERE external_db_uniquehandle IS NOT NULL |
516 | 525 | AND invite_created >= TIMESTAMPADD(DAY, -1, NOW()) |
517 | 526 | AND used = 0"); |
518 | - while ($a = mysqli_fetch_object($already_used)) |
|
519 | - $usedarray[] = $a->external_db_id; |
|
520 | - while ($a = mysqli_fetch_object($pending_invite)) |
|
521 | - if (!in_array($a->external_db_uniquehandle, $usedarray)) |
|
527 | + while ($a = mysqli_fetch_object($already_used)) { |
|
528 | + $usedarray[] = $a->external_db_id; |
|
529 | + } |
|
530 | + while ($a = mysqli_fetch_object($pending_invite)) { |
|
531 | + if (!in_array($a->external_db_uniquehandle, $usedarray)) |
|
522 | 532 | $usedarray[] = $a->external_db_uniquehandle; |
533 | + } |
|
523 | 534 | while ($a = mysqli_fetch_object($externals)) { |
524 | 535 | if ($unmapped_only === TRUE) { |
525 | - if (in_array($a->id, $usedarray)) |
|
526 | - continue; |
|
536 | + if (in_array($a->id, $usedarray)) { |
|
537 | + continue; |
|
538 | + } |
|
527 | 539 | } |
528 | 540 | $names = explode('#', $a->collapsed_name); |
529 | 541 | // trim name list to current best language match |
@@ -547,8 +559,9 @@ discard block |
||
547 | 559 | $matches = []; |
548 | 560 | preg_match("/^n: (.*), e: (.*), p: .*$/", $contact, $matches); |
549 | 561 | if ($matches[2] != "") { |
550 | - if ($mailnames != "") |
|
551 | - $mailnames .= ", "; |
|
562 | + if ($mailnames != "") { |
|
563 | + $mailnames .= ", "; |
|
564 | + } |
|
552 | 565 | // extracting real names is nice, but the <> notation |
553 | 566 | // really gets screwed up on POSTs and HTML safety |
554 | 567 | // so better not do this; use only mail addresses |
@@ -567,10 +580,11 @@ discard block |
||
567 | 580 | public static function getExternalDBEntityDetails($external_id, $realm = NULL) { |
568 | 581 | $list = []; |
569 | 582 | if (Config::$CONSORTIUM['name'] == "eduroam" && isset(Config::$CONSORTIUM['deployment-voodoo']) && Config::$CONSORTIUM['deployment-voodoo'] == "Operations Team") { // SW: APPROVED |
570 | - if ($realm !== NULL) |
|
571 | - $scanforrealm = "OR inst_realm LIKE '%$realm%'"; |
|
572 | - else |
|
573 | - $scanforrealm = ""; |
|
583 | + if ($realm !== NULL) { |
|
584 | + $scanforrealm = "OR inst_realm LIKE '%$realm%'"; |
|
585 | + } else { |
|
586 | + $scanforrealm = ""; |
|
587 | + } |
|
574 | 588 | $info_list = DBConnection::exec("EXTERNAL", "SELECT name AS collapsed_name, inst_realm as realmlist, contact AS collapsed_contact, country FROM view_active_idp_institution WHERE id_institution = $external_id $scanforrealm"); |
575 | 589 | // split names and contacts into proper pairs |
576 | 590 | while ($a = mysqli_fetch_object($info_list)) { |
@@ -604,14 +618,16 @@ discard block |
||
604 | 618 | $query = "SELECT distinct institution.inst_id AS inst_id, institution.country AS country, |
605 | 619 | group_concat(concat_ws('===',institution_option.option_name,LEFT(institution_option.option_value,200)) separator '---') AS options |
606 | 620 | FROM institution "; |
607 | - if ($active_only == 1) |
|
608 | - $query .= "JOIN profile ON institution.inst_id = profile.inst_id "; |
|
621 | + if ($active_only == 1) { |
|
622 | + $query .= "JOIN profile ON institution.inst_id = profile.inst_id "; |
|
623 | + } |
|
609 | 624 | $query .= "JOIN institution_option ON institution.inst_id = institution_option.institution_id "; |
610 | 625 | $query .= "WHERE (institution_option.option_name = 'general:instname' |
611 | 626 | OR institution_option.option_name = 'general:geo_coordinates' |
612 | 627 | OR institution_option.option_name = 'general:logo_file') "; |
613 | - if ($active_only == 1) |
|
614 | - $query .= "AND profile.showtime = 1 "; |
|
628 | + if ($active_only == 1) { |
|
629 | + $query .= "AND profile.showtime = 1 "; |
|
630 | + } |
|
615 | 631 | |
616 | 632 | if ($country) { |
617 | 633 | // escape the parameter |
@@ -624,34 +640,41 @@ discard block |
||
624 | 640 | while ($a = mysqli_fetch_object($allIDPs)) { |
625 | 641 | $O = explode('---', $a->options); |
626 | 642 | $A = []; |
627 | - if (isset($geo)) |
|
628 | - unset($geo); |
|
629 | - if (isset($names)) |
|
630 | - unset($names); |
|
643 | + if (isset($geo)) { |
|
644 | + unset($geo); |
|
645 | + } |
|
646 | + if (isset($names)) { |
|
647 | + unset($names); |
|
648 | + } |
|
631 | 649 | $A['entityID'] = $a->inst_id; |
632 | 650 | $A['country'] = strtoupper($a->country); |
633 | 651 | foreach ($O as $o) { |
634 | 652 | $opt = explode('===', $o); |
635 | - if ($opt[0] == 'general:logo_file') |
|
636 | - $A['icon'] = $a->inst_id; |
|
653 | + if ($opt[0] == 'general:logo_file') { |
|
654 | + $A['icon'] = $a->inst_id; |
|
655 | + } |
|
637 | 656 | if ($opt[0] == 'general:geo_coordinates') { |
638 | 657 | $at1 = unserialize($opt[1]); |
639 | - if (!isset($geo)) |
|
640 | - $geo = []; |
|
658 | + if (!isset($geo)) { |
|
659 | + $geo = []; |
|
660 | + } |
|
641 | 661 | $geo[] = $at1; |
642 | 662 | } |
643 | 663 | if ($opt[0] == 'general:instname') { |
644 | - if (!isset($names)) |
|
645 | - $names = []; |
|
664 | + if (!isset($names)) { |
|
665 | + $names = []; |
|
666 | + } |
|
646 | 667 | $names[] = ['value' => $opt[1]]; |
647 | 668 | } |
648 | 669 | } |
649 | 670 | $name = getLocalisedValue($names, CAT::get_lang()); |
650 | - if (!$name) |
|
651 | - continue; |
|
671 | + if (!$name) { |
|
672 | + continue; |
|
673 | + } |
|
652 | 674 | $A['title'] = $name; |
653 | - if (isset($geo)) |
|
654 | - $A['geo'] = $geo; |
|
675 | + if (isset($geo)) { |
|
676 | + $A['geo'] = $geo; |
|
677 | + } |
|
655 | 678 | $returnarray[] = $A; |
656 | 679 | } |
657 | 680 | return $returnarray; |
@@ -667,12 +690,12 @@ discard block |
||
667 | 690 | public function getAttributes($option_name = 0) { |
668 | 691 | if ($option_name) { |
669 | 692 | $returnarray = Array(); |
670 | - foreach ($this->priv_attributes as $the_attr) |
|
671 | - if ($the_attr['name'] == $option_name) |
|
693 | + foreach ($this->priv_attributes as $the_attr) { |
|
694 | + if ($the_attr['name'] == $option_name) |
|
672 | 695 | $returnarray[] = $the_attr; |
696 | + } |
|
673 | 697 | return $returnarray; |
674 | - } |
|
675 | - else { |
|
698 | + } else { |
|
676 | 699 | return $this->priv_attributes; |
677 | 700 | } |
678 | 701 | } |
@@ -686,8 +709,9 @@ discard block |
||
686 | 709 | DBConnection::exec(Federation::$DB_TYPE, "DELETE FROM federation_option WHERE federation_id = '$this->identifier' AND option_name NOT LIKE '%_file'"); |
687 | 710 | $exec_q = DBConnection::exec(Federation::$DB_TYPE, "SELECT row FROM federation_option WHERE federation_id = '$this->identifier'"); |
688 | 711 | $return_array = []; |
689 | - while ($a = mysqli_fetch_object($exec_q)) |
|
690 | - $return_array[$a->row] = "KILLME"; |
|
712 | + while ($a = mysqli_fetch_object($exec_q)) { |
|
713 | + $return_array[$a->row] = "KILLME"; |
|
714 | + } |
|
691 | 715 | return $return_array; |
692 | 716 | } |
693 | 717 |
@@ -32,6 +32,7 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * write debug messages to the log |
34 | 34 | * |
35 | + * @param integer $level |
|
35 | 36 | */ |
36 | 37 | function debug($level, $t) { |
37 | 38 | if (Config::$DEBUG_LEVEL >= $level) { |
@@ -130,7 +131,7 @@ discard block |
||
130 | 131 | * generates a UUID |
131 | 132 | * |
132 | 133 | * @param string $prefix an extra prefix to set before the UUID |
133 | - * @return UUID (possibly prefixed) |
|
134 | + * @return string (possibly prefixed) |
|
134 | 135 | */ |
135 | 136 | function uuid($prefix = '', $deterministic_source = NULL) { |
136 | 137 | if ($deterministic_source === NULL) |
@@ -56,10 +56,11 @@ discard block |
||
56 | 56 | |
57 | 57 | function rrmdir($dir) { |
58 | 58 | foreach (glob($dir . '/*') as $file) { |
59 | - if (is_dir($file)) |
|
60 | - rrmdir($file); |
|
61 | - else |
|
62 | - unlink($file); |
|
59 | + if (is_dir($file)) { |
|
60 | + rrmdir($file); |
|
61 | + } else { |
|
62 | + unlink($file); |
|
63 | + } |
|
63 | 64 | } |
64 | 65 | rmdir($dir); |
65 | 66 | } |
@@ -73,36 +74,42 @@ discard block |
||
73 | 74 | */ |
74 | 75 | function calculateCommonHostSuffix(array $hosts) { |
75 | 76 | // massage names. A trailing dot can be omitted |
76 | - foreach ($hosts as $index => $host) |
|
77 | - if (substr($host, -1) == '.') { |
|
77 | + foreach ($hosts as $index => $host) { |
|
78 | + if (substr($host, -1) == '.') { |
|
78 | 79 | $hosts[$index] = substr($host, 0, -1); |
80 | + } |
|
79 | 81 | echo "Changed host to " . $hosts[$index] . "\n"; |
80 | 82 | } |
81 | 83 | // easy :-) |
82 | - if (count($hosts) == 1) |
|
83 | - return $hosts[0]; |
|
84 | + if (count($hosts) == 1) { |
|
85 | + return $hosts[0]; |
|
86 | + } |
|
84 | 87 | // not so easy :-( |
85 | 88 | else { |
86 | 89 | // look for the last dot from the end; if the corresponding substring is |
87 | 90 | // different, no common match! |
88 | 91 | $explodednames = []; |
89 | - foreach ($hosts as $host) |
|
90 | - $explodednames[] = explode('.', $host); |
|
92 | + foreach ($hosts as $host) { |
|
93 | + $explodednames[] = explode('.', $host); |
|
94 | + } |
|
91 | 95 | $commonsuffix = []; |
92 | 96 | while (count($explodednames[0]) > 0) { |
93 | 97 | $match = TRUE; |
94 | 98 | $testname = array_pop($explodednames[0]); |
95 | 99 | for ($i = 1; $i < count($explodednames); $i = $i + 1) { |
96 | - if (count($explodednames[$i]) == 0) |
|
97 | - $match = FALSE; |
|
100 | + if (count($explodednames[$i]) == 0) { |
|
101 | + $match = FALSE; |
|
102 | + } |
|
98 | 103 | $bla = array_pop($explodednames[$i]); |
99 | - if ($bla != $testname) |
|
100 | - $match = FALSE; |
|
104 | + if ($bla != $testname) { |
|
105 | + $match = FALSE; |
|
106 | + } |
|
107 | + } |
|
108 | + if ($match == TRUE) { |
|
109 | + $commonsuffix[] = $testname; |
|
110 | + } else { |
|
111 | + break; |
|
101 | 112 | } |
102 | - if ($match == TRUE) |
|
103 | - $commonsuffix[] = $testname; |
|
104 | - else |
|
105 | - break; |
|
106 | 113 | } |
107 | 114 | $finalsuffix = array_reverse($commonsuffix); |
108 | 115 | return implode('.', $finalsuffix); |
@@ -133,10 +140,11 @@ discard block |
||
133 | 140 | * @return UUID (possibly prefixed) |
134 | 141 | */ |
135 | 142 | function uuid($prefix = '', $deterministic_source = NULL) { |
136 | - if ($deterministic_source === NULL) |
|
137 | - $chars = md5(uniqid(mt_rand(), true)); |
|
138 | - else |
|
139 | - $chars = md5($deterministic_source); |
|
143 | + if ($deterministic_source === NULL) { |
|
144 | + $chars = md5(uniqid(mt_rand(), true)); |
|
145 | + } else { |
|
146 | + $chars = md5($deterministic_source); |
|
147 | + } |
|
140 | 148 | $uuid = substr($chars, 0, 8) . '-'; |
141 | 149 | $uuid .= substr($chars, 8, 4) . '-'; |
142 | 150 | $uuid .= substr($chars, 12, 4) . '-'; |
@@ -159,12 +167,13 @@ discard block |
||
159 | 167 | $try = unserialize($val['value']); |
160 | 168 | $r_val[$try['lang']] = $try['content']; |
161 | 169 | } |
162 | - if (isset($r_val[$locale])) |
|
163 | - $out = $r_val[$locale]; |
|
164 | - elseif (isset($r_val['C'])) |
|
165 | - $out = $r_val['C']; |
|
166 | - else |
|
167 | - $out = 0; |
|
170 | + if (isset($r_val[$locale])) { |
|
171 | + $out = $r_val[$locale]; |
|
172 | + } elseif (isset($r_val['C'])) { |
|
173 | + $out = $r_val['C']; |
|
174 | + } else { |
|
175 | + $out = 0; |
|
176 | + } |
|
168 | 177 | } else { |
169 | 178 | $out = 0; |
170 | 179 | } |
@@ -203,8 +212,9 @@ discard block |
||
203 | 212 | debug(4, "Directory creation failed for $tmp_dir\n"); |
204 | 213 | return ['base'=>$path,'dir'=>'',$name=>'']; |
205 | 214 | } |
206 | - } else |
|
207 | - debug(4, "Directory created: $tmp_dir\n"); |
|
215 | + } else { |
|
216 | + debug(4, "Directory created: $tmp_dir\n"); |
|
217 | + } |
|
208 | 218 | return ['base'=>$path,'dir'=>$tmp_dir,'name'=>$name]; |
209 | 219 | } |
210 | 220 |
@@ -68,6 +68,7 @@ discard block |
||
68 | 68 | * Cannot be used to define a new IdP in the database! This happens via Federation::newIdP() |
69 | 69 | * |
70 | 70 | * @param integer $i_id the database row identifier |
71 | + * @return string |
|
71 | 72 | */ |
72 | 73 | public function __construct($i_id) { |
73 | 74 | debug(3, "--- BEGIN Constructing new IdP object ... ---\n"); |
@@ -247,7 +248,7 @@ discard block |
||
247 | 248 | * This function retrieves the IdP-wide attributes. If called with the optional parameter, only attribute values for the attribute |
248 | 249 | * name in $option_name are retrieved; otherwise, all attributes are retrieved. |
249 | 250 | * |
250 | - * @param string $option_name optionally, the name of the attribute that is to be retrieved |
|
251 | + * @param integer $option_name optionally, the name of the attribute that is to be retrieved |
|
251 | 252 | * @return array of arrays of attributes which were set for this IdP |
252 | 253 | */ |
253 | 254 | public function getAttributes($option_name = 0) { |
@@ -318,7 +319,7 @@ discard block |
||
318 | 319 | * Adds a new profile to this IdP. |
319 | 320 | * Only creates the DB entry for the Profile. If you want to add attributes later, see Profile::addAttribute(). |
320 | 321 | * |
321 | - * @return object new Profile object if successful, or FALSE if an error occured |
|
322 | + * @return Profile|null new Profile object if successful, or FALSE if an error occured |
|
322 | 323 | */ |
323 | 324 | public function newProfile() { |
324 | 325 | DBConnection::exec(IdP::$DB_TYPE, "INSERT INTO profile (inst_id) VALUES($this->identifier)"); |
@@ -136,8 +136,9 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function listProfiles($active_only = 0) { |
138 | 138 | $query = "SELECT profile_id FROM profile WHERE inst_id = $this->identifier"; |
139 | - if ($active_only) |
|
140 | - $query .= " AND showtime = 1"; |
|
139 | + if ($active_only) { |
|
140 | + $query .= " AND showtime = 1"; |
|
141 | + } |
|
141 | 142 | $allProfiles = DBConnection::exec(IdP::$DB_TYPE, $query); |
142 | 143 | $returnarray = []; |
143 | 144 | while ($a = mysqli_fetch_object($allProfiles)) { |
@@ -152,24 +153,27 @@ discard block |
||
152 | 153 | // migration phase: are there NULLs in the profile list sufficient_config column? |
153 | 154 | // if so, run prepShowtime on all profiles |
154 | 155 | $needTreatment = DBConnection::exec(IdP::$DB_TYPE, "SELECT profile_id FROM profile WHERE inst_id = $this->identifier AND sufficient_config IS NULL"); |
155 | - if (mysqli_num_rows($needTreatment) > 0) |
|
156 | - foreach ($this->listProfiles() as $prof) |
|
156 | + if (mysqli_num_rows($needTreatment) > 0) { |
|
157 | + foreach ($this->listProfiles() as $prof) |
|
157 | 158 | $prof->prepShowtime(); |
159 | + } |
|
158 | 160 | |
159 | 161 | // now, just look in the DB |
160 | 162 | $allProfiles = DBConnection::exec(IdP::$DB_TYPE, "SELECT profile_id FROM profile WHERE inst_id = $this->identifier AND sufficient_config = 1"); |
161 | - if (mysqli_num_rows($allProfiles) > 0) |
|
162 | - return TRUE; |
|
163 | - else |
|
164 | - return FALSE; |
|
163 | + if (mysqli_num_rows($allProfiles) > 0) { |
|
164 | + return TRUE; |
|
165 | + } else { |
|
166 | + return FALSE; |
|
167 | + } |
|
165 | 168 | } |
166 | 169 | |
167 | 170 | public function isOneProfileShowtime() { |
168 | 171 | $allProfiles = DBConnection::exec(IdP::$DB_TYPE, "SELECT profile_id FROM profile WHERE inst_id = $this->identifier AND showtime = 1"); |
169 | - if (mysqli_num_rows($allProfiles) > 0) |
|
170 | - return TRUE; |
|
171 | - else |
|
172 | - return FALSE; |
|
172 | + if (mysqli_num_rows($allProfiles) > 0) { |
|
173 | + return TRUE; |
|
174 | + } else { |
|
175 | + return FALSE; |
|
176 | + } |
|
173 | 177 | |
174 | 178 | } |
175 | 179 | |
@@ -177,16 +181,21 @@ discard block |
||
177 | 181 | $allProfiles = DBConnection::exec(IdP::$DB_TYPE, "SELECT status_dns, status_cert, status_reachability, status_TLS, last_status_check FROM profile WHERE inst_id = $this->identifier AND sufficient_config = 1"); |
178 | 182 | $returnarray = ['dns' => RETVAL_SKIPPED, 'cert' => L_OK, 'reachability' => RETVAL_SKIPPED, 'TLS' => RETVAL_SKIPPED, 'checktime' => NULL]; |
179 | 183 | while ($a = mysqli_fetch_object($allProfiles)) { |
180 | - if ($a->status_dns < $returnarray['dns']) |
|
181 | - $returnarray['dns'] = $a->status_dns; |
|
182 | - if ($a->status_reachability < $returnarray['reachability']) |
|
183 | - $returnarray['reachability'] = $a->status_reachability; |
|
184 | - if ($a->status_TLS < $returnarray['TLS']) |
|
185 | - $returnarray['TLS'] = $a->status_TLS; |
|
186 | - if ($a->status_cert < $returnarray['cert']) |
|
187 | - $returnarray['cert'] = $a->status_cert; |
|
188 | - if ($a->last_status_check > $returnarray['checktime']) |
|
189 | - $returnarray['checktime'] = $a->last_status_check; |
|
184 | + if ($a->status_dns < $returnarray['dns']) { |
|
185 | + $returnarray['dns'] = $a->status_dns; |
|
186 | + } |
|
187 | + if ($a->status_reachability < $returnarray['reachability']) { |
|
188 | + $returnarray['reachability'] = $a->status_reachability; |
|
189 | + } |
|
190 | + if ($a->status_TLS < $returnarray['TLS']) { |
|
191 | + $returnarray['TLS'] = $a->status_TLS; |
|
192 | + } |
|
193 | + if ($a->status_cert < $returnarray['cert']) { |
|
194 | + $returnarray['cert'] = $a->status_cert; |
|
195 | + } |
|
196 | + if ($a->last_status_check > $returnarray['checktime']) { |
|
197 | + $returnarray['checktime'] = $a->last_status_check; |
|
198 | + } |
|
190 | 199 | } |
191 | 200 | return $returnarray; |
192 | 201 | } |
@@ -199,8 +208,9 @@ discard block |
||
199 | 208 | public function owner() { |
200 | 209 | $returnarray = []; |
201 | 210 | $admins = DBConnection::exec(IdP::$DB_TYPE, "SELECT user_id, orig_mail, blesslevel FROM ownership WHERE institution_id = $this->identifier ORDER BY user_id"); |
202 | - while ($a = mysqli_fetch_object($admins)) |
|
203 | - $returnarray[] = ['ID' => $a->user_id, 'MAIL' => $a->orig_mail, 'LEVEL' => $a->blesslevel]; |
|
211 | + while ($a = mysqli_fetch_object($admins)) { |
|
212 | + $returnarray[] = ['ID' => $a->user_id, 'MAIL' => $a->orig_mail, 'LEVEL' => $a->blesslevel]; |
|
213 | + } |
|
204 | 214 | return $returnarray; |
205 | 215 | } |
206 | 216 | |
@@ -253,12 +263,12 @@ discard block |
||
253 | 263 | public function getAttributes($option_name = 0) { |
254 | 264 | if ($option_name) { |
255 | 265 | $returnarray = []; |
256 | - foreach ($this->priv_attributes as $the_attr) |
|
257 | - if ($the_attr['name'] == $option_name) |
|
266 | + foreach ($this->priv_attributes as $the_attr) { |
|
267 | + if ($the_attr['name'] == $option_name) |
|
258 | 268 | $returnarray[] = $the_attr; |
269 | + } |
|
259 | 270 | return $returnarray; |
260 | - } |
|
261 | - else { |
|
271 | + } else { |
|
262 | 272 | return $this->priv_attributes; |
263 | 273 | } |
264 | 274 | } |
@@ -273,8 +283,9 @@ discard block |
||
273 | 283 | $this->updateFreshness(); |
274 | 284 | $exec_q = DBConnection::exec(IdP::$DB_TYPE, "SELECT row FROM institution_option WHERE institution_id = $this->identifier"); |
275 | 285 | $return_array = []; |
276 | - while ($a = mysqli_fetch_object($exec_q)) |
|
277 | - $return_array[$a->row] = "KILLME"; |
|
286 | + while ($a = mysqli_fetch_object($exec_q)) { |
|
287 | + $return_array[$a->row] = "KILLME"; |
|
288 | + } |
|
278 | 289 | return $return_array; |
279 | 290 | } |
280 | 291 | |
@@ -324,10 +335,11 @@ discard block |
||
324 | 335 | DBConnection::exec(IdP::$DB_TYPE, "INSERT INTO profile (inst_id) VALUES($this->identifier)"); |
325 | 336 | $identifier = DBConnection::lastID(IdP::$DB_TYPE); |
326 | 337 | |
327 | - if ($identifier > 0) |
|
328 | - return new Profile($identifier, $this); |
|
329 | - else |
|
330 | - return NULL; |
|
338 | + if ($identifier > 0) { |
|
339 | + return new Profile($identifier, $this); |
|
340 | + } else { |
|
341 | + return NULL; |
|
342 | + } |
|
331 | 343 | } |
332 | 344 | |
333 | 345 | /** |
@@ -335,13 +347,15 @@ discard block |
||
335 | 347 | */ |
336 | 348 | public function destroy() { |
337 | 349 | /* delete all profiles */ |
338 | - foreach ($this->listProfiles() as $profile) |
|
339 | - $profile->destroy(); |
|
350 | + foreach ($this->listProfiles() as $profile) { |
|
351 | + $profile->destroy(); |
|
352 | + } |
|
340 | 353 | /* double-check that all profiles are gone */ |
341 | 354 | $profiles = $this->listProfiles(); |
342 | 355 | |
343 | - if (count($profiles) > 0) |
|
344 | - die("This IdP shouldn't have any profiles any more!"); |
|
356 | + if (count($profiles) > 0) { |
|
357 | + die("This IdP shouldn't have any profiles any more!"); |
|
358 | + } |
|
345 | 359 | |
346 | 360 | DBConnection::exec(IdP::$DB_TYPE, "DELETE FROM ownership WHERE institution_id = $this->identifier"); |
347 | 361 | DBConnection::exec(IdP::$DB_TYPE, "DELETE FROM institution_option WHERE institution_id = $this->identifier"); |
@@ -380,13 +394,15 @@ discard block |
||
380 | 394 | $candidate_list = DBConnection::exec("EXTERNAL", "SELECT id_institution AS id, name AS collapsed_name FROM view_active_idp_institution WHERE country = '" . strtolower($this->federation) . "'"); |
381 | 395 | |
382 | 396 | $already_used = DBConnection::exec(IdP::$DB_TYPE, "SELECT DISTINCT external_db_id FROM institution WHERE external_db_id IS NOT NULL AND external_db_syncstate = " . EXTERNAL_DB_SYNCSTATE_SYNCED); |
383 | - while ($a = mysqli_fetch_object($already_used)) |
|
384 | - $usedarray[] = $a->external_db_id; |
|
397 | + while ($a = mysqli_fetch_object($already_used)) { |
|
398 | + $usedarray[] = $a->external_db_id; |
|
399 | + } |
|
385 | 400 | |
386 | 401 | // and split them into ID, LANG, NAME pairs |
387 | 402 | while ($a = mysqli_fetch_object($candidate_list)) { |
388 | - if (in_array($a->id, $usedarray)) |
|
389 | - continue; |
|
403 | + if (in_array($a->id, $usedarray)) { |
|
404 | + continue; |
|
405 | + } |
|
390 | 406 | $names = explode('#', $a->collapsed_name); |
391 | 407 | foreach ($names as $name) { |
392 | 408 | $perlang = explode(': ', $name, 2); |
@@ -396,12 +412,14 @@ discard block |
||
396 | 412 | // now see if any of the languages in CAT match any of those in the external DB |
397 | 413 | $mynames = $this->getAttributes("general:instname"); |
398 | 414 | $matching_candidates = []; |
399 | - foreach ($mynames as $onename) |
|
400 | - foreach ($list as $listentry) { |
|
415 | + foreach ($mynames as $onename) { |
|
416 | + foreach ($list as $listentry) { |
|
401 | 417 | $unserialised = unserialize($onename['value']); |
402 | - if (($unserialised['lang'] == $listentry['lang'] || $unserialised['lang'] == "C") && $unserialised['content'] == $listentry['name']) |
|
403 | - if (array_search($listentry['ID'], $matching_candidates) === FALSE) |
|
418 | + } |
|
419 | + if (($unserialised['lang'] == $listentry['lang'] || $unserialised['lang'] == "C") && $unserialised['content'] == $listentry['name']) { |
|
420 | + if (array_search($listentry['ID'], $matching_candidates) === FALSE) |
|
404 | 421 | $matching_candidates[] = $listentry['ID']; |
422 | + } |
|
405 | 423 | } |
406 | 424 | |
407 | 425 | return $matching_candidates; |
@@ -441,10 +459,11 @@ discard block |
||
441 | 459 | */ |
442 | 460 | public function getExternalDBEntityDetails() { |
443 | 461 | $external_id = $this->getExternalDBId(); |
444 | - if ($external_id !== FALSE) |
|
445 | - return Federation::getExternalDBEntityDetails($external_id); |
|
446 | - else |
|
447 | - return []; |
|
462 | + if ($external_id !== FALSE) { |
|
463 | + return Federation::getExternalDBEntityDetails($external_id); |
|
464 | + } else { |
|
465 | + return []; |
|
466 | + } |
|
448 | 467 | } |
449 | 468 | |
450 | 469 | public function setExternalDBId($identifier) { |
@@ -452,8 +471,9 @@ discard block |
||
452 | 471 | if (Config::$CONSORTIUM['name'] == "eduroam" && isset(Config::$CONSORTIUM['deployment-voodoo']) && Config::$CONSORTIUM['deployment-voodoo'] == "Operations Team") { // SW: APPROVED |
453 | 472 | $already_used = DBConnection::exec(IdP::$DB_TYPE, "SELECT DISTINCT external_db_id FROM institution WHERE external_db_id = '$identifier' AND external_db_syncstate = " . EXTERNAL_DB_SYNCSTATE_SYNCED); |
454 | 473 | |
455 | - if (mysqli_num_rows($already_used) == 0) |
|
456 | - DBConnection::exec(IdP::$DB_TYPE, "UPDATE institution SET external_db_id = '$identifier', external_db_syncstate = " . EXTERNAL_DB_SYNCSTATE_SYNCED . " WHERE inst_id = $this->identifier"); |
|
474 | + if (mysqli_num_rows($already_used) == 0) { |
|
475 | + DBConnection::exec(IdP::$DB_TYPE, "UPDATE institution SET external_db_id = '$identifier', external_db_syncstate = " . EXTERNAL_DB_SYNCSTATE_SYNCED . " WHERE inst_id = $this->identifier"); |
|
476 | + } |
|
457 | 477 | } |
458 | 478 | } |
459 | 479 |
@@ -94,7 +94,7 @@ |
||
94 | 94 | * |
95 | 95 | * @assert ("user") == Array("user:email","user:fedadmin","user:realname") |
96 | 96 | * |
97 | - * @param string $class_name optionally specifies the class of options to be listed (class is the part of the option name before the : sign) |
|
97 | + * @param integer $class_name optionally specifies the class of options to be listed (class is the part of the option name before the : sign) |
|
98 | 98 | * @return array of options |
99 | 99 | */ |
100 | 100 | public function availableOptions($class_name = 0) { |
@@ -79,8 +79,9 @@ |
||
79 | 79 | $this->type_db = []; |
80 | 80 | debug(3,"--- BEGIN constructing Options instance ---\n"); |
81 | 81 | $options = DBConnection::exec(Options::$DB_TYPE, "SELECT name,type,flag from profile_option_dict ORDER BY name"); |
82 | - while($a = mysqli_fetch_object($options)) |
|
83 | - $this->type_db[$a->name] = ["type" => $a->type, "flag" => $a->flag]; |
|
82 | + while($a = mysqli_fetch_object($options)) { |
|
83 | + $this->type_db[$a->name] = ["type" => $a->type, "flag" => $a->flag]; |
|
84 | + } |
|
84 | 85 | $this->type_db["general:logo_url"] = ["type" => "string", "flag" => NULL]; |
85 | 86 | $this->type_db["eap:ca_url"] = ["type" => "string", "flag" => NULL]; |
86 | 87 | $this->type_db["internal:country"] = ["type" => "string", "flag" => NULL]; |
@@ -96,6 +96,10 @@ discard block |
||
96 | 96 | define('QR_FORMAT_PNG', 1); |
97 | 97 | |
98 | 98 | class qrstr { |
99 | + |
|
100 | + /** |
|
101 | + * @param string $repl |
|
102 | + */ |
|
99 | 103 | public static function set(&$srctab, $x, $y, $repl, $replLen = false) { |
100 | 104 | $srctab[$y] = substr_replace($srctab[$y], ($replLen !== false)?substr($repl,0,$replLen):$repl, $x, ($replLen !== false)?$replLen:strlen($repl)); |
101 | 105 | } |
@@ -231,6 +235,11 @@ discard block |
||
231 | 235 | } |
232 | 236 | |
233 | 237 | //---------------------------------------------------------------------- |
238 | + |
|
239 | + /** |
|
240 | + * @param boolean $outfile |
|
241 | + * @param string $err |
|
242 | + */ |
|
234 | 243 | public static function log($outfile, $err) |
235 | 244 | { |
236 | 245 | if (QR_LOG_DIR !== false) { |
@@ -256,6 +265,10 @@ discard block |
||
256 | 265 | } |
257 | 266 | |
258 | 267 | //---------------------------------------------------------------------- |
268 | + |
|
269 | + /** |
|
270 | + * @param string $markerId |
|
271 | + */ |
|
259 | 272 | public static function markTime($markerId) |
260 | 273 | { |
261 | 274 | list($usec, $sec) = explode(" ", microtime()); |
@@ -410,18 +423,30 @@ discard block |
||
410 | 423 | } |
411 | 424 | |
412 | 425 | //---------------------------------------------------------------------- |
426 | + |
|
427 | + /** |
|
428 | + * @param integer $version |
|
429 | + */ |
|
413 | 430 | public static function getWidth($version) |
414 | 431 | { |
415 | 432 | return self::$capacity[$version][QRCAP_WIDTH]; |
416 | 433 | } |
417 | 434 | |
418 | 435 | //---------------------------------------------------------------------- |
436 | + |
|
437 | + /** |
|
438 | + * @param integer $version |
|
439 | + */ |
|
419 | 440 | public static function getRemainder($version) |
420 | 441 | { |
421 | 442 | return self::$capacity[$version][QRCAP_REMINDER]; |
422 | 443 | } |
423 | 444 | |
424 | 445 | //---------------------------------------------------------------------- |
446 | + |
|
447 | + /** |
|
448 | + * @param integer $size |
|
449 | + */ |
|
425 | 450 | public static function getMinimumVersion($size, $level) |
426 | 451 | { |
427 | 452 | |
@@ -535,6 +560,9 @@ discard block |
||
535 | 560 | //---------------------------------------------------------------------- |
536 | 561 | // CACHEABLE!!! |
537 | 562 | |
563 | + /** |
|
564 | + * @param integer $version |
|
565 | + */ |
|
538 | 566 | public static function getEccSpec($version, $level, array &$spec) |
539 | 567 | { |
540 | 568 | if (count($spec) < 5) { |
@@ -857,12 +885,20 @@ discard block |
||
857 | 885 | } |
858 | 886 | |
859 | 887 | //---------------------------------------------------------------------- |
888 | + |
|
889 | + /** |
|
890 | + * @param string $code |
|
891 | + */ |
|
860 | 892 | public static function unserial($code) |
861 | 893 | { |
862 | 894 | return explode("\n", gzuncompress($code)); |
863 | 895 | } |
864 | 896 | |
865 | 897 | //---------------------------------------------------------------------- |
898 | + |
|
899 | + /** |
|
900 | + * @param integer $version |
|
901 | + */ |
|
866 | 902 | public static function newFrame($version) |
867 | 903 | { |
868 | 904 | if($version < 1 || $version > QRSPEC_VERSION_MAX) |
@@ -1236,6 +1272,10 @@ discard block |
||
1236 | 1272 | } |
1237 | 1273 | |
1238 | 1274 | //---------------------------------------------------------------------- |
1275 | + |
|
1276 | + /** |
|
1277 | + * @param integer $version |
|
1278 | + */ |
|
1239 | 1279 | public function encodeBitStream($version) |
1240 | 1280 | { |
1241 | 1281 | try { |
@@ -1313,6 +1353,10 @@ discard block |
||
1313 | 1353 | } |
1314 | 1354 | |
1315 | 1355 | //---------------------------------------------------------------------- |
1356 | + |
|
1357 | + /** |
|
1358 | + * @param integer $version |
|
1359 | + */ |
|
1316 | 1360 | public function setVersion($version) |
1317 | 1361 | { |
1318 | 1362 | if($version < 0 || $version > QRSPEC_VERSION_MAX) { |
@@ -1351,6 +1395,12 @@ discard block |
||
1351 | 1395 | } |
1352 | 1396 | |
1353 | 1397 | //---------------------------------------------------------------------- |
1398 | + |
|
1399 | + /** |
|
1400 | + * @param QRinput $mode |
|
1401 | + * @param integer $size |
|
1402 | + * @param integer $data |
|
1403 | + */ |
|
1354 | 1404 | public function append($mode, $size, $data) |
1355 | 1405 | { |
1356 | 1406 | try { |
@@ -1446,6 +1496,10 @@ discard block |
||
1446 | 1496 | ]; |
1447 | 1497 | |
1448 | 1498 | //---------------------------------------------------------------------- |
1499 | + |
|
1500 | + /** |
|
1501 | + * @param integer $c |
|
1502 | + */ |
|
1449 | 1503 | public static function lookAnTable($c) |
1450 | 1504 | { |
1451 | 1505 | return (($c > 127)?-1:self::$anTable[$c]); |
@@ -1531,6 +1585,10 @@ discard block |
||
1531 | 1585 | |
1532 | 1586 | |
1533 | 1587 | //---------------------------------------------------------------------- |
1588 | + |
|
1589 | + /** |
|
1590 | + * @param integer $version |
|
1591 | + */ |
|
1534 | 1592 | public function estimateBitStreamSize($version) |
1535 | 1593 | { |
1536 | 1594 | $bits = 0; |
@@ -1648,6 +1706,10 @@ discard block |
||
1648 | 1706 | } |
1649 | 1707 | |
1650 | 1708 | //---------------------------------------------------------------------- |
1709 | + |
|
1710 | + /** |
|
1711 | + * @param QRbitstream $bstream |
|
1712 | + */ |
|
1651 | 1713 | public function appendPaddingBit(&$bstream) |
1652 | 1714 | { |
1653 | 1715 | $bits = $bstream->size(); |
@@ -1977,6 +2039,10 @@ discard block |
||
1977 | 2039 | public $modeHint; |
1978 | 2040 | |
1979 | 2041 | //---------------------------------------------------------------------- |
2042 | + |
|
2043 | + /** |
|
2044 | + * @param QRinput $input |
|
2045 | + */ |
|
1980 | 2046 | public function __construct($dataStr, $input, $modeHint) |
1981 | 2047 | { |
1982 | 2048 | $this->dataStr = $dataStr; |
@@ -1985,6 +2051,10 @@ discard block |
||
1985 | 2051 | } |
1986 | 2052 | |
1987 | 2053 | //---------------------------------------------------------------------- |
2054 | + |
|
2055 | + /** |
|
2056 | + * @param string $str |
|
2057 | + */ |
|
1988 | 2058 | public static function isdigitat($str, $pos) |
1989 | 2059 | { |
1990 | 2060 | if ($pos >= strlen($str)) |
@@ -1994,6 +2064,10 @@ discard block |
||
1994 | 2064 | } |
1995 | 2065 | |
1996 | 2066 | //---------------------------------------------------------------------- |
2067 | + |
|
2068 | + /** |
|
2069 | + * @param string $str |
|
2070 | + */ |
|
1997 | 2071 | public static function isalnumat($str, $pos) |
1998 | 2072 | { |
1999 | 2073 | if ($pos >= strlen($str)) |
@@ -2114,6 +2188,10 @@ discard block |
||
2114 | 2188 | } |
2115 | 2189 | |
2116 | 2190 | //---------------------------------------------------------------------- |
2191 | + |
|
2192 | + /** |
|
2193 | + * @return integer |
|
2194 | + */ |
|
2117 | 2195 | public function eatKanji() |
2118 | 2196 | { |
2119 | 2197 | $p = 0; |
@@ -2447,6 +2525,13 @@ discard block |
||
2447 | 2525 | public static $items = []; |
2448 | 2526 | |
2449 | 2527 | //---------------------------------------------------------------------- |
2528 | + |
|
2529 | + /** |
|
2530 | + * @param integer $symsize |
|
2531 | + * @param integer $gfpoly |
|
2532 | + * @param integer $fcr |
|
2533 | + * @param integer $prim |
|
2534 | + */ |
|
2450 | 2535 | public static function init_rs($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) |
2451 | 2536 | { |
2452 | 2537 | foreach(self::$items as $rs) { |
@@ -2601,6 +2686,10 @@ discard block |
||
2601 | 2686 | } |
2602 | 2687 | |
2603 | 2688 | //---------------------------------------------------------------------- |
2689 | + |
|
2690 | + /** |
|
2691 | + * @param string $code |
|
2692 | + */ |
|
2604 | 2693 | public static function unserial($code) |
2605 | 2694 | { |
2606 | 2695 | $codeArr = []; |
@@ -2661,6 +2750,10 @@ discard block |
||
2661 | 2750 | } |
2662 | 2751 | |
2663 | 2752 | //---------------------------------------------------------------------- |
2753 | + |
|
2754 | + /** |
|
2755 | + * @param integer $length |
|
2756 | + */ |
|
2664 | 2757 | public function calcN1N3($length) |
2665 | 2758 | { |
2666 | 2759 | $demerit = 0; |
@@ -2971,6 +3064,10 @@ discard block |
||
2971 | 3064 | public $data; |
2972 | 3065 | |
2973 | 3066 | //---------------------------------------------------------------------- |
3067 | + |
|
3068 | + /** |
|
3069 | + * @param integer $mask |
|
3070 | + */ |
|
2974 | 3071 | public function encodeMask(QRinput $input, $mask) |
2975 | 3072 | { |
2976 | 3073 | if($input->getVersion() < 0 || $input->getVersion() > QRSPEC_VERSION_MAX) { |
@@ -3052,6 +3149,11 @@ discard block |
||
3052 | 3149 | } |
3053 | 3150 | |
3054 | 3151 | //---------------------------------------------------------------------- |
3152 | + |
|
3153 | + /** |
|
3154 | + * @param integer $version |
|
3155 | + * @param integer $level |
|
3156 | + */ |
|
3055 | 3157 | public function encodeString8bit($string, $version, $level) |
3056 | 3158 | { |
3057 | 3159 | if(string == NULL) { |
@@ -3071,6 +3173,12 @@ discard block |
||
3071 | 3173 | } |
3072 | 3174 | |
3073 | 3175 | //---------------------------------------------------------------------- |
3176 | + |
|
3177 | + /** |
|
3178 | + * @param integer $version |
|
3179 | + * @param integer $level |
|
3180 | + * @param boolean $casesensitive |
|
3181 | + */ |
|
3074 | 3182 | public function encodeString($string, $version, $level, $hint, $casesensitive) |
3075 | 3183 | { |
3076 | 3184 |
@@ -176,8 +176,9 @@ discard block |
||
176 | 176 | { |
177 | 177 | $barcode_array = []; |
178 | 178 | |
179 | - if (!is_array($mode)) |
|
180 | - $mode = explode(',', $mode); |
|
179 | + if (!is_array($mode)) { |
|
180 | + $mode = explode(',', $mode); |
|
181 | + } |
|
181 | 182 | |
182 | 183 | $eccLevel = 'L'; |
183 | 184 | |
@@ -194,8 +195,9 @@ discard block |
||
194 | 195 | |
195 | 196 | foreach ($qrTab as $line) { |
196 | 197 | $arrAdd = []; |
197 | - foreach(str_split($line) as $char) |
|
198 | - $arrAdd[] = ($char=='1')?1:0; |
|
198 | + foreach(str_split($line) as $char) { |
|
199 | + $arrAdd[] = ($char=='1')?1:0; |
|
200 | + } |
|
199 | 201 | $barcode_array['bcode'][] = $arrAdd; |
200 | 202 | } |
201 | 203 | |
@@ -223,8 +225,9 @@ discard block |
||
223 | 225 | |
224 | 226 | $width = count($frame); |
225 | 227 | $bitMask = array_fill(0, $width, array_fill(0, $width, 0)); |
226 | - for ($maskNo=0; $maskNo<8; $maskNo++) |
|
227 | - $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true); |
|
228 | + for ($maskNo=0; $maskNo<8; $maskNo++) { |
|
229 | + $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true); |
|
230 | + } |
|
228 | 231 | } |
229 | 232 | |
230 | 233 | QRtools::markTime('after_build_cache'); |
@@ -261,8 +264,9 @@ discard block |
||
261 | 264 | list($usec, $sec) = explode(" ", microtime()); |
262 | 265 | $time = ((float)$usec + (float)$sec); |
263 | 266 | |
264 | - if (!isset($GLOBALS['qr_time_bench'])) |
|
265 | - $GLOBALS['qr_time_bench'] = []; |
|
267 | + if (!isset($GLOBALS['qr_time_bench'])) { |
|
268 | + $GLOBALS['qr_time_bench'] = []; |
|
269 | + } |
|
266 | 270 | |
267 | 271 | $GLOBALS['qr_time_bench'][$markerId] = $time; |
268 | 272 | } |
@@ -427,8 +431,9 @@ discard block |
||
427 | 431 | |
428 | 432 | for($i=1; $i<= QRSPEC_VERSION_MAX; $i++) { |
429 | 433 | $words = self::$capacity[$i][QRCAP_WORDS] - self::$capacity[$i][QRCAP_EC][$level]; |
430 | - if($words >= $size) |
|
431 | - return $i; |
|
434 | + if($words >= $size) { |
|
435 | + return $i; |
|
436 | + } |
|
432 | 437 | } |
433 | 438 | |
434 | 439 | return -1; |
@@ -446,8 +451,9 @@ discard block |
||
446 | 451 | //---------------------------------------------------------------------- |
447 | 452 | public static function lengthIndicator($mode, $version) |
448 | 453 | { |
449 | - if ($mode == QR_MODE_STRUCTURE) |
|
450 | - return 0; |
|
454 | + if ($mode == QR_MODE_STRUCTURE) { |
|
455 | + return 0; |
|
456 | + } |
|
451 | 457 | |
452 | 458 | if ($version <= 9) { |
453 | 459 | $l = 0; |
@@ -463,8 +469,9 @@ discard block |
||
463 | 469 | //---------------------------------------------------------------------- |
464 | 470 | public static function maximumWords($mode, $version) |
465 | 471 | { |
466 | - if($mode == QR_MODE_STRUCTURE) |
|
467 | - return 3; |
|
472 | + if($mode == QR_MODE_STRUCTURE) { |
|
473 | + return 3; |
|
474 | + } |
|
468 | 475 | |
469 | 476 | if($version <= 9) { |
470 | 477 | $l = 0; |
@@ -610,8 +617,9 @@ discard block |
||
610 | 617 | //---------------------------------------------------------------------- |
611 | 618 | public static function putAlignmentPattern($version, &$frame, $width) |
612 | 619 | { |
613 | - if($version < 2) |
|
614 | - return; |
|
620 | + if($version < 2) { |
|
621 | + return; |
|
622 | + } |
|
615 | 623 | |
616 | 624 | $d = self::$alignmentPattern[$version][1] - self::$alignmentPattern[$version][0]; |
617 | 625 | if($d < 0) { |
@@ -663,8 +671,9 @@ discard block |
||
663 | 671 | //---------------------------------------------------------------------- |
664 | 672 | public static function getVersionPattern($version) |
665 | 673 | { |
666 | - if($version < 7 || $version > QRSPEC_VERSION_MAX) |
|
667 | - return 0; |
|
674 | + if($version < 7 || $version > QRSPEC_VERSION_MAX) { |
|
675 | + return 0; |
|
676 | + } |
|
668 | 677 | |
669 | 678 | return self::$versionPattern[$version -7]; |
670 | 679 | } |
@@ -681,11 +690,13 @@ discard block |
||
681 | 690 | |
682 | 691 | public static function getFormatInfo($mask, $level) |
683 | 692 | { |
684 | - if($mask < 0 || $mask > 7) |
|
685 | - return 0; |
|
693 | + if($mask < 0 || $mask > 7) { |
|
694 | + return 0; |
|
695 | + } |
|
686 | 696 | |
687 | - if($level < 0 || $level > 3) |
|
688 | - return 0; |
|
697 | + if($level < 0 || $level > 3) { |
|
698 | + return 0; |
|
699 | + } |
|
689 | 700 | |
690 | 701 | return self::$formatInfo[$level][$mask]; |
691 | 702 | } |
@@ -865,8 +876,9 @@ discard block |
||
865 | 876 | //---------------------------------------------------------------------- |
866 | 877 | public static function newFrame($version) |
867 | 878 | { |
868 | - if($version < 1 || $version > QRSPEC_VERSION_MAX) |
|
869 | - return null; |
|
879 | + if($version < 1 || $version > QRSPEC_VERSION_MAX) { |
|
880 | + return null; |
|
881 | + } |
|
870 | 882 | |
871 | 883 | if(!isset(self::$frames[$version])) { |
872 | 884 | |
@@ -884,8 +896,9 @@ discard block |
||
884 | 896 | } |
885 | 897 | } |
886 | 898 | |
887 | - if(is_null(self::$frames[$version])) |
|
888 | - return null; |
|
899 | + if(is_null(self::$frames[$version])) { |
|
900 | + return null; |
|
901 | + } |
|
889 | 902 | |
890 | 903 | return self::$frames[$version]; |
891 | 904 | } |
@@ -953,7 +966,7 @@ discard block |
||
953 | 966 | ImagePng($image, $filename); |
954 | 967 | header("Content-type: image/png"); |
955 | 968 | ImagePng($image); |
956 | - }else{ |
|
969 | + } else{ |
|
957 | 970 | ImagePng($image, $filename); |
958 | 971 | } |
959 | 972 | } |
@@ -1213,8 +1226,9 @@ discard block |
||
1213 | 1226 | { |
1214 | 1227 | $bits = 0; |
1215 | 1228 | |
1216 | - if($version == 0) |
|
1217 | - $version = 1; |
|
1229 | + if($version == 0) { |
|
1230 | + $version = 1; |
|
1231 | + } |
|
1218 | 1232 | |
1219 | 1233 | switch($this->mode) { |
1220 | 1234 | case QR_MODE_NUM: $bits = QRinput::estimateBitsModeNum($this->size); break; |
@@ -1273,8 +1287,9 @@ discard block |
||
1273 | 1287 | break; |
1274 | 1288 | } |
1275 | 1289 | |
1276 | - if($ret < 0) |
|
1277 | - return -1; |
|
1290 | + if($ret < 0) { |
|
1291 | + return -1; |
|
1292 | + } |
|
1278 | 1293 | } |
1279 | 1294 | |
1280 | 1295 | return $this->bstream->size(); |
@@ -1491,8 +1506,9 @@ discard block |
||
1491 | 1506 | //---------------------------------------------------------------------- |
1492 | 1507 | public static function checkModeKanji($size, $data) |
1493 | 1508 | { |
1494 | - if($size & 1) |
|
1495 | - return false; |
|
1509 | + if($size & 1) { |
|
1510 | + return false; |
|
1511 | + } |
|
1496 | 1512 | |
1497 | 1513 | for($i=0; $i<$size; $i+=2) { |
1498 | 1514 | $val = (ord($data[$i]) << 8) | ord($data[$i+1]); |
@@ -1512,8 +1528,9 @@ discard block |
||
1512 | 1528 | |
1513 | 1529 | public static function check($mode, $size, $data) |
1514 | 1530 | { |
1515 | - if($size <= 0) |
|
1516 | - return false; |
|
1531 | + if($size <= 0) { |
|
1532 | + return false; |
|
1533 | + } |
|
1517 | 1534 | |
1518 | 1535 | switch($mode) { |
1519 | 1536 | case QR_MODE_NUM: return self::checkModeNum($size, $data); break; |
@@ -1578,8 +1595,9 @@ discard block |
||
1578 | 1595 | $chunks = (int)($payload / 11); |
1579 | 1596 | $remain = $payload - $chunks * 11; |
1580 | 1597 | $size = $chunks * 2; |
1581 | - if($remain >= 6) |
|
1582 | - $size++; |
|
1598 | + if($remain >= 6) { |
|
1599 | + $size++; |
|
1600 | + } |
|
1583 | 1601 | break; |
1584 | 1602 | case QR_MODE_8: |
1585 | 1603 | $size = (int)($payload / 8); |
@@ -1596,8 +1614,12 @@ discard block |
||
1596 | 1614 | } |
1597 | 1615 | |
1598 | 1616 | $maxsize = QRspec::maximumWords($mode, $version); |
1599 | - if($size < 0) $size = 0; |
|
1600 | - if($size > $maxsize) $size = $maxsize; |
|
1617 | + if($size < 0) { |
|
1618 | + $size = 0; |
|
1619 | + } |
|
1620 | + if($size > $maxsize) { |
|
1621 | + $size = $maxsize; |
|
1622 | + } |
|
1601 | 1623 | |
1602 | 1624 | return $size; |
1603 | 1625 | } |
@@ -1610,8 +1632,9 @@ discard block |
||
1610 | 1632 | foreach($this->items as $item) { |
1611 | 1633 | $bits = $item->encodeBitStream($this->version); |
1612 | 1634 | |
1613 | - if($bits < 0) |
|
1614 | - return -1; |
|
1635 | + if($bits < 0) { |
|
1636 | + return -1; |
|
1637 | + } |
|
1615 | 1638 | |
1616 | 1639 | $total += $bits; |
1617 | 1640 | } |
@@ -1630,8 +1653,9 @@ discard block |
||
1630 | 1653 | for(;;) { |
1631 | 1654 | $bits = $this->createBitStream(); |
1632 | 1655 | |
1633 | - if($bits < 0) |
|
1634 | - return -1; |
|
1656 | + if($bits < 0) { |
|
1657 | + return -1; |
|
1658 | + } |
|
1635 | 1659 | |
1636 | 1660 | $ver = QRspec::getMinimumVersion((int)(($bits + 7) / 8), $this->level); |
1637 | 1661 | if($ver < 0) { |
@@ -1668,8 +1692,9 @@ discard block |
||
1668 | 1692 | $padding = new QRbitstream(); |
1669 | 1693 | $ret = $padding->appendNum($words * 8 - $bits + 4, 0); |
1670 | 1694 | |
1671 | - if($ret < 0) |
|
1672 | - return $ret; |
|
1695 | + if($ret < 0) { |
|
1696 | + return $ret; |
|
1697 | + } |
|
1673 | 1698 | |
1674 | 1699 | $padlen = $maxwords - $words; |
1675 | 1700 | |
@@ -1682,8 +1707,9 @@ discard block |
||
1682 | 1707 | |
1683 | 1708 | $ret = $padding->appendBytes($padlen, $padbuf); |
1684 | 1709 | |
1685 | - if($ret < 0) |
|
1686 | - return $ret; |
|
1710 | + if($ret < 0) { |
|
1711 | + return $ret; |
|
1712 | + } |
|
1687 | 1713 | |
1688 | 1714 | } |
1689 | 1715 | |
@@ -1860,13 +1886,15 @@ discard block |
||
1860 | 1886 | //---------------------------------------------------------------------- |
1861 | 1887 | public function appendNum($bits, $num) |
1862 | 1888 | { |
1863 | - if ($bits == 0) |
|
1864 | - return 0; |
|
1889 | + if ($bits == 0) { |
|
1890 | + return 0; |
|
1891 | + } |
|
1865 | 1892 | |
1866 | 1893 | $b = QRbitstream::newFromNum($bits, $num); |
1867 | 1894 | |
1868 | - if(is_null($b)) |
|
1869 | - return -1; |
|
1895 | + if(is_null($b)) { |
|
1896 | + return -1; |
|
1897 | + } |
|
1870 | 1898 | |
1871 | 1899 | $ret = $this->append($b); |
1872 | 1900 | unset($b); |
@@ -1877,13 +1905,15 @@ discard block |
||
1877 | 1905 | //---------------------------------------------------------------------- |
1878 | 1906 | public function appendBytes($size, $data) |
1879 | 1907 | { |
1880 | - if ($size == 0) |
|
1881 | - return 0; |
|
1908 | + if ($size == 0) { |
|
1909 | + return 0; |
|
1910 | + } |
|
1882 | 1911 | |
1883 | 1912 | $b = QRbitstream::newFromBytes($size, $data); |
1884 | 1913 | |
1885 | - if(is_null($b)) |
|
1886 | - return -1; |
|
1914 | + if(is_null($b)) { |
|
1915 | + return -1; |
|
1916 | + } |
|
1887 | 1917 | |
1888 | 1918 | $ret = $this->append($b); |
1889 | 1919 | unset($b); |
@@ -1987,8 +2017,9 @@ discard block |
||
1987 | 2017 | //---------------------------------------------------------------------- |
1988 | 2018 | public static function isdigitat($str, $pos) |
1989 | 2019 | { |
1990 | - if ($pos >= strlen($str)) |
|
1991 | - return false; |
|
2020 | + if ($pos >= strlen($str)) { |
|
2021 | + return false; |
|
2022 | + } |
|
1992 | 2023 | |
1993 | 2024 | return ((ord($str[$pos]) >= ord('0'))&&(ord($str[$pos]) <= ord('9'))); |
1994 | 2025 | } |
@@ -1996,8 +2027,9 @@ discard block |
||
1996 | 2027 | //---------------------------------------------------------------------- |
1997 | 2028 | public static function isalnumat($str, $pos) |
1998 | 2029 | { |
1999 | - if ($pos >= strlen($str)) |
|
2000 | - return false; |
|
2030 | + if ($pos >= strlen($str)) { |
|
2031 | + return false; |
|
2032 | + } |
|
2001 | 2033 | |
2002 | 2034 | return (QRinput::lookAnTable(ord($str[$pos])) >= 0); |
2003 | 2035 | } |
@@ -2005,8 +2037,9 @@ discard block |
||
2005 | 2037 | //---------------------------------------------------------------------- |
2006 | 2038 | public function identifyMode($pos) |
2007 | 2039 | { |
2008 | - if ($pos >= strlen($this->dataStr)) |
|
2009 | - return QR_MODE_NUL; |
|
2040 | + if ($pos >= strlen($this->dataStr)) { |
|
2041 | + return QR_MODE_NUL; |
|
2042 | + } |
|
2010 | 2043 | |
2011 | 2044 | $c = $this->dataStr[$pos]; |
2012 | 2045 | |
@@ -2060,8 +2093,9 @@ discard block |
||
2060 | 2093 | } |
2061 | 2094 | |
2062 | 2095 | $ret = $this->input->append(QR_MODE_NUM, $run, str_split($this->dataStr)); |
2063 | - if($ret < 0) |
|
2064 | - return -1; |
|
2096 | + if($ret < 0) { |
|
2097 | + return -1; |
|
2098 | + } |
|
2065 | 2099 | |
2066 | 2100 | return $run; |
2067 | 2101 | } |
@@ -2107,8 +2141,9 @@ discard block |
||
2107 | 2141 | } |
2108 | 2142 | |
2109 | 2143 | $ret = $this->input->append(QR_MODE_AN, $run, str_split($this->dataStr)); |
2110 | - if($ret < 0) |
|
2111 | - return -1; |
|
2144 | + if($ret < 0) { |
|
2145 | + return -1; |
|
2146 | + } |
|
2112 | 2147 | |
2113 | 2148 | return $run; |
2114 | 2149 | } |
@@ -2123,8 +2158,9 @@ discard block |
||
2123 | 2158 | } |
2124 | 2159 | |
2125 | 2160 | $ret = $this->input->append(QR_MODE_KANJI, $p, str_split($this->dataStr)); |
2126 | - if($ret < 0) |
|
2127 | - return -1; |
|
2161 | + if($ret < 0) { |
|
2162 | + return -1; |
|
2163 | + } |
|
2128 | 2164 | |
2129 | 2165 | return $run; |
2130 | 2166 | } |
@@ -2178,8 +2214,9 @@ discard block |
||
2178 | 2214 | $run = $p; |
2179 | 2215 | $ret = $this->input->append(QR_MODE_8, $run, str_split($this->dataStr)); |
2180 | 2216 | |
2181 | - if($ret < 0) |
|
2182 | - return -1; |
|
2217 | + if($ret < 0) { |
|
2218 | + return -1; |
|
2219 | + } |
|
2183 | 2220 | |
2184 | 2221 | return $run; |
2185 | 2222 | } |
@@ -2189,8 +2226,9 @@ discard block |
||
2189 | 2226 | { |
2190 | 2227 | while (strlen($this->dataStr) > 0) |
2191 | 2228 | { |
2192 | - if($this->dataStr == '') |
|
2193 | - return 0; |
|
2229 | + if($this->dataStr == '') { |
|
2230 | + return 0; |
|
2231 | + } |
|
2194 | 2232 | |
2195 | 2233 | $mode = $this->identifyMode(0); |
2196 | 2234 | |
@@ -2198,16 +2236,22 @@ discard block |
||
2198 | 2236 | case QR_MODE_NUM: $length = $this->eatNum(); break; |
2199 | 2237 | case QR_MODE_AN: $length = $this->eatAn(); break; |
2200 | 2238 | case QR_MODE_KANJI: |
2201 | - if ($hint == QR_MODE_KANJI) |
|
2202 | - $length = $this->eatKanji(); |
|
2203 | - else $length = $this->eat8(); |
|
2239 | + if ($hint == QR_MODE_KANJI) { |
|
2240 | + $length = $this->eatKanji(); |
|
2241 | + } else { |
|
2242 | + $length = $this->eat8(); |
|
2243 | + } |
|
2204 | 2244 | break; |
2205 | 2245 | default: $length = $this->eat8(); break; |
2206 | 2246 | |
2207 | 2247 | } |
2208 | 2248 | |
2209 | - if($length == 0) return 0; |
|
2210 | - if($length < 0) return -1; |
|
2249 | + if($length == 0) { |
|
2250 | + return 0; |
|
2251 | + } |
|
2252 | + if($length < 0) { |
|
2253 | + return -1; |
|
2254 | + } |
|
2211 | 2255 | |
2212 | 2256 | $this->dataStr = substr($this->dataStr, $length); |
2213 | 2257 | } |
@@ -2243,8 +2287,9 @@ discard block |
||
2243 | 2287 | |
2244 | 2288 | $split = new QRsplit($string, $input, $modeHint); |
2245 | 2289 | |
2246 | - if(!$casesensitive) |
|
2247 | - $split->toUpper(); |
|
2290 | + if(!$casesensitive) { |
|
2291 | + $split->toUpper(); |
|
2292 | + } |
|
2248 | 2293 | |
2249 | 2294 | return $split->splitString(); |
2250 | 2295 | } |
@@ -2321,11 +2366,23 @@ discard block |
||
2321 | 2366 | $rs = null; |
2322 | 2367 | |
2323 | 2368 | // Check parameter ranges |
2324 | - if($symsize < 0 || $symsize > 8) return $rs; |
|
2325 | - if($fcr < 0 || $fcr >= (1<<$symsize)) return $rs; |
|
2326 | - if($prim <= 0 || $prim >= (1<<$symsize)) return $rs; |
|
2327 | - if($nroots < 0 || $nroots >= (1<<$symsize)) return $rs; // Can't have more roots than symbol values! |
|
2328 | - if($pad < 0 || $pad >= ((1<<$symsize) -1 - $nroots)) return $rs; // Too much padding |
|
2369 | + if($symsize < 0 || $symsize > 8) { |
|
2370 | + return $rs; |
|
2371 | + } |
|
2372 | + if($fcr < 0 || $fcr >= (1<<$symsize)) { |
|
2373 | + return $rs; |
|
2374 | + } |
|
2375 | + if($prim <= 0 || $prim >= (1<<$symsize)) { |
|
2376 | + return $rs; |
|
2377 | + } |
|
2378 | + if($nroots < 0 || $nroots >= (1<<$symsize)) { |
|
2379 | + return $rs; |
|
2380 | + } |
|
2381 | + // Can't have more roots than symbol values! |
|
2382 | + if($pad < 0 || $pad >= ((1<<$symsize) -1 - $nroots)) { |
|
2383 | + return $rs; |
|
2384 | + } |
|
2385 | + // Too much padding |
|
2329 | 2386 | |
2330 | 2387 | $rs = new QRrsItem(); |
2331 | 2388 | $rs->mm = $symsize; |
@@ -2391,8 +2448,9 @@ discard block |
||
2391 | 2448 | } |
2392 | 2449 | |
2393 | 2450 | // convert rs->genpoly[] to index form for quicker encoding |
2394 | - for ($i = 0; $i <= $nroots; $i++) |
|
2395 | - $rs->genpoly[$i] = $rs->index_of[$rs->genpoly[$i]]; |
|
2451 | + for ($i = 0; $i <= $nroots; $i++) { |
|
2452 | + $rs->genpoly[$i] = $rs->index_of[$rs->genpoly[$i]]; |
|
2453 | + } |
|
2396 | 2454 | |
2397 | 2455 | return $rs; |
2398 | 2456 | } |
@@ -2450,12 +2508,24 @@ discard block |
||
2450 | 2508 | public static function init_rs($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) |
2451 | 2509 | { |
2452 | 2510 | foreach(self::$items as $rs) { |
2453 | - if($rs->pad != $pad) continue; |
|
2454 | - if($rs->nroots != $nroots) continue; |
|
2455 | - if($rs->mm != $symsize) continue; |
|
2456 | - if($rs->gfpoly != $gfpoly) continue; |
|
2457 | - if($rs->fcr != $fcr) continue; |
|
2458 | - if($rs->prim != $prim) continue; |
|
2511 | + if($rs->pad != $pad) { |
|
2512 | + continue; |
|
2513 | + } |
|
2514 | + if($rs->nroots != $nroots) { |
|
2515 | + continue; |
|
2516 | + } |
|
2517 | + if($rs->mm != $symsize) { |
|
2518 | + continue; |
|
2519 | + } |
|
2520 | + if($rs->gfpoly != $gfpoly) { |
|
2521 | + continue; |
|
2522 | + } |
|
2523 | + if($rs->fcr != $fcr) { |
|
2524 | + continue; |
|
2525 | + } |
|
2526 | + if($rs->prim != $prim) { |
|
2527 | + continue; |
|
2528 | + } |
|
2459 | 2529 | |
2460 | 2530 | return $rs; |
2461 | 2531 | } |
@@ -2594,8 +2664,9 @@ discard block |
||
2594 | 2664 | { |
2595 | 2665 | $codeArr = []; |
2596 | 2666 | |
2597 | - foreach ($bitFrame as $line) |
|
2598 | - $codeArr[] = join('', $line); |
|
2667 | + foreach ($bitFrame as $line) { |
|
2668 | + $codeArr[] = join('', $line); |
|
2669 | + } |
|
2599 | 2670 | |
2600 | 2671 | return gzcompress(join("\n", $codeArr), 9); |
2601 | 2672 | } |
@@ -2606,8 +2677,9 @@ discard block |
||
2606 | 2677 | $codeArr = []; |
2607 | 2678 | |
2608 | 2679 | $codeLines = explode("\n", gzuncompress($code)); |
2609 | - foreach ($codeLines as $line) |
|
2610 | - $codeArr[] = str_split($line); |
|
2680 | + foreach ($codeLines as $line) { |
|
2681 | + $codeArr[] = str_split($line); |
|
2682 | + } |
|
2611 | 2683 | |
2612 | 2684 | return $codeArr; |
2613 | 2685 | } |
@@ -2625,16 +2697,18 @@ discard block |
||
2625 | 2697 | $bitMask = self::unserial(file_get_contents($fileName)); |
2626 | 2698 | } else { |
2627 | 2699 | $bitMask = $this->generateMaskNo($maskNo, $width, $s, $d); |
2628 | - if (!file_exists(QR_CACHE_DIR.'mask_'.$maskNo)) |
|
2629 | - mkdir(QR_CACHE_DIR.'mask_'.$maskNo); |
|
2700 | + if (!file_exists(QR_CACHE_DIR.'mask_'.$maskNo)) { |
|
2701 | + mkdir(QR_CACHE_DIR.'mask_'.$maskNo); |
|
2702 | + } |
|
2630 | 2703 | file_put_contents($fileName, self::serial($bitMask)); |
2631 | 2704 | } |
2632 | 2705 | } else { |
2633 | 2706 | $bitMask = $this->generateMaskNo($maskNo, $width, $s, $d); |
2634 | 2707 | } |
2635 | 2708 | |
2636 | - if ($maskGenOnly) |
|
2637 | - return; |
|
2709 | + if ($maskGenOnly) { |
|
2710 | + return; |
|
2711 | + } |
|
2638 | 2712 | |
2639 | 2713 | $d = $s; |
2640 | 2714 | |
@@ -2701,8 +2775,9 @@ discard block |
||
2701 | 2775 | |
2702 | 2776 | $frameY = $frame[$y]; |
2703 | 2777 | |
2704 | - if ($y>0) |
|
2705 | - $frameYM = $frame[$y-1]; |
|
2778 | + if ($y>0) { |
|
2779 | + $frameYM = $frame[$y-1]; |
|
2780 | + } |
|
2706 | 2781 | |
2707 | 2782 | for($x=0; $x<$width; $x++) { |
2708 | 2783 | if(($x > 0) && ($y > 0)) { |
@@ -2915,14 +2990,17 @@ discard block |
||
2915 | 2990 | $blockNo++; |
2916 | 2991 | } |
2917 | 2992 | |
2918 | - if(QRspec::rsBlockNum2($spec) == 0) |
|
2919 | - return 0; |
|
2993 | + if(QRspec::rsBlockNum2($spec) == 0) { |
|
2994 | + return 0; |
|
2995 | + } |
|
2920 | 2996 | |
2921 | 2997 | $dl = QRspec::rsDataCodes2($spec); |
2922 | 2998 | $el = QRspec::rsEccCodes2($spec); |
2923 | 2999 | $rs = QRrs::init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el); |
2924 | 3000 | |
2925 | - if($rs == NULL) return -1; |
|
3001 | + if($rs == NULL) { |
|
3002 | + return -1; |
|
3003 | + } |
|
2926 | 3004 | |
2927 | 3005 | for($i=0; $i<QRspec::rsBlockNum2($spec); $i++) { |
2928 | 3006 | $ecc = array_slice($this->ecccode,$eccPos); |
@@ -3060,7 +3138,9 @@ discard block |
||
3060 | 3138 | } |
3061 | 3139 | |
3062 | 3140 | $input = new QRinput($version, $level); |
3063 | - if($input == NULL) return NULL; |
|
3141 | + if($input == NULL) { |
|
3142 | + return NULL; |
|
3143 | + } |
|
3064 | 3144 | |
3065 | 3145 | $ret = $input->append($input, QR_MODE_8, strlen($string), str_split($string)); |
3066 | 3146 | if($ret < 0) { |
@@ -3080,7 +3160,9 @@ discard block |
||
3080 | 3160 | } |
3081 | 3161 | |
3082 | 3162 | $input = new QRinput($version, $level); |
3083 | - if($input == NULL) return NULL; |
|
3163 | + if($input == NULL) { |
|
3164 | + return NULL; |
|
3165 | + } |
|
3084 | 3166 | |
3085 | 3167 | $ret = QRsplit::splitStringToQRinput($string, $input, $hint, $casesensitive); |
3086 | 3168 | if($ret < 0) { |
@@ -3190,7 +3272,9 @@ discard block |
||
3190 | 3272 | } |
3191 | 3273 | } |
3192 | 3274 | } |
3193 | - if($x < 0 || $y < 0) return null; |
|
3275 | + if($x < 0 || $y < 0) { |
|
3276 | + return null; |
|
3277 | + } |
|
3194 | 3278 | |
3195 | 3279 | $this->x = $x; |
3196 | 3280 | $this->y = $y; |
@@ -3297,8 +3381,9 @@ discard block |
||
3297 | 3381 | $err = ob_get_contents(); |
3298 | 3382 | ob_end_clean(); |
3299 | 3383 | |
3300 | - if ($err != '') |
|
3301 | - QRtools::log($outfile, $err); |
|
3384 | + if ($err != '') { |
|
3385 | + QRtools::log($outfile, $err); |
|
3386 | + } |
|
3302 | 3387 | |
3303 | 3388 | $maxSize = (int)(QR_PNG_MAXIMUM_SIZE / (count($tab)+2*$this->margin)); |
3304 | 3389 |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * supported EAP types from the DB and stores them in the priv_ arrays. |
74 | 74 | * |
75 | 75 | * @param int $p_id identifier of the profile in the DB |
76 | - * @param IdP $idp_object optionally, the institution to which this Profile belongs. Saves the construction of the IdP instance. If omitted, an extra query and instantiation is executed to find out. |
|
76 | + * @param integer $idp_object optionally, the institution to which this Profile belongs. Saves the construction of the IdP instance. If omitted, an extra query and instantiation is executed to find out. |
|
77 | 77 | */ |
78 | 78 | public function __construct($p_id, $idp_object = 0) { |
79 | 79 | debug(3, "--- BEGIN Constructing new Profile object ... ---\n"); |
@@ -372,6 +372,8 @@ discard block |
||
372 | 372 | * |
373 | 373 | * @param string device the device identifier string |
374 | 374 | * @param string path the path where the new installer can be found |
375 | + * @param string $device |
|
376 | + * @param string $path |
|
375 | 377 | */ |
376 | 378 | public function updateCache($device, $path,$mime) { |
377 | 379 | $device = DBConnection::escape_value(Profile::$DB_TYPE, $device); |
@@ -384,9 +386,9 @@ discard block |
||
384 | 386 | /** |
385 | 387 | * Log a new download for our stats |
386 | 388 | * |
387 | - * @param device the device id string |
|
388 | - * @param area either admin or user |
|
389 | - * @return TRUE if incrementing worked, FALSE if not |
|
389 | + * @param device string device id string |
|
390 | + * @param area string admin or user |
|
391 | + * @return boolean if incrementing worked, FALSE if not |
|
390 | 392 | */ |
391 | 393 | public function incrementDownloadStats($device, $area) { |
392 | 394 | $device = DBConnection::escape_value(Profile::$DB_TYPE, $device); |
@@ -399,7 +401,7 @@ discard block |
||
399 | 401 | |
400 | 402 | /** |
401 | 403 | * Retrieve current download stats from database, either for one specific device or for all devices |
402 | - * @param string $device the device id string |
|
404 | + * @param integer $device the device id string |
|
403 | 405 | * @return mixed user downloads of this profile; if device is given, returns the counter as int, otherwise an array with devicename => counter |
404 | 406 | */ |
405 | 407 | public function getUserDownloadStats($device = 0) { |
@@ -464,7 +466,7 @@ discard block |
||
464 | 466 | * @param string $attr_name name of the attribute to set |
465 | 467 | * @param string $attr_value value of the attribute to set |
466 | 468 | * @param int $eap_type identifier of the EAP type in the database. 0 if the attribute is valid for all EAP types. |
467 | - * @param string $device identifier of the device in the databse. Omit the argument if attribute is valid for all devices. |
|
469 | + * @param integer $device identifier of the device in the databse. Omit the argument if attribute is valid for all devices. |
|
468 | 470 | */ |
469 | 471 | public function addAttribute($attr_name, $attr_value, $eap_type, $device = 0) { |
470 | 472 | $attr_name = DBConnection::escape_value(Profile::$DB_TYPE, $attr_name); |
@@ -574,7 +576,7 @@ discard block |
||
574 | 576 | /** Returns an array of the profile's attributes. |
575 | 577 | * |
576 | 578 | * @param string option_name the name of a specific option. If set, only returns option values for this option name |
577 | - * @param eapmethod the EAP type, in array ("OUTER/INNER") notation. If set, returns only attributes which are specific to that EAP type |
|
579 | + * @param eapmethod integer EAP type, in array ("OUTER/INNER") notation. If set, returns only attributes which are specific to that EAP type |
|
578 | 580 | * @param string device the device ID string. If set, returns only attributes which are specific to that device |
579 | 581 | * @return array attributes of the profile |
580 | 582 | */ |
@@ -658,7 +660,7 @@ discard block |
||
658 | 660 | /** |
659 | 661 | * list all devices marking their availabiblity and possible redirects |
660 | 662 | * |
661 | - * @param string $locale for text-based attributes, either returns values for the default value, or if specified here, in the locale specified |
|
663 | + * @param integer $locale for text-based attributes, either returns values for the default value, or if specified here, in the locale specified |
|
662 | 664 | * @return array of device ids display names and their status |
663 | 665 | */ |
664 | 666 | public function listDevices($locale = 0) { |
@@ -713,7 +715,7 @@ discard block |
||
713 | 715 | * as wel as the chosen language. |
714 | 716 | * can be called with an optional $eap argument |
715 | 717 | * |
716 | - * @param array $eap if specified, retrieves attributes specific to the given EAP type |
|
718 | + * @param integer $eap if specified, retrieves attributes specific to the given EAP type |
|
717 | 719 | * @return array list of attributes in collapsed style (index is the attrib name, value is an array of different values) |
718 | 720 | */ |
719 | 721 | public function getCollapsedAttributes($eap = 0) { |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | |
241 | 241 | $idpoptions = $idp->getAttributes(); |
242 | 242 | |
243 | - foreach ($idpoptions as $the_attr) |
|
244 | - $temparray[] = [ |
|
243 | + foreach ($idpoptions as $the_attr) { |
|
244 | + $temparray[] = [ |
|
245 | 245 | "name" => $the_attr["name"], |
246 | 246 | "value" => $the_attr["value"], |
247 | 247 | "level" => $the_attr["level"], |
@@ -250,30 +250,35 @@ discard block |
||
250 | 250 | "device" => NULL, |
251 | 251 | "eapmethod" => NULL, |
252 | 252 | ]; |
253 | + } |
|
253 | 254 | |
254 | 255 | $this->priv_attributes = []; |
255 | 256 | |
256 | 257 | // check sanity (device and eapmethod are mutually exclusive) and first batch of adding (method level) |
257 | 258 | |
258 | 259 | foreach ($temparray as $attrib) { |
259 | - if ($attrib["device"] != NULL && $attrib["eapmethod"] != NULL) |
|
260 | - debug(2, "Sanity check failed - device and eapmethod are set!\n"); |
|
260 | + if ($attrib["device"] != NULL && $attrib["eapmethod"] != NULL) { |
|
261 | + debug(2, "Sanity check failed - device and eapmethod are set!\n"); |
|
262 | + } |
|
261 | 263 | } |
262 | 264 | |
263 | 265 | foreach ($temparray as $attrib) { |
264 | - if ($attrib["device"] != NULL || $attrib["eapmethod"] != NULL) |
|
265 | - $this->priv_attributes[] = $attrib; |
|
266 | + if ($attrib["device"] != NULL || $attrib["eapmethod"] != NULL) { |
|
267 | + $this->priv_attributes[] = $attrib; |
|
268 | + } |
|
266 | 269 | } |
267 | 270 | // pick all attributes which are profile specific and place into final array if no eap/device-specific exists |
268 | 271 | |
269 | 272 | foreach ($temparray as $attrib) { |
270 | 273 | if ($attrib["level"] == "Profile") { |
271 | 274 | $ignore = ""; |
272 | - foreach ($this->priv_attributes as $approved_attrib) |
|
273 | - if ($attrib["name"] == $approved_attrib["name"] && $approved_attrib["level"] != "IdP" && $approved_attrib["level"] != "Profile") |
|
275 | + foreach ($this->priv_attributes as $approved_attrib) { |
|
276 | + if ($attrib["name"] == $approved_attrib["name"] && $approved_attrib["level"] != "IdP" && $approved_attrib["level"] != "Profile") |
|
274 | 277 | $ignore = "YES"; |
275 | - if ($ignore != "YES") |
|
276 | - $this->priv_attributes[] = $attrib; |
|
278 | + } |
|
279 | + if ($ignore != "YES") { |
|
280 | + $this->priv_attributes[] = $attrib; |
|
281 | + } |
|
277 | 282 | } |
278 | 283 | } |
279 | 284 | |
@@ -282,11 +287,13 @@ discard block |
||
282 | 287 | foreach ($temparray as $attrib) { |
283 | 288 | if ($attrib["level"] == "IdP") { |
284 | 289 | $ignore = ""; |
285 | - foreach ($this->priv_attributes as $approved_attrib) |
|
286 | - if ($attrib["name"] == $approved_attrib["name"] && $approved_attrib["level"] != "IdP") |
|
290 | + foreach ($this->priv_attributes as $approved_attrib) { |
|
291 | + if ($attrib["name"] == $approved_attrib["name"] && $approved_attrib["level"] != "IdP") |
|
287 | 292 | $ignore = "YES"; |
288 | - if ($ignore != "YES") |
|
289 | - $this->priv_attributes[] = $attrib; |
|
293 | + } |
|
294 | + if ($ignore != "YES") { |
|
295 | + $this->priv_attributes[] = $attrib; |
|
296 | + } |
|
290 | 297 | } |
291 | 298 | } |
292 | 299 | |
@@ -315,8 +322,9 @@ discard block |
||
315 | 322 | $exec_query = DBConnection::exec(Profile::$DB_TYPE, "SELECT profile_id FROM profile WHERE realm LIKE '%@$realm'"); |
316 | 323 | if ($a = mysqli_fetch_object($exec_query)) { |
317 | 324 | return $a->profile_id; |
318 | - } else |
|
319 | - return FALSE; |
|
325 | + } else { |
|
326 | + return FALSE; |
|
327 | + } |
|
320 | 328 | } |
321 | 329 | |
322 | 330 | /** |
@@ -356,15 +364,15 @@ discard block |
||
356 | 364 | if ($lc < $cache->tm) { |
357 | 365 | debug(4, "Installer cached:$cache->download_path\n"); |
358 | 366 | return(['cache'=>$cache->download_path,'mime'=>$cache->mime]); |
367 | + } else { |
|
368 | + return NULL; |
|
359 | 369 | } |
360 | - else |
|
361 | - return NULL; |
|
370 | + } else { |
|
371 | + return NULL; |
|
362 | 372 | } |
363 | - else |
|
364 | - return NULL; |
|
373 | + } else { |
|
374 | + return NULL; |
|
365 | 375 | } |
366 | - else |
|
367 | - return NULL; |
|
368 | 376 | } |
369 | 377 | |
370 | 378 | /** |
@@ -405,20 +413,23 @@ discard block |
||
405 | 413 | public function getUserDownloadStats($device = 0) { |
406 | 414 | $returnarray = []; |
407 | 415 | $numbers_q = DBConnection::exec(Profile::$DB_TYPE, "SELECT device_id, SUM(downloads_user) AS downloads_user FROM downloads WHERE profile_id = $this->identifier GROUP BY device_id"); |
408 | - while ($a = mysqli_fetch_object($numbers_q)) |
|
409 | - $returnarray[$a->device_id] = $a->downloads_user; |
|
416 | + while ($a = mysqli_fetch_object($numbers_q)) { |
|
417 | + $returnarray[$a->device_id] = $a->downloads_user; |
|
418 | + } |
|
410 | 419 | if ($device !== 0) { |
411 | - if (isset($returnarray[$device])) |
|
412 | - return $returnarray[$device]; |
|
413 | - else |
|
414 | - return 0; |
|
420 | + if (isset($returnarray[$device])) { |
|
421 | + return $returnarray[$device]; |
|
422 | + } else { |
|
423 | + return 0; |
|
424 | + } |
|
415 | 425 | } |
416 | 426 | // we should pretty-print the device names |
417 | 427 | $finalarray = []; |
418 | 428 | $devlist = Devices::listDevices(); |
419 | - foreach ($returnarray as $dev_id => $count) |
|
420 | - if (isset($devlist[$dev_id])) |
|
429 | + foreach ($returnarray as $dev_id => $count) { |
|
430 | + if (isset($devlist[$dev_id])) |
|
421 | 431 | $finalarray[$devlist[$dev_id]['display']] = $count; |
432 | + } |
|
422 | 433 | return $finalarray; |
423 | 434 | } |
424 | 435 | |
@@ -434,15 +445,16 @@ discard block |
||
434 | 445 | if ($device !== 0) { |
435 | 446 | $device = DBConnection::escape_value(Profile::$DB_TYPE, $device); |
436 | 447 | $devicetext = "AND device_id = '$device'"; |
448 | + } else { |
|
449 | + $devicetext = ""; |
|
437 | 450 | } |
438 | - else |
|
439 | - $devicetext = ""; |
|
440 | 451 | DBConnection::exec(Profile::$DB_TYPE, "DELETE FROM profile_option WHERE profile_id = $this->identifier $devicetext AND eap_method_id = $eap_type_id AND option_name NOT LIKE '%_file'"); |
441 | 452 | $this->updateFreshness(); |
442 | 453 | $exec_q = DBConnection::exec(Profile::$DB_TYPE, "SELECT row FROM profile_option WHERE profile_id = $this->identifier $devicetext AND eap_method_id = $eap_type_id"); |
443 | 454 | $return_array = []; |
444 | - while ($a = mysqli_fetch_object($exec_q)) |
|
445 | - $return_array[$a->row] = "KILLME"; |
|
455 | + while ($a = mysqli_fetch_object($exec_q)) { |
|
456 | + $return_array[$a->row] = "KILLME"; |
|
457 | + } |
|
446 | 458 | return $return_array; |
447 | 459 | } |
448 | 460 | |
@@ -564,9 +576,10 @@ discard block |
||
564 | 576 | if ($complete_only == 0) { |
565 | 577 | return $this->priv_eaptypes; |
566 | 578 | } else { |
567 | - foreach ($this->priv_eaptypes as $type) |
|
568 | - if ($this->isEapTypeDefinitionComplete($type) === true) |
|
579 | + foreach ($this->priv_eaptypes as $type) { |
|
580 | + if ($this->isEapTypeDefinitionComplete($type) === true) |
|
569 | 581 | $temparray[] = $type; |
582 | + } |
|
570 | 583 | return($temparray); |
571 | 584 | } |
572 | 585 | } |
@@ -583,27 +596,31 @@ discard block |
||
583 | 596 | $outarray = []; |
584 | 597 | $temparray = []; |
585 | 598 | if ($eapmethod) { |
586 | - foreach ($this->priv_attributes as $the_attr) |
|
587 | - if ($the_attr["eapmethod"] == $eapmethod) |
|
599 | + foreach ($this->priv_attributes as $the_attr) { |
|
600 | + if ($the_attr["eapmethod"] == $eapmethod) |
|
588 | 601 | $temparray[] = $the_attr; |
602 | + } |
|
589 | 603 | } else |
590 | 604 | if ($device) { |
591 | - foreach ($this->priv_attributes as $the_attr) |
|
592 | - if ($the_attr["device"] == $device) |
|
605 | + foreach ($this->priv_attributes as $the_attr) { |
|
606 | + if ($the_attr["device"] == $device) |
|
593 | 607 | $temparray[] = $the_attr; |
608 | + } |
|
594 | 609 | }; |
595 | 610 | |
596 | - foreach ($this->priv_attributes as $the_attr) |
|
597 | - if ($the_attr["device"] == NULL && $the_attr["eapmethod"] == NULL) |
|
611 | + foreach ($this->priv_attributes as $the_attr) { |
|
612 | + if ($the_attr["device"] == NULL && $the_attr["eapmethod"] == NULL) |
|
598 | 613 | $temparray[] = $the_attr; |
614 | + } |
|
599 | 615 | |
600 | 616 | |
601 | 617 | // return only options by one name, if asked for |
602 | 618 | |
603 | 619 | if ($option_name) { |
604 | - foreach ($temparray as $the_attr) |
|
605 | - if ($the_attr["name"] == $option_name) |
|
620 | + foreach ($temparray as $the_attr) { |
|
621 | + if ($the_attr["name"] == $option_name) |
|
606 | 622 | $outarray[] = $the_attr; |
623 | + } |
|
607 | 624 | } else { |
608 | 625 | $outarray = $temparray; |
609 | 626 | } |
@@ -631,15 +648,18 @@ discard block |
||
631 | 648 | foreach ($ca_option as $one_ca) { |
632 | 649 | $x509 = new X509(); |
633 | 650 | $ca_parsed = $x509->processCertificate($one_ca['value']); |
634 | - if ($ca_parsed['root'] == 1) |
|
635 | - return true; |
|
651 | + if ($ca_parsed['root'] == 1) { |
|
652 | + return true; |
|
653 | + } |
|
636 | 654 | } |
637 | 655 | $missing[] = "eap:ca_file"; |
638 | 656 | } |
639 | - if (count($ca_option) == 0) |
|
640 | - $missing[] = "eap:ca_file"; |
|
641 | - if (count($cn_option) == 0) |
|
642 | - $missing[] = "eap:server_name"; |
|
657 | + if (count($ca_option) == 0) { |
|
658 | + $missing[] = "eap:ca_file"; |
|
659 | + } |
|
660 | + if (count($cn_option) == 0) { |
|
661 | + $missing[] = "eap:server_name"; |
|
662 | + } |
|
643 | 663 | return $missing; |
644 | 664 | } elseif ($eaptype["OUTER"] == PWD) { |
645 | 665 | /* |
@@ -662,8 +682,9 @@ discard block |
||
662 | 682 | * @return array of device ids display names and their status |
663 | 683 | */ |
664 | 684 | public function listDevices($locale = 0) { |
665 | - if ($locale == 0) |
|
666 | - $locale = $this->lang_index; |
|
685 | + if ($locale == 0) { |
|
686 | + $locale = $this->lang_index; |
|
687 | + } |
|
667 | 688 | $redirect_url = 0; |
668 | 689 | $message = 0; |
669 | 690 | $returnarray = []; |
@@ -679,20 +700,21 @@ discard block |
||
679 | 700 | $dev = $factory->device; |
680 | 701 | $redirect_url = getLocalisedValue($this->getAttributes("device-specific:redirect", 0, $d), $locale); |
681 | 702 | $dev_status = AVAILABLE; |
682 | - if(isset($D['options']) && isset($D['options']['message']) && $D['options']['message']) |
|
683 | - $message = $D['options']['message']; |
|
684 | - else |
|
685 | - $message = 0; |
|
703 | + if(isset($D['options']) && isset($D['options']['message']) && $D['options']['message']) { |
|
704 | + $message = $D['options']['message']; |
|
705 | + } else { |
|
706 | + $message = 0; |
|
707 | + } |
|
686 | 708 | |
687 | 709 | if ($redirect_url === 0) { |
688 | 710 | if(isset($D['options']) && isset($D['options']['redirect']) && $D['options']['redirect']) { |
689 | 711 | $dev_status = HIDDEN; |
690 | - } else { |
|
712 | + } else { |
|
691 | 713 | $eap = $dev->getPreferredEapType($preferred_eap); |
692 | 714 | if ($eap) { |
693 | - if (isset($EAP_options["eap-specific:customtext"][serialize($eap)])) |
|
694 | - $eap_customtext = $EAP_options["eap-specific:customtext"][serialize($eap)]; |
|
695 | - else { |
|
715 | + if (isset($EAP_options["eap-specific:customtext"][serialize($eap)])) { |
|
716 | + $eap_customtext = $EAP_options["eap-specific:customtext"][serialize($eap)]; |
|
717 | + } else { |
|
696 | 718 | $eap_customtext = getLocalisedValue($this->getAttributes("eap-specific:customtext", $eap, 0), $locale); |
697 | 719 | $EAP_options["eap-specific:customtext"][serialize($eap)] = $eap_customtext; |
698 | 720 | } |
@@ -725,8 +747,9 @@ discard block |
||
725 | 747 | $level = $b['level']; |
726 | 748 | // $S[$l] = $z[$l]; |
727 | 749 | $value = $b['value']; |
728 | - if (!isset($temp[$name][$level])) |
|
729 | - $temp[$name][$level] = []; |
|
750 | + if (!isset($temp[$name][$level])) { |
|
751 | + $temp[$name][$level] = []; |
|
752 | + } |
|
730 | 753 | if ($b['flag'] == 'ML') { |
731 | 754 | $v = unserialize($value); |
732 | 755 | $value = [$v['lang'] => $v['content']]; |
@@ -738,25 +761,29 @@ discard block |
||
738 | 761 | if ($flags[$name] == 'ML') { |
739 | 762 | $S = []; |
740 | 763 | if (isset($temp[$name]['Profile'])) { |
741 | - foreach ($temp[$name]['Profile'] as $z) |
|
742 | - foreach ($z as $l => $w) |
|
764 | + foreach ($temp[$name]['Profile'] as $z) { |
|
765 | + foreach ($z as $l => $w) |
|
743 | 766 | $S[$l] = $w; |
767 | + } |
|
744 | 768 | } |
745 | 769 | if (!$S && isset($temp[$name]['IdP'])) { |
746 | - foreach ($temp[$name]['IdP'] as $z) |
|
747 | - foreach ($z as $l => $w) |
|
770 | + foreach ($temp[$name]['IdP'] as $z) { |
|
771 | + foreach ($z as $l => $w) |
|
748 | 772 | $S[$l] = $w; |
773 | + } |
|
749 | 774 | } |
750 | 775 | $out[$name]['langs'] = $S; |
751 | - if (isset($S[$this->lang_index]) || isset($S['C'])) |
|
752 | - $out[$name][0] = (isset($S[$this->lang_index])) ? $S[$this->lang_index] : $S['C']; |
|
776 | + if (isset($S[$this->lang_index]) || isset($S['C'])) { |
|
777 | + $out[$name][0] = (isset($S[$this->lang_index])) ? $S[$this->lang_index] : $S['C']; |
|
778 | + } |
|
753 | 779 | } else { |
754 | - if (isset($temp[$name]['Method'])) |
|
755 | - $out[$name] = $temp[$name]['Method']; |
|
756 | - elseif (isset($temp[$name]['Profile'])) |
|
757 | - $out[$name] = $temp[$name]['Profile']; |
|
758 | - else |
|
759 | - $out[$name] = $temp[$name]['IdP']; |
|
780 | + if (isset($temp[$name]['Method'])) { |
|
781 | + $out[$name] = $temp[$name]['Method']; |
|
782 | + } elseif (isset($temp[$name]['Profile'])) { |
|
783 | + $out[$name] = $temp[$name]['Profile']; |
|
784 | + } else { |
|
785 | + $out[$name] = $temp[$name]['IdP']; |
|
786 | + } |
|
760 | 787 | } |
761 | 788 | } |
762 | 789 | return($out); |
@@ -794,20 +821,23 @@ discard block |
||
794 | 821 | $proper_config = FALSE; |
795 | 822 | $attribs = $this->getCollapsedAttributes(); |
796 | 823 | // do we have enough to go live? Check if any of the configured EAP methods is completely configured ... |
797 | - if (sizeof($this->getEapMethodsinOrderOfPreference(1)) > 0) |
|
798 | - $proper_config = TRUE; |
|
824 | + if (sizeof($this->getEapMethodsinOrderOfPreference(1)) > 0) { |
|
825 | + $proper_config = TRUE; |
|
826 | + } |
|
799 | 827 | // if not, it could still be that general redirect has been set |
800 | 828 | if (!$proper_config) { |
801 | - if (isset($attribs['device-specific:redirect'])) |
|
802 | - $proper_config = TRUE; |
|
829 | + if (isset($attribs['device-specific:redirect'])) { |
|
830 | + $proper_config = TRUE; |
|
831 | + } |
|
803 | 832 | // TODO: or maybe just a per-device redirect? would be good enough... |
804 | 833 | } |
805 | 834 | // do we know at least one SSID to configure, or work with wired? If not, it's not ready... |
806 | 835 | if (!isset($attribs['media:SSID']) && |
807 | 836 | !isset($attribs['media:SSID_with_legacy']) && |
808 | 837 | (!isset(Config::$CONSORTIUM['ssid']) || count(Config::$CONSORTIUM['ssid']) == 0) && |
809 | - !isset($attribs['media:wired'])) |
|
810 | - $proper_config = FALSE; |
|
838 | + !isset($attribs['media:wired'])) { |
|
839 | + $proper_config = FALSE; |
|
840 | + } |
|
811 | 841 | return $proper_config; |
812 | 842 | } |
813 | 843 | |
@@ -816,10 +846,11 @@ discard block |
||
816 | 846 | */ |
817 | 847 | public function prepShowtime() { |
818 | 848 | $proper_config = $this->readyForShowtime(); |
819 | - if ($proper_config) |
|
820 | - DBConnection::exec(Profile::$DB_TYPE, "UPDATE profile SET sufficient_config = TRUE WHERE profile_id = " . $this->identifier); |
|
821 | - else |
|
822 | - DBConnection::exec(Profile::$DB_TYPE, "UPDATE profile SET sufficient_config = FALSE WHERE profile_id = " . $this->identifier); |
|
849 | + if ($proper_config) { |
|
850 | + DBConnection::exec(Profile::$DB_TYPE, "UPDATE profile SET sufficient_config = TRUE WHERE profile_id = " . $this->identifier); |
|
851 | + } else { |
|
852 | + DBConnection::exec(Profile::$DB_TYPE, "UPDATE profile SET sufficient_config = FALSE WHERE profile_id = " . $this->identifier); |
|
853 | + } |
|
823 | 854 | $attribs = $this->getCollapsedAttributes(); |
824 | 855 | // if not enough info to go live, set FALSE |
825 | 856 | // even if enough info is there, admin has the ultimate say: |
@@ -843,10 +874,11 @@ discard block |
||
843 | 874 | /* echo "<pre>"; |
844 | 875 | print_r($r); |
845 | 876 | echo "</pre>"; */ |
846 | - if ($r[0] == "0") |
|
847 | - return FALSE; |
|
848 | - else |
|
849 | - return TRUE; |
|
877 | + if ($r[0] == "0") { |
|
878 | + return FALSE; |
|
879 | + } else { |
|
880 | + return TRUE; |
|
881 | + } |
|
850 | 882 | } |
851 | 883 | |
852 | 884 | /** |