Test Setup Failed
Push — master ( ab1e69...1cafb2 )
by Stefan
05:34 queued 11s
created
core/DeploymentManaged.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
                 $serverCandidates[IdPlist::geoDistance($adminLocation, ['lat' => $iterator->location_lat, 'lon' => $iterator->location_lon])] = $iterator->server_id;
271 271
             }
272 272
             if ($clients > $maxSupportedClients * 0.9) {
273
-                $this->loggerInstance->debug(1, "A RADIUS server for Managed SP (" . $iterator->server_id . ") is serving at more than 90% capacity!");
273
+                $this->loggerInstance->debug(1, "A RADIUS server for Managed SP (".$iterator->server_id.") is serving at more than 90% capacity!");
274 274
             }
275 275
         }
276 276
         if (count($serverCandidates) == 0 && $federation != "DEFAULT") {
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
             return $this->findGoodServerLocation($adminLocation, "DEFAULT", $blacklistedServers);
280 280
         }
281 281
         if (count($serverCandidates) == 0) {
282
-            throw new Exception("No available server found for new SP! $federation " . /** @scrutinizer ignore-type */ print_r($serverCandidates, true));
282
+            throw new Exception("No available server found for new SP! $federation "./** @scrutinizer ignore-type */ print_r($serverCandidates, true));
283 283
         }
284 284
         // put the nearest server on top of the list
285 285
         ksort($serverCandidates);
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
         $foundFreePort1 = 0;
308 308
         while ($foundFreePort1 == 0) {
309 309
             $portCandidate = random_int(1200, 65535);
310
-            $check = $this->databaseHandle->exec("SELECT port_instance_1 FROM deployment WHERE radius_instance_1 = '" . $ourserver . "' AND port_instance_1 = $portCandidate");
310
+            $check = $this->databaseHandle->exec("SELECT port_instance_1 FROM deployment WHERE radius_instance_1 = '".$ourserver."' AND port_instance_1 = $portCandidate");
311 311
             if (mysqli_num_rows(/** @scrutinizer ignore-type */ $check) == 0) {
312 312
                 $foundFreePort1 = $portCandidate;
313 313
             }
@@ -316,14 +316,14 @@  discard block
 block discarded – undo
316 316
         $foundFreePort2 = 0;
317 317
         while ($foundFreePort2 == 0) {
318 318
             $portCandidate = random_int(1200, 65535);
319
-            $check = $this->databaseHandle->exec("SELECT port_instance_2 FROM deployment WHERE radius_instance_2 = '" . $ourSecondServer . "' AND port_instance_2 = $portCandidate");
319
+            $check = $this->databaseHandle->exec("SELECT port_instance_2 FROM deployment WHERE radius_instance_2 = '".$ourSecondServer."' AND port_instance_2 = $portCandidate");
320 320
             if (mysqli_num_rows(/** @scrutinizer ignore-type */ $check) == 0) {
321 321
                 $foundFreePort2 = $portCandidate;
322 322
             }
323 323
         }
324 324
         // and make up a shared secret that is halfways readable
325 325
         $futureSecret = $this->randomString(16, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
326
-        $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");
326
+        $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");
327 327
         return ["port_instance_1" => $foundFreePort1, "port_instance_2" => $foundFreePort2, "secret" => $futureSecret, "radius_instance_1" => $ourserver, "radius_instance_2" => $ourserver];
328 328
     }
329 329
 
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
      */
371 371
     public function deactivate()
372 372
     {
373
-        $this->databaseHandle->exec("UPDATE deployment SET status = " . DeploymentManaged::INACTIVE . " WHERE deployment_id = $this->identifier");
373
+        $this->databaseHandle->exec("UPDATE deployment SET status = ".DeploymentManaged::INACTIVE." WHERE deployment_id = $this->identifier");
374 374
     }
375 375
 
376 376
     /**
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
      */
382 382
     public function activate()
383 383
     {
384
-        $this->databaseHandle->exec("UPDATE deployment SET status = " . DeploymentManaged::ACTIVE . " WHERE deployment_id = $this->identifier");
384
+        $this->databaseHandle->exec("UPDATE deployment SET status = ".DeploymentManaged::ACTIVE." WHERE deployment_id = $this->identifier");
385 385
     }
386 386
 
387 387
     /**
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
     {
394 394
         $customAttrib = $this->getAttributes("managedsp:operatorname");
395 395
         if (count($customAttrib) == 0) {
396
-            return "1sp." . $this->identifier . "-" . $this->institution . \config\ConfAssistant::SILVERBULLET['realm_suffix'];
396
+            return "1sp.".$this->identifier."-".$this->institution.\config\ConfAssistant::SILVERBULLET['realm_suffix'];
397 397
         }
398 398
         return $customAttrib[0]["value"];
399 399
     }
@@ -409,13 +409,13 @@  discard block
 block discarded – undo
409 409
     {
410 410
 
411 411
         $hostname = "radius_hostname_$idx";
412
-        $ch = curl_init("http://" . $this->$hostname);
412
+        $ch = curl_init("http://".$this->$hostname);
413 413
         if ($ch === FALSE) {
414 414
             $res = 'FAILURE';
415 415
         } else {
416 416
             curl_setopt($ch, CURLOPT_POST, 1);
417 417
             curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
418
-            $this->loggerInstance->debug(1, "Posting to http://" . $this->$hostname . ": $post\n");
418
+            $this->loggerInstance->debug(1, "Posting to http://".$this->$hostname.": $post\n");
419 419
             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
420 420
             curl_setopt($ch, CURLOPT_HEADER, 0);
421 421
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
             $this->loggerInstance->debug(1, $this);
432 432
         }
433 433
         $this->loggerInstance->debug(1, "Database update");
434
-        $this->databaseHandle->exec("UPDATE deployment SET radius_status_$idx = " . ($res == 'OK' ? \core\AbstractDeployment::RADIUS_OK : \core\AbstractDeployment::RADIUS_FAILURE) . " WHERE deployment_id = $this->identifier");
434
+        $this->databaseHandle->exec("UPDATE deployment SET radius_status_$idx = ".($res == 'OK' ? \core\AbstractDeployment::RADIUS_OK : \core\AbstractDeployment::RADIUS_FAILURE)." WHERE deployment_id = $this->identifier");
435 435
         return $res;
436 436
     }
437 437
 
@@ -452,19 +452,19 @@  discard block
 block discarded – undo
452 452
         } else {
453 453
             $txt = $remove ? _('Profile dectivation failed') : _('Profile activation/modification failed');
454 454
         }
455
-        $txt = $txt . ' ';
455
+        $txt = $txt.' ';
456 456
         if (array_count_values($response)[$status] == 2) {
457
-            $txt = $txt . _('on both RADIUS servers: primary and backup') . '.';
457
+            $txt = $txt._('on both RADIUS servers: primary and backup').'.';
458 458
         } else {
459 459
             if ($response['res[1]'] == $status) {
460
-                $txt = $txt . _('on primary RADIUS server') . '.';
460
+                $txt = $txt._('on primary RADIUS server').'.';
461 461
             } else {
462
-                $txt = $txt . _('on backup RADIUS server') . '.';
462
+                $txt = $txt._('on backup RADIUS server').'.';
463 463
             }
464 464
         }
465 465
         $mail = \core\common\OutsideComm::mailHandle();
466 466
         $email = $this->getAttributes("support:email")[0]['value'];
467
-        $mail->FromName = \config\Master::APPEARANCE['productname'] . " Notification System";
467
+        $mail->FromName = \config\Master::APPEARANCE['productname']." Notification System";
468 468
         $mail->addAddress($email);
469 469
         if ($status == 'OK') {
470 470
             $mail->Subject = _('RADIUS profile update problem fixed');
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
             return NULL;
499 499
         }
500 500
         $timeout = 10;
501
-        curl_setopt($ch, CURLOPT_URL, 'http://' . $host);
501
+        curl_setopt($ch, CURLOPT_URL, 'http://'.$host);
502 502
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
503 503
         curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
504 504
         curl_exec($ch);
@@ -590,35 +590,35 @@  discard block
 block discarded – undo
590 590
     {
591 591
         $remove = ($this->status == \core\AbstractDeployment::INACTIVE) ? 0 : 1;
592 592
         $toPost = ($onlyone ? array($onlyone => '') : array(1 => '', 2 => ''));
593
-        $toPostTemplate = 'instid=' . $this->institution . '&deploymentid=' . $this->identifier . '&secret=' . $this->secret . '&country=' . $this->getAttributes("internal:country")[0]['value'] . '&';
593
+        $toPostTemplate = 'instid='.$this->institution.'&deploymentid='.$this->identifier.'&secret='.$this->secret.'&country='.$this->getAttributes("internal:country")[0]['value'].'&';
594 594
         if ($remove) {
595
-            $toPostTemplate = $toPostTemplate . 'remove=1&';
595
+            $toPostTemplate = $toPostTemplate.'remove=1&';
596 596
         } else {
597 597
             if ($this->getAttributes("managedsp:operatorname")[0]['value'] ?? NULL) {
598
-                $toPostTemplate = $toPostTemplate . 'operatorname=' . $this->getAttributes("managedsp:operatorname")[0]['value'] . '&';
598
+                $toPostTemplate = $toPostTemplate.'operatorname='.$this->getAttributes("managedsp:operatorname")[0]['value'].'&';
599 599
             }
600 600
             if ($this->getAttributes("managedsp:vlan")[0]['value'] ?? NULL) {
601 601
                 $allRealms = $this->getAllRealms();
602 602
                 if (!empty($allRealms)) {
603
-                    $toPostTemplate = $toPostTemplate . 'vlan=' . $this->getAttributes("managedsp:vlan")[0]['value'] . '&';
604
-                    $toPostTemplate = $toPostTemplate . 'realmforvlan[]=' . implode('&realmforvlan[]=', $allRealms) . '&';
603
+                    $toPostTemplate = $toPostTemplate.'vlan='.$this->getAttributes("managedsp:vlan")[0]['value'].'&';
604
+                    $toPostTemplate = $toPostTemplate.'realmforvlan[]='.implode('&realmforvlan[]=', $allRealms).'&';
605 605
                 }
606 606
             }
607 607
         }
608 608
         foreach (array_keys($toPost) as $key) {
609
-            $elem = 'port' . $key;
610
-            $toPost[$key] = $toPostTemplate . 'port=' . $this->$elem;
609
+            $elem = 'port'.$key;
610
+            $toPost[$key] = $toPostTemplate.'port='.$this->$elem;
611 611
         }
612 612
         $response = array();
613 613
         foreach ($toPost as $key => $value) {
614
-            $this->loggerInstance->debug(1, 'toPost ' . $toPost[$key] . "\n");
615
-            $response['res[' . $key . ']'] = $this->sendToRADIUS($key, $toPost[$key]);
614
+            $this->loggerInstance->debug(1, 'toPost '.$toPost[$key]."\n");
615
+            $response['res['.$key.']'] = $this->sendToRADIUS($key, $toPost[$key]);
616 616
         }
617 617
         if ($onlyone) {
618
-            $response['res[' . ($onlyone == 1) ? 2 : 1 . ']'] = \core\AbstractDeployment::RADIUS_OK;
618
+            $response['res['.($onlyone == 1) ? 2 : 1.']'] = \core\AbstractDeployment::RADIUS_OK;
619 619
         }
620 620
         foreach (array('OK', 'FAILURE') as $status) {
621
-            if ( ( ($status == 'OK' && $notify) || ($status == 'FAILURE') ) && ( in_array($status, $response) ) ) {
621
+            if ((($status == 'OK' && $notify) || ($status == 'FAILURE')) && (in_array($status, $response))) {
622 622
                 $this->sendMailtoAdmin($remove, $response, $status);
623 623
             }
624 624
         }
Please login to merge, or discard this patch.