|
@@ -286,7 +286,7 @@ discard block |
|
|
block discarded – undo |
|
286
|
286
|
$serverCandidates[IdPlist::geoDistance($adminLocation, ['lat' => $iterator->location_lat, 'lon' => $iterator->location_lon])] = $iterator->server_id; |
|
287
|
287
|
} |
|
288
|
288
|
if ($clients > $maxSupportedClients * 0.9) { |
|
289
|
|
- $this->loggerInstance->debug(1, "A RADIUS server for Managed SP (" . $iterator->server_id . ") is serving at more than 90% capacity!"); |
|
|
289
|
+ $this->loggerInstance->debug(1, "A RADIUS server for Managed SP (".$iterator->server_id.") is serving at more than 90% capacity!"); |
|
290
|
290
|
} |
|
291
|
291
|
} |
|
292
|
292
|
if (count($serverCandidates) == 0 && $federation != "DEFAULT") { |
|
@@ -323,7 +323,7 @@ discard block |
|
|
block discarded – undo |
|
323
|
323
|
$foundFreePort1 = 0; |
|
324
|
324
|
while ($foundFreePort1 == 0) { |
|
325
|
325
|
$portCandidate = random_int(1200, 65535); |
|
326
|
|
- $check = $this->databaseHandle->exec("SELECT port_instance_1 FROM deployment WHERE radius_instance_1 = '" . $ourserver . "' AND port_instance_1 = $portCandidate"); |
|
|
326
|
+ $check = $this->databaseHandle->exec("SELECT port_instance_1 FROM deployment WHERE radius_instance_1 = '".$ourserver."' AND port_instance_1 = $portCandidate"); |
|
327
|
327
|
if (mysqli_num_rows(/** @scrutinizer ignore-type */ $check) == 0) { |
|
328
|
328
|
$foundFreePort1 = $portCandidate; |
|
329
|
329
|
} |
|
@@ -332,14 +332,14 @@ discard block |
|
|
block discarded – undo |
|
332
|
332
|
$foundFreePort2 = 0; |
|
333
|
333
|
while ($foundFreePort2 == 0) { |
|
334
|
334
|
$portCandidate = random_int(1200, 65535); |
|
335
|
|
- $check = $this->databaseHandle->exec("SELECT port_instance_2 FROM deployment WHERE radius_instance_2 = '" . $ourSecondServer . "' AND port_instance_2 = $portCandidate"); |
|
|
335
|
+ $check = $this->databaseHandle->exec("SELECT port_instance_2 FROM deployment WHERE radius_instance_2 = '".$ourSecondServer."' AND port_instance_2 = $portCandidate"); |
|
336
|
336
|
if (mysqli_num_rows(/** @scrutinizer ignore-type */ $check) == 0) { |
|
337
|
337
|
$foundFreePort2 = $portCandidate; |
|
338
|
338
|
} |
|
339
|
339
|
} |
|
340
|
340
|
// and make up a shared secret that is halfways readable |
|
341
|
341
|
$futureSecret = $this->randomString(16, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); |
|
342
|
|
- $this->databaseHandle->exec("UPDATE deployment SET radius_instance_1 = '" . $ourserver . "', radius_instance_2 = '" . $ourSecondServer . "', port_instance_1 = $foundFreePort1, port_instance_2 = $foundFreePort2, secret = '$futureSecret', consortium = '$this->consortium' WHERE deployment_id = $this->identifier"); |
|
|
342
|
+ $this->databaseHandle->exec("UPDATE deployment SET radius_instance_1 = '".$ourserver."', radius_instance_2 = '".$ourSecondServer."', port_instance_1 = $foundFreePort1, port_instance_2 = $foundFreePort2, secret = '$futureSecret', consortium = '$this->consortium' WHERE deployment_id = $this->identifier"); |
|
343
|
343
|
return ["port_instance_1" => $foundFreePort1, "port_instance_2" => $foundFreePort2, "secret" => $futureSecret, "radius_instance_1" => $ourserver, "radius_instance_2" => $ourserver]; |
|
344
|
344
|
} |
|
345
|
345
|
|
|
@@ -386,7 +386,7 @@ discard block |
|
|
block discarded – undo |
|
386
|
386
|
*/ |
|
387
|
387
|
public function deactivate() |
|
388
|
388
|
{ |
|
389
|
|
- $this->databaseHandle->exec("UPDATE deployment SET status = " . DeploymentManaged::INACTIVE . " WHERE deployment_id = $this->identifier"); |
|
|
389
|
+ $this->databaseHandle->exec("UPDATE deployment SET status = ".DeploymentManaged::INACTIVE." WHERE deployment_id = $this->identifier"); |
|
390
|
390
|
} |
|
391
|
391
|
|
|
392
|
392
|
/** |
|
@@ -397,7 +397,7 @@ discard block |
|
|
block discarded – undo |
|
397
|
397
|
*/ |
|
398
|
398
|
public function activate() |
|
399
|
399
|
{ |
|
400
|
|
- $this->databaseHandle->exec("UPDATE deployment SET status = " . DeploymentManaged::ACTIVE . " WHERE deployment_id = $this->identifier"); |
|
|
400
|
+ $this->databaseHandle->exec("UPDATE deployment SET status = ".DeploymentManaged::ACTIVE." WHERE deployment_id = $this->identifier"); |
|
401
|
401
|
} |
|
402
|
402
|
|
|
403
|
403
|
/** |
|
@@ -409,7 +409,7 @@ discard block |
|
|
block discarded – undo |
|
409
|
409
|
{ |
|
410
|
410
|
$customAttrib = $this->getAttributes("managedsp:operatorname"); |
|
411
|
411
|
if (count($customAttrib) == 0) { |
|
412
|
|
- return "1sp." . $this->identifier . "-" . $this->institution . \config\ConfAssistant::SILVERBULLET['realm_suffix']; |
|
|
412
|
+ return "1sp.".$this->identifier."-".$this->institution.\config\ConfAssistant::SILVERBULLET['realm_suffix']; |
|
413
|
413
|
} |
|
414
|
414
|
return $customAttrib[0]["value"]; |
|
415
|
415
|
} |
|
@@ -425,13 +425,13 @@ discard block |
|
|
block discarded – undo |
|
425
|
425
|
{ |
|
426
|
426
|
|
|
427
|
427
|
$hostname = "radius_hostname_$idx"; |
|
428
|
|
- $ch = curl_init("http://" . $this->$hostname); |
|
|
428
|
+ $ch = curl_init("http://".$this->$hostname); |
|
429
|
429
|
if ($ch === FALSE) { |
|
430
|
430
|
$res = 'FAILURE'; |
|
431
|
431
|
} else { |
|
432
|
432
|
curl_setopt($ch, CURLOPT_POST, 1); |
|
433
|
433
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $post); |
|
434
|
|
- $this->loggerInstance->debug(1, "Posting to http://" . $this->$hostname . ": $post\n"); |
|
|
434
|
+ $this->loggerInstance->debug(1, "Posting to http://".$this->$hostname.": $post\n"); |
|
435
|
435
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
|
436
|
436
|
curl_setopt($ch, CURLOPT_HEADER, 0); |
|
437
|
437
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
@@ -447,7 +447,7 @@ discard block |
|
|
block discarded – undo |
|
447
|
447
|
$this->loggerInstance->debug(1, $this); |
|
448
|
448
|
} |
|
449
|
449
|
$this->loggerInstance->debug(1, "Database update"); |
|
450
|
|
- $this->databaseHandle->exec("UPDATE deployment SET radius_status_$idx = " . ($res == 'OK' ? \core\AbstractDeployment::RADIUS_OK : \core\AbstractDeployment::RADIUS_FAILURE) . " WHERE deployment_id = $this->identifier"); |
|
|
450
|
+ $this->databaseHandle->exec("UPDATE deployment SET radius_status_$idx = ".($res == 'OK' ? \core\AbstractDeployment::RADIUS_OK : \core\AbstractDeployment::RADIUS_FAILURE)." WHERE deployment_id = $this->identifier"); |
|
451
|
451
|
return $res; |
|
452
|
452
|
} |
|
453
|
453
|
|
|
@@ -468,19 +468,19 @@ discard block |
|
|
block discarded – undo |
|
468
|
468
|
} else { |
|
469
|
469
|
$txt = $remove ? _('Profile deactivation failed') : _('Profile activation/modification failed'); |
|
470
|
470
|
} |
|
471
|
|
- $txt = $txt . ' '; |
|
|
471
|
+ $txt = $txt.' '; |
|
472
|
472
|
if (array_count_values($response)[$status] == 2) { |
|
473
|
|
- $txt = $txt . _('on both RADIUS servers: primary and backup') . '.'; |
|
|
473
|
+ $txt = $txt._('on both RADIUS servers: primary and backup').'.'; |
|
474
|
474
|
} else { |
|
475
|
475
|
if ($response['res[1]'] == $status) { |
|
476
|
|
- $txt = $txt . _('on primary RADIUS server') . '.'; |
|
|
476
|
+ $txt = $txt._('on primary RADIUS server').'.'; |
|
477
|
477
|
} else { |
|
478
|
|
- $txt = $txt . _('on backup RADIUS server') . '.'; |
|
|
478
|
+ $txt = $txt._('on backup RADIUS server').'.'; |
|
479
|
479
|
} |
|
480
|
480
|
} |
|
481
|
481
|
$mail = \core\common\OutsideComm::mailHandle(); |
|
482
|
482
|
$email = $this->getAttributes("support:email")[0]['value']; |
|
483
|
|
- $mail->FromName = \config\Master::APPEARANCE['productname'] . " Notification System"; |
|
|
483
|
+ $mail->FromName = \config\Master::APPEARANCE['productname']." Notification System"; |
|
484
|
484
|
$mail->addAddress($email); |
|
485
|
485
|
if ($status == 'OK') { |
|
486
|
486
|
$mail->Subject = _('RADIUS profile update problem fixed'); |
|
@@ -514,7 +514,7 @@ discard block |
|
|
block discarded – undo |
|
514
|
514
|
return NULL; |
|
515
|
515
|
} |
|
516
|
516
|
$timeout = 10; |
|
517
|
|
- curl_setopt($ch, CURLOPT_URL, 'http://' . $host); |
|
|
517
|
+ curl_setopt($ch, CURLOPT_URL, 'http://'.$host); |
|
518
|
518
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
519
|
519
|
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
520
|
520
|
curl_exec($ch); |
|
@@ -606,35 +606,35 @@ discard block |
|
|
block discarded – undo |
|
606
|
606
|
{ |
|
607
|
607
|
$remove = ($this->status == \core\AbstractDeployment::INACTIVE) ? 0 : 1; |
|
608
|
608
|
$toPost = ($onlyone ? array($onlyone => '') : array(1 => '', 2 => '')); |
|
609
|
|
- $toPostTemplate = 'instid=' . $this->institution . '&deploymentid=' . $this->identifier . '&secret=' . $this->secret . '&country=' . $this->getAttributes("internal:country")[0]['value'] . '&'; |
|
|
609
|
+ $toPostTemplate = 'instid='.$this->institution.'&deploymentid='.$this->identifier.'&secret='.$this->secret.'&country='.$this->getAttributes("internal:country")[0]['value'].'&'; |
|
610
|
610
|
if ($remove) { |
|
611
|
|
- $toPostTemplate = $toPostTemplate . 'remove=1&'; |
|
|
611
|
+ $toPostTemplate = $toPostTemplate.'remove=1&'; |
|
612
|
612
|
} else { |
|
613
|
613
|
if ($this->getAttributes("managedsp:operatorname")[0]['value'] ?? NULL) { |
|
614
|
|
- $toPostTemplate = $toPostTemplate . 'operatorname=' . $this->getAttributes("managedsp:operatorname")[0]['value'] . '&'; |
|
|
614
|
+ $toPostTemplate = $toPostTemplate.'operatorname='.$this->getAttributes("managedsp:operatorname")[0]['value'].'&'; |
|
615
|
615
|
} |
|
616
|
616
|
if ($this->getAttributes("managedsp:vlan")[0]['value'] ?? NULL) { |
|
617
|
617
|
$allRealms = $this->getAllRealms(); |
|
618
|
618
|
if (!empty($allRealms)) { |
|
619
|
|
- $toPostTemplate = $toPostTemplate . 'vlan=' . $this->getAttributes("managedsp:vlan")[0]['value'] . '&'; |
|
620
|
|
- $toPostTemplate = $toPostTemplate . 'realmforvlan[]=' . implode('&realmforvlan[]=', $allRealms) . '&'; |
|
|
619
|
+ $toPostTemplate = $toPostTemplate.'vlan='.$this->getAttributes("managedsp:vlan")[0]['value'].'&'; |
|
|
620
|
+ $toPostTemplate = $toPostTemplate.'realmforvlan[]='.implode('&realmforvlan[]=', $allRealms).'&'; |
|
621
|
621
|
} |
|
622
|
622
|
} |
|
623
|
623
|
} |
|
624
|
624
|
foreach (array_keys($toPost) as $key) { |
|
625
|
|
- $elem = 'port' . $key; |
|
626
|
|
- $toPost[$key] = $toPostTemplate . 'port=' . $this->$elem; |
|
|
625
|
+ $elem = 'port'.$key; |
|
|
626
|
+ $toPost[$key] = $toPostTemplate.'port='.$this->$elem; |
|
627
|
627
|
} |
|
628
|
628
|
$response = array(); |
|
629
|
629
|
foreach ($toPost as $key => $value) { |
|
630
|
|
- $this->loggerInstance->debug(1, 'toPost ' . $toPost[$key] . "\n"); |
|
631
|
|
- $response['res[' . $key . ']'] = $this->sendToRADIUS($key, $toPost[$key]); |
|
|
630
|
+ $this->loggerInstance->debug(1, 'toPost '.$toPost[$key]."\n"); |
|
|
631
|
+ $response['res['.$key.']'] = $this->sendToRADIUS($key, $toPost[$key]); |
|
632
|
632
|
} |
|
633
|
633
|
if ($onlyone) { |
|
634
|
|
- $response['res[' . ($onlyone == 1) ? 2 : 1 . ']'] = \core\AbstractDeployment::RADIUS_OK; |
|
|
634
|
+ $response['res['.($onlyone == 1) ? 2 : 1.']'] = \core\AbstractDeployment::RADIUS_OK; |
|
635
|
635
|
} |
|
636
|
636
|
foreach (array('OK', 'FAILURE') as $status) { |
|
637
|
|
- if ( ( ($status == 'OK' && $notify) || ($status == 'FAILURE') ) && ( in_array($status, $response) ) ) { |
|
|
637
|
+ if ((($status == 'OK' && $notify) || ($status == 'FAILURE')) && (in_array($status, $response))) { |
|
638
|
638
|
$this->sendMailtoAdmin($remove, $response, $status); |
|
639
|
639
|
} |
|
640
|
640
|
} |