|
@@ -254,7 +254,7 @@ discard block |
|
|
block discarded – undo |
|
254
|
254
|
$serverCandidates[IdPlist::geoDistance($adminLocation, ['lat' => $iterator->location_lat, 'lon' => $iterator->location_lon])] = $iterator->server_id; |
|
255
|
255
|
} |
|
256
|
256
|
if ($clients > $maxSupportedClients * 0.9) { |
|
257
|
|
- $this->loggerInstance->debug(1, "A RADIUS server for Managed SP (" . $iterator->server_id . ") is serving at more than 90% capacity!"); |
|
|
257
|
+ $this->loggerInstance->debug(1, "A RADIUS server for Managed SP (".$iterator->server_id.") is serving at more than 90% capacity!"); |
|
258
|
258
|
} |
|
259
|
259
|
} |
|
260
|
260
|
if (count($serverCandidates) == 0 && $federation != "DEFAULT") { |
|
@@ -263,7 +263,7 @@ discard block |
|
|
block discarded – undo |
|
263
|
263
|
return $this->findGoodServerLocation($adminLocation, "DEFAULT", $blacklistedServers); |
|
264
|
264
|
} |
|
265
|
265
|
if (count($serverCandidates) == 0) { |
|
266
|
|
- throw new Exception("No available server found for new SP! $federation " . /** @scrutinizer ignore-type */ print_r($serverCandidates, true)); |
|
|
266
|
+ throw new Exception("No available server found for new SP! $federation "./** @scrutinizer ignore-type */ print_r($serverCandidates, true)); |
|
267
|
267
|
} |
|
268
|
268
|
// put the nearest server on top of the list |
|
269
|
269
|
ksort($serverCandidates); |
|
@@ -291,7 +291,7 @@ discard block |
|
|
block discarded – undo |
|
291
|
291
|
$foundFreePort1 = 0; |
|
292
|
292
|
while ($foundFreePort1 == 0) { |
|
293
|
293
|
$portCandidate = random_int(1200, 65535); |
|
294
|
|
- $check = $this->databaseHandle->exec("SELECT port_instance_1 FROM deployment WHERE radius_instance_1 = '" . $ourserver . "' AND port_instance_1 = $portCandidate"); |
|
|
294
|
+ $check = $this->databaseHandle->exec("SELECT port_instance_1 FROM deployment WHERE radius_instance_1 = '".$ourserver."' AND port_instance_1 = $portCandidate"); |
|
295
|
295
|
if (mysqli_num_rows(/** @scrutinizer ignore-type */ $check) == 0) { |
|
296
|
296
|
$foundFreePort1 = $portCandidate; |
|
297
|
297
|
} |
|
@@ -300,14 +300,14 @@ discard block |
|
|
block discarded – undo |
|
300
|
300
|
$foundFreePort2 = 0; |
|
301
|
301
|
while ($foundFreePort2 == 0) { |
|
302
|
302
|
$portCandidate = random_int(1200, 65535); |
|
303
|
|
- $check = $this->databaseHandle->exec("SELECT port_instance_2 FROM deployment WHERE radius_instance_2 = '" . $ourSecondServer . "' AND port_instance_2 = $portCandidate"); |
|
|
303
|
+ $check = $this->databaseHandle->exec("SELECT port_instance_2 FROM deployment WHERE radius_instance_2 = '".$ourSecondServer."' AND port_instance_2 = $portCandidate"); |
|
304
|
304
|
if (mysqli_num_rows(/** @scrutinizer ignore-type */ $check) == 0) { |
|
305
|
305
|
$foundFreePort2 = $portCandidate; |
|
306
|
306
|
} |
|
307
|
307
|
} |
|
308
|
308
|
// and make up a shared secret that is halfways readable |
|
309
|
309
|
$futureSecret = $this->randomString(16, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); |
|
310
|
|
- $this->databaseHandle->exec("UPDATE deployment SET radius_instance_1 = '" . $ourserver . "', radius_instance_2 = '" . $ourSecondServer . "', port_instance_1 = $foundFreePort1, port_instance_2 = $foundFreePort2, secret = '$futureSecret' WHERE deployment_id = $this->identifier"); |
|
|
310
|
+ $this->databaseHandle->exec("UPDATE deployment SET radius_instance_1 = '".$ourserver."', radius_instance_2 = '".$ourSecondServer."', port_instance_1 = $foundFreePort1, port_instance_2 = $foundFreePort2, secret = '$futureSecret' WHERE deployment_id = $this->identifier"); |
|
311
|
311
|
return ["port_instance_1" => $foundFreePort1, "port_instance_2" => $foundFreePort2, "secret" => $futureSecret, "radius_instance_1" => $ourserver, "radius_instance_2" => $ourserver]; |
|
312
|
312
|
} |
|
313
|
313
|
|
|
@@ -354,7 +354,7 @@ discard block |
|
|
block discarded – undo |
|
354
|
354
|
*/ |
|
355
|
355
|
public function deactivate() |
|
356
|
356
|
{ |
|
357
|
|
- $this->databaseHandle->exec("UPDATE deployment SET status = " . DeploymentManaged::INACTIVE . " WHERE deployment_id = $this->identifier"); |
|
|
357
|
+ $this->databaseHandle->exec("UPDATE deployment SET status = ".DeploymentManaged::INACTIVE." WHERE deployment_id = $this->identifier"); |
|
358
|
358
|
} |
|
359
|
359
|
|
|
360
|
360
|
/** |
|
@@ -365,7 +365,7 @@ discard block |
|
|
block discarded – undo |
|
365
|
365
|
*/ |
|
366
|
366
|
public function activate() |
|
367
|
367
|
{ |
|
368
|
|
- $this->databaseHandle->exec("UPDATE deployment SET status = " . DeploymentManaged::ACTIVE . " WHERE deployment_id = $this->identifier"); |
|
|
368
|
+ $this->databaseHandle->exec("UPDATE deployment SET status = ".DeploymentManaged::ACTIVE." WHERE deployment_id = $this->identifier"); |
|
369
|
369
|
} |
|
370
|
370
|
|
|
371
|
371
|
/** |
|
@@ -377,7 +377,7 @@ discard block |
|
|
block discarded – undo |
|
377
|
377
|
{ |
|
378
|
378
|
$customAttrib = $this->getAttributes("managedsp:operatorname"); |
|
379
|
379
|
if (count($customAttrib) == 0) { |
|
380
|
|
- return "1sp." . $this->identifier . "-" . $this->institution . \config\ConfAssistant::SILVERBULLET['realm_suffix']; |
|
|
380
|
+ return "1sp.".$this->identifier."-".$this->institution.\config\ConfAssistant::SILVERBULLET['realm_suffix']; |
|
381
|
381
|
} |
|
382
|
382
|
return $customAttrib[0]["value"]; |
|
383
|
383
|
} |
|
@@ -393,13 +393,13 @@ discard block |
|
|
block discarded – undo |
|
393
|
393
|
{ |
|
394
|
394
|
|
|
395
|
395
|
$hostname = "radius_hostname_$idx"; |
|
396
|
|
- $ch = curl_init("http://" . $this->$hostname); |
|
|
396
|
+ $ch = curl_init("http://".$this->$hostname); |
|
397
|
397
|
if ($ch === FALSE) { |
|
398
|
398
|
$res = 'FAILURE'; |
|
399
|
399
|
} else { |
|
400
|
400
|
curl_setopt($ch, CURLOPT_POST, 1); |
|
401
|
401
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $post); |
|
402
|
|
- $this->loggerInstance->debug(1, "Posting to http://" . $this->$hostname . ": $post\n"); |
|
|
402
|
+ $this->loggerInstance->debug(1, "Posting to http://".$this->$hostname.": $post\n"); |
|
403
|
403
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
|
404
|
404
|
curl_setopt($ch, CURLOPT_HEADER, 0); |
|
405
|
405
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
@@ -414,7 +414,7 @@ discard block |
|
|
block discarded – undo |
|
414
|
414
|
$this->loggerInstance->debug(1, $this); |
|
415
|
415
|
} |
|
416
|
416
|
$this->loggerInstance->debug(1, "Database update"); |
|
417
|
|
- $this->databaseHandle->exec("UPDATE deployment SET radius_status_$idx = " . ($res == 'OK' ? \core\AbstractDeployment::RADIUS_OK : \core\AbstractDeployment::RADIUS_FAILURE) . " WHERE deployment_id = $this->identifier"); |
|
|
417
|
+ $this->databaseHandle->exec("UPDATE deployment SET radius_status_$idx = ".($res == 'OK' ? \core\AbstractDeployment::RADIUS_OK : \core\AbstractDeployment::RADIUS_FAILURE)." WHERE deployment_id = $this->identifier"); |
|
418
|
418
|
return $res; |
|
419
|
419
|
} |
|
420
|
420
|
|
|
@@ -435,19 +435,19 @@ discard block |
|
|
block discarded – undo |
|
435
|
435
|
} else { |
|
436
|
436
|
$txt = $remove ? _('Profile dectivation failed') : _('Profile activation/modification failed'); |
|
437
|
437
|
} |
|
438
|
|
- $txt = $txt . ' '; |
|
|
438
|
+ $txt = $txt.' '; |
|
439
|
439
|
if (array_count_values($response)[$status] == 2) { |
|
440
|
|
- $txt = $txt . _('on both RADIUS servers: primary and backup') . '.'; |
|
|
440
|
+ $txt = $txt._('on both RADIUS servers: primary and backup').'.'; |
|
441
|
441
|
} else { |
|
442
|
442
|
if ($response['res[1]'] == $status) { |
|
443
|
|
- $txt = $txt . _('on primary RADIUS server') . '.'; |
|
|
443
|
+ $txt = $txt._('on primary RADIUS server').'.'; |
|
444
|
444
|
} else { |
|
445
|
|
- $txt = $txt . _('on backup RADIUS server') . '.'; |
|
|
445
|
+ $txt = $txt._('on backup RADIUS server').'.'; |
|
446
|
446
|
} |
|
447
|
447
|
} |
|
448
|
448
|
$mail = \core\common\OutsideComm::mailHandle(); |
|
449
|
449
|
$email = $this->getAttributes("support:email")[0]['value']; |
|
450
|
|
- $mail->FromName = \config\Master::APPEARANCE['productname'] . " Notification System"; |
|
|
450
|
+ $mail->FromName = \config\Master::APPEARANCE['productname']." Notification System"; |
|
451
|
451
|
$mail->addAddress($email); |
|
452
|
452
|
if ($status == 'OK') { |
|
453
|
453
|
$mail->Subject = _('RADIUS profile update problem fixed'); |
|
@@ -481,7 +481,7 @@ discard block |
|
|
block discarded – undo |
|
481
|
481
|
return NULL; |
|
482
|
482
|
} |
|
483
|
483
|
$timeout = 10; |
|
484
|
|
- curl_setopt($ch, CURLOPT_URL, 'http://' . $host); |
|
|
484
|
+ curl_setopt($ch, CURLOPT_URL, 'http://'.$host); |
|
485
|
485
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
486
|
486
|
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
487
|
487
|
curl_exec($ch); |
|
@@ -572,32 +572,32 @@ discard block |
|
|
block discarded – undo |
|
572
|
572
|
{ |
|
573
|
573
|
$remove = ($this->status == \core\AbstractDeployment::INACTIVE) ? 0 : 1; |
|
574
|
574
|
$toPost = ($onlyone ? array($onlyone => '') : array(1 => '', 2 => '')); |
|
575
|
|
- $toPostTemplate = 'instid=' . $this->institution . '&deploymentid=' . $this->identifier . '&secret=' . $this->secret . '&country=' . $this->getAttributes("internal:country")[0]['value'] . '&'; |
|
|
575
|
+ $toPostTemplate = 'instid='.$this->institution.'&deploymentid='.$this->identifier.'&secret='.$this->secret.'&country='.$this->getAttributes("internal:country")[0]['value'].'&'; |
|
576
|
576
|
if ($remove) { |
|
577
|
|
- $toPostTemplate = $toPostTemplate . 'remove=1&'; |
|
|
577
|
+ $toPostTemplate = $toPostTemplate.'remove=1&'; |
|
578
|
578
|
} else { |
|
579
|
579
|
if ($this->getAttributes("managedsp:operatorname")[0]['value'] ?? NULL) { |
|
580
|
|
- $toPostTemplate = $toPostTemplate . 'operatorname=' . $this->getAttributes("managedsp:operatorname")[0]['value'] . '&'; |
|
|
580
|
+ $toPostTemplate = $toPostTemplate.'operatorname='.$this->getAttributes("managedsp:operatorname")[0]['value'].'&'; |
|
581
|
581
|
} |
|
582
|
582
|
if ($this->getAttributes("managedsp:vlan")[0]['value'] ?? NULL) { |
|
583
|
583
|
$allRealms = $this->getAllRealms(); |
|
584
|
584
|
if (!empty($allRealms)) { |
|
585
|
|
- $toPostTemplate = $toPostTemplate . 'vlan=' . $this->getAttributes("managedsp:vlan")[0]['value'] . '&'; |
|
586
|
|
- $toPostTemplate = $toPostTemplate . 'realmforvlan[]=' . implode('&realmforvlan[]=', $allRealms) . '&'; |
|
|
585
|
+ $toPostTemplate = $toPostTemplate.'vlan='.$this->getAttributes("managedsp:vlan")[0]['value'].'&'; |
|
|
586
|
+ $toPostTemplate = $toPostTemplate.'realmforvlan[]='.implode('&realmforvlan[]=', $allRealms).'&'; |
|
587
|
587
|
} |
|
588
|
588
|
} |
|
589
|
589
|
} |
|
590
|
590
|
foreach (array_keys($toPost) as $key) { |
|
591
|
|
- $elem = 'port' . $key; |
|
592
|
|
- $toPost[$key] = $toPostTemplate . 'port=' . $this->$elem; |
|
|
591
|
+ $elem = 'port'.$key; |
|
|
592
|
+ $toPost[$key] = $toPostTemplate.'port='.$this->$elem; |
|
593
|
593
|
} |
|
594
|
594
|
$response = array(); |
|
595
|
595
|
foreach ($toPost as $key => $value) { |
|
596
|
|
- $this->loggerInstance->debug(1, 'toPost ' . $toPost[$key] . "\n"); |
|
597
|
|
- $response['res[' . $key . ']'] = $this->sendToRADIUS($key, $toPost[$key]); |
|
|
596
|
+ $this->loggerInstance->debug(1, 'toPost '.$toPost[$key]."\n"); |
|
|
597
|
+ $response['res['.$key.']'] = $this->sendToRADIUS($key, $toPost[$key]); |
|
598
|
598
|
} |
|
599
|
599
|
if ($onlyone) { |
|
600
|
|
- $response['res[' . ($onlyone == 1) ? 2 : 1 . ']'] = \core\AbstractDeployment::RADIUS_OK; |
|
|
600
|
+ $response['res['.($onlyone == 1) ? 2 : 1.']'] = \core\AbstractDeployment::RADIUS_OK; |
|
601
|
601
|
} |
|
602
|
602
|
foreach (array('OK', 'FAILURE') as $status) { |
|
603
|
603
|
if ((($status == 'OK' && $notify) || ($status == 'FAILURE')) && in_array($status, $response)) { |