@@ -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 |
@@ -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 | } |
@@ -78,10 +78,11 @@ discard block |
||
78 | 78 | } else { // invalid token... be a little verbose what's wrong with it |
79 | 79 | $check_reason = DBConnection::exec(UserManagement::$DB_TYPE, "SELECT invite_token, used FROM invitations WHERE invite_token = '$token'"); |
80 | 80 | if ($a = mysqli_fetch_object($check_reason)) { |
81 | - if ($a->used == 1) |
|
82 | - return "FAIL-ALREADYCONSUMED"; |
|
83 | - else |
|
84 | - return "FAIL-EXPIRED"; |
|
81 | + if ($a->used == 1) { |
|
82 | + return "FAIL-ALREADYCONSUMED"; |
|
83 | + } else { |
|
84 | + return "FAIL-EXPIRED"; |
|
85 | + } |
|
85 | 86 | } else { |
86 | 87 | return "FAIL-NONEXISTINGTOKEN"; |
87 | 88 | } |
@@ -157,8 +158,9 @@ discard block |
||
157 | 158 | |
158 | 159 | %s"), $bestnameguess, Config::$CONSORTIUM['name'], strtoupper($fed->identifier), Config::$APPEARANCE['productname'], Config::$APPEARANCE['productname_long']); |
159 | 160 | $retval = $user->sendMailToUser(_("IdP in your federation was created"), $message); |
160 | - if ($retval == FALSE) |
|
161 | - debug (2, "Mail to federation admin was NOT sent!\n"); |
|
161 | + if ($retval == FALSE) { |
|
162 | + debug (2, "Mail to federation admin was NOT sent!\n"); |
|
163 | + } |
|
162 | 164 | } |
163 | 165 | |
164 | 166 | return $idp; |
@@ -256,14 +258,16 @@ discard block |
||
256 | 258 | if ($idp_identifier != 0) { // list invitations for existing institution, must match cat_institution_id |
257 | 259 | while ($a = mysqli_fetch_object($invitations)) { |
258 | 260 | debug(4, "Retrieving pending invitations for IdP $idp_identifier.\n"); |
259 | - if ($a->cat_institution_id == $idp_identifier) |
|
260 | - $retval[] = $a->invite_dest_mail; |
|
261 | + if ($a->cat_institution_id == $idp_identifier) { |
|
262 | + $retval[] = $a->invite_dest_mail; |
|
263 | + } |
|
261 | 264 | } |
262 | 265 | } else { // list all invitations for *new* institutions |
263 | 266 | while ($a = mysqli_fetch_object($invitations)) { |
264 | 267 | debug(4, "Retrieving pending invitations for NEW institutions.\n"); |
265 | - if ($a->cat_institution_id == NULL) |
|
266 | - $retval[] = ["country" => $a->country, "name" => $a->name, "mail" => $a->invite_dest_mail, "token" => $a->invite_token]; |
|
268 | + if ($a->cat_institution_id == NULL) { |
|
269 | + $retval[] = ["country" => $a->country, "name" => $a->name, "mail" => $a->invite_dest_mail, "token" => $a->invite_token]; |
|
270 | + } |
|
267 | 271 | } |
268 | 272 | }; |
269 | 273 | return $retval; |
@@ -280,10 +284,11 @@ discard block |
||
280 | 284 | WHERE invite_created >= TIMESTAMPADD(HOUR, -25, NOW()) AND invite_created < TIMESTAMPADD(HOUR, -24, NOW()) AND used = 0"); |
281 | 285 | while ($a = mysqli_fetch_object($invitations)) { |
282 | 286 | debug(4, "Retrieving recently expired invitations (expired in last hour)\n"); |
283 | - if ($a->cat_institution_id == NULL) |
|
284 | - $retval[] = ["country" => $a->country, "level" => $a->invite_issuer_level, "name" => $a->name, "mail" => $a->invite_dest_mail]; |
|
285 | - else |
|
286 | - $retval[] = ["country" => $a->country, "level" => $a->invite_issuer_level, "name" => "Existing IdP", "mail" => $a->invite_dest_mail]; |
|
287 | + if ($a->cat_institution_id == NULL) { |
|
288 | + $retval[] = ["country" => $a->country, "level" => $a->invite_issuer_level, "name" => $a->name, "mail" => $a->invite_dest_mail]; |
|
289 | + } else { |
|
290 | + $retval[] = ["country" => $a->country, "level" => $a->invite_issuer_level, "name" => "Existing IdP", "mail" => $a->invite_dest_mail]; |
|
291 | + } |
|
287 | 292 | } |
288 | 293 | return $retval; |
289 | 294 | } |
@@ -299,8 +304,9 @@ discard block |
||
299 | 304 | $returnarray = []; |
300 | 305 | $userid = DBConnection::escape_value(UserManagement::$DB_TYPE, $userid); |
301 | 306 | $institutions = DBConnection::exec(UserManagement::$DB_TYPE, "SELECT institution_id FROM ownership WHERE user_id = '$userid' ORDER BY institution_id"); |
302 | - while ($a = mysqli_fetch_object($institutions)) |
|
303 | - $returnarray[] = $a->institution_id; |
|
307 | + while ($a = mysqli_fetch_object($institutions)) { |
|
308 | + $returnarray[] = $a->institution_id; |
|
309 | + } |
|
304 | 310 | return $returnarray; |
305 | 311 | } |
306 | 312 |
@@ -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 |
@@ -100,11 +100,12 @@ discard block |
||
100 | 100 | if(preg_match('/(.+)=>(.+)/',$t,$m)) { |
101 | 101 | $tst = $m[1]; |
102 | 102 | $subtst=$m[2]; |
103 | - if($this->test_result[$tst] < L_ERROR) |
|
104 | - $this->test($subtst); |
|
103 | + if($this->test_result[$tst] < L_ERROR) { |
|
104 | + $this->test($subtst); |
|
105 | + } |
|
106 | + } else { |
|
107 | + $this->test($t); |
|
105 | 108 | } |
106 | - else |
|
107 | - $this->test($t); |
|
108 | 109 | } |
109 | 110 | } |
110 | 111 | |
@@ -145,10 +146,11 @@ discard block |
||
145 | 146 | preg_match('/([^ ]+) ?/',Config::$PATHS[$s],$m); |
146 | 147 | $exe = $m[1]; |
147 | 148 | $the_path = exec("which " . Config::$PATHS[$s]); |
148 | - if ($the_path == $exe) |
|
149 | - $exec_is = "EXPLICIT"; |
|
150 | - else |
|
151 | - $exec_is = "IMPLICIT"; |
|
149 | + if ($the_path == $exe) { |
|
150 | + $exec_is = "EXPLICIT"; |
|
151 | + } else { |
|
152 | + $exec_is = "IMPLICIT"; |
|
153 | + } |
|
152 | 154 | } |
153 | 155 | return(['exec'=>$the_path,'exec_is'=>$exec_is]); |
154 | 156 | } |
@@ -157,38 +159,42 @@ discard block |
||
157 | 159 | * Test for php version |
158 | 160 | */ |
159 | 161 | private function php_test() { |
160 | - if (version_compare(phpversion(), $this->php_needversion, '>=')) |
|
161 | - $this->test_return(L_OK,"<strong>PHP</strong> is sufficiently recent. You are running " . phpversion() . "."); |
|
162 | - else |
|
163 | - $this->test_return(L_ERROR,"<strong>PHP</strong> is too old. We need at least $this->php_needversion, but you only have ".phpversion(). "."); |
|
162 | + if (version_compare(phpversion(), $this->php_needversion, '>=')) { |
|
163 | + $this->test_return(L_OK,"<strong>PHP</strong> is sufficiently recent. You are running " . phpversion() . "."); |
|
164 | + } else { |
|
165 | + $this->test_return(L_ERROR,"<strong>PHP</strong> is too old. We need at least $this->php_needversion, but you only have ".phpversion(). "."); |
|
166 | + } |
|
164 | 167 | } |
165 | 168 | |
166 | 169 | /** |
167 | 170 | * test for simpleSAMLphp |
168 | 171 | */ |
169 | 172 | private function ssp_test() { |
170 | - if (!is_file(CONFIG::$AUTHENTICATION['ssp-path-to-autoloader'])) |
|
171 | - $this->test_return(L_ERROR,"<strong>simpleSAMLphp</strong> not found!"); |
|
172 | - else |
|
173 | - $this->test_return(L_OK,"<strong>simpleSAMLphp</strong> autoloader found."); |
|
173 | + if (!is_file(CONFIG::$AUTHENTICATION['ssp-path-to-autoloader'])) { |
|
174 | + $this->test_return(L_ERROR,"<strong>simpleSAMLphp</strong> not found!"); |
|
175 | + } else { |
|
176 | + $this->test_return(L_OK,"<strong>simpleSAMLphp</strong> autoloader found."); |
|
177 | + } |
|
174 | 178 | } |
175 | 179 | |
176 | 180 | /** |
177 | 181 | * test for security setting |
178 | 182 | */ |
179 | 183 | private function security_test() { |
180 | - if (in_array("I do not care about security!", Config::$SUPERADMINS)) |
|
181 | - $this->test_return(L_WARN,"You do not care about security. This page should be made accessible to the CAT admin only! See config.php 'Superadmins'!"); |
|
184 | + if (in_array("I do not care about security!", Config::$SUPERADMINS)) { |
|
185 | + $this->test_return(L_WARN,"You do not care about security. This page should be made accessible to the CAT admin only! See config.php 'Superadmins'!"); |
|
186 | + } |
|
182 | 187 | } |
183 | 188 | |
184 | 189 | /** |
185 | 190 | * test if zip is available |
186 | 191 | */ |
187 | 192 | private function zip_test() { |
188 | - if (exec("which zip") != "") |
|
189 | - $this->test_return(L_OK,"<strong>zip</strong> binary found."); |
|
190 | - else |
|
191 | - $this->test_return(L_ERROR,"<strong>zip</strong> not found in your \$PATH!"); |
|
193 | + if (exec("which zip") != "") { |
|
194 | + $this->test_return(L_OK,"<strong>zip</strong> binary found."); |
|
195 | + } else { |
|
196 | + $this->test_return(L_ERROR,"<strong>zip</strong> not found in your \$PATH!"); |
|
197 | + } |
|
192 | 198 | } |
193 | 199 | |
194 | 200 | /** |
@@ -198,59 +204,67 @@ discard block |
||
198 | 204 | exec(Config::$PATHS['eapol_test'], $out, $retval); |
199 | 205 | if($retval == 255 ) { |
200 | 206 | $o = preg_grep('/-o<server cert/',$out); |
201 | - if(count($o) > 0) |
|
202 | - $this->test_return(L_OK,"<strong>eapol_test</strong> script found."); |
|
203 | - else |
|
204 | - $this->test_return(L_ERROR,"<strong>eapol_test</strong> found, but is too old!"); |
|
207 | + if(count($o) > 0) { |
|
208 | + $this->test_return(L_OK,"<strong>eapol_test</strong> script found."); |
|
209 | + } else { |
|
210 | + $this->test_return(L_ERROR,"<strong>eapol_test</strong> found, but is too old!"); |
|
211 | + } |
|
212 | + } else { |
|
213 | + $this->test_return(L_ERROR,"<strong>eapol_test</strong> not found!"); |
|
205 | 214 | } |
206 | - else |
|
207 | - $this->test_return(L_ERROR,"<strong>eapol_test</strong> not found!"); |
|
208 | 215 | } |
209 | 216 | |
210 | 217 | /** |
211 | 218 | * test if logdir exists and is writable |
212 | 219 | */ |
213 | 220 | private function logdir_test() { |
214 | - if (fopen(Config::$PATHS['logdir'] . "/debug.log", "a") == FALSE) |
|
215 | - $this->test_return(L_WARN,"Log files in <strong>" . Config::$PATHS['logdir'] . "</strong> are not writable!"); |
|
216 | - else |
|
217 | - $this->test_return(L_OK,"Log directory is writable."); |
|
221 | + if (fopen(Config::$PATHS['logdir'] . "/debug.log", "a") == FALSE) { |
|
222 | + $this->test_return(L_WARN,"Log files in <strong>" . Config::$PATHS['logdir'] . "</strong> are not writable!"); |
|
223 | + } else { |
|
224 | + $this->test_return(L_OK,"Log directory is writable."); |
|
225 | + } |
|
218 | 226 | } |
219 | 227 | |
220 | 228 | /** |
221 | 229 | * test for required PHP modules |
222 | 230 | */ |
223 | 231 | private function phpModules_test() { |
224 | - if (function_exists('idn_to_ascii')) |
|
225 | - $this->test_return(L_OK,"PHP can handle internationalisation."); |
|
226 | - else |
|
227 | - $this->test_return(L_ERROR,"PHP can <strongNOT</strong> handle internationalisation (idn_to_ascii() from php5-intl)."); |
|
232 | + if (function_exists('idn_to_ascii')) { |
|
233 | + $this->test_return(L_OK,"PHP can handle internationalisation."); |
|
234 | + } else { |
|
235 | + $this->test_return(L_ERROR,"PHP can <strongNOT</strong> handle internationalisation (idn_to_ascii() from php5-intl)."); |
|
236 | + } |
|
228 | 237 | |
229 | - if (function_exists('gettext')) |
|
230 | - $this->test_return(L_OK,"PHP extension <strong>GNU Gettext</strong> is installed."); |
|
231 | - else |
|
232 | - $this->test_return(L_ERROR,"PHP extension <strong>GNU Gettext</strong> not found!"); |
|
238 | + if (function_exists('gettext')) { |
|
239 | + $this->test_return(L_OK,"PHP extension <strong>GNU Gettext</strong> is installed."); |
|
240 | + } else { |
|
241 | + $this->test_return(L_ERROR,"PHP extension <strong>GNU Gettext</strong> not found!"); |
|
242 | + } |
|
233 | 243 | |
234 | - if (function_exists('openssl_sign')) |
|
235 | - $this->test_return(L_OK,"PHP extension <strong>OpenSSL</strong> is installed."); |
|
236 | - else |
|
237 | - $this->test_return(L_ERROR,"PHP extension <strong>OpenSSL</strong> not found!"); |
|
244 | + if (function_exists('openssl_sign')) { |
|
245 | + $this->test_return(L_OK,"PHP extension <strong>OpenSSL</strong> is installed."); |
|
246 | + } else { |
|
247 | + $this->test_return(L_ERROR,"PHP extension <strong>OpenSSL</strong> not found!"); |
|
248 | + } |
|
238 | 249 | |
239 | - if (class_exists('Imagick')) |
|
240 | - $this->test_return(L_OK,"PHP extension <strong>Imagick</strong> is installed."); |
|
241 | - else |
|
242 | - $this->test_return(L_ERROR,"PHP extension <strong>Imagick</strong> not found! Get it from your distribution or <a href='http://pecl.php.net/package/imagick'>here</a>."); |
|
250 | + if (class_exists('Imagick')) { |
|
251 | + $this->test_return(L_OK,"PHP extension <strong>Imagick</strong> is installed."); |
|
252 | + } else { |
|
253 | + $this->test_return(L_ERROR,"PHP extension <strong>Imagick</strong> not found! Get it from your distribution or <a href='http://pecl.php.net/package/imagick'>here</a>."); |
|
254 | + } |
|
243 | 255 | |
244 | - if (function_exists('ImageCreate')) |
|
245 | - $this->test_return(L_OK,"PHP extension <strong>GD</strong> is installed."); |
|
246 | - else |
|
247 | - $this->test_return(L_ERROR,"PHP extension <strong>GD</strong> not found!</a>."); |
|
256 | + if (function_exists('ImageCreate')) { |
|
257 | + $this->test_return(L_OK,"PHP extension <strong>GD</strong> is installed."); |
|
258 | + } else { |
|
259 | + $this->test_return(L_ERROR,"PHP extension <strong>GD</strong> not found!</a>."); |
|
260 | + } |
|
248 | 261 | |
249 | - if (function_exists('mysqli_connect')) |
|
250 | - $this->test_return(L_OK,"PHP extension <strong>MySQL</strong> is installed."); |
|
251 | - else |
|
252 | - $this->test_return(L_ERROR,"PHP extension <strong>MySQL</strong> not found!"); |
|
253 | -/* |
|
262 | + if (function_exists('mysqli_connect')) { |
|
263 | + $this->test_return(L_OK,"PHP extension <strong>MySQL</strong> is installed."); |
|
264 | + } else { |
|
265 | + $this->test_return(L_ERROR,"PHP extension <strong>MySQL</strong> not found!"); |
|
266 | + } |
|
267 | + /* |
|
254 | 268 | if (function_exists('geoip_record_by_name')) { |
255 | 269 | $host = '158.75.1.10'; |
256 | 270 | $record = geoip_record_by_name($host); |
@@ -339,12 +353,14 @@ discard block |
||
339 | 353 | $A = $this->get_exec_path('openssl'); |
340 | 354 | if($A['exec'] != "") { |
341 | 355 | $t = exec($A['exec'] . ' version'); |
342 | - if($A['exec_is'] == "EXPLICIT") |
|
343 | - $this->test_return(L_OK,"<strong>$t</strong> was found and is configured explicitly in your config."); |
|
344 | - else |
|
345 | - $this->test_return(L_WARN,"<strong>$t</strong> was found, but is not configured with an absolute path in your config."); |
|
346 | - } else |
|
347 | - $this->test_return(L_ERROR,"<strong>openssl</strong> was not found on your system!"); |
|
356 | + if($A['exec_is'] == "EXPLICIT") { |
|
357 | + $this->test_return(L_OK,"<strong>$t</strong> was found and is configured explicitly in your config."); |
|
358 | + } else { |
|
359 | + $this->test_return(L_WARN,"<strong>$t</strong> was found, but is not configured with an absolute path in your config."); |
|
360 | + } |
|
361 | + } else { |
|
362 | + $this->test_return(L_ERROR,"<strong>openssl</strong> was not found on your system!"); |
|
363 | + } |
|
348 | 364 | } |
349 | 365 | |
350 | 366 | /** |
@@ -362,18 +378,22 @@ discard block |
||
362 | 378 | $A = $this->get_exec_path('makensis'); |
363 | 379 | if($A['exec'] != "") { |
364 | 380 | $t = exec($A['exec'] . ' -VERSION'); |
365 | - if($A['exec_is'] == "EXPLICIT") |
|
366 | - $this->test_return(L_OK,"<strong>makensis $t</strong> was found and is configured explicitly in your config."); |
|
367 | - else |
|
368 | - $this->test_return(L_WARN,"<strong>makensis $t</strong> was found, but is not configured with an absolute path in your config."); |
|
381 | + if($A['exec_is'] == "EXPLICIT") { |
|
382 | + $this->test_return(L_OK,"<strong>makensis $t</strong> was found and is configured explicitly in your config."); |
|
383 | + } else { |
|
384 | + $this->test_return(L_WARN,"<strong>makensis $t</strong> was found, but is not configured with an absolute path in your config."); |
|
385 | + } |
|
369 | 386 | exec($A['exec'] . ' -HELP',$t); |
370 | 387 | $t1 = count(preg_grep('/INPUTCHARSET/',$t)); |
371 | - if($t1 == 1 && Config::$NSIS_VERSION == 2) |
|
372 | - $this->test_return(L_ERROR,"Declared NSIS_VERSION does not seem to match the file pointed to by PATHS['makensis']!"); |
|
373 | - if($t1 == 0 && Config::$NSIS_VERSION >= 3) |
|
374 | - $this->test_return(L_ERROR,"Declared NSIS_VERSION does not seem to match the file pointed to by PATHS['makensis']!"); |
|
375 | - } else |
|
376 | - $this->test_return(L_ERROR,"<strong>makensis</strong> was not found on your system!"); |
|
388 | + if($t1 == 1 && Config::$NSIS_VERSION == 2) { |
|
389 | + $this->test_return(L_ERROR,"Declared NSIS_VERSION does not seem to match the file pointed to by PATHS['makensis']!"); |
|
390 | + } |
|
391 | + if($t1 == 0 && Config::$NSIS_VERSION >= 3) { |
|
392 | + $this->test_return(L_ERROR,"Declared NSIS_VERSION does not seem to match the file pointed to by PATHS['makensis']!"); |
|
393 | + } |
|
394 | + } else { |
|
395 | + $this->test_return(L_ERROR,"<strong>makensis</strong> was not found on your system!"); |
|
396 | + } |
|
377 | 397 | } |
378 | 398 | |
379 | 399 | /** |
@@ -391,18 +411,21 @@ discard block |
||
391 | 411 | foreach ($this->NSIS_Modules as $module) { |
392 | 412 | unset($out); |
393 | 413 | exec(Config::$PATHS['makensis']." -V1 '-X!include $module' '-XOutFile $exe' '-XSection X' '-XSectionEnd'", $out, $retval); |
394 | - if($retval > 0) |
|
395 | - $NSIS_Module_status[$module] = 0; |
|
396 | - else |
|
397 | - $NSIS_Module_status[$module] = 1; |
|
414 | + if($retval > 0) { |
|
415 | + $NSIS_Module_status[$module] = 0; |
|
416 | + } else { |
|
417 | + $NSIS_Module_status[$module] = 1; |
|
418 | + } |
|
419 | + } |
|
420 | + if(is_file($exe)) { |
|
421 | + unlink($exe); |
|
398 | 422 | } |
399 | - if(is_file($exe)) |
|
400 | - unlink($exe); |
|
401 | 423 | foreach ($NSIS_Module_status as $module => $status) { |
402 | - if($status == 1) |
|
403 | - $this->test_return(L_OK,"NSIS module <strong>$module</strong> was found."); |
|
404 | - else |
|
405 | - $this->test_return(L_ERROR,"NSIS module <strong>$module</strong> was not found or is not working correctly."); |
|
424 | + if($status == 1) { |
|
425 | + $this->test_return(L_OK,"NSIS module <strong>$module</strong> was found."); |
|
426 | + } else { |
|
427 | + $this->test_return(L_ERROR,"NSIS module <strong>$module</strong> was not found or is not working correctly."); |
|
428 | + } |
|
406 | 429 | } |
407 | 430 | } |
408 | 431 | private function NSIS_GetVersion_test() { |
@@ -414,12 +437,14 @@ discard block |
||
414 | 437 | } |
415 | 438 | $exe= 'tt.exe'; |
416 | 439 | exec(Config::$PATHS['makensis']." -V1 '-XOutFile $exe' '-XSection X' '-XGetVersion::WindowsName' '-XSectionEnd'", $out, $retval); |
417 | - if($retval > 0) |
|
418 | - $this->test_return(L_ERROR,"NSIS module <strong>GetVersion</strong> was not found or is not working correctly."); |
|
419 | - else |
|
420 | - $this->test_return(L_OK,"NSIS module <strong>GetVersion</strong> was found."); |
|
421 | - if(is_file($exe)) |
|
422 | - unlink($exe); |
|
440 | + if($retval > 0) { |
|
441 | + $this->test_return(L_ERROR,"NSIS module <strong>GetVersion</strong> was not found or is not working correctly."); |
|
442 | + } else { |
|
443 | + $this->test_return(L_OK,"NSIS module <strong>GetVersion</strong> was found."); |
|
444 | + } |
|
445 | + if(is_file($exe)) { |
|
446 | + unlink($exe); |
|
447 | + } |
|
423 | 448 | } |
424 | 449 | |
425 | 450 | /** |
@@ -461,21 +486,24 @@ discard block |
||
461 | 486 | private function locales_test() { |
462 | 487 | $locales = shell_exec("locale -a"); |
463 | 488 | $allthere = ""; |
464 | - foreach (Config::$LANGUAGES as $onelanguage) |
|
465 | - if (preg_match("/" . $onelanguage['locale'] . "/", $locales) == 0) |
|
489 | + foreach (Config::$LANGUAGES as $onelanguage) { |
|
490 | + if (preg_match("/" . $onelanguage['locale'] . "/", $locales) == 0) |
|
466 | 491 | $allthere .= $onelanguage['locale'] . " "; |
492 | + } |
|
467 | 493 | |
468 | - if ($allthere == "") |
|
469 | - $this->test_return(L_OK,"All of your configured locales are available on your system."); |
|
470 | - else |
|
471 | - $this->test_return(L_WARN,"Some of your configured locales (<strong>$allthere</strong>) are not installed and will not be displayed correctly!"); |
|
494 | + if ($allthere == "") { |
|
495 | + $this->test_return(L_OK,"All of your configured locales are available on your system."); |
|
496 | + } else { |
|
497 | + $this->test_return(L_WARN,"Some of your configured locales (<strong>$allthere</strong>) are not installed and will not be displayed correctly!"); |
|
498 | + } |
|
472 | 499 | } |
473 | 500 | |
474 | 501 | private function check_config_default($type,$key,$value) { |
475 | - if (empty(Config::$type[$key])) |
|
476 | - $missingvalues .="type/webcert_OCSP "; |
|
477 | - elseif (Config::$type['webcert_OCSP'] == $value) |
|
478 | - $defaultvalues .="type/$key "; |
|
502 | + if (empty(Config::$type[$key])) { |
|
503 | + $missingvalues .="type/webcert_OCSP "; |
|
504 | + } elseif (Config::$type['webcert_OCSP'] == $value) { |
|
505 | + $defaultvalues .="type/$key "; |
|
506 | + } |
|
479 | 507 | } |
480 | 508 | |
481 | 509 | |
@@ -485,32 +513,44 @@ discard block |
||
485 | 513 | private function defaults_test() { |
486 | 514 | $defaultvalues = ""; |
487 | 515 | $missingvalues = ""; |
488 | - if (Config::$APPEARANCE['from-mail'] == "[email protected]") |
|
489 | - $defaultvalues .="APPEARANCE/from-mail "; |
|
490 | - if (Config::$APPEARANCE['support-contact']['url'] == "[email protected]?body=Only%20English%20language%20please!") |
|
491 | - $defaultvalues .="APPEARANCE/support-contact/url "; |
|
492 | - if (Config::$APPEARANCE['support-contact']['display'] == "[email protected]") |
|
493 | - $defaultvalues .="APPEARANCE/support-contact/display "; |
|
494 | - if (Config::$APPEARANCE['support-contact']['developer-mail'] == "[email protected]") |
|
495 | - $defaultvalues .="APPEARANCE/support-contact/mail "; |
|
496 | - if (Config::$APPEARANCE['abuse-mail'] == "[email protected]") |
|
497 | - $defaultvalues .="APPEARANCE/abuse-mail "; |
|
498 | - if (Config::$APPEARANCE['MOTD'] == "Release Candidate. All bugs to be shot on sight!") |
|
499 | - $defaultvalues .="APPEARANCE/MOTD "; |
|
500 | - if (Config::$APPEARANCE['webcert_CRLDP'] == ['list', 'of', 'CRL', 'pointers']) |
|
501 | - $defaultvalues .="APPEARANCE/webcert_CRLDP "; |
|
502 | - if (empty(Config::$APPEARANCE['webcert_OCSP'])) |
|
503 | - $missingvalues .="APPEARANCE/webcert_OCSP "; |
|
504 | - elseif (Config::$APPEARANCE['webcert_OCSP'] == ['list', 'of', 'OCSP', 'pointers']) |
|
505 | - $defaultvalues .="APPEARANCE/webcert_OCSP "; |
|
506 | - if (isset(Config::$RADIUSTESTS['UDP-hosts'][0]) && Config::$RADIUSTESTS['UDP-hosts'][0]['ip'] == "192.0.2.1") |
|
507 | - $defaultvalues .="RADIUSTESTS/UDP-hosts "; |
|
508 | - if (Config::$DB['INST']['host'] == "db.host.example") |
|
509 | - $defaultvalues .="DB/INST "; |
|
510 | - if (Config::$DB['INST']['host'] == "db.host.example") |
|
511 | - $defaultvalues .="DB/USER "; |
|
512 | - if(!empty(Config::$DB['EXTERNAL']) && Config::$DB['EXTERNAL']['host'] == "customerdb.otherhost.example") |
|
513 | - $defaultvalues .="DB/EXTERNAL "; |
|
516 | + if (Config::$APPEARANCE['from-mail'] == "[email protected]") { |
|
517 | + $defaultvalues .="APPEARANCE/from-mail "; |
|
518 | + } |
|
519 | + if (Config::$APPEARANCE['support-contact']['url'] == "[email protected]?body=Only%20English%20language%20please!") { |
|
520 | + $defaultvalues .="APPEARANCE/support-contact/url "; |
|
521 | + } |
|
522 | + if (Config::$APPEARANCE['support-contact']['display'] == "[email protected]") { |
|
523 | + $defaultvalues .="APPEARANCE/support-contact/display "; |
|
524 | + } |
|
525 | + if (Config::$APPEARANCE['support-contact']['developer-mail'] == "[email protected]") { |
|
526 | + $defaultvalues .="APPEARANCE/support-contact/mail "; |
|
527 | + } |
|
528 | + if (Config::$APPEARANCE['abuse-mail'] == "[email protected]") { |
|
529 | + $defaultvalues .="APPEARANCE/abuse-mail "; |
|
530 | + } |
|
531 | + if (Config::$APPEARANCE['MOTD'] == "Release Candidate. All bugs to be shot on sight!") { |
|
532 | + $defaultvalues .="APPEARANCE/MOTD "; |
|
533 | + } |
|
534 | + if (Config::$APPEARANCE['webcert_CRLDP'] == ['list', 'of', 'CRL', 'pointers']) { |
|
535 | + $defaultvalues .="APPEARANCE/webcert_CRLDP "; |
|
536 | + } |
|
537 | + if (empty(Config::$APPEARANCE['webcert_OCSP'])) { |
|
538 | + $missingvalues .="APPEARANCE/webcert_OCSP "; |
|
539 | + } elseif (Config::$APPEARANCE['webcert_OCSP'] == ['list', 'of', 'OCSP', 'pointers']) { |
|
540 | + $defaultvalues .="APPEARANCE/webcert_OCSP "; |
|
541 | + } |
|
542 | + if (isset(Config::$RADIUSTESTS['UDP-hosts'][0]) && Config::$RADIUSTESTS['UDP-hosts'][0]['ip'] == "192.0.2.1") { |
|
543 | + $defaultvalues .="RADIUSTESTS/UDP-hosts "; |
|
544 | + } |
|
545 | + if (Config::$DB['INST']['host'] == "db.host.example") { |
|
546 | + $defaultvalues .="DB/INST "; |
|
547 | + } |
|
548 | + if (Config::$DB['INST']['host'] == "db.host.example") { |
|
549 | + $defaultvalues .="DB/USER "; |
|
550 | + } |
|
551 | + if(!empty(Config::$DB['EXTERNAL']) && Config::$DB['EXTERNAL']['host'] == "customerdb.otherhost.example") { |
|
552 | + $defaultvalues .="DB/EXTERNAL "; |
|
553 | + } |
|
514 | 554 | $files = []; |
515 | 555 | foreach (Config::$RADIUSTESTS['TLS-clientcerts'] as $cadata) { |
516 | 556 | foreach ($cadata['certificates'] as $cert_files) { |
@@ -521,15 +561,17 @@ discard block |
||
521 | 561 | |
522 | 562 | foreach ($files as $file) { |
523 | 563 | $handle = fopen(CAT::$root . "/config/cli-certs/" . $file, 'r'); |
524 | - if (!$handle) |
|
525 | - $defaultvalues .="CERTIFICATE/$file "; |
|
526 | - else |
|
527 | - fclose($handle); |
|
564 | + if (!$handle) { |
|
565 | + $defaultvalues .="CERTIFICATE/$file "; |
|
566 | + } else { |
|
567 | + fclose($handle); |
|
568 | + } |
|
569 | + } |
|
570 | + if ($defaultvalues != "") { |
|
571 | + $this->test_return(L_WARN,"Your configuration in config/config.php contains unchanged default values or links to inexistent files: <strong>$defaultvalues</strong>!"); |
|
572 | + } else { |
|
573 | + $this->test_return(L_OK,"Your configuration does not contain any unchanged defaults, which is a good sign."); |
|
528 | 574 | } |
529 | - if ($defaultvalues != "") |
|
530 | - $this->test_return(L_WARN,"Your configuration in config/config.php contains unchanged default values or links to inexistent files: <strong>$defaultvalues</strong>!"); |
|
531 | - else |
|
532 | - $this->test_return(L_OK,"Your configuration does not contain any unchanged defaults, which is a good sign."); |
|
533 | 575 | } |
534 | 576 | |
535 | 577 | /** |
@@ -542,10 +584,11 @@ discard block |
||
542 | 584 | $this->test_return(L_ERROR,"Connection to the $DB database failed"); |
543 | 585 | } else { |
544 | 586 | $r = mysqli_query($db,'select * from profile_option_dict'); |
545 | - if($r->num_rows == $this->profile_option_ct) |
|
546 | - $this->test_return(L_OK,"The $DB database appears to be OK."); |
|
547 | - else |
|
548 | - $this->test_return(L_ERROR,"The $DB database is reacheable but probably not updated to this version of CAT."); |
|
587 | + if($r->num_rows == $this->profile_option_ct) { |
|
588 | + $this->test_return(L_OK,"The $DB database appears to be OK."); |
|
589 | + } else { |
|
590 | + $this->test_return(L_ERROR,"The $DB database is reacheable but probably not updated to this version of CAT."); |
|
591 | + } |
|
549 | 592 | } |
550 | 593 | $DB = 'USER'; |
551 | 594 | $db = mysqli_connect(Config::$DB[$DB]['host'], Config::$DB[$DB]['user'], Config::$DB[$DB]['pass'], Config::$DB[$DB]['db']); |
@@ -553,10 +596,11 @@ discard block |
||
553 | 596 | $this->test_return(L_ERROR,"Connection to the $DB database failed"); |
554 | 597 | } else { |
555 | 598 | $r = mysqli_query($db,'desc view_admin'); |
556 | - if($r->num_rows == $this->view_admin_ct) |
|
557 | - $this->test_return(L_OK,"The $DB database appears to be OK."); |
|
558 | - else |
|
559 | - $this->test_return(L_ERROR,"The $DB is reacheable but there is something wrong with the schema"); |
|
599 | + if($r->num_rows == $this->view_admin_ct) { |
|
600 | + $this->test_return(L_OK,"The $DB database appears to be OK."); |
|
601 | + } else { |
|
602 | + $this->test_return(L_ERROR,"The $DB is reacheable but there is something wrong with the schema"); |
|
603 | + } |
|
560 | 604 | } |
561 | 605 | $DB = 'EXTERNAL'; |
562 | 606 | if(! empty(Config::$DB[$DB])) { |
@@ -565,10 +609,11 @@ discard block |
||
565 | 609 | $this->test_return(L_ERROR,"Connection to the $DB database failed"); |
566 | 610 | } else { |
567 | 611 | $r = mysqli_query($db,'desc view_admin'); |
568 | - if($r->num_rows == $this->view_admin_ct) |
|
569 | - $this->test_return(L_OK,"The $DB database appears to be OK."); |
|
570 | - else |
|
571 | - $this->test_return(L_ERROR,"The $DB is reacheable but there is something wrong with the schema"); |
|
612 | + if($r->num_rows == $this->view_admin_ct) { |
|
613 | + $this->test_return(L_OK,"The $DB database appears to be OK."); |
|
614 | + } else { |
|
615 | + $this->test_return(L_ERROR,"The $DB is reacheable but there is something wrong with the schema"); |
|
616 | + } |
|
572 | 617 | } |
573 | 618 | } |
574 | 619 | } |
@@ -578,13 +623,15 @@ discard block |
||
578 | 623 | * test devices.php for the no_cache option |
579 | 624 | */ |
580 | 625 | private function device_cache_test() { |
581 | - if((! empty(Devices::$Options['no_cache'])) && Devices::$Options['no_cache']) |
|
582 | - $global_no_cache = 1; |
|
583 | - else |
|
584 | - $global_no_cache = 0; |
|
626 | + if((! empty(Devices::$Options['no_cache'])) && Devices::$Options['no_cache']) { |
|
627 | + $global_no_cache = 1; |
|
628 | + } else { |
|
629 | + $global_no_cache = 0; |
|
630 | + } |
|
585 | 631 | |
586 | - if($global_no_cache == 1) |
|
587 | - $this->test_return(L_WARN,"Devices no_cache global option is set, this is not a good idea in a production setting\n"); |
|
632 | + if($global_no_cache == 1) { |
|
633 | + $this->test_return(L_WARN,"Devices no_cache global option is set, this is not a good idea in a production setting\n"); |
|
634 | + } |
|
588 | 635 | $Devs = Devices::listDevices(); |
589 | 636 | $no_cache_dev = ''; |
590 | 637 | $no_cache_dev_count = 0; |
@@ -605,10 +652,12 @@ discard block |
||
605 | 652 | } |
606 | 653 | |
607 | 654 | |
608 | - if($no_cache_dev_count > 1 ) |
|
609 | - $this->test_return(L_WARN,"The following devices will not be cached: $no_cache_dev"); |
|
610 | - if($no_cache_dev_count == 1 ) |
|
611 | - $this->test_return(L_WARN,"The following device will not be cached: $no_cache_dev"); |
|
655 | + if($no_cache_dev_count > 1 ) { |
|
656 | + $this->test_return(L_WARN,"The following devices will not be cached: $no_cache_dev"); |
|
657 | + } |
|
658 | + if($no_cache_dev_count == 1 ) { |
|
659 | + $this->test_return(L_WARN,"The following device will not be cached: $no_cache_dev"); |
|
660 | + } |
|
612 | 661 | |
613 | 662 | } |
614 | 663 | |
@@ -637,10 +686,11 @@ discard block |
||
637 | 686 | $mail->Subject = "testing CAT configuration mail"; |
638 | 687 | $mail->Body = "Testing CAT mailing\n"; |
639 | 688 | $sent = $mail->send(); |
640 | - if($sent) |
|
641 | - $this->test_return(L_OK,"mailer settings appear to be working, check ".Config::$APPEARANCE['abuse-mail']." mailbox if the message was receiced."); |
|
642 | - else |
|
643 | - $this->test_return(L_ERROR,"mailer settings failed, check the Config::MAILSETTINGS"); |
|
689 | + if($sent) { |
|
690 | + $this->test_return(L_OK,"mailer settings appear to be working, check ".Config::$APPEARANCE['abuse-mail']." mailbox if the message was receiced."); |
|
691 | + } else { |
|
692 | + $this->test_return(L_ERROR,"mailer settings failed, check the Config::MAILSETTINGS"); |
|
693 | + } |
|
644 | 694 | |
645 | 695 | } |
646 | 696 |
@@ -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]); |
@@ -48,8 +48,9 @@ discard block |
||
48 | 48 | |
49 | 49 | $Dev = Devices::listDevices(); |
50 | 50 | if(isset($Dev[$blueprint])) { |
51 | - if($Dev[$blueprint]['directory'] && $Dev[$blueprint]['module']) |
|
52 | - require_once("devices/".$Dev[$blueprint]['directory']."/".$Dev[$blueprint]['module'].".php"); |
|
51 | + if($Dev[$blueprint]['directory'] && $Dev[$blueprint]['module']) { |
|
52 | + require_once("devices/".$Dev[$blueprint]['directory']."/".$Dev[$blueprint]['module'].".php"); |
|
53 | + } |
|
53 | 54 | debug(4,"loaded: devices/".$Dev[$blueprint]['directory']."/".$Dev[$blueprint]['module'].".php\n"); |
54 | 55 | $class_name = "Device_".$Dev[$blueprint]['module']; |
55 | 56 | $this->device = new $class_name(); |
@@ -66,8 +67,9 @@ discard block |
||
66 | 67 | $options = Devices::$Options; |
67 | 68 | if(isset($Dev[$blueprint]['options'])) { |
68 | 69 | $Opt = $Dev[$blueprint]['options']; |
69 | - foreach ($Opt as $option => $value) |
|
70 | - $options[$option] = $value; |
|
70 | + foreach ($Opt as $option => $value) { |
|
71 | + $options[$option] = $value; |
|
72 | + } |
|
71 | 73 | } |
72 | 74 | $this->device->options = $options; |
73 | 75 | } |
@@ -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 |
@@ -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 |