Passed
Push — master ( c57d81...3d7ab7 )
by Maja
06:49
created
core/DeploymentManaged.php 2 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -432,8 +432,9 @@
 block discarded – undo
432 432
         $mail->Body = $txt;
433 433
 
434 434
         $sent = $mail->send();
435
-        if ( $sent === FALSE)
436
-        $this->loggerInstance->debug(1, 'Mailing on RADIUS problem failed');
435
+        if ( $sent === FALSE) {
436
+                $this->loggerInstance->debug(1, 'Mailing on RADIUS problem failed');
437
+        }
437 438
     }
438 439
     /**
439 440
      * prepare request to add/modify RADIUS settings for given deployment
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
                 $serverCandidates[IdPlist::geoDistance($adminLocation, ['lat' => $iterator->location_lat, 'lon' => $iterator->location_lon])] = $iterator->server_id;
251 251
             }
252 252
             if ($clients > $maxSupportedClients * 0.9) {
253
-                $this->loggerInstance->debug(1, "A RADIUS server for Managed SP (" . $iterator->server_id . ") is serving at more than 90% capacity!");
253
+                $this->loggerInstance->debug(1, "A RADIUS server for Managed SP (".$iterator->server_id.") is serving at more than 90% capacity!");
254 254
             }
255 255
         }
256 256
         if (count($serverCandidates) == 0 && $federation != "DEFAULT") {
@@ -281,28 +281,28 @@  discard block
 block discarded – undo
281 281
             $ourLocation = ['lon' => $geoip['geo']['lon'], 'lat' => $geoip['geo']['lat']];
282 282
         }
283 283
         $inst = new IdP($this->institution);
284
-        $ourserver = $this->findGoodServerLocation($ourLocation, $inst->federation , []);
284
+        $ourserver = $this->findGoodServerLocation($ourLocation, $inst->federation, []);
285 285
         // now, find an unused port in the preferred server
286 286
         $foundFreePort1 = 0;
287 287
         while ($foundFreePort1 == 0) {
288 288
             $portCandidate = random_int(1200, 65535);
289
-            $check = $this->databaseHandle->exec("SELECT port_instance_1 FROM deployment WHERE radius_instance_1 = '" . $ourserver . "' AND port_instance_1 = $portCandidate");
289
+            $check = $this->databaseHandle->exec("SELECT port_instance_1 FROM deployment WHERE radius_instance_1 = '".$ourserver."' AND port_instance_1 = $portCandidate");
290 290
             if (mysqli_num_rows(/** @scrutinizer ignore-type */ $check) == 0) {
291 291
                 $foundFreePort1 = $portCandidate;
292 292
             }
293 293
         }
294
-        $ourSecondServer = $this->findGoodServerLocation($ourLocation, $inst->federation , [$ourserver]);
294
+        $ourSecondServer = $this->findGoodServerLocation($ourLocation, $inst->federation, [$ourserver]);
295 295
         $foundFreePort2 = 0;
296 296
         while ($foundFreePort2 == 0) {
297 297
             $portCandidate = random_int(1200, 65535);
298
-            $check = $this->databaseHandle->exec("SELECT port_instance_2 FROM deployment WHERE radius_instance_2 = '" . $ourSecondServer . "' AND port_instance_2 = $portCandidate");
298
+            $check = $this->databaseHandle->exec("SELECT port_instance_2 FROM deployment WHERE radius_instance_2 = '".$ourSecondServer."' AND port_instance_2 = $portCandidate");
299 299
             if (mysqli_num_rows(/** @scrutinizer ignore-type */ $check) == 0) {
300 300
                 $foundFreePort2 = $portCandidate;
301 301
             }
302 302
         }
303 303
         // and make up a shared secret that is halfways readable
304 304
         $futureSecret = $this->randomString(16, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
305
-        $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");
305
+        $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");
306 306
         return ["port_instance_1" => $foundFreePort1, "port_instance_2" => $foundFreePort2, "secret" => $futureSecret, "radius_instance_1" => $ourserver, "radius_instance_2" => $ourserver];
307 307
     }
308 308
 
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
      * @return void
346 346
      */
347 347
     public function deactivate() {
348
-        $this->databaseHandle->exec("UPDATE deployment SET status = " . DeploymentManaged::INACTIVE . " WHERE deployment_id = $this->identifier");
348
+        $this->databaseHandle->exec("UPDATE deployment SET status = ".DeploymentManaged::INACTIVE." WHERE deployment_id = $this->identifier");
349 349
     }
350 350
 
351 351
     /**
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
      * @return void
356 356
      */
357 357
     public function activate() {
358
-        $this->databaseHandle->exec("UPDATE deployment SET status = " . DeploymentManaged::ACTIVE . " WHERE deployment_id = $this->identifier");
358
+        $this->databaseHandle->exec("UPDATE deployment SET status = ".DeploymentManaged::ACTIVE." WHERE deployment_id = $this->identifier");
359 359
     }
360 360
 
361 361
     /**
@@ -381,17 +381,17 @@  discard block
 block discarded – undo
381 381
     public function sendToRADIUS($idx, $post) {
382 382
             
383 383
         $hostname = "radius_hostname_$idx";
384
-        $ch = curl_init( "http://" . $this->$hostname );
384
+        $ch = curl_init("http://".$this->$hostname);
385 385
         if ($ch === FALSE) {
386 386
             $res = 'FAILURE';
387 387
         } else {
388
-            curl_setopt( $ch, CURLOPT_POST, 1);
389
-            curl_setopt( $ch, CURLOPT_POSTFIELDS, $post);
390
-            $this->loggerInstance->debug(1, "Posting to http://" . $this->$hostname . ": $post\n");
391
-            curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
392
-            curl_setopt( $ch, CURLOPT_HEADER, 0);
393
-            curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
394
-            $exec = curl_exec( $ch );
388
+            curl_setopt($ch, CURLOPT_POST, 1);
389
+            curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
390
+            $this->loggerInstance->debug(1, "Posting to http://".$this->$hostname.": $post\n");
391
+            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
392
+            curl_setopt($ch, CURLOPT_HEADER, 0);
393
+            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
394
+            $exec = curl_exec($ch);
395 395
             if ($exec === FALSE) {
396 396
                 $res = 'FAILURE';
397 397
             } else {
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
             $this->loggerInstance->debug(1, "Response from FR configurator: $res\n");
401 401
             $this->loggerInstance->debug(1, $this);           
402 402
         }
403
-        $this->databaseHandle->exec("UPDATE deployment SET radius_status_$idx = " . ($res == 'OK'? \core\AbstractDeployment::RADIUS_OK : \core\AbstractDeployment::RADIUS_FAILURE) . " WHERE deployment_id = $this->identifier");
403
+        $this->databaseHandle->exec("UPDATE deployment SET radius_status_$idx = ".($res == 'OK' ? \core\AbstractDeployment::RADIUS_OK : \core\AbstractDeployment::RADIUS_FAILURE)." WHERE deployment_id = $this->identifier");
404 404
         return $res;
405 405
     }
406 406
     /**
@@ -414,28 +414,28 @@  discard block
 block discarded – undo
414 414
     private function sendMailtoAdmin($remove, $response) {
415 415
         $txt = '';
416 416
         if ($remove) {
417
-            $txt = _('Profile dectivation failed' . ' ');
417
+            $txt = _('Profile dectivation failed'.' ');
418 418
         } else {
419
-            $txt = _('Profile activation/modification failed' . ' ');
419
+            $txt = _('Profile activation/modification failed'.' ');
420 420
         }
421 421
         if (array_count_values($response)['FAILURE'] == 2) {
422
-            $txt = $txt . _('on both RADIUS servers: primary and backup') . '.';
422
+            $txt = $txt._('on both RADIUS servers: primary and backup').'.';
423 423
         } else {
424 424
             if ($response['res[1]'] == 'FAILURE') {
425
-                $txt = $txt . _('on primary RADIUS server') . '.';
425
+                $txt = $txt._('on primary RADIUS server').'.';
426 426
             } else {
427
-                $txt = $txt . _('on backup RADIUS server') . '.';
427
+                $txt = $txt._('on backup RADIUS server').'.';
428 428
             }
429 429
         }
430 430
         $mail = \core\common\OutsideComm::mailHandle();
431 431
         $email = $this->getAttributes("support:email")[0]['value'];
432
-        $mail->FromName = \config\Master::APPEARANCE['productname'] . " Notification System";
432
+        $mail->FromName = \config\Master::APPEARANCE['productname']." Notification System";
433 433
         $mail->addAddress($email);
434 434
         $mail->Subject = _('RADIUS profile update problem');
435 435
         $mail->Body = $txt;
436 436
 
437 437
         $sent = $mail->send();
438
-        if ( $sent === FALSE)
438
+        if ($sent === FALSE)
439 439
         $this->loggerInstance->debug(1, 'Mailing on RADIUS problem failed');
440 440
     }
441 441
     /**
@@ -448,18 +448,18 @@  discard block
 block discarded – undo
448 448
     public function setRADIUSconfig($remove = 0, $onlyone = 0) {
449 449
         $toPost = array();
450 450
         if ($onlyone) {
451
-            $toPost[$onlyone]  = '';
451
+            $toPost[$onlyone] = '';
452 452
         } else {
453 453
             // run on both servers
454 454
             $toPost[1] = '';
455 455
             $toPost[2] = '';
456 456
         }
457
-        $toPostTemplate = 'instid=' . $this->institution . '&deploymentid=' . $this->identifier . '&secret=' . $this->secret . '&country=' . $this->getAttributes("internal:country")[0]['value'] . '&';
457
+        $toPostTemplate = 'instid='.$this->institution.'&deploymentid='.$this->identifier.'&secret='.$this->secret.'&country='.$this->getAttributes("internal:country")[0]['value'].'&';
458 458
         if ($remove) {
459
-            $toPostTemplate = $toPostTemplate . 'remove=1&';
459
+            $toPostTemplate = $toPostTemplate.'remove=1&';
460 460
         } else {
461 461
             if ($this->getAttributes("managedsp:operatorname")[0]['value'] ?? NULL) {
462
-                $toPostTemplate = $toPostTemplate . 'operatorname=' . $this->getAttributes("managedsp:operatorname")[0]['value'] . '&';
462
+                $toPostTemplate = $toPostTemplate.'operatorname='.$this->getAttributes("managedsp:operatorname")[0]['value'].'&';
463 463
             }
464 464
             if ($this->getAttributes("managedsp:vlan")[0]['value'] ?? NULL) {
465 465
                 $idp = new IdP($this->institution);
@@ -476,25 +476,25 @@  discard block
 block discarded – undo
476 476
                     }
477 477
                 }
478 478
                 if (!empty($allRealms)) {
479
-                    $toPostTemplate = $toPostTemplate . 'vlan=' . $this->getAttributes("managedsp:vlan")[0]['value'] . '&';
480
-                    $toPostTemplate = $toPostTemplate . 'realmforvlan[]=' . implode('&realmforvlan[]=', $allRealms) . '&';
479
+                    $toPostTemplate = $toPostTemplate.'vlan='.$this->getAttributes("managedsp:vlan")[0]['value'].'&';
480
+                    $toPostTemplate = $toPostTemplate.'realmforvlan[]='.implode('&realmforvlan[]=', $allRealms).'&';
481 481
                 }
482 482
             }
483 483
         }
484 484
         foreach (array_keys($toPost) as $key) {
485 485
             if ($key == 1) {
486
-                $toPost[$key] = $toPostTemplate . 'port=' . $this->port1;
486
+                $toPost[$key] = $toPostTemplate.'port='.$this->port1;
487 487
             } else {
488
-                $toPost[$key] = $toPostTemplate . 'port=' . $this->port2;
488
+                $toPost[$key] = $toPostTemplate.'port='.$this->port2;
489 489
             }      
490 490
         }
491 491
         $response = array();
492 492
         foreach ($toPost as $key => $value) {
493
-            $this->loggerInstance->debug(1, 'toPost ' . $toPost[$key] ."\n");
493
+            $this->loggerInstance->debug(1, 'toPost '.$toPost[$key]."\n");
494 494
             $response['res['.$key.']'] = $this->sendToRADIUS($key, $toPost[$key]);
495 495
         }
496 496
         if ($onlyone) {
497
-            $response['res['.($onlyone==1)? 2 : 1 . ']'] = \core\AbstractDeployment::RADIUS_OK;
497
+            $response['res['.($onlyone == 1) ? 2 : 1.']'] = \core\AbstractDeployment::RADIUS_OK;
498 498
         }
499 499
         if (in_array('FAILURE', $response)) {
500 500
             $this->sendMailtoAdmin($remove, $response);
Please login to merge, or discard this patch.
web/admin/edit_hotspot.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  */
27 27
 ?>
28 28
 <?php
29
-require_once dirname(dirname(dirname(__FILE__))) . "/config/_config.php";
29
+require_once dirname(dirname(dirname(__FILE__)))."/config/_config.php";
30 30
 
31 31
 $deco = new \web\lib\admin\PageDecoration();
32 32
 $validator = new \web\lib\common\InputValidation();
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
 if (!isset($_GET['deployment_id'])) {
38 38
     $my_inst->newDeployment(\core\AbstractDeployment::DEPLOYMENTTYPE_MANAGED);
39
-    header("Location: overview_sp.php?inst_id=" . $my_inst->identifier);
39
+    header("Location: overview_sp.php?inst_id=".$my_inst->identifier);
40 40
     exit(0);
41 41
 }
42 42
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         if (in_array('OK', $response)) {
51 51
             $deployment->deactivate();
52 52
         }
53
-        header("Location: overview_sp.php?inst_id=" . $my_inst->identifier . '&' . urldecode(http_build_query($response)));
53
+        header("Location: overview_sp.php?inst_id=".$my_inst->identifier.'&'.urldecode(http_build_query($response)));
54 54
         exit(0);
55 55
     }
56 56
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         if (in_array('OK', $response)) {
60 60
             $deployment->activate();
61 61
         }
62
-        header("Location: overview_sp.php?inst_id=" . $my_inst->identifier . '&' . urldecode(http_build_query($response)));
62
+        header("Location: overview_sp.php?inst_id=".$my_inst->identifier.'&'.urldecode(http_build_query($response)));
63 63
         exit(0);
64 64
     }
65 65
     
@@ -74,11 +74,11 @@  discard block
 block discarded – undo
74 74
             if (in_array(2, $_POST['update']) && !in_array(1, $_POST['update'])) {
75 75
                 $which = 2;
76 76
             }
77
-            $response = $deployment->setRADIUSconfig(($deployment->status == 0)? 1 : 0, $which);
77
+            $response = $deployment->setRADIUSconfig(($deployment->status == 0) ? 1 : 0, $which);
78 78
         } else {
79 79
             $response = array();
80 80
         }
81
-        header("Location: overview_sp.php?inst_id=" . $my_inst->identifier . '&' . urldecode(http_build_query($response)));
81
+        header("Location: overview_sp.php?inst_id=".$my_inst->identifier.'&'.urldecode(http_build_query($response)));
82 82
         exit(0);
83 83
     }
84 84
     
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
         if ($deployment->status == core\DeploymentManaged::ACTIVE) {
99 99
             $response = $deployment->setRADIUSconfig();
100 100
         }
101
-        header("Location: overview_sp.php?inst_id=" . $my_inst->identifier . '&' . urldecode(http_build_query($response)));
101
+        header("Location: overview_sp.php?inst_id=".$my_inst->identifier.'&'.urldecode(http_build_query($response)));
102 102
         exit(0);
103 103
     }
104 104
 }
@@ -126,12 +126,12 @@  discard block
 block discarded – undo
126 126
     echo $uiElements->instLevelInfoBoxes($my_inst);
127 127
     $deploymentOptions = $deployment->getAttributes();
128 128
     echo "<form enctype='multipart/form-data' action='edit_hotspot.php?inst_id=$my_inst->identifier&amp;deployment_id=$deployment->identifier' method='post' accept-charset='UTF-8'>
129
-                <input type='hidden' name='MAX_FILE_SIZE' value='" . \config\Master::MAX_UPLOAD_SIZE . "'>";
129
+                <input type='hidden' name='MAX_FILE_SIZE' value='".\config\Master::MAX_UPLOAD_SIZE."'>";
130 130
     $optionDisplay = new \web\lib\admin\OptionDisplay($deploymentOptions, "Profile");
131 131
     ?>
132 132
     <?php
133 133
     echo "<fieldset class='option_container' id='managedsp_override'>
134
-    <legend><strong>" . _("Options for this deployment") . "</strong></legend>";
134
+    <legend><strong>" . _("Options for this deployment")."</strong></legend>";
135 135
     ?>
136 136
     <table>
137 137
         <tr>
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
             <!-- input for VLAN identifier for home users-->
150 150
             <td>
151 151
                 <span id='vlan_label'>
152
-                    <?php echo sprintf(_("VLAN tag for own users%s:"), ($vlan === NULL ? "" : " " . _("(unset with '0')"))); ?>
152
+                    <?php echo sprintf(_("VLAN tag for own users%s:"), ($vlan === NULL ? "" : " "._("(unset with '0')"))); ?>
153 153
                 </span>
154 154
             </td>
155 155
             <td>
@@ -164,10 +164,10 @@  discard block
 block discarded – undo
164 164
     </table>
165 165
     <?php
166 166
     echo $optionDisplay->prefilledOptionTable("managedsp");
167
-    echo "<button type='button' class='newoption' onclick='getXML(\"managedsp\")'>" . _("Add new option") . "</button>";
167
+    echo "<button type='button' class='newoption' onclick='getXML(\"managedsp\")'>"._("Add new option")."</button>";
168 168
     echo "</fieldset>";
169 169
 
170 170
 
171
-    echo "<p><button type='submit' name='submitbutton' value='" . web\lib\common\FormElements::BUTTON_SAVE . "'>" . _("Save data") . "</button><button type='button' class='delete' name='abortbutton' value='abort' onclick='javascript:window.location = \"overview_sp.php?inst_id=$my_inst->identifier\"'>" . _("Discard changes") . "</button></p></form>";
171
+    echo "<p><button type='submit' name='submitbutton' value='".web\lib\common\FormElements::BUTTON_SAVE."'>"._("Save data")."</button><button type='button' class='delete' name='abortbutton' value='abort' onclick='javascript:window.location = \"overview_sp.php?inst_id=$my_inst->identifier\"'>"._("Discard changes")."</button></p></form>";
172 172
     echo $deco->footer();
173 173
     
Please login to merge, or discard this patch.