Test Failed
Push — master ( e3ff0d...7df8e1 )
by Maja
08:30 queued 16s
created
core/DeploymentManaged.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -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") {
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
         // only check the consortium pool group we want to attach to
318 318
         // TODO: if we also collect stats from OpenRoaming hosts, differentiate the logs!
319 319
         $opName = $this->getOperatorName();
320
-        $stats = $this->databaseHandle->exec("SELECT activity_time, realm, mac, result FROM activity WHERE operatorname = ? AND activity_time > DATE_SUB(NOW(), INTERVAL ? SECOND) ORDER BY activity_time", "si", $opName, $backlog );
320
+        $stats = $this->databaseHandle->exec("SELECT activity_time, realm, mac, result FROM activity WHERE operatorname = ? AND activity_time > DATE_SUB(NOW(), INTERVAL ? SECOND) ORDER BY activity_time", "si", $opName, $backlog);
321 321
         return mysqli_fetch_all($stats, \MYSQLI_ASSOC);
322 322
     }
323 323
         
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
         $foundFreePort1 = 0;
342 342
         while ($foundFreePort1 == 0) {
343 343
             $portCandidate = random_int(1200, 65535);
344
-            $check = $this->databaseHandle->exec("SELECT port_instance_1 FROM deployment WHERE radius_instance_1 = '" . $ourserver . "' AND port_instance_1 = $portCandidate");
344
+            $check = $this->databaseHandle->exec("SELECT port_instance_1 FROM deployment WHERE radius_instance_1 = '".$ourserver."' AND port_instance_1 = $portCandidate");
345 345
             if (mysqli_num_rows(/** @scrutinizer ignore-type */ $check) == 0) {
346 346
                 $foundFreePort1 = $portCandidate;
347 347
             }
@@ -350,14 +350,14 @@  discard block
 block discarded – undo
350 350
         $foundFreePort2 = 0;
351 351
         while ($foundFreePort2 == 0) {
352 352
             $portCandidate = random_int(1200, 65535);
353
-            $check = $this->databaseHandle->exec("SELECT port_instance_2 FROM deployment WHERE radius_instance_2 = '" . $ourSecondServer . "' AND port_instance_2 = $portCandidate");
353
+            $check = $this->databaseHandle->exec("SELECT port_instance_2 FROM deployment WHERE radius_instance_2 = '".$ourSecondServer."' AND port_instance_2 = $portCandidate");
354 354
             if (mysqli_num_rows(/** @scrutinizer ignore-type */ $check) == 0) {
355 355
                 $foundFreePort2 = $portCandidate;
356 356
             }
357 357
         }
358 358
         // and make up a shared secret that is halfways readable
359 359
         $futureSecret = $this->randomString(16, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
360
-        $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");
360
+        $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");
361 361
         return ["port_instance_1" => $foundFreePort1, "port_instance_2" => $foundFreePort2, "secret" => $futureSecret, "radius_instance_1" => $ourserver, "radius_instance_2" => $ourserver];
362 362
     }
363 363
 
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
      */
405 405
     public function deactivate()
406 406
     {
407
-        $this->databaseHandle->exec("UPDATE deployment SET status = " . DeploymentManaged::INACTIVE . " WHERE deployment_id = $this->identifier");
407
+        $this->databaseHandle->exec("UPDATE deployment SET status = ".DeploymentManaged::INACTIVE." WHERE deployment_id = $this->identifier");
408 408
     }
409 409
 
410 410
     /**
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
      */
416 416
     public function activate()
417 417
     {
418
-        $this->databaseHandle->exec("UPDATE deployment SET status = " . DeploymentManaged::ACTIVE . " WHERE deployment_id = $this->identifier");
418
+        $this->databaseHandle->exec("UPDATE deployment SET status = ".DeploymentManaged::ACTIVE." WHERE deployment_id = $this->identifier");
419 419
     }
420 420
 
421 421
     /**
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
     {
428 428
         $customAttrib = $this->getAttributes("managedsp:operatorname");
429 429
         if (count($customAttrib) == 0) {
430
-            return "1sp." . $this->identifier . "-" . $this->institution . \config\ConfAssistant::SILVERBULLET['realm_suffix'];
430
+            return "1sp.".$this->identifier."-".$this->institution.\config\ConfAssistant::SILVERBULLET['realm_suffix'];
431 431
         }
432 432
         return $customAttrib[0]["value"];
433 433
     }
@@ -443,13 +443,13 @@  discard block
 block discarded – undo
443 443
     {
444 444
 
445 445
         $hostname = "radius_hostname_$idx";
446
-        $ch = curl_init("http://" . $this->$hostname);
446
+        $ch = curl_init("http://".$this->$hostname);
447 447
         if ($ch === FALSE) {
448 448
             $res = 'FAILURE';
449 449
         } else {
450 450
             curl_setopt($ch, CURLOPT_POST, 1);
451 451
             curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
452
-            $this->loggerInstance->debug(1, "Posting to http://" . $this->$hostname . ": $post\n");
452
+            $this->loggerInstance->debug(1, "Posting to http://".$this->$hostname.": $post\n");
453 453
             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
454 454
             curl_setopt($ch, CURLOPT_HEADER, 0);
455 455
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
             $this->loggerInstance->debug(1, $this);
466 466
         }
467 467
         $this->loggerInstance->debug(1, "Database update");
468
-        $this->databaseHandle->exec("UPDATE deployment SET radius_status_$idx = " . ($res == 'OK' ? \core\AbstractDeployment::RADIUS_OK : \core\AbstractDeployment::RADIUS_FAILURE) . " WHERE deployment_id = $this->identifier");
468
+        $this->databaseHandle->exec("UPDATE deployment SET radius_status_$idx = ".($res == 'OK' ? \core\AbstractDeployment::RADIUS_OK : \core\AbstractDeployment::RADIUS_FAILURE)." WHERE deployment_id = $this->identifier");
469 469
         return $res;
470 470
     }
471 471
 
@@ -486,19 +486,19 @@  discard block
 block discarded – undo
486 486
         } else {
487 487
             $txt = $remove ? _('Profile deactivation failed') : _('Profile activation/modification failed');
488 488
         }
489
-        $txt = $txt . ' ';
489
+        $txt = $txt.' ';
490 490
         if (array_count_values($response)[$status] == 2) {
491
-            $txt = $txt . _('on both RADIUS servers: primary and backup') . '.';
491
+            $txt = $txt._('on both RADIUS servers: primary and backup').'.';
492 492
         } else {
493 493
             if ($response['res[1]'] == $status) {
494
-                $txt = $txt . _('on primary RADIUS server') . '.';
494
+                $txt = $txt._('on primary RADIUS server').'.';
495 495
             } else {
496
-                $txt = $txt . _('on backup RADIUS server') . '.';
496
+                $txt = $txt._('on backup RADIUS server').'.';
497 497
             }
498 498
         }
499 499
         $mail = \core\common\OutsideComm::mailHandle();
500 500
         $email = $this->getAttributes("support:email")[0]['value'];
501
-        $mail->FromName = \config\Master::APPEARANCE['productname'] . " Notification System";
501
+        $mail->FromName = \config\Master::APPEARANCE['productname']." Notification System";
502 502
         $mail->addAddress($email);
503 503
         if ($status == 'OK') {
504 504
             $mail->Subject = _('RADIUS profile update problem fixed');
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
             return NULL;
533 533
         }
534 534
         $timeout = 10;
535
-        curl_setopt($ch, CURLOPT_URL, 'http://' . $host);
535
+        curl_setopt($ch, CURLOPT_URL, 'http://'.$host);
536 536
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
537 537
         curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
538 538
         curl_exec($ch);
@@ -624,33 +624,33 @@  discard block
 block discarded – undo
624 624
     {
625 625
         $remove = ($this->status == \core\AbstractDeployment::INACTIVE) ? 0 : 1;
626 626
         $toPost = ($onlyone ? array($onlyone => '') : array(1 => '', 2 => ''));
627
-        $toPostTemplate = 'instid=' . $this->institution . '&deploymentid=' . $this->identifier . '&secret=' . $this->secret . '&country=' . $this->getAttributes("internal:country")[0]['value'] . '&';
627
+        $toPostTemplate = 'instid='.$this->institution.'&deploymentid='.$this->identifier.'&secret='.$this->secret.'&country='.$this->getAttributes("internal:country")[0]['value'].'&';
628 628
         if ($remove) {
629
-            $toPostTemplate = $toPostTemplate . 'remove=1&';
629
+            $toPostTemplate = $toPostTemplate.'remove=1&';
630 630
         } else {
631
-            $toPostTemplate = $toPostTemplate . 'operatorname=' . $this->getOperatorName() . '&'; 
631
+            $toPostTemplate = $toPostTemplate.'operatorname='.$this->getOperatorName().'&'; 
632 632
             if ($this->getAttributes("managedsp:vlan")[0]['value'] ?? NULL) {
633 633
                 $allRealms = $this->getAllRealms();
634 634
                 if (!empty($allRealms)) {
635
-                    $toPostTemplate = $toPostTemplate . 'vlan=' . $this->getAttributes("managedsp:vlan")[0]['value'] . '&';
636
-                    $toPostTemplate = $toPostTemplate . 'realmforvlan[]=' . implode('&realmforvlan[]=', $allRealms) . '&';
635
+                    $toPostTemplate = $toPostTemplate.'vlan='.$this->getAttributes("managedsp:vlan")[0]['value'].'&';
636
+                    $toPostTemplate = $toPostTemplate.'realmforvlan[]='.implode('&realmforvlan[]=', $allRealms).'&';
637 637
                 }
638 638
             }
639 639
         }
640 640
         foreach (array_keys($toPost) as $key) {
641
-            $elem = 'port' . $key;
642
-            $toPost[$key] = $toPostTemplate . 'port=' . $this->$elem;
641
+            $elem = 'port'.$key;
642
+            $toPost[$key] = $toPostTemplate.'port='.$this->$elem;
643 643
         }
644 644
         $response = array();
645 645
         foreach ($toPost as $key => $value) {
646
-            $this->loggerInstance->debug(1, 'toPost ' . $toPost[$key] . "\n");
647
-            $response['res[' . $key . ']'] = $this->sendToRADIUS($key, $toPost[$key]);
646
+            $this->loggerInstance->debug(1, 'toPost '.$toPost[$key]."\n");
647
+            $response['res['.$key.']'] = $this->sendToRADIUS($key, $toPost[$key]);
648 648
         }
649 649
         if ($onlyone) {
650
-            $response['res[' . ($onlyone == 1) ? 2 : 1 . ']'] = \core\AbstractDeployment::RADIUS_OK;
650
+            $response['res['.($onlyone == 1) ? 2 : 1.']'] = \core\AbstractDeployment::RADIUS_OK;
651 651
         }
652 652
         foreach (array('OK', 'FAILURE') as $status) {
653
-            if ( ( ($status == 'OK' && $notify) || ($status == 'FAILURE') ) && ( in_array($status, $response) ) ) {
653
+            if ((($status == 'OK' && $notify) || ($status == 'FAILURE')) && (in_array($status, $response))) {
654 654
                 $this->sendMailtoAdmin($remove, $response, $status);
655 655
             }
656 656
         }
Please login to merge, or discard this patch.