Completed
Pull Request — master (#532)
06:37
created
functions/checks/check_db_structure.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -22,26 +22,26 @@
 block discarded – undo
22 22
 
23 23
 # print result
24 24
 if( (!isset($errors['tableError'])) && (!isset($errors['fieldError'])) ) {
25
-	print 'All tables and fields are installed properly'. "\n";
25
+    print 'All tables and fields are installed properly'. "\n";
26 26
 }
27 27
 else {
28
-	# missing tables
29
-	if (isset($errors['tableError'])) {
30
-		print 'Missing tables:'. "\n";
31
-
32
-		foreach ($errors['tableError'] as $table) {
33
-			print " - ".$table."\n";
34
-		}
35
-	}
36
-
37
-	# missing fields
38
-	if (isset($errors['fieldError'])) {
39
-		print "\n".'Missing fields'. "\n";
40
-
41
-		foreach ($errors['fieldError'] as $table=>$field) {
42
-			print 'Table `'. $table .'`: missing field `'. $field .'`;'."\n";
43
-		}
44
-	}
28
+    # missing tables
29
+    if (isset($errors['tableError'])) {
30
+        print 'Missing tables:'. "\n";
31
+
32
+        foreach ($errors['tableError'] as $table) {
33
+            print " - ".$table."\n";
34
+        }
35
+    }
36
+
37
+    # missing fields
38
+    if (isset($errors['fieldError'])) {
39
+        print "\n".'Missing fields'. "\n";
40
+
41
+        foreach ($errors['fieldError'] as $table=>$field) {
42
+            print 'Table `'. $table .'`: missing field `'. $field .'`;'."\n";
43
+        }
44
+    }
45 45
 }
46 46
 print "\n";
47 47
 ?>
48 48
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -8,26 +8,26 @@  discard block
 block discarded – undo
8 8
  ****************************************/
9 9
 
10 10
 # functions
11
-require_once( dirname(__FILE__) . '/../functions.php' );
11
+require_once(dirname (__FILE__).'/../functions.php');
12 12
 
13 13
 # Classes
14 14
 $Database = new Database_PDO;
15 15
 $Tools = new Tools ($Database);
16 16
 
17 17
 # title
18
-print "\n".'Database structure verification'. "\n--------------------\n";
18
+print "\n".'Database structure verification'."\n--------------------\n";
19 19
 
20 20
 # check for errors
21
-$errors = $Tools->verify_database();
21
+$errors = $Tools->verify_database ();
22 22
 
23 23
 # print result
24
-if( (!isset($errors['tableError'])) && (!isset($errors['fieldError'])) ) {
25
-	print 'All tables and fields are installed properly'. "\n";
24
+if ((!isset($errors['tableError'])) && (!isset($errors['fieldError']))) {
25
+	print 'All tables and fields are installed properly'."\n";
26 26
 }
27 27
 else {
28 28
 	# missing tables
29 29
 	if (isset($errors['tableError'])) {
30
-		print 'Missing tables:'. "\n";
30
+		print 'Missing tables:'."\n";
31 31
 
32 32
 		foreach ($errors['tableError'] as $table) {
33 33
 			print " - ".$table."\n";
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
 
37 37
 	# missing fields
38 38
 	if (isset($errors['fieldError'])) {
39
-		print "\n".'Missing fields'. "\n";
39
+		print "\n".'Missing fields'."\n";
40 40
 
41 41
 		foreach ($errors['fieldError'] as $table=>$field) {
42
-			print 'Table `'. $table .'`: missing field `'. $field .'`;'."\n";
42
+			print 'Table `'.$table.'`: missing field `'.$field.'`;'."\n";
43 43
 		}
44 44
 	}
45 45
 }
Please login to merge, or discard this patch.
functions/checks/check_db_upgrade.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 
9 9
 /* redirect */
10 10
 if($User->settings->version < VERSION) {
11
-	header("Location: ".create_link("upgrade"));
12
-	die();
11
+    header("Location: ".create_link("upgrade"));
12
+    die();
13 13
 }
14 14
 ?>
15 15
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@
 block discarded – undo
7 7
 # use required functions
8 8
 
9 9
 /* redirect */
10
-if($User->settings->version < VERSION) {
11
-	header("Location: ".create_link("upgrade"));
10
+if ($User->settings->version < VERSION) {
11
+	header ("Location: ".create_link ("upgrade"));
12 12
 	die();
13 13
 }
14 14
 ?>
15 15
\ No newline at end of file
Please login to merge, or discard this patch.
functions/scripts/find_untranslated_files.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -14,23 +14,23 @@  discard block
 block discarded – undo
14 14
 $untranslated = explode("\n",shell_exec("cd ".dirname(__FILE__)."/../../ && grep -r '_(' * "));
15 15
 // loop and search
16 16
 foreach ($untranslated as $u) {
17
-	// find string
18
-	$str = get_string_between($u, "_('", "')");
19
-	// remove "" and '
20
-	$str = trim($str, "',\"");
21
-	// search for invalud content and remove
22
-	if (substr($str, 0, 1)!="$") {
23
-		$all_translations[] = $str;
24
-	}
17
+    // find string
18
+    $str = get_string_between($u, "_('", "')");
19
+    // remove "" and '
20
+    $str = trim($str, "',\"");
21
+    // search for invalud content and remove
22
+    if (substr($str, 0, 1)!="$") {
23
+        $all_translations[] = $str;
24
+    }
25 25
 
26
-	// find string
27
-	$str = get_string_between($u, '_("', '")');
28
-	// remove "" and '
29
-	$str = trim($str, "',\"");
30
-	// search for invalud content and remove
31
-	if (substr($str, 0, 1)!="$") {
32
-		$all_translations[] = $str;
33
-	}
26
+    // find string
27
+    $str = get_string_between($u, '_("', '")');
28
+    // remove "" and '
29
+    $str = trim($str, "',\"");
30
+    // search for invalud content and remove
31
+    if (substr($str, 0, 1)!="$") {
32
+        $all_translations[] = $str;
33
+    }
34 34
 }
35 35
 //unique
36 36
 $all_translations = array_unique($all_translations);
@@ -40,25 +40,25 @@  discard block
 block discarded – undo
40 40
 $untranslated = explode("\n",shell_exec("cd ".dirname(__FILE__)."/../../ && more functions/locale/en/LC_MESSAGES/phpipam.po"));
41 41
 // loop and create
42 42
 foreach ($untranslated as $u) {
43
-	// search for string
44
-	if (substr($u, 0, 7)=='msgid "') {
45
-		$u = str_replace("msgid ", "", $u);
46
-		$u = trim($u, '"');
47
-		$translated[] = $u;
48
-	}
43
+    // search for string
44
+    if (substr($u, 0, 7)=='msgid "') {
45
+        $u = str_replace("msgid ", "", $u);
46
+        $u = trim($u, '"');
47
+        $translated[] = $u;
48
+    }
49 49
 }
50 50
 
51 51
 // remove existing from unique
52 52
 foreach ($all_translations as $tr) {
53
-	if (!in_array($tr, $translated)) {
54
-		$new[] = $tr;
55
-	}
53
+    if (!in_array($tr, $translated)) {
54
+        $new[] = $tr;
55
+    }
56 56
 }
57 57
 
58 58
 // format
59 59
 foreach ($new as $tr) {
60
-	$text[] = "msgid \"$tr\"";
61
-	$text[] = "msgstr \"\"\n";
60
+    $text[] = "msgid \"$tr\"";
61
+    $text[] = "msgstr \"\"\n";
62 62
 }
63 63
 // join text
64 64
 $text = implode("\n",$text);
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -7,50 +7,50 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // only from cli
10
-if (php_sapi_name() != "cli")	{ die("Cli only!"); }
10
+if (php_sapi_name () != "cli") { die("Cli only!"); }
11 11
 
12 12
 
13 13
 // search for all translated words and put them to array
14
-$untranslated = explode("\n",shell_exec("cd ".dirname(__FILE__)."/../../ && grep -r '_(' * "));
14
+$untranslated = explode ("\n", shell_exec ("cd ".dirname (__FILE__)."/../../ && grep -r '_(' * "));
15 15
 // loop and search
16 16
 foreach ($untranslated as $u) {
17 17
 	// find string
18
-	$str = get_string_between($u, "_('", "')");
18
+	$str = get_string_between ($u, "_('", "')");
19 19
 	// remove "" and '
20
-	$str = trim($str, "',\"");
20
+	$str = trim ($str, "',\"");
21 21
 	// search for invalud content and remove
22
-	if (substr($str, 0, 1)!="$") {
22
+	if (substr ($str, 0, 1) != "$") {
23 23
 		$all_translations[] = $str;
24 24
 	}
25 25
 
26 26
 	// find string
27
-	$str = get_string_between($u, '_("', '")');
27
+	$str = get_string_between ($u, '_("', '")');
28 28
 	// remove "" and '
29
-	$str = trim($str, "',\"");
29
+	$str = trim ($str, "',\"");
30 30
 	// search for invalud content and remove
31
-	if (substr($str, 0, 1)!="$") {
31
+	if (substr ($str, 0, 1) != "$") {
32 32
 		$all_translations[] = $str;
33 33
 	}
34 34
 }
35 35
 //unique
36
-$all_translations = array_unique($all_translations);
36
+$all_translations = array_unique ($all_translations);
37 37
 
38 38
 
39 39
 // search all existing translations
40
-$untranslated = explode("\n",shell_exec("cd ".dirname(__FILE__)."/../../ && more functions/locale/en/LC_MESSAGES/phpipam.po"));
40
+$untranslated = explode ("\n", shell_exec ("cd ".dirname (__FILE__)."/../../ && more functions/locale/en/LC_MESSAGES/phpipam.po"));
41 41
 // loop and create
42 42
 foreach ($untranslated as $u) {
43 43
 	// search for string
44
-	if (substr($u, 0, 7)=='msgid "') {
45
-		$u = str_replace("msgid ", "", $u);
46
-		$u = trim($u, '"');
44
+	if (substr ($u, 0, 7) == 'msgid "') {
45
+		$u = str_replace ("msgid ", "", $u);
46
+		$u = trim ($u, '"');
47 47
 		$translated[] = $u;
48 48
 	}
49 49
 }
50 50
 
51 51
 // remove existing from unique
52 52
 foreach ($all_translations as $tr) {
53
-	if (!in_array($tr, $translated)) {
53
+	if (!in_array ($tr, $translated)) {
54 54
 		$new[] = $tr;
55 55
 	}
56 56
 }
@@ -61,20 +61,20 @@  discard block
 block discarded – undo
61 61
 	$text[] = "msgstr \"\"\n";
62 62
 }
63 63
 // join text
64
-$text = implode("\n",$text);
64
+$text = implode ("\n", $text);
65 65
 
66 66
 
67 67
 // output changes
68
-print_r($text);
68
+print_r ($text);
69 69
 
70 70
 
71 71
 // returns string between 2 separators
72
-function get_string_between($string, $start, $end){
72
+function get_string_between ($string, $start, $end) {
73 73
     $string = " ".$string;
74
-    $ini = strpos($string,$start);
74
+    $ini = strpos ($string, $start);
75 75
     if ($ini == 0) return "";
76
-    $ini += strlen($start);
77
-    $len = strpos($string,$end,$ini) - $ini;
78
-    return substr($string,$ini,$len);
76
+    $ini += strlen ($start);
77
+    $len = strpos ($string, $end, $ini) - $ini;
78
+    return substr ($string, $ini, $len);
79 79
 }
80 80
 ?>
81 81
\ No newline at end of file
Please login to merge, or discard this patch.
functions/scripts/resolveIPaddresses.php 2 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
 /* settings */
16 16
 $resolve_config['emptyonly'] = true;			# if true it will only update the ones without DNS entry!
17 17
 $resolve_config['subnets']	 = array();			# which subnets to check - by id
18
-												# example -> array(1,3,5)	will only update subnets with id 1,3,5
19
-												# 	you can get id's and descriptions with following MySQL query:
20
-												#	select `id`,`description` from `subnets`;
18
+                                                # example -> array(1,3,5)	will only update subnets with id 1,3,5
19
+                                                # 	you can get id's and descriptions with following MySQL query:
20
+                                                #	select `id`,`description` from `subnets`;
21 21
 $resolve_config['verbose']  = true;				# verbose response - prints results, cron will email it to you!
22 22
 
23 23
 # include required scripts
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 
40 40
 # set subnet
41 41
 if (isset($argv[1])) {
42
-	$req_subnets = explode(",", $argv[1]);
43
-	foreach ($req_subnets as $s) {
44
-		if (!is_numeric($s)) { $Result->show_cli("Invalid subnetId provided - $s\n", true); }
45
-		else {
46
-			$resolve_config['subnets'][] = $s;
47
-		}
48
-	}
42
+    $req_subnets = explode(",", $argv[1]);
43
+    foreach ($req_subnets as $s) {
44
+        if (!is_numeric($s)) { $Result->show_cli("Invalid subnetId provided - $s\n", true); }
45
+        else {
46
+            $resolve_config['subnets'][] = $s;
47
+        }
48
+    }
49 49
 }
50 50
 
51 51
 
@@ -56,29 +56,29 @@  discard block
 block discarded – undo
56 56
 
57 57
 # check all subnets
58 58
 if(sizeof($resolve_config['subnets']) == 0) {
59
-	# get ony ip's with empty DNS
60
-	if($resolve_config['emptyonly'] == 1) 	{ $query = 'select `id`,`ip_addr`,`dns_name`,`subnetId` from `ipaddresses` where `dns_name` = "" or `dns_name` is NULL order by `ip_addr` ASC;'; }
61
-	else 									{ $query = 'select `id`,`ip_addr`,`dns_name`,`subnetId` from `ipaddresses` order by `ip_addr` ASC;'; }
59
+    # get ony ip's with empty DNS
60
+    if($resolve_config['emptyonly'] == 1) 	{ $query = 'select `id`,`ip_addr`,`dns_name`,`subnetId` from `ipaddresses` where `dns_name` = "" or `dns_name` is NULL order by `ip_addr` ASC;'; }
61
+    else 									{ $query = 'select `id`,`ip_addr`,`dns_name`,`subnetId` from `ipaddresses` order by `ip_addr` ASC;'; }
62 62
 }
63 63
 # check selected subnets
64 64
 else {
65
-	$query[] = "select `id`,`ip_addr`,`dns_name`,`subnetId` from `ipaddresses` where ";
66
-	//go through subnets
67
-	$m=1;
68
-	foreach($resolve_config['subnets'] as $k=>$subnetId) {
69
-		// last
70
-		if($m==sizeof($resolve_config['subnets']))	{ $query[] = '`subnetId` = "'. $subnetId .'" '; }
71
-		else										{ $query[] = '`subnetId` = "'. $subnetId .'" or '; }
72
-		$m++;
73
-	}
74
-	# get ony ip's with empty DNS
75
-	if($resolve_config['emptyonly'] == 1) {
76
-		$query[] = ' and (`dns_name` = "" or `dns_name` is NULL ) ';
77
-	}
78
-	$query[] = 'order by `ip_addr` ASC;';
79
-
80
-	//join
81
-	$query = implode("\n", $query);
65
+    $query[] = "select `id`,`ip_addr`,`dns_name`,`subnetId` from `ipaddresses` where ";
66
+    //go through subnets
67
+    $m=1;
68
+    foreach($resolve_config['subnets'] as $k=>$subnetId) {
69
+        // last
70
+        if($m==sizeof($resolve_config['subnets']))	{ $query[] = '`subnetId` = "'. $subnetId .'" '; }
71
+        else										{ $query[] = '`subnetId` = "'. $subnetId .'" or '; }
72
+        $m++;
73
+    }
74
+    # get ony ip's with empty DNS
75
+    if($resolve_config['emptyonly'] == 1) {
76
+        $query[] = ' and (`dns_name` = "" or `dns_name` is NULL ) ';
77
+    }
78
+    $query[] = 'order by `ip_addr` ASC;';
79
+
80
+    //join
81
+    $query = implode("\n", $query);
82 82
 }
83 83
 
84 84
 # fetch records
@@ -86,31 +86,31 @@  discard block
 block discarded – undo
86 86
 
87 87
 # try to update dns records
88 88
 if (sizeof($ipaddresses)>0) {
89
-	foreach($ipaddresses as $ip) {
90
-		# fetch subnet
91
-		$subnet = $Subnets->fetch_subnet ("id", $ip->subnetId);
92
-		$nsid = $subnet===false ? false : $subnet->nameserverId;
93
-		# try to resolve
94
-		$hostname = $DNS->resolve_address ($ip->ip_addr, null, true, $nsid);
95
-
96
-		# update if change
97
-		if($hostname['class']=="resolved") {
98
-			# values
99
-			$values = array("dns_name"=>$hostname['name'],
100
-							"id"=>$ip->id
101
-							);
102
-			# execute
103
-			if(!$Admin->object_modify("ipaddresses", "edit", "id", $values))	{ $Result->show_cli("Failed to update address ".$Subnets->transform_to_dotted($ip->ip_addr)); }
104
-
105
-			# set text
106
-			$res[] = 'updated ip address '. $Subnets->transform_to_dotted($ip->ip_addr) . ' with hostname '. $hostname['name'];
107
-		}
108
-	}
89
+    foreach($ipaddresses as $ip) {
90
+        # fetch subnet
91
+        $subnet = $Subnets->fetch_subnet ("id", $ip->subnetId);
92
+        $nsid = $subnet===false ? false : $subnet->nameserverId;
93
+        # try to resolve
94
+        $hostname = $DNS->resolve_address ($ip->ip_addr, null, true, $nsid);
95
+
96
+        # update if change
97
+        if($hostname['class']=="resolved") {
98
+            # values
99
+            $values = array("dns_name"=>$hostname['name'],
100
+                            "id"=>$ip->id
101
+                            );
102
+            # execute
103
+            if(!$Admin->object_modify("ipaddresses", "edit", "id", $values))	{ $Result->show_cli("Failed to update address ".$Subnets->transform_to_dotted($ip->ip_addr)); }
104
+
105
+            # set text
106
+            $res[] = 'updated ip address '. $Subnets->transform_to_dotted($ip->ip_addr) . ' with hostname '. $hostname['name'];
107
+        }
108
+    }
109 109
 }
110 110
 
111 111
 
112 112
 # if verbose print result so it can be emailed via cron!
113 113
 if($resolve_config['verbose'] == true && isset($res)) {
114
-	print implode("\n", $res);
114
+    print implode("\n", $res);
115 115
 }
116 116
 ?>
117 117
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -13,35 +13,35 @@  discard block
 block discarded – undo
13 13
 
14 14
 
15 15
 /* settings */
16
-$resolve_config['emptyonly'] = true;			# if true it will only update the ones without DNS entry!
17
-$resolve_config['subnets']	 = array();			# which subnets to check - by id
16
+$resolve_config['emptyonly'] = true; # if true it will only update the ones without DNS entry!
17
+$resolve_config['subnets'] = array (); # which subnets to check - by id
18 18
 												# example -> array(1,3,5)	will only update subnets with id 1,3,5
19 19
 												# 	you can get id's and descriptions with following MySQL query:
20 20
 												#	select `id`,`description` from `subnets`;
21
-$resolve_config['verbose']  = true;				# verbose response - prints results, cron will email it to you!
21
+$resolve_config['verbose'] = true; # verbose response - prints results, cron will email it to you!
22 22
 
23 23
 # include required scripts
24
-require( dirname(__FILE__) . '/../functions.php' );
24
+require(dirname (__FILE__).'/../functions.php');
25 25
 
26 26
 # initialize objects
27
-$Database 	= new Database_PDO;
28
-$Admin		= new Admin ($Database, false);
27
+$Database = new Database_PDO;
28
+$Admin = new Admin ($Database, false);
29 29
 $Subnets	= new Subnets ($Database);
30
-$DNS		= new DNS ($Database);
31
-$Result		= new Result();
30
+$DNS = new DNS ($Database);
31
+$Result		= new Result ();
32 32
 
33 33
 // set to 1 in case of errors
34
-ini_set('display_errors', 0);
35
-error_reporting(E_ERROR);
34
+ini_set ('display_errors', 0);
35
+error_reporting (E_ERROR);
36 36
 
37 37
 # cli required
38
-if( php_sapi_name()!="cli" ) { $Result->show_cli("cli only\n", true); }
38
+if (php_sapi_name () != "cli") { $Result->show_cli ("cli only\n", true); }
39 39
 
40 40
 # set subnet
41 41
 if (isset($argv[1])) {
42
-	$req_subnets = explode(",", $argv[1]);
42
+	$req_subnets = explode (",", $argv[1]);
43 43
 	foreach ($req_subnets as $s) {
44
-		if (!is_numeric($s)) { $Result->show_cli("Invalid subnetId provided - $s\n", true); }
44
+		if (!is_numeric ($s)) { $Result->show_cli ("Invalid subnetId provided - $s\n", true); }
45 45
 		else {
46 46
 			$resolve_config['subnets'][] = $s;
47 47
 		}
@@ -55,62 +55,62 @@  discard block
 block discarded – undo
55 55
 #
56 56
 
57 57
 # check all subnets
58
-if(sizeof($resolve_config['subnets']) == 0) {
58
+if (sizeof ($resolve_config['subnets']) == 0) {
59 59
 	# get ony ip's with empty DNS
60
-	if($resolve_config['emptyonly'] == 1) 	{ $query = 'select `id`,`ip_addr`,`dns_name`,`subnetId` from `ipaddresses` where `dns_name` = "" or `dns_name` is NULL order by `ip_addr` ASC;'; }
61
-	else 									{ $query = 'select `id`,`ip_addr`,`dns_name`,`subnetId` from `ipaddresses` order by `ip_addr` ASC;'; }
60
+	if ($resolve_config['emptyonly'] == 1) { $query = 'select `id`,`ip_addr`,`dns_name`,`subnetId` from `ipaddresses` where `dns_name` = "" or `dns_name` is NULL order by `ip_addr` ASC;'; }
61
+	else { $query = 'select `id`,`ip_addr`,`dns_name`,`subnetId` from `ipaddresses` order by `ip_addr` ASC;'; }
62 62
 }
63 63
 # check selected subnets
64 64
 else {
65 65
 	$query[] = "select `id`,`ip_addr`,`dns_name`,`subnetId` from `ipaddresses` where ";
66 66
 	//go through subnets
67
-	$m=1;
68
-	foreach($resolve_config['subnets'] as $k=>$subnetId) {
67
+	$m = 1;
68
+	foreach ($resolve_config['subnets'] as $k=>$subnetId) {
69 69
 		// last
70
-		if($m==sizeof($resolve_config['subnets']))	{ $query[] = '`subnetId` = "'. $subnetId .'" '; }
71
-		else										{ $query[] = '`subnetId` = "'. $subnetId .'" or '; }
70
+		if ($m == sizeof ($resolve_config['subnets'])) { $query[] = '`subnetId` = "'.$subnetId.'" '; }
71
+		else { $query[] = '`subnetId` = "'.$subnetId.'" or '; }
72 72
 		$m++;
73 73
 	}
74 74
 	# get ony ip's with empty DNS
75
-	if($resolve_config['emptyonly'] == 1) {
75
+	if ($resolve_config['emptyonly'] == 1) {
76 76
 		$query[] = ' and (`dns_name` = "" or `dns_name` is NULL ) ';
77 77
 	}
78 78
 	$query[] = 'order by `ip_addr` ASC;';
79 79
 
80 80
 	//join
81
-	$query = implode("\n", $query);
81
+	$query = implode ("\n", $query);
82 82
 }
83 83
 
84 84
 # fetch records
85
-$ipaddresses = $Database->getObjectsQuery($query);
85
+$ipaddresses = $Database->getObjectsQuery ($query);
86 86
 
87 87
 # try to update dns records
88
-if (sizeof($ipaddresses)>0) {
89
-	foreach($ipaddresses as $ip) {
88
+if (sizeof ($ipaddresses) > 0) {
89
+	foreach ($ipaddresses as $ip) {
90 90
 		# fetch subnet
91 91
 		$subnet = $Subnets->fetch_subnet ("id", $ip->subnetId);
92
-		$nsid = $subnet===false ? false : $subnet->nameserverId;
92
+		$nsid = $subnet === false ? false : $subnet->nameserverId;
93 93
 		# try to resolve
94 94
 		$hostname = $DNS->resolve_address ($ip->ip_addr, null, true, $nsid);
95 95
 
96 96
 		# update if change
97
-		if($hostname['class']=="resolved") {
97
+		if ($hostname['class'] == "resolved") {
98 98
 			# values
99
-			$values = array("dns_name"=>$hostname['name'],
99
+			$values = array ("dns_name"=>$hostname['name'],
100 100
 							"id"=>$ip->id
101 101
 							);
102 102
 			# execute
103
-			if(!$Admin->object_modify("ipaddresses", "edit", "id", $values))	{ $Result->show_cli("Failed to update address ".$Subnets->transform_to_dotted($ip->ip_addr)); }
103
+			if (!$Admin->object_modify ("ipaddresses", "edit", "id", $values)) { $Result->show_cli ("Failed to update address ".$Subnets->transform_to_dotted ($ip->ip_addr)); }
104 104
 
105 105
 			# set text
106
-			$res[] = 'updated ip address '. $Subnets->transform_to_dotted($ip->ip_addr) . ' with hostname '. $hostname['name'];
106
+			$res[] = 'updated ip address '.$Subnets->transform_to_dotted ($ip->ip_addr).' with hostname '.$hostname['name'];
107 107
 		}
108 108
 	}
109 109
 }
110 110
 
111 111
 
112 112
 # if verbose print result so it can be emailed via cron!
113
-if($resolve_config['verbose'] == true && isset($res)) {
114
-	print implode("\n", $res);
113
+if ($resolve_config['verbose'] == true && isset($res)) {
114
+	print implode ("\n", $res);
115 115
 }
116 116
 ?>
117 117
\ No newline at end of file
Please login to merge, or discard this patch.
functions/scripts/discoveryCheck.php 2 patches
Indentation   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -78,18 +78,18 @@  discard block
 block discarded – undo
78 78
     $addresses_tmp = array();
79 79
     // loop
80 80
     foreach($scan_subnets as $s) {
81
-    	// if subnet has slaves dont check it
82
-    	if ($Subnets->has_slaves ($s->id) === false) {
83
-    		$addresses_tmp[$s->id] = $Scan-> prepare_addresses_to_scan ("discovery", $s->id, false);
84
-    	}
81
+        // if subnet has slaves dont check it
82
+        if ($Subnets->has_slaves ($s->id) === false) {
83
+            $addresses_tmp[$s->id] = $Scan-> prepare_addresses_to_scan ("discovery", $s->id, false);
84
+        }
85 85
     }
86 86
 
87 87
     //reindex
88 88
     if(sizeof($addresses_tmp)>0) {
89 89
         foreach($addresses_tmp as $s_id=>$a) {
90
-        	foreach($a as $ip) {
91
-        		$addresses[] = array("subnetId"=>$s_id, "ip_addr"=>$ip);
92
-        	}
90
+            foreach($a as $ip) {
91
+                $addresses[] = array("subnetId"=>$s_id, "ip_addr"=>$ip);
92
+            }
93 93
         }
94 94
     }
95 95
 }
@@ -110,101 +110,101 @@  discard block
 block discarded – undo
110 110
 
111 111
 //different scan for fping
112 112
 if($Scan->icmp_type=="fping") {
113
-	//run per MAX_THREADS
114
-	for ($m=0; $m<=$size_subnets; $m += $Scan->settings->scanMaxThreads) {
115
-	    // create threads
116
-	    $threads = array();
117
-	    //fork processes
118
-	    for ($i = 0; $i <= $Scan->settings->scanMaxThreads && $i <= $size_subnets; $i++) {
119
-	    	//only if index exists!
120
-	    	if(isset($scan_subnets[$z])) {
121
-				//start new thread
122
-	            $threads[$z] = new Thread( 'fping_subnet' );
123
-				$threads[$z]->start_fping( $Subnets->transform_to_dotted($scan_subnets[$z]->subnet)."/".$scan_subnets[$z]->mask );
124
-	            $z++;				//next index
125
-			}
126
-	    }
127
-	    // wait for all the threads to finish
128
-	    while( !empty( $threads ) ) {
129
-			foreach($threads as $index => $thread) {
130
-				$child_pipe = "/tmp/pipe_".$thread->getPid();
131
-
132
-				if (file_exists($child_pipe)) {
133
-					$file_descriptor = fopen( $child_pipe, "r");
134
-					$child_response = "";
135
-					while (!feof($file_descriptor)) {
136
-						$child_response .= fread($file_descriptor, 8192);
137
-					}
138
-					//we have the child data in the parent, but serialized:
139
-					$child_response = unserialize( $child_response );
140
-					//store
141
-					$scan_subnets[$index]->discovered = $child_response;
142
-					//now, child is dead, and parent close the pipe
143
-					unlink( $child_pipe );
144
-					unset($threads[$index]);
145
-				}
146
-			}
147
-	        usleep(200000);
148
-	    }
149
-	}
150
-
151
-	//fping finds all subnet addresses, we must remove existing ones !
152
-	foreach($scan_subnets as $sk=>$s) {
153
-    	if(isset($s->discovered)) {
154
-    		foreach($s->discovered as $rk=>$result) {
155
-    			if(!in_array($Subnets->transform_to_decimal($result), $addresses_tmp[$s->id])) {
156
-    				unset($scan_subnets[$sk]->discovered[$rk]);
157
-    			}
158
-    		}
113
+    //run per MAX_THREADS
114
+    for ($m=0; $m<=$size_subnets; $m += $Scan->settings->scanMaxThreads) {
115
+        // create threads
116
+        $threads = array();
117
+        //fork processes
118
+        for ($i = 0; $i <= $Scan->settings->scanMaxThreads && $i <= $size_subnets; $i++) {
119
+            //only if index exists!
120
+            if(isset($scan_subnets[$z])) {
121
+                //start new thread
122
+                $threads[$z] = new Thread( 'fping_subnet' );
123
+                $threads[$z]->start_fping( $Subnets->transform_to_dotted($scan_subnets[$z]->subnet)."/".$scan_subnets[$z]->mask );
124
+                $z++;				//next index
125
+            }
126
+        }
127
+        // wait for all the threads to finish
128
+        while( !empty( $threads ) ) {
129
+            foreach($threads as $index => $thread) {
130
+                $child_pipe = "/tmp/pipe_".$thread->getPid();
131
+
132
+                if (file_exists($child_pipe)) {
133
+                    $file_descriptor = fopen( $child_pipe, "r");
134
+                    $child_response = "";
135
+                    while (!feof($file_descriptor)) {
136
+                        $child_response .= fread($file_descriptor, 8192);
137
+                    }
138
+                    //we have the child data in the parent, but serialized:
139
+                    $child_response = unserialize( $child_response );
140
+                    //store
141
+                    $scan_subnets[$index]->discovered = $child_response;
142
+                    //now, child is dead, and parent close the pipe
143
+                    unlink( $child_pipe );
144
+                    unset($threads[$index]);
145
+                }
146
+            }
147
+            usleep(200000);
148
+        }
149
+    }
150
+
151
+    //fping finds all subnet addresses, we must remove existing ones !
152
+    foreach($scan_subnets as $sk=>$s) {
153
+        if(isset($s->discovered)) {
154
+            foreach($s->discovered as $rk=>$result) {
155
+                if(!in_array($Subnets->transform_to_decimal($result), $addresses_tmp[$s->id])) {
156
+                    unset($scan_subnets[$sk]->discovered[$rk]);
157
+                }
158
+            }
159 159
             //rekey
160 160
             $scan_subnets[$sk]->discovered = array_values($scan_subnets[$sk]->discovered);
161
-		}
162
-	}
161
+        }
162
+    }
163 163
 }
164 164
 //ping, pear
165 165
 else {
166
-	//run per MAX_THREADS
166
+    //run per MAX_THREADS
167 167
     for ($m=0; $m<=$size_addresses; $m += $Scan->settings->scanMaxThreads) {
168 168
         // create threads
169 169
         $threads = array();
170 170
 
171 171
         //fork processes
172 172
         for ($i = 0; $i <= $Scan->settings->scanMaxThreads && $i <= $size_addresses; $i++) {
173
-        	//only if index exists!
174
-        	if(isset($addresses[$z])) {
175
-				//start new thread
176
-	            $threads[$z] = new Thread( 'ping_address' );
177
-	            $threads[$z]->start( $Subnets->transform_to_dotted($addresses[$z]['ip_addr']) );
178
-				$z++;			//next index
179
-			}
173
+            //only if index exists!
174
+            if(isset($addresses[$z])) {
175
+                //start new thread
176
+                $threads[$z] = new Thread( 'ping_address' );
177
+                $threads[$z]->start( $Subnets->transform_to_dotted($addresses[$z]['ip_addr']) );
178
+                $z++;			//next index
179
+            }
180 180
         }
181 181
 
182 182
         // wait for all the threads to finish
183 183
         while( !empty( $threads ) ) {
184 184
             foreach( $threads as $index => $thread ) {
185 185
                 if( ! $thread->isAlive() ) {
186
-					//unset dead hosts
187
-					if($thread->getExitCode() != 0) {
188
-						unset($addresses[$index]);
189
-					}
186
+                    //unset dead hosts
187
+                    if($thread->getExitCode() != 0) {
188
+                        unset($addresses[$index]);
189
+                    }
190 190
                     //remove thread
191 191
                     unset( $threads[$index]);
192 192
                 }
193 193
             }
194 194
             usleep(200000);
195 195
         }
196
-	}
197
-
198
-	//ok, we have all available addresses, rekey them
199
-	foreach($addresses as $a) {
200
-		$add_tmp[$a['subnetId']][] = $Subnets->transform_to_dotted($a['ip_addr']);
201
-	}
202
-	//add to scan_subnets as result
203
-	foreach($scan_subnets as $sk=>$s) {
204
-		if(isset($add_tmp[$s->id])) {
205
-			$scan_subnets[$sk]->discovered = $add_tmp[$s->id];
206
-		}
207
-	}
196
+    }
197
+
198
+    //ok, we have all available addresses, rekey them
199
+    foreach($addresses as $a) {
200
+        $add_tmp[$a['subnetId']][] = $Subnets->transform_to_dotted($a['ip_addr']);
201
+    }
202
+    //add to scan_subnets as result
203
+    foreach($scan_subnets as $sk=>$s) {
204
+        if(isset($add_tmp[$s->id])) {
205
+            $scan_subnets[$sk]->discovered = $add_tmp[$s->id];
206
+        }
207
+    }
208 208
 }
209 209
 
210 210
 
@@ -226,31 +226,31 @@  discard block
 block discarded – undo
226 226
 $discovered = 0;				//for mailing
227 227
 
228 228
 foreach($scan_subnets as $s) {
229
-	if(sizeof(@$s->discovered)>0) {
230
-		foreach($s->discovered as $ip) {
231
-			// fetch subnet
232
-			$subnet = $Subnets->fetch_subnet ("id", $s->id);
233
-			$nsid = $subnet===false ? false : $subnet->nameserverId;
234
-			// try to resolve hostname
235
-			$hostname = $DNS->resolve_address ($ip, false, true, $nsid);
236
-
237
-			//set update query
238
-			$values = array("subnetId"=>$s->id,
239
-							"ip_addr"=>$Subnets->transform_address($ip, "decimal"),
240
-							"dns_name"=>$hostname['name'],
241
-							"description"=>"-- autodiscovered --",
242
-							"note"=>"This host was autodiscovered on ".$nowdate,
243
-							"lastSeen"=>$nowdate,
244
-							"state"=>"2",
245
-							"action"=>"add"
246
-							);
247
-			//insert
248
-			$Addresses->modify_address($values);
249
-
250
-			//set discovered
251
-			$discovered++;
252
-		}
253
-	}
229
+    if(sizeof(@$s->discovered)>0) {
230
+        foreach($s->discovered as $ip) {
231
+            // fetch subnet
232
+            $subnet = $Subnets->fetch_subnet ("id", $s->id);
233
+            $nsid = $subnet===false ? false : $subnet->nameserverId;
234
+            // try to resolve hostname
235
+            $hostname = $DNS->resolve_address ($ip, false, true, $nsid);
236
+
237
+            //set update query
238
+            $values = array("subnetId"=>$s->id,
239
+                            "ip_addr"=>$Subnets->transform_address($ip, "decimal"),
240
+                            "dns_name"=>$hostname['name'],
241
+                            "description"=>"-- autodiscovered --",
242
+                            "note"=>"This host was autodiscovered on ".$nowdate,
243
+                            "lastSeen"=>$nowdate,
244
+                            "state"=>"2",
245
+                            "action"=>"add"
246
+                            );
247
+            //insert
248
+            $Addresses->modify_address($values);
249
+
250
+            //set discovered
251
+            $discovered++;
252
+        }
253
+    }
254 254
 }
255 255
 
256 256
 # update scan time
@@ -261,84 +261,84 @@  discard block
 block discarded – undo
261 261
 # send mail
262 262
 if($discovered>0 && $send_mail) {
263 263
 
264
-	# check for recipients
265
-	foreach($Admin->fetch_multiple_objects ("users", "role", "Administrator") as $admin) {
266
-		if($admin->mailNotify=="Yes") {
267
-			$recepients[] = array("name"=>$admin->real_name, "email"=>$admin->email);
268
-		}
269
-	}
270
-	# none?
271
-	if(!isset($recepients))	{ die(); }
272
-
273
-	# fetch mailer settings
274
-	$mail_settings = $Admin->fetch_object("settingsMail", "id", 1);
275
-	# fake user object, needed for create_link
276
-	$User = new StdClass();
277
-	@$User->settings->prettyLinks = $Scan->settings->prettyLinks;
278
-
279
-	# initialize mailer
280
-	$phpipam_mail = new phpipam_mail($Scan->settings, $mail_settings);
281
-	$phpipam_mail->initialize_mailer();
282
-
283
-
284
-
285
-	// set subject
286
-	$subject	= "phpIPAM new addresses detected ".date("Y-m-d H:i:s");
287
-
288
-	//html
289
-	$content[] = "<h3>phpIPAM found $discovered new hosts</h3>";
290
-	$content[] = "<table style='margin-left:10px;margin-top:5px;width:auto;padding:0px;border-collapse:collapse;border:1px solid gray;'>";
291
-	$content[] = "<tr>";
292
-	$content[] = "	<th style='padding:3px 8px;border:1px solid silver;border-bottom:2px solid gray;'>IP</th>";
293
-	$content[] = "	<th style='padding:3px 8px;border:1px solid silver;border-bottom:2px solid gray;'>Subnet</th>";
294
-	$content[] = "	<th style='padding:3px 8px;border:1px solid silver;border-bottom:2px solid gray;'>Section</th>";
295
-	$content[] = "</tr>";
296
-	//plain
297
-	$content_plain[] = "phpIPAM found $discovered new hosts\r\n------------------------------";
298
-	//Changes
299
-	foreach($scan_subnets as $s) {
300
-		if(sizeof(@$s->discovered)>0) {
301
-			foreach($s->discovered as $ip) {
302
-				//set subnet
303
-				$subnet 	 = $Subnets->fetch_subnet(null, $s->id);
304
-				//set section
305
-				$section 	 = $Admin->fetch_object("sections", "id", $s->sectionId);
306
-
307
-				$content[] = "<tr>";
308
-				$content[] = "	<td style='padding:3px 8px;border:1px solid silver;'>$ip</td>";
309
-				$content[] = "	<td style='padding:3px 8px;border:1px solid silver;'><a href='".rtrim($Scan->settings->siteURL, "/")."".create_link("subnets",$section->id,$subnet->id)."'>".$Subnets->transform_to_dotted($subnet->subnet)."/".$subnet->mask." - ".$subnet->description."</a></td>";
310
-				$content[] = "	<td style='padding:3px 8px;border:1px solid silver;'><a href='".rtrim($Scan->settings->siteURL, "/")."".create_link("subnets",$section->id)."'>$section->name $section->description</a></td>";
311
-				$content[] = "</tr>";
312
-
313
-				//plain content
314
-				$content_plain[] = "\t * $ip (".$Subnets->transform_to_dotted($subnet->subnet)."/".$subnet->mask.")";
315
-			}
316
-		}
317
-	}
318
-	$content[] = "</table>";
319
-
320
-
321
-	# set content
322
-	$content 		= $phpipam_mail->generate_message (implode("\r\n", $content));
323
-	$content_plain 	= implode("\r\n",$content_plain);
324
-
325
-	# try to send
326
-	try {
327
-		$phpipam_mail->Php_mailer->setFrom($mail_settings->mAdminMail, $mail_settings->mAdminName);
328
-		//add all admins to CC
329
-		foreach($recepients as $admin) {
330
-			$phpipam_mail->Php_mailer->addAddress(addslashes($admin['email']), addslashes($admin['name']));
331
-		}
332
-		$phpipam_mail->Php_mailer->Subject = $subject;
333
-		$phpipam_mail->Php_mailer->msgHTML($content);
334
-		$phpipam_mail->Php_mailer->AltBody = $content_plain;
335
-		//send
336
-		$phpipam_mail->Php_mailer->send();
337
-	} catch (phpmailerException $e) {
338
-		$Result->show_cli("Mailer Error: ".$e->errorMessage(), true);
339
-	} catch (Exception $e) {
340
-		$Result->show_cli("Mailer Error: ".$e->errorMessage(), true);
341
-	}
264
+    # check for recipients
265
+    foreach($Admin->fetch_multiple_objects ("users", "role", "Administrator") as $admin) {
266
+        if($admin->mailNotify=="Yes") {
267
+            $recepients[] = array("name"=>$admin->real_name, "email"=>$admin->email);
268
+        }
269
+    }
270
+    # none?
271
+    if(!isset($recepients))	{ die(); }
272
+
273
+    # fetch mailer settings
274
+    $mail_settings = $Admin->fetch_object("settingsMail", "id", 1);
275
+    # fake user object, needed for create_link
276
+    $User = new StdClass();
277
+    @$User->settings->prettyLinks = $Scan->settings->prettyLinks;
278
+
279
+    # initialize mailer
280
+    $phpipam_mail = new phpipam_mail($Scan->settings, $mail_settings);
281
+    $phpipam_mail->initialize_mailer();
282
+
283
+
284
+
285
+    // set subject
286
+    $subject	= "phpIPAM new addresses detected ".date("Y-m-d H:i:s");
287
+
288
+    //html
289
+    $content[] = "<h3>phpIPAM found $discovered new hosts</h3>";
290
+    $content[] = "<table style='margin-left:10px;margin-top:5px;width:auto;padding:0px;border-collapse:collapse;border:1px solid gray;'>";
291
+    $content[] = "<tr>";
292
+    $content[] = "	<th style='padding:3px 8px;border:1px solid silver;border-bottom:2px solid gray;'>IP</th>";
293
+    $content[] = "	<th style='padding:3px 8px;border:1px solid silver;border-bottom:2px solid gray;'>Subnet</th>";
294
+    $content[] = "	<th style='padding:3px 8px;border:1px solid silver;border-bottom:2px solid gray;'>Section</th>";
295
+    $content[] = "</tr>";
296
+    //plain
297
+    $content_plain[] = "phpIPAM found $discovered new hosts\r\n------------------------------";
298
+    //Changes
299
+    foreach($scan_subnets as $s) {
300
+        if(sizeof(@$s->discovered)>0) {
301
+            foreach($s->discovered as $ip) {
302
+                //set subnet
303
+                $subnet 	 = $Subnets->fetch_subnet(null, $s->id);
304
+                //set section
305
+                $section 	 = $Admin->fetch_object("sections", "id", $s->sectionId);
306
+
307
+                $content[] = "<tr>";
308
+                $content[] = "	<td style='padding:3px 8px;border:1px solid silver;'>$ip</td>";
309
+                $content[] = "	<td style='padding:3px 8px;border:1px solid silver;'><a href='".rtrim($Scan->settings->siteURL, "/")."".create_link("subnets",$section->id,$subnet->id)."'>".$Subnets->transform_to_dotted($subnet->subnet)."/".$subnet->mask." - ".$subnet->description."</a></td>";
310
+                $content[] = "	<td style='padding:3px 8px;border:1px solid silver;'><a href='".rtrim($Scan->settings->siteURL, "/")."".create_link("subnets",$section->id)."'>$section->name $section->description</a></td>";
311
+                $content[] = "</tr>";
312
+
313
+                //plain content
314
+                $content_plain[] = "\t * $ip (".$Subnets->transform_to_dotted($subnet->subnet)."/".$subnet->mask.")";
315
+            }
316
+        }
317
+    }
318
+    $content[] = "</table>";
319
+
320
+
321
+    # set content
322
+    $content 		= $phpipam_mail->generate_message (implode("\r\n", $content));
323
+    $content_plain 	= implode("\r\n",$content_plain);
324
+
325
+    # try to send
326
+    try {
327
+        $phpipam_mail->Php_mailer->setFrom($mail_settings->mAdminMail, $mail_settings->mAdminName);
328
+        //add all admins to CC
329
+        foreach($recepients as $admin) {
330
+            $phpipam_mail->Php_mailer->addAddress(addslashes($admin['email']), addslashes($admin['name']));
331
+        }
332
+        $phpipam_mail->Php_mailer->Subject = $subject;
333
+        $phpipam_mail->Php_mailer->msgHTML($content);
334
+        $phpipam_mail->Php_mailer->AltBody = $content_plain;
335
+        //send
336
+        $phpipam_mail->Php_mailer->send();
337
+    } catch (phpmailerException $e) {
338
+        $Result->show_cli("Mailer Error: ".$e->errorMessage(), true);
339
+    } catch (Exception $e) {
340
+        $Result->show_cli("Mailer Error: ".$e->errorMessage(), true);
341
+    }
342 342
 }
343 343
 
344 344
 ?>
Please login to merge, or discard this patch.
Spacing   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -24,60 +24,60 @@  discard block
 block discarded – undo
24 24
 
25 25
 
26 26
 # include required scripts
27
-require( dirname(__FILE__) . '/../functions.php' );
28
-require( dirname(__FILE__) . '/../../functions/classes/class.Thread.php');
27
+require(dirname (__FILE__).'/../functions.php');
28
+require(dirname (__FILE__).'/../../functions/classes/class.Thread.php');
29 29
 
30 30
 # initialize objects
31 31
 $Database 	= new Database_PDO;
32
-$Subnets	= new Subnets ($Database);
32
+$Subnets = new Subnets ($Database);
33 33
 $Addresses	= new Addresses ($Database);
34
-$Tools		= new Tools ($Database);
35
-$Scan		= new Scan ($Database);
36
-$DNS		= new DNS ($Database);
37
-$Result		= new Result();
34
+$Tools = new Tools ($Database);
35
+$Scan = new Scan ($Database);
36
+$DNS = new DNS ($Database);
37
+$Result = new Result ();
38 38
 
39 39
 // set exit flag to true
40
-$Scan->ping_set_exit(true);
40
+$Scan->ping_set_exit (true);
41 41
 // set debugging
42
-$Scan->reset_debugging(false);
42
+$Scan->reset_debugging (false);
43 43
 // change scan type?
44 44
 //$Scan->reset_scan_method ("pear");
45 45
 // set ping statuses
46
-$statuses = explode(";", $Scan->settings->pingStatus);
46
+$statuses = explode (";", $Scan->settings->pingStatus);
47 47
 // set mail override flag
48 48
 $send_mail = true;
49 49
 
50 50
 // set now for whole script
51
-$now     = time();
51
+$now     = time ();
52 52
 $nowdate = date ("Y-m-d H:i:s");
53 53
 
54 54
 
55 55
 // response for mailing
56
-$address_change = array();			// Array with differences, can be used to email to admins
56
+$address_change = array (); // Array with differences, can be used to email to admins
57 57
 
58 58
 
59 59
 // script can only be run from cli
60
-if(php_sapi_name()!="cli") 						{ die("This script can only be run from cli!"); }
60
+if (php_sapi_name () != "cli") { die("This script can only be run from cli!"); }
61 61
 // test to see if threading is available
62
-if(!Thread::available()) 						{ die("Threading is required for scanning subnets. Please recompile PHP with pcntl extension"); }
62
+if (!Thread::available ()) { die("Threading is required for scanning subnets. Please recompile PHP with pcntl extension"); }
63 63
 // verify ping path
64
-if ($Scan->icmp_type=="ping") {
65
-if(!file_exists($Scan->settings->scanPingPath)) { die("Invalid ping path!"); }
64
+if ($Scan->icmp_type == "ping") {
65
+if (!file_exists ($Scan->settings->scanPingPath)) { die("Invalid ping path!"); }
66 66
 }
67 67
 // verify fping path
68
-if ($Scan->icmp_type=="fping") {
69
-if(!file_exists($Scan->settings->scanFPingPath)){ die("Invalid fping path!"); }
68
+if ($Scan->icmp_type == "fping") {
69
+if (!file_exists ($Scan->settings->scanFPingPath)) { die("Invalid fping path!"); }
70 70
 }
71 71
 
72 72
 
73 73
 //first fetch all subnets to be scanned
74 74
 $scan_subnets = $Subnets->fetch_all_subnets_for_discoveryCheck (1);
75 75
 //set addresses
76
-if ($scan_subnets!==false) {
76
+if ($scan_subnets !== false) {
77 77
     // initial array
78
-    $addresses_tmp = array();
78
+    $addresses_tmp = array ();
79 79
     // loop
80
-    foreach($scan_subnets as $s) {
80
+    foreach ($scan_subnets as $s) {
81 81
     	// if subnet has slaves dont check it
82 82
     	if ($Subnets->has_slaves ($s->id) === false) {
83 83
     		$addresses_tmp[$s->id] = $Scan-> prepare_addresses_to_scan ("discovery", $s->id, false);
@@ -85,123 +85,123 @@  discard block
 block discarded – undo
85 85
     }
86 86
 
87 87
     //reindex
88
-    if(sizeof($addresses_tmp)>0) {
89
-        foreach($addresses_tmp as $s_id=>$a) {
90
-        	foreach($a as $ip) {
91
-        		$addresses[] = array("subnetId"=>$s_id, "ip_addr"=>$ip);
88
+    if (sizeof ($addresses_tmp) > 0) {
89
+        foreach ($addresses_tmp as $s_id=>$a) {
90
+        	foreach ($a as $ip) {
91
+        		$addresses[] = array ("subnetId"=>$s_id, "ip_addr"=>$ip);
92 92
         	}
93 93
         }
94 94
     }
95 95
 }
96 96
 
97 97
 
98
-if($Scan->debugging)							{ print_r($scan_subnets); }
99
-if($scan_subnets===false) 						{ die("No subnets are marked for new hosts checking"); }
98
+if ($Scan->debugging) { print_r ($scan_subnets); }
99
+if ($scan_subnets === false) { die("No subnets are marked for new hosts checking"); }
100 100
 
101 101
 
102 102
 //scan
103
-if($Scan->debugging)							{ print "Using $Scan->icmp_type\n--------------------\n\n"; }
103
+if ($Scan->debugging) { print "Using $Scan->icmp_type\n--------------------\n\n"; }
104 104
 
105 105
 
106
-$z = 0;			//addresses array index
106
+$z = 0; //addresses array index
107 107
 
108
-$size_subnets = max(array_keys($scan_subnets));
109
-$size_addresses = max(array_keys($addresses));
108
+$size_subnets = max (array_keys ($scan_subnets));
109
+$size_addresses = max (array_keys ($addresses));
110 110
 
111 111
 //different scan for fping
112
-if($Scan->icmp_type=="fping") {
112
+if ($Scan->icmp_type == "fping") {
113 113
 	//run per MAX_THREADS
114
-	for ($m=0; $m<=$size_subnets; $m += $Scan->settings->scanMaxThreads) {
114
+	for ($m = 0; $m <= $size_subnets; $m += $Scan->settings->scanMaxThreads) {
115 115
 	    // create threads
116
-	    $threads = array();
116
+	    $threads = array ();
117 117
 	    //fork processes
118 118
 	    for ($i = 0; $i <= $Scan->settings->scanMaxThreads && $i <= $size_subnets; $i++) {
119 119
 	    	//only if index exists!
120
-	    	if(isset($scan_subnets[$z])) {
120
+	    	if (isset($scan_subnets[$z])) {
121 121
 				//start new thread
122
-	            $threads[$z] = new Thread( 'fping_subnet' );
123
-				$threads[$z]->start_fping( $Subnets->transform_to_dotted($scan_subnets[$z]->subnet)."/".$scan_subnets[$z]->mask );
124
-	            $z++;				//next index
122
+	            $threads[$z] = new Thread ('fping_subnet');
123
+				$threads[$z]->start_fping ($Subnets->transform_to_dotted ($scan_subnets[$z]->subnet)."/".$scan_subnets[$z]->mask);
124
+	            $z++; //next index
125 125
 			}
126 126
 	    }
127 127
 	    // wait for all the threads to finish
128
-	    while( !empty( $threads ) ) {
129
-			foreach($threads as $index => $thread) {
130
-				$child_pipe = "/tmp/pipe_".$thread->getPid();
128
+	    while (!empty($threads)) {
129
+			foreach ($threads as $index => $thread) {
130
+				$child_pipe = "/tmp/pipe_".$thread->getPid ();
131 131
 
132
-				if (file_exists($child_pipe)) {
133
-					$file_descriptor = fopen( $child_pipe, "r");
132
+				if (file_exists ($child_pipe)) {
133
+					$file_descriptor = fopen ($child_pipe, "r");
134 134
 					$child_response = "";
135
-					while (!feof($file_descriptor)) {
136
-						$child_response .= fread($file_descriptor, 8192);
135
+					while (!feof ($file_descriptor)) {
136
+						$child_response .= fread ($file_descriptor, 8192);
137 137
 					}
138 138
 					//we have the child data in the parent, but serialized:
139
-					$child_response = unserialize( $child_response );
139
+					$child_response = unserialize ($child_response);
140 140
 					//store
141 141
 					$scan_subnets[$index]->discovered = $child_response;
142 142
 					//now, child is dead, and parent close the pipe
143
-					unlink( $child_pipe );
143
+					unlink ($child_pipe);
144 144
 					unset($threads[$index]);
145 145
 				}
146 146
 			}
147
-	        usleep(200000);
147
+	        usleep (200000);
148 148
 	    }
149 149
 	}
150 150
 
151 151
 	//fping finds all subnet addresses, we must remove existing ones !
152
-	foreach($scan_subnets as $sk=>$s) {
153
-    	if(isset($s->discovered)) {
154
-    		foreach($s->discovered as $rk=>$result) {
155
-    			if(!in_array($Subnets->transform_to_decimal($result), $addresses_tmp[$s->id])) {
152
+	foreach ($scan_subnets as $sk=>$s) {
153
+    	if (isset($s->discovered)) {
154
+    		foreach ($s->discovered as $rk=>$result) {
155
+    			if (!in_array ($Subnets->transform_to_decimal ($result), $addresses_tmp[$s->id])) {
156 156
     				unset($scan_subnets[$sk]->discovered[$rk]);
157 157
     			}
158 158
     		}
159 159
             //rekey
160
-            $scan_subnets[$sk]->discovered = array_values($scan_subnets[$sk]->discovered);
160
+            $scan_subnets[$sk]->discovered = array_values ($scan_subnets[$sk]->discovered);
161 161
 		}
162 162
 	}
163 163
 }
164 164
 //ping, pear
165 165
 else {
166 166
 	//run per MAX_THREADS
167
-    for ($m=0; $m<=$size_addresses; $m += $Scan->settings->scanMaxThreads) {
167
+    for ($m = 0; $m <= $size_addresses; $m += $Scan->settings->scanMaxThreads) {
168 168
         // create threads
169
-        $threads = array();
169
+        $threads = array ();
170 170
 
171 171
         //fork processes
172 172
         for ($i = 0; $i <= $Scan->settings->scanMaxThreads && $i <= $size_addresses; $i++) {
173 173
         	//only if index exists!
174
-        	if(isset($addresses[$z])) {
174
+        	if (isset($addresses[$z])) {
175 175
 				//start new thread
176
-	            $threads[$z] = new Thread( 'ping_address' );
177
-	            $threads[$z]->start( $Subnets->transform_to_dotted($addresses[$z]['ip_addr']) );
178
-				$z++;			//next index
176
+	            $threads[$z] = new Thread ('ping_address');
177
+	            $threads[$z]->start ($Subnets->transform_to_dotted ($addresses[$z]['ip_addr']));
178
+				$z++; //next index
179 179
 			}
180 180
         }
181 181
 
182 182
         // wait for all the threads to finish
183
-        while( !empty( $threads ) ) {
184
-            foreach( $threads as $index => $thread ) {
185
-                if( ! $thread->isAlive() ) {
183
+        while (!empty($threads)) {
184
+            foreach ($threads as $index => $thread) {
185
+                if (!$thread->isAlive ()) {
186 186
 					//unset dead hosts
187
-					if($thread->getExitCode() != 0) {
187
+					if ($thread->getExitCode () != 0) {
188 188
 						unset($addresses[$index]);
189 189
 					}
190 190
                     //remove thread
191
-                    unset( $threads[$index]);
191
+                    unset($threads[$index]);
192 192
                 }
193 193
             }
194
-            usleep(200000);
194
+            usleep (200000);
195 195
         }
196 196
 	}
197 197
 
198 198
 	//ok, we have all available addresses, rekey them
199
-	foreach($addresses as $a) {
200
-		$add_tmp[$a['subnetId']][] = $Subnets->transform_to_dotted($a['ip_addr']);
199
+	foreach ($addresses as $a) {
200
+		$add_tmp[$a['subnetId']][] = $Subnets->transform_to_dotted ($a['ip_addr']);
201 201
 	}
202 202
 	//add to scan_subnets as result
203
-	foreach($scan_subnets as $sk=>$s) {
204
-		if(isset($add_tmp[$s->id])) {
203
+	foreach ($scan_subnets as $sk=>$s) {
204
+		if (isset($add_tmp[$s->id])) {
205 205
 			$scan_subnets[$sk]->discovered = $add_tmp[$s->id];
206 206
 		}
207 207
 	}
@@ -209,34 +209,34 @@  discard block
 block discarded – undo
209 209
 
210 210
 
211 211
 # print change
212
-if($Scan->debugging)							{ "\nDiscovered addresses:\n----------\n"; print_r($scan_subnets); }
212
+if ($Scan->debugging) { "\nDiscovered addresses:\n----------\n"; print_r ($scan_subnets); }
213 213
 
214 214
 
215 215
 
216 216
 # reinitialize objects
217 217
 $Database 	= new Database_PDO;
218
-$Admin		= new Admin ($Database, false);
218
+$Admin = new Admin ($Database, false);
219 219
 $Addresses	= new Addresses ($Database);
220 220
 $Subnets	= new Subnets ($Database);
221
-$DNS		= new DNS ($Database);
222
-$Scan		= new Scan ($Database);
223
-$Result		= new Result();
221
+$DNS = new DNS ($Database);
222
+$Scan = new Scan ($Database);
223
+$Result		= new Result ();
224 224
 
225 225
 # insert to database
226
-$discovered = 0;				//for mailing
226
+$discovered = 0; //for mailing
227 227
 
228
-foreach($scan_subnets as $s) {
229
-	if(sizeof(@$s->discovered)>0) {
230
-		foreach($s->discovered as $ip) {
228
+foreach ($scan_subnets as $s) {
229
+	if (sizeof (@$s->discovered) > 0) {
230
+		foreach ($s->discovered as $ip) {
231 231
 			// fetch subnet
232 232
 			$subnet = $Subnets->fetch_subnet ("id", $s->id);
233
-			$nsid = $subnet===false ? false : $subnet->nameserverId;
233
+			$nsid = $subnet === false ? false : $subnet->nameserverId;
234 234
 			// try to resolve hostname
235 235
 			$hostname = $DNS->resolve_address ($ip, false, true, $nsid);
236 236
 
237 237
 			//set update query
238
-			$values = array("subnetId"=>$s->id,
239
-							"ip_addr"=>$Subnets->transform_address($ip, "decimal"),
238
+			$values = array ("subnetId"=>$s->id,
239
+							"ip_addr"=>$Subnets->transform_address ($ip, "decimal"),
240 240
 							"dns_name"=>$hostname['name'],
241 241
 							"description"=>"-- autodiscovered --",
242 242
 							"note"=>"This host was autodiscovered on ".$nowdate,
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 							"action"=>"add"
246 246
 							);
247 247
 			//insert
248
-			$Addresses->modify_address($values);
248
+			$Addresses->modify_address ($values);
249 249
 
250 250
 			//set discovered
251 251
 			$discovered++;
@@ -259,31 +259,31 @@  discard block
 block discarded – undo
259 259
 
260 260
 
261 261
 # send mail
262
-if($discovered>0 && $send_mail) {
262
+if ($discovered > 0 && $send_mail) {
263 263
 
264 264
 	# check for recipients
265
-	foreach($Admin->fetch_multiple_objects ("users", "role", "Administrator") as $admin) {
266
-		if($admin->mailNotify=="Yes") {
267
-			$recepients[] = array("name"=>$admin->real_name, "email"=>$admin->email);
265
+	foreach ($Admin->fetch_multiple_objects ("users", "role", "Administrator") as $admin) {
266
+		if ($admin->mailNotify == "Yes") {
267
+			$recepients[] = array ("name"=>$admin->real_name, "email"=>$admin->email);
268 268
 		}
269 269
 	}
270 270
 	# none?
271
-	if(!isset($recepients))	{ die(); }
271
+	if (!isset($recepients)) { die(); }
272 272
 
273 273
 	# fetch mailer settings
274
-	$mail_settings = $Admin->fetch_object("settingsMail", "id", 1);
274
+	$mail_settings = $Admin->fetch_object ("settingsMail", "id", 1);
275 275
 	# fake user object, needed for create_link
276
-	$User = new StdClass();
276
+	$User = new StdClass ();
277 277
 	@$User->settings->prettyLinks = $Scan->settings->prettyLinks;
278 278
 
279 279
 	# initialize mailer
280
-	$phpipam_mail = new phpipam_mail($Scan->settings, $mail_settings);
281
-	$phpipam_mail->initialize_mailer();
280
+	$phpipam_mail = new phpipam_mail ($Scan->settings, $mail_settings);
281
+	$phpipam_mail->initialize_mailer ();
282 282
 
283 283
 
284 284
 
285 285
 	// set subject
286
-	$subject	= "phpIPAM new addresses detected ".date("Y-m-d H:i:s");
286
+	$subject = "phpIPAM new addresses detected ".date ("Y-m-d H:i:s");
287 287
 
288 288
 	//html
289 289
 	$content[] = "<h3>phpIPAM found $discovered new hosts</h3>";
@@ -296,22 +296,22 @@  discard block
 block discarded – undo
296 296
 	//plain
297 297
 	$content_plain[] = "phpIPAM found $discovered new hosts\r\n------------------------------";
298 298
 	//Changes
299
-	foreach($scan_subnets as $s) {
300
-		if(sizeof(@$s->discovered)>0) {
301
-			foreach($s->discovered as $ip) {
299
+	foreach ($scan_subnets as $s) {
300
+		if (sizeof (@$s->discovered) > 0) {
301
+			foreach ($s->discovered as $ip) {
302 302
 				//set subnet
303
-				$subnet 	 = $Subnets->fetch_subnet(null, $s->id);
303
+				$subnet = $Subnets->fetch_subnet (null, $s->id);
304 304
 				//set section
305
-				$section 	 = $Admin->fetch_object("sections", "id", $s->sectionId);
305
+				$section 	 = $Admin->fetch_object ("sections", "id", $s->sectionId);
306 306
 
307 307
 				$content[] = "<tr>";
308 308
 				$content[] = "	<td style='padding:3px 8px;border:1px solid silver;'>$ip</td>";
309
-				$content[] = "	<td style='padding:3px 8px;border:1px solid silver;'><a href='".rtrim($Scan->settings->siteURL, "/")."".create_link("subnets",$section->id,$subnet->id)."'>".$Subnets->transform_to_dotted($subnet->subnet)."/".$subnet->mask." - ".$subnet->description."</a></td>";
310
-				$content[] = "	<td style='padding:3px 8px;border:1px solid silver;'><a href='".rtrim($Scan->settings->siteURL, "/")."".create_link("subnets",$section->id)."'>$section->name $section->description</a></td>";
309
+				$content[] = "	<td style='padding:3px 8px;border:1px solid silver;'><a href='".rtrim ($Scan->settings->siteURL, "/")."".create_link ("subnets", $section->id, $subnet->id)."'>".$Subnets->transform_to_dotted ($subnet->subnet)."/".$subnet->mask." - ".$subnet->description."</a></td>";
310
+				$content[] = "	<td style='padding:3px 8px;border:1px solid silver;'><a href='".rtrim ($Scan->settings->siteURL, "/")."".create_link ("subnets", $section->id)."'>$section->name $section->description</a></td>";
311 311
 				$content[] = "</tr>";
312 312
 
313 313
 				//plain content
314
-				$content_plain[] = "\t * $ip (".$Subnets->transform_to_dotted($subnet->subnet)."/".$subnet->mask.")";
314
+				$content_plain[] = "\t * $ip (".$Subnets->transform_to_dotted ($subnet->subnet)."/".$subnet->mask.")";
315 315
 			}
316 316
 		}
317 317
 	}
@@ -319,25 +319,25 @@  discard block
 block discarded – undo
319 319
 
320 320
 
321 321
 	# set content
322
-	$content 		= $phpipam_mail->generate_message (implode("\r\n", $content));
323
-	$content_plain 	= implode("\r\n",$content_plain);
322
+	$content = $phpipam_mail->generate_message (implode ("\r\n", $content));
323
+	$content_plain = implode ("\r\n", $content_plain);
324 324
 
325 325
 	# try to send
326 326
 	try {
327
-		$phpipam_mail->Php_mailer->setFrom($mail_settings->mAdminMail, $mail_settings->mAdminName);
327
+		$phpipam_mail->Php_mailer->setFrom ($mail_settings->mAdminMail, $mail_settings->mAdminName);
328 328
 		//add all admins to CC
329
-		foreach($recepients as $admin) {
330
-			$phpipam_mail->Php_mailer->addAddress(addslashes($admin['email']), addslashes($admin['name']));
329
+		foreach ($recepients as $admin) {
330
+			$phpipam_mail->Php_mailer->addAddress (addslashes ($admin['email']), addslashes ($admin['name']));
331 331
 		}
332 332
 		$phpipam_mail->Php_mailer->Subject = $subject;
333
-		$phpipam_mail->Php_mailer->msgHTML($content);
333
+		$phpipam_mail->Php_mailer->msgHTML ($content);
334 334
 		$phpipam_mail->Php_mailer->AltBody = $content_plain;
335 335
 		//send
336
-		$phpipam_mail->Php_mailer->send();
336
+		$phpipam_mail->Php_mailer->send ();
337 337
 	} catch (phpmailerException $e) {
338
-		$Result->show_cli("Mailer Error: ".$e->errorMessage(), true);
338
+		$Result->show_cli ("Mailer Error: ".$e->errorMessage (), true);
339 339
 	} catch (Exception $e) {
340
-		$Result->show_cli("Mailer Error: ".$e->errorMessage(), true);
340
+		$Result->show_cli ("Mailer Error: ".$e->errorMessage (), true);
341 341
 	}
342 342
 }
343 343
 
Please login to merge, or discard this patch.
config.dist.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -70,9 +70,9 @@
 block discarded – undo
70 70
 elseif ($proxy_enabled == true && proxy_use_auth == true) {
71 71
     stream_context_set_default(
72 72
         array('http' => array(
73
-              'proxy' => "tcp://$proxy_server:$proxy_port",
74
-              'request_fulluri' => true,
75
-              'header' => "Proxy-Authorization: Basic $proxy_auth"
73
+                'proxy' => "tcp://$proxy_server:$proxy_port",
74
+                'request_fulluri' => true,
75
+                'header' => "Proxy-Authorization: Basic $proxy_auth"
76 76
         )));
77 77
 }
78 78
 
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@  discard block
 block discarded – undo
18 18
 
19 19
      php 5.3.7 required
20 20
 */
21
-$db['ssl']        = false;                           # true/false, enable or disable SSL as a whole
22
-$db['ssl_key']    = "/path/to/cert.key";             # path to an SSL key file. Only makes sense combined with ssl_cert
23
-$db['ssl_cert']   = "/path/to/cert.crt";             # path to an SSL certificate file. Only makes sense combined with ssl_key
24
-$db['ssl_ca']     = "/path/to/ca.crt";               # path to a file containing SSL CA certs
25
-$db['ssl_capath'] = "/path/to/ca_certs";             # path to a directory containing CA certs
21
+$db['ssl']        = false; # true/false, enable or disable SSL as a whole
22
+$db['ssl_key']    = "/path/to/cert.key"; # path to an SSL key file. Only makes sense combined with ssl_cert
23
+$db['ssl_cert']   = "/path/to/cert.crt"; # path to an SSL certificate file. Only makes sense combined with ssl_key
24
+$db['ssl_ca']     = "/path/to/ca.crt"; # path to a file containing SSL CA certs
25
+$db['ssl_capath'] = "/path/to/ca_certs"; # path to a directory containing CA certs
26 26
 $db['ssl_cipher'] = "DHE-RSA-AES256-SHA:AES128-SHA"; # one or more SSL Ciphers
27 27
 
28 28
 /**
@@ -47,36 +47,36 @@  discard block
 block discarded – undo
47 47
  *  Also change
48 48
  *	RewriteBase / in .htaccess
49 49
  ******************************/
50
-if(!defined('BASE'))
51
-define('BASE', "/");
50
+if (!defined ('BASE'))
51
+define ('BASE', "/");
52 52
 
53 53
 /**
54 54
  * Multicast unique mac requirement - section or vlan
55 55
  */
56
-if(!defined('MCUNIQUE'))
57
-define('MCUNIQUE', "section");
56
+if (!defined ('MCUNIQUE'))
57
+define ('MCUNIQUE', "section");
58 58
 
59 59
 
60 60
 /*  proxy connection details
61 61
  ******************************/
62
-$proxy_enabled  = false;                                  # Enable/Disable usage of the Proxy server
63
-$proxy_server   = "myproxy.something.com";                # Proxy server FQDN or IP
64
-$proxy_port     = "8080";                                 # Proxy server port
65
-$proxy_user     = "USERNAME";                             # Proxy Username
66
-$proxy_pass     = "PASSWORD";                             # Proxy Password
67
-$proxy_use_auth = false;                                  # Enable/Disable Proxy authentication
62
+$proxy_enabled  = false; # Enable/Disable usage of the Proxy server
63
+$proxy_server   = "myproxy.something.com"; # Proxy server FQDN or IP
64
+$proxy_port     = "8080"; # Proxy server port
65
+$proxy_user     = "USERNAME"; # Proxy Username
66
+$proxy_pass     = "PASSWORD"; # Proxy Password
67
+$proxy_use_auth = false; # Enable/Disable Proxy authentication
68 68
 
69 69
 /**
70 70
  * proxy to use for every internet access like update check
71 71
  */
72
-$proxy_auth     = base64_encode("$proxy_user:$proxy_pass");
72
+$proxy_auth = base64_encode ("$proxy_user:$proxy_pass");
73 73
 
74 74
 if ($proxy_enabled == true && $proxy_use_auth == false) {
75
-    stream_context_set_default(array('http' => array('proxy'=>'tcp://'.$proxy_server.':'.$proxy_port)));
75
+    stream_context_set_default (array ('http' => array ('proxy'=>'tcp://'.$proxy_server.':'.$proxy_port)));
76 76
 }
77 77
 elseif ($proxy_enabled == true && $proxy_use_auth == true) {
78
-    stream_context_set_default(
79
-        array('http' => array(
78
+    stream_context_set_default (
79
+        array ('http' => array (
80 80
               'proxy' => "tcp://$proxy_server:$proxy_port",
81 81
               'request_fulluri' => true,
82 82
               'header' => "Proxy-Authorization: Basic $proxy_auth"
Please login to merge, or discard this patch.
functions/checks/check_php_build.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
 # check for PEAR functions
44 44
 if ((@include_once 'PEAR.php') != true) {
45
-	$missingExt[] = "php PEAR support";
45
+    $missingExt[] = "php PEAR support";
46 46
 }
47 47
 
48 48
 # if db ssl = true check version
@@ -63,14 +63,14 @@  discard block
 block discarded – undo
63 63
     $error  .= "<head>";
64 64
     $error  .= "<base href='$url' />";
65 65
     $error  .= '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap.min.css">';
66
-	$error  .= '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-custom.css">';
67
-	$error  .= "</head>";
66
+    $error  .= '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-custom.css">';
67
+    $error  .= "</head>";
68 68
     $error  .= "<body style='margin:0px;'>";
69
-	$error  .= '<div class="row header-install" id="header"><div class="col-xs-12">';
70
-	$error  .= '<div class="hero-unit" style="padding:20px;margin-bottom:10px;">';
71
-	$error  .= '<a href="'.create_link(null,null,null,null,null,true).'">phpipam requirements error</a>';
72
-	$error  .= '</div>';
73
-	$error  .= '</div></div>';
69
+    $error  .= '<div class="row header-install" id="header"><div class="col-xs-12">';
70
+    $error  .= '<div class="hero-unit" style="padding:20px;margin-bottom:10px;">';
71
+    $error  .= '<a href="'.create_link(null,null,null,null,null,true).'">phpipam requirements error</a>';
72
+    $error  .= '</div>';
73
+    $error  .= '</div></div>';
74 74
 
75 75
     /* error */
76 76
     $error  .= "<div class='alert alert-danger' style='margin:auto;margin-top:20px;width:500px;'><strong>"._('The following required PHP extensions are missing').":</strong><br><hr>";
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -17,25 +17,25 @@  discard block
 block discarded – undo
17 17
 
18 18
 
19 19
 # Required extensions
20
-$requiredExt  = array("session", "sockets", "filter", "openssl", "gmp", "json", "gettext", "PDO", "pdo_mysql");
20
+$requiredExt  = array ("session", "sockets", "filter", "openssl", "gmp", "json", "gettext", "PDO", "pdo_mysql");
21 21
 
22 22
 # Available extensions
23
-$availableExt = get_loaded_extensions();
23
+$availableExt = get_loaded_extensions ();
24 24
 
25 25
 # Empty missing array to prevent errors
26 26
 $missingExt[0] = "";
27 27
 
28 28
 # if not all are present create array of missing ones
29 29
 foreach ($requiredExt as $extension) {
30
-    if (!in_array($extension, $availableExt)) {
30
+    if (!in_array ($extension, $availableExt)) {
31 31
         $missingExt[] = $extension;
32 32
     }
33 33
 }
34 34
 
35 35
 # check if mod_rewrite is enabled in apache
36
-if (function_exists("apache_get_modules")) {
37
-    $modules = apache_get_modules();
38
-    if(!in_array("mod_rewrite", $modules)) {
36
+if (function_exists ("apache_get_modules")) {
37
+    $modules = apache_get_modules ();
38
+    if (!in_array ("mod_rewrite", $modules)) {
39 39
         $missingExt[] = "mod_rewrite (Apache module)";
40 40
     }
41 41
 }
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
 }
47 47
 
48 48
 # if db ssl = true check version
49
-if (@$db['ssl']==true) {
50
-    if (phpversion() < "5.3.7") {
49
+if (@$db['ssl'] == true) {
50
+    if (phpversion () < "5.3.7") {
51 51
         $missingExt[] = "For SSL MySQL php version 5.3.7 is required!";
52 52
     }
53 53
 }
54 54
 
55 55
 # if any extension is missing print error and die!
56
-if (sizeof($missingExt) != 1) {
56
+if (sizeof ($missingExt) != 1) {
57 57
 
58 58
     /* remove dummy 0 line */
59 59
     unset($missingExt[0]);
@@ -68,18 +68,18 @@  discard block
 block discarded – undo
68 68
     $error  .= "<body style='margin:0px;'>";
69 69
 	$error  .= '<div class="row header-install" id="header"><div class="col-xs-12">';
70 70
 	$error  .= '<div class="hero-unit" style="padding:20px;margin-bottom:10px;">';
71
-	$error  .= '<a href="'.create_link(null,null,null,null,null,true).'">phpipam requirements error</a>';
71
+	$error  .= '<a href="'.create_link (null, null, null, null, null, true).'">phpipam requirements error</a>';
72 72
 	$error  .= '</div>';
73 73
 	$error  .= '</div></div>';
74 74
 
75 75
     /* error */
76
-    $error  .= "<div class='alert alert-danger' style='margin:auto;margin-top:20px;width:500px;'><strong>"._('The following required PHP extensions are missing').":</strong><br><hr>";
77
-    $error  .= '<ul>' . "\n";
76
+    $error  .= "<div class='alert alert-danger' style='margin:auto;margin-top:20px;width:500px;'><strong>"._ ('The following required PHP extensions are missing').":</strong><br><hr>";
77
+    $error  .= '<ul>'."\n";
78 78
     foreach ($missingExt as $missing) {
79
-        $error .= '<li>'. $missing .'</li>' . "\n";
79
+        $error .= '<li>'.$missing.'</li>'."\n";
80 80
     }
81
-    $error  .= '</ul><hr>' . "\n";
82
-    $error  .= _('Please recompile PHP to include missing extensions and restart Apache.') . "\n";
81
+    $error  .= '</ul><hr>'."\n";
82
+    $error  .= _ ('Please recompile PHP to include missing extensions and restart Apache.')."\n";
83 83
 
84 84
     $error  .= "</body>";
85 85
     $error  .= "</html>";
Please login to merge, or discard this patch.
functions/classes/class.Radius.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -571,8 +571,8 @@
 block discarded – undo
571 571
     {
572 572
         if ($this->_debug_mode)
573 573
         {
574
-	        //save debugging
575
-	        $this->debug_text[] = date('Y-m-d H:i:s').' DEBUG: '.$debug_info;
574
+            //save debugging
575
+            $this->debug_text[] = date('Y-m-d H:i:s').' DEBUG: '.$debug_info;
576 576
         }
577 577
     }
578 578
 
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.Thread.php 2 patches
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -11,47 +11,47 @@  discard block
 block discarded – undo
11 11
     const FUNCTION_NOT_CALLABLE = 10;
12 12
     const COULD_NOT_FORK = 15;
13 13
 
14
-	/**
15
-	* possible errors
16
-	*
17
-	* @var array
18
-	*/
14
+    /**
15
+     * possible errors
16
+     *
17
+     * @var array
18
+     */
19 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
     );
23 23
 
24
-	/**
25
-	* callback for the function that should
26
-	* run as a separate thread
27
-	*
28
-	* @var callback
29
-	*/
24
+    /**
25
+     * callback for the function that should
26
+     * run as a separate thread
27
+     *
28
+     * @var callback
29
+     */
30 30
     protected $runnable;
31 31
 
32
-	/**
33
-	* holds the current process id
34
-	*
35
-	* @var integer
36
-	*/
32
+    /**
33
+     * holds the current process id
34
+     *
35
+     * @var integer
36
+     */
37 37
     private $pid;
38 38
 
39
-	/**
40
-	* holds the exit code after the child dies
41
-	*/
39
+    /**
40
+     * holds the exit code after the child dies
41
+     */
42 42
     private $exitCode = -1;
43 43
 
44 44
     /**
45
-	* holds type - needed for fping
46
-	*/
47
-	public $stype = "ping";
45
+     * holds type - needed for fping
46
+     */
47
+    public $stype = "ping";
48 48
 
49
-	/**
50
-	* checks if threading is supported by the current
51
-	* PHP configuration
52
-	*
53
-	* @return boolean
54
-	*/
49
+    /**
50
+     * checks if threading is supported by the current
51
+     * PHP configuration
52
+     *
53
+     * @return boolean
54
+     */
55 55
     public static function available() {
56 56
         $required_functions = array(
57 57
             'pcntl_fork',
@@ -66,24 +66,24 @@  discard block
 block discarded – undo
66 66
         return true;
67 67
     }
68 68
 
69
-	/**
70
-	* class constructor - you can pass
71
-	* the callback function as an argument
72
-	*
73
-	* @param callback $_runnable
74
-	*/
69
+    /**
70
+     * class constructor - you can pass
71
+     * the callback function as an argument
72
+     *
73
+     * @param callback $_runnable
74
+     */
75 75
     public function __construct( $_runnable = null ) {
76
-		if( $_runnable !== null ) {
77
-			$this->setRunnable( $_runnable );
78
-		}
76
+        if( $_runnable !== null ) {
77
+            $this->setRunnable( $_runnable );
78
+        }
79 79
     }
80 80
 
81
-	/**
82
-	* sets the callback
83
-	*
84
-	* @param callback $_runnable
85
-	* @return callback
86
-	*/
81
+    /**
82
+     * sets the callback
83
+     *
84
+     * @param callback $_runnable
85
+     * @return callback
86
+     */
87 87
     public function setRunnable( $_runnable ) {
88 88
         if( self::runnableOk( $_runnable ) ) {
89 89
             $this->runnable = $_runnable;
@@ -93,43 +93,43 @@  discard block
 block discarded – undo
93 93
         }
94 94
     }
95 95
 
96
-	/**
97
-	* gets the callback
98
-	*
99
-	* @return callback
100
-	*/
96
+    /**
97
+     * gets the callback
98
+     *
99
+     * @return callback
100
+     */
101 101
     public function getRunnable() {
102 102
         return $this->runnable;
103 103
     }
104 104
 
105
-	/**
106
-	* checks if the callback is ok (the function/method
107
-	* actually exists and is runnable from the current
108
-	* context)
109
-	*
110
-	* can be called statically
111
-	*
112
-	* @param callback $_runnable
113
-	* @return boolean
114
-	*/
105
+    /**
106
+     * checks if the callback is ok (the function/method
107
+     * actually exists and is runnable from the current
108
+     * context)
109
+     *
110
+     * can be called statically
111
+     *
112
+     * @param callback $_runnable
113
+     * @return boolean
114
+     */
115 115
     public static function runnableOk( $_runnable ) {
116 116
         return ( function_exists( $_runnable ) && is_callable( $_runnable ) );
117 117
     }
118 118
 
119
-	/**
120
-	* returns the process id (pid) of the simulated thread
121
-	*
122
-	* @return int
123
-	*/
119
+    /**
120
+     * returns the process id (pid) of the simulated thread
121
+     *
122
+     * @return int
123
+     */
124 124
     public function getPid() {
125 125
         return $this->pid;
126 126
     }
127 127
 
128
-	/**
129
-	* checks if the child thread is alive
130
-	*
131
-	* @return boolean
132
-	*/
128
+    /**
129
+     * checks if the child thread is alive
130
+     *
131
+     * @return boolean
132
+     */
133 133
     public function isAlive() {
134 134
         $pid = pcntl_waitpid( $this->pid, $status, WNOHANG );
135 135
 
@@ -143,22 +143,22 @@  discard block
 block discarded – undo
143 143
         }
144 144
     }
145 145
 
146
-	/**
147
-	* return exit code of child (-1 if child is still alive)
148
-	*
149
-	* @return int
150
-	*/
146
+    /**
147
+     * return exit code of child (-1 if child is still alive)
148
+     *
149
+     * @return int
150
+     */
151 151
     public function getExitCode() {
152 152
         $this->isAlive();
153 153
         return $this->exitCode;
154 154
     }
155 155
 
156
-	/**
157
-	* starts the thread, all the parameters are
158
-	* passed to the callback function
159
-	*
160
-	* @return void
161
-	*/
156
+    /**
157
+     * starts the thread, all the parameters are
158
+     * passed to the callback function
159
+     *
160
+     * @return void
161
+     */
162 162
     public function start() {
163 163
         $pid = @ pcntl_fork();
164 164
         if( $pid == -1 ) {
@@ -183,59 +183,59 @@  discard block
 block discarded – undo
183 183
         }
184 184
     }
185 185
 
186
-	/**
187
-	* starts the thread, all the parameters are
188
-	* passed to the callback function
189
-	*
190
-	*	modification for fping threading for cron scanning
191
-	*
192
-	* @return void
193
-	*/
186
+    /**
187
+     * starts the thread, all the parameters are
188
+     * passed to the callback function
189
+     *
190
+     *	modification for fping threading for cron scanning
191
+     *
192
+     * @return void
193
+     */
194 194
     public function start_fping() {
195
-		$status = 0;
196
-		$results = null;
197
-		$pid = pcntl_fork();
195
+        $status = 0;
196
+        $results = null;
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
202
-			$this->pid = $pid;
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
+            $this->pid = $pid;
203 203
 
204
-		} else { // child
205
-			$this->pid = posix_getpid();//pid (child)
206
-			$this->ppid = posix_getppid();//pid (parent)
204
+        } else { // child
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 );
214
-			}
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
+            }
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);
221
-			}
222
-			//we have to open the pipe and send the data serialized
223
-			$pipe_descriptor = fopen($pipe, 'w');
224
-			fwrite($pipe_descriptor, serialize( $results ) );
218
+            if(!file_exists($pipe)) {//child talks to parent using this pipe
219
+                umask(0);
220
+                posix_mkfifo($pipe, 0600);
221
+            }
222
+            //we have to open the pipe and send the data serialized
223
+            $pipe_descriptor = fopen($pipe, 'w');
224
+            fwrite($pipe_descriptor, serialize( $results ) );
225 225
 
226
-			//and kill the child using posix_kill ( exit(0) duplicates headers!! )
227
-			posix_kill( $this->pid , SIGKILL);
228
-			exit(0);
229
-		}
226
+            //and kill the child using posix_kill ( exit(0) duplicates headers!! )
227
+            posix_kill( $this->pid , SIGKILL);
228
+            exit(0);
229
+        }
230 230
     }
231 231
 
232
-	/**
233
-	* attempts to stop the thread
234
-	* returns true on success and false otherwise
235
-	*
236
-	* @param integer $_signal - SIGKILL/SIGTERM
237
-	* @param boolean $_wait
238
-	*/
232
+    /**
233
+     * attempts to stop the thread
234
+     * returns true on success and false otherwise
235
+     *
236
+     * @param integer $_signal - SIGKILL/SIGTERM
237
+     * @param boolean $_wait
238
+     */
239 239
     public function stop( $_signal = SIGKILL, $_wait = false ) {
240 240
         if( $this->isAlive() ) {
241 241
             posix_kill( $this->pid, $_signal );
@@ -245,22 +245,22 @@  discard block
 block discarded – undo
245 245
         }
246 246
     }
247 247
 
248
-	/**
249
-	* alias of stop();
250
-	*
251
-	* @return boolean
252
-	*/
248
+    /**
249
+     * alias of stop();
250
+     *
251
+     * @return boolean
252
+     */
253 253
     public function kill( $_signal = SIGKILL, $_wait = false ) {
254 254
         return $this->stop( $_signal, $_wait );
255 255
     }
256 256
 
257
-	/**
258
-	* gets the error's message based on
259
-	* its id
260
-	*
261
-	* @param integer $_code
262
-	* @return string
263
-	*/
257
+    /**
258
+     * gets the error's message based on
259
+     * its id
260
+     *
261
+     * @param integer $_code
262
+     * @return string
263
+     */
264 264
     public function getError( $_code ) {
265 265
         if ( isset( $this->errors[$_code] ) ) {
266 266
             return $this->errors[$_code];
@@ -270,11 +270,11 @@  discard block
 block discarded – undo
270 270
         }
271 271
     }
272 272
 
273
-	/**
274
-	* signal handler
275
-	*
276
-	* @param integer $_signal
277
-	*/
273
+    /**
274
+     * signal handler
275
+     *
276
+     * @param integer $_signal
277
+     */
278 278
     protected function signalHandler( $_signal ) {
279 279
         switch( $_signal ) {
280 280
             case SIGTERM:
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.