Passed
Push — release_2_0 ( 0d5fd5...cf68a9 )
by Maja
08:03
created
web/admin/sanity_tests.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  *          <base_url>/copyright.php after deploying the software
20 20
  */
21 21
 
22
-require_once dirname(dirname(dirname(__FILE__))) . "/config/_config.php";
22
+require_once dirname(dirname(dirname(__FILE__)))."/config/_config.php";
23 23
 
24 24
 $Tests = [
25 25
     'cat_base_url',
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     'mailer',
38 38
 ];
39 39
 
40
-if (CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_SILVERBULLET'] == "LOCAL" || CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_RADIUS'] == "LOCAL" ) {
40
+if (CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_SILVERBULLET'] == "LOCAL" || CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_RADIUS'] == "LOCAL") {
41 41
     $Tests[] = 'makensis';
42 42
     $Tests[] = 'makensis=>NSISmodules';
43 43
 }
@@ -71,10 +71,10 @@  discard block
 block discarded – undo
71 71
             $message = "Your configuration appears to be fine.";
72 72
             break;
73 73
         default:
74
-            throw new Exception("The result code level " . $test->test_result['global'] . " is not defined!");
74
+            throw new Exception("The result code level ".$test->test_result['global']." is not defined!");
75 75
     }
76 76
     $uiElements = new web\lib\admin\UIElements();
77
-    $out .= $uiElements->boxFlexible($test->test_result['global'], "<br><strong>Test Summary</strong><br>" . $message . "<br>See below for details<br><hr>");
77
+    $out .= $uiElements->boxFlexible($test->test_result['global'], "<br><strong>Test Summary</strong><br>".$message."<br>See below for details<br><hr>");
78 78
     foreach ($test->out as $testValue) {
79 79
         foreach ($testValue as $o) {
80 80
             $out .= $uiElements->boxFlexible($o['level'], $o['message']);
Please login to merge, or discard this patch.
web/admin/edit_silverbullet.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 /*
21 21
  * Class autoloader invocation, should be included prior to any other code at the entry points to the application
22 22
  */
23
-require_once dirname(dirname(dirname(__FILE__))) . "/config/_config.php";
24
-require_once dirname(dirname(dirname(__FILE__))) . "/core/phpqrcode.php";
23
+require_once dirname(dirname(dirname(__FILE__)))."/config/_config.php";
24
+require_once dirname(dirname(dirname(__FILE__)))."/core/phpqrcode.php";
25 25
 const QRCODE_PIXELS_PER_SYMBOL = 12;
26 26
 
27 27
 $auth = new \web\lib\admin\Authentication();
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     $fed = new \core\Federation($inst->federation);
56 56
     $allowSb = $fed->getAttributes("fed:silverbullet");
57 57
     if (count($allowSb) == 0) {
58
-        throw new Exception("We were told to create a new SB profile, but this " . CONFIG_CONFASSISTANT['CONSORTIUM']['nomenclature_federation'] . " does not allow SB at all!");
58
+        throw new Exception("We were told to create a new SB profile, but this ".CONFIG_CONFASSISTANT['CONSORTIUM']['nomenclature_federation']." does not allow SB at all!");
59 59
     }
60 60
     // okay, new SB profiles are allowed. 
61 61
     // but is there a support:email attribute on inst level?
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     // Create one.
67 67
     $newProfile = $inst->newProfile(core\AbstractProfile::PROFILETYPE_SILVERBULLET);
68 68
     // and modify the REQUEST_URI to add the new profile ID
69
-    $_SERVER['REQUEST_URI'] = $_SERVER['REQUEST_URI'] . "&profile_id=" . $newProfile->identifier;
69
+    $_SERVER['REQUEST_URI'] = $_SERVER['REQUEST_URI']."&profile_id=".$newProfile->identifier;
70 70
     $_GET['profile_id'] = $newProfile->identifier;
71 71
     $profile = $newProfile;
72 72
 } else {
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
                         break;
135 135
                     }
136 136
                     $properName = $validator->User($elements[0]);
137
-                    $properDate = new DateTime($elements[1] . " 00:00:00");
137
+                    $properDate = new DateTime($elements[1]." 00:00:00");
138 138
                     $numberOfActivations = $elements[2] ?? 1;
139 139
                     $number = $validator->integer($numberOfActivations);
140 140
                     if ($number === FALSE) { // invalid input received, default to sane
@@ -227,18 +227,18 @@  discard block
 block discarded – undo
227 227
                     // warn and ask for confirmation unless already confirmed
228 228
                     if (!isset($_POST['insecureconfirm']) || $_POST['insecureconfirm'] != "CONFIRM") {
229 229
                         echo $deco->pageheader(_("Insecure mail domain!"), "ADMIN-IDP-USERS");
230
-                        echo "<p>" . sprintf(_("The mail domain of the mail address <strong>%s</strong> is not secure: some or all of the mail servers are not accepting encrypted connections (no consistent support for STARTTLS)."), $properEmail) . "</p>";
231
-                        echo "<p>" . _("The invitation would need to be sent in cleartext across the internet, and can possibly be read and abused by anyone in transit.") . "</p>";
232
-                        echo "<p>" . _("Do you want the system to send this mail anyway?") . "</p>";
230
+                        echo "<p>".sprintf(_("The mail domain of the mail address <strong>%s</strong> is not secure: some or all of the mail servers are not accepting encrypted connections (no consistent support for STARTTLS)."), $properEmail)."</p>";
231
+                        echo "<p>"._("The invitation would need to be sent in cleartext across the internet, and can possibly be read and abused by anyone in transit.")."</p>";
232
+                        echo "<p>"._("Do you want the system to send this mail anyway?")."</p>";
233 233
                         echo $formtext;
234
-                        echo "<button type='submit' class='delete'>" . _("DO NOT SEND") . "</button>";
234
+                        echo "<button type='submit' class='delete'>"._("DO NOT SEND")."</button>";
235 235
                         echo "</form>";
236 236
                         echo $formtext;
237
-                        echo "<input type='hidden' name='command' value='" . \web\lib\common\FormElements::BUTTON_SENDINVITATIONMAILBYCAT . "'</>";
237
+                        echo "<input type='hidden' name='command' value='".\web\lib\common\FormElements::BUTTON_SENDINVITATIONMAILBYCAT."'</>";
238 238
                         echo "<input type='hidden' name='address' value='$properEmail'</>";
239
-                        echo "<input type='hidden' name='token' value='" . $invitationObject->invitationTokenString . "'</>";
239
+                        echo "<input type='hidden' name='token' value='".$invitationObject->invitationTokenString."'</>";
240 240
                         echo "<input type='hidden' name='insecureconfirm' value='CONFIRM'/>";
241
-                        echo "<button type='submit'>" . _("Send anyway.") . "</button>";
241
+                        echo "<button type='submit'>"._("Send anyway.")."</button>";
242 242
                         echo "</form>";
243 243
                         echo $deco->footer();
244 244
                         exit;
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 $allUsers = $profile->listAllUsers();
289 289
 $activeUsers = $profile->listActiveUsers();
290 290
 
291
-echo $deco->defaultPagePrelude(_(sprintf(_('Managing %s users'), \core\ProfileSilverbullet::PRODUCTNAME )));
291
+echo $deco->defaultPagePrelude(_(sprintf(_('Managing %s users'), \core\ProfileSilverbullet::PRODUCTNAME)));
292 292
 ?>
293 293
 <script src='js/option_expand.js' type='text/javascript'></script>
294 294
 <script src='../external/jquery/jquery.js' type='text/javascript'></script>
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
     echo $deco->productHeader("ADMIN-IDP-USERS");
324 324
     ?>
325 325
     <img src='../resources/images/icons/loading51.gif' id='spin' alt='loading...' style='position:absolute;left: 50%; top: 50%; transform: translate(-100px, -50px); display:none; z-index: 100;'>
326
-    <?php echo $uiElements->instLevelInfoBoxes($inst);?>
326
+    <?php echo $uiElements->instLevelInfoBoxes($inst); ?>
327 327
     <div class='infobox'>
328 328
         <h2><?php echo sprintf(_('Current %s users'), \core\ProfileSilverbullet::PRODUCTNAME); ?></h2>
329 329
         <table>
@@ -423,23 +423,23 @@  discard block
 block discarded – undo
423 423
                                 ?>
424 424
 
425 425
                                 <div class="sb-certificate-summary ca-summary" <?php echo $style; ?>>
426
-                                    <div class="sb-certificate-details"><?php echo _("Device:") . " " . $display; ?>
427
-                                        <br><?php echo _("Serial Number:") . "&nbsp;" . dechex($oneCert->serial); ?>
428
-                                        <br><?php echo _("CN:") . "&nbsp;" . explode('@', $oneCert->username)[0] . "@…"; ?>
429
-                                        <br><?php echo _("Expiry:") . "&nbsp;" . $oneCert->expiry; ?>
430
-                                        <br><?php echo _("Issued:") . "&nbsp;" . $oneCert->issued; ?>
426
+                                    <div class="sb-certificate-details"><?php echo _("Device:")." ".$display; ?>
427
+                                        <br><?php echo _("Serial Number:")."&nbsp;".dechex($oneCert->serial); ?>
428
+                                        <br><?php echo _("CN:")."&nbsp;".explode('@', $oneCert->username)[0]."@…"; ?>
429
+                                        <br><?php echo _("Expiry:")."&nbsp;".$oneCert->expiry; ?>
430
+                                        <br><?php echo _("Issued:")."&nbsp;".$oneCert->issued; ?>
431 431
                                     </div>
432 432
                                     <div style="text-align:right;padding-top: 5px; <?php echo $buttonStyle; ?>">
433 433
                                         <?php
434 434
                                         if ($buttonText == "") {
435 435
                                             echo "$formtext"
436
-                                            . "<input type='hidden' name='certSerial' value='" . $oneCert->serial . "'/>"
437
-                                            . "<input type='hidden' name='certAlgo' value='" . $oneCert->ca_type . "'/>"
436
+                                            . "<input type='hidden' name='certSerial' value='".$oneCert->serial."'/>"
437
+                                            . "<input type='hidden' name='certAlgo' value='".$oneCert->ca_type."'/>"
438 438
                                             . "<button type='submit' "
439 439
                                                     . "name='command' "
440
-                                                    . "value='" . \web\lib\common\FormElements::BUTTON_REVOKECREDENTIAL . "' "
440
+                                                    . "value='".\web\lib\common\FormElements::BUTTON_REVOKECREDENTIAL."' "
441 441
                                                     . "class='delete' "
442
-                                                    . "onclick='return confirm(\"" . sprintf(_("The device in question will stop functioning with %s. The revocation cannot be undone. Are you sure you want to do this?"), CONFIG_CONFASSISTANT['CONSORTIUM']['display_name']) . "\")'>"
442
+                                                    . "onclick='return confirm(\"".sprintf(_("The device in question will stop functioning with %s. The revocation cannot be undone. Are you sure you want to do this?"), CONFIG_CONFASSISTANT['CONSORTIUM']['display_name'])."\")'>"
443 443
                                                     . _("Revoke") 
444 444
                                                     . "</button>"
445 445
                                             . "</form>";
@@ -465,38 +465,38 @@  discard block
 block discarded – undo
465 465
                                     $tokenHtmlBuffer .= "<tr class='sb-certificate-row'><td></td>";
466 466
                                     $jsEncodedBody = str_replace('\n', '%0D%0A', str_replace('"', '', json_encode($invitationObject->invitationMailBody())));
467 467
                                     $tokenHtmlBuffer .= "<td>";
468
-                                    $tokenHtmlBuffer .= sprintf(_("The invitation token %s is ready for sending! Choose how to send it:"),"<input type='text' readonly='readonly' style='background-color:lightgrey;' size='60' value='" . $invitationObject->link() . "' name='token' class='identifiedtokenarea-" . $invitationObject->identifier . "'>(…)<br/>");
468
+                                    $tokenHtmlBuffer .= sprintf(_("The invitation token %s is ready for sending! Choose how to send it:"), "<input type='text' readonly='readonly' style='background-color:lightgrey;' size='60' value='".$invitationObject->link()."' name='token' class='identifiedtokenarea-".$invitationObject->identifier."'>(…)<br/>");
469 469
                                     $tokenHtmlBuffer .= "<table>
470 470
                                     <tr><td style='vertical-align:bottom;'>"._("E-Mail:")."</td><td>
471 471
                                     $formtext
472
-                                <input type='hidden' value='" . $invitationObject->invitationTokenString . "' name='token'><br/>
472
+                                <input type='hidden' value='".$invitationObject->invitationTokenString."' name='token'><br/>
473 473
                                 <input type='text' name='address' id='address-$invitationObject->identifier'/>
474
-                                <button type='button' onclick='window.location=\"mailto:\"+document.getElementById(\"address-$invitationObject->identifier\").value+\"?subject=" . $invitationObject->invitationMailSubject() . "&amp;body=$jsEncodedBody\"; return false;'>" . _("Local mail client") . "</button>
475
-                                <button type='submit' name='command' onclick='document.getElementById(\"spin\").style.display =\"block\"' value='" . \web\lib\common\FormElements::BUTTON_SENDINVITATIONMAILBYCAT . "'>"._("Send with CAT")."</button>
474
+                                <button type='button' onclick='window.location=\"mailto:\"+document.getElementById(\"address-$invitationObject->identifier\").value+\"?subject=".$invitationObject->invitationMailSubject()."&amp;body=$jsEncodedBody\"; return false;'>"._("Local mail client")."</button>
475
+                                <button type='submit' name='command' onclick='document.getElementById(\"spin\").style.display =\"block\"' value='" . \web\lib\common\FormElements::BUTTON_SENDINVITATIONMAILBYCAT."'>"._("Send with CAT")."</button>
476 476
                                     </form>
477 477
                                     </td></tr>
478 478
                                     <tr><td style='vertical-align:bottom;'>"._("SMS:")."</td><td>
479 479
                                     $formtext
480
-                                    <input type='hidden' value='" . $invitationObject->invitationTokenString . "' name='token'><br/>
480
+                                    <input type='hidden' value='".$invitationObject->invitationTokenString."' name='token'><br/>
481 481
                                     <input type='text' name='smsnumber' />
482
-				<button type='submit' name='command' value='" . \web\lib\common\FormElements::BUTTON_SENDINVITATIONSMS . "'>" . _("Send in SMS...") . "</button>
482
+				<button type='submit' name='command' value='" . \web\lib\common\FormElements::BUTTON_SENDINVITATIONSMS."'>"._("Send in SMS...")."</button>
483 483
                                     </form>
484 484
 				</td></tr>
485 485
                                     <tr><td style='vertical-align:bottom;'>"._("Manual:")."</td><td>
486
-				<button type='button' class='clipboardButton' onclick='clipboardCopy(" . $invitationObject->identifier . ");'>" . _("Copy to Clipboard") . "</button>
486
+				<button type='button' class='clipboardButton' onclick='clipboardCopy(" . $invitationObject->identifier.");'>"._("Copy to Clipboard")."</button>
487 487
                                     <form style='display:inline-block;' method='post' action='inc/displayQRcode.inc.php' onsubmit='popupQRWindow(this); return false;' accept-charset='UTF-8'>
488
-                                    <input type='hidden' value='" . $invitationObject->invitationTokenString . "' name='token'><br/>
489
-                                      <button type='submit'>" . _("Display QR code") . "</button>
488
+                                    <input type='hidden' value='" . $invitationObject->invitationTokenString."' name='token'><br/>
489
+                                      <button type='submit'>" . _("Display QR code")."</button>
490 490
                                   </form>
491 491
                                         </td></tr>
492 492
                                         
493 493
                                 </table>
494 494
                                 </td>";
495
-                                    $tokenHtmlBuffer .= "<td>" . _("Expiry Date:") . " " . $invitationObject->expiry . " UTC<br>" . _("Activations remaining:") . " " . sprintf(_("%d of %d"), $invitationObject->activationsRemaining, $invitationObject->activationsTotal) . "</td>";
495
+                                    $tokenHtmlBuffer .= "<td>"._("Expiry Date:")." ".$invitationObject->expiry." UTC<br>"._("Activations remaining:")." ".sprintf(_("%d of %d"), $invitationObject->activationsRemaining, $invitationObject->activationsTotal)."</td>";
496 496
                                     $tokenHtmlBuffer .= "<td>"
497 497
                                             . $formtext
498
-                                            . "<input type='hidden' name='invitationtoken' value='" . $invitationObject->invitationTokenString . "'/>"
499
-                                            . "<button type='submit' name='command' value='" . \web\lib\common\FormElements::BUTTON_REVOKEINVITATION . "' class='delete'>"._("Revoke"). "</button></form>"
498
+                                            . "<input type='hidden' name='invitationtoken' value='".$invitationObject->invitationTokenString."'/>"
499
+                                            . "<button type='submit' name='command' value='".\web\lib\common\FormElements::BUTTON_REVOKEINVITATION."' class='delete'>"._("Revoke")."</button></form>"
500 500
                                             . "</td></tr>";
501 501
                                     break;
502 502
                                 case core\SilverbulletInvitation::SB_TOKENSTATUS_EXPIRED:
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
                                 <span><input type="text" maxlength="19" class="sb-date-picker" name="userexpiry" value="<?php echo $profile->getUserExpiryDate($oneUserId); ?>">&nbsp;(UTC)</span>
519 519
                             </div>
520 520
                             <input type="hidden" name="userid" value="<?php echo $oneUserId; ?>"/>
521
-                            <button type="submit" name="command" value="<?php echo \web\lib\common\FormElements::BUTTON_CHANGEUSEREXPIRY ?>"><?php echo _("Update");?></button>
521
+                            <button type="submit" name="command" value="<?php echo \web\lib\common\FormElements::BUTTON_CHANGEUSEREXPIRY ?>"><?php echo _("Update"); ?></button>
522 522
                             </form>
523 523
                         </td>
524 524
                         <td>
@@ -526,13 +526,13 @@  discard block
 block discarded – undo
526 526
                                 <?php
527 527
                                 if ($hasOnePendingInvite || count($validCerts) > 0) {
528 528
                                     $deletionText = sprintf(_("All of the currently active devices will stop functioning with %s. This cannot be undone. While the user can be re-activated later, they will then need to be re-provisioned with new invitation tokens. Are you sure you want to do this?"), CONFIG_CONFASSISTANT['CONSORTIUM']['display_name']);
529
-                                    echo $formtext . "
529
+                                    echo $formtext."
530 530
                                     <input type='hidden' name='userid' value='$oneUserId'/>
531 531
                                     <button type='submit' "
532 532
                                             . "name='command' "
533
-                                            . "value='" . \web\lib\common\FormElements::BUTTON_DEACTIVATEUSER . "' "
533
+                                            . "value='".\web\lib\common\FormElements::BUTTON_DEACTIVATEUSER."' "
534 534
                                             . "class='delete' "
535
-                                            . ( count($validCerts) > 0 ? "onclick='return confirm(\"".$deletionText."\")' " : "" )
535
+                                            . (count($validCerts) > 0 ? "onclick='return confirm(\"".$deletionText."\")' " : "")
536 536
                                             . ">" 
537 537
                                             . _("Deactivate User") 
538 538
                                             . "</button>
@@ -571,13 +571,13 @@  discard block
 block discarded – undo
571 571
                                     . ' If all accounts shown as active above are indeed still valid, please check the box below and push "Save".'
572 572
                                     . ' If any of the accounts are stale, please deactivate them by pushing the corresponding button before doing this.'), CONFIG_CONFASSISTANT['SILVERBULLET']['gracetime'] ?? core\ProfileSilverbullet::SB_ACKNOWLEDGEMENT_REQUIRED_DAYS);
573 573
 
574
-                    echo $formtext . "<div style='padding-bottom: 20px;'>"
574
+                    echo $formtext."<div style='padding-bottom: 20px;'>"
575 575
                     . "
576 576
                     <p>$acknowledgeText</p>
577 577
                     <input type='checkbox' name='acknowledge' value='true'>
578
-                    <label>" . sprintf(_("I have verified that all configured users are still eligible for %s."),CONFIG_CONFASSISTANT['CONSORTIUM']['display_name']) . "</label>
578
+                    <label>".sprintf(_("I have verified that all configured users are still eligible for %s."), CONFIG_CONFASSISTANT['CONSORTIUM']['display_name'])."</label>
579 579
                 </div>
580
-                <button type='submit' name='command' value='" . \web\lib\common\FormElements::BUTTON_ACKUSERELIGIBILITY . "'>"._("Save")."</button></form>";
580
+                <button type='submit' name='command' value='" . \web\lib\common\FormElements::BUTTON_ACKUSERELIGIBILITY."'>"._("Save")."</button></form>";
581 581
                 }
582 582
                 ?>
583 583
             </div>
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
     
655 655
     <form action="overview_idp.php?inst_id=<?php echo $inst->identifier; ?>" method="POST">
656 656
         <p>
657
-        <button type='submit' name='submitbutton' value="nomatter"><?php echo sprintf(_("Back to %s page"),$uiElements->nomenclatureInst);?></button>
657
+        <button type='submit' name='submitbutton' value="nomatter"><?php echo sprintf(_("Back to %s page"), $uiElements->nomenclatureInst); ?></button>
658 658
         </p>
659 659
     </form>
660 660
     <?php
Please login to merge, or discard this patch.
web/admin/overview_user.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
 namespace core;
23 23
 
24
-require_once dirname(dirname(dirname(__FILE__))) . "/config/_config.php";
24
+require_once dirname(dirname(dirname(__FILE__)))."/config/_config.php";
25 25
 
26 26
 $instMgmt = new \core\UserManagement();
27 27
 $deco = new \web\lib\admin\PageDecoration();
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 <?php echo $uiElements->infoblock($user->getAttributes(), "user", "User"); ?>
52 52
             <tr>
53 53
                 <td>
54
-<?php echo "" . _("Unique Identifier") ?>
54
+<?php echo ""._("Unique Identifier") ?>
55 55
                 </td>
56 56
                 <td>
57 57
                 </td>
@@ -64,14 +64,14 @@  discard block
 block discarded – undo
64 64
     <div>
65 65
         <?php
66 66
         if (CONFIG['DB']['USER']['readonly'] === FALSE) {
67
-            echo "<a href='edit_user.php'><button>" . _("Edit User Details") . "</button></a>";
67
+            echo "<a href='edit_user.php'><button>"._("Edit User Details")."</button></a>";
68 68
         }
69 69
 
70 70
         if ($user->isFederationAdmin()) {
71
-            echo "<form action='overview_federation.php' method='GET' accept-charset='UTF-8'><button type='submit'>" . sprintf(_('Click here for %s management tasks'), $uiElements->nomenclatureFed) . "</button></form>";
71
+            echo "<form action='overview_federation.php' method='GET' accept-charset='UTF-8'><button type='submit'>".sprintf(_('Click here for %s management tasks'), $uiElements->nomenclatureFed)."</button></form>";
72 72
         }
73 73
         if ($user->isSuperadmin()) {
74
-            echo "<form action='112365365321.php' method='GET' accept-charset='UTF-8'><button type='submit'>" . _('Click here to access the superadmin page') . "</button></form>";
74
+            echo "<form action='112365365321.php' method='GET' accept-charset='UTF-8'><button type='submit'>"._('Click here to access the superadmin page')."</button></form>";
75 75
         }
76 76
         ?>
77 77
     </div>
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
         if (CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_SILVERBULLET'] == "LOCAL") {
84 84
             $target = "https://wiki.geant.org/x/SSNwBg"; // Managed IdP manual
85 85
         }
86
-        $helptext = "<h3 style='display:inline;'>" . sprintf(_("(Need help? Refer to the <a href='%s'>%s administrator manual</a>)"), $target, $uiElements->nomenclatureInst) . "</h3>";
86
+        $helptext = "<h3 style='display:inline;'>".sprintf(_("(Need help? Refer to the <a href='%s'>%s administrator manual</a>)"), $target, $uiElements->nomenclatureInst)."</h3>";
87 87
     } else {
88 88
         $helptext = "";
89 89
     }
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
         // we need to run the Federation constructor
93 93
         $cat = new \core\CAT;
94 94
         /// first parameter: number of Identity Providers; second param is the literal configured term for 'Identity Provider' (you may or may not be able to add a plural suffix for your locale)
95
-        echo "<h2>" . sprintf(ngettext("You are managing the following <span style='display:none'>%d </span>%s:", "You are managing the following <strong>%d</strong> %s:", sizeof($hasInst)), sizeof($hasInst), $uiElements->nomenclatureInst) . "</h2>";
95
+        echo "<h2>".sprintf(ngettext("You are managing the following <span style='display:none'>%d </span>%s:", "You are managing the following <strong>%d</strong> %s:", sizeof($hasInst)), sizeof($hasInst), $uiElements->nomenclatureInst)."</h2>";
96 96
         $instlist = [];
97 97
         $my_idps = [];
98 98
         $myFeds = [];
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
             $country[$key] = $row['country'];
115 115
             $name[$key] = $row['name'];
116 116
         }
117
-        echo "<tr><th>" . sprintf(_("%s Name"), $uiElements->nomenclatureInst) . "</th><th>" . sprintf(_("Other admins of this %s"), $uiElements->nomenclatureInst) . "</th><th>" . ( CONFIG['DB']['INST']['readonly'] === FALSE ? _("Administrator Management") : "") . "</th></tr>";
117
+        echo "<tr><th>".sprintf(_("%s Name"), $uiElements->nomenclatureInst)."</th><th>".sprintf(_("Other admins of this %s"), $uiElements->nomenclatureInst)."</th><th>".(CONFIG['DB']['INST']['readonly'] === FALSE ? _("Administrator Management") : "")."</th></tr>";
118 118
         foreach ($myFeds as $fed_id => $fed_name) {
119 119
             /// nomenclature 'fed', fed name, nomenclature 'inst'
120
-            echo "<tr><td colspan='3'><strong>" . sprintf(_("%s %s: %s list"), $uiElements->nomenclatureFed, $fed_name, $uiElements->nomenclatureInst) . "</strong></td></tr>";
120
+            echo "<tr><td colspan='3'><strong>".sprintf(_("%s %s: %s list"), $uiElements->nomenclatureFed, $fed_name, $uiElements->nomenclatureInst)."</strong></td></tr>";
121 121
 
122 122
             $fed_idps = $my_idps[$fed_id];
123 123
             asort($fed_idps);
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
                 $oneinst = $instlist[$index];
126 126
                 $the_inst = $oneinst['object'];
127 127
 
128
-                echo "<tr><td><a href='overview_idp.php?inst_id=$the_inst->identifier'>" . $oneinst['name'] . "</a></td><td>";
128
+                echo "<tr><td><a href='overview_idp.php?inst_id=$the_inst->identifier'>".$oneinst['name']."</a></td><td>";
129 129
                 echo "<input type='hidden' name='inst' value='$the_inst->identifier'>";
130 130
                 $admins = $the_inst->listOwners();
131 131
                 $blessedUser = FALSE;
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
                         $coadmin = new \core\User($username['ID']);
135 135
                         $coadmin_name = $coadmin->getAttributes('user:realname');
136 136
                         if (count($coadmin_name) > 0) {
137
-                            echo $coadmin_name[0]['value'] . "<br/>";
137
+                            echo $coadmin_name[0]['value']."<br/>";
138 138
                             unset($admins[$number]);
139 139
                         }
140 140
                     } else { // don't list self
@@ -150,25 +150,25 @@  discard block
 block discarded – undo
150 150
                 }
151 151
                 echo "</td><td>";
152 152
                 if ($blessedUser && CONFIG['DB']['INST']['readonly'] === FALSE) {
153
-                    echo "<div style='white-space: nowrap;'><form method='post' action='inc/manageAdmins.inc.php?inst_id=" . $the_inst->identifier . "' onsubmit='popupRedirectWindow(this); return false;' accept-charset='UTF-8'><button type='submit'>" . _("Add/Remove Administrators") . "</button></form></div>";
153
+                    echo "<div style='white-space: nowrap;'><form method='post' action='inc/manageAdmins.inc.php?inst_id=".$the_inst->identifier."' onsubmit='popupRedirectWindow(this); return false;' accept-charset='UTF-8'><button type='submit'>"._("Add/Remove Administrators")."</button></form></div>";
154 154
                 }
155 155
                 echo "</td></tr>";
156 156
             }
157 157
         }
158 158
         echo "</table>";
159 159
     } else {
160
-        echo "<h2>" . sprintf(_("You are not managing any %s."), $uiElements->nomenclatureInst) . "</h2>";
160
+        echo "<h2>".sprintf(_("You are not managing any %s."), $uiElements->nomenclatureInst)."</h2>";
161 161
     }
162 162
     if (CONFIG['DB']['INST']['readonly'] === FALSE) {
163 163
         if (CONFIG_CONFASSISTANT['CONSORTIUM']['selfservice_registration'] === NULL) {
164
-            echo "<p>" . sprintf(_("Please ask your %s administrator to invite you to become an %s administrator."), $uiElements->nomenclatureFed, $uiElements->nomenclatureInst) . "</p>";
164
+            echo "<p>".sprintf(_("Please ask your %s administrator to invite you to become an %s administrator."), $uiElements->nomenclatureFed, $uiElements->nomenclatureInst)."</p>";
165 165
             echo "<hr/>
166 166
              <div style='white-space: nowrap;'>
167 167
                 <form action='action_enrollment.php' method='get' accept-charset='UTF-8'>" .
168
-            sprintf(_("Did you receive an invitation token to manage an %s? Please paste it here:"), $uiElements->nomenclatureInst) .
168
+            sprintf(_("Did you receive an invitation token to manage an %s? Please paste it here:"), $uiElements->nomenclatureInst).
169 169
             "        <input type='text' id='token' name='token'/>
170 170
                     <button type='submit'>" .
171
-            _("Go!") . "
171
+            _("Go!")."
172 172
                     </button>
173 173
                 </form>
174 174
              </div>";
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
             <div style='white-space: nowrap;'>
178 178
         <form action='action_enrollment.php' method='get'><button type='submit' accept-charset='UTF-8'>
179 179
                 <input type='hidden' id='token' name='token' value='SELF-REGISTER'/>" .
180
-            sprintf(_("New %s Registration"), $uiElements->nomenclatureInst) . "
180
+            sprintf(_("New %s Registration"), $uiElements->nomenclatureInst)."
181 181
             </button>
182 182
         </form>
183 183
         </div>";
Please login to merge, or discard this patch.
web/admin/edit_idp.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  *          <base_url>/copyright.php after deploying the software
20 20
  */
21 21
 
22
-require_once dirname(dirname(dirname(__FILE__))) . "/config/_config.php";
22
+require_once dirname(dirname(dirname(__FILE__)))."/config/_config.php";
23 23
 
24 24
 $auth = new \web\lib\admin\Authentication();
25 25
 $deco = new \web\lib\admin\PageDecoration();
@@ -94,12 +94,12 @@  discard block
 block discarded – undo
94 94
         </table>
95 95
     </div>
96 96
     <?php
97
-    echo "<form enctype='multipart/form-data' action='edit_idp_result.php?inst_id=$my_inst->identifier" . ($wizardStyle ? "&wizard=true" : "") . "' method='post' accept-charset='UTF-8'>
98
-              <input type='hidden' name='MAX_FILE_SIZE' value='" . CONFIG['MAX_UPLOAD_SIZE'] . "'>";
97
+    echo "<form enctype='multipart/form-data' action='edit_idp_result.php?inst_id=$my_inst->identifier".($wizardStyle ? "&wizard=true" : "")."' method='post' accept-charset='UTF-8'>
98
+              <input type='hidden' name='MAX_FILE_SIZE' value='" . CONFIG['MAX_UPLOAD_SIZE']."'>";
99 99
 
100 100
     if ($wizardStyle) {
101
-        echo "<p>" .
102
-        sprintf(_("Hello, newcomer. The %s is new to us. This wizard will ask you several questions about it, so that we can generate beautiful profiles for you in the end. All of the information below is optional, but it is important to fill out as many fields as possible for the benefit of your end users."), $uiElements->nomenclatureInst) . "</p>";
101
+        echo "<p>".
102
+        sprintf(_("Hello, newcomer. The %s is new to us. This wizard will ask you several questions about it, so that we can generate beautiful profiles for you in the end. All of the information below is optional, but it is important to fill out as many fields as possible for the benefit of your end users."), $uiElements->nomenclatureInst)."</p>";
103 103
     }
104 104
     $optionDisplay = new web\lib\admin\OptionDisplay($idpoptions, "IdP");
105 105
     ?>
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
         <legend><strong><?php echo _("General Information"); ?></strong></legend>
108 108
         <?php
109 109
         if ($wizardStyle) {
110
-            echo "<p>" .
111
-            _("Some properties are valid across all deployment profiles. This is the place where you can describe those properties in a fine-grained way. The solicited information is used as follows:") . "</p>
110
+            echo "<p>".
111
+            _("Some properties are valid across all deployment profiles. This is the place where you can describe those properties in a fine-grained way. The solicited information is used as follows:")."</p>
112 112
                       <ul>
113
-                         <li>" . _("<strong>Logo</strong>: When you submit a logo, we will embed this logo into all installers where a custom logo is possible. We accept any image format, but for best results, we suggest SVG. If you don't upload a logo, we will use the generic logo instead (see top-right corner of this page).") . "</li>
114
-                         <li>" . sprintf(_("<strong>Name</strong>: The %s may have names in multiple languages. It is recommended to always populate at least the 'default/other' language, as it is used as a fallback if the system does not have a name in the exact language the user requests a download in."),$uiElements->nomenclatureInst) . "</li>";
113
+                         <li>" . _("<strong>Logo</strong>: When you submit a logo, we will embed this logo into all installers where a custom logo is possible. We accept any image format, but for best results, we suggest SVG. If you don't upload a logo, we will use the generic logo instead (see top-right corner of this page).")."</li>
114
+                         <li>" . sprintf(_("<strong>Name</strong>: The %s may have names in multiple languages. It is recommended to always populate at least the 'default/other' language, as it is used as a fallback if the system does not have a name in the exact language the user requests a download in."), $uiElements->nomenclatureInst)."</li>";
115 115
             echo "</ul>";
116 116
         }
117 117
         echo $optionDisplay->prefilledOptionTable("general");
@@ -125,47 +125,47 @@  discard block
 block discarded – undo
125 125
         <legend><strong><?php echo _("Media Properties"); ?></strong></legend>
126 126
         <?php
127 127
         if ($wizardStyle) {
128
-            echo "<p>" .
129
-            sprintf(_("In this section, you define on which media %s should be configured on user devices."), CONFIG_CONFASSISTANT['CONSORTIUM']['display_name']) . "</p>
128
+            echo "<p>".
129
+            sprintf(_("In this section, you define on which media %s should be configured on user devices."), CONFIG_CONFASSISTANT['CONSORTIUM']['display_name'])."</p>
130 130
           <ul>";
131 131
             echo "<li>";
132
-            echo "<strong>" . ( count(CONFIG_CONFASSISTANT['CONSORTIUM']['ssid']) > 0 ? _("Additional SSIDs:") : _("SSIDs:")) . " </strong>";
132
+            echo "<strong>".(count(CONFIG_CONFASSISTANT['CONSORTIUM']['ssid']) > 0 ? _("Additional SSIDs:") : _("SSIDs:"))." </strong>";
133 133
             if (count(CONFIG_CONFASSISTANT['CONSORTIUM']['ssid']) > 0) {
134 134
                 $ssidlist = "";
135 135
                 foreach (CONFIG_CONFASSISTANT['CONSORTIUM']['ssid'] as $ssid) {
136
-                    $ssidlist .= ", '<strong>" . $ssid . "</strong>'";
136
+                    $ssidlist .= ", '<strong>".$ssid."</strong>'";
137 137
                 }
138 138
                 $ssidlist = substr($ssidlist, 2);
139 139
                 echo sprintf(ngettext("We will always configure this SSID for WPA2/AES: %s.", "We will always configure these SSIDs for WPA2/AES: %s.", count(CONFIG_CONFASSISTANT['CONSORTIUM']['ssid'])), $ssidlist);
140 140
                 if (CONFIG_CONFASSISTANT['CONSORTIUM']['tkipsupport']) {
141
-                    echo " " . _("They will also be configured for WPA/TKIP if the device supports multiple encryption types.");
141
+                    echo " "._("They will also be configured for WPA/TKIP if the device supports multiple encryption types.");
142 142
                 }
143
-                echo "<br/>" . sprintf(_("It is also possible to define custom additional SSIDs with the options '%s' and '%s' below."), $uiElements->displayName("media:SSID"), $uiElements->displayName("media:SSID_with_legacy"));
143
+                echo "<br/>".sprintf(_("It is also possible to define custom additional SSIDs with the options '%s' and '%s' below."), $uiElements->displayName("media:SSID"), $uiElements->displayName("media:SSID_with_legacy"));
144 144
             } else {
145 145
                 echo _("Please configure which SSIDs should be configured in the installers.");
146 146
             }
147
-            echo " " . _("By default, we will only configure the SSIDs with WPA2/AES encryption. By using the '(with WPA/TKIP)' option you can specify that we should include legacy support for WPA/TKIP where possible.");
147
+            echo " "._("By default, we will only configure the SSIDs with WPA2/AES encryption. By using the '(with WPA/TKIP)' option you can specify that we should include legacy support for WPA/TKIP where possible.");
148 148
             echo "</li>";
149 149
 
150 150
             echo "<li>";
151
-            echo "<strong>" . ( count(CONFIG_CONFASSISTANT['CONSORTIUM']['ssid']) > 0 ? _("Additional Hotspot 2.0 / Passpoint Consortia:") : _("Hotspot 2.0 / Passpoint Consortia:")) . " </strong>";
151
+            echo "<strong>".(count(CONFIG_CONFASSISTANT['CONSORTIUM']['ssid']) > 0 ? _("Additional Hotspot 2.0 / Passpoint Consortia:") : _("Hotspot 2.0 / Passpoint Consortia:"))." </strong>";
152 152
             if (count(CONFIG_CONFASSISTANT['CONSORTIUM']['interworking-consortium-oi']) > 0) {
153 153
                 $consortiumlist = "";
154 154
                 foreach (CONFIG_CONFASSISTANT['CONSORTIUM']['interworking-consortium-oi'] as $oi) {
155
-                    $consortiumlist .= ", '<strong>" . $oi . "</strong>'";
155
+                    $consortiumlist .= ", '<strong>".$oi."</strong>'";
156 156
                 }
157 157
                 $consortiumlist = substr($consortiumlist, 2);
158 158
                 echo sprintf(ngettext("We will always configure this Consortium OI: %s.", "We will always configure these Consortium OIs: %s.", count(CONFIG_CONFASSISTANT['CONSORTIUM']['interworking-consortium-oi'])), $consortiumlist);
159 159
 
160
-                echo "<br/>" . sprintf(_("It is also possible to define custom additional OIs with the option '%s' below."), $uiElements->displayName("media:consortium_OI"));
160
+                echo "<br/>".sprintf(_("It is also possible to define custom additional OIs with the option '%s' below."), $uiElements->displayName("media:consortium_OI"));
161 161
             } else {
162 162
                 echo _("Please configure which Consortium OIs should be configured in the installers.");
163 163
             }
164 164
             echo "</li>";
165
-            echo "<li><strong>" . _("Support for wired IEEE 802.1X:") . " </strong>"
166
-            . _("If you want to configure your users' devices with IEEE 802.1X support for wired ethernet, please check the corresponding box. Note that this makes the installation process a bit more difficult on some platforms (Windows: needs administrator privileges; Apple: attempting to install a profile with wired support on a device without an active wired ethernet card will fail).") .
165
+            echo "<li><strong>"._("Support for wired IEEE 802.1X:")." </strong>"
166
+            . _("If you want to configure your users' devices with IEEE 802.1X support for wired ethernet, please check the corresponding box. Note that this makes the installation process a bit more difficult on some platforms (Windows: needs administrator privileges; Apple: attempting to install a profile with wired support on a device without an active wired ethernet card will fail).").
167 167
             "</li>";
168
-            echo "<li><strong>" . _("Removal of bootstrap/onboarding SSIDs:") . " </strong>"
168
+            echo "<li><strong>"._("Removal of bootstrap/onboarding SSIDs:")." </strong>"
169 169
             . _("If you use a captive portal to distribute configurations, you may want to unconfigure/disable that SSID after the bootstrap process. With this option, the SSID will either be removed, or be defined as 'Only connect manually'.")
170 170
             . "</li>";
171 171
             echo "</ul>";
@@ -181,16 +181,16 @@  discard block
 block discarded – undo
181 181
             echo "<p>"._("This section can be used to upload specific Terms of Use for your users and to display details of how your users can reach your local helpdesk.")."</p>";
182 182
             
183 183
             if (CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_RADIUS'] == "LOCAL") {
184
-                echo "<p>" .
184
+                echo "<p>".
185 185
                         
186
-                sprintf(_("Do you provide helpdesk services for your users? If so, it would be nice if you would tell us the pointers to this helpdesk."),$uiElements->nomenclatureInst)  . "</p>" .
187
-                "<p>" .
188
-                _("If you enter a value here, it will be added to the installers for all your users, and will be displayed on the download page. If you operate separate helpdesks for different user groups (we call this 'profiles') specify per-profile helpdesk information later in this wizard. If you operate no help desk at all, just leave these fields empty.") . "</p>";
186
+                sprintf(_("Do you provide helpdesk services for your users? If so, it would be nice if you would tell us the pointers to this helpdesk."), $uiElements->nomenclatureInst)."</p>".
187
+                "<p>".
188
+                _("If you enter a value here, it will be added to the installers for all your users, and will be displayed on the download page. If you operate separate helpdesks for different user groups (we call this 'profiles') specify per-profile helpdesk information later in this wizard. If you operate no help desk at all, just leave these fields empty.")."</p>";
189 189
                 if (CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_SILVERBULLET'] == "LOCAL") {
190
-                echo "<p>" . sprintf(_("For %s deployments, providing at least a local e-mail contact is required."), core\ProfileSilverbullet::PRODUCTNAME) ." " . _("This is the contact point for your end users' level 1 support.") . "</p>";
190
+                echo "<p>".sprintf(_("For %s deployments, providing at least a local e-mail contact is required."), core\ProfileSilverbullet::PRODUCTNAME)." "._("This is the contact point for your end users' level 1 support.")."</p>";
191 191
                 }
192 192
             } elseif (CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_SILVERBULLET'] == "LOCAL") {
193
-                echo "<p>". _("Providing at least a local support e-mail contact is required.")." "._("This is the contact point for your end users' level 1 support.")."</p>";
193
+                echo "<p>"._("Providing at least a local support e-mail contact is required.")." "._("This is the contact point for your end users' level 1 support.")."</p>";
194 194
             }
195 195
             
196 196
         }
@@ -200,8 +200,8 @@  discard block
 block discarded – undo
200 200
         <button type='button' class='newoption' onclick='getXML("support")'><?php echo _("Add new option"); ?></button></fieldset>
201 201
     <?php
202 202
     if ($wizardStyle) {
203
-        echo "<p>" . sprintf(_("When you are sure that everything is correct, please click on %sContinue ...%s"), "<button type='submit' name='submitbutton' value='" . web\lib\common\FormElements::BUTTON_CONTINUE . "'>", "</button>") . "</p></form>";
203
+        echo "<p>".sprintf(_("When you are sure that everything is correct, please click on %sContinue ...%s"), "<button type='submit' name='submitbutton' value='".web\lib\common\FormElements::BUTTON_CONTINUE."'>", "</button>")."</p></form>";
204 204
     } else {
205
-        echo "<div><button type='submit' name='submitbutton' value='" . web\lib\common\FormElements::BUTTON_SAVE . "'>" . _("Save data") . "</button> <button type='button' class='delete' name='abortbutton' value='abort' onclick='javascript:window.location = \"overview_idp.php?inst_id=$my_inst->identifier\"'>" . _("Discard changes") . "</button></div></form>";
205
+        echo "<div><button type='submit' name='submitbutton' value='".web\lib\common\FormElements::BUTTON_SAVE."'>"._("Save data")."</button> <button type='button' class='delete' name='abortbutton' value='abort' onclick='javascript:window.location = \"overview_idp.php?inst_id=$my_inst->identifier\"'>"._("Discard changes")."</button></div></form>";
206 206
     }
207 207
     echo $deco->footer();
Please login to merge, or discard this patch.
web/lib/admin/OptionDisplay.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
 use Exception;
26 26
 
27
-require_once dirname(dirname(dirname(dirname(__FILE__)))) . "/config/_config.php";
27
+require_once dirname(dirname(dirname(dirname(__FILE__))))."/config/_config.php";
28 28
 
29 29
 /**
30 30
  * We need to display previously set options in various forms. This class covers
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
      * @return string HTML code <table>
88 88
      */
89 89
     public function prefilledOptionTable(string $attributePrefix) {
90
-        $retval = "<table id='expandable_$attributePrefix" . "_options'>";
90
+        $retval = "<table id='expandable_$attributePrefix"."_options'>";
91 91
 
92 92
         $prepopulate = [];
93 93
         foreach ($this->listOfOptions as $existingAttribute) {
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
         if (CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_SILVERBULLET'] == "LOCAL" && CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_RADIUS'] != "LOCAL") {
120 120
             $blackListOnPrefill .= "|fed:silverbullet";
121 121
         }
122
-        if (is_array($prepopulate) && ( count($prepopulate) > 1 || $class == "device-specific" || $class == "eap-specific")) { // editing... fill with values
122
+        if (is_array($prepopulate) && (count($prepopulate) > 1 || $class == "device-specific" || $class == "eap-specific")) { // editing... fill with values
123 123
             foreach ($prepopulate as $option) {
124 124
                 if (preg_match("/$class:/", $option['name']) && !preg_match("/($blackListOnPrefill)/", $option['name'])) {
125 125
                     $optiontypearray = $optioninfo->optionType($option['name']);
126 126
                     $loggerInstance = new \core\common\Logging();
127 127
                     $loggerInstance->debug(5, "About to execute optiontext with PREFILL!\n");
128
-                    $retval .= $this->optiontext([$option['name']], ($optiontypearray["type"] == "file" ? 'ROWID-' . $option['level'] . '-' . $option['row'] : $option['value']), $option['lang']);
128
+                    $retval .= $this->optiontext([$option['name']], ($optiontypearray["type"] == "file" ? 'ROWID-'.$option['level'].'-'.$option['row'] : $option['value']), $option['lang']);
129 129
                 }
130 130
             }
131 131
         } else { // not editing exist, this in new: add empty list
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
         if (!isset($descriptions[$input])) {
188 188
             return "";
189 189
         }
190
-        return "<span class='tooltip' id='S$rowid-tooltip-$input' style='display:" . ($isVisible ? "block" : "none") . "' onclick='alert(\"" . $descriptions[$input] . "\")'><img src='../resources/images/icons/question-mark-icon.png" . "'></span>";
190
+        return "<span class='tooltip' id='S$rowid-tooltip-$input' style='display:".($isVisible ? "block" : "none")."' onclick='alert(\"".$descriptions[$input]."\")'><img src='../resources/images/icons/question-mark-icon.png"."'></span>";
191 191
     }
192 192
 
193 193
     /**
@@ -200,18 +200,18 @@  discard block
 block discarded – undo
200 200
      */
201 201
     private function selectElement($rowid, $list) {
202 202
         $jsmagic = "onchange='
203
-                               if (/#ML#/.test(document.getElementById(\"option-S" . $rowid . "-select\").value)) {
203
+                               if (/#ML#/.test(document.getElementById(\"option-S" . $rowid."-select\").value)) {
204 204
                                    document.getElementById(\"S$rowid-input-langselect\").style.display = \"block\";
205 205
                                    } else {
206 206
                                    document.getElementById(\"S$rowid-input-langselect\").style.display = \"none\";
207 207
                                    }";
208 208
         foreach (array_keys(OptionDisplay::HTML_DATATYPE_TEXTS) as $key) {
209
-            $jsmagic .= "if (/#" . $key . "#/.test(document.getElementById(\"option-S" . $rowid . "-select\").value)) {
210
-                                  document.getElementById(\"S$rowid-input-file\").style.display = \"" . ($key == \core\Options::TYPECODE_FILE ? "block" : "none") . "\";
211
-                                  document.getElementById(\"S$rowid-input-text\").style.display = \"" . ($key == \core\Options::TYPECODE_TEXT ? "block" : "none") . "\";
212
-                                  document.getElementById(\"S$rowid-input-string\").style.display = \"" . ($key == \core\Options::TYPECODE_STRING ? "block" : "none") . "\";
213
-                                  document.getElementById(\"S$rowid-input-boolean\").style.display = \"" . ($key == \core\Options::TYPECODE_BOOLEAN ? "block" : "none") . "\";
214
-                                  document.getElementById(\"S$rowid-input-integer\").style.display = \"" . ($key == \core\Options::TYPECODE_INTEGER ? "block" : "none") . "\";
209
+            $jsmagic .= "if (/#".$key."#/.test(document.getElementById(\"option-S".$rowid."-select\").value)) {
210
+                                  document.getElementById(\"S$rowid-input-file\").style.display = \"".($key == \core\Options::TYPECODE_FILE ? "block" : "none")."\";
211
+                                  document.getElementById(\"S$rowid-input-text\").style.display = \"".($key == \core\Options::TYPECODE_TEXT ? "block" : "none")."\";
212
+                                  document.getElementById(\"S$rowid-input-string\").style.display = \"".($key == \core\Options::TYPECODE_STRING ? "block" : "none")."\";
213
+                                  document.getElementById(\"S$rowid-input-boolean\").style.display = \"".($key == \core\Options::TYPECODE_BOOLEAN ? "block" : "none")."\";
214
+                                  document.getElementById(\"S$rowid-input-integer\").style.display = \"".($key == \core\Options::TYPECODE_INTEGER ? "block" : "none")."\";
215 215
                              }
216 216
                              ";
217 217
             // hide all tooltips (each is a <span>, and there are no other <span>s)
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
         $activelisttype = [];
241 241
         foreach ($list as $value) {
242 242
             $listtype = $optioninfo->optionType($value);
243
-            $retval .= "<option id='option-S$rowid-v-$value' value='$value#" . $listtype["type"] . "#" . $listtype["flag"] . "#' ";
243
+            $retval .= "<option id='option-S$rowid-v-$value' value='$value#".$listtype["type"]."#".$listtype["flag"]."#' ";
244 244
             if ($iterator == $this->optionIterator) {
245 245
                 $retval .= "selected='selected'";
246 246
                 $activelisttype = $listtype;
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
             } else {
249 249
                 $tooltips .= $this->tooltip($rowid, $value, FALSE);
250 250
             }
251
-            $retval .= ">" . $uiElements->displayName($value) . "</option>";
251
+            $retval .= ">".$uiElements->displayName($value)."</option>";
252 252
             $iterator++;
253 253
         }
254 254
         if (count($activelisttype) == 0) {
@@ -271,9 +271,9 @@  discard block
 block discarded – undo
271 271
      */
272 272
     private function selectLanguage($rowid, $makeVisible) {
273 273
         \core\common\Entity::intoThePotatoes();
274
-        $retval = "<select style='display:" . ($makeVisible ? "block" : "none") . "' name='value[S$rowid-lang]' id='S" . $rowid . "-input-langselect'>
275
-            <option value='' name='select_language' selected>" . _("select language") . "</option>
276
-            <option value='C' name='all_languages'>" . _("default/other languages") . "</option>";
274
+        $retval = "<select style='display:".($makeVisible ? "block" : "none")."' name='value[S$rowid-lang]' id='S".$rowid."-input-langselect'>
275
+            <option value='' name='select_language' selected>" . _("select language")."</option>
276
+            <option value='C' name='all_languages'>" . _("default/other languages")."</option>";
277 277
         foreach (CONFIG['LANGUAGES'] as $langindex => $possibleLang) {
278 278
             $thislang = $possibleLang['display'];
279 279
             $retval .= "<option value='$langindex' name='$langindex'>$thislang</option>";
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
     private function inputFields($rowid, $activetype) {
302 302
         $retval = "";
303 303
         foreach (OptionDisplay::HTML_DATATYPE_TEXTS as $key => $type) {
304
-            $retval .= "<" . $type['html'] . " style='display:" . ($activetype['type'] == $key ? "block" : "none") . "' name='value[S$rowid-$key]' id='S" . $rowid . "-input-" . $key . "'" . $type['tail'] . ">";
304
+            $retval .= "<".$type['html']." style='display:".($activetype['type'] == $key ? "block" : "none")."' name='value[S$rowid-$key]' id='S".$rowid."-input-".$key."'".$type['tail'].">";
305 305
         }
306 306
         return $retval;
307 307
     }
@@ -316,11 +316,11 @@  discard block
 block discarded – undo
316 316
     private function noPrefillText(int $rowid, array $list) {
317 317
         // first column: the <select> element with the names of options and their field-toggling JS magic
318 318
         $selectorInfo = $this->selectElement($rowid, $list);
319
-        $retval = "<td>" . $selectorInfo["TEXT"] . "</td>";
319
+        $retval = "<td>".$selectorInfo["TEXT"]."</td>";
320 320
         // second column: the <select> element for language selection - only visible if the active option is multi-lang
321
-        $retval .= "<td>" . $this->selectLanguage($rowid, $selectorInfo['ACTIVE']['flag'] == "ML") . "</td>";
321
+        $retval .= "<td>".$this->selectLanguage($rowid, $selectorInfo['ACTIVE']['flag'] == "ML")."</td>";
322 322
         // third column: the actual input fields; the data type of the active option is visible, all others hidden
323
-        $retval .= "<td>" . $this->inputFields($rowid, $selectorInfo['ACTIVE']) . "</td>";
323
+        $retval .= "<td>".$this->inputFields($rowid, $selectorInfo['ACTIVE'])."</td>";
324 324
         return $retval;
325 325
     }
326 326
 
@@ -343,20 +343,20 @@  discard block
 block discarded – undo
343 343
         $retval .= "<td>";
344 344
         $uiElements = new UIElements();
345 345
         $listtype = $optioninfo->optionType($optionName);
346
-        $retval .= "<span style='display:flex;'>" . $uiElements->displayName($optionName);
347
-        $retval .= $this->tooltip($rowid, $optionName, TRUE) . "</span>";
348
-        $retval .= "<input type='hidden' id='option-S$rowid-select' name='option[S$rowid]' value='$optionName#" . $listtype["type"] . "#" . $listtype["flag"] . "#' ></td>";
346
+        $retval .= "<span style='display:flex;'>".$uiElements->displayName($optionName);
347
+        $retval .= $this->tooltip($rowid, $optionName, TRUE)."</span>";
348
+        $retval .= "<input type='hidden' id='option-S$rowid-select' name='option[S$rowid]' value='$optionName#".$listtype["type"]."#".$listtype["flag"]."#' ></td>";
349 349
 
350 350
         // language tag if any
351 351
         $retval .= "<td>";
352 352
         if ($listtype["flag"] == "ML") {
353 353
 
354
-            $language = "(" . strtoupper($optionLang) . ")";
354
+            $language = "(".strtoupper($optionLang).")";
355 355
             if ($optionLang == 'C') {
356 356
                 $language = _("(default/other languages)");
357 357
             }
358 358
             $retval .= $language;
359
-            $retval .= "<input type='hidden' name='value[S$rowid-lang]' id='S" . $rowid . "-input-langselect' value='" . $optionLang . "' style='display:block'>";
359
+            $retval .= "<input type='hidden' name='value[S$rowid-lang]' id='S".$rowid."-input-langselect' value='".$optionLang."' style='display:block'>";
360 360
         }
361 361
         $retval .= "</td>";
362 362
 // attribute content
@@ -366,12 +366,12 @@  discard block
 block discarded – undo
366 366
             case \core\Options::TYPECODE_COORDINATES:
367 367
                 $this->allLocationCount = $this->allLocationCount + 1;
368 368
                 // display of the locations varies by map provider
369
-                $classname = "\web\lib\admin\Map" . CONFIG_CONFASSISTANT['MAPPROVIDER']['PROVIDER'];
369
+                $classname = "\web\lib\admin\Map".CONFIG_CONFASSISTANT['MAPPROVIDER']['PROVIDER'];
370 370
                 $link = $classname::optionListDisplayCode($optionValue, $this->allLocationCount);
371
-                $retval .= "<input readonly style='display:none' type='text' name='value[S$rowid-" . \core\Options::TYPECODE_TEXT . "]' id='S$rowid-input-text' value='$optionValue'>$link";
371
+                $retval .= "<input readonly style='display:none' type='text' name='value[S$rowid-".\core\Options::TYPECODE_TEXT."]' id='S$rowid-input-text' value='$optionValue'>$link";
372 372
                 break;
373 373
             case \core\Options::TYPECODE_FILE:
374
-                $retval .= "<input readonly type='text' name='value[S$rowid-" . \core\Options::TYPECODE_STRING . "]' id='S" . $rowid . "-input-string' style='display:none' value='" . urlencode($optionValue) . "'>";
374
+                $retval .= "<input readonly type='text' name='value[S$rowid-".\core\Options::TYPECODE_STRING."]' id='S".$rowid."-input-string' style='display:none' value='".urlencode($optionValue)."'>";
375 375
                 $uiElements = new UIElements();
376 376
                 switch ($optionName) {
377 377
                     case "eap:ca_file":
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
                 if ($listtype['type'] == \core\Options::TYPECODE_BOOLEAN) {// only modify in this one case
402 402
                     $displayedVariant = ($optionValue == "on" ? _("on") : _("off"));
403 403
                 }
404
-                $retval .= "<strong>$displayedVariant</strong><input type='hidden' name='value[S$rowid-" . $listtype['type'] . "]' id='S" . $rowid . "-input-" . $listtype["type"] . "' value=\"" . htmlspecialchars($optionValue) . "\" style='display:block'>";
404
+                $retval .= "<strong>$displayedVariant</strong><input type='hidden' name='value[S$rowid-".$listtype['type']."]' id='S".$rowid."-input-".$listtype["type"]."' value=\"".htmlspecialchars($optionValue)."\" style='display:block'>";
405 405
                 break;
406 406
             default:
407 407
                 // this should never happen!
@@ -445,10 +445,10 @@  discard block
 block discarded – undo
445 445
        <td>
446 446
           <button type='button' class='delete' onclick='";
447 447
         if ($prefillValue !== NULL && $item == "general:geo_coordinates") {
448
-            $funcname = "Map" . CONFIG_CONFASSISTANT['MAPPROVIDER']['PROVIDER'] . 'DeleteCoord';
449
-            $retval .= 'if (typeof ' . $funcname . ' === "function") { ' . $funcname . '(' . $this->allLocationCount . '); } ';
448
+            $funcname = "Map".CONFIG_CONFASSISTANT['MAPPROVIDER']['PROVIDER'].'DeleteCoord';
449
+            $retval .= 'if (typeof '.$funcname.' === "function") { '.$funcname.'('.$this->allLocationCount.'); } ';
450 450
         }
451
-        $retval .= 'deleteOption("option-S' . $rowid . '")';
451
+        $retval .= 'deleteOption("option-S'.$rowid.'")';
452 452
         $retval .= "'>-</button>
453 453
        </td>
454 454
     </tr>";
Please login to merge, or discard this patch.
web/admin/API.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  *          <base_url>/copyright.php after deploying the software
21 21
  */
22 22
 
23
-require_once dirname(dirname(dirname(__FILE__))) . "/config/_config.php";
23
+require_once dirname(dirname(dirname(__FILE__)))."/config/_config.php";
24 24
 
25 25
 /**
26 26
  * Checks if the profile is a valid SB profile belonging to the federation
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 $inputRaw = file_get_contents('php://input');
70 70
 $inputDecoded = json_decode($inputRaw, TRUE);
71 71
 if (!is_array($inputDecoded)) {
72
-    $adminApi->returnError(web\lib\admin\API::ERROR_MALFORMED_REQUEST, "Unable to decode JSON POST data." . json_last_error_msg() . $inputRaw);
72
+    $adminApi->returnError(web\lib\admin\API::ERROR_MALFORMED_REQUEST, "Unable to decode JSON POST data.".json_last_error_msg().$inputRaw);
73 73
     exit(1);
74 74
 }
75 75
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             throw new Exception("A required parameter is missing, and this wasn't caught earlier?!");
159 159
         }
160 160
         $newtokens = $mgmt->createTokens(true, [$admin], $idp);
161
-        $URL = "https://" . $_SERVER['SERVER_NAME'] . dirname($_SERVER['SCRIPT_NAME']) . "/action_enrollment.php?token=" . array_keys($newtokens)[0];
161
+        $URL = "https://".$_SERVER['SERVER_NAME'].dirname($_SERVER['SCRIPT_NAME'])."/action_enrollment.php?token=".array_keys($newtokens)[0];
162 162
         $success = ["TOKEN URL" => $URL, "TOKEN" => array_keys($newtokens)[0]];
163 163
         // done with the essentials - display in response. But if we also have an email address, send it there
164 164
         $email = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_TARGETMAIL);
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
         if ($found) {
196 196
             $adminApi->returnSuccess([]);
197 197
         }
198
-        $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "The admin with ID $toBeDeleted is not associated to IdP " . $idp->identifier);
198
+        $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "The admin with ID $toBeDeleted is not associated to IdP ".$idp->identifier);
199 199
         break;
200 200
     case web\lib\admin\API::ACTION_STATISTICS_FED:
201 201
         $adminApi->returnSuccess($fed->downloadStats("array"));
@@ -242,10 +242,10 @@  discard block
 block discarded – undo
242 242
                 $outer = "";
243 243
                 $profile->setAnonymousIDSupport(FALSE);
244 244
             } else {
245
-                $outer = $outer . "@";
245
+                $outer = $outer."@";
246 246
                 $profile->setAnonymousIDSupport(TRUE);
247 247
             }
248
-            $profile->setRealm($outer . $realm);
248
+            $profile->setRealm($outer.$realm);
249 249
         }
250 250
         /* const AUXATTRIB_PROFILE_TESTUSER = 'ATTRIB-PROFILE-TESTUSER'; */
251 251
         $testuser = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_TESTUSER);
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
         // extract relevant subset of information from cert objects
474 474
         $certDetails = [];
475 475
         foreach ($certs as $cert) {
476
-            $certDetails[$cert->ca_type . ":" . $cert->serial] = ["ISSUED" => $cert->issued, "EXPIRY" => $cert->expiry, "STATUS" => $cert->status, "DEVICE" => $cert->device, "CN" => $cert->username, "ANNOTATION" => $cert->annotation];
476
+            $certDetails[$cert->ca_type.":".$cert->serial] = ["ISSUED" => $cert->issued, "EXPIRY" => $cert->expiry, "STATUS" => $cert->status, "DEVICE" => $cert->device, "CN" => $cert->username, "ANNOTATION" => $cert->annotation];
477 477
         }
478 478
         $adminApi->returnSuccess($certDetails);
479 479
         break;
Please login to merge, or discard this patch.
Switch Indentation   +353 added lines, -353 removed lines patch added patch discarded remove patch
@@ -115,212 +115,212 @@  discard block
 block discarded – undo
115 115
 }
116 116
 
117 117
 switch ($inputDecoded['ACTION']) {
118
-    case web\lib\admin\API::ACTION_NEWINST:
119
-        // create the inst, no admin, no attributes
120
-        $idp = new \core\IdP($fed->newIdP("PENDING", "API"));
121
-        // now add all submitted attributes
122
-        $inputs = $adminApi->uglify($scrubbedParameters);
123
-        $optionParser->processSubmittedFields($idp, $inputs["POST"], $inputs["FILES"]);
124
-        $adminApi->returnSuccess([web\lib\admin\API::AUXATTRIB_CAT_INST_ID => $idp->identifier]);
125
-        break;
126
-    case web\lib\admin\API::ACTION_DELINST:
127
-        try {
128
-            $idp = $validator->IdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID));
129
-        } catch (Exception $e) {
130
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!");
131
-            exit(1);
132
-        }
133
-        $idp->destroy();
134
-        $adminApi->returnSuccess([]);
135
-        break;
136
-    case web\lib\admin\API::ACTION_ADMIN_LIST:
137
-        try {
138
-            $idp = $validator->IdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID));
139
-        } catch (Exception $e) {
140
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!");
141
-            exit(1);
142
-        }
143
-        $adminApi->returnSuccess($idp->listOwners());
144
-        break;
145
-    case web\lib\admin\API::ACTION_ADMIN_ADD:
146
-        // IdP in question
147
-        try {
148
-            $idp = $validator->IdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID));
149
-        } catch (Exception $e) {
150
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!");
151
-            exit(1);
152
-        }
153
-        // here is the token
154
-        $mgmt = new core\UserManagement();
155
-        // we know we have an admin ID but scrutinizer wants this checked more explicitly
156
-        $admin = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_ADMINID);
157
-        if ($admin === FALSE) {
158
-            throw new Exception("A required parameter is missing, and this wasn't caught earlier?!");
159
-        }
160
-        $newtokens = $mgmt->createTokens(true, [$admin], $idp);
161
-        $URL = "https://" . $_SERVER['SERVER_NAME'] . dirname($_SERVER['SCRIPT_NAME']) . "/action_enrollment.php?token=" . array_keys($newtokens)[0];
162
-        $success = ["TOKEN URL" => $URL, "TOKEN" => array_keys($newtokens)[0]];
163
-        // done with the essentials - display in response. But if we also have an email address, send it there
164
-        $email = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_TARGETMAIL);
165
-        if ($email !== FALSE) {
166
-            $sent = \core\common\OutsideComm::adminInvitationMail($email, "EXISTING-FED", array_keys($newtokens)[0], $idp->name, $fed);
167
-            $success["EMAIL SENT"] = $sent["SENT"];
168
-            if ($sent["SENT"] === TRUE) {
169
-                $success["EMAIL TRANSPORT SECURE"] = $sent["TRANSPORT"];
170
-            }
171
-        }
172
-        $adminApi->returnSuccess($success);
173
-        break;
174
-    case web\lib\admin\API::ACTION_ADMIN_DEL:
175
-        // IdP in question
176
-        try {
177
-            $idp = $validator->IdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID));
178
-        } catch (Exception $e) {
179
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!");
180
-            exit(1);
181
-        }
182
-        $currentAdmins = $idp->listOwners();
183
-        $toBeDeleted = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_ADMINID);
184
-        if ($toBeDeleted === FALSE) {
185
-            throw new Exception("A required parameter is missing, and this wasn't caught earlier?!");
186
-        }
187
-        $found = FALSE;
188
-        foreach ($currentAdmins as $oneAdmin) {
189
-            if ($oneAdmin['MAIL'] == $toBeDeleted) {
190
-                $found = TRUE;
191
-                $mgmt = new core\UserManagement();
192
-                $mgmt->removeAdminFromIdP($idp, $oneAdmin['ID']);
118
+        case web\lib\admin\API::ACTION_NEWINST:
119
+            // create the inst, no admin, no attributes
120
+            $idp = new \core\IdP($fed->newIdP("PENDING", "API"));
121
+            // now add all submitted attributes
122
+            $inputs = $adminApi->uglify($scrubbedParameters);
123
+            $optionParser->processSubmittedFields($idp, $inputs["POST"], $inputs["FILES"]);
124
+            $adminApi->returnSuccess([web\lib\admin\API::AUXATTRIB_CAT_INST_ID => $idp->identifier]);
125
+            break;
126
+        case web\lib\admin\API::ACTION_DELINST:
127
+            try {
128
+                $idp = $validator->IdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID));
129
+            } catch (Exception $e) {
130
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!");
131
+                exit(1);
193 132
             }
194
-        }
195
-        if ($found) {
133
+            $idp->destroy();
196 134
             $adminApi->returnSuccess([]);
197
-        }
198
-        $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "The admin with ID $toBeDeleted is not associated to IdP " . $idp->identifier);
199
-        break;
200
-    case web\lib\admin\API::ACTION_STATISTICS_FED:
201
-        $adminApi->returnSuccess($fed->downloadStats("array"));
202
-        break;
203
-    case \web\lib\admin\API::ACTION_NEWPROF_RADIUS:
204
-    // fall-through intended: both get mostly identical treatment
205
-    case web\lib\admin\API::ACTION_NEWPROF_SB:
206
-        try {
207
-            $idp = $validator->IdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID));
208
-        } catch (Exception $e) {
209
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!");
210
-            exit(1);
211
-        }
212
-        if ($inputDecoded['ACTION'] == web\lib\admin\API::ACTION_NEWPROF_RADIUS) {
213
-            $type = "RADIUS";
214
-        } else {
215
-            $type = "SILVERBULLET";
216
-        }
217
-        $profile = $idp->newProfile($type);
218
-        if ($profile === NULL) {
219
-            $adminApi->returnError(\web\lib\admin\API::ERROR_INTERNAL_ERROR, "Unable to create a new Profile, for no apparent reason. Please contact support.");
220
-            exit(1);
221
-        }
222
-        $inputs = $adminApi->uglify($scrubbedParameters);
223
-        $optionParser->processSubmittedFields($profile, $inputs["POST"], $inputs["FILES"]);
224
-        if ($inputDecoded['ACTION'] == web\lib\admin\API::ACTION_NEWPROF_SB) {
225
-            // auto-accept ToU?
226
-            if ($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_TOU) !== FALSE) {
227
-                $profile->addAttribute("hiddenprofile:tou_accepted", NULL, 1);
228
-            }
229
-            // we're done at this point
230
-            $adminApi->returnSuccess([\web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID => $profile->identifier]);
231
-            continue;
232
-        }
233
-        if (!$profile instanceof core\ProfileRADIUS) {
234
-            throw new Exception("Can't be. This is only here to convince Scrutinizer that we're really talking RADIUS.");
235
-        }
236
-        /* const AUXATTRIB_PROFILE_REALM = 'ATTRIB-PROFILE-REALM';
237
-          const AUXATTRIB_PROFILE_OUTERVALUE = 'ATTRIB-PROFILE-OUTERVALUE'; */
238
-        $realm = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_REALM);
239
-        $outer = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_OUTERVALUE);
240
-        if ($realm !== FALSE) {
241
-            if ($outer === FALSE) {
242
-                $outer = "";
243
-                $profile->setAnonymousIDSupport(FALSE);
135
+            break;
136
+        case web\lib\admin\API::ACTION_ADMIN_LIST:
137
+            try {
138
+                $idp = $validator->IdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID));
139
+            } catch (Exception $e) {
140
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!");
141
+                exit(1);
142
+            }
143
+            $adminApi->returnSuccess($idp->listOwners());
144
+            break;
145
+        case web\lib\admin\API::ACTION_ADMIN_ADD:
146
+            // IdP in question
147
+            try {
148
+                $idp = $validator->IdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID));
149
+            } catch (Exception $e) {
150
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!");
151
+                exit(1);
152
+            }
153
+            // here is the token
154
+            $mgmt = new core\UserManagement();
155
+            // we know we have an admin ID but scrutinizer wants this checked more explicitly
156
+            $admin = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_ADMINID);
157
+            if ($admin === FALSE) {
158
+                throw new Exception("A required parameter is missing, and this wasn't caught earlier?!");
159
+            }
160
+            $newtokens = $mgmt->createTokens(true, [$admin], $idp);
161
+            $URL = "https://" . $_SERVER['SERVER_NAME'] . dirname($_SERVER['SCRIPT_NAME']) . "/action_enrollment.php?token=" . array_keys($newtokens)[0];
162
+            $success = ["TOKEN URL" => $URL, "TOKEN" => array_keys($newtokens)[0]];
163
+            // done with the essentials - display in response. But if we also have an email address, send it there
164
+            $email = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_TARGETMAIL);
165
+            if ($email !== FALSE) {
166
+                $sent = \core\common\OutsideComm::adminInvitationMail($email, "EXISTING-FED", array_keys($newtokens)[0], $idp->name, $fed);
167
+                $success["EMAIL SENT"] = $sent["SENT"];
168
+                if ($sent["SENT"] === TRUE) {
169
+                    $success["EMAIL TRANSPORT SECURE"] = $sent["TRANSPORT"];
170
+                }
171
+            }
172
+            $adminApi->returnSuccess($success);
173
+            break;
174
+        case web\lib\admin\API::ACTION_ADMIN_DEL:
175
+            // IdP in question
176
+            try {
177
+                $idp = $validator->IdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID));
178
+            } catch (Exception $e) {
179
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!");
180
+                exit(1);
181
+            }
182
+            $currentAdmins = $idp->listOwners();
183
+            $toBeDeleted = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_ADMINID);
184
+            if ($toBeDeleted === FALSE) {
185
+                throw new Exception("A required parameter is missing, and this wasn't caught earlier?!");
186
+            }
187
+            $found = FALSE;
188
+            foreach ($currentAdmins as $oneAdmin) {
189
+                if ($oneAdmin['MAIL'] == $toBeDeleted) {
190
+                    $found = TRUE;
191
+                    $mgmt = new core\UserManagement();
192
+                    $mgmt->removeAdminFromIdP($idp, $oneAdmin['ID']);
193
+                }
194
+            }
195
+            if ($found) {
196
+                $adminApi->returnSuccess([]);
197
+            }
198
+            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "The admin with ID $toBeDeleted is not associated to IdP " . $idp->identifier);
199
+            break;
200
+        case web\lib\admin\API::ACTION_STATISTICS_FED:
201
+            $adminApi->returnSuccess($fed->downloadStats("array"));
202
+            break;
203
+        case \web\lib\admin\API::ACTION_NEWPROF_RADIUS:
204
+        // fall-through intended: both get mostly identical treatment
205
+        case web\lib\admin\API::ACTION_NEWPROF_SB:
206
+            try {
207
+                $idp = $validator->IdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID));
208
+            } catch (Exception $e) {
209
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!");
210
+                exit(1);
211
+            }
212
+            if ($inputDecoded['ACTION'] == web\lib\admin\API::ACTION_NEWPROF_RADIUS) {
213
+                $type = "RADIUS";
244 214
             } else {
245
-                $outer = $outer . "@";
246
-                $profile->setAnonymousIDSupport(TRUE);
215
+                $type = "SILVERBULLET";
247 216
             }
248
-            $profile->setRealm($outer . $realm);
249
-        }
250
-        /* const AUXATTRIB_PROFILE_TESTUSER = 'ATTRIB-PROFILE-TESTUSER'; */
251
-        $testuser = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_TESTUSER);
252
-        if ($testuser !== FALSE) {
253
-            $profile->setRealmCheckUser(TRUE, $testuser);
254
-        }
255
-        /* const AUXATTRIB_PROFILE_INPUT_HINT = 'ATTRIB-PROFILE-HINTREALM';
217
+            $profile = $idp->newProfile($type);
218
+            if ($profile === NULL) {
219
+                $adminApi->returnError(\web\lib\admin\API::ERROR_INTERNAL_ERROR, "Unable to create a new Profile, for no apparent reason. Please contact support.");
220
+                exit(1);
221
+            }
222
+            $inputs = $adminApi->uglify($scrubbedParameters);
223
+            $optionParser->processSubmittedFields($profile, $inputs["POST"], $inputs["FILES"]);
224
+            if ($inputDecoded['ACTION'] == web\lib\admin\API::ACTION_NEWPROF_SB) {
225
+                // auto-accept ToU?
226
+                if ($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_TOU) !== FALSE) {
227
+                    $profile->addAttribute("hiddenprofile:tou_accepted", NULL, 1);
228
+                }
229
+                // we're done at this point
230
+                $adminApi->returnSuccess([\web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID => $profile->identifier]);
231
+                continue;
232
+            }
233
+            if (!$profile instanceof core\ProfileRADIUS) {
234
+                throw new Exception("Can't be. This is only here to convince Scrutinizer that we're really talking RADIUS.");
235
+            }
236
+            /* const AUXATTRIB_PROFILE_REALM = 'ATTRIB-PROFILE-REALM';
237
+          const AUXATTRIB_PROFILE_OUTERVALUE = 'ATTRIB-PROFILE-OUTERVALUE'; */
238
+            $realm = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_REALM);
239
+            $outer = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_OUTERVALUE);
240
+            if ($realm !== FALSE) {
241
+                if ($outer === FALSE) {
242
+                    $outer = "";
243
+                    $profile->setAnonymousIDSupport(FALSE);
244
+                } else {
245
+                    $outer = $outer . "@";
246
+                    $profile->setAnonymousIDSupport(TRUE);
247
+                }
248
+                $profile->setRealm($outer . $realm);
249
+            }
250
+            /* const AUXATTRIB_PROFILE_TESTUSER = 'ATTRIB-PROFILE-TESTUSER'; */
251
+            $testuser = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_TESTUSER);
252
+            if ($testuser !== FALSE) {
253
+                $profile->setRealmCheckUser(TRUE, $testuser);
254
+            }
255
+            /* const AUXATTRIB_PROFILE_INPUT_HINT = 'ATTRIB-PROFILE-HINTREALM';
256 256
           const AUXATTRIB_PROFILE_INPUT_VERIFY = 'ATTRIB-PROFILE-VERIFYREALM'; */
257
-        $hint = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_INPUT_HINT);
258
-        $enforce = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_INPUT_VERIFY);
259
-        if ($enforce !== FALSE) {
260
-            $profile->setInputVerificationPreference($enforce, $hint);
261
-        }
262
-        /* const AUXATTRIB_PROFILE_EAPTYPE */
263
-        $iterator = 1;
264
-        foreach ($scrubbedParameters as $oneParam) {
265
-            if ($oneParam['NAME'] == web\lib\admin\API::AUXATTRIB_PROFILE_EAPTYPE && is_int($oneParam["VALUE"])) {
266
-                $type = new \core\common\EAP($oneParam["VALUE"]);
267
-                $profile->addSupportedEapMethod($type, $iterator);
268
-                $iterator = $iterator + 1;
257
+            $hint = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_INPUT_HINT);
258
+            $enforce = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_INPUT_VERIFY);
259
+            if ($enforce !== FALSE) {
260
+                $profile->setInputVerificationPreference($enforce, $hint);
269 261
             }
270
-        }
271
-        // reinstantiate $profile freshly from DB - it was updated in the process
272
-        $profileFresh = new core\ProfileRADIUS($profile->identifier);
273
-        $profileFresh->prepShowtime();
274
-        $adminApi->returnSuccess([\web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID => $profileFresh->identifier]);
275
-        break;
276
-    case web\lib\admin\API::ACTION_ENDUSER_NEW:
277
-        $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
278
-        if ($prof_id === FALSE) {
279
-            exit(1);
280
-        }
281
-        $evaluation = commonSbProfileChecks($fed, $prof_id);
282
-        if ($evaluation === FALSE) {
283
-            exit(1);
284
-        }
285
-        list($idp, $profile) = $evaluation;
286
-        $user = $validator->string($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERNAME));
287
-        $expiryRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_EXPIRY);
288
-        if ($expiryRaw === FALSE) {
289
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "The expiry date wasn't found in the request.");
290
-            exit(1);
291
-        }
292
-        $expiry = new DateTime($expiryRaw);
293
-        try {
294
-            $retval = $profile->addUser($user, $expiry);
295
-        } catch (Exception $e) {
296
-            $adminApi->returnError(web\lib\admin\API::ERROR_INTERNAL_ERROR, "The operation failed. Maybe a duplicate username, or malformed expiry date?");
297
-            exit(1);
298
-        }
299
-        if ($retval == 0) {// that didn't work, it seems
300
-            $adminApi->returnError(web\lib\admin\API::ERROR_INTERNAL_ERROR, "The operation failed subtly. Contact the administrators.");
301
-            exit(1);
302
-        }
303
-        $adminApi->returnSuccess([web\lib\admin\API::AUXATTRIB_SB_USERNAME => $user, \web\lib\admin\API::AUXATTRIB_SB_USERID => $retval]);
304
-        break;
305
-    case \web\lib\admin\API::ACTION_ENDUSER_DEACTIVATE:
306
-    // fall-through intended: both actions are very similar
307
-    case \web\lib\admin\API::ACTION_TOKEN_NEW:
308
-        $profile_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
309
-        if ($profile_id === FALSE) {
310
-            exit(1);
311
-        }
312
-        $evaluation = commonSbProfileChecks($fed, $profile_id);
313
-        if ($evaluation === FALSE) {
314
-            exit(1);
315
-        }
316
-        list($idp, $profile) = $evaluation;
317
-        $userId = $validator->integer($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERID));
318
-        if ($userId === FALSE) {
319
-            $adminApi->returnError(\web\lib\admin\API::ERROR_INVALID_PARAMETER, "User ID is not an integer.");
320
-            exit(1);
321
-        }
322
-        $additionalInfo = [];
323
-        switch ($inputDecoded['ACTION']) { // this is where the two differ
262
+            /* const AUXATTRIB_PROFILE_EAPTYPE */
263
+            $iterator = 1;
264
+            foreach ($scrubbedParameters as $oneParam) {
265
+                if ($oneParam['NAME'] == web\lib\admin\API::AUXATTRIB_PROFILE_EAPTYPE && is_int($oneParam["VALUE"])) {
266
+                    $type = new \core\common\EAP($oneParam["VALUE"]);
267
+                    $profile->addSupportedEapMethod($type, $iterator);
268
+                    $iterator = $iterator + 1;
269
+                }
270
+            }
271
+            // reinstantiate $profile freshly from DB - it was updated in the process
272
+            $profileFresh = new core\ProfileRADIUS($profile->identifier);
273
+            $profileFresh->prepShowtime();
274
+            $adminApi->returnSuccess([\web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID => $profileFresh->identifier]);
275
+            break;
276
+        case web\lib\admin\API::ACTION_ENDUSER_NEW:
277
+            $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
278
+            if ($prof_id === FALSE) {
279
+                exit(1);
280
+            }
281
+            $evaluation = commonSbProfileChecks($fed, $prof_id);
282
+            if ($evaluation === FALSE) {
283
+                exit(1);
284
+            }
285
+            list($idp, $profile) = $evaluation;
286
+            $user = $validator->string($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERNAME));
287
+            $expiryRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_EXPIRY);
288
+            if ($expiryRaw === FALSE) {
289
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "The expiry date wasn't found in the request.");
290
+                exit(1);
291
+            }
292
+            $expiry = new DateTime($expiryRaw);
293
+            try {
294
+                $retval = $profile->addUser($user, $expiry);
295
+            } catch (Exception $e) {
296
+                $adminApi->returnError(web\lib\admin\API::ERROR_INTERNAL_ERROR, "The operation failed. Maybe a duplicate username, or malformed expiry date?");
297
+                exit(1);
298
+            }
299
+            if ($retval == 0) {// that didn't work, it seems
300
+                $adminApi->returnError(web\lib\admin\API::ERROR_INTERNAL_ERROR, "The operation failed subtly. Contact the administrators.");
301
+                exit(1);
302
+            }
303
+            $adminApi->returnSuccess([web\lib\admin\API::AUXATTRIB_SB_USERNAME => $user, \web\lib\admin\API::AUXATTRIB_SB_USERID => $retval]);
304
+            break;
305
+        case \web\lib\admin\API::ACTION_ENDUSER_DEACTIVATE:
306
+        // fall-through intended: both actions are very similar
307
+        case \web\lib\admin\API::ACTION_TOKEN_NEW:
308
+            $profile_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
309
+            if ($profile_id === FALSE) {
310
+                exit(1);
311
+            }
312
+            $evaluation = commonSbProfileChecks($fed, $profile_id);
313
+            if ($evaluation === FALSE) {
314
+                exit(1);
315
+            }
316
+            list($idp, $profile) = $evaluation;
317
+            $userId = $validator->integer($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERID));
318
+            if ($userId === FALSE) {
319
+                $adminApi->returnError(\web\lib\admin\API::ERROR_INVALID_PARAMETER, "User ID is not an integer.");
320
+                exit(1);
321
+            }
322
+            $additionalInfo = [];
323
+            switch ($inputDecoded['ACTION']) { // this is where the two differ
324 324
             case \web\lib\admin\API::ACTION_ENDUSER_DEACTIVATE:
325 325
                 $result = $profile->deactivateUser($userId);
326 326
                 break;
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
                     }
354 354
                 }
355 355
                 break;
356
-        }
356
+            }
357 357
 
358 358
         if ($result !== TRUE) {
359 359
             $adminApi->returnError(\web\lib\admin\API::ERROR_INVALID_PARAMETER, "These parameters did not lead to an existing, active user.");
@@ -361,65 +361,65 @@  discard block
 block discarded – undo
361 361
         }
362 362
         $adminApi->returnSuccess($additionalInfo);
363 363
         break;
364
-    case \web\lib\admin\API::ACTION_ENDUSER_IDENTIFY:
365
-        $profile_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
366
-        if ($profile_id === FALSE) {
367
-            exit(1);
368
-        }
369
-        $evaluation = commonSbProfileChecks($fed, $profile_id);
370
-        if ($evaluation === FALSE) {
371
-            exit(1);
372
-        }
373
-        list($idp, $profile) = $evaluation;
374
-        $userId = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERID);
375
-        $userName = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERNAME);
376
-        $certSerial = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTSERIAL);
377
-        if ($userId === FALSE && $userName === FALSE && $certSerial === FALSE) {
378
-            // we need at least one of those
379
-            $adminApi->returnError(\web\lib\admin\API::ERROR_MISSING_PARAMETER, "At least one of User ID, Username, or certificate serial is required.");
380
-        }
381
-        $userlist = $profile->listAllUsers();
382
-        if ($userName === FALSE && $certSerial === FALSE) { // we got a user ID
383
-            if (!isset($userlist[$userId])) {
384
-                return $adminApi->returnError(\web\lib\admin\API::ERROR_INVALID_PARAMETER, "This user ID does not exist in this profile.");
364
+        case \web\lib\admin\API::ACTION_ENDUSER_IDENTIFY:
365
+            $profile_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
366
+            if ($profile_id === FALSE) {
367
+                exit(1);
385 368
             }
386
-            $adminApi->returnSuccess([$userId => $userlist[$userId]]);
387
-        }
388
-        if ($userId === FALSE && $certSerial === FALSE) { // we got a username
389
-            $key = array_search($userName, $userlist);
390
-            if ($key === FALSE) {
391
-                return $adminApi->returnError(\web\lib\admin\API::ERROR_INVALID_PARAMETER, "This username does not exist in this profile.");
369
+            $evaluation = commonSbProfileChecks($fed, $profile_id);
370
+            if ($evaluation === FALSE) {
371
+                exit(1);
392 372
             }
393
-            $adminApi->returnSuccess([$key => $userlist[$key]]);
394
-        }
395
-        if ($userId === FALSE && $userName === FALSE) { // we got a cert serial
396
-            $serial = explode(":", $certSerial);
397
-            $cert = new \core\SilverbulletCertificate($serial[1], $serial[0]);
398
-            if ($cert->status == \core\SilverbulletCertificate::CERTSTATUS_INVALID) {
399
-                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial not found.");
373
+            list($idp, $profile) = $evaluation;
374
+            $userId = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERID);
375
+            $userName = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERNAME);
376
+            $certSerial = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTSERIAL);
377
+            if ($userId === FALSE && $userName === FALSE && $certSerial === FALSE) {
378
+                // we need at least one of those
379
+                $adminApi->returnError(\web\lib\admin\API::ERROR_MISSING_PARAMETER, "At least one of User ID, Username, or certificate serial is required.");
400 380
             }
401
-            if ($cert->profileId != $profile->identifier) {
402
-                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial does not belong to this profile.");
381
+            $userlist = $profile->listAllUsers();
382
+            if ($userName === FALSE && $certSerial === FALSE) { // we got a user ID
383
+                if (!isset($userlist[$userId])) {
384
+                    return $adminApi->returnError(\web\lib\admin\API::ERROR_INVALID_PARAMETER, "This user ID does not exist in this profile.");
385
+                }
386
+                $adminApi->returnSuccess([$userId => $userlist[$userId]]);
403 387
             }
404
-            $adminApi->returnSuccess([$cert->userId => $userlist[$cert->userId]]);
405
-        }
406
-        $adminApi->returnError(\web\lib\admin\API::ERROR_INVALID_PARAMETER, "Only exactly one of User ID, username or cert serial can be specified.");
407
-        break;
408
-    case \web\lib\admin\API::ACTION_ENDUSER_LIST:
409
-    // fall-through: those two are similar
410
-    case \web\lib\admin\API::ACTION_TOKEN_LIST:
411
-        $profile_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
412
-        if ($profile_id === FALSE) {
413
-            exit(1);
414
-        }
415
-        $evaluation = commonSbProfileChecks($fed, $profile_id);
416
-        if ($evaluation === FALSE) {
417
-            exit(1);
418
-        }
419
-        list($idp, $profile) = $evaluation;
420
-        $allUsers = $profile->listAllUsers();
421
-        // this is where they differ
422
-        switch ($inputDecoded['ACTION']) {
388
+            if ($userId === FALSE && $certSerial === FALSE) { // we got a username
389
+                $key = array_search($userName, $userlist);
390
+                if ($key === FALSE) {
391
+                    return $adminApi->returnError(\web\lib\admin\API::ERROR_INVALID_PARAMETER, "This username does not exist in this profile.");
392
+                }
393
+                $adminApi->returnSuccess([$key => $userlist[$key]]);
394
+            }
395
+            if ($userId === FALSE && $userName === FALSE) { // we got a cert serial
396
+                $serial = explode(":", $certSerial);
397
+                $cert = new \core\SilverbulletCertificate($serial[1], $serial[0]);
398
+                if ($cert->status == \core\SilverbulletCertificate::CERTSTATUS_INVALID) {
399
+                    $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial not found.");
400
+                }
401
+                if ($cert->profileId != $profile->identifier) {
402
+                    $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial does not belong to this profile.");
403
+                }
404
+                $adminApi->returnSuccess([$cert->userId => $userlist[$cert->userId]]);
405
+            }
406
+            $adminApi->returnError(\web\lib\admin\API::ERROR_INVALID_PARAMETER, "Only exactly one of User ID, username or cert serial can be specified.");
407
+            break;
408
+        case \web\lib\admin\API::ACTION_ENDUSER_LIST:
409
+        // fall-through: those two are similar
410
+        case \web\lib\admin\API::ACTION_TOKEN_LIST:
411
+            $profile_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
412
+            if ($profile_id === FALSE) {
413
+                exit(1);
414
+            }
415
+            $evaluation = commonSbProfileChecks($fed, $profile_id);
416
+            if ($evaluation === FALSE) {
417
+                exit(1);
418
+            }
419
+            list($idp, $profile) = $evaluation;
420
+            $allUsers = $profile->listAllUsers();
421
+            // this is where they differ
422
+            switch ($inputDecoded['ACTION']) {
423 423
             case \web\lib\admin\API::ACTION_ENDUSER_LIST:
424 424
                 $adminApi->returnSuccess($allUsers);
425 425
                 break;
@@ -438,105 +438,105 @@  discard block
 block discarded – undo
438 438
                     $infoSet[$oneTokenObject->userId] = [\web\lib\admin\API::AUXATTRIB_TOKEN => $oneTokenObject->invitationTokenString, "STATUS" => $oneTokenObject->invitationTokenStatus];
439 439
                 }
440 440
                 $adminApi->returnSuccess($infoSet);
441
-        }
442
-        break;
443
-    case \web\lib\admin\API::ACTION_TOKEN_REVOKE:
444
-        $tokenRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_TOKEN);
445
-        if ($tokenRaw === FALSE) {
446
-            exit(1);
447
-        }
448
-        $token = new core\SilverbulletInvitation($tokenRaw);
449
-        if ($token->invitationTokenStatus !== core\SilverbulletInvitation::SB_TOKENSTATUS_VALID && $token->invitationTokenStatus !== core\SilverbulletInvitation::SB_TOKENSTATUS_PARTIALLY_REDEEMED) {
450
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "This is not a currently valid token.");
451
-            exit(1);
452
-        }
453
-        $token->revokeInvitation();
454
-        $adminApi->returnSuccess([]);
455
-        break;
456
-    case \web\lib\admin\API::ACTION_CERT_LIST:
457
-        $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
458
-        $user_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERID);
459
-        if ($prof_id === FALSE || !is_int($user_id)) {
460
-            exit(1);
461
-        }
462
-        $evaluation = commonSbProfileChecks($fed, $prof_id);
463
-        if ($evaluation === FALSE) {
464
-            exit(1);
465
-        }
466
-        list($idp, $profile) = $evaluation;
467
-        $invitations = $profile->userStatus($user_id);
468
-        // now pull out cert information from the object
469
-        $certs = [];
470
-        foreach ($invitations as $oneInvitation) {
471
-            $certs = array_merge($certs, $oneInvitation->associatedCertificates);
472
-        }
473
-        // extract relevant subset of information from cert objects
474
-        $certDetails = [];
475
-        foreach ($certs as $cert) {
476
-            $certDetails[$cert->ca_type . ":" . $cert->serial] = ["ISSUED" => $cert->issued, "EXPIRY" => $cert->expiry, "STATUS" => $cert->status, "DEVICE" => $cert->device, "CN" => $cert->username, "ANNOTATION" => $cert->annotation];
477
-        }
478
-        $adminApi->returnSuccess($certDetails);
479
-        break;
480
-    case \web\lib\admin\API::ACTION_CERT_REVOKE:
481
-        $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
482
-        if ($prof_id === FALSE) {
483
-            exit(1);
484
-        }
485
-        $evaluation = commonSbProfileChecks($fed, $prof_id);
486
-        if ($evaluation === FALSE) {
487
-            exit(1);
488
-        }
489
-        list($idp, $profile) = $evaluation;
490
-        // tear apart the serial
491
-        $serialRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTSERIAL);
492
-        if ($serialRaw === FALSE) {
493
-            exit(1);
494
-        }
495
-        $serial = explode(":", $serialRaw);
496
-        $cert = new \core\SilverbulletCertificate($serial[1], $serial[0]);
497
-        if ($cert->status == \core\SilverbulletCertificate::CERTSTATUS_INVALID) {
498
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial not found.");
499
-        }
500
-        if ($cert->profileId != $profile->identifier) {
501
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial does not belong to this profile.");
502
-        }
503
-        $cert->revokeCertificate();
504
-        $adminApi->returnSuccess([]);
441
+            }
505 442
         break;
506
-    case \web\lib\admin\API::ACTION_CERT_ANNOTATE:
507
-        $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
508
-        if ($prof_id === FALSE) {
509
-            exit(1);
510
-        }
511
-        $evaluation = commonSbProfileChecks($fed, $prof_id);
512
-        if ($evaluation === FALSE) {
513
-            exit(1);
514
-        }
515
-        list($idp, $profile) = $evaluation;
516
-        // tear apart the serial
517
-        $serialRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTSERIAL);
518
-        if ($serialRaw === FALSE) {
519
-            exit(1);
520
-        }
521
-        $serial = explode(":", $serialRaw);
522
-        $cert = new \core\SilverbulletCertificate($serial[1], $serial[0]);
523
-        if ($cert->status == \core\SilverbulletCertificate::CERTSTATUS_INVALID) {
524
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial not found.");
525
-        }
526
-        if ($cert->profileId != $profile->identifier) {
527
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial does not belong to this profile.");
528
-        }
529
-        $annotationRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTANNOTATION);
530
-        if ($annotationRaw === FALSE) {
531
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Unable to extract annotation.");
443
+        case \web\lib\admin\API::ACTION_TOKEN_REVOKE:
444
+            $tokenRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_TOKEN);
445
+            if ($tokenRaw === FALSE) {
446
+                exit(1);
447
+            }
448
+            $token = new core\SilverbulletInvitation($tokenRaw);
449
+            if ($token->invitationTokenStatus !== core\SilverbulletInvitation::SB_TOKENSTATUS_VALID && $token->invitationTokenStatus !== core\SilverbulletInvitation::SB_TOKENSTATUS_PARTIALLY_REDEEMED) {
450
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "This is not a currently valid token.");
451
+                exit(1);
452
+            }
453
+            $token->revokeInvitation();
454
+            $adminApi->returnSuccess([]);
532 455
             break;
533
-        }
534
-        $annotation = json_decode($annotationRaw, TRUE);
535
-        $cert->annotate($annotation);
536
-        $adminApi->returnSuccess([]);
456
+        case \web\lib\admin\API::ACTION_CERT_LIST:
457
+            $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
458
+            $user_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERID);
459
+            if ($prof_id === FALSE || !is_int($user_id)) {
460
+                exit(1);
461
+            }
462
+            $evaluation = commonSbProfileChecks($fed, $prof_id);
463
+            if ($evaluation === FALSE) {
464
+                exit(1);
465
+            }
466
+            list($idp, $profile) = $evaluation;
467
+            $invitations = $profile->userStatus($user_id);
468
+            // now pull out cert information from the object
469
+            $certs = [];
470
+            foreach ($invitations as $oneInvitation) {
471
+                $certs = array_merge($certs, $oneInvitation->associatedCertificates);
472
+            }
473
+            // extract relevant subset of information from cert objects
474
+            $certDetails = [];
475
+            foreach ($certs as $cert) {
476
+                $certDetails[$cert->ca_type . ":" . $cert->serial] = ["ISSUED" => $cert->issued, "EXPIRY" => $cert->expiry, "STATUS" => $cert->status, "DEVICE" => $cert->device, "CN" => $cert->username, "ANNOTATION" => $cert->annotation];
477
+            }
478
+            $adminApi->returnSuccess($certDetails);
479
+            break;
480
+        case \web\lib\admin\API::ACTION_CERT_REVOKE:
481
+            $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
482
+            if ($prof_id === FALSE) {
483
+                exit(1);
484
+            }
485
+            $evaluation = commonSbProfileChecks($fed, $prof_id);
486
+            if ($evaluation === FALSE) {
487
+                exit(1);
488
+            }
489
+            list($idp, $profile) = $evaluation;
490
+            // tear apart the serial
491
+            $serialRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTSERIAL);
492
+            if ($serialRaw === FALSE) {
493
+                exit(1);
494
+            }
495
+            $serial = explode(":", $serialRaw);
496
+            $cert = new \core\SilverbulletCertificate($serial[1], $serial[0]);
497
+            if ($cert->status == \core\SilverbulletCertificate::CERTSTATUS_INVALID) {
498
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial not found.");
499
+            }
500
+            if ($cert->profileId != $profile->identifier) {
501
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial does not belong to this profile.");
502
+            }
503
+            $cert->revokeCertificate();
504
+            $adminApi->returnSuccess([]);
505
+            break;
506
+        case \web\lib\admin\API::ACTION_CERT_ANNOTATE:
507
+            $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
508
+            if ($prof_id === FALSE) {
509
+                exit(1);
510
+            }
511
+            $evaluation = commonSbProfileChecks($fed, $prof_id);
512
+            if ($evaluation === FALSE) {
513
+                exit(1);
514
+            }
515
+            list($idp, $profile) = $evaluation;
516
+            // tear apart the serial
517
+            $serialRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTSERIAL);
518
+            if ($serialRaw === FALSE) {
519
+                exit(1);
520
+            }
521
+            $serial = explode(":", $serialRaw);
522
+            $cert = new \core\SilverbulletCertificate($serial[1], $serial[0]);
523
+            if ($cert->status == \core\SilverbulletCertificate::CERTSTATUS_INVALID) {
524
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial not found.");
525
+            }
526
+            if ($cert->profileId != $profile->identifier) {
527
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial does not belong to this profile.");
528
+            }
529
+            $annotationRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTANNOTATION);
530
+            if ($annotationRaw === FALSE) {
531
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Unable to extract annotation.");
532
+                break;
533
+            }
534
+            $annotation = json_decode($annotationRaw, TRUE);
535
+            $cert->annotate($annotation);
536
+            $adminApi->returnSuccess([]);
537 537
         
538
-        break;
538
+            break;
539 539
         
540
-    default:
541
-        $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_ACTION, "Not implemented yet.");
540
+        default:
541
+            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_ACTION, "Not implemented yet.");
542 542
 }
543 543
\ No newline at end of file
Please login to merge, or discard this patch.
core/diag/Sociopath.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -67,45 +67,45 @@
 block discarded – undo
67 67
         // let's start the numbering at 1
68 68
         $this->qaArray = [
69 69
             1 => ["AREA" => AbstractTest::INFRA_DEVICE,
70
-                  "TXT" => _("Have you ever used the network succesfully, e.g. at your home institution without roaming?"),
71
-                  "FACTOR_YES" => 0.8, // that's good, but it doesn't mean strikingly much
72
-                  "FACTOR_NO" => 2, // that's bad, and points strongly to a config on this end
73
-                  "VERDICTLECTURE" => sprintf(_("If your device has never worked before with this setup, then very likely your device configuation is wrong. %s"), $confAssistantText)],
70
+                    "TXT" => _("Have you ever used the network succesfully, e.g. at your home institution without roaming?"),
71
+                    "FACTOR_YES" => 0.8, // that's good, but it doesn't mean strikingly much
72
+                    "FACTOR_NO" => 2, // that's bad, and points strongly to a config on this end
73
+                    "VERDICTLECTURE" => sprintf(_("If your device has never worked before with this setup, then very likely your device configuation is wrong. %s"), $confAssistantText)],
74 74
             2 => ["AREA" => AbstractTest::INFRA_DEVICE, 
75
-                  "TXT" => _("Did the device previously work when roaming, i.e. at other hotspots away from your home institution?"), 
76
-                  "FACTOR_YES" => 0.6, // that's good, and somewhat encouraging
77
-                  "FACTOR_NO" => 3, // that is almost a smoking gun
78
-                  "VERDICTLECTURE" => sprintf(_("If roaming consistently does not work, then very likely your device configuration is wrong. Typical errors causing this symptom include: using a routing ('outer') username without the @realm.tld suffix - those potentially work at your home organisation, but can not be used when roaming. %s"),$confAssistantText)],
75
+                    "TXT" => _("Did the device previously work when roaming, i.e. at other hotspots away from your home institution?"), 
76
+                    "FACTOR_YES" => 0.6, // that's good, and somewhat encouraging
77
+                    "FACTOR_NO" => 3, // that is almost a smoking gun
78
+                    "VERDICTLECTURE" => sprintf(_("If roaming consistently does not work, then very likely your device configuration is wrong. Typical errors causing this symptom include: using a routing ('outer') username without the @realm.tld suffix - those potentially work at your home organisation, but can not be used when roaming. %s"),$confAssistantText)],
79 79
             3 => ["AREA" => AbstractTest::INFRA_DEVICE, 
80
-                  "TXT" => _("Did you recently change the configuration on your device?"), 
81
-                  "FACTOR_YES" => 3, // that is almost a smoking gun
82
-                  "FACTOR_NO" => 0.6, // encouraging
83
-                  "VERDICTLECTURE" => _("Accounts only need to be configured once, and can then be used anywhere on the planet without any changes. If you recently changed the configuration, that change may very well be at fault. You should never change your network configuration unless explicitly instructed so by your Identity Provider; even in the case of temporary login issues.")],
80
+                    "TXT" => _("Did you recently change the configuration on your device?"), 
81
+                    "FACTOR_YES" => 3, // that is almost a smoking gun
82
+                    "FACTOR_NO" => 0.6, // encouraging
83
+                    "VERDICTLECTURE" => _("Accounts only need to be configured once, and can then be used anywhere on the planet without any changes. If you recently changed the configuration, that change may very well be at fault. You should never change your network configuration unless explicitly instructed so by your Identity Provider; even in the case of temporary login issues.")],
84 84
             4 => ["AREA" => AbstractTest::INFRA_DEVICE, 
85
-                  "TXT" => _("Did you recently change your password?"), 
86
-                  "FACTOR_YES" => 1.5, // that doesn't mean it is the source of the problem, but it /might/ be that the user forgot to provide the new password
87
-                  "FACTOR_NO" => 0.6, // encouraging
88
-                  "VERDICTLECTURE" => _("When you change your password, you also need to supply the new password in the device configuration.")],
85
+                    "TXT" => _("Did you recently change your password?"), 
86
+                    "FACTOR_YES" => 1.5, // that doesn't mean it is the source of the problem, but it /might/ be that the user forgot to provide the new password
87
+                    "FACTOR_NO" => 0.6, // encouraging
88
+                    "VERDICTLECTURE" => _("When you change your password, you also need to supply the new password in the device configuration.")],
89 89
             5 => ["AREA" => AbstractTest::INFRA_DEVICE, 
90
-                  "TXT" => _("If you use more than one device: do your other devices still work?"),
91
-                  "FACTOR_YES" => 0.33, // seems that all is okay with the account as such
92
-                  "FACTOR_NO" => 3, // now that is suspicious indeed
93
-                  "VERDICTLECTURE" => _("If all devices stopped working simultaneously, there may be a problem with your account as such. Maybe your account expired, or you were forced to change the password? These questions are best answered by your Identity Provider [MGW: display contact info]"),],
90
+                    "TXT" => _("If you use more than one device: do your other devices still work?"),
91
+                    "FACTOR_YES" => 0.33, // seems that all is okay with the account as such
92
+                    "FACTOR_NO" => 3, // now that is suspicious indeed
93
+                    "VERDICTLECTURE" => _("If all devices stopped working simultaneously, there may be a problem with your account as such. Maybe your account expired, or you were forced to change the password? These questions are best answered by your Identity Provider [MGW: display contact info]"),],
94 94
             6 => ["AREA" => AbstractTest::INFRA_SP_80211, 
95
-                  "TXT" => _("Is the place you are currently at heavily crowded, or is a network-intensive workload going on?"), 
96
-                  "FACTOR_YES" => 3,
97
-                  "FACTOR_NO" => 0.33,
98
-                  "VERDICTLECTURE" => _("The network is likely overloaded at this location and point in time. You may have to wait until later before you get a better connectivity. If you think the network should be reinforced for more capacity at this place, you should inform the hotspot provider. [MGW: add contact info]")],            
95
+                    "TXT" => _("Is the place you are currently at heavily crowded, or is a network-intensive workload going on?"), 
96
+                    "FACTOR_YES" => 3,
97
+                    "FACTOR_NO" => 0.33,
98
+                    "VERDICTLECTURE" => _("The network is likely overloaded at this location and point in time. You may have to wait until later before you get a better connectivity. If you think the network should be reinforced for more capacity at this place, you should inform the hotspot provider. [MGW: add contact info]")],            
99 99
             7 => ["AREA" => AbstractTest::INFRA_SP_80211, 
100
-                  "TXT" => _("Does the connection get better when you move around?"), 
101
-                  "FACTOR_YES" => 3,
102
-                  "FACTOR_NO" => 0.33,
103
-                  "VERDICTLECTURE" => _("You should move to a different location to achieve better network coverage and service. If you think the exact spot you are at deserves better coverage, you should inform the hotspot provider. [MGW: add contact info]")],
100
+                    "TXT" => _("Does the connection get better when you move around?"), 
101
+                    "FACTOR_YES" => 3,
102
+                    "FACTOR_NO" => 0.33,
103
+                    "VERDICTLECTURE" => _("You should move to a different location to achieve better network coverage and service. If you think the exact spot you are at deserves better coverage, you should inform the hotspot provider. [MGW: add contact info]")],
104 104
             8 => ["AREA" => AbstractTest::INFRA_SP_LAN, 
105
-                  "TXT" => _("Do you see errors stating something similar to 'Unable to get IP address'?"), 
106
-                  "FACTOR_YES" => 5, // gotcha
107
-                  "FACTOR_YES" => 0.5, // the user saying no is not conclusive; maybe the device isn't that verbose or he's not looking at the right spot
108
-                  "VERDICTLECTURE" => _("The evidence at hand suggests that there may be an infrastructure problem at this particular hotspot provider. There is nothing you can do to solve this problem locally. Please be patient and try again at a later time.")],
105
+                    "TXT" => _("Do you see errors stating something similar to 'Unable to get IP address'?"), 
106
+                    "FACTOR_YES" => 5, // gotcha
107
+                    "FACTOR_YES" => 0.5, // the user saying no is not conclusive; maybe the device isn't that verbose or he's not looking at the right spot
108
+                    "VERDICTLECTURE" => _("The evidence at hand suggests that there may be an infrastructure problem at this particular hotspot provider. There is nothing you can do to solve this problem locally. Please be patient and try again at a later time.")],
109 109
         ];
110 110
         \core\common\Entity::outOfThePotatoes();
111 111
     }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 
24 24
 use \Exception;
25 25
 
26
-require_once dirname(dirname(__DIR__)) . "/config/_config.php";
26
+require_once dirname(dirname(__DIR__))."/config/_config.php";
27 27
 
28 28
 /**
29 29
  * This class talks to end users, asking them annoying questions to get to the
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
                   "TXT" => _("Did the device previously work when roaming, i.e. at other hotspots away from your home institution?"), 
76 76
                   "FACTOR_YES" => 0.6, // that's good, and somewhat encouraging
77 77
                   "FACTOR_NO" => 3, // that is almost a smoking gun
78
-                  "VERDICTLECTURE" => sprintf(_("If roaming consistently does not work, then very likely your device configuration is wrong. Typical errors causing this symptom include: using a routing ('outer') username without the @realm.tld suffix - those potentially work at your home organisation, but can not be used when roaming. %s"),$confAssistantText)],
78
+                  "VERDICTLECTURE" => sprintf(_("If roaming consistently does not work, then very likely your device configuration is wrong. Typical errors causing this symptom include: using a routing ('outer') username without the @realm.tld suffix - those potentially work at your home organisation, but can not be used when roaming. %s"), $confAssistantText)],
79 79
             3 => ["AREA" => AbstractTest::INFRA_DEVICE, 
80 80
                   "TXT" => _("Did you recently change the configuration on your device?"), 
81 81
                   "FACTOR_YES" => 3, // that is almost a smoking gun
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
                   "TXT" => _("If you use more than one device: do your other devices still work?"),
91 91
                   "FACTOR_YES" => 0.33, // seems that all is okay with the account as such
92 92
                   "FACTOR_NO" => 3, // now that is suspicious indeed
93
-                  "VERDICTLECTURE" => _("If all devices stopped working simultaneously, there may be a problem with your account as such. Maybe your account expired, or you were forced to change the password? These questions are best answered by your Identity Provider [MGW: display contact info]"),],
93
+                  "VERDICTLECTURE" => _("If all devices stopped working simultaneously, there may be a problem with your account as such. Maybe your account expired, or you were forced to change the password? These questions are best answered by your Identity Provider [MGW: display contact info]"), ],
94 94
             6 => ["AREA" => AbstractTest::INFRA_SP_80211, 
95 95
                   "TXT" => _("Is the place you are currently at heavily crowded, or is a network-intensive workload going on?"), 
96 96
                   "FACTOR_YES" => 3,
@@ -124,11 +124,11 @@  discard block
 block discarded – undo
124 124
         $questionDetails = $this->qaArray[$questionNumber];
125 125
         if ($answer === TRUE) {
126 126
             $this->possibleFailureReasons[$questionDetails['AREA']] = $this->possibleFailureReasons[$questionDetails['AREA']] * $questionDetails["FACTOR_YES"];
127
-            $this->loggerInstance->debug(3,"Adjusting ".$questionDetails['AREA']." by ".$questionDetails["FACTOR_YES"]."\n");
127
+            $this->loggerInstance->debug(3, "Adjusting ".$questionDetails['AREA']." by ".$questionDetails["FACTOR_YES"]."\n");
128 128
             $factor = $questionDetails["FACTOR_YES"];
129 129
         } elseif ($answer === FALSE) {
130 130
             $this->possibleFailureReasons[$questionDetails['AREA']] = $this->possibleFailureReasons[$questionDetails['AREA']] * $questionDetails["FACTOR_NO"];
131
-            $this->loggerInstance->debug(3,"Adjusting ".$questionDetails['AREA']." by ".$questionDetails["FACTOR_NO"]."\n");
131
+            $this->loggerInstance->debug(3, "Adjusting ".$questionDetails['AREA']." by ".$questionDetails["FACTOR_NO"]."\n");
132 132
             $factor = $questionDetails["FACTOR_NO"];
133 133
         } else {
134 134
             $factor = 1;
@@ -138,8 +138,8 @@  discard block
 block discarded – undo
138 138
         $this->additionalFindings["QUESTIONSASKED"] = $this->previousQuestions;
139 139
         $_SESSION["SUSPECTS"] = $this->possibleFailureReasons;
140 140
         $_SESSION["EVIDENCE"] = $this->additionalFindings;
141
-        $this->loggerInstance->debug(3,$_SESSION['SUSPECTS']);
142
-        $this->loggerInstance->debug(3,$_SESSION['EVIDENCE']);
141
+        $this->loggerInstance->debug(3, $_SESSION['SUSPECTS']);
142
+        $this->loggerInstance->debug(3, $_SESSION['EVIDENCE']);
143 143
     }
144 144
     
145 145
     /**
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
         // if both are identical, take any of the questions in the pool of both
159 159
         foreach ($this->qaArray as $questionNumber => $questionDetails) {
160 160
             // if we find a question we didn't ask before AND it is related to our currently high-scoring problem area, ask it
161
-            if (!array_key_exists($questionNumber, $this->previousQuestions) && ( $questionDetails["AREA"] == $highestCategory || $questionDetails["AREA"] == $nextCategory) ) {
161
+            if (!array_key_exists($questionNumber, $this->previousQuestions) && ($questionDetails["AREA"] == $highestCategory || $questionDetails["AREA"] == $nextCategory)) {
162 162
                 return json_encode(["NEXTEXISTS" => TRUE, "NUMBER" => $questionNumber, "TEXT" => $questionDetails["TXT"]]);
163 163
             }
164 164
         }
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
      * @return string JSON encoded array with all the info we have
172 172
      */
173 173
     public function getCurrentGuessState() {
174
-        return json_encode([ "SUSPECTS" => $this->possibleFailureReasons, "EVIDENCE" => $this->additionalFindings ]);
174
+        return json_encode(["SUSPECTS" => $this->possibleFailureReasons, "EVIDENCE" => $this->additionalFindings]);
175 175
     }
176 176
     
177 177
     /**
Please login to merge, or discard this patch.
core/DBConnection.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 
33 33
 use \Exception;
34 34
 
35
-require_once dirname(__DIR__) . "/config/_config.php";
35
+require_once dirname(__DIR__)."/config/_config.php";
36 36
 
37 37
 /**
38 38
  * This class is a singleton for establishing a connection to the database
@@ -60,14 +60,14 @@  discard block
 block discarded – undo
60 60
             case "EXTERNAL":
61 61
             case "FRONTEND":
62 62
             case "DIAGNOSTICS":
63
-                if (!isset(self::${"instance" . $theDb})) {
63
+                if (!isset(self::${"instance".$theDb})) {
64 64
                     $class = __CLASS__;
65
-                    self::${"instance" . $theDb} = new $class($database);
66
-                    DBConnection::${"instance" . $theDb}->databaseInstance = $theDb;
65
+                    self::${"instance".$theDb} = new $class($database);
66
+                    DBConnection::${"instance".$theDb}->databaseInstance = $theDb;
67 67
                 }
68
-                return self::${"instance" . $theDb};
68
+                return self::${"instance".$theDb};
69 69
             default:
70
-                throw new Exception("This type of database (" . strtoupper($database) . ") is not known!");
70
+                throw new Exception("This type of database (".strtoupper($database).") is not known!");
71 71
         }
72 72
     }
73 73
 
@@ -106,18 +106,18 @@  discard block
 block discarded – undo
106 106
             }
107 107
         }
108 108
         // log exact query to debug log, if log level is at 5
109
-        $this->loggerInstance->debug(5, "DB ATTEMPT: " . $querystring . "\n");
109
+        $this->loggerInstance->debug(5, "DB ATTEMPT: ".$querystring."\n");
110 110
         if ($types !== NULL) {
111
-            $this->loggerInstance->debug(5, "Argument type sequence: $types, parameters are: " . print_r($arguments, true));
111
+            $this->loggerInstance->debug(5, "Argument type sequence: $types, parameters are: ".print_r($arguments, true));
112 112
         }
113 113
 
114 114
         if ($this->connection->connect_error) {
115
-            throw new Exception("ERROR: Cannot send query to $this->databaseInstance database (no connection, error number" . $this->connection->connect_error . ")!");
115
+            throw new Exception("ERROR: Cannot send query to $this->databaseInstance database (no connection, error number".$this->connection->connect_error.")!");
116 116
         }
117 117
         if ($types === NULL) {
118 118
             $result = $this->connection->query($querystring);
119 119
             if ($result === FALSE) {
120
-                throw new Exception("DB: Unable to execute simple statement! Error was --> " . $this->connection->error . " <--");
120
+                throw new Exception("DB: Unable to execute simple statement! Error was --> ".$this->connection->error." <--");
121 121
             }
122 122
         } else {
123 123
             // fancy! prepared statement with dedicated argument list
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
             }
131 131
             $prepResult = $statementObject->prepare($querystring);
132 132
             if ($prepResult === FALSE) {
133
-                throw new Exception("DB: Unable to prepare statement! Statement was --> $querystring <--, error was --> " . $statementObject->error . " <--.");
133
+                throw new Exception("DB: Unable to prepare statement! Statement was --> $querystring <--, error was --> ".$statementObject->error." <--.");
134 134
             }
135 135
 
136 136
             // we have a variable number of arguments packed into the ... array
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
             array_unshift($localArray, $types);
143 143
             $retval = call_user_func_array([$statementObject, "bind_param"], $localArray);
144 144
             if ($retval === FALSE) {
145
-                throw new Exception("DB: Unable to bind parameters to prepared statement! Argument array was --> " . var_export($localArray, TRUE) . " <--. Error was --> " . $statementObject->error . " <--");
145
+                throw new Exception("DB: Unable to bind parameters to prepared statement! Argument array was --> ".var_export($localArray, TRUE)." <--. Error was --> ".$statementObject->error." <--");
146 146
             }
147 147
             $result = $statementObject->execute();
148 148
             if ($result === FALSE) {
149
-                throw new Exception("DB: Unable to execute prepared statement! Error was --> " . $statementObject->error . " <--");
149
+                throw new Exception("DB: Unable to execute prepared statement! Error was --> ".$statementObject->error." <--");
150 150
             }
151 151
             $selectResult = $statementObject->get_result();
152 152
             if ($selectResult !== FALSE) {
@@ -158,14 +158,14 @@  discard block
 block discarded – undo
158 158
 
159 159
         // all cases where $result could be FALSE have been caught earlier
160 160
         if ($this->connection->errno) {
161
-            throw new Exception("ERROR: Cannot execute query in $this->databaseInstance database - (hopefully escaped) query was '$querystring', errno was " . $this->connection->errno . "!");
161
+            throw new Exception("ERROR: Cannot execute query in $this->databaseInstance database - (hopefully escaped) query was '$querystring', errno was ".$this->connection->errno."!");
162 162
         }
163 163
 
164 164
 
165 165
         if ($isMoreThanSelect) {
166
-            $this->loggerInstance->writeSQLAudit("[DB: " . strtoupper($this->databaseInstance) . "] " . $querystring);
166
+            $this->loggerInstance->writeSQLAudit("[DB: ".strtoupper($this->databaseInstance)."] ".$querystring);
167 167
             if ($types !== NULL) {
168
-                $this->loggerInstance->writeSQLAudit("Argument type sequence: $types, parameters are: " . print_r($arguments, true));
168
+                $this->loggerInstance->writeSQLAudit("Argument type sequence: $types, parameters are: ".print_r($arguments, true));
169 169
             }
170 170
         }
171 171
         return $result;
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
         $databaseCapitalised = strtoupper($database);
250 250
         $this->connection = new \mysqli(CONFIG['DB'][$databaseCapitalised]['host'], CONFIG['DB'][$databaseCapitalised]['user'], CONFIG['DB'][$databaseCapitalised]['pass'], CONFIG['DB'][$databaseCapitalised]['db']);
251 251
         if ($this->connection->connect_error) {
252
-            throw new Exception("ERROR: Unable to connect to $database database! This is a fatal error, giving up (error number " . $this->connection->connect_errno . ").");
252
+            throw new Exception("ERROR: Unable to connect to $database database! This is a fatal error, giving up (error number ".$this->connection->connect_errno.").");
253 253
         }
254 254
 
255 255
         if ($databaseCapitalised == "EXTERNAL" && CONFIG_CONFASSISTANT['CONSORTIUM']['name'] == "eduroam" && isset(CONFIG_CONFASSISTANT['CONSORTIUM']['deployment-voodoo']) && CONFIG_CONFASSISTANT['CONSORTIUM']['deployment-voodoo'] == "Operations Team") {
Please login to merge, or discard this patch.
web/admin/edit_idp_result.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  *          <base_url>/copyright.php after deploying the software
20 20
  */
21 21
 
22
-require_once dirname(dirname(dirname(__FILE__))) . "/config/_config.php";
22
+require_once dirname(dirname(dirname(__FILE__)))."/config/_config.php";
23 23
 
24 24
 $auth = new \web\lib\admin\Authentication();
25 25
 $loggerInstance = new \core\common\Logging();
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     $instId = $my_inst->identifier;
35 35
     // delete the IdP and send user to enrollment
36 36
     $my_inst->destroy();
37
-    $loggerInstance->writeAudit($_SESSION['user'], "DEL", "IdP " . $instId);
37
+    $loggerInstance->writeAudit($_SESSION['user'], "DEL", "IdP ".$instId);
38 38
     header("Location: overview_user.php");
39 39
     exit;
40 40
 }
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     }
51 51
     // flush all IdP attributes and send user to creation wizard
52 52
     $my_inst->flushAttributes();
53
-    $loggerInstance->writeAudit($_SESSION['user'], "DEL", "IdP starting over" . $instId);
53
+    $loggerInstance->writeAudit($_SESSION['user'], "DEL", "IdP starting over".$instId);
54 54
     header("Location: edit_idp.php?inst_id=$instId&wizard=true");
55 55
     exit;
56 56
 }
@@ -72,21 +72,21 @@  discard block
 block discarded – undo
72 72
 }
73 73
 
74 74
 $inst_name = $my_inst->name;
75
-echo "<h1>" . sprintf(_("Submitted attributes for IdP '%s'"), $inst_name) . "</h1>";
75
+echo "<h1>".sprintf(_("Submitted attributes for IdP '%s'"), $inst_name)."</h1>";
76 76
 echo "<table>";
77 77
 echo $optionParser->processSubmittedFields($my_inst, $_POST, $_FILES);
78 78
 echo "</table>";
79 79
 
80 80
 // delete cached logo, if present
81
-$dir = ROOT . '/web/downloads/logos/';
82
-$globResult = glob($dir . $my_inst->identifier . "_*.png");
81
+$dir = ROOT.'/web/downloads/logos/';
82
+$globResult = glob($dir.$my_inst->identifier."_*.png");
83 83
 if ($globResult === FALSE) { // we should catch the improbable error condition
84 84
     $globResult = [];
85 85
 }
86 86
 array_map('unlink', $globResult);
87 87
 $loggerInstance->debug(4, "UNLINK from $dir\n");
88 88
 
89
-$loggerInstance->writeAudit($_SESSION['user'], "MOD", "IdP " . $my_inst->identifier . " - attributes changed");
89
+$loggerInstance->writeAudit($_SESSION['user'], "MOD", "IdP ".$my_inst->identifier." - attributes changed");
90 90
 
91 91
 // re-instantiate ourselves... profiles need fresh data
92 92
 
@@ -98,15 +98,15 @@  discard block
 block discarded – undo
98 98
 
99 99
 if (isset(CONFIG_CONFASSISTANT['CONSORTIUM']['ssid']) && count(CONFIG_CONFASSISTANT['CONSORTIUM']['ssid']) > 0) {
100 100
     foreach (CONFIG_CONFASSISTANT['CONSORTIUM']['ssid'] as $ssidname) {
101
-        $ssids[] = $ssidname . " " . (isset(CONFIG_CONFASSISTANT['CONSORTIUM']['tkipsupport']) && CONFIG_CONFASSISTANT['CONSORTIUM']['tkipsupport'] === TRUE ? _("(WPA2/AES and WPA/TKIP)") : _("(WPA2/AES)") );
101
+        $ssids[] = $ssidname." ".(isset(CONFIG_CONFASSISTANT['CONSORTIUM']['tkipsupport']) && CONFIG_CONFASSISTANT['CONSORTIUM']['tkipsupport'] === TRUE ? _("(WPA2/AES and WPA/TKIP)") : _("(WPA2/AES)"));
102 102
     }
103 103
 }
104 104
 
105 105
 foreach ($my_inst->getAttributes("media:SSID_with_legacy") as $ssidname) {
106
-    $ssids[] = $ssidname['value'] . " " . _("(WPA2/AES and WPA/TKIP)");
106
+    $ssids[] = $ssidname['value']." "._("(WPA2/AES and WPA/TKIP)");
107 107
 }
108 108
 foreach ($my_inst->getAttributes("media:SSID") as $ssidname) {
109
-    $ssids[] = $ssidname['value'] . " " . _("(WPA2/AES)");
109
+    $ssids[] = $ssidname['value']." "._("(WPA2/AES)");
110 110
 }
111 111
 
112 112
 echo "<table>";
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 if (count($ssids) > 0) {
115 115
     $printedlist = "";
116 116
     foreach ($ssids as $names) {
117
-        $printedlist = $printedlist . "$names ";
117
+        $printedlist = $printedlist."$names ";
118 118
     }
119 119
     echo $uiElements->boxOkay(sprintf(_("Your installers will configure the following SSIDs: <strong>%s</strong>"), $printedlist), _("SSIDs configured"));
120 120
 }
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
         // did we get an email address? then, show the silverbullet jumpstart button
143 143
         // otherwise, issue a smartass comment
144 144
         if (count($my_inst->getAttributes("support:email")) > 0) {
145
-            echo "<form method='post' action='edit_silverbullet.php?inst_id=$my_inst->identifier' accept-charset='UTF-8'><button type='submit'>" . sprintf(_("Continue to %s properties"), \core\ProfileSilverbullet::PRODUCTNAME) . "</button></form>";
145
+            echo "<form method='post' action='edit_silverbullet.php?inst_id=$my_inst->identifier' accept-charset='UTF-8'><button type='submit'>".sprintf(_("Continue to %s properties"), \core\ProfileSilverbullet::PRODUCTNAME)."</button></form>";
146 146
         } else {
147 147
             echo "<table>";
148 148
             echo $uiElements->boxError(sprintf(_("You did not submit an e-mail address. This is required for %s. Please go to the %s dashboard and edit your helpdesk settings to include a helpdesk e-mail address."), core\ProfileSilverbullet::PRODUCTNAME, $ui->nomenclatureInst), _("No support e-mail!"));
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
         }
151 151
     }
152 152
     if (CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_RADIUS'] == "LOCAL") {
153
-        echo "<br/><form method='post' action='edit_profile.php?inst_id=$my_inst->identifier' accept-charset='UTF-8'><button type='submit'>" . _("Continue to RADIUS/EAP profile definition") . "</button></form>";
153
+        echo "<br/><form method='post' action='edit_profile.php?inst_id=$my_inst->identifier' accept-charset='UTF-8'><button type='submit'>"._("Continue to RADIUS/EAP profile definition")."</button></form>";
154 154
     }
155 155
 }
156
-echo "<br/><form method='post' action='overview_idp.php?inst_id=$my_inst->identifier' accept-charset='UTF-8'><button type='submit'>" . _("Continue to dashboard") . "</button></form>";
156
+echo "<br/><form method='post' action='overview_idp.php?inst_id=$my_inst->identifier' accept-charset='UTF-8'><button type='submit'>"._("Continue to dashboard")."</button></form>";
157 157
 
158 158
 echo $deco->footer();
Please login to merge, or discard this patch.