| @@ -109,7 +109,7 @@ discard block | ||
| 109 | 109 | $deployment->deactivate(); | 
| 110 | 110 | } | 
| 111 | 111 |              header("Location: overview_org.php?inst_id=" . $my_inst->identifier . '&' . urldecode(http_build_query($response)) . '#profilebox_' .  | 
| 112 | - $deployment->identifier); | |
| 112 | + $deployment->identifier); | |
| 113 | 113 | exit(0); | 
| 114 | 114 | case web\lib\common\FormElements::BUTTON_REMOVESP: | 
| 115 | 115 | $deployment->remove(); | 
| @@ -140,9 +140,9 @@ discard block | ||
| 140 | 140 | // valid signature | 
| 141 | 141 | $data = openssl_x509_parse($deployment->radsec_cert); | 
| 142 | 142 | $certdata = array( | 
| 143 | - $data['serialNumberHex'], | |
| 144 | -                              date_create_from_format('ymdGis', substr($data['validTo'], 0, -1))->format('YmdHis') | |
| 145 | - ); | |
| 143 | + $data['serialNumberHex'], | |
| 144 | +                                date_create_from_format('ymdGis', substr($data['validTo'], 0, -1))->format('YmdHis') | |
| 145 | + ); | |
| 146 | 146 |                      $torevoke = implode('#', $certdata); | 
| 147 | 147 | $response = $deployment->setRADIUSconfig(0, 0, $torevoke); | 
| 148 | 148 | $deployment->tlsfromcsr($csr); | 
| @@ -194,7 +194,7 @@ discard block | ||
| 194 | 194 | } | 
| 195 | 195 |              header("Location: overview_org.php?inst_id=" . $my_inst->identifier . '&' . urldecode(http_build_query($response)) . '#profilebox_' . $deployment->identifier); | 
| 196 | 196 | exit(0); | 
| 197 | - default: | |
| 197 | + default: | |
| 198 | 198 |                  throw new Exception("Unknown button action requested!"); | 
| 199 | 199 | } | 
| 200 | 200 | } | 
| @@ -27,7 +27,7 @@ discard block | ||
| 27 | 27 | */ | 
| 28 | 28 | ?> | 
| 29 | 29 | <?php | 
| 30 | -require_once dirname(dirname(dirname(__FILE__))) . "/config/_config.php"; | |
| 30 | +require_once dirname(dirname(dirname(__FILE__)))."/config/_config.php"; | |
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | $deco = new \web\lib\admin\PageDecoration(); | 
| @@ -41,10 +41,10 @@ discard block | ||
| 41 | 41 |              ( $_POST['consortium'] == "OpenRoaming" && count($myfed->getAttributes("fed:openroaming")) > 0 ) | 
| 42 | 42 | ) | 
| 43 | 43 |      ) {*/ | 
| 44 | - if (isset($_POST['consortium']) && $_POST['consortium'] == "eduroam") | |
| 44 | + if (isset($_POST['consortium']) && $_POST['consortium'] == "eduroam") | |
| 45 | 45 |      { | 
| 46 | 46 | $deployment = $my_inst->newDeployment(\core\AbstractDeployment::DEPLOYMENTTYPE_MANAGED, $_POST['consortium']); | 
| 47 | -        header("Location: overview_org.php?inst_id=" . $my_inst->identifier . '#profilebox_' . $deployment->identifier); | |
| 47 | +        header("Location: overview_org.php?inst_id=".$my_inst->identifier.'#profilebox_'.$deployment->identifier); | |
| 48 | 48 | exit(0); | 
| 49 | 49 |      } else { | 
| 50 | 50 |          throw new Exception("Desired consortium for Managed SP needs to be specified, and allowed!"); | 
| @@ -101,19 +101,19 @@ discard block | ||
| 101 | 101 |              if (isset($_POST['agreement']) && $_POST['agreement'] == "true") { | 
| 102 | 102 |                  $deployment->addAttribute("hiddenmanagedsp:tou_accepted", NULL, 1); | 
| 103 | 103 | } | 
| 104 | -            header("Location: overview_org.php?inst_id=" . $my_inst->identifier . '#profilebox_' . $deployment->identifier); | |
| 104 | +            header("Location: overview_org.php?inst_id=".$my_inst->identifier.'#profilebox_'.$deployment->identifier); | |
| 105 | 105 | exit(0); | 
| 106 | 106 | case web\lib\common\FormElements::BUTTON_DELETE: | 
| 107 | 107 | $response = $deployment->setRADIUSconfig(); | 
| 108 | 108 |              if (in_array('OK', $response)) { | 
| 109 | 109 | $deployment->deactivate(); | 
| 110 | 110 | } | 
| 111 | -            header("Location: overview_org.php?inst_id=" . $my_inst->identifier . '&' . urldecode(http_build_query($response)) . '#profilebox_' .  | |
| 111 | +            header("Location: overview_org.php?inst_id=".$my_inst->identifier.'&'.urldecode(http_build_query($response)).'#profilebox_'.  | |
| 112 | 112 | $deployment->identifier); | 
| 113 | 113 | exit(0); | 
| 114 | 114 | case web\lib\common\FormElements::BUTTON_REMOVESP: | 
| 115 | 115 | $deployment->remove(); | 
| 116 | -            header("Location: overview_org.php?inst_id=" . $my_inst->identifier); | |
| 116 | +            header("Location: overview_org.php?inst_id=".$my_inst->identifier); | |
| 117 | 117 | exit(0); | 
| 118 | 118 | case web\lib\common\FormElements::BUTTON_RENEWTLS: | 
| 119 | 119 | $data = openssl_x509_parse($deployment->radsec_cert); | 
| @@ -124,14 +124,14 @@ discard block | ||
| 124 | 124 |              $torevoke = implode('#', $certdata); | 
| 125 | 125 | $response = $deployment->setRADIUSconfig(0, 0, $torevoke); | 
| 126 | 126 | $deployment->renewtls(); | 
| 127 | -            header("Location: overview_org.php?inst_id=" . $my_inst->identifier . '#profilebox_' . $deployment->identifier); | |
| 127 | +            header("Location: overview_org.php?inst_id=".$my_inst->identifier.'#profilebox_'.$deployment->identifier); | |
| 128 | 128 | exit(0); | 
| 129 | 129 | case web\lib\common\FormElements::BUTTON_USECSR: | 
| 130 | 130 |              if (isset($_FILES['upload']) && $_FILES['upload']['size'] > 0) { | 
| 131 | 131 | $csrpem = file_get_contents($_FILES['upload']['tmp_name']); | 
| 132 | 132 |                  if ($csrpem === FALSE) { | 
| 133 | 133 | // seems we can't work with this file for some reason. Ignore. | 
| 134 | -                    header("Location: overview_org.php?inst_id=" . $my_inst->identifier . '&errormsg=NOCSR_' . $deployment->identifier . '#profilebox_' . $deployment->identifier); | |
| 134 | +                    header("Location: overview_org.php?inst_id=".$my_inst->identifier.'&errormsg=NOCSR_'.$deployment->identifier.'#profilebox_'.$deployment->identifier); | |
| 135 | 135 | exit(0); | 
| 136 | 136 | } | 
| 137 | 137 | $csr = new \phpseclib3\File\X509(); | 
| @@ -146,10 +146,10 @@ discard block | ||
| 146 | 146 |                      $torevoke = implode('#', $certdata); | 
| 147 | 147 | $response = $deployment->setRADIUSconfig(0, 0, $torevoke); | 
| 148 | 148 | $deployment->tlsfromcsr($csr); | 
| 149 | -                    header("Location: overview_org.php?inst_id=" . $my_inst->identifier . '#profilebox_' . $deployment->identifier); | |
| 149 | +                    header("Location: overview_org.php?inst_id=".$my_inst->identifier.'#profilebox_'.$deployment->identifier); | |
| 150 | 150 | exit(0); | 
| 151 | 151 |                  } else { | 
| 152 | -                    header("Location: overview_org.php?inst_id=" . $my_inst->identifier . '&errormsg=WRONGCSR_' . $deployment->identifier . '#profilebox_' . $deployment->identifier); | |
| 152 | +                    header("Location: overview_org.php?inst_id=".$my_inst->identifier.'&errormsg=WRONGCSR_'.$deployment->identifier.'#profilebox_'.$deployment->identifier); | |
| 153 | 153 | exit(0); | 
| 154 | 154 | } | 
| 155 | 155 | } | 
| @@ -159,7 +159,7 @@ discard block | ||
| 159 | 159 |                  if (in_array('OK', $response)) { | 
| 160 | 160 | $deployment->activate(); | 
| 161 | 161 | } | 
| 162 | -                header("Location: overview_org.php?inst_id=" . $my_inst->identifier . '&' . urldecode(http_build_query($response)) . '#profilebox_' . $deployment->identifier); | |
| 162 | +                header("Location: overview_org.php?inst_id=".$my_inst->identifier.'&'.urldecode(http_build_query($response)).'#profilebox_'.$deployment->identifier); | |
| 163 | 163 | exit(0); | 
| 164 | 164 |              } else { | 
| 165 | 165 |                  throw new Exception("Activate button pushed without acknowledged ToUs!"); | 
| @@ -192,7 +192,7 @@ discard block | ||
| 192 | 192 |              } else { | 
| 193 | 193 | $response = ['NOOP', 'NOOP']; | 
| 194 | 194 | } | 
| 195 | -            header("Location: overview_org.php?inst_id=" . $my_inst->identifier . '&' . urldecode(http_build_query($response)) . '#profilebox_' . $deployment->identifier); | |
| 195 | +            header("Location: overview_org.php?inst_id=".$my_inst->identifier.'&'.urldecode(http_build_query($response)).'#profilebox_'.$deployment->identifier); | |
| 196 | 196 | exit(0); | 
| 197 | 197 | default: | 
| 198 | 198 |                  throw new Exception("Unknown button action requested!"); | 
| @@ -201,10 +201,10 @@ discard block | ||
| 201 | 201 |  if (isset($_POST['command'])) { | 
| 202 | 202 |      switch ($_POST['command']) { | 
| 203 | 203 | case web\lib\common\FormElements::BUTTON_CLOSE: | 
| 204 | -            header("Location: overview_org.php?inst_id=" . $my_inst->identifier) . '#profilebox_' . $deployment->identifier; | |
| 204 | +            header("Location: overview_org.php?inst_id=".$my_inst->identifier).'#profilebox_'.$deployment->identifier; | |
| 205 | 205 | exit(0); | 
| 206 | 206 | default: | 
| 207 | -            header("Location: overview_org.php?inst_id=" . $my_inst->identifier . '#profilebox_' . $deployment->identifier); | |
| 207 | +            header("Location: overview_org.php?inst_id=".$my_inst->identifier.'#profilebox_'.$deployment->identifier); | |
| 208 | 208 | exit(0); | 
| 209 | 209 | } | 
| 210 | 210 | } | 
| @@ -230,7 +230,7 @@ discard block | ||
| 230 | 230 | echo $uiElements->instLevelInfoBoxes($my_inst); | 
| 231 | 231 | $deploymentOptions = $deployment->getAttributes(); | 
| 232 | 232 | echo "<form enctype='multipart/form-data' action='edit_hotspot.php?inst_id=$my_inst->identifier&deployment_id=$deployment->identifier' method='post' accept-charset='UTF-8'> | 
| 233 | - <input type='hidden' name='MAX_FILE_SIZE' value='" . \config\Master::MAX_UPLOAD_SIZE . "'>"; | |
| 233 | + <input type='hidden' name='MAX_FILE_SIZE' value='".\config\Master::MAX_UPLOAD_SIZE."'>"; | |
| 234 | 234 | $optionDisplay = new \web\lib\admin\OptionDisplay($deploymentOptions, \core\Options::LEVEL_PROFILE); | 
| 235 | 235 | ?> | 
| 236 | 236 | <fieldset class='option_container' id='managedsp_override'> | 
| @@ -264,7 +264,7 @@ discard block | ||
| 264 | 264 | <!-- input for VLAN identifier for guests--> | 
| 265 | 265 | <td> | 
| 266 | 266 | <span id='guest_vlan_label'> | 
| 267 | -                        <?php echo sprintf(_("VLAN tag for guests:"), ($guest_vlan === NULL ? "" : " " . _("(unset with '0')"))); ?> | |
| 267 | +                        <?php echo sprintf(_("VLAN tag for guests:"), ($guest_vlan === NULL ? "" : " "._("(unset with '0')"))); ?> | |
| 268 | 268 | </span> | 
| 269 | 269 | </td> | 
| 270 | 270 | <td> | 
| @@ -280,7 +280,7 @@ discard block | ||
| 280 | 280 | <!-- input for VLAN identifier for home users--> | 
| 281 | 281 | <td> | 
| 282 | 282 | <span id='vlan_label'> | 
| 283 | -                        <?php echo sprintf(_("VLAN tag for own users%s:"), ($vlan === NULL ? "" : " " . _("(unset with '0')"))); ?> | |
| 283 | +                        <?php echo sprintf(_("VLAN tag for own users%s:"), ($vlan === NULL ? "" : " "._("(unset with '0')"))); ?> | |
| 284 | 284 | </span> | 
| 285 | 285 | </td> | 
| 286 | 286 | <td> | 
| @@ -300,7 +300,7 @@ discard block | ||
| 300 | 300 | </fieldset> | 
| 301 | 301 | |
| 302 | 302 | <?php | 
| 303 | -    echo "<p><button type='submit' name='submitbutton' class='deploymentopts' value='" . web\lib\common\FormElements::BUTTON_SAVE . "'>" . _("Save data") . "</button><button type='button' class='delete' name='abortbutton' value='abort' onclick='javascript:window.location = \"overview_org.php?inst_id=$my_inst->identifier\"'>" . _("Discard changes") . "</button></p></form>"; | |
| 303 | +    echo "<p><button type='submit' name='submitbutton' class='deploymentopts' value='".web\lib\common\FormElements::BUTTON_SAVE."'>"._("Save data")."</button><button type='button' class='delete' name='abortbutton' value='abort' onclick='javascript:window.location = \"overview_org.php?inst_id=$my_inst->identifier\"'>"._("Discard changes")."</button></p></form>"; | |
| 304 | 304 | echo $deco->footer(); | 
| 305 | 305 | ?> | 
| 306 | 306 | <script> | 
| @@ -11,33 +11,33 @@ | ||
| 11 | 11 | isset($_REQUEST['instid']) && isset($_REQUEST['deploymentid']) && | 
| 12 | 12 | (isset($_REQUEST['port']) && isset($_REQUEST['secret']) && isset($_REQUEST['pskkey']) && isset($_REQUEST['country']) || | 
| 13 | 13 |       isset($_REQUEST['torevoke']))) { | 
| 14 | -  if (isset($_REQUEST['remove'])) { | |
| 14 | +    if (isset($_REQUEST['remove'])) { | |
| 15 | 15 | $remove = 1; | 
| 16 | -  } else { | |
| 16 | +    } else { | |
| 17 | 17 |      if (isset($_REQUEST['operatorname'])) { | 
| 18 | - $opn = trim($_REQUEST['operatorname']); | |
| 18 | + $opn = trim($_REQUEST['operatorname']); | |
| 19 | 19 | } | 
| 20 | 20 | if (isset($_REQUEST['vlan']) && isset($_REQUEST['realmforvlan']) && | 
| 21 | 21 |          is_array($_REQUEST['realmforvlan'])) { | 
| 22 | -      $vlans = $_REQUEST['vlan'] . '#' . implode('#', $_REQUEST['realmforvlan']); | |
| 22 | +        $vlans = $_REQUEST['vlan'] . '#' . implode('#', $_REQUEST['realmforvlan']); | |
| 23 | 23 | } | 
| 24 | 24 |      if (isset($_REQUEST['guest_vlan'])) { | 
| 25 | - $guest_vlan = $_REQUEST['guest_vlan']; | |
| 25 | + $guest_vlan = $_REQUEST['guest_vlan']; | |
| 26 | 26 | } | 
| 27 | - } | |
| 28 | -  if (isset($_REQUEST['torevoke'])) { | |
| 29 | -	  $el = explode('#', $_REQUEST['torevoke']); | |
| 30 | -	  $res = cat_socket(implode(':', array($_REQUEST['instid'], $_REQUEST['deploymentid'], $el[0], $el[1]))); | |
| 31 | -  } else { | |
| 32 | - # arguments 5-7 are Base64 encoded | |
| 33 | -  	$res = cat_socket(implode(':', array($_REQUEST['country'], | |
| 34 | - $_REQUEST['instid'], $_REQUEST['deploymentid'], | |
| 35 | - $_REQUEST['port'], | |
| 36 | - base64_encode($_REQUEST['secret']), | |
| 37 | - base64_encode($opn), | |
| 38 | - base64_encode($vlans), base64_encode($_REQUEST['pskkey']), $guest_vlan, $remove))); | |
| 39 | - } | |
| 40 | - echo $res; | |
| 27 | + } | |
| 28 | +    if (isset($_REQUEST['torevoke'])) { | |
| 29 | +        $el = explode('#', $_REQUEST['torevoke']); | |
| 30 | +        $res = cat_socket(implode(':', array($_REQUEST['instid'], $_REQUEST['deploymentid'], $el[0], $el[1]))); | |
| 31 | +    } else { | |
| 32 | + # arguments 5-7 are Base64 encoded | |
| 33 | +        $res = cat_socket(implode(':', array($_REQUEST['country'], | |
| 34 | + $_REQUEST['instid'], $_REQUEST['deploymentid'], | |
| 35 | + $_REQUEST['port'], | |
| 36 | + base64_encode($_REQUEST['secret']), | |
| 37 | + base64_encode($opn), | |
| 38 | + base64_encode($vlans), base64_encode($_REQUEST['pskkey']), $guest_vlan, $remove))); | |
| 39 | + } | |
| 40 | + echo $res; | |
| 41 | 41 |  } else { | 
| 42 | - echo "FAILURE"; | |
| 42 | + echo "FAILURE"; | |
| 43 | 43 | } | 
| @@ -19,7 +19,7 @@ | ||
| 19 | 19 | } | 
| 20 | 20 | if (isset($_REQUEST['vlan']) && isset($_REQUEST['realmforvlan']) && | 
| 21 | 21 |          is_array($_REQUEST['realmforvlan'])) { | 
| 22 | -      $vlans = $_REQUEST['vlan'] . '#' . implode('#', $_REQUEST['realmforvlan']); | |
| 22 | +      $vlans = $_REQUEST['vlan'].'#'.implode('#', $_REQUEST['realmforvlan']); | |
| 23 | 23 | } | 
| 24 | 24 |      if (isset($_REQUEST['guest_vlan'])) { | 
| 25 | 25 | $guest_vlan = $_REQUEST['guest_vlan']; | 
| @@ -322,7 +322,7 @@ discard block | ||
| 322 | 322 | $serverCandidates[IdPlist::geoDistance($adminLocation, ['lat' => $iterator->location_lat, 'lon' => $iterator->location_lon])] = $iterator->server_id; | 
| 323 | 323 | } | 
| 324 | 324 |              if ($clients > $maxSupportedClients * 0.9) { | 
| 325 | -                $this->loggerInstance->debug(1, "A RADIUS server for Managed SP (" . $iterator->server_id . ") is serving at more than 90% capacity!"); | |
| 325 | +                $this->loggerInstance->debug(1, "A RADIUS server for Managed SP (".$iterator->server_id.") is serving at more than 90% capacity!"); | |
| 326 | 326 | } | 
| 327 | 327 | } | 
| 328 | 328 |          if (count($serverCandidates) == 0 && $federation != "DEFAULT") { | 
| @@ -344,7 +344,7 @@ discard block | ||
| 344 | 344 | * | 
| 345 | 345 | * @throws Exception | 
| 346 | 346 | */ | 
| 347 | -    private function setTLSSerialNumber($max=PHP_INT_MAX) { | |
| 347 | +    private function setTLSSerialNumber($max = PHP_INT_MAX) { | |
| 348 | 348 | $nonDupSerialFound = FALSE; | 
| 349 | 349 |          do { | 
| 350 | 350 | $serial = random_int(1000000000, $max); | 
| @@ -364,7 +364,7 @@ discard block | ||
| 364 | 364 | */ | 
| 365 | 365 | private function createTLScredentials() | 
| 366 | 366 |      { | 
| 367 | - $clientName = 'SP' . $this->identifier . '-' . $this->institution; | |
| 367 | + $clientName = 'SP'.$this->identifier.'-'.$this->institution; | |
| 368 | 368 | $dn = array( | 
| 369 | 369 | "organizationName" => "eduroam", | 
| 370 | 370 | "organizationalUnitName" => "eduroam Managed SP", | 
| @@ -378,14 +378,14 @@ discard block | ||
| 378 | 378 | openssl_pkey_export($privkey, $this->radsec_priv); | 
| 379 | 379 | // Generate a certificate signing request | 
| 380 | 380 | $csr = openssl_csr_new($dn, $privkey, | 
| 381 | -                               array('digest_alg' => 'sha256', 'config' => ROOT . "/config/ManagedSPCerts/openssl.cnf")); | |
| 381 | +                               array('digest_alg' => 'sha256', 'config' => ROOT."/config/ManagedSPCerts/openssl.cnf")); | |
| 382 | 382 | // get CA certificate and private key | 
| 383 | - $caprivkey = array(file_get_contents(ROOT . "/config/ManagedSPCerts/eduroamSP-CA.key"), | |
| 383 | + $caprivkey = array(file_get_contents(ROOT."/config/ManagedSPCerts/eduroamSP-CA.key"), | |
| 384 | 384 | \config\Master::MANAGEDSP['capass']); | 
| 385 | - $cacert = file_get_contents(ROOT . "/config/ManagedSPCerts/eduroamSP-CA.pem"); | |
| 385 | + $cacert = file_get_contents(ROOT."/config/ManagedSPCerts/eduroamSP-CA.pem"); | |
| 386 | 386 | $this->setTLSSerialNumber(); | 
| 387 | 387 | $clientcert = openssl_csr_sign($csr, $cacert, $caprivkey, \config\Master::MANAGEDSP['daystoexpiry'], | 
| 388 | -                          array('digest_alg'=>'sha512', 'config' => ROOT . "/config/ManagedSPCerts/openssl.cnf"), $this->radsec_cert_serial_no); | |
| 388 | +                          array('digest_alg'=>'sha512', 'config' => ROOT."/config/ManagedSPCerts/openssl.cnf"), $this->radsec_cert_serial_no); | |
| 389 | 389 | openssl_x509_export($clientcert, $this->radsec_cert); | 
| 390 | 390 | } | 
| 391 | 391 | /** | 
| @@ -410,8 +410,8 @@ discard block | ||
| 410 | 410 | $conditional1 = "AND activity_time > DATE_SUB(NOW(), INTERVAL $backlog SECOND )"; | 
| 411 | 411 | $conditional2 = "DESC"; | 
| 412 | 412 | } | 
| 413 | - $client = 'SP' . $this->identifier . '-' . $this->institution; | |
| 414 | -        $stats = $this->databaseHandle->exec("SELECT activity_time, realm, mac, cui, result, ap_id, prot, outer_user FROM activity WHERE owner = ? $conditional1 ORDER BY activity_time $conditional2", "s", $client ); | |
| 413 | + $client = 'SP'.$this->identifier.'-'.$this->institution; | |
| 414 | +        $stats = $this->databaseHandle->exec("SELECT activity_time, realm, mac, cui, result, ap_id, prot, outer_user FROM activity WHERE owner = ? $conditional1 ORDER BY activity_time $conditional2", "s", $client); | |
| 415 | 415 | |
| 416 | 416 | return mysqli_fetch_all($stats, \MYSQLI_ASSOC); | 
| 417 | 417 | } | 
| @@ -529,11 +529,11 @@ discard block | ||
| 529 | 529 | $dn['rdnSequence'][1][0]['value']['utf8String'] = 'eduroam Managed SP'; | 
| 530 | 530 | $dn['rdnSequence'][2] = array(); | 
| 531 | 531 |         $dn['rdnSequence'][2][] = array('type' => 'id-at-commonName', 'value' => array()); | 
| 532 | - $dn['rdnSequence'][2][0]['value']['utf8String'] = 'SP' . $this->identifier . "-" . $this->institution; | |
| 532 | + $dn['rdnSequence'][2][0]['value']['utf8String'] = 'SP'.$this->identifier."-".$this->institution; | |
| 533 | 533 | $csr->setDN($dn); | 
| 534 | - $pemcakey = file_get_contents(ROOT . "/config/ManagedSPCerts/eduroamSP-CA.key"); | |
| 535 | - $cakey = \phpseclib3\Crypt\PublicKeyLoader::loadPrivateKey($pemcakey, \config\Master::MANAGEDSP['capass'] ); | |
| 536 | - $pemca = file_get_contents(ROOT . "/config/ManagedSPCerts/eduroamSP-CA.pem"); | |
| 534 | + $pemcakey = file_get_contents(ROOT."/config/ManagedSPCerts/eduroamSP-CA.key"); | |
| 535 | + $cakey = \phpseclib3\Crypt\PublicKeyLoader::loadPrivateKey($pemcakey, \config\Master::MANAGEDSP['capass']); | |
| 536 | + $pemca = file_get_contents(ROOT."/config/ManagedSPCerts/eduroamSP-CA.pem"); | |
| 537 | 537 | $ca = new \phpseclib3\File\X509(); | 
| 538 | 538 | $ca->loadX509($pemca); | 
| 539 | 539 | $ca->setPrivateKey($cakey); | 
| @@ -542,7 +542,7 @@ discard block | ||
| 542 | 542 |         $csr->setExtension('id-ce-keyUsage', ['digitalSignature', 'nonRepudiation', 'keyEncipherment']); | 
| 543 | 543 |         $csr->setExtension('id-ce-extKeyUsage', ['id-kp-clientAuth']); | 
| 544 | 544 |         $csr->setExtension('id-ce-basicConstraints', ['cA' => false], false); | 
| 545 | -       $x509->setEndDate('+' . \config\Master::MANAGEDSP['daystoexpiry'] . ' days'); | |
| 545 | +       $x509->setEndDate('+'.\config\Master::MANAGEDSP['daystoexpiry'].' days'); | |
| 546 | 546 | $this->setTLSSerialNumber(999999999999999999); | 
| 547 | 547 | $x509->setSerialNumber($this->radsec_cert_serial_no, 10); | 
| 548 | 548 | $cert = $x509->loadX509($x509->saveX509($x509->sign($ca, $csr))); | 
| @@ -584,7 +584,7 @@ discard block | ||
| 584 | 584 |      { | 
| 585 | 585 |          $customAttrib = $this->getAttributes("managedsp:operatorname"); | 
| 586 | 586 |          if (count($customAttrib) == 0) { | 
| 587 | - return "1sp." . $this->identifier . "-" . $this->institution . \config\ConfAssistant::SILVERBULLET['realm_suffix']; | |
| 587 | + return "1sp.".$this->identifier."-".$this->institution.\config\ConfAssistant::SILVERBULLET['realm_suffix']; | |
| 588 | 588 | } | 
| 589 | 589 | return $customAttrib[0]["value"]; | 
| 590 | 590 | } | 
| @@ -599,14 +599,14 @@ discard block | ||
| 599 | 599 | private function sendToRADIUS(int $idx, $post) | 
| 600 | 600 |      { | 
| 601 | 601 | $hostname = "radius_hostname_$idx"; | 
| 602 | -        $ch = curl_init("http://" . $this->$hostname . ':' . \config\Master::MANAGEDSP['radiusconfigport']); | |
| 602 | +        $ch = curl_init("http://".$this->$hostname.':'.\config\Master::MANAGEDSP['radiusconfigport']); | |
| 603 | 603 |          if ($ch === FALSE) { | 
| 604 | 604 | $res = 'FAILURE'; | 
| 605 | 605 |          } else { | 
| 606 | 606 | curl_setopt($ch, CURLOPT_USERAGENT, "CAT-ManagedSP"); | 
| 607 | 607 | curl_setopt($ch, CURLOPT_POST, 1); | 
| 608 | 608 | curl_setopt($ch, CURLOPT_POSTFIELDS, $post); | 
| 609 | - $this->loggerInstance->debug(1, "Posting to http://" . $this->$hostname . ':' . \config\Master::MANAGEDSP['radiusconfigport'] . "/$post\n"); | |
| 609 | + $this->loggerInstance->debug(1, "Posting to http://".$this->$hostname.':'.\config\Master::MANAGEDSP['radiusconfigport']."/$post\n"); | |
| 610 | 610 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); | 
| 611 | 611 | curl_setopt($ch, CURLOPT_HEADER, 0); | 
| 612 | 612 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | 
| @@ -645,19 +645,19 @@ discard block | ||
| 645 | 645 |          } else { | 
| 646 | 646 |              $txt = $remove ? _('Profile deactivation failed') : _('Profile activation/modification failed'); | 
| 647 | 647 | } | 
| 648 | - $txt = $txt . ' '; | |
| 648 | + $txt = $txt.' '; | |
| 649 | 649 |          if (array_count_values($response)[$status] == 2) { | 
| 650 | -            $txt = $txt . _('on both RADIUS servers: primary and backup') . '.'; | |
| 650 | +            $txt = $txt._('on both RADIUS servers: primary and backup').'.'; | |
| 651 | 651 |          } else { | 
| 652 | 652 |              if ($response['res[1]'] == $status) { | 
| 653 | -                $txt = $txt . _('on primary RADIUS server') . '.'; | |
| 653 | +                $txt = $txt._('on primary RADIUS server').'.'; | |
| 654 | 654 |              } else { | 
| 655 | -                $txt = $txt . _('on backup RADIUS server') . '.'; | |
| 655 | +                $txt = $txt._('on backup RADIUS server').'.'; | |
| 656 | 656 | } | 
| 657 | 657 | } | 
| 658 | 658 | $mail = \core\common\OutsideComm::mailHandle(); | 
| 659 | 659 |          $email = $this->getAttributes("support:email")[0]['value']; | 
| 660 | - $mail->FromName = \config\Master::APPEARANCE['productname'] . " Notification System"; | |
| 660 | + $mail->FromName = \config\Master::APPEARANCE['productname']." Notification System"; | |
| 661 | 661 | $mail->addAddress($email); | 
| 662 | 662 |          if ($status == 'OK') { | 
| 663 | 663 |              $mail->Subject = _('RADIUS profile update problem fixed'); | 
| @@ -691,7 +691,7 @@ discard block | ||
| 691 | 691 | return NULL; | 
| 692 | 692 | } | 
| 693 | 693 | $timeout = 10; | 
| 694 | - curl_setopt($ch, CURLOPT_URL, 'http://' . $host); | |
| 694 | + curl_setopt($ch, CURLOPT_URL, 'http://'.$host); | |
| 695 | 695 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | 
| 696 | 696 | curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); | 
| 697 | 697 | curl_exec($ch); | 
| @@ -783,52 +783,52 @@ discard block | ||
| 783 | 783 |      { | 
| 784 | 784 | $toPost = ($onlyone ? array($onlyone => '') : array(1 => '', 2 => '')); | 
| 785 | 785 |          if ($torevoke != '') { | 
| 786 | - $toPostTemplate = 'instid=' . $this->institution . '&deploymentid=' . $this->identifier . | |
| 786 | + $toPostTemplate = 'instid='.$this->institution.'&deploymentid='.$this->identifier. | |
| 787 | 787 | "&torevoke=$torevoke"; | 
| 788 | 788 |              foreach (array_keys($toPost) as $key) { | 
| 789 | 789 | $toPost[$key] = $toPostTemplate; | 
| 790 | 790 | } | 
| 791 | 791 |          } else { | 
| 792 | 792 | $remove = ($this->status == \core\AbstractDeployment::INACTIVE) ? 0 : 1; | 
| 793 | - $toPostTemplate = 'instid=' . $this->institution . '&deploymentid=' . $this->identifier . | |
| 794 | - '&secret=' . $this->secret . | |
| 795 | -                '&country=' . $this->getAttributes("internal:country")[0]['value'] . | |
| 796 | - '&pskkey=' . $this->pskkey . '&'; | |
| 793 | + $toPostTemplate = 'instid='.$this->institution.'&deploymentid='.$this->identifier. | |
| 794 | + '&secret='.$this->secret. | |
| 795 | +                '&country='.$this->getAttributes("internal:country")[0]['value']. | |
| 796 | + '&pskkey='.$this->pskkey.'&'; | |
| 797 | 797 |              if ($remove) { | 
| 798 | - $toPostTemplate = $toPostTemplate . 'remove=1&'; | |
| 798 | + $toPostTemplate = $toPostTemplate.'remove=1&'; | |
| 799 | 799 |              } else { | 
| 800 | - $toPostTemplate = $toPostTemplate . 'operatorname=' . $this->getOperatorName() . '&'; | |
| 800 | + $toPostTemplate = $toPostTemplate.'operatorname='.$this->getOperatorName().'&'; | |
| 801 | 801 |                  if ($this->getAttributes("managedsp:vlan")[0]['value'] ?? NULL) { | 
| 802 | 802 | $allRealms = $this->getAllRealms(); | 
| 803 | 803 |                      if (!empty($allRealms)) { | 
| 804 | -                        $toPostTemplate = $toPostTemplate . 'vlan=' . $this->getAttributes("managedsp:vlan")[0]['value'] . '&'; | |
| 805 | -                        $toPostTemplate = $toPostTemplate . 'realmforvlan[]=' . implode('&realmforvlan[]=', $allRealms) . '&'; | |
| 804 | +                        $toPostTemplate = $toPostTemplate.'vlan='.$this->getAttributes("managedsp:vlan")[0]['value'].'&'; | |
| 805 | +                        $toPostTemplate = $toPostTemplate.'realmforvlan[]='.implode('&realmforvlan[]=', $allRealms).'&'; | |
| 806 | 806 | } | 
| 807 | 807 | } | 
| 808 | 808 |                  if ($this->getAttributes("managedsp:guest_vlan")[0]['value'] ?? NULL) { | 
| 809 | -                    $toPostTemplate = $toPostTemplate . 'guest_vlan=' . $this->getAttributes("managedsp:guest_vlan")[0]['value'] . '&'; | |
| 809 | +                    $toPostTemplate = $toPostTemplate.'guest_vlan='.$this->getAttributes("managedsp:guest_vlan")[0]['value'].'&'; | |
| 810 | 810 | } | 
| 811 | 811 | } | 
| 812 | 812 |              foreach (array_keys($toPost) as $key) { | 
| 813 | - $elem = 'port' . $key; | |
| 814 | - $toPost[$key] = $toPostTemplate . 'port=' . $this->$elem; | |
| 813 | + $elem = 'port'.$key; | |
| 814 | + $toPost[$key] = $toPostTemplate.'port='.$this->$elem; | |
| 815 | 815 | } | 
| 816 | 816 | } | 
| 817 | 817 | $response = array(); | 
| 818 | 818 |          foreach ($toPost as $key => $value) { | 
| 819 | - $this->loggerInstance->debug(1, 'toPost ' . $toPost[$key] . "\n"); | |
| 819 | + $this->loggerInstance->debug(1, 'toPost '.$toPost[$key]."\n"); | |
| 820 | 820 | // temporarly one server $response['res[' . $key . ']'] = $this->sendToRADIUS($key, $toPost[$key]); | 
| 821 | 821 |              //if ($key == 2) { | 
| 822 | 822 | // $response['res[2]'] = 'OK'; | 
| 823 | 823 |              //} else { | 
| 824 | - $response['res[' . $key . ']'] = $this->sendToRADIUS($key, $toPost[$key]); | |
| 824 | + $response['res['.$key.']'] = $this->sendToRADIUS($key, $toPost[$key]); | |
| 825 | 825 | //} | 
| 826 | 826 | } | 
| 827 | 827 |          if ($onlyone) { | 
| 828 | - $response['res[' . ($onlyone == 1) ? 2 : 1 . ']'] = \core\AbstractDeployment::RADIUS_OK; | |
| 828 | + $response['res['.($onlyone == 1) ? 2 : 1.']'] = \core\AbstractDeployment::RADIUS_OK; | |
| 829 | 829 | } | 
| 830 | 830 |          foreach (array('OK', 'FAILURE') as $status) { | 
| 831 | -            if ( ( ($status == 'OK' && $notify) || ($status == 'FAILURE') ) && ( in_array($status, $response) ) ) { | |
| 831 | +            if ((($status == 'OK' && $notify) || ($status == 'FAILURE')) && (in_array($status, $response))) { | |
| 832 | 832 | $this->sendMailtoAdmin($remove, $response, $status); | 
| 833 | 833 | } | 
| 834 | 834 | } |