Completed
Pull Request — master (#532)
06:37
created
functions/classes/class.Radius.php 2 patches
Doc Comments   +34 added lines patch added patch discarded remove patch
@@ -355,30 +355,45 @@  discard block
 block discarded – undo
355 355
     }
356 356
 
357 357
 
358
+    /**
359
+     * @param integer $packet_code
360
+     */
358 361
     function SetPacketCodeToSend($packet_code)
359 362
     {
360 363
         $this->_radius_packet_to_send = $packet_code;
361 364
     }
362 365
 
363 366
 
367
+    /**
368
+     * @param boolean $debug_mode
369
+     */
364 370
     function SetDebugMode($debug_mode)
365 371
     {
366 372
         $this->_debug_mode = (TRUE === $debug_mode);
367 373
     }
368 374
 
369 375
 
376
+    /**
377
+     * @param string $ip_radius_server
378
+     */
370 379
     function SetIpRadiusServer($ip_radius_server)
371 380
     {
372 381
         $this->_ip_radius_server = gethostbyname($ip_radius_server);
373 382
     }
374 383
 
375 384
 
385
+    /**
386
+     * @param string $shared_secret
387
+     */
376 388
     function SetSharedSecret($shared_secret)
377 389
     {
378 390
         $this->_shared_secret = $shared_secret;
379 391
     }
380 392
 
381 393
 
394
+    /**
395
+     * @param string $radius_suffix
396
+     */
382 397
     function SetRadiusSuffix($radius_suffix)
383 398
     {
384 399
         $this->_radius_suffix = $radius_suffix;
@@ -468,6 +483,9 @@  discard block
 block discarded – undo
468 483
     }
469 484
 
470 485
 
486
+    /**
487
+     * @param integer $authentication_port
488
+     */
471 489
     function SetAuthenticationPort($authentication_port)
472 490
     {
473 491
         if ((intval($authentication_port) > 0) && (intval($authentication_port) < 65536))
@@ -477,6 +495,9 @@  discard block
 block discarded – undo
477 495
     }
478 496
 
479 497
 
498
+    /**
499
+     * @param integer $accounting_port
500
+     */
480 501
     function SetAccountingPort($accounting_port)
481 502
     {
482 503
         if ((intval($accounting_port) > 0) && (intval($accounting_port) < 65536))
@@ -541,6 +562,9 @@  discard block
 block discarded – undo
541 562
     }
542 563
 
543 564
 
565
+    /**
566
+     * @param integer $info_index
567
+     */
544 568
     function GetRadiusPacketInfo($info_index)
545 569
     {
546 570
         if (isset($this->_radius_packet_info[intval($info_index)]))
@@ -567,6 +591,9 @@  discard block
 block discarded – undo
567 591
     }
568 592
 
569 593
 
594
+    /**
595
+     * @param string $debug_info
596
+     */
570 597
     function DebugInfo($debug_info)
571 598
     {
572 599
         if ($this->_debug_mode)
@@ -577,6 +604,9 @@  discard block
 block discarded – undo
577 604
     }
578 605
 
579 606
 
607
+    /**
608
+     * @param integer $type
609
+     */
580 610
     function SetAttribute($type, $value)
581 611
     {
582 612
         $attribute_index = -1;
@@ -631,6 +661,10 @@  discard block
 block discarded – undo
631 661
     }
632 662
 
633 663
 
664
+    /**
665
+     * @param string $attribute_raw_value
666
+     * @param integer $attribute_format
667
+     */
634 668
     function DecodeAttribute($attribute_raw_value, $attribute_format)
635 669
     {
636 670
         $attribute_value = NULL;
Please login to merge, or discard this patch.
Spacing   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -182,32 +182,32 @@  discard block
 block discarded – undo
182 182
  *********************************************************************/
183 183
 class Radius
184 184
 {
185
-    var $_ip_radius_server;       // Radius server IP address
186
-    var $_shared_secret;          // Shared secret with the radius server
187
-    var $_radius_suffix;          // Radius suffix (default is '');
188
-    var $_udp_timeout;            // Timeout of the UDP connection in seconds (default value is 5)
189
-    var $_authentication_port;    // Authentication port (default value is 1812)
190
-    var $_accounting_port;        // Accouting port (default value is 1813)
191
-    var $_nas_ip_address;         // NAS IP address
192
-    var $_nas_port;               // NAS port
193
-    var $_encrypted_password;     // Encrypted password, as described in the RFC 2865
194
-    var $_user_ip_address;        // Remote IP address of the user
195
-    var $_request_authenticator;  // Request-Authenticator, 16 octets random number
185
+    var $_ip_radius_server; // Radius server IP address
186
+    var $_shared_secret; // Shared secret with the radius server
187
+    var $_radius_suffix; // Radius suffix (default is '');
188
+    var $_udp_timeout; // Timeout of the UDP connection in seconds (default value is 5)
189
+    var $_authentication_port; // Authentication port (default value is 1812)
190
+    var $_accounting_port; // Accouting port (default value is 1813)
191
+    var $_nas_ip_address; // NAS IP address
192
+    var $_nas_port; // NAS port
193
+    var $_encrypted_password; // Encrypted password, as described in the RFC 2865
194
+    var $_user_ip_address; // Remote IP address of the user
195
+    var $_request_authenticator; // Request-Authenticator, 16 octets random number
196 196
     var $_response_authenticator; // Request-Authenticator, 16 octets random number
197
-    var $_username;               // Username to sent to the Radius server
198
-    var $_password;               // Password to sent to the Radius server (clear password, must be encrypted)
199
-    var $_identifier_to_send;     // Identifier field for the packet to be sent
200
-    var $_identifier_received;    // Identifier field for the received packet
201
-    var $_radius_packet_to_send;  // Radius packet code (1=Access-Request, 2=Access-Accept, 3=Access-Reject, 4=Accounting-Request, 5=Accounting-Response, 11=Access-Challenge, 12=Status-Server (experimental), 13=Status-Client (experimental), 255=Reserved
197
+    var $_username; // Username to sent to the Radius server
198
+    var $_password; // Password to sent to the Radius server (clear password, must be encrypted)
199
+    var $_identifier_to_send; // Identifier field for the packet to be sent
200
+    var $_identifier_received; // Identifier field for the received packet
201
+    var $_radius_packet_to_send; // Radius packet code (1=Access-Request, 2=Access-Accept, 3=Access-Reject, 4=Accounting-Request, 5=Accounting-Response, 11=Access-Challenge, 12=Status-Server (experimental), 13=Status-Client (experimental), 255=Reserved
202 202
     var $_radius_packet_received; // Radius packet code (1=Access-Request, 2=Access-Accept, 3=Access-Reject, 4=Accounting-Request, 5=Accounting-Response, 11=Access-Challenge, 12=Status-Server (experimental), 13=Status-Client (experimental), 255=Reserved
203
-    var $_attributes_to_send;     // Radius attributes to send
204
-    var $_attributes_received;    // Radius attributes received
205
-    var $_socket_to_server;       // Socket connection
206
-    var $_debug_mode;             // Debug mode flag
207
-    var $_attributes_info;        // Attributes info array
208
-    var $_radius_packet_info;     // Radius packet codes info array
209
-    var $_last_error_code;        // Last error code
210
-    var $_last_error_message;     // Last error message
203
+    var $_attributes_to_send; // Radius attributes to send
204
+    var $_attributes_received; // Radius attributes received
205
+    var $_socket_to_server; // Socket connection
206
+    var $_debug_mode; // Debug mode flag
207
+    var $_attributes_info; // Attributes info array
208
+    var $_radius_packet_info; // Radius packet codes info array
209
+    var $_last_error_code; // Last error code
210
+    var $_last_error_message; // Last error message
211 211
 
212 212
 
213 213
     /*********************************************************************
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
      * @param integer accounting port
228 228
      * @return NULL
229 229
      *********************************************************************/
230
-    public function Radius($ip_radius_server = '127.0.0.1', $shared_secret = '', $radius_suffix = '', $udp_timeout = 5, $authentication_port = 1812, $accounting_port = 1813)
230
+    public function Radius ($ip_radius_server = '127.0.0.1', $shared_secret = '', $radius_suffix = '', $udp_timeout = 5, $authentication_port = 1812, $accounting_port = 1813)
231 231
     {
232 232
         $this->_radius_packet_info[1] = 'Access-Request';
233 233
         $this->_radius_packet_info[2] = 'Access-Accept';
@@ -239,96 +239,96 @@  discard block
 block discarded – undo
239 239
         $this->_radius_packet_info[13] = 'Status-Client (experimental)';
240 240
         $this->_radius_packet_info[255] = 'Reserved';
241 241
 
242
-        $this->_attributes_info[1] = array('User-Name', 'S');
243
-        $this->_attributes_info[2] = array('User-Password', 'S');
244
-        $this->_attributes_info[3] = array('CHAP-Password', 'S'); // Type (1) / Length (1) / CHAP Ident (1) / String
245
-        $this->_attributes_info[4] = array('NAS-IP-Address', 'A');
246
-        $this->_attributes_info[5] = array('NAS-Port', 'I');
247
-        $this->_attributes_info[6] = array('Service-Type', 'I');
248
-        $this->_attributes_info[7] = array('Framed-Protocol', 'I');
249
-        $this->_attributes_info[8] = array('Framed-IP-Address', 'A');
250
-        $this->_attributes_info[9] = array('Framed-IP-Netmask', 'A');
251
-        $this->_attributes_info[10] = array('Framed-Routing', 'I');
252
-        $this->_attributes_info[11] = array('Filter-Id', 'T');
253
-        $this->_attributes_info[12] = array('Framed-MTU', 'I');
254
-        $this->_attributes_info[13] = array('Framed-Compression', 'I');
255
-        $this->_attributes_info[14] = array('Login-IP-Host', 'A');
256
-        $this->_attributes_info[15] = array('Login-service', 'I');
257
-        $this->_attributes_info[16] = array('Login-TCP-Port', 'I');
258
-        $this->_attributes_info[17] = array('(unassigned)', '');
259
-        $this->_attributes_info[18] = array('Reply-Message', 'T');
260
-        $this->_attributes_info[19] = array('Callback-Number', 'S');
261
-        $this->_attributes_info[20] = array('Callback-Id', 'S');
262
-        $this->_attributes_info[21] = array('(unassigned)', '');
263
-        $this->_attributes_info[22] = array('Framed-Route', 'T');
264
-        $this->_attributes_info[23] = array('Framed-IPX-Network', 'I');
265
-        $this->_attributes_info[24] = array('State', 'S');
266
-        $this->_attributes_info[25] = array('Class', 'S');
267
-        $this->_attributes_info[26] = array('Vendor-Specific', 'S'); // Type (1) / Length (1) / Vendor-Id (4) / Vendor type (1) / Vendor length (1) / Attribute-Specific...
268
-        $this->_attributes_info[27] = array('Session-Timeout', 'I');
269
-        $this->_attributes_info[28] = array('Idle-Timeout', 'I');
270
-        $this->_attributes_info[29] = array('Termination-Action', 'I');
271
-        $this->_attributes_info[30] = array('Called-Station-Id', 'S');
272
-        $this->_attributes_info[31] = array('Calling-Station-Id', 'S');
273
-        $this->_attributes_info[32] = array('NAS-Identifier', 'S');
274
-        $this->_attributes_info[33] = array('Proxy-State', 'S');
275
-        $this->_attributes_info[34] = array('Login-LAT-Service', 'S');
276
-        $this->_attributes_info[35] = array('Login-LAT-Node', 'S');
277
-        $this->_attributes_info[36] = array('Login-LAT-Group', 'S');
278
-        $this->_attributes_info[37] = array('Framed-AppleTalk-Link', 'I');
279
-        $this->_attributes_info[38] = array('Framed-AppleTalk-Network', 'I');
280
-        $this->_attributes_info[39] = array('Framed-AppleTalk-Zone', 'S');
281
-        $this->_attributes_info[60] = array('CHAP-Challenge', 'S');
282
-        $this->_attributes_info[61] = array('NAS-Port-Type', 'I');
283
-        $this->_attributes_info[62] = array('Port-Limit', 'I');
284
-        $this->_attributes_info[63] = array('Login-LAT-Port', 'S');
285
-        $this->_attributes_info[76] = array('Prompt', 'I');
242
+        $this->_attributes_info[1] = array ('User-Name', 'S');
243
+        $this->_attributes_info[2] = array ('User-Password', 'S');
244
+        $this->_attributes_info[3] = array ('CHAP-Password', 'S'); // Type (1) / Length (1) / CHAP Ident (1) / String
245
+        $this->_attributes_info[4] = array ('NAS-IP-Address', 'A');
246
+        $this->_attributes_info[5] = array ('NAS-Port', 'I');
247
+        $this->_attributes_info[6] = array ('Service-Type', 'I');
248
+        $this->_attributes_info[7] = array ('Framed-Protocol', 'I');
249
+        $this->_attributes_info[8] = array ('Framed-IP-Address', 'A');
250
+        $this->_attributes_info[9] = array ('Framed-IP-Netmask', 'A');
251
+        $this->_attributes_info[10] = array ('Framed-Routing', 'I');
252
+        $this->_attributes_info[11] = array ('Filter-Id', 'T');
253
+        $this->_attributes_info[12] = array ('Framed-MTU', 'I');
254
+        $this->_attributes_info[13] = array ('Framed-Compression', 'I');
255
+        $this->_attributes_info[14] = array ('Login-IP-Host', 'A');
256
+        $this->_attributes_info[15] = array ('Login-service', 'I');
257
+        $this->_attributes_info[16] = array ('Login-TCP-Port', 'I');
258
+        $this->_attributes_info[17] = array ('(unassigned)', '');
259
+        $this->_attributes_info[18] = array ('Reply-Message', 'T');
260
+        $this->_attributes_info[19] = array ('Callback-Number', 'S');
261
+        $this->_attributes_info[20] = array ('Callback-Id', 'S');
262
+        $this->_attributes_info[21] = array ('(unassigned)', '');
263
+        $this->_attributes_info[22] = array ('Framed-Route', 'T');
264
+        $this->_attributes_info[23] = array ('Framed-IPX-Network', 'I');
265
+        $this->_attributes_info[24] = array ('State', 'S');
266
+        $this->_attributes_info[25] = array ('Class', 'S');
267
+        $this->_attributes_info[26] = array ('Vendor-Specific', 'S'); // Type (1) / Length (1) / Vendor-Id (4) / Vendor type (1) / Vendor length (1) / Attribute-Specific...
268
+        $this->_attributes_info[27] = array ('Session-Timeout', 'I');
269
+        $this->_attributes_info[28] = array ('Idle-Timeout', 'I');
270
+        $this->_attributes_info[29] = array ('Termination-Action', 'I');
271
+        $this->_attributes_info[30] = array ('Called-Station-Id', 'S');
272
+        $this->_attributes_info[31] = array ('Calling-Station-Id', 'S');
273
+        $this->_attributes_info[32] = array ('NAS-Identifier', 'S');
274
+        $this->_attributes_info[33] = array ('Proxy-State', 'S');
275
+        $this->_attributes_info[34] = array ('Login-LAT-Service', 'S');
276
+        $this->_attributes_info[35] = array ('Login-LAT-Node', 'S');
277
+        $this->_attributes_info[36] = array ('Login-LAT-Group', 'S');
278
+        $this->_attributes_info[37] = array ('Framed-AppleTalk-Link', 'I');
279
+        $this->_attributes_info[38] = array ('Framed-AppleTalk-Network', 'I');
280
+        $this->_attributes_info[39] = array ('Framed-AppleTalk-Zone', 'S');
281
+        $this->_attributes_info[60] = array ('CHAP-Challenge', 'S');
282
+        $this->_attributes_info[61] = array ('NAS-Port-Type', 'I');
283
+        $this->_attributes_info[62] = array ('Port-Limit', 'I');
284
+        $this->_attributes_info[63] = array ('Login-LAT-Port', 'S');
285
+        $this->_attributes_info[76] = array ('Prompt', 'I');
286 286
 
287 287
         $this->_identifier_to_send = 0;
288 288
         $this->_user_ip_address = (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '0.0.0.0');
289 289
 
290
-        $this->GenerateRequestAuthenticator();
291
-        $this->SetIpRadiusServer($ip_radius_server);
292
-        $this->SetSharedSecret($shared_secret);
293
-        $this->SetAuthenticationPort($authentication_port);
294
-        $this->SetAccountingPort($accounting_port);
295
-        $this->SetRadiusSuffix($radius_suffix);
296
-        $this->SetUdpTimeout($udp_timeout);
297
-        $this->SetUsername();
298
-        $this->SetPassword();
299
-        $this->SetNasIpAddress();
300
-        $this->SetNasPort();
301
-
302
-        $this->ClearLastError();
303
-        $this->ClearDataToSend();
304
-        $this->ClearDataReceived();
290
+        $this->GenerateRequestAuthenticator ();
291
+        $this->SetIpRadiusServer ($ip_radius_server);
292
+        $this->SetSharedSecret ($shared_secret);
293
+        $this->SetAuthenticationPort ($authentication_port);
294
+        $this->SetAccountingPort ($accounting_port);
295
+        $this->SetRadiusSuffix ($radius_suffix);
296
+        $this->SetUdpTimeout ($udp_timeout);
297
+        $this->SetUsername ();
298
+        $this->SetPassword ();
299
+        $this->SetNasIpAddress ();
300
+        $this->SetNasPort ();
301
+
302
+        $this->ClearLastError ();
303
+        $this->ClearDataToSend ();
304
+        $this->ClearDataReceived ();
305 305
     }
306 306
 
307 307
 
308
-    function GetNextIdentifier()
308
+    function GetNextIdentifier ()
309 309
     {
310 310
         $this->_identifier_to_send = (($this->_identifier_to_send + 1) % 256);
311 311
         return $this->_identifier_to_send;
312 312
     }
313 313
 
314 314
 
315
-    function GenerateRequestAuthenticator()
315
+    function GenerateRequestAuthenticator ()
316 316
     {
317 317
         $this->_request_authenticator = '';
318 318
         for ($ra_loop = 0; $ra_loop <= 15; $ra_loop++)
319 319
         {
320
-            $this->_request_authenticator .= chr(rand(1, 255));
320
+            $this->_request_authenticator .= chr (rand (1, 255));
321 321
         }
322 322
     }
323 323
 
324 324
 
325
-    function GetRequestAuthenticator()
325
+    function GetRequestAuthenticator ()
326 326
     {
327 327
         return $this->_request_authenticator;
328 328
     }
329 329
 
330 330
 
331
-    function GetLastError()
331
+    function GetLastError ()
332 332
     {
333 333
         if (0 < $this->_last_error_code)
334 334
         {
@@ -340,174 +340,174 @@  discard block
 block discarded – undo
340 340
     }
341 341
 
342 342
 
343
-    function ClearDataToSend()
343
+    function ClearDataToSend ()
344 344
     {
345 345
         $this->_radius_packet_to_send = 0;
346 346
         $this->_attributes_to_send = NULL;
347 347
     }
348 348
 
349 349
 
350
-    function ClearDataReceived()
350
+    function ClearDataReceived ()
351 351
     {
352 352
         $this->_radius_packet_received = 0;
353 353
         $this->_attributes_received = NULL;
354 354
     }
355 355
 
356 356
 
357
-    function SetPacketCodeToSend($packet_code)
357
+    function SetPacketCodeToSend ($packet_code)
358 358
     {
359 359
         $this->_radius_packet_to_send = $packet_code;
360 360
     }
361 361
 
362 362
 
363
-    function SetDebugMode($debug_mode)
363
+    function SetDebugMode ($debug_mode)
364 364
     {
365 365
         $this->_debug_mode = (TRUE === $debug_mode);
366 366
     }
367 367
 
368 368
 
369
-    function SetIpRadiusServer($ip_radius_server)
369
+    function SetIpRadiusServer ($ip_radius_server)
370 370
     {
371
-        $this->_ip_radius_server = gethostbyname($ip_radius_server);
371
+        $this->_ip_radius_server = gethostbyname ($ip_radius_server);
372 372
     }
373 373
 
374 374
 
375
-    function SetSharedSecret($shared_secret)
375
+    function SetSharedSecret ($shared_secret)
376 376
     {
377 377
         $this->_shared_secret = $shared_secret;
378 378
     }
379 379
 
380 380
 
381
-    function SetRadiusSuffix($radius_suffix)
381
+    function SetRadiusSuffix ($radius_suffix)
382 382
     {
383 383
         $this->_radius_suffix = $radius_suffix;
384 384
     }
385 385
 
386 386
 
387
-    function SetUsername($username = '')
387
+    function SetUsername ($username = '')
388 388
     {
389 389
         $temp_username = $username;
390
-        if (false === strpos($temp_username, '@'))
390
+        if (false === strpos ($temp_username, '@'))
391 391
         {
392 392
             $temp_username .= $this->_radius_suffix;
393 393
         }
394 394
 
395 395
         $this->_username = $temp_username;
396
-        $this->SetAttribute(1, $this->_username);
396
+        $this->SetAttribute (1, $this->_username);
397 397
     }
398 398
 
399 399
 
400
-    function SetPassword($password = '')
400
+    function SetPassword ($password = '')
401 401
     {
402 402
         $this->_password = $password;
403 403
         $encrypted_password = '';
404 404
         $padded_password = $password;
405 405
 
406
-        if (0 != (strlen($password) % 16))
406
+        if (0 != (strlen ($password) % 16))
407 407
         {
408
-            $padded_password .= str_repeat(chr(0), (16 - strlen($password) % 16));
408
+            $padded_password .= str_repeat (chr (0), (16 - strlen ($password) % 16));
409 409
         }
410 410
 
411 411
         $previous_result = $this->_request_authenticator;
412 412
 
413
-        for ($full_loop = 0; $full_loop < (strlen($padded_password) / 16); $full_loop++)
413
+        for ($full_loop = 0; $full_loop < (strlen ($padded_password) / 16); $full_loop++)
414 414
         {
415
-            $xor_value = md5($this->_shared_secret.$previous_result);
415
+            $xor_value = md5 ($this->_shared_secret.$previous_result);
416 416
 
417 417
             $previous_result = '';
418 418
             for ($xor_loop = 0; $xor_loop <= 15; $xor_loop++)
419 419
             {
420
-                $value1 = ord(substr($padded_password, ($full_loop * 16) + $xor_loop, 1));
421
-                $value2 = hexdec(substr($xor_value, 2 * $xor_loop, 2));
422
-                $xor_result = $value1^$value2;
423
-                $previous_result .= chr($xor_result);
420
+                $value1 = ord (substr ($padded_password, ($full_loop * 16) + $xor_loop, 1));
421
+                $value2 = hexdec (substr ($xor_value, 2 * $xor_loop, 2));
422
+                $xor_result = $value1 ^ $value2;
423
+                $previous_result .= chr ($xor_result);
424 424
             }
425 425
             $encrypted_password .= $previous_result;
426 426
         }
427 427
 
428 428
         $this->_encrypted_password = $encrypted_password;
429
-        $this->SetAttribute(2, $this->_encrypted_password);
429
+        $this->SetAttribute (2, $this->_encrypted_password);
430 430
     }
431 431
 
432 432
 
433
-    function SetNasIPAddress($nas_ip_address = '')
433
+    function SetNasIPAddress ($nas_ip_address = '')
434 434
     {
435
-        if (0 < strlen($nas_ip_address))
435
+        if (0 < strlen ($nas_ip_address))
436 436
         {
437
-            $this->_nas_ip_address = gethostbyname($nas_ip_address);
437
+            $this->_nas_ip_address = gethostbyname ($nas_ip_address);
438 438
         } else
439 439
         {
440
-            $this->_nas_ip_address = gethostbyname(isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '0.0.0.0');
440
+            $this->_nas_ip_address = gethostbyname (isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '0.0.0.0');
441 441
         }
442
-        $this->SetAttribute(4, $this->_nas_ip_address);
442
+        $this->SetAttribute (4, $this->_nas_ip_address);
443 443
     }
444 444
 
445 445
 
446
-    function SetNasPort($nas_port = 0)
446
+    function SetNasPort ($nas_port = 0)
447 447
     {
448
-        $this->_nas_port = intval($nas_port);
449
-        $this->SetAttribute(5, $this->_nas_port);
448
+        $this->_nas_port = intval ($nas_port);
449
+        $this->SetAttribute (5, $this->_nas_port);
450 450
     }
451 451
 
452 452
 
453
-    function SetUdpTimeout($udp_timeout = 5)
453
+    function SetUdpTimeout ($udp_timeout = 5)
454 454
     {
455
-        if (intval($udp_timeout) > 0)
455
+        if (intval ($udp_timeout) > 0)
456 456
         {
457
-            $this->_udp_timeout = intval($udp_timeout);
457
+            $this->_udp_timeout = intval ($udp_timeout);
458 458
         }
459 459
     }
460 460
 
461 461
 
462
-    function ClearLastError()
462
+    function ClearLastError ()
463 463
     {
464 464
         $this->_last_error_code    = 0;
465 465
         $this->_last_error_message = '';
466 466
     }
467 467
 
468 468
 
469
-    function SetAuthenticationPort($authentication_port)
469
+    function SetAuthenticationPort ($authentication_port)
470 470
     {
471
-        if ((intval($authentication_port) > 0) && (intval($authentication_port) < 65536))
471
+        if ((intval ($authentication_port) > 0) && (intval ($authentication_port) < 65536))
472 472
         {
473
-            $this->_authentication_port = intval($authentication_port);
473
+            $this->_authentication_port = intval ($authentication_port);
474 474
         }
475 475
     }
476 476
 
477 477
 
478
-    function SetAccountingPort($accounting_port)
478
+    function SetAccountingPort ($accounting_port)
479 479
     {
480
-        if ((intval($accounting_port) > 0) && (intval($accounting_port) < 65536))
480
+        if ((intval ($accounting_port) > 0) && (intval ($accounting_port) < 65536))
481 481
         {
482
-            $this->_accounting_port = intval($accounting_port);
482
+            $this->_accounting_port = intval ($accounting_port);
483 483
         }
484 484
     }
485 485
 
486 486
 
487
-    function GetReceivedPacket()
487
+    function GetReceivedPacket ()
488 488
     {
489 489
         return $this->_radius_packet_received;
490 490
     }
491 491
 
492 492
 
493
-    function GetReceivedAttributes()
493
+    function GetReceivedAttributes ()
494 494
     {
495 495
         return $this->_attributes_received;
496 496
     }
497 497
 
498 498
 
499
-    function GetReadableReceivedAttributes()
499
+    function GetReadableReceivedAttributes ()
500 500
     {
501 501
         $readable_attributes = '';
502 502
         if (isset($this->_attributes_received))
503 503
         {
504 504
             foreach ($this->_attributes_received as $one_received_attribute)
505 505
             {
506
-                $attributes_info = $this->GetAttributesInfo($one_received_attribute[0]);
506
+                $attributes_info = $this->GetAttributesInfo ($one_received_attribute[0]);
507 507
                 $readable_attributes .= $attributes_info[0].": ";
508 508
                 if (26 == $one_received_attribute[0])
509 509
                 {
510
-                    $vendor_array = $this->DecodeVendorSpecificContent($one_received_attribute[1]);
510
+                    $vendor_array = $this->DecodeVendorSpecificContent ($one_received_attribute[1]);
511 511
                     foreach ($vendor_array as $vendor_one)
512 512
                     {
513 513
                         $readable_attributes .= 'Vendor-Id: '.$vendor_one[0].", Vendor-type: ".$vendor_one[1].",  Attribute-specific: ".$vendor_one[2];
@@ -523,12 +523,12 @@  discard block
 block discarded – undo
523 523
     }
524 524
 
525 525
 
526
-    function GetAttribute($attribute_type)
526
+    function GetAttribute ($attribute_type)
527 527
     {
528 528
         $attribute_value = NULL;
529 529
         foreach ($this->_attributes_received as $one_received_attribute)
530 530
         {
531
-            if (intval($attribute_type) == $one_received_attribute[0])
531
+            if (intval ($attribute_type) == $one_received_attribute[0])
532 532
             {
533 533
                 $attribute_value = $one_received_attribute[1];
534 534
                 break;
@@ -538,11 +538,11 @@  discard block
 block discarded – undo
538 538
     }
539 539
 
540 540
 
541
-    function GetRadiusPacketInfo($info_index)
541
+    function GetRadiusPacketInfo ($info_index)
542 542
     {
543
-        if (isset($this->_radius_packet_info[intval($info_index)]))
543
+        if (isset($this->_radius_packet_info[intval ($info_index)]))
544 544
         {
545
-            return $this->_radius_packet_info[intval($info_index)];
545
+            return $this->_radius_packet_info[intval ($info_index)];
546 546
         } else
547 547
         {
548 548
             return '';
@@ -550,34 +550,34 @@  discard block
 block discarded – undo
550 550
     }
551 551
 
552 552
 
553
-    function GetAttributesInfo($info_index)
553
+    function GetAttributesInfo ($info_index)
554 554
     {
555
-        if (isset($this->_attributes_info[intval($info_index)]))
555
+        if (isset($this->_attributes_info[intval ($info_index)]))
556 556
         {
557
-            return $this->_attributes_info[intval($info_index)];
557
+            return $this->_attributes_info[intval ($info_index)];
558 558
         } else
559 559
         {
560
-            return array('', '');
560
+            return array ('', '');
561 561
         }
562 562
     }
563 563
 
564 564
 
565
-    function DebugInfo($debug_info)
565
+    function DebugInfo ($debug_info)
566 566
     {
567 567
         if ($this->_debug_mode)
568 568
         {
569 569
 	        //save debugging
570
-	        $this->debug_text[] = date('Y-m-d H:i:s').' DEBUG: '.$debug_info;
570
+	        $this->debug_text[] = date ('Y-m-d H:i:s').' DEBUG: '.$debug_info;
571 571
         }
572 572
     }
573 573
 
574 574
 
575
-    function SetAttribute($type, $value)
575
+    function SetAttribute ($type, $value)
576 576
     {
577 577
         $attribute_index = -1;
578
-        for ($attributes_loop = 0; $attributes_loop < count($this->_attributes_to_send); $attributes_loop++)
578
+        for ($attributes_loop = 0; $attributes_loop < count ($this->_attributes_to_send); $attributes_loop++)
579 579
         {
580
-            if ($type == ord(substr($this->_attributes_to_send[$attributes_loop], 0, 1)))
580
+            if ($type == ord (substr ($this->_attributes_to_send[$attributes_loop], 0, 1)))
581 581
             {
582 582
                 $attribute_index = $attributes_loop;
583 583
                 break;
@@ -591,17 +591,17 @@  discard block
 block discarded – undo
591 591
             switch ($this->_attributes_info[$type][1])
592 592
             {
593 593
                 case 'T': // Text, 1-253 octets containing UTF-8 encoded ISO 10646 characters (RFC 2279).
594
-                    $temp_attribute = chr($type).chr(2 + strlen($value)).$value;
594
+                    $temp_attribute = chr ($type).chr (2 + strlen ($value)).$value;
595 595
                     break;
596 596
                 case 'S': // String, 1-253 octets containing binary data (values 0 through 255 decimal, inclusive).
597
-                    $temp_attribute = chr($type).chr(2 + strlen($value)).$value;
597
+                    $temp_attribute = chr ($type).chr (2 + strlen ($value)).$value;
598 598
                     break;
599 599
                 case 'A': // Address, 32 bit value, most significant octet first.
600
-                    $ip_array = explode(".", $value);
601
-                    $temp_attribute = chr($type).chr(6).chr($ip_array[0]).chr($ip_array[1]).chr($ip_array[2]).chr($ip_array[3]);
600
+                    $ip_array = explode (".", $value);
601
+                    $temp_attribute = chr ($type).chr (6).chr ($ip_array[0]).chr ($ip_array[1]).chr ($ip_array[2]).chr ($ip_array[3]);
602 602
                     break;
603 603
                 case 'I': // Integer, 32 bit unsigned value, most significant octet first.
604
-                    $temp_attribute = chr($type).chr(6).chr(($value / (256 * 256 * 256)) % 256).chr(($value / (256 * 256)) % 256).chr(($value / (256)) % 256).chr($value % 256);
604
+                    $temp_attribute = chr ($type).chr (6).chr (($value / (256 * 256 * 256)) % 256).chr (($value / (256 * 256)) % 256).chr (($value / (256)) % 256).chr ($value % 256);
605 605
                     break;
606 606
                 case 'D': // Time, 32 bit unsigned value, most significant octet first -- seconds since 00:00:00 UTC, January 1, 1970. (not used in this RFC)
607 607
                     $temp_attribute = NULL;
@@ -620,12 +620,12 @@  discard block
 block discarded – undo
620 620
             $this->_attributes_to_send[] = $temp_attribute;
621 621
             $additional_debug = 'Added';
622 622
         }
623
-        $attribute_info = $this->GetAttributesInfo($type);
624
-        $this->DebugInfo($additional_debug.' Attribute '.$type.' ('.$attribute_info[0].'), format '.$attribute_info[1].', value <em>'.$value.'</em>');
623
+        $attribute_info = $this->GetAttributesInfo ($type);
624
+        $this->DebugInfo ($additional_debug.' Attribute '.$type.' ('.$attribute_info[0].'), format '.$attribute_info[1].', value <em>'.$value.'</em>');
625 625
     }
626 626
 
627 627
 
628
-    function DecodeAttribute($attribute_raw_value, $attribute_format)
628
+    function DecodeAttribute ($attribute_raw_value, $attribute_format)
629 629
     {
630 630
         $attribute_value = NULL;
631 631
 
@@ -640,10 +640,10 @@  discard block
 block discarded – undo
640 640
                     $attribute_value = $attribute_raw_value;
641 641
                     break;
642 642
                 case 'A': // Address, 32 bit value, most significant octet first.
643
-                    $attribute_value = ord(substr($attribute_raw_value, 0, 1)).'.'.ord(substr($attribute_raw_value, 1, 1)).'.'.ord(substr($attribute_raw_value, 2, 1)).'.'.ord(substr($attribute_raw_value, 3, 1));
643
+                    $attribute_value = ord (substr ($attribute_raw_value, 0, 1)).'.'.ord (substr ($attribute_raw_value, 1, 1)).'.'.ord (substr ($attribute_raw_value, 2, 1)).'.'.ord (substr ($attribute_raw_value, 3, 1));
644 644
                     break;
645 645
                 case 'I': // Integer, 32 bit unsigned value, most significant octet first.
646
-                    $attribute_value = (ord(substr($attribute_raw_value, 0, 1)) * 256 * 256 * 256) + (ord(substr($attribute_raw_value, 1, 1)) * 256 * 256) + (ord(substr($attribute_raw_value, 2, 1)) * 256) + ord(substr($attribute_raw_value, 3, 1));
646
+                    $attribute_value = (ord (substr ($attribute_raw_value, 0, 1)) * 256 * 256 * 256) + (ord (substr ($attribute_raw_value, 1, 1)) * 256 * 256) + (ord (substr ($attribute_raw_value, 2, 1)) * 256) + ord (substr ($attribute_raw_value, 3, 1));
647 647
                     break;
648 648
                 case 'D': // Time, 32 bit unsigned value, most significant octet first -- seconds since 00:00:00 UTC, January 1, 1970. (not used in this RFC)
649 649
                     $attribute_value = NULL;
@@ -659,18 +659,18 @@  discard block
 block discarded – undo
659 659
     /*********************************************************************
660 660
      * Array returned: array(array(Vendor-Id1, Vendor type1, Attribute-Specific1), ..., array(Vendor-IdN, Vendor typeN, Attribute-SpecificN)
661 661
      *********************************************************************/
662
-    function DecodeVendorSpecificContent($vendor_specific_raw_value)
662
+    function DecodeVendorSpecificContent ($vendor_specific_raw_value)
663 663
     {
664
-        $result = array();
664
+        $result = array ();
665 665
         $offset_in_raw = 0;
666
-        $vendor_id = (ord(substr($vendor_specific_raw_value, 0, 1)) * 256 * 256 * 256) + (ord(substr($vendor_specific_raw_value, 1, 1)) * 256 * 256) + (ord(substr($vendor_specific_raw_value, 2, 1)) * 256) + ord(substr($vendor_specific_raw_value, 3, 1));
666
+        $vendor_id = (ord (substr ($vendor_specific_raw_value, 0, 1)) * 256 * 256 * 256) + (ord (substr ($vendor_specific_raw_value, 1, 1)) * 256 * 256) + (ord (substr ($vendor_specific_raw_value, 2, 1)) * 256) + ord (substr ($vendor_specific_raw_value, 3, 1));
667 667
         $offset_in_raw += 4;
668
-        while ($offset_in_raw < strlen($vendor_specific_raw_value))
668
+        while ($offset_in_raw < strlen ($vendor_specific_raw_value))
669 669
         {
670
-            $vendor_type = (ord(substr($vendor_specific_raw_value, 0 + $offset_in_raw, 1)));
671
-            $vendor_length = (ord(substr($vendor_specific_raw_value, 1 + $offset_in_raw, 1)));
672
-            $attribute_specific = substr($vendor_specific_raw_value, 2 + $offset_in_raw, $vendor_length);
673
-            $result[] = array($vendor_id, $vendor_type, $attribute_specific);
670
+            $vendor_type = (ord (substr ($vendor_specific_raw_value, 0 + $offset_in_raw, 1)));
671
+            $vendor_length = (ord (substr ($vendor_specific_raw_value, 1 + $offset_in_raw, 1)));
672
+            $attribute_specific = substr ($vendor_specific_raw_value, 2 + $offset_in_raw, $vendor_length);
673
+            $result[] = array ($vendor_id, $vendor_type, $attribute_specific);
674 674
             $offset_in_raw += ($vendor_length);
675 675
         }
676 676
 
@@ -683,140 +683,140 @@  discard block
 block discarded – undo
683 683
      *
684 684
      * Return TRUE if Access-Request is accepted, FALSE otherwise
685 685
      */
686
-    function AccessRequest($username = '', $password = '', $udp_timeout = 0, $state = NULL)
686
+    function AccessRequest ($username = '', $password = '', $udp_timeout = 0, $state = NULL)
687 687
     {
688
-        $this->ClearDataReceived();
689
-        $this->ClearLastError();
688
+        $this->ClearDataReceived ();
689
+        $this->ClearLastError ();
690 690
 
691
-        $this->SetPacketCodeToSend(1); // Access-Request
691
+        $this->SetPacketCodeToSend (1); // Access-Request
692 692
 
693
-        if (0 < strlen($username))
693
+        if (0 < strlen ($username))
694 694
         {
695
-            $this->SetUsername($username);
695
+            $this->SetUsername ($username);
696 696
         }
697 697
 
698
-        if (0 < strlen($password))
698
+        if (0 < strlen ($password))
699 699
         {
700
-            $this->SetPassword($password);
700
+            $this->SetPassword ($password);
701 701
         }
702 702
 
703 703
         if ($state !== NULL)
704 704
         {
705
-            $this->SetAttribute(24, $state);
705
+            $this->SetAttribute (24, $state);
706 706
         } else
707 707
         {
708
-            $this->SetAttribute(6, 1); // 1=Login
708
+            $this->SetAttribute (6, 1); // 1=Login
709 709
         }
710 710
 
711
-        if (intval($udp_timeout) > 0)
711
+        if (intval ($udp_timeout) > 0)
712 712
         {
713
-            $this->SetUdpTimeout($udp_timeout);
713
+            $this->SetUdpTimeout ($udp_timeout);
714 714
         }
715 715
 
716 716
         $attributes_content = '';
717
-        for ($attributes_loop = 0; $attributes_loop < count($this->_attributes_to_send); $attributes_loop++)
717
+        for ($attributes_loop = 0; $attributes_loop < count ($this->_attributes_to_send); $attributes_loop++)
718 718
         {
719 719
             $attributes_content .= $this->_attributes_to_send[$attributes_loop];
720 720
         }
721 721
 
722 722
         $packet_length  = 4; // Radius packet code + Identifier + Length high + Length low
723
-        $packet_length += strlen($this->_request_authenticator); // Request-Authenticator
724
-        $packet_length += strlen($attributes_content); // Attributes
723
+        $packet_length += strlen ($this->_request_authenticator); // Request-Authenticator
724
+        $packet_length += strlen ($attributes_content); // Attributes
725 725
 
726
-        $packet_data  = chr($this->_radius_packet_to_send);
727
-        $packet_data .= chr($this->GetNextIdentifier());
728
-        $packet_data .= chr(intval($packet_length / 256));
729
-        $packet_data .= chr(intval($packet_length % 256));
726
+        $packet_data  = chr ($this->_radius_packet_to_send);
727
+        $packet_data .= chr ($this->GetNextIdentifier ());
728
+        $packet_data .= chr (intval ($packet_length / 256));
729
+        $packet_data .= chr (intval ($packet_length % 256));
730 730
         $packet_data .= $this->_request_authenticator;
731 731
         $packet_data .= $attributes_content;
732 732
 
733
-        $_socket_to_server = socket_create(AF_INET, SOCK_DGRAM, 17); // UDP packet = 17
733
+        $_socket_to_server = socket_create (AF_INET, SOCK_DGRAM, 17); // UDP packet = 17
734 734
 
735 735
         if ($_socket_to_server === FALSE)
736 736
         {
737
-            $this->_last_error_code    = socket_last_error();
738
-            $this->_last_error_message = socket_strerror($this->_last_error_code);
739
-        } elseif (FALSE === socket_connect($_socket_to_server, $this->_ip_radius_server, $this->_authentication_port))
737
+            $this->_last_error_code    = socket_last_error ();
738
+            $this->_last_error_message = socket_strerror ($this->_last_error_code);
739
+        } elseif (FALSE === socket_connect ($_socket_to_server, $this->_ip_radius_server, $this->_authentication_port))
740 740
         {
741
-            $this->_last_error_code    = socket_last_error();
742
-            $this->_last_error_message = socket_strerror($this->_last_error_code);
743
-        } elseif (FALSE === socket_write($_socket_to_server, $packet_data, $packet_length))
741
+            $this->_last_error_code    = socket_last_error ();
742
+            $this->_last_error_message = socket_strerror ($this->_last_error_code);
743
+        } elseif (FALSE === socket_write ($_socket_to_server, $packet_data, $packet_length))
744 744
         {
745
-            $this->_last_error_code    = socket_last_error();
746
-            $this->_last_error_message = socket_strerror($this->_last_error_code);
745
+            $this->_last_error_code    = socket_last_error ();
746
+            $this->_last_error_message = socket_strerror ($this->_last_error_code);
747 747
         } else
748 748
         {
749
-            $this->DebugInfo('<b>Packet type '.$this->_radius_packet_to_send.' ('.$this->GetRadiusPacketInfo($this->_radius_packet_to_send).')'.' sent</b>');
749
+            $this->DebugInfo ('<b>Packet type '.$this->_radius_packet_to_send.' ('.$this->GetRadiusPacketInfo ($this->_radius_packet_to_send).')'.' sent</b>');
750 750
             if ($this->_debug_mode)
751 751
             {
752 752
                 $readable_attributes = '';
753 753
                 foreach ($this->_attributes_to_send as $one_attribute_to_send)
754 754
                 {
755
-                    $attribute_info = $this->GetAttributesInfo(ord(substr($one_attribute_to_send, 0, 1)));
756
-                    $this->DebugInfo('Attribute '.ord(substr($one_attribute_to_send, 0, 1)).' ('.$attribute_info[0].'), length '.(ord(substr($one_attribute_to_send, 1, 1)) - 2).', format '.$attribute_info[1].', value <em>'.$this->DecodeAttribute(substr($one_attribute_to_send, 2), ord(substr($one_attribute_to_send, 0, 1))).'</em>');
755
+                    $attribute_info = $this->GetAttributesInfo (ord (substr ($one_attribute_to_send, 0, 1)));
756
+                    $this->DebugInfo ('Attribute '.ord (substr ($one_attribute_to_send, 0, 1)).' ('.$attribute_info[0].'), length '.(ord (substr ($one_attribute_to_send, 1, 1)) - 2).', format '.$attribute_info[1].', value <em>'.$this->DecodeAttribute (substr ($one_attribute_to_send, 2), ord (substr ($one_attribute_to_send, 0, 1))).'</em>');
757 757
                 }
758 758
             }
759
-            $read_socket_array   = array($_socket_to_server);
759
+            $read_socket_array   = array ($_socket_to_server);
760 760
             $write_socket_array  = NULL;
761 761
             $except_socket_array = NULL;
762 762
 
763
-            $received_packet = chr(0);
763
+            $received_packet = chr (0);
764 764
 
765
-            if (!(FALSE === socket_select($read_socket_array, $write_socket_array, $except_socket_array, $this->_udp_timeout)))
765
+            if (!(FALSE === socket_select ($read_socket_array, $write_socket_array, $except_socket_array, $this->_udp_timeout)))
766 766
             {
767
-                if (in_array($_socket_to_server, $read_socket_array))
767
+                if (in_array ($_socket_to_server, $read_socket_array))
768 768
                 {
769
-                    if (FALSE === ($received_packet = @socket_read($_socket_to_server, 1024))) {
769
+                    if (FALSE === ($received_packet = @socket_read ($_socket_to_server, 1024))) {
770 770
                         // @ used, than no error is displayed if the connection is closed by the remote host
771 771
                     {
772
-                        $received_packet = chr(0);
772
+                        $received_packet = chr (0);
773 773
                     }
774
-                        $this->_last_error_code    = socket_last_error();
775
-                        $this->_last_error_message = socket_strerror($this->_last_error_code);
774
+                        $this->_last_error_code    = socket_last_error ();
775
+                        $this->_last_error_message = socket_strerror ($this->_last_error_code);
776 776
                     } else
777 777
                     {
778
-                        socket_close($_socket_to_server);
778
+                        socket_close ($_socket_to_server);
779 779
                     }
780 780
                 }
781 781
             } else
782 782
             {
783
-                socket_close($_socket_to_server);
783
+                socket_close ($_socket_to_server);
784 784
             }
785 785
         }
786 786
 
787
-        $this->_radius_packet_received = intval(ord(substr($received_packet, 0, 1)));
787
+        $this->_radius_packet_received = intval (ord (substr ($received_packet, 0, 1)));
788 788
 
789
-        $this->DebugInfo('<b>Packet type '.$this->_radius_packet_received.' ('.$this->GetRadiusPacketInfo($this->_radius_packet_received).')'.' received</b>');
789
+        $this->DebugInfo ('<b>Packet type '.$this->_radius_packet_received.' ('.$this->GetRadiusPacketInfo ($this->_radius_packet_received).')'.' received</b>');
790 790
 
791 791
         if ($this->_radius_packet_received > 0)
792 792
         {
793
-            $this->_identifier_received = intval(ord(substr($received_packet, 1, 1)));
794
-            $packet_length = (intval(ord(substr($received_packet, 2, 1))) * 256) + (intval(ord(substr($received_packet, 3, 1))));
795
-            $this->_response_authenticator = substr($received_packet, 4, 16);
796
-            $attributes_content = substr($received_packet, 20, ($packet_length - 4 - 16));
797
-            while (strlen($attributes_content) > 2)
793
+            $this->_identifier_received = intval (ord (substr ($received_packet, 1, 1)));
794
+            $packet_length = (intval (ord (substr ($received_packet, 2, 1))) * 256) + (intval (ord (substr ($received_packet, 3, 1))));
795
+            $this->_response_authenticator = substr ($received_packet, 4, 16);
796
+            $attributes_content = substr ($received_packet, 20, ($packet_length - 4 - 16));
797
+            while (strlen ($attributes_content) > 2)
798 798
             {
799
-                $attribute_type = intval(ord(substr($attributes_content, 0, 1)));
800
-                $attribute_length = intval(ord(substr($attributes_content, 1, 1)));
801
-                $attribute_raw_value = substr($attributes_content, 2, $attribute_length - 2);
802
-                $attributes_content = substr($attributes_content, $attribute_length);
799
+                $attribute_type = intval (ord (substr ($attributes_content, 0, 1)));
800
+                $attribute_length = intval (ord (substr ($attributes_content, 1, 1)));
801
+                $attribute_raw_value = substr ($attributes_content, 2, $attribute_length - 2);
802
+                $attributes_content = substr ($attributes_content, $attribute_length);
803 803
 
804
-                $attribute_value = $this->DecodeAttribute($attribute_raw_value, $attribute_type);
804
+                $attribute_value = $this->DecodeAttribute ($attribute_raw_value, $attribute_type);
805 805
 
806
-                $attribute_info = $this->GetAttributesInfo($attribute_type);
806
+                $attribute_info = $this->GetAttributesInfo ($attribute_type);
807 807
                 if (26 == $attribute_type)
808 808
                 {
809
-                    $vendor_array = $this->DecodeVendorSpecificContent($attribute_value);
809
+                    $vendor_array = $this->DecodeVendorSpecificContent ($attribute_value);
810 810
                     foreach ($vendor_array as $vendor_one)
811 811
                     {
812
-                        $this->DebugInfo('Attribute '.$attribute_type.' ('.$attribute_info[0].'), length '.($attribute_length - 2).', format '.$attribute_info[1].', Vendor-Id: '.$vendor_one[0].", Vendor-type: ".$vendor_one[1].",  Attribute-specific: ".$vendor_one[2]);
812
+                        $this->DebugInfo ('Attribute '.$attribute_type.' ('.$attribute_info[0].'), length '.($attribute_length - 2).', format '.$attribute_info[1].', Vendor-Id: '.$vendor_one[0].", Vendor-type: ".$vendor_one[1].",  Attribute-specific: ".$vendor_one[2]);
813 813
                     }
814 814
                 } else
815 815
                 {
816
-                    $this->DebugInfo('Attribute '.$attribute_type.' ('.$attribute_info[0].'), length '.($attribute_length - 2).', format '.$attribute_info[1].', value <em>'.$attribute_value.'</em>');
816
+                    $this->DebugInfo ('Attribute '.$attribute_type.' ('.$attribute_info[0].'), length '.($attribute_length - 2).', format '.$attribute_info[1].', value <em>'.$attribute_value.'</em>');
817 817
                 }
818 818
 
819
-                $this->_attributes_received[] = array($attribute_type, $attribute_value);
819
+                $this->_attributes_received[] = array ($attribute_type, $attribute_value);
820 820
             }
821 821
         }
822 822
 
Please login to merge, or discard this patch.
functions/classes/class.Result.php 2 patches
Doc Comments   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 *
72 72
 	 * @access public
73 73
 	 * @param string $text (default: "No value provided")
74
-	 * @return void
74
+	 * @return string
75 75
 	 */
76 76
 	public function show_cli_message ($text="No value provided") {
77 77
 		// array - join
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
 	 * Show GUI result
96 96
 	 *
97 97
 	 * @access public
98
-	 * @param mixed $class
99
-	 * @param mixed $text
100
-	 * @param mixed $popup
101
-	 * @param mixed $popup2
102
-	 * @return void
98
+	 * @param string $class
99
+	 * @param string $text
100
+	 * @param boolean $popup
101
+	 * @param boolean $popup2
102
+	 * @return string
103 103
 	 */
104 104
 	public function show_message ($class, $text, $popup, $popup2) {
105 105
 		// format if array
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 * Exists with exception for API
145 145
 	 *
146 146
 	 * @access public
147
-	 * @param mixed $content
147
+	 * @param string $content
148 148
 	 * @return void
149 149
 	 */
150 150
 	public function throw_exception ($content) {
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -45,28 +45,28 @@  discard block
 block discarded – undo
45 45
 	 * @param bool $popup2 (default: false)					close for JS for popup2
46 46
 	 * @return void
47 47
 	 */
48
-	public function show($class="muted", $text="No value provided", $die=false, $popup=false, $inline = false, $popup2 = false) {
48
+	public function show ($class = "muted", $text = "No value provided", $die = false, $popup = false, $inline = false, $popup2 = false) {
49 49
 
50 50
 		# set die
51 51
 		$this->die = $die;
52 52
 
53 53
 		# API - throw exception
54
-		if($this->exit_method == "exception")  {
54
+		if ($this->exit_method == "exception") {
55 55
 			# ok, just return success
56
-			if ($class=="success") 		{ return true; }
57
-			else						{ return $this->throw_exception ($text); }
56
+			if ($class == "success") { return true; }
57
+			else { return $this->throw_exception ($text); }
58 58
 		}
59 59
 		else {
60 60
 			# cli or GUI
61
-			if (php_sapi_name()=="cli") { print $this->show_cli_message ($text); }
61
+			if (php_sapi_name () == "cli") { print $this->show_cli_message ($text); }
62 62
 			else {
63 63
 				# return or print
64
-				if ($inline) 			{ return $this->show_message ($class, $text, $popup, $popup2); }
65
-				else					{ print  $this->show_message ($class, $text, $popup, $popup2); }
64
+				if ($inline) { return $this->show_message ($class, $text, $popup, $popup2); }
65
+				else { print  $this->show_message ($class, $text, $popup, $popup2); }
66 66
 			}
67 67
 
68 68
 			# die
69
-			if($this->die===true)	{die(); }
69
+			if ($this->die === true) {die(); }
70 70
 		}
71 71
 	}
72 72
 
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 	 * @param bool $die (default: false)
79 79
 	 * @return void
80 80
 	 */
81
-	public function show_cli ($text="No value provided", $die=false) {
82
-		$this->show(false, $text, $die, false, false, false);
81
+	public function show_cli ($text = "No value provided", $die = false) {
82
+		$this->show (false, $text, $die, false, false, false);
83 83
 	}
84 84
 
85 85
 	/**
@@ -89,18 +89,18 @@  discard block
 block discarded – undo
89 89
 	 * @param string $text (default: "No value provided")
90 90
 	 * @return void
91 91
 	 */
92
-	public function show_cli_message ($text="No value provided") {
92
+	public function show_cli_message ($text = "No value provided") {
93 93
 		// array - join
94
-		if (is_array($text) && sizeof($text)>0) {
94
+		if (is_array ($text) && sizeof ($text) > 0) {
95 95
 			// 1 element
96
-			if(sizeof( $text )==1) {
96
+			if (sizeof ($text) == 1) {
97 97
 				$text = $text[0];
98 98
 			}
99 99
 			// multiple - format
100 100
 			else {
101
-				foreach( $text as $l ) { $out[] = "\t* $l"; }
101
+				foreach ($text as $l) { $out[] = "\t* $l"; }
102 102
 				// join
103
-				$text = implode("\n", $out);
103
+				$text = implode ("\n", $out);
104 104
 			}
105 105
 		}
106 106
 		# print
@@ -119,41 +119,41 @@  discard block
 block discarded – undo
119 119
 	 */
120 120
 	public function show_message ($class, $text, $popup, $popup2) {
121 121
     	// to array if object
122
-    	if (is_object($text))   { $text = (array) $text; }
122
+    	if (is_object ($text)) { $text = (array) $text; }
123 123
 		// format if array
124
-		if(is_array($text)) {
124
+		if (is_array ($text)) {
125 125
 			// single value
126
-			if(sizeof( $text )==1) {
126
+			if (sizeof ($text) == 1) {
127 127
 				$out = $text;
128 128
 			}
129 129
 			// multiple values
130 130
 			else {
131 131
 				$out[] = "<ul>";
132
-				foreach( $text as $l ) { $out[] = "<li>$l</li>"; }
132
+				foreach ($text as $l) { $out[] = "<li>$l</li>"; }
133 133
 				$out[] = "</ul>";
134 134
 			}
135 135
 			// join
136
-			$text = implode("\n", $out);
136
+			$text = implode ("\n", $out);
137 137
 		}
138 138
 
139 139
 		# print popup or normal
140
-		if($popup===false) {
140
+		if ($popup === false) {
141 141
 			return "<div class='alert alert-".$class."'>".$text."</div>";
142 142
 		}
143 143
 		else {
144 144
 			// set close class for JS
145
-			$pclass = $popup2===false ? "hidePopups" : "hidePopup2";
145
+			$pclass = $popup2 === false ? "hidePopups" : "hidePopup2";
146 146
 			// change danger to error for popup
147
-			$htext = $class==="danger" ? "error" : $class;
147
+			$htext = $class === "danger" ? "error" : $class;
148 148
 
149
-			$out[] = '<div class="pHeader">'._(ucwords($htext)).'</div>';
149
+			$out[] = '<div class="pHeader">'._ (ucwords ($htext)).'</div>';
150 150
 			$out[] = '<div class="pContent">';
151 151
 			$out[] = '<div class="alert alert-'.$class.'">'.$text.'</div>';
152 152
 			$out[] = '</div>';
153
-			$out[] = '<div class="pFooter"><button class="btn btn-sm btn-default '.$pclass.'">'._('Close').'</button></div>';
153
+			$out[] = '<div class="pFooter"><button class="btn btn-sm btn-default '.$pclass.'">'._ ('Close').'</button></div>';
154 154
 
155 155
 			// return
156
-			return implode("\n", $out);
156
+			return implode ("\n", $out);
157 157
 		}
158 158
 	}
159 159
 
@@ -166,11 +166,11 @@  discard block
 block discarded – undo
166 166
 	 */
167 167
 	public function throw_exception ($content) {
168 168
 		// include Exceptions class for API
169
-		include_once( dirname(__FILE__) . '../../../api/controllers/Responses.php' );
169
+		include_once(dirname (__FILE__).'../../../api/controllers/Responses.php');
170 170
 		// initialize exceptions
171 171
 		$Exceptions = new Responses ();
172 172
 		// throw error
173
-		$Exceptions->throw_exception(500, $content);
173
+		$Exceptions->throw_exception (500, $content);
174 174
 	}
175 175
 
176 176
 	/**
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
 	 * @access public
180 180
 	 * @return void
181 181
 	 */
182
-	public function __destruct() {
182
+	public function __destruct () {
183 183
 		// exit if required
184
-		if ($this->die === true)	{ die(); }
184
+		if ($this->die === true) { die(); }
185 185
 	}
186 186
 }
187 187
 
Please login to merge, or discard this patch.
functions/classes/class.Scan.php 2 patches
Doc Comments   +8 added lines, -9 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * Returns all possible ping types / apps
63 63
 	 *
64 64
 	 * @access public
65
-	 * @return array
65
+	 * @return string[]
66 66
 	 */
67 67
 	public function ping_fetch_types () {
68 68
 		return array("ping", "pear", "fping");
@@ -152,7 +152,6 @@  discard block
 block discarded – undo
152 152
 	 * @param mixed $address
153 153
 	 * @param int $count (default: 1)
154 154
 	 * @param int $timeout (default: 1)
155
-	 * @param bool $exit (default: false)
156 155
 	 * @return void
157 156
 	 */
158 157
 	public function ping_address ($address, $count=1, $timeout = 1) {
@@ -178,7 +177,7 @@  discard block
 block discarded – undo
178 177
 	 *
179 178
 	 * @access protected
180 179
 	 * @param ip $address
181
-	 * @return void
180
+	 * @return null|integer
182 181
 	 */
183 182
 	protected function ping_address_method_ping ($address) {
184 183
 		# verify ping path
@@ -276,8 +275,7 @@  discard block
 block discarded – undo
276 275
 	 *	fping cannot be run from web, it needs root privileges to be able to open raw socket :/
277 276
 	 *
278 277
 	 * @access public
279
-	 * @param mixed $subnet 	//CIDR
280
-	 * @return void
278
+	 * @return null|integer
281 279
 	 */
282 280
 	public function ping_address_method_fping ($address) {
283 281
 		# verify ping path
@@ -329,7 +327,7 @@  discard block
 block discarded – undo
329 327
 	 *	fping cannot be run from web, it needs root privileges to be able to open raw socket :/
330 328
 	 *
331 329
 	 * @access public
332
-	 * @param mixed $subnet 	//CIDR
330
+	 * @param mixed $subnet_cidr 	//CIDR
333 331
 	 * @return void
334 332
 	 */
335 333
 	public function ping_address_method_fping_subnet ($subnet_cidr, $return_result = false) {
@@ -377,8 +375,8 @@  discard block
 block discarded – undo
377 375
 	 * Explains invalid error codes
378 376
 	 *
379 377
 	 * @access public
380
-	 * @param mixed $code
381
-	 * @return void
378
+	 * @param null|integer $code
379
+	 * @return string|false
382 380
 	 */
383 381
 	public function ping_exit_explain ($code) {
384 382
 		# fetch explain codes
@@ -396,7 +394,7 @@  discard block
 block discarded – undo
396 394
 	 *	extend if needed for future scripts
397 395
 	 *
398 396
 	 * @access public
399
-	 * @return void
397
+	 * @return string[]
400 398
 	 */
401 399
 	public function ping_set_exit_code_explains () {
402 400
 		$explain_codes[0]  = "SUCCESS";
@@ -523,6 +521,7 @@  discard block
 block discarded – undo
523 521
 	 *
524 522
 	 * @access public
525 523
 	 * @param mixed $subnetId
524
+	 * @param boolean $die
526 525
 	 * @return void
527 526
 	 */
528 527
 	public function prepare_addresses_to_discover_subnetId ($subnetId, $die) {
Please login to merge, or discard this patch.
Spacing   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
 		# initialize Result
132 132
 		$this->Result = new Result ();
133 133
 		# debugging
134
-		$this->set_debugging();
134
+		$this->set_debugging ();
135 135
 		# fetch settings
136
-		is_null($this->settings) ? $this->get_settings() : (object) $this->settings;
136
+		is_null ($this->settings) ? $this->get_settings () : (object) $this->settings;
137 137
 		# set type
138 138
 		$this->reset_scan_method ($this->settings->scanPingType);
139 139
 		# set php exec
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	 * @return array
150 150
 	 */
151 151
 	public function ping_fetch_types () {
152
-		return array("ping", "pear", "fping");
152
+		return array ("ping", "pear", "fping");
153 153
 	}
154 154
 
155 155
 	/**
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
 		// fetch possible methods
164 164
 		$possible = $this->ping_fetch_types ();
165 165
 		//check
166
-		if(!in_array($method, $possible)) {
166
+		if (!in_array ($method, $possible)) {
167 167
 			//die or print?
168
-			if($this->icmp_exit)				{ die(json_encode(array("status"=>1, "error"=>"Invalid scan method"))); }
169
-			else								{ $this->Result->show("danger", "Invalid scan method", true); }
168
+			if ($this->icmp_exit) { die(json_encode (array ("status"=>1, "error"=>"Invalid scan method"))); }
169
+			else { $this->Result->show ("danger", "Invalid scan method", true); }
170 170
 		}
171 171
 		//ok
172 172
 		else {
@@ -239,13 +239,13 @@  discard block
 block discarded – undo
239 239
 	 * @param bool $exit (default: false)
240 240
 	 * @return void
241 241
 	 */
242
-	public function ping_address ($address, $count=1, $timeout = 1) {
242
+	public function ping_address ($address, $count = 1, $timeout = 1) {
243 243
 		#set parameters
244 244
 		$this->icmp_timeout = $timeout;
245 245
 		$this->icmp_count = $count;
246 246
 
247 247
 		# escape address
248
-		$address = escapeshellarg($address);
248
+		$address = escapeshellarg ($address);
249 249
 
250 250
 		# make sure it is in right format
251 251
 		$address = $this->transform_address ($address, "dotted");
@@ -269,27 +269,27 @@  discard block
 block discarded – undo
269 269
 		$this->ping_verify_path ($this->settings->scanPingPath);
270 270
 
271 271
 		# if ipv6 append 6
272
-		if ($this->identify_address ($address)=="IPv6")	{ $this->settings->scanPingPath = $this->settings->scanPingPath."6"; }
272
+		if ($this->identify_address ($address) == "IPv6") { $this->settings->scanPingPath = $this->settings->scanPingPath."6"; }
273 273
 
274 274
 		# set ping command based on OS type
275
-		if	(PHP_OS == "FreeBSD" || PHP_OS == "NetBSD")                         { $cmd = $this->settings->scanPingPath." -c $this->icmp_count -W ".($this->icmp_timeout*1000)." $address 1>/dev/null 2>&1"; }
276
-		elseif(PHP_OS == "Linux" || PHP_OS == "OpenBSD")                        { $cmd = $this->settings->scanPingPath." -c $this->icmp_count -w $this->icmp_timeout $address 1>/dev/null 2>&1"; }
277
-		elseif(PHP_OS == "WIN32" || PHP_OS == "Windows" || PHP_OS == "WINNT")	{ $cmd = $this->settings->scanPingPath." -n $this->icmp_count -I ".($this->icmp_timeout*1000)." $address 1>/dev/null 2>&1"; }
278
-		else																	{ $cmd = $this->settings->scanPingPath." -c $this->icmp_count -n $address 1>/dev/null 2>&1"; }
275
+		if (PHP_OS == "FreeBSD" || PHP_OS == "NetBSD") { $cmd = $this->settings->scanPingPath." -c $this->icmp_count -W ".($this->icmp_timeout * 1000)." $address 1>/dev/null 2>&1"; }
276
+		elseif (PHP_OS == "Linux" || PHP_OS == "OpenBSD") { $cmd = $this->settings->scanPingPath." -c $this->icmp_count -w $this->icmp_timeout $address 1>/dev/null 2>&1"; }
277
+		elseif (PHP_OS == "WIN32" || PHP_OS == "Windows" || PHP_OS == "WINNT") { $cmd = $this->settings->scanPingPath." -n $this->icmp_count -I ".($this->icmp_timeout * 1000)." $address 1>/dev/null 2>&1"; }
278
+		else { $cmd = $this->settings->scanPingPath." -c $this->icmp_count -n $address 1>/dev/null 2>&1"; }
279 279
 
280 280
         # for IPv6 remove wait
281
-        if ($this->identify_address ($address)=="IPv6") {
282
-            $cmd = explode(" ", $cmd);
281
+        if ($this->identify_address ($address) == "IPv6") {
282
+            $cmd = explode (" ", $cmd);
283 283
             unset($cmd[3], $cmd[4]);
284
-            $cmd = implode(" ", $cmd);
284
+            $cmd = implode (" ", $cmd);
285 285
         }
286 286
 
287 287
 		# execute command, return $retval
288
-	    exec($cmd, $output, $retval);
288
+	    exec ($cmd, $output, $retval);
289 289
 
290 290
 		# return result for web or cmd
291
-		if($this->icmp_exit)	{ exit  ($retval); }
292
-		else					{ return $retval; }
291
+		if ($this->icmp_exit) { exit  ($retval); }
292
+		else { return $retval; }
293 293
 	}
294 294
 
295 295
 	/**
@@ -301,38 +301,38 @@  discard block
 block discarded – undo
301 301
 	 */
302 302
 	protected function ping_address_method_pear ($address) {
303 303
 		# we need pear ping package
304
-		require_once(dirname(__FILE__) . '/../../functions/PEAR/Net/Ping.php');
305
-		$ping = Net_Ping::factory();
304
+		require_once(dirname (__FILE__).'/../../functions/PEAR/Net/Ping.php');
305
+		$ping = Net_Ping::factory ();
306 306
 
307 307
 		# ipv6 not supported
308
-		if ($this->identify_address ($address)=="IPv6") {
308
+		if ($this->identify_address ($address) == "IPv6") {
309 309
     		//return result for web or cmd
310
-    		if($this->icmp_exit) 	{ exit	(255); }
311
-    		else	  				{ return 255; }
310
+    		if ($this->icmp_exit) { exit	(255); }
311
+    		else { return 255; }
312 312
 		}
313 313
 
314 314
 		# check for errors
315
-		if($ping->pear->isError($ping)) {
316
-			if($this->icmp_exit)	{ exit  ($ping->getMessage()); }
317
-			else					{ return $ping->getMessage(); }
315
+		if ($ping->pear->isError ($ping)) {
316
+			if ($this->icmp_exit) { exit  ($ping->getMessage ()); }
317
+			else { return $ping->getMessage (); }
318 318
 		}
319 319
 		else {
320 320
 			//set count and timeout
321
-			$ping->setArgs(array('count' => $this->icmp_timeout, 'timeout' => $this->icmp_timeout));
321
+			$ping->setArgs (array ('count' => $this->icmp_timeout, 'timeout' => $this->icmp_timeout));
322 322
 			//execute
323
-			$ping_response = $ping->ping($address);
323
+			$ping_response = $ping->ping ($address);
324 324
 			//check response for error
325
-			if($ping->pear->isError($ping_response)) {
325
+			if ($ping->pear->isError ($ping_response)) {
326 326
 				$result['code'] = 2;
327 327
 			}
328 328
 			else {
329 329
 				//all good
330
-				if($ping_response->_transmitted == $ping_response->_received) {
330
+				if ($ping_response->_transmitted == $ping_response->_received) {
331 331
 					$result['code'] = 0;
332
-					$this->rtt = "RTT: ". strstr($ping_response->_round_trip['avg'], ".", true);
332
+					$this->rtt = "RTT: ".strstr ($ping_response->_round_trip['avg'], ".", true);
333 333
 				}
334 334
 				//ping loss
335
-				elseif($ping_response->_received == 0) {
335
+				elseif ($ping_response->_received == 0) {
336 336
 					$result['code'] = 1;
337 337
 				}
338 338
 				//failed
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
 		}
344 344
 
345 345
 		//return result for web or cmd
346
-		if($this->icmp_exit) 	{ exit	($result['code']); }
347
-		else	  				{ return $result['code']; }
346
+		if ($this->icmp_exit) { exit	($result['code']); }
347
+		else { return $result['code']; }
348 348
 	}
349 349
 
350 350
 	/**
@@ -368,21 +368,21 @@  discard block
 block discarded – undo
368 368
 		$this->ping_verify_path ($this->settings->scanFPingPath);
369 369
 
370 370
 		# if ipv6 append 6
371
-		if ($this->identify_address ($address)=="IPv6")	{ $this->settings->scanFPingPath = $this->settings->scanFPingPath."6"; }
371
+		if ($this->identify_address ($address) == "IPv6") { $this->settings->scanFPingPath = $this->settings->scanFPingPath."6"; }
372 372
 
373 373
 		# set command
374
-		$cmd = $this->settings->scanFPingPath." -c $this->icmp_count -t ".($this->icmp_timeout*1000)." $address";
374
+		$cmd = $this->settings->scanFPingPath." -c $this->icmp_count -t ".($this->icmp_timeout * 1000)." $address";
375 375
 		# execute command, return $retval
376
-	    exec($cmd, $output, $retval);
376
+	    exec ($cmd, $output, $retval);
377 377
 
378 378
 	    # save result
379
-	    if($retval==0) {
379
+	    if ($retval == 0) {
380 380
 	    	$this->save_fping_rtt ($output[0]);
381 381
 		}
382 382
 
383 383
 		# return result for web or cmd
384
-		if($this->icmp_exit)	{ exit  ($retval); }
385
-		else					{ return $retval; }
384
+		if ($this->icmp_exit) { exit  ($retval); }
385
+		else { return $retval; }
386 386
 	}
387 387
 
388 388
 	/**
@@ -394,10 +394,10 @@  discard block
 block discarded – undo
394 394
 	 */
395 395
 	private function save_fping_rtt ($line) {
396 396
 		// 173.192.112.30 : xmt/rcv/%loss = 1/1/0%, min/avg/max = 160/160/160
397
- 		$tmp = explode(" ",$line);
397
+ 		$tmp = explode (" ", $line);
398 398
 
399 399
  		# save rtt
400
-		@$this->rtt	= "RTT: ".str_replace("(", "", $tmp[7]);
400
+		@$this->rtt = "RTT: ".str_replace ("(", "", $tmp[7]);
401 401
 	}
402 402
 
403 403
 	/**
@@ -420,14 +420,14 @@  discard block
 block discarded – undo
420 420
 		# verify ping path
421 421
 		$this->ping_verify_path ($this->settings->scanFPingPath);
422 422
 		# set command
423
-		$cmd = $this->settings->scanFPingPath." -c $this->icmp_count -t ".($this->icmp_timeout*1000)." -Ag $subnet_cidr";
423
+		$cmd = $this->settings->scanFPingPath." -c $this->icmp_count -t ".($this->icmp_timeout * 1000)." -Ag $subnet_cidr";
424 424
 		# execute command, return $retval
425
-	    exec($cmd, $output, $retval);
425
+	    exec ($cmd, $output, $retval);
426 426
 
427 427
 	    # save result
428
-	    if(sizeof($output)>0) {
429
-	    	foreach($output as $line) {
430
-		    	$tmp = explode(" ",$line);
428
+	    if (sizeof ($output) > 0) {
429
+	    	foreach ($output as $line) {
430
+		    	$tmp = explode (" ", $line);
431 431
 		    	$out[] = $tmp[0];
432 432
 	    	}
433 433
 	    }
@@ -436,11 +436,11 @@  discard block
 block discarded – undo
436 436
 	    $this->fping_result = $out;
437 437
 
438 438
 	    # return result?
439
-	    if($return_result)		{ return $out; }
439
+	    if ($return_result) { return $out; }
440 440
 
441 441
 		# return result for web or cmd
442
-		if($this->icmp_exit)	{ exit  ($retval); }
443
-		else					{ return $retval; }
442
+		if ($this->icmp_exit) { exit  ($retval); }
443
+		else { return $retval; }
444 444
 	}
445 445
 
446 446
 	/**
@@ -451,9 +451,9 @@  discard block
 block discarded – undo
451 451
 	 * @return void
452 452
 	 */
453 453
 	private function ping_verify_path ($path) {
454
-		if(!file_exists($path)) {
455
-			if($this->icmp_exit)	{ exit  ($this->ping_exit_explain(1000)); }
456
-			else					{ return $this->Result->show("danger", _($this->ping_exit_explain(1000)), true);  }
454
+		if (!file_exists ($path)) {
455
+			if ($this->icmp_exit) { exit  ($this->ping_exit_explain (1000)); }
456
+			else { return $this->Result->show ("danger", _ ($this->ping_exit_explain (1000)), true); }
457 457
 		}
458 458
 	}
459 459
 
@@ -513,13 +513,13 @@  discard block
 block discarded – undo
513 513
 	 */
514 514
 	public function ping_update_lastseen ($id, $datetime = null) {
515 515
     	# set datetime
516
-    	$datetime = is_null($datetime) ? date("Y-m-d H:i:s") : $datetime;
516
+    	$datetime = is_null ($datetime) ? date ("Y-m-d H:i:s") : $datetime;
517 517
 		# execute
518
-		try { $this->Database->updateObject("ipaddresses", array("id"=>$id, "lastSeen"=>$datetime), "id"); }
518
+		try { $this->Database->updateObject ("ipaddresses", array ("id"=>$id, "lastSeen"=>$datetime), "id"); }
519 519
 		catch (Exception $e) {
520
-			!$this->debugging ? : $this->Result->show("danger", $e->getMessage(), false);
520
+			!$this->debugging ? : $this->Result->show ("danger", $e->getMessage (), false);
521 521
 			# log
522
-			!$this->debugging ? : $this->Log->write ("status_update", _('Failed to update address status'), 0 );
522
+			!$this->debugging ? : $this->Log->write ("status_update", _ ('Failed to update address status'), 0);
523 523
 		}
524 524
 	}
525 525
 
@@ -533,10 +533,10 @@  discard block
 block discarded – undo
533 533
 	 */
534 534
 	public function ping_update_scanagent_checktime ($id, $date = false) {
535 535
     	# set time
536
-    	if ($date === false)    { $date = date("Y-m-d H:i:s"); }
537
-    	else                    { $date = $date; }
536
+    	if ($date === false) { $date = date ("Y-m-d H:i:s"); }
537
+    	else { $date = $date; }
538 538
 		# execute
539
-		try { $this->Database->updateObject("scanAgents", array("id"=>$id, "last_access"=>date("Y-m-d H:i:s")), "id"); }
539
+		try { $this->Database->updateObject ("scanAgents", array ("id"=>$id, "last_access"=>date ("Y-m-d H:i:s")), "id"); }
540 540
 		catch (Exception $e) {
541 541
 		}
542 542
 	}
@@ -551,20 +551,20 @@  discard block
 block discarded – undo
551 551
 	 */
552 552
 	public function telnet_address ($address, $port) {
553 553
 		# set all ports
554
-		$ports = explode(",", str_replace(";",",",$port));
554
+		$ports = explode (",", str_replace (";", ",", $port));
555 555
 		# default response is dead
556 556
 		$retval = 1;
557 557
 		//try each port untill one is alive
558
-		foreach($ports as $p) {
558
+		foreach ($ports as $p) {
559 559
 			// open socket
560
-			$conn = @fsockopen($address, $p, $errno, $errstr, $this->icmp_timeout);
560
+			$conn = @fsockopen ($address, $p, $errno, $errstr, $this->icmp_timeout);
561 561
 			//failed
562 562
 			if (!$conn) {}
563 563
 			//success
564
-			else 		{
565
-				$retval = 0;	//set return as port if alive
566
-				fclose($conn);
567
-				break;			//end foreach if success
564
+			else {
565
+				$retval = 0; //set return as port if alive
566
+				fclose ($conn);
567
+				break; //end foreach if success
568 568
 			}
569 569
 		}
570 570
 	    # exit with result
@@ -595,11 +595,11 @@  discard block
 block discarded – undo
595 595
 	 */
596 596
 	public function prepare_addresses_to_scan ($type, $subnet, $die = true) {
597 597
 		# discover new addresses
598
-		if($type=="discovery") 	{ return is_numeric($subnet) ? $this->prepare_addresses_to_discover_subnetId ($subnet, $die) : $this->prepare_addresses_to_discover_subnet ($subnet, $die); }
598
+		if ($type == "discovery") { return is_numeric ($subnet) ? $this->prepare_addresses_to_discover_subnetId ($subnet, $die) : $this->prepare_addresses_to_discover_subnet ($subnet, $die); }
599 599
 		# update addresses statuses
600
-		elseif($type=="update") { return $this->prepare_addresses_to_update ($subnet); }
600
+		elseif ($type == "update") { return $this->prepare_addresses_to_update ($subnet); }
601 601
 		# fail
602
-		else 					{ die(json_encode(array("status"=>1, "error"=>"Invalid scan type provided"))); }
602
+		else { die(json_encode (array ("status"=>1, "error"=>"Invalid scan type provided"))); }
603 603
 	}
604 604
 
605 605
 	/**
@@ -611,19 +611,19 @@  discard block
 block discarded – undo
611 611
 	 */
612 612
 	public function prepare_addresses_to_discover_subnetId ($subnetId, $die) {
613 613
 		# initialize classes
614
-		$Subnets   = new Subnets ($this->Database);
614
+		$Subnets = new Subnets ($this->Database);
615 615
 
616 616
 		//subnet ID is provided, fetch subnet
617
-		$subnet = $Subnets->fetch_subnet(null, $subnetId);
618
-		if($subnet===false)	{
619
-			 if ($die)											{ die(json_encode(array("status"=>1, "error"=>"Invalid subnet ID provided"))); }
620
-			 else												{ return array(); }
617
+		$subnet = $Subnets->fetch_subnet (null, $subnetId);
618
+		if ($subnet === false) {
619
+			 if ($die) { die(json_encode (array ("status"=>1, "error"=>"Invalid subnet ID provided"))); }
620
+			 else { return array (); }
621 621
 		}
622 622
 
623 623
 		// we should support only up to 4094 hosts!
624
-		if($Subnets->get_max_hosts ($subnet->mask, "IPv4")>4094 && php_sapi_name()!="cli")
625
-		if ($die)												{ die(json_encode(array("status"=>1, "error"=>"Scanning from GUI is only available for subnets up to /20 or 4094 hosts!"))); }
626
-		else													{ return array(); }
624
+		if ($Subnets->get_max_hosts ($subnet->mask, "IPv4") > 4094 && php_sapi_name () != "cli")
625
+		if ($die) { die(json_encode (array ("status"=>1, "error"=>"Scanning from GUI is only available for subnets up to /20 or 4094 hosts!"))); }
626
+		else { return array (); }
627 627
 
628 628
 		# set array of addresses to scan, exclude existing!
629 629
 		$ip = $this->get_all_possible_subnet_addresses ($subnet->subnet, $subnet->mask);
@@ -632,9 +632,9 @@  discard block
 block discarded – undo
632 632
 		$ip = $this->remove_existing_subnet_addresses ($ip, $subnetId);
633 633
 
634 634
 		//none to scan?
635
-		if(sizeof($ip)==0)	{
636
-			if ($die)											{ die(json_encode(array("status"=>1, "error"=>"Didn't find any address to scan!"))); }
637
-			else												{ return array(); }
635
+		if (sizeof ($ip) == 0) {
636
+			if ($die) { die(json_encode (array ("status"=>1, "error"=>"Didn't find any address to scan!"))); }
637
+			else { return array (); }
638 638
 		}
639 639
 
640 640
 		//return
@@ -653,23 +653,23 @@  discard block
 block discarded – undo
653 653
 		# initialize classes
654 654
 		$Subnets   = new Subnets ($this->Database);
655 655
 		# make sure we have proper subnet format
656
-		$subnet    = $Subnets->transform_address($subnet, "decimal");
656
+		$subnet    = $Subnets->transform_address ($subnet, "decimal");
657 657
 		//fetch start and stop addresses
658 658
 		$boundaries = (object) $Subnets->get_network_boundaries ($subnet, $mask);
659 659
 		//create array
660
-		if($mask==32) {
661
-			$ip[] = $Subnets->transform_to_decimal($boundaries->network);
660
+		if ($mask == 32) {
661
+			$ip[] = $Subnets->transform_to_decimal ($boundaries->network);
662 662
 		}
663
-		elseif($mask==31) {
664
-			$ip[] = $Subnets->transform_to_decimal($boundaries->network);
665
-			$ip[] = $Subnets->transform_to_decimal($boundaries->broadcast);
663
+		elseif ($mask == 31) {
664
+			$ip[] = $Subnets->transform_to_decimal ($boundaries->network);
665
+			$ip[] = $Subnets->transform_to_decimal ($boundaries->broadcast);
666 666
 		}
667 667
 		else {
668 668
 			//set loop limits
669
-			$start = gmp_strval(gmp_add($Subnets->transform_to_decimal($boundaries->network),1));
670
-			$stop  = gmp_strval($Subnets->transform_to_decimal($boundaries->broadcast));
669
+			$start = gmp_strval (gmp_add ($Subnets->transform_to_decimal ($boundaries->network), 1));
670
+			$stop  = gmp_strval ($Subnets->transform_to_decimal ($boundaries->broadcast));
671 671
 			//loop
672
-			for($m=$start; $m<$stop; $m++) {
672
+			for ($m = $start; $m < $stop; $m++) {
673 673
 				$ip[] = $m;
674 674
 			}
675 675
 		}
@@ -689,20 +689,20 @@  discard block
 block discarded – undo
689 689
 		# first fetch all addresses
690 690
 		$Addresses = new Addresses ($this->Database);
691 691
 		// get all existing IP addresses in subnet
692
-		$addresses  = $Addresses->fetch_subnet_addresses($subnetId);
692
+		$addresses = $Addresses->fetch_subnet_addresses ($subnetId);
693 693
 		// if some exist remove them
694
-		if(sizeof($addresses)>0 && sizeof(@$ip)>0) {
695
-			foreach($addresses as $a) {
696
-				$key = array_search($a->ip_addr, $ip);
697
-				if($key !== false) {
694
+		if (sizeof ($addresses) > 0 && sizeof (@$ip) > 0) {
695
+			foreach ($addresses as $a) {
696
+				$key = array_search ($a->ip_addr, $ip);
697
+				if ($key !== false) {
698 698
 					unset($ip[$key]);
699 699
 				}
700 700
 			}
701 701
 			//reindex array for pinging
702
-			$ip = array_values(@$ip);
702
+			$ip = array_values (@$ip);
703 703
 		}
704 704
 		//return
705
-		return is_array(@$ip) ? $ip : array();
705
+		return is_array (@$ip) ? $ip : array ();
706 706
 	}
707 707
 
708 708
 	/**
@@ -714,11 +714,11 @@  discard block
 block discarded – undo
714 714
 	 */
715 715
 	public function prepare_addresses_to_discover_subnet ($subnet) {
716 716
 		//set subnet / mask
717
-		$subnet_parsed = explode("/", $subnet);
717
+		$subnet_parsed = explode ("/", $subnet);
718 718
 		# result
719 719
 		$ip = $this->get_all_possible_subnet_addresses ($subnet_parsed[0], $subnet_parsed[1]);
720 720
 		//none to scan?
721
-		if(sizeof($ip)==0)									{ die(json_encode(array("status"=>1, "error"=>"Didn't find any address to scan!"))); }
721
+		if (sizeof ($ip) == 0) { die(json_encode (array ("status"=>1, "error"=>"Didn't find any address to scan!"))); }
722 722
 		//result
723 723
 		return $ip;
724 724
 	}
@@ -734,19 +734,19 @@  discard block
 block discarded – undo
734 734
 		# first fetch all addresses
735 735
 		$Addresses = new Addresses ($this->Database);
736 736
 		// get all existing IP addresses in subnet
737
-		$subnet_addresses = $Addresses->fetch_subnet_addresses($subnetId);
737
+		$subnet_addresses = $Addresses->fetch_subnet_addresses ($subnetId);
738 738
 		//create array
739
-		if(sizeof($subnet_addresses)>0) {
740
-			foreach($subnet_addresses as $a) {
739
+		if (sizeof ($subnet_addresses) > 0) {
740
+			foreach ($subnet_addresses as $a) {
741 741
 				$scan_addresses[$a->id] = $a->ip_addr;
742 742
 			}
743 743
 			//reindex
744
-			$scan_addresses = array_values(@$scan_addresses);
744
+			$scan_addresses = array_values (@$scan_addresses);
745 745
 			//return
746 746
 			return $scan_addresses;
747 747
 		}
748 748
 		else {
749
-			return array();
749
+			return array ();
750 750
 		}
751 751
 	}
752 752
 }
Please login to merge, or discard this patch.
functions/classes/class.Thread.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -248,7 +248,7 @@
 block discarded – undo
248 248
 	/**
249 249
 	* alias of stop();
250 250
 	*
251
-	* @return boolean
251
+	* @return boolean|null
252 252
 	*/
253 253
     public function kill( $_signal = SIGKILL, $_wait = false ) {
254 254
         return $this->stop( $_signal, $_wait );
Please login to merge, or discard this patch.
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	*
17 17
 	* @var array
18 18
 	*/
19
-    private $errors = array(
19
+    private $errors = array (
20 20
         Thread::FUNCTION_NOT_CALLABLE => 'You must specify a valid function name that can be called from the current scope.',
21 21
         Thread::COULD_NOT_FORK => 'pcntl_fork() returned a status of -1. No new process was created',
22 22
     );
@@ -52,13 +52,13 @@  discard block
 block discarded – undo
52 52
 	*
53 53
 	* @return boolean
54 54
 	*/
55
-    public static function available() {
56
-        $required_functions = array(
55
+    public static function available () {
56
+        $required_functions = array (
57 57
             'pcntl_fork',
58 58
         );
59 59
 
60
-        foreach( $required_functions as $function ) {
61
-            if ( !function_exists( $function ) ) {
60
+        foreach ($required_functions as $function) {
61
+            if (!function_exists ($function)) {
62 62
                 return false;
63 63
             }
64 64
         }
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
 	*
73 73
 	* @param callback $_runnable
74 74
 	*/
75
-    public function __construct( $_runnable = null ) {
76
-		if( $_runnable !== null ) {
77
-			$this->setRunnable( $_runnable );
75
+    public function __construct ($_runnable = null) {
76
+		if ($_runnable !== null) {
77
+			$this->setRunnable ($_runnable);
78 78
 		}
79 79
     }
80 80
 
@@ -84,12 +84,12 @@  discard block
 block discarded – undo
84 84
 	* @param callback $_runnable
85 85
 	* @return callback
86 86
 	*/
87
-    public function setRunnable( $_runnable ) {
88
-        if( self::runnableOk( $_runnable ) ) {
87
+    public function setRunnable ($_runnable) {
88
+        if (self::runnableOk ($_runnable)) {
89 89
             $this->runnable = $_runnable;
90 90
         }
91 91
         else {
92
-            throw new Exception( $this->getError( Thread::FUNCTION_NOT_CALLABLE ), Thread::FUNCTION_NOT_CALLABLE );
92
+            throw new Exception ($this->getError (Thread::FUNCTION_NOT_CALLABLE), Thread::FUNCTION_NOT_CALLABLE);
93 93
         }
94 94
     }
95 95
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	*
99 99
 	* @return callback
100 100
 	*/
101
-    public function getRunnable() {
101
+    public function getRunnable () {
102 102
         return $this->runnable;
103 103
     }
104 104
 
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 	* @param callback $_runnable
113 113
 	* @return boolean
114 114
 	*/
115
-    public static function runnableOk( $_runnable ) {
116
-        return ( function_exists( $_runnable ) && is_callable( $_runnable ) );
115
+    public static function runnableOk ($_runnable) {
116
+        return (function_exists ($_runnable) && is_callable ($_runnable));
117 117
     }
118 118
 
119 119
 	/**
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	*
122 122
 	* @return int
123 123
 	*/
124
-    public function getPid() {
124
+    public function getPid () {
125 125
         return $this->pid;
126 126
     }
127 127
 
@@ -130,14 +130,14 @@  discard block
 block discarded – undo
130 130
 	*
131 131
 	* @return boolean
132 132
 	*/
133
-    public function isAlive() {
134
-        $pid = pcntl_waitpid( $this->pid, $status, WNOHANG );
133
+    public function isAlive () {
134
+        $pid = pcntl_waitpid ($this->pid, $status, WNOHANG);
135 135
 
136 136
         if ($pid === 0) { // child is still alive
137 137
             return true;
138 138
         } else {
139
-            if (pcntl_wifexited($status) && $this->exitCode == -1) { // normal exit
140
-                $this->exitCode = pcntl_wexitstatus($status);
139
+            if (pcntl_wifexited ($status) && $this->exitCode == -1) { // normal exit
140
+                $this->exitCode = pcntl_wexitstatus ($status);
141 141
             }
142 142
             return false;
143 143
         }
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
 	*
149 149
 	* @return int
150 150
 	*/
151
-    public function getExitCode() {
152
-        $this->isAlive();
151
+    public function getExitCode () {
152
+        $this->isAlive ();
153 153
         return $this->exitCode;
154 154
     }
155 155
 
@@ -159,27 +159,27 @@  discard block
 block discarded – undo
159 159
 	*
160 160
 	* @return void
161 161
 	*/
162
-    public function start() {
163
-        $pid = @ pcntl_fork();
164
-        if( $pid == -1 ) {
165
-            throw new Exception( $this->getError( Thread::COULD_NOT_FORK ), Thread::COULD_NOT_FORK );
162
+    public function start () {
163
+        $pid = @ pcntl_fork ();
164
+        if ($pid == -1) {
165
+            throw new Exception ($this->getError (Thread::COULD_NOT_FORK), Thread::COULD_NOT_FORK);
166 166
         }
167
-        if( $pid ) {
167
+        if ($pid) {
168 168
             // parent
169 169
             $this->pid = $pid;
170 170
         }
171 171
         else {
172 172
             // child
173
-            pcntl_signal( SIGTERM, array( $this, 'signalHandler' ) );
174
-            $arguments = func_get_args();
175
-            if ( !empty( $arguments ) ) {
176
-                call_user_func_array( $this->runnable, $arguments );
173
+            pcntl_signal (SIGTERM, array ($this, 'signalHandler'));
174
+            $arguments = func_get_args ();
175
+            if (!empty($arguments)) {
176
+                call_user_func_array ($this->runnable, $arguments);
177 177
             }
178 178
             else {
179
-                call_user_func( $this->runnable );
179
+                call_user_func ($this->runnable);
180 180
             }
181 181
 
182
-            exit( 0 );
182
+            exit(0);
183 183
         }
184 184
     }
185 185
 
@@ -191,40 +191,40 @@  discard block
 block discarded – undo
191 191
 	*
192 192
 	* @return void
193 193
 	*/
194
-    public function start_fping() {
194
+    public function start_fping () {
195 195
 		$status = 0;
196 196
 		$results = null;
197
-		$pid = pcntl_fork();
197
+		$pid = pcntl_fork ();
198 198
 
199
-		if( $pid == -1 ) { //error forking, no child is created
200
-			throw new Exception( $this->getError( Thread::COULD_NOT_FORK ), Thread::COULD_NOT_FORK );
201
-		}else if ( $pid ) {// parent
199
+		if ($pid == -1) { //error forking, no child is created
200
+			throw new Exception ($this->getError (Thread::COULD_NOT_FORK), Thread::COULD_NOT_FORK);
201
+		} else if ($pid) {// parent
202 202
 			$this->pid = $pid;
203 203
 
204 204
 		} else { // child
205
-			$this->pid = posix_getpid();//pid (child)
206
-			$this->ppid = posix_getppid();//pid (parent)
205
+			$this->pid = posix_getpid (); //pid (child)
206
+			$this->ppid = posix_getppid (); //pid (parent)
207 207
 
208
-			pcntl_signal( SIGTERM, array( $this, 'signalHandler' ) );
209
-			$array_args = func_get_args();
210
-			if ( !empty( $array_args ) ) {
211
-				$results = call_user_func_array( $this->runnable, $array_args );
212
-			}else{
213
-				$results = call_user_func( $this->runnable );
208
+			pcntl_signal (SIGTERM, array ($this, 'signalHandler'));
209
+			$array_args = func_get_args ();
210
+			if (!empty($array_args)) {
211
+				$results = call_user_func_array ($this->runnable, $array_args);
212
+			} else {
213
+				$results = call_user_func ($this->runnable);
214 214
 			}
215 215
 
216
-			$pipe = "/tmp/pipe_".$this->pid;//pid is known by parent
216
+			$pipe = "/tmp/pipe_".$this->pid; //pid is known by parent
217 217
 
218
-			if(!file_exists($pipe)) {//child talks to parent using this pipe
219
-				umask(0);
220
-				posix_mkfifo($pipe, 0600);
218
+			if (!file_exists ($pipe)) {//child talks to parent using this pipe
219
+				umask (0);
220
+				posix_mkfifo ($pipe, 0600);
221 221
 			}
222 222
 			//we have to open the pipe and send the data serialized
223
-			$pipe_descriptor = fopen($pipe, 'w');
224
-			fwrite($pipe_descriptor, serialize( $results ) );
223
+			$pipe_descriptor = fopen ($pipe, 'w');
224
+			fwrite ($pipe_descriptor, serialize ($results));
225 225
 
226 226
 			//and kill the child using posix_kill ( exit(0) duplicates headers!! )
227
-			posix_kill( $this->pid , SIGKILL);
227
+			posix_kill ($this->pid, SIGKILL);
228 228
 			exit(0);
229 229
 		}
230 230
     }
@@ -236,11 +236,11 @@  discard block
 block discarded – undo
236 236
 	* @param integer $_signal - SIGKILL/SIGTERM
237 237
 	* @param boolean $_wait
238 238
 	*/
239
-    public function stop( $_signal = SIGKILL, $_wait = false ) {
240
-        if( $this->isAlive() ) {
241
-            posix_kill( $this->pid, $_signal );
242
-            if( $_wait ) {
243
-                pcntl_waitpid( $this->pid, $status = 0 );
239
+    public function stop ($_signal = SIGKILL, $_wait = false) {
240
+        if ($this->isAlive ()) {
241
+            posix_kill ($this->pid, $_signal);
242
+            if ($_wait) {
243
+                pcntl_waitpid ($this->pid, $status = 0);
244 244
             }
245 245
         }
246 246
     }
@@ -250,8 +250,8 @@  discard block
 block discarded – undo
250 250
 	*
251 251
 	* @return boolean
252 252
 	*/
253
-    public function kill( $_signal = SIGKILL, $_wait = false ) {
254
-        return $this->stop( $_signal, $_wait );
253
+    public function kill ($_signal = SIGKILL, $_wait = false) {
254
+        return $this->stop ($_signal, $_wait);
255 255
     }
256 256
 
257 257
 	/**
@@ -261,12 +261,12 @@  discard block
 block discarded – undo
261 261
 	* @param integer $_code
262 262
 	* @return string
263 263
 	*/
264
-    public function getError( $_code ) {
265
-        if ( isset( $this->errors[$_code] ) ) {
264
+    public function getError ($_code) {
265
+        if (isset($this->errors[$_code])) {
266 266
             return $this->errors[$_code];
267 267
         }
268 268
         else {
269
-            return 'No such error code ' . $_code . '! Quit inventing errors!!!';
269
+            return 'No such error code '.$_code.'! Quit inventing errors!!!';
270 270
         }
271 271
     }
272 272
 
@@ -275,10 +275,10 @@  discard block
 block discarded – undo
275 275
 	*
276 276
 	* @param integer $_signal
277 277
 	*/
278
-    protected function signalHandler( $_signal ) {
279
-        switch( $_signal ) {
278
+    protected function signalHandler ($_signal) {
279
+        switch ($_signal) {
280 280
             case SIGTERM:
281
-                exit( 0 );
281
+                exit(0);
282 282
             break;
283 283
         }
284 284
     }
Please login to merge, or discard this patch.
functions/classes/class.Install.php 2 patches
Doc Comments   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 * @param bool $drop_database (default: false)
68 68
 	 * @param bool $create_database (default: false)
69 69
 	 * @param bool $create_grants (default: false)
70
-	 * @return void
70
+	 * @return boolean|null
71 71
 	 */
72 72
 	public function install_database ($rootuser, $rootpass, $drop_database = false, $create_database = false, $create_grants = false) {
73 73
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * Execute files installation
146 146
 	 *
147 147
 	 * @access private
148
-	 * @return void
148
+	 * @return false|null
149 149
 	 */
150 150
 	private function install_database_execute () {
151 151
 	    # import SCHEMA file queries
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	 *
198 198
 	 * @access public
199 199
 	 * @param bool $redirect
200
-	 * @return void
200
+	 * @return boolean
201 201
 	 */
202 202
 	public function check_db_connection ($redirect = false) {
203 203
 		# try to connect
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	 *
218 218
 	 * @access public
219 219
 	 * @param mixed $table
220
-	 * @return void
220
+	 * @return boolean
221 221
 	 */
222 222
 	public function check_table ($table, $redirect = false) {
223 223
 		# set query
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	 * @param mixed $adminpass
285 285
 	 * @param mixed $siteTitle
286 286
 	 * @param mixed $siteURL
287
-	 * @return void
287
+	 * @return boolean
288 288
 	 */
289 289
 	function postauth_update($adminpass, $siteTitle, $siteURL) {
290 290
 		# update Admin pass
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 	 *
301 301
 	 * @access public
302 302
 	 * @param mixed $adminpass
303
-	 * @return void
303
+	 * @return boolean
304 304
 	 */
305 305
 	public function postauth_update_admin_pass ($adminpass) {
306 306
 		try { $this->Database->updateObject("users", array("password"=>$adminpass, "passChange"=>"No","username"=>"Admin"), "username"); }
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 	 * @access private
315 315
 	 * @param mixed $siteTitle
316 316
 	 * @param mixed $siteURL
317
-	 * @return void
317
+	 * @return boolean
318 318
 	 */
319 319
 	private function postauth_update_settings ($siteTitle, $siteURL) {
320 320
 		try { $this->Database->updateObject("settings", array("siteTitle"=>$siteTitle, "siteURL"=>$siteURL,"id"=>1), "id"); }
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 	 * Upgrade database checks and executes.
341 341
 	 *
342 342
 	 * @access public
343
-	 * @return void
343
+	 * @return null|boolean
344 344
 	 */
345 345
 	public function upgrade_database () {
346 346
 		# first check version
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 	 * Execute database upgrade.
362 362
 	 *
363 363
 	 * @access private
364
-	 * @return void
364
+	 * @return boolean
365 365
 	 */
366 366
 	private function upgrade_database_execute () {
367 367
 		# set queries
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 	 * Fetch all upgrade queries from DB files
409 409
 	 *
410 410
 	 * @access public
411
-	 * @return void
411
+	 * @return string
412 412
 	 */
413 413
 	public function get_upgrade_queries () {
414 414
 		// save all queries fro UPDATE.sql file
Please login to merge, or discard this patch.
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 		# set debugging
86 86
 		$this->set_db_params ();
87 87
 		# Log object
88
-		try { $this->Database->connect(); }
89
-		catch ( Exception $e ) {}
88
+		try { $this->Database->connect (); }
89
+		catch (Exception $e) {}
90 90
 	}
91 91
 
92 92
 
@@ -122,23 +122,23 @@  discard block
 block discarded – undo
122 122
 		$this->Database_root->install = true;
123 123
 
124 124
 		# drop database if requested
125
-		if($drop_database===true) 	{ $this->drop_database(); }
125
+		if ($drop_database === true) { $this->drop_database (); }
126 126
 
127 127
 		# create database if requested
128
-		if($create_database===true) { $this->create_database(); }
128
+		if ($create_database === true) { $this->create_database (); }
129 129
 
130 130
 		# set permissions!
131
-		if($create_grants===true) 	{ $this->create_grants(); }
131
+		if ($create_grants === true) { $this->create_grants (); }
132 132
 
133 133
 	    # reset connection, reset install flag and connect again
134
-		$this->Database_root->resetConn();
134
+		$this->Database_root->resetConn ();
135 135
 
136 136
 		# install database
137
-		if($this->install_database_execute () !== false) {
137
+		if ($this->install_database_execute () !== false) {
138 138
 		    # return true, if some errors occured script already died! */
139
-			sleep(1);
139
+			sleep (1);
140 140
 			$this->Log = new Logging ($this->Database);
141
-			$this->Log->write( "Database installation", "Database installed successfully. Version ".VERSION.".".REVISION." installed", 1 );
141
+			$this->Log->write ("Database installation", "Database installed successfully. Version ".VERSION.".".REVISION." installed", 1);
142 142
 			return true;
143 143
 		}
144 144
 	}
@@ -151,10 +151,10 @@  discard block
 block discarded – undo
151 151
 	 */
152 152
 	private function drop_database () {
153 153
 	 	# set query
154
-	    $query = "drop database if exists `". $this->db['name'] ."`;";
154
+	    $query = "drop database if exists `".$this->db['name']."`;";
155 155
 		# execute
156
-		try { $this->Database_root->runQuery($query); }
157
-		catch (Exception $e) {	$this->Result->show("danger", $e->getMessage(), true);}
156
+		try { $this->Database_root->runQuery ($query); }
157
+		catch (Exception $e) {	$this->Result->show ("danger", $e->getMessage (), true); }
158 158
 	}
159 159
 
160 160
 	/**
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
 	 */
166 166
 	private function create_database () {
167 167
 	 	# set query
168
-	    $query = "create database `". $this->db['name'] ."`;";
168
+	    $query = "create database `".$this->db['name']."`;";
169 169
 		# execute
170
-		try { $this->Database_root->runQuery($query); }
171
-		catch (Exception $e) {	$this->Result->show("danger", $e->getMessage(), true);}
170
+		try { $this->Database_root->runQuery ($query); }
171
+		catch (Exception $e) {	$this->Result->show ("danger", $e->getMessage (), true); }
172 172
 	}
173 173
 
174 174
 	/**
@@ -179,10 +179,10 @@  discard block
 block discarded – undo
179 179
 	 */
180 180
 	private function create_grants () {
181 181
 	 	# set query
182
-	    $query = 'grant ALL on `'. $this->db['name'] .'`.* to '. $this->db['user'] .'@localhost identified by "'. $this->db['pass'] .'";';
182
+	    $query = 'grant ALL on `'.$this->db['name'].'`.* to '.$this->db['user'].'@localhost identified by "'.$this->db['pass'].'";';
183 183
 		# execute
184
-		try { $this->Database_root->runQuery($query); }
185
-		catch (Exception $e) {	$this->Result->show("danger", $e->getMessage(), true);}
184
+		try { $this->Database_root->runQuery ($query); }
185
+		catch (Exception $e) {	$this->Result->show ("danger", $e->getMessage (), true); }
186 186
 	}
187 187
 
188 188
 	/**
@@ -193,28 +193,28 @@  discard block
 block discarded – undo
193 193
 	 */
194 194
 	private function install_database_execute () {
195 195
 	    # import SCHEMA file queries
196
-	    $query  = file_get_contents("../../db/SCHEMA.sql");
196
+	    $query = file_get_contents ("../../db/SCHEMA.sql");
197 197
 
198 198
 	    # formulate queries
199
-	    $queries = array_filter(explode(";\n", $query));
199
+	    $queries = array_filter (explode (";\n", $query));
200 200
 
201 201
 	    # execute
202
-	    foreach($queries as $q) {
202
+	    foreach ($queries as $q) {
203 203
 		    //length check
204
-		    if (strlen($q)>0) {
205
-				try { $this->Database_root->runQuery($q.";"); }
204
+		    if (strlen ($q) > 0) {
205
+				try { $this->Database_root->runQuery ($q.";"); }
206 206
 				catch (Exception $e) {
207 207
 					//unlock tables
208
-					try { $this->Database_root->runQuery("UNLOCK TABLES;"); }
208
+					try { $this->Database_root->runQuery ("UNLOCK TABLES;"); }
209 209
 					catch (Exception $e) {}
210 210
 					//drop database
211
-					try { $this->Database_root->runQuery("drop database if exists `". $this->db['name'] ."`;"); }
211
+					try { $this->Database_root->runQuery ("drop database if exists `".$this->db['name']."`;"); }
212 212
 					catch (Exception $e) {
213
-						$this->Result->show("danger", 'Cannot drop database: '.$e->getMessage(), true);
213
+						$this->Result->show ("danger", 'Cannot drop database: '.$e->getMessage (), true);
214 214
 					}
215 215
 					//print error
216
-					$this->Result->show("danger", "Cannot install sql SCHEMA file: ".$e->getMessage()."<br>query that failed: <pre>$q</pre>", false);
217
-					$this->Result->show("info", "Database dropped", false);
216
+					$this->Result->show ("danger", "Cannot install sql SCHEMA file: ".$e->getMessage ()."<br>query that failed: <pre>$q</pre>", false);
217
+					$this->Result->show ("info", "Database dropped", false);
218 218
 
219 219
 					return false;
220 220
 				}
@@ -245,12 +245,12 @@  discard block
 block discarded – undo
245 245
 	 */
246 246
 	public function check_db_connection ($redirect = false) {
247 247
 		# try to connect
248
-		try { $res = $this->Database->connect(); }
249
-		catch (Exception $e) 	{
250
-			$this->exception = $e->getMessage();
248
+		try { $res = $this->Database->connect (); }
249
+		catch (Exception $e) {
250
+			$this->exception = $e->getMessage ();
251 251
 			# redirect ?
252
-			if($redirect == true)  	{ $this->redirect_to_install (); }
253
-			else					{ return false; }
252
+			if ($redirect == true) { $this->redirect_to_install (); }
253
+			else { return false; }
254 254
 		}
255 255
 		# ok
256 256
 		return true;
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
 		# set query
268 268
 		$query = "SELECT COUNT(*) AS `cnt` FROM information_schema.tables WHERE table_schema = '".$this->db['name']."' AND table_name = '$table';";
269 269
 		# try to fetch count
270
-		try { $table = $this->Database->getObjectQuery($query); }
271
-		catch (Exception $e) 	{ if($redirect === true) $this->redirect_to_install ();	else return false; }
270
+		try { $table = $this->Database->getObjectQuery ($query); }
271
+		catch (Exception $e) { if ($redirect === true) $this->redirect_to_install (); else return false; }
272 272
 		# redirect if it is not existing
273
-		if($table->cnt!=1) 	 	{ if($redirect === true) $this->redirect_to_install ();	else return false; }
273
+		if ($table->cnt != 1) { if ($redirect === true) $this->redirect_to_install (); else return false; }
274 274
 		# ok
275 275
 		return true;
276 276
 	}
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 	 */
284 284
 	private function redirect_to_install () {
285 285
 		# redirect to install
286
-		header("Location: ".create_link("install"));
286
+		header ("Location: ".create_link ("install"));
287 287
 	}
288 288
 
289 289
 	/**
@@ -293,8 +293,8 @@  discard block
 block discarded – undo
293 293
 	 * @return void
294 294
 	 */
295 295
 	public function set_debugging () {
296
-		require( dirname(__FILE__) . '/../../config.php' );
297
-		if($debugging==true) { $this->debugging = true; }
296
+		require(dirname (__FILE__).'/../../config.php');
297
+		if ($debugging == true) { $this->debugging = true; }
298 298
 	}
299 299
 
300 300
 	/**
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 	 * @return void
305 305
 	 */
306 306
 	private function set_db_params () {
307
-		require( dirname(__FILE__) . '/../../config.php' );
307
+		require(dirname (__FILE__).'/../../config.php');
308 308
 		$this->db = $db;
309 309
 	}
310 310
 
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	 * @param mixed $siteURL
331 331
 	 * @return void
332 332
 	 */
333
-	function postauth_update($adminpass, $siteTitle, $siteURL) {
333
+	function postauth_update ($adminpass, $siteTitle, $siteURL) {
334 334
 		# update Admin pass
335 335
 		$this->postauth_update_admin_pass ($adminpass);
336 336
 		# update settings
@@ -347,8 +347,8 @@  discard block
 block discarded – undo
347 347
 	 * @return void
348 348
 	 */
349 349
 	public function postauth_update_admin_pass ($adminpass) {
350
-		try { $this->Database->updateObject("users", array("password"=>$adminpass, "passChange"=>"No","username"=>"Admin"), "username"); }
351
-		catch (Exception $e) { $this->Result->show("danger", $e->getMessage(), false); }
350
+		try { $this->Database->updateObject ("users", array ("password"=>$adminpass, "passChange"=>"No", "username"=>"Admin"), "username"); }
351
+		catch (Exception $e) { $this->Result->show ("danger", $e->getMessage (), false); }
352 352
 		return true;
353 353
 	}
354 354
 
@@ -361,8 +361,8 @@  discard block
 block discarded – undo
361 361
 	 * @return void
362 362
 	 */
363 363
 	private function postauth_update_settings ($siteTitle, $siteURL) {
364
-		try { $this->Database->updateObject("settings", array("siteTitle"=>$siteTitle, "siteURL"=>$siteURL,"id"=>1), "id"); }
365
-		catch (Exception $e) { $this->Result->show("danger", $e->getMessage(), false); }
364
+		try { $this->Database->updateObject ("settings", array ("siteTitle"=>$siteTitle, "siteURL"=>$siteURL, "id"=>1), "id"); }
365
+		catch (Exception $e) { $this->Result->show ("danger", $e->getMessage (), false); }
366 366
 		return true;
367 367
 	}
368 368
 
@@ -390,10 +390,10 @@  discard block
 block discarded – undo
390 390
 		# first check version
391 391
 		$this->get_settings ();
392 392
 
393
-		if($this->settings->version == VERSION)				{ $this->Result->show("danger", "Database already at latest version", true); }
393
+		if ($this->settings->version == VERSION) { $this->Result->show ("danger", "Database already at latest version", true); }
394 394
 		else {
395 395
 			# check db connection
396
-			if($this->check_db_connection(false)===false)  	{ $this->Result->show("danger", "Cannot connect to database", true); }
396
+			if ($this->check_db_connection (false) === false) { $this->Result->show ("danger", "Cannot connect to database", true); }
397 397
 			# execute
398 398
 			else {
399 399
 				return $this->upgrade_database_execute ();
@@ -411,26 +411,26 @@  discard block
 block discarded – undo
411 411
 		# set queries
412 412
 		$subversion_queries = $this->get_upgrade_queries ();
413 413
 		// create default arrays
414
-		$queries = array();
414
+		$queries = array ();
415 415
 		// succesfull queries:
416
-		$queries_ok = array();
416
+		$queries_ok = array ();
417 417
 
418 418
 		// replace CRLF
419
-		$subversion_queries = str_replace("\r\n", "\n", $subversion_queries);
420
-		$queries = array_filter(explode(";\n", $subversion_queries));
419
+		$subversion_queries = str_replace ("\r\n", "\n", $subversion_queries);
420
+		$queries = array_filter (explode (";\n", $subversion_queries));
421 421
 
422 422
 	    # execute all queries
423
-	    foreach($queries as $query) {
424
-    	    if (strlen($query)>5) {
425
-    			try { $this->Database->runQuery($query); }
423
+	    foreach ($queries as $query) {
424
+    	    if (strlen ($query) > 5) {
425
+    			try { $this->Database->runQuery ($query); }
426 426
     			catch (Exception $e) {
427 427
     				$this->Log = new Logging ($this->Database);
428 428
     				# write log
429
-    				$this->Log->write( "Database upgrade", $e->getMessage()."<br>query: ".$query, 2 );
429
+    				$this->Log->write ("Database upgrade", $e->getMessage ()."<br>query: ".$query, 2);
430 430
     				# fail
431 431
     				print "<h3>Upgrade failed !</h3><hr style='margin:30px;'>";
432
-    				$this->Result->show("danger", $e->getMessage()."<hr>Failed query: <pre>".$query.";</pre>", false);
433
-    				$this->Result->show("success", "Succesfull queries: <pre>".implode(";", $queries_ok).";</pre>", false);
432
+    				$this->Result->show ("danger", $e->getMessage ()."<hr>Failed query: <pre>".$query.";</pre>", false);
433
+    				$this->Result->show ("success", "Succesfull queries: <pre>".implode (";", $queries_ok).";</pre>", false);
434 434
     				# revert version
435 435
     				//try { $this->Database->runQuery('update `settings` set `version` = ?', array($this->settings->version)); }
436 436
     				//catch (Exception $e) { var_dump($e); }
@@ -444,9 +444,9 @@  discard block
 block discarded – undo
444 444
 
445 445
 
446 446
 		# all good, print it
447
-		sleep(1);
447
+		sleep (1);
448 448
 		$this->Log = new Logging ($this->Database);
449
-		$this->Log->write( "Database upgrade", "Database upgraded from version ".$this->settings->version." to version ".VERSION.".".REVISION, 1 );
449
+		$this->Log->write ("Database upgrade", "Database upgraded from version ".$this->settings->version." to version ".VERSION.".".REVISION, 1);
450 450
 		return true;
451 451
 	}
452 452
 
@@ -458,30 +458,30 @@  discard block
 block discarded – undo
458 458
 	 */
459 459
 	public function get_upgrade_queries () {
460 460
 		// save all queries fro UPDATE.sql file
461
-		$queries = str_replace("\r\n", "\n", (file_get_contents( dirname(__FILE__) . '/../../db/UPDATE.sql')));
461
+		$queries = str_replace ("\r\n", "\n", (file_get_contents (dirname (__FILE__).'/../../db/UPDATE.sql')));
462 462
 
463 463
 		// fetch settings if not present - for manual instructions
464 464
 		if (!isset($this->settings->version)) { $this->get_settings (); }
465 465
 
466 466
         // explode and loop to get next version from current
467 467
         $delimiter = false;
468
-        foreach (explode("/* VERSION ", $queries) as $k=>$q) {
469
-            $q_version = str_replace(" */", "", array_shift(explode("\n", $q)));
468
+        foreach (explode ("/* VERSION ", $queries) as $k=>$q) {
469
+            $q_version = str_replace (" */", "", array_shift (explode ("\n", $q)));
470 470
 
471 471
             // if delimiter was found in previous loop
472
-            if ($delimiter!==false) {
472
+            if ($delimiter !== false) {
473 473
                 $delimiter = $q_version;
474 474
                 break;
475 475
             }
476 476
             // if match with current set pointer to next item - delimiter
477
-            if ($q_version==$this->settings->version) {
477
+            if ($q_version == $this->settings->version) {
478 478
                 $delimiter = true;
479 479
             };
480 480
         }
481 481
 
482 482
         // remove older queries before this version
483
-        $old_queries = explode("/* VERSION $delimiter */", $queries);
484
-        $old_queries = trim($old_queries[1]);
483
+        $old_queries = explode ("/* VERSION $delimiter */", $queries);
484
+        $old_queries = trim ($old_queries[1]);
485 485
 
486 486
 		# return
487 487
 		return $old_queries;
Please login to merge, or discard this patch.
api/controllers/Responses.php 2 patches
Doc Comments   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -80,7 +80,6 @@  discard block
 block discarded – undo
80 80
 	 * Sets header based on provided HTTP code
81 81
 	 *
82 82
 	 * @access private
83
-	 * @param mixed $code
84 83
 	 * @return void
85 84
 	 */
86 85
 	private function set_header () {
@@ -99,7 +98,7 @@  discard block
 block discarded – undo
99 98
 	 *
100 99
 	 * @access public
101 100
 	 * @param mixed $result
102
-	 * @return void
101
+	 * @return string
103 102
 	 */
104 103
 	public function formulate_result ($result) {
105 104
 		// make sure result is array
@@ -210,7 +209,7 @@  discard block
 block discarded – undo
210 209
 	 * Outputs result
211 210
 	 *
212 211
 	 * @access private
213
-	 * @return void
212
+	 * @return string
214 213
 	 */
215 214
 	private function create_result () {
216 215
 		// reorder
@@ -239,7 +238,7 @@  discard block
 block discarded – undo
239 238
 	 * Creates XML result
240 239
 	 *
241 240
 	 * @access private
242
-	 * @return void
241
+	 * @return string|false
243 242
 	 */
244 243
 	private function create_xml () {
245 244
 		// convert whole object to array
@@ -329,7 +328,7 @@  discard block
 block discarded – undo
329 328
 	 * Creates JSON result
330 329
 	 *
331 330
 	 * @access private
332
-	 * @return void
331
+	 * @return string
333 332
 	 */
334 333
 	private function create_json () {
335 334
 		return json_encode((array) $this->result);
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @access public
55 55
 	 */
56
-	public function __construct() {
56
+	public function __construct () {
57 57
 		# set error codes
58 58
 		$this->set_error_codes ();
59 59
 	}
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 		// set header
110 110
 		$this->set_header ();
111 111
 		// throw exception
112
-		throw new Exception($exception);
112
+		throw new Exception ($exception);
113 113
 	}
114 114
 
115 115
 	/**
@@ -121,11 +121,11 @@  discard block
 block discarded – undo
121 121
 	 */
122 122
 	private function set_header () {
123 123
 		// wrong code
124
-		if(!isset($this->exception))		{ header("HTTP/1.1 500 Invalid result code"); }
125
-		else								{ header("HTTP/1.1 ".$this->result['code']." ".$this->errors[$this->result['code']]); }
124
+		if (!isset($this->exception)) { header ("HTTP/1.1 500 Invalid result code"); }
125
+		else { header ("HTTP/1.1 ".$this->result['code']." ".$this->errors[$this->result['code']]); }
126 126
 
127 127
 		// 401 - add location
128
-		if ($this->result['code']==401) {
128
+		if ($this->result['code'] == 401) {
129 129
 			$this->set_location_header ("/api/".$_REQUEST['app_id']."/user/");
130 130
 		}
131 131
 	}
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	 */
140 140
 	public function formulate_result ($result) {
141 141
 		// make sure result is array
142
-		$this->result = is_null($this->result) ? (array) $result : $this->result;
142
+		$this->result = is_null ($this->result) ? (array) $result : $this->result;
143 143
 
144 144
 		// get requested content type
145 145
 		$this->get_request_content_type ();
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 		// set cache header
150 150
 		$this->set_cache_header ();
151 151
 		// set result header if not already set with $result['success']=false
152
-		$this->exception===true ? : $this->set_success_header ();
152
+		$this->exception === true ? : $this->set_success_header ();
153 153
 
154 154
 		// return result
155 155
 		return $this->create_result ();
@@ -163,11 +163,11 @@  discard block
 block discarded – undo
163 163
 	 */
164 164
 	public function validate_content_type () {
165 165
 		// not set, presume json
166
-		if( !isset($_SERVER['CONTENT_TYPE']) ) {}
166
+		if (!isset($_SERVER['CONTENT_TYPE'])) {}
167 167
 		// post
168
-		elseif($_SERVER['CONTENT_TYPE']=="application/x-www-form-urlencoded") {}
168
+		elseif ($_SERVER['CONTENT_TYPE'] == "application/x-www-form-urlencoded") {}
169 169
 		// set, verify
170
-		elseif (!($_SERVER['CONTENT_TYPE']=="application/xml" || $_SERVER['CONTENT_TYPE']=="application/json")) {
170
+		elseif (!($_SERVER['CONTENT_TYPE'] == "application/xml" || $_SERVER['CONTENT_TYPE'] == "application/json")) {
171 171
 			$this->throw_exception (415, "Invalid Content type ".$_SERVER['CONTENT_TYPE']);
172 172
 		}
173 173
 	}
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 * @return void
180 180
 	 */
181 181
 	private function get_request_content_type () {
182
-		$this->result_type = $_SERVER['CONTENT_TYPE']=="application/xml" ? "xml" : "json";
182
+		$this->result_type = $_SERVER['CONTENT_TYPE'] == "application/xml" ? "xml" : "json";
183 183
 	}
184 184
 
185 185
 	/**
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 */
191 191
 	private function set_content_type_header () {
192 192
 		// content_type
193
-		$this->result_type == "xml" ? header('Content-Type: application/xml') : header('Content-Type: application/json');
193
+		$this->result_type == "xml" ? header ('Content-Type: application/xml') : header ('Content-Type: application/json');
194 194
 	}
195 195
 
196 196
 	/**
@@ -201,13 +201,13 @@  discard block
 block discarded – undo
201 201
 	 */
202 202
 	private function set_cache_header ($seconds = NULL) {
203 203
 		// none
204
-		if($seconds===NULL) {
205
-			header("Cache-Control: no-cache");
206
-			header("Pragma: no-cache");
204
+		if ($seconds === NULL) {
205
+			header ("Cache-Control: no-cache");
206
+			header ("Pragma: no-cache");
207 207
 		}
208 208
 		// cache
209 209
 		else {
210
-			header("Cache-Control: $seconds");
210
+			header ("Cache-Control: $seconds");
211 211
 		}
212 212
 	}
213 213
 
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 	 */
220 220
 	private function set_success_header () {
221 221
 		// check fo location
222
-		if(isset($this->result['location'])) {
222
+		if (isset($this->result['location'])) {
223 223
 			$this->set_location_header ($this->result['location']);
224 224
 		}
225 225
 
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	 * @return void
240 240
 	 */
241 241
 	private function set_location_header ($location) {
242
-		header("Location: ".$location);
242
+		header ("Location: ".$location);
243 243
 	}
244 244
 
245 245
 	/**
@@ -267,9 +267,9 @@  discard block
 block discarded – undo
267 267
 		// reset
268 268
 		$this->result['code'] = $tmp['code'];
269 269
 		$this->result['success'] = $tmp['success'];
270
-		if(isset($tmp['message']))	{ $this->result['message'] = $tmp['message']; }
271
-		if(isset($tmp['data']))		{ $this->result['data'] = $tmp['data']; }
272
-		if(isset($tmp['ip']))	    { $this->result['ip'] = $tmp['ip']; }
270
+		if (isset($tmp['message'])) { $this->result['message'] = $tmp['message']; }
271
+		if (isset($tmp['data'])) { $this->result['data'] = $tmp['data']; }
272
+		if (isset($tmp['ip'])) { $this->result['ip'] = $tmp['ip']; }
273 273
 	}
274 274
 
275 275
 	/**
@@ -280,15 +280,15 @@  discard block
 block discarded – undo
280 280
 	 */
281 281
 	private function create_xml () {
282 282
 		// convert whole object to array
283
-		$this->result = $this->object_to_array($this->result);
283
+		$this->result = $this->object_to_array ($this->result);
284 284
 
285 285
 		// new SimpleXMLElement object
286
-		$xml = new SimpleXMLElement('<'.$_GET['controller'].'/>');
286
+		$xml = new SimpleXMLElement ('<'.$_GET['controller'].'/>');
287 287
 		// generate xml from result
288
-		$this->array_to_xml($xml, $this->result);
288
+		$this->array_to_xml ($xml, $this->result);
289 289
 
290 290
 		// return XML result
291
-		return $xml->asXML();
291
+		return $xml->asXML ();
292 292
 	}
293 293
 
294 294
 	/**
@@ -299,23 +299,23 @@  discard block
 block discarded – undo
299 299
 	 * @param array $data
300 300
 	 * @return void
301 301
 	 */
302
-	private function array_to_xml(SimpleXMLElement $object, array $data) {
302
+	private function array_to_xml (SimpleXMLElement $object, array $data) {
303 303
 		// loop through values
304 304
 	    foreach ($data as $key => $value) {
305 305
 		    // if spaces exist in key replace them with underscores
306
-		    if(strpos($key, " ")>0)	{ $key = str_replace(" ", "_", $key); }
306
+		    if (strpos ($key, " ") > 0) { $key = str_replace (" ", "_", $key); }
307 307
 
308 308
 		    // if key is numeric append item
309
-		    if(is_numeric($key)) $key = "item".$key;
309
+		    if (is_numeric ($key)) $key = "item".$key;
310 310
 
311 311
 			// if array add child
312
-	        if (is_array($value)) {
313
-	            $new_object = $object->addChild($key);
314
-	            $this->array_to_xml($new_object, $value);
312
+	        if (is_array ($value)) {
313
+	            $new_object = $object->addChild ($key);
314
+	            $this->array_to_xml ($new_object, $value);
315 315
 	        }
316 316
 	        // else write value
317 317
 	        else {
318
-	            $object->addChild($key, $value);
318
+	            $object->addChild ($key, $value);
319 319
 	        }
320 320
 	    }
321 321
 	}
@@ -335,9 +335,9 @@  discard block
 block discarded – undo
335 335
 	 * @license http://creativecommons.org/licenses/by/3.0/
336 336
 	 * @license CC-BY-3.0 <http://spdx.org/licenses/CC-BY-3.0>
337 337
 	 */
338
-	public function xml_to_array ( $xmlObject, $out = array () ) {
339
-	    foreach ( (array) $xmlObject as $index => $node )
340
-	        $out[$index] = ( is_object ( $node ) ) ? $this->xml_to_array ( $node ) : $node;
338
+	public function xml_to_array ($xmlObject, $out = array ()) {
339
+	    foreach ((array) $xmlObject as $index => $node)
340
+	        $out[$index] = (is_object ($node)) ? $this->xml_to_array ($node) : $node;
341 341
 
342 342
 	    return $out;
343 343
 	}
@@ -351,11 +351,11 @@  discard block
 block discarded – undo
351 351
 	 */
352 352
 	private function object_to_array ($obj) {
353 353
 		// object to array
354
-	    if(is_object($obj)) $obj = (array) $obj;
355
-	    if(is_array($obj)) {
356
-	        $new = array();
357
-	        foreach($obj as $key => $val) {
358
-	            $new[$key] = $this->object_to_array($val);
354
+	    if (is_object ($obj)) $obj = (array) $obj;
355
+	    if (is_array ($obj)) {
356
+	        $new = array ();
357
+	        foreach ($obj as $key => $val) {
358
+	            $new[$key] = $this->object_to_array ($val);
359 359
 	        }
360 360
 	    }
361 361
 	    else $new = $obj;
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 	 * @return void
370 370
 	 */
371 371
 	private function create_json () {
372
-		return json_encode((array) $this->result);
372
+		return json_encode ((array) $this->result);
373 373
 	}
374 374
 
375 375
 
Please login to merge, or discard this patch.
api/controllers/User.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	 * Validates users token from database
331 331
 	 *
332 332
 	 * @access private
333
-	 * @return void
333
+	 * @return boolean
334 334
 	 */
335 335
 	private function validate_user_token () {
336 336
 		// is set
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 	 * Checks if token has expired
413 413
 	 *
414 414
 	 * @access private
415
-	 * @return void
415
+	 * @return boolean
416 416
 	 */
417 417
 	private function validate_token_expiration () {
418 418
 		return strtotime($this->token_expires) < time() ? true : false;
Please login to merge, or discard this patch.
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 * @param mixed $params
111 111
 	 * @param mixed $Response
112 112
 	 */
113
-	public function __construct ($Database, $Tools=null, $params=null, $Response) {
113
+	public function __construct ($Database, $Tools = null, $params = null, $Response) {
114 114
 		$this->Database = $Database;
115 115
 		$this->Response = $Response;
116 116
 		$this->_params = $params;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 		$this->set_token_length ();
124 124
 
125 125
 		// if HTTP_TOKEN is set change it to HTTP_PHPIPAM_TOKEN
126
-		if (isset($_SERVER['HTTP_TOKEN'])&&!isset($_SERVER['HTTP_PHPIPAM_TOKEN'])) 		{ $_SERVER['HTTP_PHPIPAM_TOKEN'] = $_SERVER['HTTP_TOKEN']; }
126
+		if (isset($_SERVER['HTTP_TOKEN']) && !isset($_SERVER['HTTP_PHPIPAM_TOKEN'])) { $_SERVER['HTTP_PHPIPAM_TOKEN'] = $_SERVER['HTTP_TOKEN']; }
127 127
 	}
128 128
 
129 129
 
@@ -146,15 +146,15 @@  discard block
 block discarded – undo
146 146
 		$this->validate_options_request ();
147 147
 
148 148
 		// methods
149
-		$result = array();
150
-		$result['methods'] = array(
151
-								array("href"=>"/api/".$this->_params->app_id."/user/", 	"methods"=>array(array("rel"=>"read", 	"method"=>"GET"),
152
-																										 array("rel"=>"create", "method"=>"POST"),
153
-																										 array("rel"=>"update", "method"=>"PATCH"),
154
-																										 array("rel"=>"delete", "method"=>"DELETE"))),
149
+		$result = array ();
150
+		$result['methods'] = array (
151
+								array ("href"=>"/api/".$this->_params->app_id."/user/", "methods"=>array (array ("rel"=>"read", "method"=>"GET"),
152
+																										 array ("rel"=>"create", "method"=>"POST"),
153
+																										 array ("rel"=>"update", "method"=>"PATCH"),
154
+																										 array ("rel"=>"delete", "method"=>"DELETE"))),
155 155
 							);
156 156
 		# result
157
-		return array("code"=>200, "data"=>$result);
157
+		return array ("code"=>200, "data"=>$result);
158 158
 	}
159 159
 
160 160
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 		// validate token
177 177
 		$this->validate_requested_token ();
178 178
 		// ok
179
-		return array("code"=>200, "data"=>array("expires"=>$this->token_expires));
179
+		return array ("code"=>200, "data"=>array ("expires"=>$this->token_expires));
180 180
 	}
181 181
 
182 182
 
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 		// refresh
215 215
 		$this->refresh_token_expiration ();
216 216
 		// ok
217
-		return array("code"=>200, "data"=>array("expires"=>$this->token_expires));
217
+		return array ("code"=>200, "data"=>array ("expires"=>$this->token_expires));
218 218
 	}
219 219
 
220 220
 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 		// remove token
237 237
 		$this->remove_token ();
238 238
 		// result
239
-		return array("code"=>200, "data"=>array("Token removed"));
239
+		return array ("code"=>200, "data"=>array ("Token removed"));
240 240
 	}
241 241
 
242 242
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 			// get count
281 281
 			$cnt = $this->User->block_check_ip ();
282 282
 			// failure
283
-			if ($cnt > $this->max_failures) 		{ $this->Response->throw_exception(500, "Your IP has been blocked for 5 minutes because of excesive login failures"); }
283
+			if ($cnt > $this->max_failures) { $this->Response->throw_exception (500, "Your IP has been blocked for 5 minutes because of excesive login failures"); }
284 284
 		}
285 285
 	}
286 286
 
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 		}
315 315
 
316 316
 	    # result
317
-	    return array("code"=>200, "data"=>array("token"=>$this->token, "expires"=>$this->token_expires));
317
+	    return array ("code"=>200, "data"=>array ("token"=>$this->token, "expires"=>$this->token_expires));
318 318
 	}
319 319
 
320 320
 
@@ -338,11 +338,11 @@  discard block
 block discarded – undo
338 338
 	 */
339 339
 	public function set_token_valid_time ($token_valid_time = null) {
340 340
 		// validate integer
341
-		if ($this->token_length!=null) {
342
-			if (!is_numeric($this->token_length))	{ $this->Response->throw_exception(500, "token valid time must be an integer"); }
341
+		if ($this->token_length != null) {
342
+			if (!is_numeric ($this->token_length)) { $this->Response->throw_exception (500, "token valid time must be an integer"); }
343 343
 		}
344 344
 		// save
345
-		$this->token_valid_time = is_null($token_valid_time) ? 21600 : $token_valid_time;
345
+		$this->token_valid_time = is_null ($token_valid_time) ? 21600 : $token_valid_time;
346 346
 	}
347 347
 
348 348
 	/**
@@ -352,13 +352,13 @@  discard block
 block discarded – undo
352 352
 	 * @param mixed $failures (default: null)
353 353
 	 * @return void
354 354
 	 */
355
-	public function set_max_failures ($failures=null) {
355
+	public function set_max_failures ($failures = null) {
356 356
 		// validate integer
357
-		if ($this->token_length!=null) {
358
-			if (!is_numeric($this->token_length))	{ $this->Response->throw_exception(500, "Max failures must be an integer"); }
357
+		if ($this->token_length != null) {
358
+			if (!is_numeric ($this->token_length)) { $this->Response->throw_exception (500, "Max failures must be an integer"); }
359 359
 		}
360 360
 		// save
361
-		$this->max_failures = $failures==null ? 10 : $failures;
361
+		$this->max_failures = $failures == null ? 10 : $failures;
362 362
 	}
363 363
 
364 364
 	/**
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
 	 */
371 371
 	public function block_ip ($block = true) {
372 372
 		// validate integer
373
-		if (!is_bool($block)) {
374
-			if (!is_numeric($this->token_length))	{ $this->Response->throw_exception(500, "Max failures must be an integer"); }
373
+		if (!is_bool ($block)) {
374
+			if (!is_numeric ($this->token_length)) { $this->Response->throw_exception (500, "Max failures must be an integer"); }
375 375
 		}
376 376
 		// save
377 377
 		$this->block_ip = $$block;
@@ -386,12 +386,12 @@  discard block
 block discarded – undo
386 386
 	 */
387 387
 	public function set_token_length ($length = null) {
388 388
 		// validate number
389
-		if ($length!=null) {
390
-			if (!is_numeric($length))				{ $this->Response->throw_exception(500, "token length must be an integer"); }
391
-			elseif ($length>24)						{ $this->Response->throw_exception(500, "Maximum token length is 24 characters"); }
389
+		if ($length != null) {
390
+			if (!is_numeric ($length)) { $this->Response->throw_exception (500, "token length must be an integer"); }
391
+			elseif ($length > 24) { $this->Response->throw_exception (500, "Maximum token length is 24 characters"); }
392 392
 		}
393 393
 		// save
394
-		$this->token_length = is_null($length) ? 24 : $length;
394
+		$this->token_length = is_null ($length) ? 24 : $length;
395 395
 	}
396 396
 
397 397
 	/**
@@ -402,14 +402,14 @@  discard block
 block discarded – undo
402 402
 	 */
403 403
 	private function save_user_token () {
404 404
 		# set token values
405
-		$values = array(
405
+		$values = array (
406 406
 					"id"=>$this->User->user->id,
407 407
 					"token"=>$this->token,
408 408
 					"token_valid_until"=>$this->token_expires
409 409
 					);
410 410
 		# save token to database
411
-		if(!$this->Admin->object_modify ("users", "edit",  "id", $values ))
412
-													{ $this->Response->throw_exception(500, "Failed to update token"); }
411
+		if (!$this->Admin->object_modify ("users", "edit", "id", $values))
412
+													{ $this->Response->throw_exception (500, "Failed to update token"); }
413 413
 	}
414 414
 
415 415
 	/**
@@ -420,13 +420,13 @@  discard block
 block discarded – undo
420 420
 	 */
421 421
 	private function validate_user_token () {
422 422
 		// is set
423
-		if (strlen($this->User->user->token)==0)							{ return false; }
423
+		if (strlen ($this->User->user->token) == 0) { return false; }
424 424
 		// date not set
425
-		elseif (strlen($this->User->user->token_valid_until)==0)			{ return false; }
425
+		elseif (strlen ($this->User->user->token_valid_until) == 0) { return false; }
426 426
 		// expired
427
-		elseif ($this->User->user->token_valid_until < date("Y-m-d H:is:"))	{ return false; }
427
+		elseif ($this->User->user->token_valid_until < date ("Y-m-d H:is:")) { return false; }
428 428
 		// ok
429
-		else																{ return true; }
429
+		else { return true; }
430 430
 
431 431
 	}
432 432
 
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 	 * @return void
438 438
 	 */
439 439
 	private function validate_requested_token () {
440
-		return $this->_params->controller=="user" ? $this->validate_requested_token_user () : $this->validate_requested_token_general ();
440
+		return $this->_params->controller == "user" ? $this->validate_requested_token_user () : $this->validate_requested_token_general ();
441 441
 	}
442 442
 
443 443
 	/**
@@ -448,20 +448,20 @@  discard block
 block discarded – undo
448 448
 	 */
449 449
 	private function validate_requested_token_user () {
450 450
 		// check that token is present
451
-		if(!isset($_SERVER['HTTP_PHPIPAM_TOKEN']))	{ $this->Response->throw_exception(403, "Please provide token"); }
451
+		if (!isset($_SERVER['HTTP_PHPIPAM_TOKEN'])) { $this->Response->throw_exception (403, "Please provide token"); }
452 452
 		// validate and remove token
453 453
 		else {
454 454
 			// fetch token
455
-			if(($token = $this->Admin->fetch_object ("users", "token", $_SERVER['HTTP_PHPIPAM_TOKEN'])) === false)
456
-													{ $this->Response->throw_exception(403, "Invalid token"); }
455
+			if (($token = $this->Admin->fetch_object ("users", "token", $_SERVER['HTTP_PHPIPAM_TOKEN'])) === false)
456
+													{ $this->Response->throw_exception (403, "Invalid token"); }
457 457
 			// save token
458 458
 			$this->User->user = $token;
459 459
 			$this->token = $token->token;
460 460
 			$this->token_expires = $token->token_valid_until;
461 461
 
462 462
 			// expired
463
-			if($this->validate_token_expiration () === true)
464
-													{  $this->Response->throw_exception(403, "Token expired");  }
463
+			if ($this->validate_token_expiration () === true)
464
+													{  $this->Response->throw_exception (403, "Token expired"); }
465 465
 		}
466 466
 	}
467 467
 
@@ -473,20 +473,20 @@  discard block
 block discarded – undo
473 473
 	 */
474 474
 	private function validate_requested_token_general () {
475 475
 		// check that token is present
476
-		if(!isset($_SERVER['HTTP_PHPIPAM_TOKEN']))	{ $this->Response->throw_exception(401, $this->Response->errors[401]); }
476
+		if (!isset($_SERVER['HTTP_PHPIPAM_TOKEN'])) { $this->Response->throw_exception (401, $this->Response->errors[401]); }
477 477
 		// validate and remove token
478 478
 		else {
479 479
 			// fetch token
480
-			if(($token = $this->Admin->fetch_object ("users", "token", $_SERVER['HTTP_PHPIPAM_TOKEN'])) === false)
481
-													{ $this->Response->throw_exception(401, $this->Response->errors[401]); }
480
+			if (($token = $this->Admin->fetch_object ("users", "token", $_SERVER['HTTP_PHPIPAM_TOKEN'])) === false)
481
+													{ $this->Response->throw_exception (401, $this->Response->errors[401]); }
482 482
 			// save token
483 483
 			$this->User->user = $token;
484 484
 			$this->token = $token->token;
485 485
 			$this->token_expires = $token->token_valid_until;
486 486
 
487 487
 			// expired
488
-			if($this->validate_token_expiration () === true)
489
-													{  $this->Response->throw_exception(401, $this->Response->errors[401]);  }
488
+			if ($this->validate_token_expiration () === true)
489
+													{  $this->Response->throw_exception (401, $this->Response->errors[401]); }
490 490
 			// refresh
491 491
 			$this->refresh_token_expiration ();
492 492
 		}
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 	 * @return void
502 502
 	 */
503 503
 	private function validate_token_expiration () {
504
-		return strtotime($this->token_expires) < time() ? true : false;
504
+		return strtotime ($this->token_expires) < time () ? true : false;
505 505
 	}
506 506
 
507 507
 	/**
@@ -515,24 +515,24 @@  discard block
 block discarded – undo
515 515
 		$this->token = $this->User->user->token;
516 516
         
517 517
 		// convert existing expiry date string to a timestamp
518
-		$expire_time = strtotime($this->token_expires);
518
+		$expire_time = strtotime ($this->token_expires);
519 519
 
520 520
 		// Write Throttling from token updates
521 521
 		// In order to keep the DB writes from token updates to a minimum, only update the expire time
522 522
 		// if the expire time was set more than 60 seconds ago.
523
-		if ( ((time()+$this->token_valid_time) - $expire_time) < 60) {
523
+		if (((time () + $this->token_valid_time) - $expire_time) < 60) {
524 524
 				return;
525 525
 		}
526 526
 
527
-		$this->token_expires = date("Y-m-d H:i:s", time()+$this->token_valid_time);
527
+		$this->token_expires = date ("Y-m-d H:i:s", time () + $this->token_valid_time);
528 528
 		# set token values
529
-		$values = array(
529
+		$values = array (
530 530
 					"id"=>$this->User->user->id,
531 531
 					"token_valid_until"=>$this->token_expires
532 532
 					);
533 533
 		# save token to database
534
-		if(!$this->Admin->object_modify ("users", "edit",  "id", $values ))
535
-													{ $this->Response->throw_exception(500, "Failed to update token expiration date"); }
534
+		if (!$this->Admin->object_modify ("users", "edit", "id", $values))
535
+													{ $this->Response->throw_exception (500, "Failed to update token expiration date"); }
536 536
 	}
537 537
 
538 538
 	/**
@@ -543,14 +543,14 @@  discard block
 block discarded – undo
543 543
 	 */
544 544
 	private function remove_token () {
545 545
 		# set token values
546
-		$values = array(
546
+		$values = array (
547 547
 					"id"=>$this->User->user->id,
548 548
 					"token"=>null,
549 549
 					"token_valid_until"=>null
550 550
 					);
551 551
 		# save token to database
552
-		if(!$this->Admin->object_modify ("users", "edit",  "id", $values ))
553
-													{ $this->Response->throw_exception(500, "Failed to remove token"); }
552
+		if (!$this->Admin->object_modify ("users", "edit", "id", $values))
553
+													{ $this->Response->throw_exception (500, "Failed to remove token"); }
554 554
 
555 555
 	}
556 556
 
@@ -561,16 +561,16 @@  discard block
 block discarded – undo
561 561
 	 * @return void
562 562
 	 */
563 563
 	private function generate_token () {
564
-	    $chars 		  = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$%!=.';
565
-	    $chars_length = strlen($chars);
564
+	    $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$%!=.';
565
+	    $chars_length = strlen ($chars);
566 566
 	    // generate string
567 567
 	    $token = '';
568 568
 	    for ($i = 0; $i < $this->token_length; $i++) {
569
-	        $token .= $chars[rand(0, $chars_length - 1)];
569
+	        $token .= $chars[rand (0, $chars_length - 1)];
570 570
 	    }
571 571
 	    // save token and valid time
572 572
 	    $this->token = $token;
573
-	    $this->token_expires = date("Y-m-d H:i:s", time()+$this->token_valid_time);
573
+	    $this->token_expires = date ("Y-m-d H:i:s", time () + $this->token_valid_time);
574 574
 	}
575 575
 
576 576
 }
Please login to merge, or discard this patch.
functions/classes/class.Rackspace.php 2 patches
Doc Comments   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
      * Fetches details about specific rack
153 153
      *
154 154
      * @access public
155
-     * @param mixed $id
155
+     * @param integer $id
156 156
      * @return void
157 157
      */
158 158
     public function fetch_rack_details ($id) {
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
      * Fetches all devices attached to rack
170 170
      *
171 171
      * @access public
172
-     * @param mixed $id
172
+     * @param integer $id
173 173
      * @return void
174 174
      */
175 175
     public function fetch_rack_devices ($id) {
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
      * Set active rack devide.
248 248
      *
249 249
      * @access public
250
-     * @param mixed $id         // device id
250
+     * @param boolean $id         // device id
251 251
      * @return void
252 252
      */
253 253
     public function set_active_rack_device ($id) {
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
      *
384 384
      * @access private
385 385
      * @param RackContent $content
386
-     * @param mixed $img
386
+     * @param resource $img
387 387
      * @param mixed $name
388 388
      * @return void
389 389
      */
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
      * getSpace function.
502 502
      *
503 503
      * @access public
504
-     * @return void
504
+     * @return integer
505 505
      */
506 506
     public function getSpace() {
507 507
         return $this->space;
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
      * Checks if item is active
544 544
      *
545 545
      * @access public
546
-     * @return void
546
+     * @return boolean
547 547
      */
548 548
     public function isActive() {
549 549
         return $this->active;
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
      * returns id
615 615
      *
616 616
      * @access public
617
-     * @return void
617
+     * @return integer
618 618
      */
619 619
     public function getId() {
620 620
         return $this->id;
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
      * Checks if item is active
657 657
      *
658 658
      * @access public
659
-     * @return void
659
+     * @return boolean
660 660
      */
661 661
     public function isActive() {
662 662
         return $this->active;
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
      * Returns start position
678 678
      *
679 679
      * @access public
680
-     * @return void
680
+     * @return integer
681 681
      */
682 682
     public function getStartLocation() {
683 683
         return $this->startLocation;
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
      * Gets rack size.
699 699
      *
700 700
      * @access public
701
-     * @return void
701
+     * @return integer
702 702
      */
703 703
     public function getSize() {
704 704
         return $this->size;
Please login to merge, or discard this patch.
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
      * @var array
16 16
      * @access public
17 17
      */
18
-    public $rack_sizes = array();
18
+    public $rack_sizes = array ();
19 19
 
20 20
     /**
21 21
      * List of all racks
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      * @var array
36 36
      * @access private
37 37
      */
38
-    private $rack_content = array();
38
+    private $rack_content = array ();
39 39
 
40 40
 	/**
41 41
 	 * Result printing class
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 		# set racksizes
104 104
 		$this->define_rack_sizes ();
105 105
 		# initialize rack
106
-        $this->Drawer = new RackDrawer();
106
+        $this->Drawer = new RackDrawer ();
107 107
 	}
108 108
 
109 109
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
      * @return void
123 123
      */
124 124
     private function define_rack_sizes () {
125
-        $this->rack_sizes = array(14, 20, 24, 30, 35, 40, 42, 44, 45, 48);
125
+        $this->rack_sizes = array (14, 20, 24, 30, 35, 40, 42, 44, 45, 48);
126 126
     }
127 127
 
128 128
 
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
      * @return void
134 134
      */
135 135
     public function fetch_all_racks () {
136
-        $all_racks = $this->fetch_all_objects("racks", "name", "acs");
136
+        $all_racks = $this->fetch_all_objects ("racks", "name", "acs");
137 137
         // reorder
138
-        if ($all_racks==false) {
138
+        if ($all_racks == false) {
139 139
             $this->all_racks = false;
140 140
         }
141 141
         else {
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
             return $this->all_racks->$id;
162 162
         }
163 163
         else {
164
-            return $this->fetch_object("racks", "id", $id);
164
+            return $this->fetch_object ("racks", "id", $id);
165 165
         }
166 166
     }
167 167
 
@@ -204,10 +204,10 @@  discard block
 block discarded – undo
204 204
         $this->rack_size = $rack->size;
205 205
 
206 206
         // set content
207
-        if ($devices!==false) {
207
+        if ($devices !== false) {
208 208
             foreach ($devices as $d) {
209 209
                 // add initial location
210
-                $rd = array("id"=>$d->id,
210
+                $rd = array ("id"=>$d->id,
211 211
                             "name"=>$d->hostname,
212 212
                             "startLocation"=>$d->rack_start,
213 213
                             "size"=>$d->rack_size,
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
         // create rack
224 224
         $this->set_rack ();
225 225
         // set active device
226
-        if ($deviceId!==false) {
226
+        if ($deviceId !== false) {
227 227
             $this->set_active_rack_device ($deviceId);
228 228
         }
229 229
         // draw rack drawer
@@ -238,9 +238,9 @@  discard block
 block discarded – undo
238 238
      */
239 239
     private function set_rack () {
240 240
         // initialize
241
-        $this->Rack = new Rack (array("name"=>$this->rack_name, "content"=>$this->rack_content));
241
+        $this->Rack = new Rack (array ("name"=>$this->rack_name, "content"=>$this->rack_content));
242 242
         // set rack size
243
-        $this->Rack->setSpace($this->rack_size);
243
+        $this->Rack->setSpace ($this->rack_size);
244 244
     }
245 245
 
246 246
     /**
@@ -251,9 +251,9 @@  discard block
 block discarded – undo
251 251
      * @return void
252 252
      */
253 253
     public function set_active_rack_device ($id) {
254
-        foreach ($this->Rack->getContent() as $content) {
255
-            if ($content->getId() == $id) {
256
-                $content->setActive();
254
+        foreach ($this->Rack->getContent () as $content) {
255
+            if ($content->getId () == $id) {
256
+                $content->setActive ();
257 257
             }
258 258
         }
259 259
     }
@@ -312,15 +312,15 @@  discard block
 block discarded – undo
312 312
      * @param Rack $rack
313 313
      * @return void
314 314
      */
315
-    public function draw(Rack $rack) {
315
+    public function draw (Rack $rack) {
316 316
         $this->rack = $rack;
317
-        $this->template = imagecreatefrompng( $this->createURL().BASE."css/1.2/images/blankracks/".$this->rack->getSpace().".png" );
318
-        $this->drawNameplate();
319
-        $this->drawContents();
317
+        $this->template = imagecreatefrompng ($this->createURL ().BASE."css/1.2/images/blankracks/".$this->rack->getSpace ().".png");
318
+        $this->drawNameplate ();
319
+        $this->drawContents ();
320 320
 
321
-        header("Content-type: image/png");
322
-        imagepng($this->template);
323
-        imagedestroy($this->template);
321
+        header ("Content-type: image/png");
322
+        imagepng ($this->template);
323
+        imagedestroy ($this->template);
324 324
     }
325 325
 
326 326
     /**
@@ -329,12 +329,12 @@  discard block
 block discarded – undo
329 329
      * @access private
330 330
      * @return void
331 331
      */
332
-    private function drawNameplate() {
333
-        $nameplate = imagecreate(150, 20);
334
-        imagecolorallocate( $nameplate, 255, 255, 255 ); // Allocate a background color (first color assigned)
335
-        $textColour = imagecolorallocate($nameplate, 0, 0, 0);
336
-        $this->imageCenterString($nameplate, 3, $this->rack->getName(), $textColour);
337
-        imagecopy($this->template, $nameplate, 52, 1, 0, 0, 150, 20);
332
+    private function drawNameplate () {
333
+        $nameplate = imagecreate (150, 20);
334
+        imagecolorallocate ($nameplate, 255, 255, 255); // Allocate a background color (first color assigned)
335
+        $textColour = imagecolorallocate ($nameplate, 0, 0, 0);
336
+        $this->imageCenterString ($nameplate, 3, $this->rack->getName (), $textColour);
337
+        imagecopy ($this->template, $nameplate, 52, 1, 0, 0, 150, 20);
338 338
     }
339 339
 
340 340
     /**
@@ -345,15 +345,15 @@  discard block
 block discarded – undo
345 345
      * @param string $text
346 346
      * @param int $color
347 347
      */
348
-    private function imageCenterString($img, $font, $text, $color) {
348
+    private function imageCenterString ($img, $font, $text, $color) {
349 349
         if ($font < 0 || $font > 5) {
350 350
             $font = 0;
351 351
         }
352
-        $num = Array( Array(4.6, 6), Array(4.6, 6), Array(5.6, 12), Array(6.5, 12), Array(7.6, 16), Array(8.5, 16));
353
-        $width = ceil(strlen($text) * $num[$font][0]);
354
-        $x = imagesx($img) - $width - 8;
355
-        $y = Imagesy($img) - ($num[$font][1] + 2);
356
-        imagestring($img, $font, $x/2, $y/2, $text, $color);
352
+        $num = Array (Array (4.6, 6), Array (4.6, 6), Array (5.6, 12), Array (6.5, 12), Array (7.6, 16), Array (8.5, 16));
353
+        $width = ceil (strlen ($text) * $num[$font][0]);
354
+        $x = imagesx ($img) - $width - 8;
355
+        $y = Imagesy ($img) - ($num[$font][1] + 2);
356
+        imagestring ($img, $font, $x / 2, $y / 2, $text, $color);
357 357
     }
358 358
 
359 359
 
@@ -363,18 +363,18 @@  discard block
 block discarded – undo
363 363
      * @access private
364 364
      * @return void
365 365
      */
366
-    private function drawContents() {
367
-        foreach ($this->rack->getContent() as $content)
366
+    private function drawContents () {
367
+        foreach ($this->rack->getContent () as $content)
368 368
         {
369
-            $pixelSize = 20 * $content->getSize();
369
+            $pixelSize = 20 * $content->getSize ();
370 370
 
371
-            $img = imagecreate(200, $pixelSize);
372
-            $this->drawContent($content, $img, $content->getName());
371
+            $img = imagecreate (200, $pixelSize);
372
+            $this->drawContent ($content, $img, $content->getName ());
373 373
 
374
-            $yPos = 22 + 20 * ($this->rack->getSpace() - ($content->getStartLocation() + $content->getSize()));
374
+            $yPos = 22 + 20 * ($this->rack->getSpace () - ($content->getStartLocation () + $content->getSize ()));
375 375
 
376
-            imagecopy($this->template, $img, 27, $yPos, 0, 0, 200, $pixelSize);
377
-            imagedestroy($img);
376
+            imagecopy ($this->template, $img, 27, $yPos, 0, 0, 200, $pixelSize);
377
+            imagedestroy ($img);
378 378
         }
379 379
     }
380 380
 
@@ -387,21 +387,21 @@  discard block
 block discarded – undo
387 387
      * @param mixed $name
388 388
      * @return void
389 389
      */
390
-    private function drawContent(RackContent $content, $img, $name)
390
+    private function drawContent (RackContent $content, $img, $name)
391 391
     {
392
-        if ($content->isActive()) {
393
-            imagecolorallocate($img, 207, 232, 255); // Allocate a background color (first color assigned) - active
394
-            $textColour = imagecolorallocate($img, 0, 0, 0);
395
-            $lineColour = imagecolorallocate($img, 122, 137, 150);
392
+        if ($content->isActive ()) {
393
+            imagecolorallocate ($img, 207, 232, 255); // Allocate a background color (first color assigned) - active
394
+            $textColour = imagecolorallocate ($img, 0, 0, 0);
395
+            $lineColour = imagecolorallocate ($img, 122, 137, 150);
396 396
         } else {
397
-            imagecolorallocate($img, 230, 230, 230); // Allocate a background color (first color assigned)  - all
398
-            $textColour = imagecolorallocate($img, 0, 0, 0);
399
-            $lineColour = imagecolorallocate($img, 122, 137, 150);
397
+            imagecolorallocate ($img, 230, 230, 230); // Allocate a background color (first color assigned)  - all
398
+            $textColour = imagecolorallocate ($img, 0, 0, 0);
399
+            $lineColour = imagecolorallocate ($img, 122, 137, 150);
400 400
         }
401 401
 
402
-        $this->imageCenterString($img, 3, $name, $textColour);
403
-        imageline($img, 0, 0, 200, 0, $lineColour);
404
-        imageline($img, 0, imagesy($img) - 1, 200, imagesy($img) - 1, $lineColour);
402
+        $this->imageCenterString ($img, 3, $name, $textColour);
403
+        imageline ($img, 0, 0, 200, 0, $lineColour);
404
+        imageline ($img, 0, imagesy ($img) - 1, 200, imagesy ($img) - 1, $lineColour);
405 405
     }
406 406
 }
407 407
 
@@ -418,13 +418,13 @@  discard block
 block discarded – undo
418 418
      * @param array $fields
419 419
      * @return void
420 420
      */
421
-    public function __construct(array $fields)
421
+    public function __construct (array $fields)
422 422
     {
423 423
         foreach ($fields as $field => $value)
424 424
         {
425
-            $setter = 'set' . ucfirst($field);
426
-            if (method_exists($this, $setter)) {
427
-                $this->$setter($value);
425
+            $setter = 'set'.ucfirst ($field);
426
+            if (method_exists ($this, $setter)) {
427
+                $this->$setter ($value);
428 428
             }
429 429
         }
430 430
     }
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
      * @access public
483 483
      * @return void
484 484
      */
485
-    public function getName() {
485
+    public function getName () {
486 486
         return $this->name;
487 487
     }
488 488
 
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
      * @param mixed $name
494 494
      * @return void
495 495
      */
496
-    public function setName($name) {
496
+    public function setName ($name) {
497 497
         $this->name = $name;
498 498
     }
499 499
 
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
      * @access public
504 504
      * @return void
505 505
      */
506
-    public function getSpace() {
506
+    public function getSpace () {
507 507
         return $this->space;
508 508
     }
509 509
 
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
      * @param mixed $space
515 515
      * @return void
516 516
      */
517
-    public function setSpace($space) {
517
+    public function setSpace ($space) {
518 518
         $this->space = $space;
519 519
     }
520 520
 
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
      * @access public
525 525
      * @return void
526 526
      */
527
-    public function getContent() {
527
+    public function getContent () {
528 528
         return $this->content;
529 529
     }
530 530
 
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
      * @param mixed $content
536 536
      * @return void
537 537
      */
538
-    public function setContent($content) {
538
+    public function setContent ($content) {
539 539
         $this->content = $content;
540 540
     }
541 541
 
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
      * @access public
546 546
      * @return void
547 547
      */
548
-    public function isActive() {
548
+    public function isActive () {
549 549
         return $this->active;
550 550
     }
551 551
 
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
      * @param bool $active (default: true)
557 557
      * @return void
558 558
      */
559
-    public function setActive($active) {
559
+    public function setActive ($active) {
560 560
         $this->active = $active;
561 561
     }
562 562
 }
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
      * @access public
617 617
      * @return void
618 618
      */
619
-    public function getId() {
619
+    public function getId () {
620 620
         return $this->id;
621 621
     }
622 622
 
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
      * @param mixed $id
628 628
      * @return void
629 629
      */
630
-    public function setId($id) {
630
+    public function setId ($id) {
631 631
         $this->id = $id;
632 632
     }
633 633
 
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
      * @access public
638 638
      * @return void
639 639
      */
640
-    public function getName() {
640
+    public function getName () {
641 641
         return $this->name;
642 642
     }
643 643
 
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
      * @param mixed $name
649 649
      * @return void
650 650
      */
651
-    public function setName($name) {
651
+    public function setName ($name) {
652 652
         $this->name = $name;
653 653
     }
654 654
 
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
      * @access public
659 659
      * @return void
660 660
      */
661
-    public function isActive() {
661
+    public function isActive () {
662 662
         return $this->active;
663 663
     }
664 664
 
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
      * @param bool $active (default: true)
670 670
      * @return void
671 671
      */
672
-    public function setActive($active = true) {
672
+    public function setActive ($active = true) {
673 673
         $this->active = $active;
674 674
     }
675 675
 
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
      * @access public
680 680
      * @return void
681 681
      */
682
-    public function getStartLocation() {
682
+    public function getStartLocation () {
683 683
         return $this->startLocation;
684 684
     }
685 685
 
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
      * @param mixed $startLocation
691 691
      * @return void
692 692
      */
693
-    public function setStartLocation($startLocation) {
693
+    public function setStartLocation ($startLocation) {
694 694
         $this->startLocation = $startLocation;
695 695
     }
696 696
 
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
      * @access public
701 701
      * @return void
702 702
      */
703
-    public function getSize() {
703
+    public function getSize () {
704 704
         return $this->size;
705 705
     }
706 706
 
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
      * @param mixed $size
712 712
      * @return void
713 713
      */
714
-    public function setSize($size) {
714
+    public function setSize ($size) {
715 715
         $this->size = $size;
716 716
     }
717 717
 }
Please login to merge, or discard this patch.
functions/classes/class.FirewallZones.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -239,7 +239,7 @@
 block discarded – undo
239 239
 	 * Fetches zone mapping from database, depending on id
240 240
 	 *
241 241
 	 * @access public
242
-	 * @param mixed $id
242
+	 * @param string $id
243 243
 	 * @return void
244 244
 	 */
245 245
 	public function get_zone_mapping ($id) {
Please login to merge, or discard this patch.
Spacing   +213 added lines, -213 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 		# Log object
84 84
 		$this->Log = new Logging ($this->Database);
85 85
 		# get settings
86
-		$this->get_settings();
86
+		$this->get_settings ();
87 87
 		# subnet object
88 88
 		$this->Subnets = new Subnets ($this->Database);
89 89
 	}
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
 	 * @return string
98 98
 	 */
99 99
 	public function zone2hex ($zone) {
100
-		$firewallZoneSettings = json_decode($this->settings->firewallZoneSettings,true);
100
+		$firewallZoneSettings = json_decode ($this->settings->firewallZoneSettings, true);
101 101
 		if ($firewallZoneSettings['padding'] == 'on') {
102
-			return str_pad(dechex($zone),$firewallZoneSettings['zoneLength'],"0",STR_PAD_LEFT);
102
+			return str_pad (dechex ($zone), $firewallZoneSettings['zoneLength'], "0", STR_PAD_LEFT);
103 103
 		} else {
104
-			return dechex($zone);
104
+			return dechex ($zone);
105 105
 		}
106 106
 
107 107
 	}
@@ -116,14 +116,14 @@  discard block
 block discarded – undo
116 116
 	 */
117 117
 	public function generate_zone_name ($values = NULL) {
118 118
 		# get settings
119
-		$firewallZoneSettings = json_decode($this->settings->firewallZoneSettings,true);
119
+		$firewallZoneSettings = json_decode ($this->settings->firewallZoneSettings, true);
120 120
 		# execute based on action
121
-		if($firewallZoneSettings['zoneGenerator'] == 0 || $firewallZoneSettings['zoneGenerator'] == 1 ) {
122
-			return $this->generate_numeric_zone_name ($firewallZoneSettings['zoneLength'],$firewallZoneSettings['zoneGenerator']);
123
-		} elseif($firewallZoneSettings['zoneGenerator'] == 2 ) {
121
+		if ($firewallZoneSettings['zoneGenerator'] == 0 || $firewallZoneSettings['zoneGenerator'] == 1) {
122
+			return $this->generate_numeric_zone_name ($firewallZoneSettings['zoneLength'], $firewallZoneSettings['zoneGenerator']);
123
+		} elseif ($firewallZoneSettings['zoneGenerator'] == 2) {
124 124
 			return $this->validate_text_zone_name ($values);
125 125
 		} else {
126
-			return $this->Result->show("danger", _("Invalid generator ID"), true);
126
+			return $this->Result->show ("danger", _ ("Invalid generator ID"), true);
127 127
 		}
128 128
 	}
129 129
 
@@ -136,29 +136,29 @@  discard block
 block discarded – undo
136 136
 	 * @param mixed $zoneGenerator
137 137
 	 * @return void
138 138
 	 */
139
-	private function generate_numeric_zone_name ($zoneLength,$zoneGenerator) {
139
+	private function generate_numeric_zone_name ($zoneLength, $zoneGenerator) {
140 140
 
141 141
 		# execute
142
-		try { $maxZone = $this->Database->getObjectsQuery('SELECT MAX(CAST(zone as UNSIGNED)) as zone FROM firewallZones WHERE generator NOT LIKE 2;');}
142
+		try { $maxZone = $this->Database->getObjectsQuery ('SELECT MAX(CAST(zone as UNSIGNED)) as zone FROM firewallZones WHERE generator NOT LIKE 2;'); }
143 143
 		catch (Exception $e) {
144
-			$this->Result->show("danger", _("Error: ").$e->getMessage(), false);
144
+			$this->Result->show ("danger", _ ("Error: ").$e->getMessage (), false);
145 145
 			return false;
146 146
 		}
147 147
 
148
-		if($maxZone[0]->zone) {
148
+		if ($maxZone[0]->zone) {
149 149
 			# add 1 to the zone name
150 150
 			$zoneName = ++$maxZone[0]->zone;
151
-			if($zoneGenerator == 0 ) {
152
-				if(strlen($zoneName) > $zoneLength) {
153
-					return $this->Result->show("danger", _("Maximum zone name length reached! Consider to change your settings in order to generate larger zone names."), true);
151
+			if ($zoneGenerator == 0) {
152
+				if (strlen ($zoneName) > $zoneLength) {
153
+					return $this->Result->show ("danger", _ ("Maximum zone name length reached! Consider to change your settings in order to generate larger zone names."), true);
154 154
 				}
155
-			} elseif($zoneGenerator == 1) {
155
+			} elseif ($zoneGenerator == 1) {
156 156
 				# the highest convertable integer value for dechex() is 4294967295!
157
-				if($zoneName > 4294967295) {
158
-					return $this->Result->show("danger", _("The maximum convertable vlaue is reached. Consider to switch to decimal or text mode and change the zone name length value."), true);
157
+				if ($zoneName > 4294967295) {
158
+					return $this->Result->show ("danger", _ ("The maximum convertable vlaue is reached. Consider to switch to decimal or text mode and change the zone name length value."), true);
159 159
 				}
160
-				if(strlen(dechex($zoneName)) > $zoneLength){
161
-					return $this->Result->show("danger", _("Maximum zone name length reached! Consider to change your settings in order to generate larger zone names."), true);
160
+				if (strlen (dechex ($zoneName)) > $zoneLength) {
161
+					return $this->Result->show ("danger", _ ("Maximum zone name length reached! Consider to change your settings in order to generate larger zone names."), true);
162 162
 				}
163 163
 			}
164 164
 
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 		}
169 169
 
170 170
 		# return the values
171
-		return sizeof($zoneName)>0 ? $zoneName : false;
171
+		return sizeof ($zoneName) > 0 ? $zoneName : false;
172 172
 	}
173 173
 
174 174
 
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
 	 */
182 182
 	private function validate_text_zone_name ($values) {
183 183
 		# get settings
184
-		$firewallZoneSettings = json_decode($this->settings->firewallZoneSettings,true);
184
+		$firewallZoneSettings = json_decode ($this->settings->firewallZoneSettings, true);
185 185
 
186
-		if($values[1]){
186
+		if ($values[1]) {
187 187
 			$query = 'SELECT zone FROM firewallZones WHERE zone = ? AND id NOT LIKE ?;';
188 188
 			$params = $values;
189 189
 		} else {
@@ -192,15 +192,15 @@  discard block
 block discarded – undo
192 192
 		}
193 193
 
194 194
 		# execute
195
-		try { $uniqueZone = $this->Database->getObjectsQuery($query,$params);}
195
+		try { $uniqueZone = $this->Database->getObjectsQuery ($query, $params); }
196 196
 		catch (Exception $e) {
197
-			$this->Result->show("danger", _("Error: ").$e->getMessage(), false);
197
+			$this->Result->show ("danger", _ ("Error: ").$e->getMessage (), false);
198 198
 			return false;
199 199
 		}
200 200
 
201 201
 		if ($uniqueZone[0]->zone && $firewallZoneSettings['strictMode'] == 'on') {
202 202
 
203
-			$this->Result->show("danger", _("Error: The zone name ".$zone." is not unique!"), false);
203
+			$this->Result->show ("danger", _ ("Error: The zone name ".$zone." is not unique!"), false);
204 204
 
205 205
 		} else {
206 206
 			# set the initial zone name to "1"
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 		}
209 209
 
210 210
 		# return the values
211
-		return sizeof($zoneName)>0 ? $zoneName : false;
211
+		return sizeof ($zoneName) > 0 ? $zoneName : false;
212 212
 	}
213 213
 
214 214
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 */
221 221
 	public function get_zone_mappings () {
222 222
 		# try to fetch all zone mappings
223
-		try { $mappings =  $this->Database->getObjectsQuery('SELECT
223
+		try { $mappings = $this->Database->getObjectsQuery ('SELECT
224 224
 						firewallZones.id AS id,
225 225
 						firewallZones.generator AS generator,
226 226
 						firewallZones.length AS length,
@@ -237,12 +237,12 @@  discard block
 block discarded – undo
237 237
 						FROM firewallZoneMapping
238 238
 						RIGHT JOIN firewallZones ON zoneId = firewallZones.id
239 239
 						LEFT JOIN devices ON deviceId = devices.id
240
-						having  deviceId is not NULL order by firewallZones.id ASC;');}
240
+						having  deviceId is not NULL order by firewallZones.id ASC;'); }
241 241
 		# throw exception
242
-		catch (Exception $e) {$this->Result->show("danger", _("Database error: ").$e->getMessage());}
242
+		catch (Exception $e) {$this->Result->show ("danger", _ ("Database error: ").$e->getMessage ()); }
243 243
 
244 244
 		# try to fetch all subnet and vlan informations for all zones
245
-		try { $networkInformation =  $this->Database->getObjectsQuery('SELECT
245
+		try { $networkInformation = $this->Database->getObjectsQuery ('SELECT
246 246
 						firewallZoneSubnet.zoneId AS zoneId,
247 247
 						firewallZoneSubnet.subnetId AS subnetId,
248 248
 						subnets.sectionId AS sectionId,
@@ -256,32 +256,32 @@  discard block
 block discarded – undo
256 256
 						vlans.name AS vlanName
257 257
 						FROM firewallZoneSubnet
258 258
 						LEFT JOIN subnets ON subnetId = subnets.id
259
-						LEFT JOIN vlans ON subnets.vlanId = vlans.vlanId ORDER BY subnet ASC;');}
259
+						LEFT JOIN vlans ON subnets.vlanId = vlans.vlanId ORDER BY subnet ASC;'); }
260 260
 		# throw exception
261
-		catch (Exception $e) {$this->Result->show("danger", _("Database error: ").$e->getMessage());}
261
+		catch (Exception $e) {$this->Result->show ("danger", _ ("Database error: ").$e->getMessage ()); }
262 262
 
263 263
 		# modify the zone output values
264 264
 		foreach ($mappings as $key => $val) {
265 265
 			# transform the zone name from decimal to hex
266
-			if($mappings[$key]->generator == 1 ){
267
-				$mappings[$key]->zone = dechex($mappings[$key]->zone);
266
+			if ($mappings[$key]->generator == 1) {
267
+				$mappings[$key]->zone = dechex ($mappings[$key]->zone);
268 268
 			}
269 269
 			# add some padding if it is activated and the zone generatore is not text
270
-			if($mappings[$key]->padding == 1 && $mappings[$key]->generator != 2){
270
+			if ($mappings[$key]->padding == 1 && $mappings[$key]->generator != 2) {
271 271
 			# remove leading zeros (padding) and raise the value in case of any zone name length changes
272 272
 			# add some padding to reach the maximum zone name lenght
273
-			$mappings[$key]->zone = str_pad(ltrim($mappings[$key]->zone,0),$mappings[$key]->length,"0",STR_PAD_LEFT);
273
+			$mappings[$key]->zone = str_pad (ltrim ($mappings[$key]->zone, 0), $mappings[$key]->length, "0", STR_PAD_LEFT);
274 274
 			}
275 275
 			# inject network informations
276 276
 			foreach ($networkInformation as $nkey => $nval) {
277
-				if($mappings[$key]->id == $nval->zoneId) {
277
+				if ($mappings[$key]->id == $nval->zoneId) {
278 278
 					# add each network and vlan information to the object
279 279
 					$mappings[$key]->network[] = $networkInformation[$nkey];
280 280
 				}
281 281
 			}
282 282
 		}
283 283
 		# return the values
284
-		return sizeof($mappings)>0 ? $mappings : false;
284
+		return sizeof ($mappings) > 0 ? $mappings : false;
285 285
 	}
286 286
 
287 287
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 	 */
295 295
 	public function get_zone_mapping ($id) {
296 296
 		# try to fetch id specific zone mapping
297
-		try { $mapping =  $this->Database->getObjectsQuery('SELECT
297
+		try { $mapping = $this->Database->getObjectsQuery ('SELECT
298 298
 						firewallZones.id AS id,
299 299
 						firewallZones.generator AS generator,
300 300
 						firewallZones.length AS length,
@@ -310,12 +310,12 @@  discard block
 block discarded – undo
310 310
 						FROM firewallZoneMapping
311 311
 						RIGHT JOIN firewallZones ON zoneId = firewallZones.id
312 312
 						LEFT JOIN devices ON deviceId = devices.id
313
-						having  deviceId is not NULL AND mappingId = ?;', $id);}
313
+						having  deviceId is not NULL AND mappingId = ?;', $id); }
314 314
 		# throw exception
315
-		catch (Exception $e) {$this->Result->show("danger", _("Database error: ").$e->getMessage());}
315
+		catch (Exception $e) {$this->Result->show ("danger", _ ("Database error: ").$e->getMessage ()); }
316 316
 
317 317
 		# try to fetch all subnet and vlan informations for all zones
318
-		try { $networkInformation =  $this->Database->getObjectsQuery('SELECT
318
+		try { $networkInformation = $this->Database->getObjectsQuery ('SELECT
319 319
 						firewallZoneSubnet.zoneId AS zoneId,
320 320
 						firewallZoneSubnet.subnetId AS subnetId,
321 321
 						subnets.sectionId AS sectionId,
@@ -330,25 +330,25 @@  discard block
 block discarded – undo
330 330
 						FROM firewallZoneSubnet
331 331
 						LEFT JOIN subnets ON subnetId = subnets.id
332 332
 						LEFT JOIN vlans ON subnets.vlanId = vlans.vlanId
333
-						HAVING zoneId = ? ORDER BY subnet ASC;', $mapping[0]->id);}
333
+						HAVING zoneId = ? ORDER BY subnet ASC;', $mapping[0]->id); }
334 334
 		# throw exception
335
-		catch (Exception $e) {$this->Result->show("danger", _("Database error: ").$e->getMessage());}
335
+		catch (Exception $e) {$this->Result->show ("danger", _ ("Database error: ").$e->getMessage ()); }
336 336
 
337 337
 		# modify the zone output values
338 338
 		foreach ($mapping as $key => $val) {
339 339
 			# transform the zone name from decimal to hex
340
-			if($mapping[$key]->generator == 1 ){
341
-				$mapping[$key]->zone = dechex($mapping[$key]->zone);
340
+			if ($mapping[$key]->generator == 1) {
341
+				$mapping[$key]->zone = dechex ($mapping[$key]->zone);
342 342
 			}
343 343
 			# add some padding if it is activated and the zone generatore is not text
344
-			if($mapping[$key]->padding == 1 && $mapping[$key]->generator != 2){
344
+			if ($mapping[$key]->padding == 1 && $mapping[$key]->generator != 2) {
345 345
 			# remove leading zeros (padding) and raise the value in case of any zone name length changes
346 346
 			# add some padding to reach the maximum zone name lenght
347
-			$mapping[$key]->zone = str_pad(ltrim($mapping[$key]->zone,0),$mapping[$key]->length,"0",STR_PAD_LEFT);
347
+			$mapping[$key]->zone = str_pad (ltrim ($mapping[$key]->zone, 0), $mapping[$key]->length, "0", STR_PAD_LEFT);
348 348
 			}
349 349
 			# inject network informations
350 350
 			foreach ($networkInformation as $nkey => $nval) {
351
-				if($mapping[$key]->id == $nval->zoneId) {
351
+				if ($mapping[$key]->id == $nval->zoneId) {
352 352
 					# remove the zoneId, we don't need it anymore
353 353
 					unset($networkInformation[$nkey]->zoneId);
354 354
 					# add each network and vlan information to the object
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 			}
358 358
 		}
359 359
 		# return the values
360
-		return sizeof($mapping)>0 ? $mapping[0] : false;
360
+		return sizeof ($mapping) > 0 ? $mapping[0] : false;
361 361
 	}
362 362
 
363 363
 	/**
@@ -369,13 +369,13 @@  discard block
 block discarded – undo
369 369
 	 */
370 370
 	public function check_zone_mapping ($zoneId) {
371 371
 		# try to fetch id specific zone mapping
372
-		try { $mapping =  $this->Database->getObjectsQuery('SELECT id FROM firewallZoneMapping WHERE zoneId = ?;', $zoneId);}
372
+		try { $mapping = $this->Database->getObjectsQuery ('SELECT id FROM firewallZoneMapping WHERE zoneId = ?;', $zoneId); }
373 373
 
374 374
 		# throw exception
375
-		catch (Exception $e) {$this->Result->show("danger", _("Database error: ").$e->getMessage());}
375
+		catch (Exception $e) {$this->Result->show ("danger", _ ("Database error: ").$e->getMessage ()); }
376 376
 
377 377
 		# return the values
378
-		return sizeof($mapping)>0 ? $mapping[0] : false;
378
+		return sizeof ($mapping) > 0 ? $mapping[0] : false;
379 379
 	}
380 380
 
381 381
 
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 	 */
389 389
 	public function get_zone_subnet_info ($id) {
390 390
 		# try to fetch id specific zone information
391
-		try { $info =  $this->Database->getObjectsQuery('SELECT
391
+		try { $info = $this->Database->getObjectsQuery ('SELECT
392 392
 						firewallZones.zone as zone,
393 393
 						firewallZones.padding as padding,
394 394
 						firewallZones.length as length,
@@ -408,27 +408,27 @@  discard block
 block discarded – undo
408 408
 						LEFT JOIN firewallZoneSubnet on firewallZoneMapping.zoneId = firewallZoneSubnet.zoneId
409 409
 						LEFT JOIN devices ON firewallZoneMapping.deviceId = devices.id
410 410
 						LEFT JOIN subnets ON firewallZoneSubnet.subnetId = subnets.id
411
-						HAVING firewallZoneSubnet.subnetId = ?;', $id);}
411
+						HAVING firewallZoneSubnet.subnetId = ?;', $id); }
412 412
 		# throw exception
413
-		catch (Exception $e) {$this->Result->show("danger", _("Database error: ").$e->getMessage());}
413
+		catch (Exception $e) {$this->Result->show ("danger", _ ("Database error: ").$e->getMessage ()); }
414 414
 		if ($info) {
415 415
 			# modify the zone output values
416 416
 			foreach ($info as $key => $val) {
417 417
 				# transform the zone name from decimal to hex
418
-				if($info[$key]->generator == 1 ){
419
-					$info[$key]->zone = dechex($info[$key]->zone);
418
+				if ($info[$key]->generator == 1) {
419
+					$info[$key]->zone = dechex ($info[$key]->zone);
420 420
 				}
421 421
 				# add some padding if it is activated and the zone generatore is not text
422
-				if($info[$key]->padding == 1 && $info[$key]->generator != 2){
422
+				if ($info[$key]->padding == 1 && $info[$key]->generator != 2) {
423 423
 				# remove leading zeros (padding) and raise the value in case of any zone name length changes
424 424
 				# add some padding to reach the maximum zone name lenght
425
-				$info[$key]->zone = str_pad(ltrim($info[$key]->zone,0),$info[$key]->length,"0",STR_PAD_LEFT);
425
+				$info[$key]->zone = str_pad (ltrim ($info[$key]->zone, 0), $info[$key]->length, "0", STR_PAD_LEFT);
426 426
 				}
427 427
 			}
428 428
 		}
429 429
 
430 430
 		# return the values
431
-		return sizeof($info)>0 ? $info[0] : false;
431
+		return sizeof ($info) > 0 ? $info[0] : false;
432 432
 	}
433 433
 
434 434
 
@@ -440,12 +440,12 @@  discard block
 block discarded – undo
440 440
 	 */
441 441
 	public function get_zones () {
442 442
 		# try to fetch all zones
443
-		try { $zones =  $this->Database->getObjectsQuery('SELECT * FROM firewallZones;');}
443
+		try { $zones = $this->Database->getObjectsQuery ('SELECT * FROM firewallZones;'); }
444 444
 		# throw exception
445
-		catch (Exception $e) {$this->Result->show("danger", _("Database error: ").$e->getMessage());}
445
+		catch (Exception $e) {$this->Result->show ("danger", _ ("Database error: ").$e->getMessage ()); }
446 446
 
447 447
 		# try to fetch all subnet and vlan informations for all zones
448
-		try { $networkInformation =  $this->Database->getObjectsQuery('SELECT
448
+		try { $networkInformation = $this->Database->getObjectsQuery ('SELECT
449 449
 						firewallZoneSubnet.zoneId AS zoneId,
450 450
 						firewallZoneSubnet.subnetId AS subnetId,
451 451
 						subnets.sectionId AS sectionId,
@@ -459,25 +459,25 @@  discard block
 block discarded – undo
459 459
 						vlans.name AS vlanName
460 460
 						FROM firewallZoneSubnet
461 461
 						LEFT JOIN subnets ON firewallZoneSubnet.subnetId = subnets.id
462
-						LEFT JOIN vlans ON subnets.vlanId = vlans.vlanId ORDER BY subnet ASC;');}
462
+						LEFT JOIN vlans ON subnets.vlanId = vlans.vlanId ORDER BY subnet ASC;'); }
463 463
 		# throw exception
464
-		catch (Exception $e) {$this->Result->show("danger", _("Database error: ").$e->getMessage());}
464
+		catch (Exception $e) {$this->Result->show ("danger", _ ("Database error: ").$e->getMessage ()); }
465 465
 
466 466
 		# modify the zone output values
467 467
 		foreach ($zones as $key => $val) {
468 468
 			# transform the zone name from decimal to hex
469
-			if($zones[$key]->generator == 1 ){
470
-				$zones[$key]->zone = dechex($zones[$key]->zone);
469
+			if ($zones[$key]->generator == 1) {
470
+				$zones[$key]->zone = dechex ($zones[$key]->zone);
471 471
 			}
472 472
 			# add some padding if it is activated and the zone generatore is not text
473
-			if($zones[$key]->padding == 1 && $zones[$key]->generator != 2){
473
+			if ($zones[$key]->padding == 1 && $zones[$key]->generator != 2) {
474 474
 			# remove leading zeros (padding) and raise the value in case of any zone name length changes
475 475
 			# add some padding to reach the maximum zone name lenght
476
-			$zones[$key]->zone = str_pad(ltrim($zones[$key]->zone,0),$zones[$key]->length,"0",STR_PAD_LEFT);
476
+			$zones[$key]->zone = str_pad (ltrim ($zones[$key]->zone, 0), $zones[$key]->length, "0", STR_PAD_LEFT);
477 477
 			}
478 478
 			# inject network informations
479 479
 			foreach ($networkInformation as $nkey => $nval) {
480
-				if($zones[$key]->id == $nval->zoneId) {
480
+				if ($zones[$key]->id == $nval->zoneId) {
481 481
 					# remove the zoneId, we don't need it anymore
482 482
 					unset($networkInformation[$nkey]->zoneId);
483 483
 					# add each network and vlan information to the object
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
 			}
487 487
 		}
488 488
 		# return the values
489
-		return sizeof($zones)>0 ? $zones : false;
489
+		return sizeof ($zones) > 0 ? $zones : false;
490 490
 	}
491 491
 
492 492
 
@@ -499,13 +499,13 @@  discard block
 block discarded – undo
499 499
 	 */
500 500
 	public function get_zone ($id) {
501 501
 		# try to fetch zone with ID $id
502
-		try { $zone = $this->Database->getObjectsQuery('SELECT * FROM firewallZones WHERE id = ?;', $id);}
502
+		try { $zone = $this->Database->getObjectsQuery ('SELECT * FROM firewallZones WHERE id = ?;', $id); }
503 503
 
504 504
 		# throw exception
505
-		catch (Exception $e) {$this->Result->show("danger", _("Database error: ").$e->getMessage());}
505
+		catch (Exception $e) {$this->Result->show ("danger", _ ("Database error: ").$e->getMessage ()); }
506 506
 
507 507
 		# try to fetch all subnet and vlan informations for this zone
508
-		try { $networkInformation =  $this->Database->getObjectsQuery('SELECT
508
+		try { $networkInformation = $this->Database->getObjectsQuery ('SELECT
509 509
 						firewallZoneSubnet.zoneId AS zoneId,
510 510
 						firewallZoneSubnet.subnetId AS subnetId,
511 511
 						subnets.sectionId AS sectionId,
@@ -519,25 +519,25 @@  discard block
 block discarded – undo
519 519
 						vlans.name AS vlanName
520 520
 						FROM firewallZoneSubnet
521 521
 						LEFT JOIN subnets ON firewallZoneSubnet.subnetId = subnets.id
522
-						LEFT JOIN vlans ON subnets.vlanId = vlans.vlanId HAVING zoneId = ? ORDER BY subnet ASC;', $id);}
522
+						LEFT JOIN vlans ON subnets.vlanId = vlans.vlanId HAVING zoneId = ? ORDER BY subnet ASC;', $id); }
523 523
 		# throw exception
524
-		catch (Exception $e) {$this->Result->show("danger", _("Database error: ").$e->getMessage());}
524
+		catch (Exception $e) {$this->Result->show ("danger", _ ("Database error: ").$e->getMessage ()); }
525 525
 
526 526
 		# modify the zone output values
527 527
 		foreach ($zone as $key => $val) {
528 528
 			# transform the zone name from decimal to hex
529
-			if($zone[$key]->generator == 1 ){
530
-				$zone[$key]->zone = dechex($zone[$key]->zone);
529
+			if ($zone[$key]->generator == 1) {
530
+				$zone[$key]->zone = dechex ($zone[$key]->zone);
531 531
 			}
532 532
 			# add some padding if it is activated and the zone generatore is not text
533
-			if($zone[$key]->padding == 1 && $zone[$key]->generator != 2){
533
+			if ($zone[$key]->padding == 1 && $zone[$key]->generator != 2) {
534 534
 			# remove leading zeros (padding) and raise the value in case of any zone name length changes
535 535
 			# add some padding to reach the maximum zone name lenght
536
-			$zone[$key]->zone = str_pad(ltrim($zone[$key]->zone,0),$zone[$key]->length,"0",STR_PAD_LEFT);
536
+			$zone[$key]->zone = str_pad (ltrim ($zone[$key]->zone, 0), $zone[$key]->length, "0", STR_PAD_LEFT);
537 537
 			}
538 538
 			# inject network informations
539 539
 			foreach ($networkInformation as $nkey => $nval) {
540
-				if($zone[$key]->id == $nval->zoneId) {
540
+				if ($zone[$key]->id == $nval->zoneId) {
541 541
 					# remove the zoneId, we don't need it anymore
542 542
 					unset($networkInformation[$nkey]->zoneId);
543 543
 					# add each network and vlan information to the object
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 		}
548 548
 
549 549
 		# return the values
550
-		return sizeof($zone)>0 ? $zone[0] : false;
550
+		return sizeof ($zone) > 0 ? $zone[0] : false;
551 551
 	}
552 552
 
553 553
 
@@ -560,22 +560,22 @@  discard block
 block discarded – undo
560 560
 	 */
561 561
 	public function get_zone_detail ($id) {
562 562
 		# get zone informations
563
-		$zoneInformation = $this->get_zone($id);
563
+		$zoneInformation = $this->get_zone ($id);
564 564
 
565 565
 		# build html output
566 566
 		print '<table class="table table-auto table-condensed" style="margin-bottom:0px;">';
567 567
 		print "<tr><td colspan='2'><h4>Zone details</h4><hr></td></tr>";
568 568
 		print '<tr>';
569
-		print '<td style="width:110px;">'._('Zone Name').'</td>';
569
+		print '<td style="width:110px;">'._ ('Zone Name').'</td>';
570 570
 		print '<td>'.$zoneInformation->zone.'</td>';
571 571
 		print '</tr>';
572 572
 		print '<tr>';
573
-		print '<td>'._('Indicator').'</td>';
573
+		print '<td>'._ ('Indicator').'</td>';
574 574
 		$title = $zoneInformation->indicator == 0 ? 'Own Zone' : 'Customer Zone';
575
-		print '<td><span class="fa fa-home"  title="'._($title).'"></span></td>';
575
+		print '<td><span class="fa fa-home"  title="'._ ($title).'"></span></td>';
576 576
 		print '</tr>';
577 577
 		print '<tr>';
578
-		print '<td>'._('Description').'</td>';
578
+		print '<td>'._ ('Description').'</td>';
579 579
 		print '<td>'.$zoneInformation->description.'</td>';
580 580
 		print '</tr>';
581 581
 		print "</table>";
@@ -584,8 +584,8 @@  discard block
 block discarded – undo
584 584
 			print "<table class='table table-condensed' style='margin-bottom:30px;'>";
585 585
 			print "<tr><td colspan='2'><br><h4>Subnets</h4><hr></td></tr>";
586 586
 			print '<tr>';
587
-			print '<th>'._('Subnet').'</th>';
588
-			print '<th>'._('VLAN').'</th>';
587
+			print '<th>'._ ('Subnet').'</th>';
588
+			print '<th>'._ ('VLAN').'</th>';
589 589
 			print '</tr>';
590 590
 			foreach ($zoneInformation->network as $network) {
591 591
 				print '<tr>';
@@ -594,8 +594,8 @@  discard block
 block discarded – undo
594 594
 				$network->vlanName = $network->vlanName ? "(".$network->vlanName.")" : "";
595 595
 
596 596
 				if (!$network->subnetIsFolder) {
597
-					print '<td>'.$this->Subnets->transform_to_dotted($network->subnet).'/'.$network->subnetMask.$network->subnetDescription.'</td>';
598
-				} else{
597
+					print '<td>'.$this->Subnets->transform_to_dotted ($network->subnet).'/'.$network->subnetMask.$network->subnetDescription.'</td>';
598
+				} else {
599 599
 					print '<td>Folder '.$network->subnetDescription.'</td>';
600 600
 				}
601 601
 				print '<td>'.$network->vlan.$network->vlanName.'</td>';
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
 	 */
615 615
 	public function get_zone_network ($id) {
616 616
 		# try to fetch all subnet and vlan informations for this zone
617
-		try { $networkInformation =  $this->Database->getObjectsQuery('SELECT
617
+		try { $networkInformation = $this->Database->getObjectsQuery ('SELECT
618 618
 						firewallZoneSubnet.zoneId AS zoneId,
619 619
 						firewallZoneSubnet.subnetId AS subnetId,
620 620
 						subnets.sectionId AS sectionId,
@@ -628,11 +628,11 @@  discard block
 block discarded – undo
628 628
 						vlans.name AS vlanName
629 629
 						FROM firewallZoneSubnet
630 630
 						LEFT JOIN subnets ON firewallZoneSubnet.subnetId = subnets.id
631
-						LEFT JOIN vlans ON subnets.vlanId = vlans.vlanId HAVING zoneId = ? ORDER BY subnet ASC;', $id);}
631
+						LEFT JOIN vlans ON subnets.vlanId = vlans.vlanId HAVING zoneId = ? ORDER BY subnet ASC;', $id); }
632 632
 		# throw exception
633
-		catch (Exception $e) {$this->Result->show("danger", _("Database error: ").$e->getMessage());}
633
+		catch (Exception $e) {$this->Result->show ("danger", _ ("Database error: ").$e->getMessage ()); }
634 634
 
635
-		$rowspan = count($networkInformation);
635
+		$rowspan = count ($networkInformation);
636 636
 		$i = 1;
637 637
 		print '<table class="table table-noborder table-condensed" style="padding-bottom:20px;">';
638 638
 		foreach ($networkInformation as $network) {
@@ -641,16 +641,16 @@  discard block
 block discarded – undo
641 641
 				print '<td rowspan="'.$rowspan.'" style="width:150px;">Network</td>';
642 642
 			}
643 643
 			print '<td>';
644
-			print '<a class="btn btn-xs btn-danger editNetwork" style="margin-right:5px;" alt="'._('Delete Network').'" title="'._('Delete Network').'" data-action="delete" data-zoneId="'.$id.'" data-subnetId="'.$network->subnetId.'">';
644
+			print '<a class="btn btn-xs btn-danger editNetwork" style="margin-right:5px;" alt="'._ ('Delete Network').'" title="'._ ('Delete Network').'" data-action="delete" data-zoneId="'.$id.'" data-subnetId="'.$network->subnetId.'">';
645 645
 			print '<span><i class="fa fa-close"></i></span>';
646 646
 			print "</a>";
647 647
 
648
-			if ($network->subnetIsFolder == 1 ) {
648
+			if ($network->subnetIsFolder == 1) {
649 649
 				print 'Folder: '.$network->subnetDescription;
650 650
 			} else {
651 651
 				# display network information with or without description
652
-				if ($network->subnetDescription) 	{	print $this->Subnets->transform_to_dotted($network->subnet).'/'.$network->subnetMask.' ('.$network->subnetDescription.')</td>';	}
653
-				else 								{	print $this->Subnets->transform_to_dotted($network->subnet).'/'.$network->subnetMask.'</td>';	}
652
+				if ($network->subnetDescription) {	print $this->Subnets->transform_to_dotted ($network->subnet).'/'.$network->subnetMask.' ('.$network->subnetDescription.')</td>'; }
653
+				else {	print $this->Subnets->transform_to_dotted ($network->subnet).'/'.$network->subnetMask.'</td>'; }
654 654
 			}
655 655
 			print '</tr>';
656 656
 			$i++;
@@ -668,16 +668,16 @@  discard block
 block discarded – undo
668 668
 	 */
669 669
 	public function check_zone_network ($subnetId) {
670 670
 		# check if the subnet is already bound to this or any other zone
671
-		try { $networkInformation =  $this->Database->getObjectsQuery('SELECT * FROM firewallZoneSubnet WHERE subnetId = ?;', $subnetId);}
671
+		try { $networkInformation = $this->Database->getObjectsQuery ('SELECT * FROM firewallZoneSubnet WHERE subnetId = ?;', $subnetId); }
672 672
 
673 673
 		# throw exception
674
-		catch (Exception $e) {$this->Result->show("danger", _("Database error: ").$e->getMessage());}
674
+		catch (Exception $e) {$this->Result->show ("danger", _ ("Database error: ").$e->getMessage ()); }
675 675
 
676
-		if(!sizeof($networkInformation)>0 ) {
676
+		if (!sizeof ($networkInformation) > 0) {
677 677
 			# return dummy value
678 678
 			return 'success';
679 679
 		} else {
680
-			$this->Result->show("danger","<strong>"._('Error').":</strong><br>"._("This network is already bound to this or another zone.<br>The binding must be unique."), false);
680
+			$this->Result->show ("danger", "<strong>"._ ('Error').":</strong><br>"._ ("This network is already bound to this or another zone.<br>The binding must be unique."), false);
681 681
 			return false;
682 682
 		}
683 683
 		# return dummy value
@@ -693,24 +693,24 @@  discard block
 block discarded – undo
693 693
 	 * @param mixed $subnetId
694 694
 	 * @return false|string
695 695
 	 */
696
-	public function add_zone_network ($zoneId,$subnetId) {
696
+	public function add_zone_network ($zoneId, $subnetId) {
697 697
 		# check if the subnet is already bound to this or any other zone
698
-		try { $networkInformation =  $this->Database->getObjectsQuery('SELECT * FROM firewallZoneSubnet WHERE subnetId = ?;', $subnetId);}
698
+		try { $networkInformation = $this->Database->getObjectsQuery ('SELECT * FROM firewallZoneSubnet WHERE subnetId = ?;', $subnetId); }
699 699
 
700 700
 		# throw exception
701
-		catch (Exception $e) {$this->Result->show("danger", _("Database error: ").$e->getMessage());}
701
+		catch (Exception $e) {$this->Result->show ("danger", _ ("Database error: ").$e->getMessage ()); }
702 702
 
703
-		if(!sizeof($networkInformation)>0 ) {
703
+		if (!sizeof ($networkInformation) > 0) {
704 704
 			$query = 'INSERT INTO firewallZoneSubnet (zoneId, subnetId) VALUES (?,?);';
705
-			$params = array('zoneId' => $zoneId, 'subnetId' => $subnetId);
705
+			$params = array ('zoneId' => $zoneId, 'subnetId' => $subnetId);
706 706
 
707 707
 			# try to fetch all subnet and vlan informations for this zone
708
-			try { $addRow =  $this->Database->insertObject("firewallZoneSubnet", $params);}
708
+			try { $addRow = $this->Database->insertObject ("firewallZoneSubnet", $params); }
709 709
 
710 710
 			# throw exception
711
-			catch (Exception $e) {$this->Result->show("danger", _("Database error: ").$e->getMessage());}
711
+			catch (Exception $e) {$this->Result->show ("danger", _ ("Database error: ").$e->getMessage ()); }
712 712
 		} else {
713
-			$this->Result->show("danger","<strong>"._('Error').":</strong><br>"._("This network is already bound to this or another zone.<br>The binding must be unique."), false);
713
+			$this->Result->show ("danger", "<strong>"._ ('Error').":</strong><br>"._ ("This network is already bound to this or another zone.<br>The binding must be unique."), false);
714 714
 			return false;
715 715
 		}
716 716
 		# return dummy value
@@ -726,12 +726,12 @@  discard block
 block discarded – undo
726 726
 	 * @param mixed $subnetId
727 727
 	 * @return string|false
728 728
 	 */
729
-	public function delete_zone_network ($zoneId,$subnetId) {
729
+	public function delete_zone_network ($zoneId, $subnetId) {
730 730
 		# try to fetch all subnet and vlan informations for this zone
731
-		try { $deleteRow =  $this->Database->deleteRow("firewallZoneSubnet", "zoneId", $zoneId, "subnetId", $subnetId); }
731
+		try { $deleteRow = $this->Database->deleteRow ("firewallZoneSubnet", "zoneId", $zoneId, "subnetId", $subnetId); }
732 732
 
733 733
 		# throw exception
734
-		catch (Exception $e) {$this->Result->show("danger", _("Database error: ").$e->getMessage());}
734
+		catch (Exception $e) {$this->Result->show ("danger", _ ("Database error: ").$e->getMessage ()); }
735 735
 
736 736
 		# return dummy value or false
737 737
 		if ($deleteRow) {
@@ -765,10 +765,10 @@  discard block
 block discarded – undo
765 765
 		}
766 766
 
767 767
 		# execute based on action
768
-		if($action=="add")			{ return $this->zone_add ($values,$network); }
769
-		elseif($action=="edit")		{ return $this->zone_edit ($values); }
770
-		elseif($action=="delete")	{ return $this->zone_delete ($values['id']); }
771
-		else						{ return $this->Result->show("danger", _("Invalid action"), true); }
768
+		if ($action == "add") { return $this->zone_add ($values, $network); }
769
+		elseif ($action == "edit") { return $this->zone_edit ($values); }
770
+		elseif ($action == "delete") { return $this->zone_delete ($values['id']); }
771
+		else { return $this->Result->show ("danger", _ ("Invalid action"), true); }
772 772
 	}
773 773
 
774 774
 
@@ -780,35 +780,35 @@  discard block
 block discarded – undo
780 780
 	 * @param mixed $network
781 781
 	 * @return boolean
782 782
 	 */
783
-	private function zone_add ($values,$network) {
783
+	private function zone_add ($values, $network) {
784 784
 		# get the settings
785
-		$firewallZoneSettings = json_decode($this->settings->firewallZoneSettings,true);
785
+		$firewallZoneSettings = json_decode ($this->settings->firewallZoneSettings, true);
786 786
 
787 787
 		# push the zone name length into the values array
788 788
 		$values['length'] = $firewallZoneSettings['zoneLength'];
789 789
 
790 790
 		# execute insert
791
-		try { $this->Database->insertObject("firewallZones", $values); }
791
+		try { $this->Database->insertObject ("firewallZones", $values); }
792 792
 		catch (Exception $e) {
793
-			$this->Result->show("danger", _("Error: ").$e->getMessage(), false);
794
-			$this->Log->write( "Firewall zone created", "Failed to add new firewall zone<hr>".$e->getMessage(), 2, $this->User->username);
793
+			$this->Result->show ("danger", _ ("Error: ").$e->getMessage (), false);
794
+			$this->Log->write ("Firewall zone created", "Failed to add new firewall zone<hr>".$e->getMessage (), 2, $this->User->username);
795 795
 			return false;
796 796
 		}
797 797
 
798 798
 		# fetch the highest inserted id, matching the zone name
799
-		try { $lastId=$this->Database->getObjectsQuery("SELECT MAX(id) AS id FROM firewallZones WHERE zone = ? ;", $values['zone']);}
799
+		try { $lastId = $this->Database->getObjectsQuery ("SELECT MAX(id) AS id FROM firewallZones WHERE zone = ? ;", $values['zone']); }
800 800
 		catch (Exception $e) {
801
-			$this->Result->show("danger", _("Error: ").$e->getMessage(), false);
801
+			$this->Result->show ("danger", _ ("Error: ").$e->getMessage (), false);
802 802
 			return false;
803 803
 		}
804 804
 
805 805
 		if ($network) {
806 806
 			foreach ($network as $subnetId) {
807
-				$values = array('zoneId' => $lastId[0]->id, 'subnetId' => $subnetId);
807
+				$values = array ('zoneId' => $lastId[0]->id, 'subnetId' => $subnetId);
808 808
 				# add the network bindings if there are any
809
-				try { $this->Database->insertObject("firewallZoneSubnet", $values); }
809
+				try { $this->Database->insertObject ("firewallZoneSubnet", $values); }
810 810
 				catch (Exception $e) {
811
-					$this->Result->show("danger", _("Error: ").$e->getMessage(), false);
811
+					$this->Result->show ("danger", _ ("Error: ").$e->getMessage (), false);
812 812
 					return false;
813 813
 				}
814 814
 			}
@@ -829,14 +829,14 @@  discard block
 block discarded – undo
829 829
 	 */
830 830
 	private function zone_edit ($values) {
831 831
 		# execute
832
-		try { $this->Database->updateObject("firewallZones", $values, "id"); }
832
+		try { $this->Database->updateObject ("firewallZones", $values, "id"); }
833 833
 		catch (Exception $e) {
834
-			$this->Result->show("danger", _("Error: ").$e->getMessage(), false);
835
-			$this->Log->write( "Firewall zone edited", "Failed to edit firewall zone<hr>".$e->getMessage(), 2, $this->User->username);
834
+			$this->Result->show ("danger", _ ("Error: ").$e->getMessage (), false);
835
+			$this->Log->write ("Firewall zone edited", "Failed to edit firewall zone<hr>".$e->getMessage (), 2, $this->User->username);
836 836
 			return false;
837 837
 		}
838 838
 		# ok
839
-		$this->Log->write( "Firewall zone edited", "Firewall zone edited<hr>".$this->array_to_log($values), 0, $this->User->username);
839
+		$this->Log->write ("Firewall zone edited", "Firewall zone edited<hr>".$this->array_to_log ($values), 0, $this->User->username);
840 840
 		return true;
841 841
 	}
842 842
 
@@ -850,25 +850,25 @@  discard block
 block discarded – undo
850 850
 	 */
851 851
 	private function zone_delete ($id) {
852 852
 		# save old values
853
-		$old_zone = $this->get_zone($id);
853
+		$old_zone = $this->get_zone ($id);
854 854
 
855 855
 		# delete mappings
856
-		try { $this->Database->deleteRow("firewallZoneMapping", "zoneId", $id); }
856
+		try { $this->Database->deleteRow ("firewallZoneMapping", "zoneId", $id); }
857 857
 		catch (Exception $e) {
858
-			$this->Log->write( "Firewall zone and mappings delete", "Failed to delete firewall zone mappfings of $old_zone->zone<hr>".$e->getMessage(), 2, $this->User->username);
859
-			$this->Result->show("danger", _("Error: ").$e->getMessage(), false);
858
+			$this->Log->write ("Firewall zone and mappings delete", "Failed to delete firewall zone mappfings of $old_zone->zone<hr>".$e->getMessage (), 2, $this->User->username);
859
+			$this->Result->show ("danger", _ ("Error: ").$e->getMessage (), false);
860 860
 			return false;
861 861
 		}
862 862
 
863 863
 		# delete zone
864
-		try { $this->Database->deleteRow("firewallZones", "id", $id); }
864
+		try { $this->Database->deleteRow ("firewallZones", "id", $id); }
865 865
 		catch (Exception $e) {
866
-			$this->Log->write( "Firewall zone delete", "Failed to delete firewall zone $old_zone->zone<hr>".$e->getMessage(), 2, $this->User->username);
867
-			$this->Result->show("danger", _("Error: ").$e->getMessage(), false);
866
+			$this->Log->write ("Firewall zone delete", "Failed to delete firewall zone $old_zone->zone<hr>".$e->getMessage (), 2, $this->User->username);
867
+			$this->Result->show ("danger", _ ("Error: ").$e->getMessage (), false);
868 868
 			return false;
869 869
 		}
870 870
 		# ok
871
-		$this->Log->write( "Firewall zone deleted", "Firewall zone ".$old_zone->zone." deleted<hr>".$this->array_to_log($old_subnet), 0, $this->User->username);
871
+		$this->Log->write ("Firewall zone deleted", "Firewall zone ".$old_zone->zone." deleted<hr>".$this->array_to_log ($old_subnet), 0, $this->User->username);
872 872
 
873 873
 		return true;
874 874
 	}
@@ -890,10 +890,10 @@  discard block
 block discarded – undo
890 890
 		$values = $this->reformat_empty_array_fields ($values, null);
891 891
 
892 892
 		# execute based on action
893
-		if($action=="add")			{ return $this->mapping_add ($values); }
894
-		elseif($action=="edit")		{ return $this->mapping_edit ($values); }
895
-		elseif($action=="delete")	{ return $this->mapping_delete ($values['id']); }
896
-		else						{ return $this->Result->show("danger", _("Invalid action"), true); }
893
+		if ($action == "add") { return $this->mapping_add ($values); }
894
+		elseif ($action == "edit") { return $this->mapping_edit ($values); }
895
+		elseif ($action == "delete") { return $this->mapping_delete ($values['id']); }
896
+		else { return $this->Result->show ("danger", _ ("Invalid action"), true); }
897 897
 	}
898 898
 
899 899
 
@@ -906,17 +906,17 @@  discard block
 block discarded – undo
906 906
 	 */
907 907
 	private function mapping_add ($values) {
908 908
 		# get the settings
909
-		$firewallZoneSettings = json_decode($this->settings->firewallZoneSettings,true);
909
+		$firewallZoneSettings = json_decode ($this->settings->firewallZoneSettings, true);
910 910
 
911 911
 		# execute
912
-		try { $this->Database->insertObject("firewallZoneMapping", $values); }
912
+		try { $this->Database->insertObject ("firewallZoneMapping", $values); }
913 913
 		catch (Exception $e) {
914
-			$this->Result->show("danger", _("Error: ").$e->getMessage(), false);
915
-			$this->Log->write( "Firewall zone mapping created", "Failed to add new firewall zone mapping<hr>".$e->getMessage(), 2, $this->User->username);
914
+			$this->Result->show ("danger", _ ("Error: ").$e->getMessage (), false);
915
+			$this->Log->write ("Firewall zone mapping created", "Failed to add new firewall zone mapping<hr>".$e->getMessage (), 2, $this->User->username);
916 916
 			return false;
917 917
 		}
918 918
 		# ok
919
-		$this->Log->write( "Firewall zone mapping created", "New firewall zone mapping created<hr>".$this->array_to_log($values), 0, $this->User->username);
919
+		$this->Log->write ("Firewall zone mapping created", "New firewall zone mapping created<hr>".$this->array_to_log ($values), 0, $this->User->username);
920 920
 		return true;
921 921
 	}
922 922
 
@@ -930,14 +930,14 @@  discard block
 block discarded – undo
930 930
 	 */
931 931
 	private function mapping_edit ($values) {
932 932
 		# execute
933
-		try { $this->Database->updateObject("firewallZoneMapping", $values, "id"); }
933
+		try { $this->Database->updateObject ("firewallZoneMapping", $values, "id"); }
934 934
 		catch (Exception $e) {
935
-			$this->Result->show("danger", _("Error: ").$e->getMessage(), false);
936
-			$this->Log->write( "Firewall zone mapping edited", "Failed to edit firewall zone mapping<hr>".$e->getMessage(), 2, $this->User->username);
935
+			$this->Result->show ("danger", _ ("Error: ").$e->getMessage (), false);
936
+			$this->Log->write ("Firewall zone mapping edited", "Failed to edit firewall zone mapping<hr>".$e->getMessage (), 2, $this->User->username);
937 937
 			return false;
938 938
 		}
939 939
 		# ok
940
-		$this->Log->write( "Firewall zone mapping edited", "Firewall zone mapping edited<hr>".$this->array_to_log($values), 0, $this->User->username);
940
+		$this->Log->write ("Firewall zone mapping edited", "Firewall zone mapping edited<hr>".$this->array_to_log ($values), 0, $this->User->username);
941 941
 		return true;
942 942
 	}
943 943
 
@@ -951,17 +951,17 @@  discard block
 block discarded – undo
951 951
 	 */
952 952
 	private function mapping_delete ($id) {
953 953
 		# save old values
954
-		$old_mapping = $this->get_zone_mapping($id);
954
+		$old_mapping = $this->get_zone_mapping ($id);
955 955
 
956 956
 		# delete mapping
957
-		try { $this->Database->deleteRow("firewallZoneMapping", "id", $id); }
957
+		try { $this->Database->deleteRow ("firewallZoneMapping", "id", $id); }
958 958
 		catch (Exception $e) {
959
-			$this->Log->write( "Firewall zone mapping delete", "Failed to delete firewall zone mapping $old_zone->zone<hr>".$e->getMessage(), 2, $this->User->username);
960
-			$this->Result->show("danger", _("Error: ").$e->getMessage(), false);
959
+			$this->Log->write ("Firewall zone mapping delete", "Failed to delete firewall zone mapping $old_zone->zone<hr>".$e->getMessage (), 2, $this->User->username);
960
+			$this->Result->show ("danger", _ ("Error: ").$e->getMessage (), false);
961 961
 			return false;
962 962
 		}
963 963
 		# ok
964
-		$this->Log->write( "Firewall zone mapping deleted", "Firewall zone mapping ".$old_zone->zone." deleted<hr>".$this->array_to_log($old_subnet), 0, $this->User->username);
964
+		$this->Log->write ("Firewall zone mapping deleted", "Firewall zone mapping ".$old_zone->zone." deleted<hr>".$this->array_to_log ($old_subnet), 0, $this->User->username);
965 965
 
966 966
 		return true;
967 967
 	}
@@ -975,26 +975,26 @@  discard block
 block discarded – undo
975 975
 	 */
976 976
 	public function generate_subnet_object ($id) {
977 977
 		# fetch the settings
978
-		$firewallZoneSettings = json_decode($this->settings->firewallZoneSettings,true);
978
+		$firewallZoneSettings = json_decode ($this->settings->firewallZoneSettings, true);
979 979
 
980 980
 		# fetch zone informations
981
-		$zone = $this->get_zone_subnet_info($id);
981
+		$zone = $this->get_zone_subnet_info ($id);
982 982
 
983 983
 		# build the object name prefix
984 984
 		foreach ($firewallZoneSettings['pattern'] as $pattern) {
985 985
 			switch ($pattern) {
986 986
 				case 'patternIndicator':
987
-					if ($zone->indicator == 0 ) {	$firewallAddressObject = $firewallAddressObject.$firewallZoneSettings['indicator'][0]; }
988
-					else 						{ 	$firewallAddressObject = $firewallAddressObject.$firewallZoneSettings['indicator'][1]; }
987
+					if ($zone->indicator == 0) {	$firewallAddressObject = $firewallAddressObject.$firewallZoneSettings['indicator'][0]; }
988
+					else { 	$firewallAddressObject = $firewallAddressObject.$firewallZoneSettings['indicator'][1]; }
989 989
 					break;
990 990
 				case 'patternZoneName':
991 991
 					$firewallAddressObject = $firewallAddressObject.$zone->zone;
992 992
 					break;
993 993
 				case 'patternIPType':
994 994
 					# check if the subnet is v4 or v6
995
-					if (filter_var($this->Subnets->transform_to_dotted($zone->subnet), FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
995
+					if (filter_var ($this->Subnets->transform_to_dotted ($zone->subnet), FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
996 996
 						$firewallAddressObject = $firewallAddressObject.$firewallZoneSettings['ipType'][0];
997
-					} elseif (filter_var($this->Subnets->transform_to_dotted($zone->subnet), FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
997
+					} elseif (filter_var ($this->Subnets->transform_to_dotted ($zone->subnet), FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
998 998
 						$firewallAddressObject = $firewallAddressObject.$firewallZoneSettings['ipType'][1];
999 999
 					}
1000 1000
 					break;
@@ -1005,27 +1005,27 @@  discard block
 block discarded – undo
1005 1005
 		}
1006 1006
 
1007 1007
 		#build the object name
1008
-		if ($firewallZoneSettings['subnetPatternValues'][$firewallZoneSettings['subnetPattern']] == 'network' ) {
1008
+		if ($firewallZoneSettings['subnetPatternValues'][$firewallZoneSettings['subnetPattern']] == 'network') {
1009 1009
 			# check if the subnet is v4 or v6
1010
-			if (filter_var($this->Subnets->transform_to_dotted($zone->subnet), FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
1011
-				$firewallAddressObject = $firewallAddressObject.$this->Subnets->transform_to_dotted($zone->subnet).'-'.$zone->mask;
1012
-			} elseif (filter_var($this->Subnets->transform_to_dotted($zone->subnet), FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
1013
-				$firewallAddressObject = $firewallAddressObject.str_replace(':',$firewallZoneSettings['separator'],$this->Subnets->transform_to_dotted($zone->subnet)).'-'.$zone->mask;
1010
+			if (filter_var ($this->Subnets->transform_to_dotted ($zone->subnet), FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
1011
+				$firewallAddressObject = $firewallAddressObject.$this->Subnets->transform_to_dotted ($zone->subnet).'-'.$zone->mask;
1012
+			} elseif (filter_var ($this->Subnets->transform_to_dotted ($zone->subnet), FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
1013
+				$firewallAddressObject = $firewallAddressObject.str_replace (':', $firewallZoneSettings['separator'], $this->Subnets->transform_to_dotted ($zone->subnet)).'-'.$zone->mask;
1014 1014
 			}
1015
-		} elseif ($firewallZoneSettings['subnetPatternValues'][$firewallZoneSettings['subnetPattern']] == 'description' ) {
1016
-			$firewallAddressObject = $firewallAddressObject.str_replace(' ',$firewallZoneSettings['separator'],strtolower($zone->subnetDescription));
1015
+		} elseif ($firewallZoneSettings['subnetPatternValues'][$firewallZoneSettings['subnetPattern']] == 'description') {
1016
+			$firewallAddressObject = $firewallAddressObject.str_replace (' ', $firewallZoneSettings['separator'], strtolower ($zone->subnetDescription));
1017 1017
 		}
1018 1018
 
1019 1019
 		# get subnet information to compare against the changes
1020
-		$subnet = (array) $this->Subnets->fetch_subnet("id",$id);
1020
+		$subnet = (array) $this->Subnets->fetch_subnet ("id", $id);
1021 1021
 
1022 1022
 		# compare both versions, if there is no difference, just do nothing
1023
-		if ($zone->firewallAddressObject != $firewallAddressObject ) {
1023
+		if ($zone->firewallAddressObject != $firewallAddressObject) {
1024 1024
 			# update field in database
1025
-			$values = array('id' => $id , 'firewallAddressObject' => $firewallAddressObject);
1026
-			try { $this->Database->updateObject("subnets", $values, "id"); }
1025
+			$values = array ('id' => $id, 'firewallAddressObject' => $firewallAddressObject);
1026
+			try { $this->Database->updateObject ("subnets", $values, "id"); }
1027 1027
 			catch (Exception $e) {
1028
-				$this->Result->show("danger", _("Error: ").$e->getMessage(), false);
1028
+				$this->Result->show ("danger", _ ("Error: ").$e->getMessage (), false);
1029 1029
 				return false;
1030 1030
 			}
1031 1031
 			# clone the address_old obj and replace the firewallAddressObject field to get a diff for logging
@@ -1033,7 +1033,7 @@  discard block
 block discarded – undo
1033 1033
 			$subnet['firewallAddressObject'] = $firewallAddressObject;
1034 1034
 
1035 1035
 			# write changelog
1036
-			$this->Log->write_changelog('subnet', 'edit', 'success', $subnet_old,$subnet);
1036
+			$this->Log->write_changelog ('subnet', 'edit', 'success', $subnet_old, $subnet);
1037 1037
 
1038 1038
 			return ture;
1039 1039
 		}
@@ -1048,32 +1048,32 @@  discard block
 block discarded – undo
1048 1048
 	 * @param mixed $dnsName
1049 1049
 	 * @return string
1050 1050
 	 */
1051
-	public function generate_address_object ($id,$dnsName) {
1051
+	public function generate_address_object ($id, $dnsName) {
1052 1052
 		# fetch the settings
1053
-		$firewallZoneSettings = json_decode($this->settings->firewallZoneSettings,true);
1053
+		$firewallZoneSettings = json_decode ($this->settings->firewallZoneSettings, true);
1054 1054
 
1055 1055
 		# fetch zone informations
1056
-		$zone = $this->get_zone_subnet_info($id);
1056
+		$zone = $this->get_zone_subnet_info ($id);
1057 1057
 
1058 1058
 		foreach ($firewallZoneSettings['pattern'] as $pattern) {
1059 1059
 			switch ($pattern) {
1060 1060
 				case 'patternIndicator':
1061
-					if ($zone->indicator == 0 ) {	$firewallAddressObject = $firewallAddressObject.$firewallZoneSettings['indicator'][0]; }
1062
-					else 						{ 	$firewallAddressObject = $firewallAddressObject.$firewallZoneSettings['indicator'][1]; }
1061
+					if ($zone->indicator == 0) {	$firewallAddressObject = $firewallAddressObject.$firewallZoneSettings['indicator'][0]; }
1062
+					else { 	$firewallAddressObject = $firewallAddressObject.$firewallZoneSettings['indicator'][1]; }
1063 1063
 					break;
1064 1064
 				case 'patternZoneName':
1065 1065
 					$firewallAddressObject = $firewallAddressObject.$zone->zone;
1066 1066
 					break;
1067 1067
 				case 'patternIPType':
1068 1068
 					# check if the subnet is v4 or v6
1069
-					if (filter_var($this->Subnets->transform_to_dotted($zone->subnet), FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
1069
+					if (filter_var ($this->Subnets->transform_to_dotted ($zone->subnet), FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
1070 1070
 						$firewallAddressObject = $firewallAddressObject.$firewallZoneSettings['ipType'][0];
1071
-					} elseif (filter_var($this->Subnets->transform_to_dotted($zone->subnet), FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
1071
+					} elseif (filter_var ($this->Subnets->transform_to_dotted ($zone->subnet), FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
1072 1072
 						$firewallAddressObject = $firewallAddressObject.$firewallZoneSettings['ipType'][1];
1073 1073
 					}
1074 1074
 					break;
1075 1075
 				case 'patternHost':
1076
-						$hostName = explode('.', $dnsName);
1076
+						$hostName = explode ('.', $dnsName);
1077 1077
 						$firewallAddressObject = $firewallAddressObject.$hostName[0];
1078 1078
 					break;
1079 1079
 				case 'patternFQDN':
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
 	 * @param mixed $dnsName
1097 1097
 	 * @return void
1098 1098
 	 */
1099
-	public function update_address_object ($subnetId,$IPId,$dnsName) {
1099
+	public function update_address_object ($subnetId, $IPId, $dnsName) {
1100 1100
 		# Addresses object
1101 1101
 		$this->Addresses = new Addresses ($this->Database);
1102 1102
 
@@ -1104,30 +1104,30 @@  discard block
 block discarded – undo
1104 1104
 		$address_old = $this->Addresses->fetch_address (null, $IPId);
1105 1105
 
1106 1106
 		# fetch the settings
1107
-		$firewallZoneSettings = json_decode($this->settings->firewallZoneSettings,true);
1107
+		$firewallZoneSettings = json_decode ($this->settings->firewallZoneSettings, true);
1108 1108
 
1109 1109
 		# fetch zone informations
1110
-		$zone = $this->get_zone_subnet_info($subnetId);
1110
+		$zone = $this->get_zone_subnet_info ($subnetId);
1111 1111
 
1112 1112
 		foreach ($firewallZoneSettings['pattern'] as $pattern) {
1113 1113
 			switch ($pattern) {
1114 1114
 				case 'patternIndicator':
1115
-					if ($zone->indicator == 0 ) {	$firewallAddressObject = $firewallAddressObject.$firewallZoneSettings['indicator'][0]; }
1116
-					else 						{ 	$firewallAddressObject = $firewallAddressObject.$firewallZoneSettings['indicator'][1]; }
1115
+					if ($zone->indicator == 0) {	$firewallAddressObject = $firewallAddressObject.$firewallZoneSettings['indicator'][0]; }
1116
+					else { 	$firewallAddressObject = $firewallAddressObject.$firewallZoneSettings['indicator'][1]; }
1117 1117
 					break;
1118 1118
 				case 'patternZoneName':
1119 1119
 					$firewallAddressObject = $firewallAddressObject.$zone->zone;
1120 1120
 					break;
1121 1121
 				case 'patternIPType':
1122 1122
 					# check if the subnet is v4 or v6
1123
-					if (filter_var($this->Subnets->transform_to_dotted($zone->subnet), FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
1123
+					if (filter_var ($this->Subnets->transform_to_dotted ($zone->subnet), FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
1124 1124
 						$firewallAddressObject = $firewallAddressObject.$firewallZoneSettings['ipType'][0];
1125
-					} elseif (filter_var($this->Subnets->transform_to_dotted($zone->subnet), FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
1125
+					} elseif (filter_var ($this->Subnets->transform_to_dotted ($zone->subnet), FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
1126 1126
 						$firewallAddressObject = $firewallAddressObject.$firewallZoneSettings['ipType'][1];
1127 1127
 					}
1128 1128
 					break;
1129 1129
 				case 'patternHost':
1130
-						$hostName = explode('.', $dnsName);
1130
+						$hostName = explode ('.', $dnsName);
1131 1131
 						$firewallAddressObject = $firewallAddressObject.$hostName[0];
1132 1132
 					break;
1133 1133
 				case 'patternFQDN':
@@ -1141,10 +1141,10 @@  discard block
 block discarded – undo
1141 1141
 
1142 1142
 		if ($address_old->firewallAddressObject != $firewallAddressObject) {
1143 1143
 			# update field in database
1144
-			$values = array('id' => $IPId , 'subnetId' => $subnetId, 'firewallAddressObject' => $firewallAddressObject);
1145
-			try { $this->Database->updateObject("ipaddresses", $values, "id", "subnetId"); }
1144
+			$values = array ('id' => $IPId, 'subnetId' => $subnetId, 'firewallAddressObject' => $firewallAddressObject);
1145
+			try { $this->Database->updateObject ("ipaddresses", $values, "id", "subnetId"); }
1146 1146
 			catch (Exception $e) {
1147
-				$this->Result->show("danger", _("Error: ").$e->getMessage(), false);
1147
+				$this->Result->show ("danger", _ ("Error: ").$e->getMessage (), false);
1148 1148
 				return false;
1149 1149
 			}
1150 1150
 			# clone the address_old obj and replace the firewallAddressObject field to get a diff for logging
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
 			$address->firewallAddressObject = $firewallAddressObject;
1153 1153
 
1154 1154
 			# write changelog
1155
-			$this->Log->write_changelog('ip_addr', 'edit', 'success', (array)$address_old,(array)$address);
1155
+			$this->Log->write_changelog ('ip_addr', 'edit', 'success', (array) $address_old, (array) $address);
1156 1156
 
1157 1157
 			return ture;
1158 1158
 		}
@@ -1172,14 +1172,14 @@  discard block
 block discarded – undo
1172 1172
 		$this->Addresses = new Addresses ($this->Database);
1173 1173
 
1174 1174
 		# fetch the settings
1175
-		$firewallZoneSettings = json_decode($this->settings->firewallZoneSettings,true);
1175
+		$firewallZoneSettings = json_decode ($this->settings->firewallZoneSettings, true);
1176 1176
 
1177 1177
 		# fetch zone informations
1178
-		$zone = $this->get_zone_subnet_info($subnetId);
1178
+		$zone = $this->get_zone_subnet_info ($subnetId);
1179 1179
 
1180
-		try { $ipaddresses = $this->Database->getObjectsQuery('SELECT id, dns_name FROM ipaddresses WHERE subnetId = ? ',$subnetId); }
1180
+		try { $ipaddresses = $this->Database->getObjectsQuery ('SELECT id, dns_name FROM ipaddresses WHERE subnetId = ? ', $subnetId); }
1181 1181
 		catch (Exception $e) {
1182
-			$this->Result->show("danger", _("Error: ").$e->getMessage(), false);
1182
+			$this->Result->show ("danger", _ ("Error: ").$e->getMessage (), false);
1183 1183
 			return false;
1184 1184
 		}
1185 1185
 		foreach ($ipaddresses as $ipaddress) {
@@ -1189,22 +1189,22 @@  discard block
 block discarded – undo
1189 1189
 			foreach ($firewallZoneSettings['pattern'] as $key => $pattern) {
1190 1190
 				switch ($pattern) {
1191 1191
 					case 'patternIndicator':
1192
-						if ($zone->indicator == 0 ) {	$firewallAddressObject = $firewallAddressObject.$firewallZoneSettings['indicator'][0]; }
1193
-						else 						{ 	$firewallAddressObject = $firewallAddressObject.$firewallZoneSettings['indicator'][1]; }
1192
+						if ($zone->indicator == 0) {	$firewallAddressObject = $firewallAddressObject.$firewallZoneSettings['indicator'][0]; }
1193
+						else { 	$firewallAddressObject = $firewallAddressObject.$firewallZoneSettings['indicator'][1]; }
1194 1194
 						break;
1195 1195
 					case 'patternZoneName':
1196 1196
 						$firewallAddressObject = $firewallAddressObject.$zone->zone;
1197 1197
 						break;
1198 1198
 					case 'patternIPType':
1199 1199
 						# check if the subnet is v4 or v6
1200
-						if (filter_var($this->Subnets->transform_to_dotted($zone->subnet), FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
1200
+						if (filter_var ($this->Subnets->transform_to_dotted ($zone->subnet), FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
1201 1201
 							$firewallAddressObject = $firewallAddressObject.$firewallZoneSettings['ipType'][0];
1202
-						} elseif (filter_var($this->Subnets->transform_to_dotted($zone->subnet), FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
1202
+						} elseif (filter_var ($this->Subnets->transform_to_dotted ($zone->subnet), FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
1203 1203
 							$firewallAddressObject = $firewallAddressObject.$firewallZoneSettings['ipType'][1];
1204 1204
 						}
1205 1205
 						break;
1206 1206
 					case 'patternHost':
1207
-							$hostName = explode('.', $ipaddress->dns_name);
1207
+							$hostName = explode ('.', $ipaddress->dns_name);
1208 1208
 							$firewallAddressObject = $firewallAddressObject.$hostName[0];
1209 1209
 						break;
1210 1210
 					case 'patternFQDN':
@@ -1218,10 +1218,10 @@  discard block
 block discarded – undo
1218 1218
 
1219 1219
 			if ($address_old->firewallAddressObject != $firewallAddressObject) {
1220 1220
 				# update field in database
1221
-				$values = array('id' => $ipaddress->id , 'subnetId' => $subnetId, 'firewallAddressObject' => $firewallAddressObject);
1222
-				try { $this->Database->updateObject("ipaddresses", $values, "id", "subnetId"); }
1221
+				$values = array ('id' => $ipaddress->id, 'subnetId' => $subnetId, 'firewallAddressObject' => $firewallAddressObject);
1222
+				try { $this->Database->updateObject ("ipaddresses", $values, "id", "subnetId"); }
1223 1223
 				catch (Exception $e) {
1224
-					$this->Result->show("danger", _("Error: ").$e->getMessage(), false);
1224
+					$this->Result->show ("danger", _ ("Error: ").$e->getMessage (), false);
1225 1225
 					return false;
1226 1226
 				}
1227 1227
 				# clone the address_old obj and replace the firewallAddressObject field to get a diff for logging
@@ -1229,7 +1229,7 @@  discard block
 block discarded – undo
1229 1229
 				$address->firewallAddressObject = $firewallAddressObject;
1230 1230
 
1231 1231
 				# write changelog
1232
-				$this->Log->write_changelog('ip_addr', 'edit', 'success', (array)$address_old,(array)$address);
1232
+				$this->Log->write_changelog ('ip_addr', 'edit', 'success', (array) $address_old, (array) $address);
1233 1233
 			}
1234 1234
 
1235 1235
 			# unset firewallAddressObject to avoid chaining
Please login to merge, or discard this patch.