Passed
Push — release_2_0 ( f2471a...804114 )
by Stefan
07:43
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/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 3 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.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -417,7 +417,7 @@
 block discarded – undo
417 417
         $userId = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERID);
418 418
         $userName = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERNAME);
419 419
         $certSerial = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTSERIAL);
420
-		$certCN = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTCN);
420
+        $certCN = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTCN);
421 421
         if ($userId === FALSE && $userName === FALSE && $certSerial === FALSE && $certCN === FALSE) {
422 422
             // we need at least one of those
423 423
             $adminApi->returnError(\web\lib\admin\API::ERROR_MISSING_PARAMETER, "At least one of User ID, Username, certificate serial, or certificate CN is required.");
Please login to merge, or discard this patch.
Switch Indentation   +370 added lines, -370 removed lines patch added patch discarded remove patch
@@ -115,213 +115,213 @@  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_FEDERATION_LISTIDP:
204
-        $retArray = [];
205
-        $idpIdentifier = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID);
206
-        if ($idpIdentifier === FALSE) {
207
-            $allIdPs = $fed->listIdentityProviders(0);
208
-            foreach ($allIdPs as $instanceId => $oneIdP) {
209
-                $theIdP = $oneIdP["instance"];
210
-                $retArray[$instanceId] = $theIdP->getAttributes();
211
-            }
212
-        } else {
135
+            break;
136
+        case web\lib\admin\API::ACTION_ADMIN_LIST:
213 137
             try {
214
-                $thisIdP = $validator->IdP($idpIdentifier);
138
+                $idp = $validator->IdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID));
215 139
             } catch (Exception $e) {
216 140
                 $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!");
217 141
                 exit(1);
218 142
             }
219
-            $retArray[$idpIdentifier] = $thisIdP->getAttributes();
220
-        }
221
-        foreach ($retArray as $instNumber => $oneInstData) {
222
-            foreach ($oneInstData as $attribNumber => $oneAttrib) {
223
-                if ($oneAttrib['name'] == "general:logo_file") {
224
-                    // JSON doesn't cope well with raw binary data, so b64 it
225
-                    $retArray[$instNumber][$attribNumber]['value'] = base64_encode($oneAttrib['value']);
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"];
226 170
                 }
227 171
             }
228
-        }
229
-        $adminApi->returnSuccess($retArray);
230
-        break;
231
-    case \web\lib\admin\API::ACTION_NEWPROF_RADIUS:
232
-    // fall-through intended: both get mostly identical treatment
233
-    case web\lib\admin\API::ACTION_NEWPROF_SB:
234
-        try {
235
-            $idp = $validator->IdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID));
236
-        } catch (Exception $e) {
237
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!");
238
-            exit(1);
239
-        }
240
-        if ($inputDecoded['ACTION'] == web\lib\admin\API::ACTION_NEWPROF_RADIUS) {
241
-            $type = "RADIUS";
242
-        } else {
243
-            $type = "SILVERBULLET";
244
-        }
245
-        $profile = $idp->newProfile($type);
246
-        if ($profile === NULL) {
247
-            $adminApi->returnError(\web\lib\admin\API::ERROR_INTERNAL_ERROR, "Unable to create a new Profile, for no apparent reason. Please contact support.");
248
-            exit(1);
249
-        }
250
-        $inputs = $adminApi->uglify($scrubbedParameters);
251
-        $optionParser->processSubmittedFields($profile, $inputs["POST"], $inputs["FILES"]);
252
-        if ($inputDecoded['ACTION'] == web\lib\admin\API::ACTION_NEWPROF_SB) {
253
-            // auto-accept ToU?
254
-            if ($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_TOU) !== FALSE) {
255
-                $profile->addAttribute("hiddenprofile:tou_accepted", NULL, 1);
256
-            }
257
-            // we're done at this point
258
-            $adminApi->returnSuccess([\web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID => $profile->identifier]);
259
-            continue;
260
-        }
261
-        if (!$profile instanceof core\ProfileRADIUS) {
262
-            throw new Exception("Can't be. This is only here to convince Scrutinizer that we're really talking RADIUS.");
263
-        }
264
-        /* const AUXATTRIB_PROFILE_REALM = 'ATTRIB-PROFILE-REALM';
265
-          const AUXATTRIB_PROFILE_OUTERVALUE = 'ATTRIB-PROFILE-OUTERVALUE'; */
266
-        $realm = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_REALM);
267
-        $outer = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_OUTERVALUE);
268
-        if ($realm !== FALSE) {
269
-            if ($outer === FALSE) {
270
-                $outer = "";
271
-                $profile->setAnonymousIDSupport(FALSE);
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_FEDERATION_LISTIDP:
204
+            $retArray = [];
205
+            $idpIdentifier = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID);
206
+            if ($idpIdentifier === FALSE) {
207
+                $allIdPs = $fed->listIdentityProviders(0);
208
+                foreach ($allIdPs as $instanceId => $oneIdP) {
209
+                    $theIdP = $oneIdP["instance"];
210
+                    $retArray[$instanceId] = $theIdP->getAttributes();
211
+                }
272 212
             } else {
273
-                $outer = $outer . "@";
274
-                $profile->setAnonymousIDSupport(TRUE);
213
+                try {
214
+                    $thisIdP = $validator->IdP($idpIdentifier);
215
+                } catch (Exception $e) {
216
+                    $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!");
217
+                    exit(1);
218
+                }
219
+                $retArray[$idpIdentifier] = $thisIdP->getAttributes();
275 220
             }
276
-            $profile->setRealm($outer . $realm);
277
-        }
278
-        /* const AUXATTRIB_PROFILE_TESTUSER = 'ATTRIB-PROFILE-TESTUSER'; */
279
-        $testuser = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_TESTUSER);
280
-        if ($testuser !== FALSE) {
281
-            $profile->setRealmCheckUser(TRUE, $testuser);
282
-        }
283
-        /* const AUXATTRIB_PROFILE_INPUT_HINT = 'ATTRIB-PROFILE-HINTREALM';
221
+            foreach ($retArray as $instNumber => $oneInstData) {
222
+                foreach ($oneInstData as $attribNumber => $oneAttrib) {
223
+                    if ($oneAttrib['name'] == "general:logo_file") {
224
+                        // JSON doesn't cope well with raw binary data, so b64 it
225
+                        $retArray[$instNumber][$attribNumber]['value'] = base64_encode($oneAttrib['value']);
226
+                    }
227
+                }
228
+            }
229
+            $adminApi->returnSuccess($retArray);
230
+            break;
231
+        case \web\lib\admin\API::ACTION_NEWPROF_RADIUS:
232
+        // fall-through intended: both get mostly identical treatment
233
+        case web\lib\admin\API::ACTION_NEWPROF_SB:
234
+            try {
235
+                $idp = $validator->IdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID));
236
+            } catch (Exception $e) {
237
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!");
238
+                exit(1);
239
+            }
240
+            if ($inputDecoded['ACTION'] == web\lib\admin\API::ACTION_NEWPROF_RADIUS) {
241
+                $type = "RADIUS";
242
+            } else {
243
+                $type = "SILVERBULLET";
244
+            }
245
+            $profile = $idp->newProfile($type);
246
+            if ($profile === NULL) {
247
+                $adminApi->returnError(\web\lib\admin\API::ERROR_INTERNAL_ERROR, "Unable to create a new Profile, for no apparent reason. Please contact support.");
248
+                exit(1);
249
+            }
250
+            $inputs = $adminApi->uglify($scrubbedParameters);
251
+            $optionParser->processSubmittedFields($profile, $inputs["POST"], $inputs["FILES"]);
252
+            if ($inputDecoded['ACTION'] == web\lib\admin\API::ACTION_NEWPROF_SB) {
253
+                // auto-accept ToU?
254
+                if ($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_TOU) !== FALSE) {
255
+                    $profile->addAttribute("hiddenprofile:tou_accepted", NULL, 1);
256
+                }
257
+                // we're done at this point
258
+                $adminApi->returnSuccess([\web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID => $profile->identifier]);
259
+                continue;
260
+            }
261
+            if (!$profile instanceof core\ProfileRADIUS) {
262
+                throw new Exception("Can't be. This is only here to convince Scrutinizer that we're really talking RADIUS.");
263
+            }
264
+            /* const AUXATTRIB_PROFILE_REALM = 'ATTRIB-PROFILE-REALM';
265
+          const AUXATTRIB_PROFILE_OUTERVALUE = 'ATTRIB-PROFILE-OUTERVALUE'; */
266
+            $realm = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_REALM);
267
+            $outer = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_OUTERVALUE);
268
+            if ($realm !== FALSE) {
269
+                if ($outer === FALSE) {
270
+                    $outer = "";
271
+                    $profile->setAnonymousIDSupport(FALSE);
272
+                } else {
273
+                    $outer = $outer . "@";
274
+                    $profile->setAnonymousIDSupport(TRUE);
275
+                }
276
+                $profile->setRealm($outer . $realm);
277
+            }
278
+            /* const AUXATTRIB_PROFILE_TESTUSER = 'ATTRIB-PROFILE-TESTUSER'; */
279
+            $testuser = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_TESTUSER);
280
+            if ($testuser !== FALSE) {
281
+                $profile->setRealmCheckUser(TRUE, $testuser);
282
+            }
283
+            /* const AUXATTRIB_PROFILE_INPUT_HINT = 'ATTRIB-PROFILE-HINTREALM';
284 284
           const AUXATTRIB_PROFILE_INPUT_VERIFY = 'ATTRIB-PROFILE-VERIFYREALM'; */
285
-        $hint = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_INPUT_HINT);
286
-        $enforce = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_INPUT_VERIFY);
287
-        if ($enforce !== FALSE) {
288
-            $profile->setInputVerificationPreference($enforce, $hint);
289
-        }
290
-        /* const AUXATTRIB_PROFILE_EAPTYPE */
291
-        $iterator = 1;
292
-        foreach ($scrubbedParameters as $oneParam) {
293
-            if ($oneParam['NAME'] == web\lib\admin\API::AUXATTRIB_PROFILE_EAPTYPE && is_int($oneParam["VALUE"])) {
294
-                $type = new \core\common\EAP($oneParam["VALUE"]);
295
-                $profile->addSupportedEapMethod($type, $iterator);
296
-                $iterator = $iterator + 1;
285
+            $hint = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_INPUT_HINT);
286
+            $enforce = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_INPUT_VERIFY);
287
+            if ($enforce !== FALSE) {
288
+                $profile->setInputVerificationPreference($enforce, $hint);
297 289
             }
298
-        }
299
-        // reinstantiate $profile freshly from DB - it was updated in the process
300
-        $profileFresh = new core\ProfileRADIUS($profile->identifier);
301
-        $profileFresh->prepShowtime();
302
-        $adminApi->returnSuccess([\web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID => $profileFresh->identifier]);
303
-        break;
304
-    case web\lib\admin\API::ACTION_ENDUSER_NEW:
305
-    // fall-through intentional, those two actions are doing nearly identical things
306
-    case web\lib\admin\API::ACTION_ENDUSER_CHANGEEXPIRY:
307
-        $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
308
-        if ($prof_id === FALSE) {
309
-            exit(1);
310
-        }
311
-        $evaluation = commonSbProfileChecks($fed, $prof_id);
312
-        if ($evaluation === FALSE) {
313
-            exit(1);
314
-        }
315
-        list($idp, $profile) = $evaluation;
316
-        $user = $validator->string($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERNAME));
317
-        $expiryRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_EXPIRY);
318
-        if ($expiryRaw === FALSE) {
319
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "The expiry date wasn't found in the request.");
290
+            /* const AUXATTRIB_PROFILE_EAPTYPE */
291
+            $iterator = 1;
292
+            foreach ($scrubbedParameters as $oneParam) {
293
+                if ($oneParam['NAME'] == web\lib\admin\API::AUXATTRIB_PROFILE_EAPTYPE && is_int($oneParam["VALUE"])) {
294
+                    $type = new \core\common\EAP($oneParam["VALUE"]);
295
+                    $profile->addSupportedEapMethod($type, $iterator);
296
+                    $iterator = $iterator + 1;
297
+                }
298
+            }
299
+            // reinstantiate $profile freshly from DB - it was updated in the process
300
+            $profileFresh = new core\ProfileRADIUS($profile->identifier);
301
+            $profileFresh->prepShowtime();
302
+            $adminApi->returnSuccess([\web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID => $profileFresh->identifier]);
320 303
             break;
321
-        }
322
-        $expiry = new DateTime($expiryRaw);
323
-        try {
324
-            switch ($inputDecoded['ACTION']) {
304
+        case web\lib\admin\API::ACTION_ENDUSER_NEW:
305
+        // fall-through intentional, those two actions are doing nearly identical things
306
+        case web\lib\admin\API::ACTION_ENDUSER_CHANGEEXPIRY:
307
+            $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
308
+            if ($prof_id === FALSE) {
309
+                exit(1);
310
+            }
311
+            $evaluation = commonSbProfileChecks($fed, $prof_id);
312
+            if ($evaluation === FALSE) {
313
+                exit(1);
314
+            }
315
+            list($idp, $profile) = $evaluation;
316
+            $user = $validator->string($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERNAME));
317
+            $expiryRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_EXPIRY);
318
+            if ($expiryRaw === FALSE) {
319
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "The expiry date wasn't found in the request.");
320
+                break;
321
+            }
322
+            $expiry = new DateTime($expiryRaw);
323
+            try {
324
+                switch ($inputDecoded['ACTION']) {
325 325
                 case web\lib\admin\API::ACTION_ENDUSER_NEW:
326 326
                     $retval = $profile->addUser($user, $expiry);
327 327
                     break;
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
                         $retval = 1; // function doesn't have any failure vectors not raising an Exception and doesn't return a value
335 335
                     }
336 336
                     break;
337
-            }
337
+                }
338 338
         } catch (Exception $e) {
339 339
             $adminApi->returnError(web\lib\admin\API::ERROR_INTERNAL_ERROR, "The operation failed. Maybe a duplicate username, or malformed expiry date?");
340 340
             exit(1);
@@ -345,25 +345,25 @@  discard block
 block discarded – undo
345 345
         }
346 346
         $adminApi->returnSuccess([web\lib\admin\API::AUXATTRIB_SB_USERNAME => $user, \web\lib\admin\API::AUXATTRIB_SB_USERID => $retval]);
347 347
         break;
348
-    case \web\lib\admin\API::ACTION_ENDUSER_DEACTIVATE:
349
-    // fall-through intended: both actions are very similar
350
-    case \web\lib\admin\API::ACTION_TOKEN_NEW:
351
-        $profile_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
352
-        if ($profile_id === FALSE) {
353
-            exit(1);
354
-        }
355
-        $evaluation = commonSbProfileChecks($fed, $profile_id);
356
-        if ($evaluation === FALSE) {
357
-            exit(1);
358
-        }
359
-        list($idp, $profile) = $evaluation;
360
-        $userId = $validator->integer($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERID));
361
-        if ($userId === FALSE) {
362
-            $adminApi->returnError(\web\lib\admin\API::ERROR_INVALID_PARAMETER, "User ID is not an integer.");
363
-            exit(1);
364
-        }
365
-        $additionalInfo = [];
366
-        switch ($inputDecoded['ACTION']) { // this is where the two differ
348
+        case \web\lib\admin\API::ACTION_ENDUSER_DEACTIVATE:
349
+        // fall-through intended: both actions are very similar
350
+        case \web\lib\admin\API::ACTION_TOKEN_NEW:
351
+            $profile_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
352
+            if ($profile_id === FALSE) {
353
+                exit(1);
354
+            }
355
+            $evaluation = commonSbProfileChecks($fed, $profile_id);
356
+            if ($evaluation === FALSE) {
357
+                exit(1);
358
+            }
359
+            list($idp, $profile) = $evaluation;
360
+            $userId = $validator->integer($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERID));
361
+            if ($userId === FALSE) {
362
+                $adminApi->returnError(\web\lib\admin\API::ERROR_INVALID_PARAMETER, "User ID is not an integer.");
363
+                exit(1);
364
+            }
365
+            $additionalInfo = [];
366
+            switch ($inputDecoded['ACTION']) { // this is where the two differ
367 367
             case \web\lib\admin\API::ACTION_ENDUSER_DEACTIVATE:
368 368
                 $result = $profile->deactivateUser($userId);
369 369
                 break;
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
                     }
397 397
                 }
398 398
                 break;
399
-        }
399
+            }
400 400
 
401 401
         if ($result !== TRUE) {
402 402
             $adminApi->returnError(\web\lib\admin\API::ERROR_INVALID_PARAMETER, "These parameters did not lead to an existing, active user.");
@@ -404,69 +404,69 @@  discard block
 block discarded – undo
404 404
         }
405 405
         $adminApi->returnSuccess($additionalInfo);
406 406
         break;
407
-    case \web\lib\admin\API::ACTION_ENDUSER_IDENTIFY:
408
-        $profile_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
409
-        if ($profile_id === FALSE) {
410
-            exit(1);
411
-        }
412
-        $evaluation = commonSbProfileChecks($fed, $profile_id);
413
-        if ($evaluation === FALSE) {
414
-            exit(1);
415
-        }
416
-        list($idp, $profile) = $evaluation;
417
-        $userId = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERID);
418
-        $userName = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERNAME);
419
-        $certSerial = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTSERIAL);
420
-		$certCN = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTCN);
421
-        if ($userId === FALSE && $userName === FALSE && $certSerial === FALSE && $certCN === FALSE) {
422
-            // we need at least one of those
423
-            $adminApi->returnError(\web\lib\admin\API::ERROR_MISSING_PARAMETER, "At least one of User ID, Username, certificate serial, or certificate CN is required.");
424
-            break;
425
-        }
426
-        if ($certSerial !== FALSE) { // we got a cert serial
427
-            $serial = explode(":", $certSerial);
428
-            $cert = new \core\SilverbulletCertificate($serial[1], $serial[0]);
407
+        case \web\lib\admin\API::ACTION_ENDUSER_IDENTIFY:
408
+            $profile_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
409
+            if ($profile_id === FALSE) {
410
+                exit(1);
429 411
             }
430
-        if ($certCN !== FALSE) { // we got a cert CN
431
-            $cert = new \core\SilverbulletCertificate($certCN);
432
-        }
433
-        if ($cert !== NULL) { // we found a cert; verify it and extract userId
434
-            if ($cert->status == \core\SilverbulletCertificate::CERTSTATUS_INVALID) {
435
-                return $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Certificate not found.");
412
+            $evaluation = commonSbProfileChecks($fed, $profile_id);
413
+            if ($evaluation === FALSE) {
414
+                exit(1);
436 415
             }
437
-            if ($cert->profileId != $profile->identifier) {
438
-                return $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Certificate does not belong to this profile.");
416
+            list($idp, $profile) = $evaluation;
417
+            $userId = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERID);
418
+            $userName = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERNAME);
419
+            $certSerial = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTSERIAL);
420
+		    $certCN = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTCN);
421
+            if ($userId === FALSE && $userName === FALSE && $certSerial === FALSE && $certCN === FALSE) {
422
+                // we need at least one of those
423
+                $adminApi->returnError(\web\lib\admin\API::ERROR_MISSING_PARAMETER, "At least one of User ID, Username, certificate serial, or certificate CN is required.");
424
+                break;
439 425
             }
440
-            $userId = $cert->userId;
441
-        }
442
-        if ($userId !== FALSE) {
443
-            $userList = $profile->getUserById($userId);
444
-        }
445
-        if ($userName !== FALSE) {
446
-            $userList = $profile->getUserByName($userName);
447
-        }
448
-        if (count($userList) === 1) {
449
-            foreach ($userList as $oneUserId => $oneUserName) {
450
-                return $adminApi->returnSuccess([web\lib\admin\API::AUXATTRIB_SB_USERNAME => $oneUserName, \web\lib\admin\API::AUXATTRIB_SB_USERID => $oneUserId]);
426
+            if ($certSerial !== FALSE) { // we got a cert serial
427
+                $serial = explode(":", $certSerial);
428
+                $cert = new \core\SilverbulletCertificate($serial[1], $serial[0]);
429
+                }
430
+            if ($certCN !== FALSE) { // we got a cert CN
431
+                $cert = new \core\SilverbulletCertificate($certCN);
451 432
             }
452
-        }
453
-        $adminApi->returnError(\web\lib\admin\API::ERROR_INVALID_PARAMETER, "No matching user found in this profile.");
454
-        break;
455
-    case \web\lib\admin\API::ACTION_ENDUSER_LIST:
456
-    // fall-through: those two are similar
457
-    case \web\lib\admin\API::ACTION_TOKEN_LIST:
458
-        $profile_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
459
-        if ($profile_id === FALSE) {
460
-            exit(1);
461
-        }
462
-        $evaluation = commonSbProfileChecks($fed, $profile_id);
463
-        if ($evaluation === FALSE) {
464
-            exit(1);
465
-        }
466
-        list($idp, $profile) = $evaluation;
467
-        $allUsers = $profile->listAllUsers();
468
-        // this is where they differ
469
-        switch ($inputDecoded['ACTION']) {
433
+            if ($cert !== NULL) { // we found a cert; verify it and extract userId
434
+                if ($cert->status == \core\SilverbulletCertificate::CERTSTATUS_INVALID) {
435
+                    return $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Certificate not found.");
436
+                }
437
+                if ($cert->profileId != $profile->identifier) {
438
+                    return $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Certificate does not belong to this profile.");
439
+                }
440
+                $userId = $cert->userId;
441
+            }
442
+            if ($userId !== FALSE) {
443
+                $userList = $profile->getUserById($userId);
444
+            }
445
+            if ($userName !== FALSE) {
446
+                $userList = $profile->getUserByName($userName);
447
+            }
448
+            if (count($userList) === 1) {
449
+                foreach ($userList as $oneUserId => $oneUserName) {
450
+                    return $adminApi->returnSuccess([web\lib\admin\API::AUXATTRIB_SB_USERNAME => $oneUserName, \web\lib\admin\API::AUXATTRIB_SB_USERID => $oneUserId]);
451
+                }
452
+            }
453
+            $adminApi->returnError(\web\lib\admin\API::ERROR_INVALID_PARAMETER, "No matching user found in this profile.");
454
+            break;
455
+        case \web\lib\admin\API::ACTION_ENDUSER_LIST:
456
+        // fall-through: those two are similar
457
+        case \web\lib\admin\API::ACTION_TOKEN_LIST:
458
+            $profile_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
459
+            if ($profile_id === FALSE) {
460
+                exit(1);
461
+            }
462
+            $evaluation = commonSbProfileChecks($fed, $profile_id);
463
+            if ($evaluation === FALSE) {
464
+                exit(1);
465
+            }
466
+            list($idp, $profile) = $evaluation;
467
+            $allUsers = $profile->listAllUsers();
468
+            // this is where they differ
469
+            switch ($inputDecoded['ACTION']) {
470 470
             case \web\lib\admin\API::ACTION_ENDUSER_LIST:
471 471
                 $adminApi->returnSuccess($allUsers);
472 472
                 break;
@@ -485,105 +485,105 @@  discard block
 block discarded – undo
485 485
                     $infoSet[$oneTokenObject->userId] = [\web\lib\admin\API::AUXATTRIB_TOKEN => $oneTokenObject->invitationTokenString, "STATUS" => $oneTokenObject->invitationTokenStatus];
486 486
                 }
487 487
                 $adminApi->returnSuccess($infoSet);
488
-        }
489
-        break;
490
-    case \web\lib\admin\API::ACTION_TOKEN_REVOKE:
491
-        $tokenRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_TOKEN);
492
-        if ($tokenRaw === FALSE) {
493
-            exit(1);
494
-        }
495
-        $token = new core\SilverbulletInvitation($tokenRaw);
496
-        if ($token->invitationTokenStatus !== core\SilverbulletInvitation::SB_TOKENSTATUS_VALID && $token->invitationTokenStatus !== core\SilverbulletInvitation::SB_TOKENSTATUS_PARTIALLY_REDEEMED) {
497
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "This is not a currently valid token.");
498
-            exit(1);
499
-        }
500
-        $token->revokeInvitation();
501
-        $adminApi->returnSuccess([]);
502
-        break;
503
-    case \web\lib\admin\API::ACTION_CERT_LIST:
504
-        $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
505
-        $user_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERID);
506
-        if ($prof_id === FALSE || !is_int($user_id)) {
507
-            exit(1);
508
-        }
509
-        $evaluation = commonSbProfileChecks($fed, $prof_id);
510
-        if ($evaluation === FALSE) {
511
-            exit(1);
512
-        }
513
-        list($idp, $profile) = $evaluation;
514
-        $invitations = $profile->userStatus($user_id);
515
-        // now pull out cert information from the object
516
-        $certs = [];
517
-        foreach ($invitations as $oneInvitation) {
518
-            $certs = array_merge($certs, $oneInvitation->associatedCertificates);
519
-        }
520
-        // extract relevant subset of information from cert objects
521
-        $certDetails = [];
522
-        foreach ($certs as $cert) {
523
-            $certDetails[$cert->ca_type . ":" . $cert->serial] = ["ISSUED" => $cert->issued, "EXPIRY" => $cert->expiry, "STATUS" => $cert->status, "DEVICE" => $cert->device, "CN" => $cert->username, "ANNOTATION" => $cert->annotation];
524
-        }
525
-        $adminApi->returnSuccess($certDetails);
526
-        break;
527
-    case \web\lib\admin\API::ACTION_CERT_REVOKE:
528
-        $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
529
-        if ($prof_id === FALSE) {
530
-            exit(1);
531
-        }
532
-        $evaluation = commonSbProfileChecks($fed, $prof_id);
533
-        if ($evaluation === FALSE) {
534
-            exit(1);
535
-        }
536
-        list($idp, $profile) = $evaluation;
537
-        // tear apart the serial
538
-        $serialRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTSERIAL);
539
-        if ($serialRaw === FALSE) {
540
-            exit(1);
541
-        }
542
-        $serial = explode(":", $serialRaw);
543
-        $cert = new \core\SilverbulletCertificate($serial[1], $serial[0]);
544
-        if ($cert->status == \core\SilverbulletCertificate::CERTSTATUS_INVALID) {
545
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial not found.");
546
-        }
547
-        if ($cert->profileId != $profile->identifier) {
548
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial does not belong to this profile.");
549
-        }
550
-        $cert->revokeCertificate();
551
-        $adminApi->returnSuccess([]);
488
+            }
552 489
         break;
553
-    case \web\lib\admin\API::ACTION_CERT_ANNOTATE:
554
-        $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
555
-        if ($prof_id === FALSE) {
556
-            exit(1);
557
-        }
558
-        $evaluation = commonSbProfileChecks($fed, $prof_id);
559
-        if ($evaluation === FALSE) {
560
-            exit(1);
561
-        }
562
-        list($idp, $profile) = $evaluation;
563
-        // tear apart the serial
564
-        $serialRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTSERIAL);
565
-        if ($serialRaw === FALSE) {
566
-            exit(1);
567
-        }
568
-        $serial = explode(":", $serialRaw);
569
-        $cert = new \core\SilverbulletCertificate($serial[1], $serial[0]);
570
-        if ($cert->status == \core\SilverbulletCertificate::CERTSTATUS_INVALID) {
571
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial not found.");
572
-        }
573
-        if ($cert->profileId != $profile->identifier) {
574
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial does not belong to this profile.");
575
-        }
576
-        $annotationRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTANNOTATION);
577
-        if ($annotationRaw === FALSE) {
578
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Unable to extract annotation.");
490
+        case \web\lib\admin\API::ACTION_TOKEN_REVOKE:
491
+            $tokenRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_TOKEN);
492
+            if ($tokenRaw === FALSE) {
493
+                exit(1);
494
+            }
495
+            $token = new core\SilverbulletInvitation($tokenRaw);
496
+            if ($token->invitationTokenStatus !== core\SilverbulletInvitation::SB_TOKENSTATUS_VALID && $token->invitationTokenStatus !== core\SilverbulletInvitation::SB_TOKENSTATUS_PARTIALLY_REDEEMED) {
497
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "This is not a currently valid token.");
498
+                exit(1);
499
+            }
500
+            $token->revokeInvitation();
501
+            $adminApi->returnSuccess([]);
579 502
             break;
580
-        }
581
-        $annotation = json_decode($annotationRaw, TRUE);
582
-        $cert->annotate($annotation);
583
-        $adminApi->returnSuccess([]);
503
+        case \web\lib\admin\API::ACTION_CERT_LIST:
504
+            $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
505
+            $user_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERID);
506
+            if ($prof_id === FALSE || !is_int($user_id)) {
507
+                exit(1);
508
+            }
509
+            $evaluation = commonSbProfileChecks($fed, $prof_id);
510
+            if ($evaluation === FALSE) {
511
+                exit(1);
512
+            }
513
+            list($idp, $profile) = $evaluation;
514
+            $invitations = $profile->userStatus($user_id);
515
+            // now pull out cert information from the object
516
+            $certs = [];
517
+            foreach ($invitations as $oneInvitation) {
518
+                $certs = array_merge($certs, $oneInvitation->associatedCertificates);
519
+            }
520
+            // extract relevant subset of information from cert objects
521
+            $certDetails = [];
522
+            foreach ($certs as $cert) {
523
+                $certDetails[$cert->ca_type . ":" . $cert->serial] = ["ISSUED" => $cert->issued, "EXPIRY" => $cert->expiry, "STATUS" => $cert->status, "DEVICE" => $cert->device, "CN" => $cert->username, "ANNOTATION" => $cert->annotation];
524
+            }
525
+            $adminApi->returnSuccess($certDetails);
526
+            break;
527
+        case \web\lib\admin\API::ACTION_CERT_REVOKE:
528
+            $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
529
+            if ($prof_id === FALSE) {
530
+                exit(1);
531
+            }
532
+            $evaluation = commonSbProfileChecks($fed, $prof_id);
533
+            if ($evaluation === FALSE) {
534
+                exit(1);
535
+            }
536
+            list($idp, $profile) = $evaluation;
537
+            // tear apart the serial
538
+            $serialRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTSERIAL);
539
+            if ($serialRaw === FALSE) {
540
+                exit(1);
541
+            }
542
+            $serial = explode(":", $serialRaw);
543
+            $cert = new \core\SilverbulletCertificate($serial[1], $serial[0]);
544
+            if ($cert->status == \core\SilverbulletCertificate::CERTSTATUS_INVALID) {
545
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial not found.");
546
+            }
547
+            if ($cert->profileId != $profile->identifier) {
548
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial does not belong to this profile.");
549
+            }
550
+            $cert->revokeCertificate();
551
+            $adminApi->returnSuccess([]);
552
+            break;
553
+        case \web\lib\admin\API::ACTION_CERT_ANNOTATE:
554
+            $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
555
+            if ($prof_id === FALSE) {
556
+                exit(1);
557
+            }
558
+            $evaluation = commonSbProfileChecks($fed, $prof_id);
559
+            if ($evaluation === FALSE) {
560
+                exit(1);
561
+            }
562
+            list($idp, $profile) = $evaluation;
563
+            // tear apart the serial
564
+            $serialRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTSERIAL);
565
+            if ($serialRaw === FALSE) {
566
+                exit(1);
567
+            }
568
+            $serial = explode(":", $serialRaw);
569
+            $cert = new \core\SilverbulletCertificate($serial[1], $serial[0]);
570
+            if ($cert->status == \core\SilverbulletCertificate::CERTSTATUS_INVALID) {
571
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial not found.");
572
+            }
573
+            if ($cert->profileId != $profile->identifier) {
574
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial does not belong to this profile.");
575
+            }
576
+            $annotationRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTANNOTATION);
577
+            if ($annotationRaw === FALSE) {
578
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Unable to extract annotation.");
579
+                break;
580
+            }
581
+            $annotation = json_decode($annotationRaw, TRUE);
582
+            $cert->annotate($annotation);
583
+            $adminApi->returnSuccess([]);
584 584
 
585
-        break;
585
+            break;
586 586
 
587
-    default:
588
-        $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_ACTION, "Not implemented yet.");
587
+        default:
588
+            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_ACTION, "Not implemented yet.");
589 589
 }
590 590
\ 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/User.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
         common\Entity::intoThePotatoes();
155 155
         $mail = \core\common\OutsideComm::mailHandle();
156 156
 // who to whom?
157
-        $mail->FromName = CONFIG['APPEARANCE']['productname'] . " Notification System";
158
-        $mail->addReplyTo(CONFIG['APPEARANCE']['support-contact']['developer-mail'], CONFIG['APPEARANCE']['productname'] . " " . _("Feedback"));
157
+        $mail->FromName = CONFIG['APPEARANCE']['productname']." Notification System";
158
+        $mail->addReplyTo(CONFIG['APPEARANCE']['support-contact']['developer-mail'], CONFIG['APPEARANCE']['productname']." "._("Feedback"));
159 159
         $mail->addAddress($mailaddr[0]["value"]);
160 160
 // what do we want to say?
161 161
         $mail->Subject = $subject;
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
                 }
219 219
                 $lookFor .= "$name";
220 220
             }
221
-            $finding = preg_match("/^(" . $lookFor . "):(.*)/", $oneRow->user_id, $matches);
221
+            $finding = preg_match("/^(".$lookFor."):(.*)/", $oneRow->user_id, $matches);
222 222
             if ($finding === 0 || $finding === FALSE) {
223 223
                 return FALSE;
224 224
             }
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
                         $matchedProviders[] = $idp;
237 237
                         $name = $idp;
238 238
                         if ($skipCurl == 0) {
239
-                            $url = CONFIG_DIAGNOSTICS['eduGainResolver']['url'] . "?action=get_entity_name&type=idp&e_id=$idp&lang=$lang";
239
+                            $url = CONFIG_DIAGNOSTICS['eduGainResolver']['url']."?action=get_entity_name&type=idp&e_id=$idp&lang=$lang";
240 240
                             $ch = curl_init($url);
241 241
                             if ($ch === FALSE) {
242 242
                                 $loggerInstance->debug(2, "Unable ask eduGAIN about IdP - CURL init failed!");
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
                             }
253 253
                             curl_close($ch);
254 254
                         }
255
-                        $listOfProviders[] = User::PROVIDER_STRINGS[$providerStrings[0]] . " - IdP: " . $name;
255
+                        $listOfProviders[] = User::PROVIDER_STRINGS[$providerStrings[0]]." - IdP: ".$name;
256 256
                     }
257 257
                     break;
258 258
                 case $providerStrings[1]:
Please login to merge, or discard this patch.
core/common/OutsideComm.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
             $loggerInstance->debug(4, "OutsideComm::mailAddressValidSecure: no MX.");
118 118
             return OutsideComm::MAILDOMAIN_NO_MX;
119 119
         }
120
-        $loggerInstance->debug(5, "Domain: $domain MX: " . print_r($mx, TRUE));
120
+        $loggerInstance->debug(5, "Domain: $domain MX: ".print_r($mx, TRUE));
121 121
         // create a pool of A and AAAA records for all the MXes
122 122
         $ipAddrs = [];
123 123
         foreach ($mx as $onemx) {
@@ -127,14 +127,14 @@  discard block
 block discarded – undo
127 127
                 $ipAddrs[] = $oneipv4['ip'];
128 128
             }
129 129
             foreach ($v6list as $oneipv6) {
130
-                $ipAddrs[] = "[" . $oneipv6['ipv6'] . "]";
130
+                $ipAddrs[] = "[".$oneipv6['ipv6']."]";
131 131
             }
132 132
         }
133 133
         if (count($ipAddrs) == 0) {
134 134
             $loggerInstance->debug(4, "OutsideComm::mailAddressValidSecure: no mailserver hosts.");
135 135
             return OutsideComm::MAILDOMAIN_NO_HOST;
136 136
         }
137
-        $loggerInstance->debug(5, "Domain: $domain Addrs: " . print_r($ipAddrs, TRUE));
137
+        $loggerInstance->debug(5, "Domain: $domain Addrs: ".print_r($ipAddrs, TRUE));
138 138
         // connect to all hosts. If all can't connect, return MAILDOMAIN_NO_CONNECT. 
139 139
         // If at least one does not support STARTTLS or one of the hosts doesn't connect
140 140
         // , return MAILDOMAIN_NO_STARTTLS (one which we can't connect to we also
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         switch (CONFIG_CONFASSISTANT['SMSSETTINGS']['provider']) {
187 187
             case 'Nexmo':
188 188
                 // taken from https://docs.nexmo.com/messaging/sms-api
189
-                $url = 'https://rest.nexmo.com/sms/json?' . http_build_query(
189
+                $url = 'https://rest.nexmo.com/sms/json?'.http_build_query(
190 190
                                 [
191 191
                                     'api_key' => CONFIG_CONFASSISTANT['SMSSETTINGS']['username'],
192 192
                                     'api_secret' => CONFIG_CONFASSISTANT['SMSSETTINGS']['password'],
@@ -211,14 +211,14 @@  discard block
 block discarded – undo
211 211
                     $loggerInstance->debug(2, 'Problem with SMS invitation: no message was sent!');
212 212
                     return OutsideComm::SMS_NOTSENT;
213 213
                 }
214
-                $loggerInstance->debug(2, 'Total of ' . $messageCount . ' messages were attempted to send.');
214
+                $loggerInstance->debug(2, 'Total of '.$messageCount.' messages were attempted to send.');
215 215
 
216 216
                 $totalFailures = 0;
217 217
                 foreach ($decoded_response['messages'] as $message) {
218 218
                     if ($message['status'] == 0) {
219
-                        $loggerInstance->debug(2, $message['message-id'] . ": Success");
219
+                        $loggerInstance->debug(2, $message['message-id'].": Success");
220 220
                     } else {
221
-                        $loggerInstance->debug(2, $message['message-id'] . ": Failed (failure code = " . $message['status'] . ")");
221
+                        $loggerInstance->debug(2, $message['message-id'].": Failed (failure code = ".$message['status'].")");
222 222
                         $totalFailures++;
223 223
                     }
224 224
                 }
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
             $proto = "https://";
271 271
         }
272 272
         // then, send out the mail
273
-        $message = _("Hello,") . "\n\n" . wordwrap($introTexts[$introtext] . " " . $validity, 72) . "\n\n";
273
+        $message = _("Hello,")."\n\n".wordwrap($introTexts[$introtext]." ".$validity, 72)."\n\n";
274 274
         // default means we don't have a Reply-To.
275 275
         $replyToMessage = wordwrap(_("manually. Please do not reply to this mail; this is a send-only address."));
276 276
 
@@ -278,8 +278,8 @@  discard block
 block discarded – undo
278 278
             // see if we are supposed to add a custom message
279 279
             $customtext = $federation->getAttributes('fed:custominvite');
280 280
             if (count($customtext) > 0) {
281
-                $message .= wordwrap(sprintf(_("Additional message from your %s administrator:"), Entity::$nomenclature_fed), 72) . "\n---------------------------------" .
282
-                        wordwrap($customtext[0]['value'], 72) . "\n---------------------------------\n\n";
281
+                $message .= wordwrap(sprintf(_("Additional message from your %s administrator:"), Entity::$nomenclature_fed), 72)."\n---------------------------------".
282
+                        wordwrap($customtext[0]['value'], 72)."\n---------------------------------\n\n";
283 283
             }
284 284
             // and add Reply-To already now
285 285
             foreach ($federation->listFederationAdmins() as $fedadmin_id) {
@@ -294,19 +294,19 @@  discard block
 block discarded – undo
294 294
             }
295 295
         }
296 296
 
297
-        $message .= wordwrap(sprintf(_("To enlist as an administrator for that %s, please click on the following link:"), Entity::$nomenclature_inst), 72) . "\n\n" .
298
-                $proto . $_SERVER['SERVER_NAME'] . CONFIG['PATHS']['cat_base_url'] . "admin/action_enrollment.php?token=$newtoken\n\n" .
299
-                wordwrap(sprintf(_("If clicking the link doesn't work, you can also go to the %s Administrator Interface at"), CONFIG['APPEARANCE']['productname']), 72) . "\n\n" .
300
-                $proto . $_SERVER['SERVER_NAME'] . CONFIG['PATHS']['cat_base_url'] . "admin/\n\n" .
301
-                _("and enter the invitation token") . "\n\n" .
302
-                $newtoken . "\n\n$replyToMessage\n\n" .
303
-                wordwrap(_("Do NOT forward the mail before the token has expired - or the recipients may be able to consume the token on your behalf!"), 72) . "\n\n" .
304
-                wordwrap(sprintf(_("We wish you a lot of fun with the %s."), CONFIG['APPEARANCE']['productname']), 72) . "\n\n" .
297
+        $message .= wordwrap(sprintf(_("To enlist as an administrator for that %s, please click on the following link:"), Entity::$nomenclature_inst), 72)."\n\n".
298
+                $proto.$_SERVER['SERVER_NAME'].CONFIG['PATHS']['cat_base_url']."admin/action_enrollment.php?token=$newtoken\n\n".
299
+                wordwrap(sprintf(_("If clicking the link doesn't work, you can also go to the %s Administrator Interface at"), CONFIG['APPEARANCE']['productname']), 72)."\n\n".
300
+                $proto.$_SERVER['SERVER_NAME'].CONFIG['PATHS']['cat_base_url']."admin/\n\n".
301
+                _("and enter the invitation token")."\n\n".
302
+                $newtoken."\n\n$replyToMessage\n\n".
303
+                wordwrap(_("Do NOT forward the mail before the token has expired - or the recipients may be able to consume the token on your behalf!"), 72)."\n\n".
304
+                wordwrap(sprintf(_("We wish you a lot of fun with the %s."), CONFIG['APPEARANCE']['productname']), 72)."\n\n".
305 305
                 sprintf(_("Sincerely,\n\nYour friendly folks from %s Operations"), CONFIG_CONFASSISTANT['CONSORTIUM']['display_name']);
306 306
 
307 307
 
308 308
 // who to whom?
309
-        $mail->FromName = CONFIG['APPEARANCE']['productname'] . " Invitation System";
309
+        $mail->FromName = CONFIG['APPEARANCE']['productname']." Invitation System";
310 310
 
311 311
         if (isset(CONFIG['APPEARANCE']['invitation-bcc-mail']) && CONFIG['APPEARANCE']['invitation-bcc-mail'] !== NULL) {
312 312
             $mail->addBCC(CONFIG['APPEARANCE']['invitation-bcc-mail']);
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
         $loggerInstance = new Logging();
357 357
         $ch = \curl_init($url);
358 358
         if ($ch === FALSE) {
359
-            $loggerInstance->debug(2,"Unable to POST JSON request: CURL init failed!");
359
+            $loggerInstance->debug(2, "Unable to POST JSON request: CURL init failed!");
360 360
             return json_decode(json_encode(FALSE), TRUE);
361 361
         }
362 362
         \curl_setopt_array($ch, array(
Please login to merge, or discard this patch.
web/lib/admin/UIElements.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
         $find = array_keys($displayNames, $input, TRUE);
129 129
 
130 130
         if (count($find) == 0) { // this is an error! throw an Exception
131
-            throw new \Exception("The translation of an option name was requested, but the option is not known to the system: " . htmlentities($input));
131
+            throw new \Exception("The translation of an option name was requested, but the option is not known to the system: ".htmlentities($input));
132 132
         }
133 133
         \core\common\Entity::outOfThePotatoes();
134 134
         return $find[0];
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 
150 150
         foreach ($optionlist as $option) {
151 151
             $type = $optioninfo->optionType($option['name']);
152
-            if (preg_match('/^' . $class . '/', $option['name']) && $option['level'] == "$level") {
152
+            if (preg_match('/^'.$class.'/', $option['name']) && $option['level'] == "$level") {
153 153
                 // all non-multilang attribs get this assignment ...
154 154
                 $language = "";
155 155
                 $content = $option['value'];
@@ -167,19 +167,19 @@  discard block
 block discarded – undo
167 167
                         $locationMarkers[] = $coords;
168 168
                         break;
169 169
                     case "file":
170
-                        $retval .= "<tr><td>" . $this->displayName($option['name']) . "</td><td>$language</td><td>";
170
+                        $retval .= "<tr><td>".$this->displayName($option['name'])."</td><td>$language</td><td>";
171 171
                         switch ($option['name']) {
172 172
                             case "general:logo_file":
173 173
                             case "fed:logo_file":
174
-                                $retval .= $this->previewImageinHTML('ROWID-' . $option['level'] . '-' . $option['row']);
174
+                                $retval .= $this->previewImageinHTML('ROWID-'.$option['level'].'-'.$option['row']);
175 175
                                 break;
176 176
                             case "eap:ca_file":
177 177
                             // fall-through intended: display both the same way
178 178
                             case "fed:minted_ca_file":
179
-                                $retval .= $this->previewCAinHTML('ROWID-' . $option['level'] . '-' . $option['row']);
179
+                                $retval .= $this->previewCAinHTML('ROWID-'.$option['level'].'-'.$option['row']);
180 180
                                 break;
181 181
                             case "support:info_file":
182
-                                $retval .= $this->previewInfoFileinHTML('ROWID-' . $option['level'] . '-' . $option['row']);
182
+                                $retval .= $this->previewInfoFileinHTML('ROWID-'.$option['level'].'-'.$option['row']);
183 183
                                 break;
184 184
                             default:
185 185
                         }
@@ -189,10 +189,10 @@  discard block
 block discarded – undo
189 189
                             // do not display the option at all; it gets auto-set by the ProfileSilverbullet constructor and doesn't have to be seen
190 190
                             break;
191 191
                         }
192
-                        $retval .= "<tr><td>" . $this->displayName($option['name']) . "</td><td>$language</td><td><strong>" . ($content == "on" ? _("on") : _("off") ) . "</strong></td></tr>";
192
+                        $retval .= "<tr><td>".$this->displayName($option['name'])."</td><td>$language</td><td><strong>".($content == "on" ? _("on") : _("off"))."</strong></td></tr>";
193 193
                         break;
194 194
                     default:
195
-                        $retval .= "<tr><td>" . $this->displayName($option['name']) . "</td><td>$language</td><td><strong>$content</strong></td></tr>";
195
+                        $retval .= "<tr><td>".$this->displayName($option['name'])."</td><td>$language</td><td><strong>$content</strong></td></tr>";
196 196
                 }
197 197
             }
198 198
         }
@@ -201,11 +201,11 @@  discard block
 block discarded – undo
201 201
             $locationCount = 0;
202 202
             foreach ($locationMarkers as $g) {
203 203
                 $locationCount++;
204
-                $marker .= '<marker name="' . $locationCount . '" lat="' . $g['lat'] . '" lng="' . $g['lon'] . '" />';
204
+                $marker .= '<marker name="'.$locationCount.'" lat="'.$g['lat'].'" lng="'.$g['lon'].'" />';
205 205
             }
206 206
             $marker .= '<\/markers>'; // some validator says this should be escaped
207 207
             $jMarker = json_encode($locationMarkers);
208
-            $retval .= '<tr><td><script>markers=\'' . $marker . '\'; jmarkers = \'' . $jMarker . '\';</script></td><td></td><td></td></tr>';
208
+            $retval .= '<tr><td><script>markers=\''.$marker.'\'; jmarkers = \''.$jMarker.'\';</script></td><td></td><td></td></tr>';
209 209
         }
210 210
         \core\common\Entity::outOfThePotatoes();
211 211
         return $retval;
@@ -221,11 +221,11 @@  discard block
 block discarded – undo
221 221
         \core\common\Entity::intoThePotatoes();
222 222
         $idpoptions = $myInst->getAttributes();
223 223
         $retval = "<div class='infobox'>
224
-        <h2>" . sprintf(_("General %s details"), $this->nomenclatureInst) . "</h2>
224
+        <h2>" . sprintf(_("General %s details"), $this->nomenclatureInst)."</h2>
225 225
         <table>
226 226
             <tr>
227 227
                 <td>
228
-                    " . _("Country:") . "
228
+                    " . _("Country:")."
229 229
                 </td>
230 230
                 <td>
231 231
                 </td>
@@ -235,16 +235,16 @@  discard block
 block discarded – undo
235 235
         $retval .= $myFed->name;
236 236
         $retval .= "</strong>
237 237
                 </td>
238
-            </tr>" . $this->infoblock($idpoptions, "general", "IdP") . "
238
+            </tr>" . $this->infoblock($idpoptions, "general", "IdP")."
239 239
         </table>
240 240
     </div>";
241 241
 
242 242
         $blocks = [["support", _("Global Helpdesk Details")], ["media", _("Media Properties")]];
243 243
         foreach ($blocks as $block) {
244 244
             $retval .= "<div class='infobox'>
245
-            <h2>" . $block[1] . "</h2>
245
+            <h2>" . $block[1]."</h2>
246 246
             <table>" .
247
-                    $this->infoblock($idpoptions, $block[0], "IdP") .
247
+                    $this->infoblock($idpoptions, $block[0], "IdP").
248 248
                     "</table>
249 249
         </div>";
250 250
         }
@@ -259,12 +259,12 @@  discard block
 block discarded – undo
259 259
      */
260 260
     private function displaySize(int $number) {
261 261
         if ($number > 1024 * 1024) {
262
-            return round($number / 1024 / 1024, 2) . " MiB";
262
+            return round($number / 1024 / 1024, 2)." MiB";
263 263
         }
264 264
         if ($number > 1024) {
265
-            return round($number / 1024, 2) . " KiB";
265
+            return round($number / 1024, 2)." KiB";
266 266
         }
267
-        return $number . " B";
267
+        return $number." B";
268 268
     }
269 269
 
270 270
     /**
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
         $this->checkROWIDpresence($cAReference);
337 337
         $rawResult = UIElements::getBlobFromDB($cAReference, FALSE);
338 338
         if (is_bool($rawResult)) { // we didn't actually get a CA!
339
-            $retval = "<div class='ca-summary'>" . _("There was an error while retrieving the certificate from the database!") . "</div>";
339
+            $retval = "<div class='ca-summary'>"._("There was an error while retrieving the certificate from the database!")."</div>";
340 340
             \core\common\Entity::outOfThePotatoes();
341 341
             return $retval;
342 342
         }
@@ -352,13 +352,13 @@  discard block
 block discarded – undo
352 352
 
353 353
         $details['name'] = preg_replace('/(.)\/(.)/', "$1<br/>$2", $details['name']);
354 354
         $details['name'] = preg_replace('/\//', "", $details['name']);
355
-        $certstatus = ( $details['root'] == 1 ? "R" : "I");
355
+        $certstatus = ($details['root'] == 1 ? "R" : "I");
356 356
         if ($details['ca'] == 0 && $details['root'] != 1) {
357
-            $retval = "<div class='ca-summary' style='background-color:red'><div style='position:absolute; right: 0px; width:20px; height:20px; background-color:maroon;  border-radius:10px; text-align: center;'><div style='padding-top:3px; font-weight:bold; color:#ffffff;'>S</div></div>" . _("This is a <strong>SERVER</strong> certificate!") . "<br/>" . $details['name'] . "</div>";
357
+            $retval = "<div class='ca-summary' style='background-color:red'><div style='position:absolute; right: 0px; width:20px; height:20px; background-color:maroon;  border-radius:10px; text-align: center;'><div style='padding-top:3px; font-weight:bold; color:#ffffff;'>S</div></div>"._("This is a <strong>SERVER</strong> certificate!")."<br/>".$details['name']."</div>";
358 358
             \core\common\Entity::outOfThePotatoes();
359 359
             return $retval;
360 360
         }
361
-        $retval = "<div class='ca-summary'                                ><div style='position:absolute; right: 0px; width:20px; height:20px; background-color:#0000ff; border-radius:10px; text-align: center;'><div style='padding-top:3px; font-weight:bold; color:#ffffff;'>$certstatus</div></div>" . $details['name'] . "</div>";
361
+        $retval = "<div class='ca-summary'                                ><div style='position:absolute; right: 0px; width:20px; height:20px; background-color:#0000ff; border-radius:10px; text-align: center;'><div style='padding-top:3px; font-weight:bold; color:#ffffff;'>$certstatus</div></div>".$details['name']."</div>";
362 362
         \core\common\Entity::outOfThePotatoes();
363 363
         return $retval;
364 364
     }
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
     public function previewImageinHTML($imageReference) {
373 373
         \core\common\Entity::intoThePotatoes();
374 374
         $this->checkROWIDpresence($imageReference);
375
-        $retval = "<img style='max-width:150px' src='inc/filepreview.php?id=" . $imageReference . "' alt='" . _("Preview of logo file") . "'/>";
375
+        $retval = "<img style='max-width:150px' src='inc/filepreview.php?id=".$imageReference."' alt='"._("Preview of logo file")."'/>";
376 376
         \core\common\Entity::outOfThePotatoes();
377 377
         return $retval;
378 378
     }
@@ -388,13 +388,13 @@  discard block
 block discarded – undo
388 388
         $this->checkROWIDpresence($fileReference);
389 389
         $fileBlob = UIElements::getBlobFromDB($fileReference, FALSE);
390 390
         if (is_bool($fileBlob)) { // we didn't actually get a file!
391
-            $retval = "<div class='ca-summary'>" . _("There was an error while retrieving the file from the database!") . "</div>";
391
+            $retval = "<div class='ca-summary'>"._("There was an error while retrieving the file from the database!")."</div>";
392 392
             \core\common\Entity::outOfThePotatoes();
393 393
             return $retval;
394 394
         }
395 395
         $decodedFileBlob = base64_decode($fileBlob);
396 396
         $fileinfo = new \finfo();
397
-        $retval = "<div class='ca-summary'>" . _("File exists") . " (" . $fileinfo->buffer($decodedFileBlob, FILEINFO_MIME_TYPE) . ", " . $this->displaySize(strlen($decodedFileBlob)) . ")<br/><a href='inc/filepreview.php?id=$fileReference'>" . _("Preview") . "</a></div>";
397
+        $retval = "<div class='ca-summary'>"._("File exists")." (".$fileinfo->buffer($decodedFileBlob, FILEINFO_MIME_TYPE).", ".$this->displaySize(strlen($decodedFileBlob)).")<br/><a href='inc/filepreview.php?id=$fileReference'>"._("Preview")."</a></div>";
398 398
         \core\common\Entity::outOfThePotatoes();
399 399
         return $retval;
400 400
     }
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
             $retval .= "<tr><td>";
423 423
         }
424 424
         $finalCaption = ($caption !== NULL ? $caption : $uiMessages[$level]['text']);
425
-        $retval .= "<img class='icon' src='" . $uiMessages[$level]['icon'] . "' alt='" . $finalCaption . "' title='" . $finalCaption . "'/>";
425
+        $retval .= "<img class='icon' src='".$uiMessages[$level]['icon']."' alt='".$finalCaption."' title='".$finalCaption."'/>";
426 426
         if (!$omittabletags) {
427 427
             $retval .= "</td><td>";
428 428
         }
@@ -502,8 +502,8 @@  discard block
 block discarded – undo
502 502
             return "";
503 503
         }
504 504
 
505
-        $loggerInstance->debug(4, "Consortium logo is at: " . ROOT . "/web/resources/images/consortium_logo_large.png");
506
-        $logogd = imagecreatefrompng(ROOT . "/web/resources/images/consortium_logo_large.png");
505
+        $loggerInstance->debug(4, "Consortium logo is at: ".ROOT."/web/resources/images/consortium_logo_large.png");
506
+        $logogd = imagecreatefrompng(ROOT."/web/resources/images/consortium_logo_large.png");
507 507
         if ($logogd === FALSE) { // consortium logo is bogus; don't do anything
508 508
             return "";
509 509
         }
@@ -518,8 +518,8 @@  discard block
 block discarded – undo
518 518
         $scale = sqrt($maxoccupy / $totallogopixels);
519 519
         $loggerInstance->debug(4, "Scaling info: $scale, $maxoccupy, $totallogopixels\n");
520 520
         // determine final pixel size - round to multitude of $symbolsize to match exact symbol boundary
521
-        $targetwidth = (int)($symbolsize * round($sizelogo[0] * $scale / $symbolsize));
522
-        $targetheight = (int)($symbolsize * round($sizelogo[1] * $scale / $symbolsize));
521
+        $targetwidth = (int) ($symbolsize * round($sizelogo[0] * $scale / $symbolsize));
522
+        $targetheight = (int) ($symbolsize * round($sizelogo[1] * $scale / $symbolsize));
523 523
         // paint white below the logo, in case it has transparencies (looks bad)
524 524
         // have one symbol in each direction extra white space
525 525
         $whiteimage = imagecreate($targetwidth + 2 * $symbolsize, $targetheight + 2 * $symbolsize);
@@ -528,8 +528,8 @@  discard block
 block discarded – undo
528 528
         }
529 529
         imagecolorallocate($whiteimage, 255, 255, 255);
530 530
         // also make sure the initial placement is a multitude of 12; otherwise "two half" symbols might be affected
531
-        $targetplacementx = (int)($symbolsize * round(($sizeinput[0] / 2 - ($targetwidth - $symbolsize) / 2) / $symbolsize));
532
-        $targetplacementy = (int)($symbolsize * round(($sizeinput[1] / 2 - ($targetheight - $symbolsize) / 2) / $symbolsize));
531
+        $targetplacementx = (int) ($symbolsize * round(($sizeinput[0] / 2 - ($targetwidth - $symbolsize) / 2) / $symbolsize));
532
+        $targetplacementy = (int) ($symbolsize * round(($sizeinput[1] / 2 - ($targetheight - $symbolsize) / 2) / $symbolsize));
533 533
         imagecopyresized($inputgd, $whiteimage, $targetplacementx - $symbolsize, $targetplacementy - $symbolsize, 0, 0, $targetwidth + 2 * $symbolsize, $targetheight + 2 * $symbolsize, $targetwidth + 2 * $symbolsize, $targetheight + 2 * $symbolsize);
534 534
         imagecopyresized($inputgd, $logogd, $targetplacementx, $targetplacementy, 0, 0, $targetwidth, $targetheight, $sizelogo[0], $sizelogo[1]);
535 535
         ob_start();
Please login to merge, or discard this patch.
web/diag/magicTelepath.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@
 block discarded – undo
19 19
  *          <base_url>/copyright.php after deploying the software
20 20
  */
21 21
 
22
-require_once dirname(dirname(__DIR__)) . "/config/_config.php";
22
+require_once dirname(dirname(__DIR__))."/config/_config.php";
23 23
 $realm = filter_input(INPUT_GET, 'realm', FILTER_SANITIZE_STRING);
24
-$visited = filter_input(INPUT_GET,'visited', FILTER_SANITIZE_STRING);
25
-$nro = filter_input(INPUT_GET,'nro', FILTER_SANITIZE_STRING);
24
+$visited = filter_input(INPUT_GET, 'visited', FILTER_SANITIZE_STRING);
25
+$nro = filter_input(INPUT_GET, 'nro', FILTER_SANITIZE_STRING);
26 26
 CAT_session_start();
27 27
 $languageObject = new core\common\Language();
28 28
 $languageObject->setTextDomain("diagonstics");
Please login to merge, or discard this patch.
web/diag/diag.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,8 +42,8 @@
 block discarded – undo
42 42
     $auth->authenticate();
43 43
 }
44 44
 if (isset($_SESSION['admin_diag_auth'])) {
45
-   $admin =  1;
46
-   unset($_SESSION['admin_diag_auth']);
45
+    $admin =  1;
46
+    unset($_SESSION['admin_diag_auth']);
47 47
 }
48 48
 $Gui = new \web\lib\user\Gui();
49 49
 $skinObject = new \web\lib\user\Skinjob($_REQUEST['skin'] ?? $_SESSION['skin'] ?? $fedskin[0] ?? CONFIG['APPEARANCE']['skins'][0]);
Please login to merge, or discard this 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
 $admin = filter_input(INPUT_GET, 'admin', FILTER_VALIDATE_INT);
24 24
 $auth = new \web\lib\admin\Authentication();
25 25
 $isauth = 0;
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
             unset($q_el[$idx]);
34 34
             $q_r = preg_replace("/\?.*/", "", $_SERVER['REQUEST_URI']);
35 35
             if (count($q_el)) {
36
-                $q_r = $q_r . '?' . implode('&', $q_el);
36
+                $q_r = $q_r.'?'.implode('&', $q_el);
37 37
             }
38 38
             $_SERVER['REQUEST_URI'] = $q_r;
39 39
         }
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
     $auth->authenticate();
43 43
 }
44 44
 if (isset($_SESSION['admin_diag_auth'])) {
45
-   $admin =  1;
45
+   $admin = 1;
46 46
    unset($_SESSION['admin_diag_auth']);
47 47
 }
48 48
 $Gui = new \web\lib\user\Gui();
49 49
 $skinObject = new \web\lib\user\Skinjob($_REQUEST['skin'] ?? $_SESSION['skin'] ?? $fedskin[0] ?? CONFIG['APPEARANCE']['skins'][0]);
50
-require "../skins/" . $skinObject->skin . "/diag/diag.php";
50
+require "../skins/".$skinObject->skin."/diag/diag.php";
51 51
 
52 52
 
Please login to merge, or discard this patch.