@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | $serverCandidates[IdPlist::geoDistance($adminLocation, ['lat' => $iterator->location_lat, 'lon' => $iterator->location_lon])] = $iterator->server_id; |
234 | 234 | } |
235 | 235 | if ($clients > $maxSupportedClients * 0.9) { |
236 | - $this->loggerInstance->debug(1, "A RADIUS server for Managed SP (" . $iterator->server_id . ") is serving at more than 90% capacity!"); |
|
236 | + $this->loggerInstance->debug(1, "A RADIUS server for Managed SP (".$iterator->server_id.") is serving at more than 90% capacity!"); |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | if (count($serverCandidates) == 0 && $federation != "DEFAULT") { |
@@ -264,28 +264,28 @@ discard block |
||
264 | 264 | $ourLocation = ['lon' => $geoip['geo']['lon'], 'lat' => $geoip['geo']['lat']]; |
265 | 265 | } |
266 | 266 | $inst = new IdP($this->institution); |
267 | - $ourserver = $this->findGoodServerLocation($ourLocation, $inst->federation , []); |
|
267 | + $ourserver = $this->findGoodServerLocation($ourLocation, $inst->federation, []); |
|
268 | 268 | // now, find an unused port in the preferred server |
269 | 269 | $foundFreePort1 = 0; |
270 | 270 | while ($foundFreePort1 == 0) { |
271 | 271 | $portCandidate = random_int(1200, 65535); |
272 | - $check = $this->databaseHandle->exec("SELECT port_instance_1 FROM deployment WHERE radius_instance_1 = '" . $ourserver . "' AND port_instance_1 = $portCandidate"); |
|
272 | + $check = $this->databaseHandle->exec("SELECT port_instance_1 FROM deployment WHERE radius_instance_1 = '".$ourserver."' AND port_instance_1 = $portCandidate"); |
|
273 | 273 | if (mysqli_num_rows(/** @scrutinizer ignore-type */ $check) == 0) { |
274 | 274 | $foundFreePort1 = $portCandidate; |
275 | 275 | } |
276 | 276 | } |
277 | - $ourSecondServer = $this->findGoodServerLocation($ourLocation, $inst->federation , [$ourserver]); |
|
277 | + $ourSecondServer = $this->findGoodServerLocation($ourLocation, $inst->federation, [$ourserver]); |
|
278 | 278 | $foundFreePort2 = 0; |
279 | 279 | while ($foundFreePort2 == 0) { |
280 | 280 | $portCandidate = random_int(1200, 65535); |
281 | - $check = $this->databaseHandle->exec("SELECT port_instance_2 FROM deployment WHERE radius_instance_2 = '" . $ourSecondServer . "' AND port_instance_2 = $portCandidate"); |
|
281 | + $check = $this->databaseHandle->exec("SELECT port_instance_2 FROM deployment WHERE radius_instance_2 = '".$ourSecondServer."' AND port_instance_2 = $portCandidate"); |
|
282 | 282 | if (mysqli_num_rows(/** @scrutinizer ignore-type */ $check) == 0) { |
283 | 283 | $foundFreePort2 = $portCandidate; |
284 | 284 | } |
285 | 285 | } |
286 | 286 | // and make up a shared secret that is halfways readable |
287 | 287 | $futureSecret = $this->randomString(16, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); |
288 | - $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"); |
|
288 | + $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"); |
|
289 | 289 | return ["port_instance_1" => $foundFreePort1, "port_instance_2" => $foundFreePort2, "secret" => $futureSecret, "radius_instance_1" => $ourserver, "radius_instance_2" => $ourserver]; |
290 | 290 | } |
291 | 291 | |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * @return void |
329 | 329 | */ |
330 | 330 | public function deactivate() { |
331 | - $this->databaseHandle->exec("UPDATE deployment SET status = " . DeploymentManaged::INACTIVE . " WHERE deployment_id = $this->identifier"); |
|
331 | + $this->databaseHandle->exec("UPDATE deployment SET status = ".DeploymentManaged::INACTIVE." WHERE deployment_id = $this->identifier"); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | * @return void |
339 | 339 | */ |
340 | 340 | public function activate() { |
341 | - $this->databaseHandle->exec("UPDATE deployment SET status = " . DeploymentManaged::ACTIVE . " WHERE deployment_id = $this->identifier"); |
|
341 | + $this->databaseHandle->exec("UPDATE deployment SET status = ".DeploymentManaged::ACTIVE." WHERE deployment_id = $this->identifier"); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | /** |
@@ -361,12 +361,12 @@ discard block |
||
361 | 361 | * @return string |
362 | 362 | */ |
363 | 363 | public function setRADIUSconfig($remove = 0) { |
364 | - $toPost1 = 'instid=' . $this->institution . '&deploymentid=' . $this->identifier . '&secret=' . $this->secret . '&country=' . $this->getAttributes("internal:country")[0]['value'] . '&'; |
|
364 | + $toPost1 = 'instid='.$this->institution.'&deploymentid='.$this->identifier.'&secret='.$this->secret.'&country='.$this->getAttributes("internal:country")[0]['value'].'&'; |
|
365 | 365 | if ($remove) { |
366 | - $toPost1 = $toPost1 . 'remove=1&'; |
|
366 | + $toPost1 = $toPost1.'remove=1&'; |
|
367 | 367 | } else { |
368 | 368 | if ($this->getAttributes("managedsp:operatorname")[0]['value'] ?? NULL) { |
369 | - $toPost1 = $toPost1 . 'operatorname=' . $this->getAttributes("managedsp:operatorname")[0]['value'] . '&'; |
|
369 | + $toPost1 = $toPost1.'operatorname='.$this->getAttributes("managedsp:operatorname")[0]['value'].'&'; |
|
370 | 370 | } |
371 | 371 | if ($this->getAttributes("managedsp:vlan")[0]['value'] ?? NULL) { |
372 | 372 | $idp = new IdP($this->institution); |
@@ -384,23 +384,23 @@ discard block |
||
384 | 384 | } |
385 | 385 | if (!empty($allRealms)) { |
386 | 386 | $this->loggerInstance->debug(1, $allRealms); |
387 | - $toPost1 = $toPost1 . 'vlan=' . $this->getAttributes("managedsp:vlan")[0]['value'] . '&'; |
|
388 | - $toPost1 = $toPost1 . 'realmforvlan[]=' . implode('&realmforvlan[]=', $allRealms) . '&'; |
|
387 | + $toPost1 = $toPost1.'vlan='.$this->getAttributes("managedsp:vlan")[0]['value'].'&'; |
|
388 | + $toPost1 = $toPost1.'realmforvlan[]='.implode('&realmforvlan[]=', $allRealms).'&'; |
|
389 | 389 | } |
390 | 390 | } |
391 | 391 | } |
392 | 392 | $toPost2 = $toPost1; |
393 | - $toPost1 = $toPost1 . 'port=' . $this->port1; |
|
394 | - $toPost2 = $toPost2 . 'port=' . $this->port2; |
|
395 | - $ch = curl_init( "http://" . $this->radius_hostname_1 ); |
|
393 | + $toPost1 = $toPost1.'port='.$this->port1; |
|
394 | + $toPost2 = $toPost2.'port='.$this->port2; |
|
395 | + $ch = curl_init("http://".$this->radius_hostname_1); |
|
396 | 396 | if ($ch) { |
397 | - curl_setopt( $ch, CURLOPT_POST, 1); |
|
398 | - curl_setopt( $ch, CURLOPT_POSTFIELDS, $toPost1); |
|
399 | - $this->loggerInstance->debug(1, "Posting to http://" . $this->radius_hostname_1 . ": $toPost1\n"); |
|
400 | - curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1); |
|
401 | - curl_setopt( $ch, CURLOPT_HEADER, 0); |
|
402 | - curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1); |
|
403 | - $response = curl_exec( $ch ); |
|
397 | + curl_setopt($ch, CURLOPT_POST, 1); |
|
398 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $toPost1); |
|
399 | + $this->loggerInstance->debug(1, "Posting to http://".$this->radius_hostname_1.": $toPost1\n"); |
|
400 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
|
401 | + curl_setopt($ch, CURLOPT_HEADER, 0); |
|
402 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
403 | + $response = curl_exec($ch); |
|
404 | 404 | if ($response === FALSE) { |
405 | 405 | $response = 'FAILURE'; |
406 | 406 | } |