@@ -22,26 +22,26 @@ |
||
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 |
@@ -8,7 +8,7 @@ |
||
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 |
@@ -14,23 +14,23 @@ discard block |
||
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 |
||
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); |
@@ -72,7 +72,9 @@ |
||
72 | 72 | function get_string_between($string, $start, $end){ |
73 | 73 | $string = " ".$string; |
74 | 74 | $ini = strpos($string,$start); |
75 | - if ($ini == 0) return ""; |
|
75 | + if ($ini == 0) { |
|
76 | + return ""; |
|
77 | + } |
|
76 | 78 | $ini += strlen($start); |
77 | 79 | $len = strpos($string,$end,$ini) - $ini; |
78 | 80 | return substr($string,$ini,$len); |
@@ -15,9 +15,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -78,18 +78,18 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 | ?> |
@@ -70,9 +70,9 @@ |
||
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 |
@@ -47,14 +47,16 @@ |
||
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 | 55 | * Multicast unique mac requirement - section or vlan |
55 | 56 | */ |
56 | -if(!defined('MCUNIQUE')) |
|
57 | -define('MCUNIQUE', "section"); |
|
57 | +if(!defined('MCUNIQUE')) { |
|
58 | + define('MCUNIQUE', "section"); |
|
59 | +} |
|
58 | 60 | |
59 | 61 | |
60 | 62 | /* proxy connection details |
@@ -42,7 +42,7 @@ discard block |
||
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 |
||
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>"; |
@@ -571,8 +571,8 @@ |
||
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 |
@@ -330,11 +330,10 @@ discard block |
||
330 | 330 | |
331 | 331 | function GetLastError() |
332 | 332 | { |
333 | - if (0 < $this->_last_error_code) |
|
334 | - { |
|
333 | + if (0 < $this->_last_error_code) { |
|
335 | 334 | return $this->_last_error_message.' ('.$this->_last_error_code.')'; |
336 | - } else |
|
337 | - { |
|
335 | + } |
|
336 | + else { |
|
338 | 337 | return ''; |
339 | 338 | } |
340 | 339 | } |
@@ -387,8 +386,7 @@ discard block |
||
387 | 386 | function SetUsername($username = '') |
388 | 387 | { |
389 | 388 | $temp_username = $username; |
390 | - if (false === strpos($temp_username, '@')) |
|
391 | - { |
|
389 | + if (false === strpos($temp_username, '@')) { |
|
392 | 390 | $temp_username .= $this->_radius_suffix; |
393 | 391 | } |
394 | 392 | |
@@ -403,8 +401,7 @@ discard block |
||
403 | 401 | $encrypted_password = ''; |
404 | 402 | $padded_password = $password; |
405 | 403 | |
406 | - if (0 != (strlen($password) % 16)) |
|
407 | - { |
|
404 | + if (0 != (strlen($password) % 16)) { |
|
408 | 405 | $padded_password .= str_repeat(chr(0), (16 - strlen($password) % 16)); |
409 | 406 | } |
410 | 407 | |
@@ -432,11 +429,10 @@ discard block |
||
432 | 429 | |
433 | 430 | function SetNasIPAddress($nas_ip_address = '') |
434 | 431 | { |
435 | - if (0 < strlen($nas_ip_address)) |
|
436 | - { |
|
432 | + if (0 < strlen($nas_ip_address)) { |
|
437 | 433 | $this->_nas_ip_address = gethostbyname($nas_ip_address); |
438 | - } else |
|
439 | - { |
|
434 | + } |
|
435 | + else { |
|
440 | 436 | $this->_nas_ip_address = gethostbyname(isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '0.0.0.0'); |
441 | 437 | } |
442 | 438 | $this->SetAttribute(4, $this->_nas_ip_address); |
@@ -452,8 +448,7 @@ discard block |
||
452 | 448 | |
453 | 449 | function SetUdpTimeout($udp_timeout = 5) |
454 | 450 | { |
455 | - if (intval($udp_timeout) > 0) |
|
456 | - { |
|
451 | + if (intval($udp_timeout) > 0) { |
|
457 | 452 | $this->_udp_timeout = intval($udp_timeout); |
458 | 453 | } |
459 | 454 | } |
@@ -468,8 +463,7 @@ discard block |
||
468 | 463 | |
469 | 464 | function SetAuthenticationPort($authentication_port) |
470 | 465 | { |
471 | - if ((intval($authentication_port) > 0) && (intval($authentication_port) < 65536)) |
|
472 | - { |
|
466 | + if ((intval($authentication_port) > 0) && (intval($authentication_port) < 65536)) { |
|
473 | 467 | $this->_authentication_port = intval($authentication_port); |
474 | 468 | } |
475 | 469 | } |
@@ -477,8 +471,7 @@ discard block |
||
477 | 471 | |
478 | 472 | function SetAccountingPort($accounting_port) |
479 | 473 | { |
480 | - if ((intval($accounting_port) > 0) && (intval($accounting_port) < 65536)) |
|
481 | - { |
|
474 | + if ((intval($accounting_port) > 0) && (intval($accounting_port) < 65536)) { |
|
482 | 475 | $this->_accounting_port = intval($accounting_port); |
483 | 476 | } |
484 | 477 | } |
@@ -499,21 +492,19 @@ discard block |
||
499 | 492 | function GetReadableReceivedAttributes() |
500 | 493 | { |
501 | 494 | $readable_attributes = ''; |
502 | - if (isset($this->_attributes_received)) |
|
503 | - { |
|
495 | + if (isset($this->_attributes_received)) { |
|
504 | 496 | foreach ($this->_attributes_received as $one_received_attribute) |
505 | 497 | { |
506 | 498 | $attributes_info = $this->GetAttributesInfo($one_received_attribute[0]); |
507 | 499 | $readable_attributes .= $attributes_info[0].": "; |
508 | - if (26 == $one_received_attribute[0]) |
|
509 | - { |
|
500 | + if (26 == $one_received_attribute[0]) { |
|
510 | 501 | $vendor_array = $this->DecodeVendorSpecificContent($one_received_attribute[1]); |
511 | 502 | foreach ($vendor_array as $vendor_one) |
512 | 503 | { |
513 | 504 | $readable_attributes .= 'Vendor-Id: '.$vendor_one[0].", Vendor-type: ".$vendor_one[1].", Attribute-specific: ".$vendor_one[2]; |
514 | 505 | } |
515 | - } else |
|
516 | - { |
|
506 | + } |
|
507 | + else { |
|
517 | 508 | $readable_attributes .= $one_received_attribute[1]; |
518 | 509 | } |
519 | 510 | $readable_attributes .= "<br />\n"; |
@@ -528,8 +519,7 @@ discard block |
||
528 | 519 | $attribute_value = NULL; |
529 | 520 | foreach ($this->_attributes_received as $one_received_attribute) |
530 | 521 | { |
531 | - if (intval($attribute_type) == $one_received_attribute[0]) |
|
532 | - { |
|
522 | + if (intval($attribute_type) == $one_received_attribute[0]) { |
|
533 | 523 | $attribute_value = $one_received_attribute[1]; |
534 | 524 | break; |
535 | 525 | } |
@@ -540,11 +530,10 @@ discard block |
||
540 | 530 | |
541 | 531 | function GetRadiusPacketInfo($info_index) |
542 | 532 | { |
543 | - if (isset($this->_radius_packet_info[intval($info_index)])) |
|
544 | - { |
|
533 | + if (isset($this->_radius_packet_info[intval($info_index)])) { |
|
545 | 534 | return $this->_radius_packet_info[intval($info_index)]; |
546 | - } else |
|
547 | - { |
|
535 | + } |
|
536 | + else { |
|
548 | 537 | return ''; |
549 | 538 | } |
550 | 539 | } |
@@ -552,11 +541,10 @@ discard block |
||
552 | 541 | |
553 | 542 | function GetAttributesInfo($info_index) |
554 | 543 | { |
555 | - if (isset($this->_attributes_info[intval($info_index)])) |
|
556 | - { |
|
544 | + if (isset($this->_attributes_info[intval($info_index)])) { |
|
557 | 545 | return $this->_attributes_info[intval($info_index)]; |
558 | - } else |
|
559 | - { |
|
546 | + } |
|
547 | + else { |
|
560 | 548 | return array('', ''); |
561 | 549 | } |
562 | 550 | } |
@@ -564,8 +552,7 @@ discard block |
||
564 | 552 | |
565 | 553 | function DebugInfo($debug_info) |
566 | 554 | { |
567 | - if ($this->_debug_mode) |
|
568 | - { |
|
555 | + if ($this->_debug_mode) { |
|
569 | 556 | //save debugging |
570 | 557 | $this->debug_text[] = date('Y-m-d H:i:s').' DEBUG: '.$debug_info; |
571 | 558 | } |
@@ -577,8 +564,7 @@ discard block |
||
577 | 564 | $attribute_index = -1; |
578 | 565 | for ($attributes_loop = 0; $attributes_loop < count($this->_attributes_to_send); $attributes_loop++) |
579 | 566 | { |
580 | - if ($type == ord(substr($this->_attributes_to_send[$attributes_loop], 0, 1))) |
|
581 | - { |
|
567 | + if ($type == ord(substr($this->_attributes_to_send[$attributes_loop], 0, 1))) { |
|
582 | 568 | $attribute_index = $attributes_loop; |
583 | 569 | break; |
584 | 570 | } |
@@ -586,10 +572,8 @@ discard block |
||
586 | 572 | |
587 | 573 | $temp_attribute = NULL; |
588 | 574 | |
589 | - if (isset($this->_attributes_info[$type])) |
|
590 | - { |
|
591 | - switch ($this->_attributes_info[$type][1]) |
|
592 | - { |
|
575 | + if (isset($this->_attributes_info[$type])) { |
|
576 | + switch ($this->_attributes_info[$type][1]) { |
|
593 | 577 | case 'T': // Text, 1-253 octets containing UTF-8 encoded ISO 10646 characters (RFC 2279). |
594 | 578 | $temp_attribute = chr($type).chr(2 + strlen($value)).$value; |
595 | 579 | break; |
@@ -611,12 +595,11 @@ discard block |
||
611 | 595 | } |
612 | 596 | } |
613 | 597 | |
614 | - if ($attribute_index > -1) |
|
615 | - { |
|
598 | + if ($attribute_index > -1) { |
|
616 | 599 | $this->_attributes_to_send[$attribute_index] = $temp_attribute; |
617 | 600 | $additional_debug = 'Modified'; |
618 | - } else |
|
619 | - { |
|
601 | + } |
|
602 | + else { |
|
620 | 603 | $this->_attributes_to_send[] = $temp_attribute; |
621 | 604 | $additional_debug = 'Added'; |
622 | 605 | } |
@@ -629,10 +612,8 @@ discard block |
||
629 | 612 | { |
630 | 613 | $attribute_value = NULL; |
631 | 614 | |
632 | - if (isset($this->_attributes_info[$attribute_format])) |
|
633 | - { |
|
634 | - switch ($this->_attributes_info[$attribute_format][1]) |
|
635 | - { |
|
615 | + if (isset($this->_attributes_info[$attribute_format])) { |
|
616 | + switch ($this->_attributes_info[$attribute_format][1]) { |
|
636 | 617 | case 'T': // Text, 1-253 octets containing UTF-8 encoded ISO 10646 characters (RFC 2279). |
637 | 618 | $attribute_value = $attribute_raw_value; |
638 | 619 | break; |
@@ -690,26 +671,22 @@ discard block |
||
690 | 671 | |
691 | 672 | $this->SetPacketCodeToSend(1); // Access-Request |
692 | 673 | |
693 | - if (0 < strlen($username)) |
|
694 | - { |
|
674 | + if (0 < strlen($username)) { |
|
695 | 675 | $this->SetUsername($username); |
696 | 676 | } |
697 | 677 | |
698 | - if (0 < strlen($password)) |
|
699 | - { |
|
678 | + if (0 < strlen($password)) { |
|
700 | 679 | $this->SetPassword($password); |
701 | 680 | } |
702 | 681 | |
703 | - if ($state !== NULL) |
|
704 | - { |
|
682 | + if ($state !== NULL) { |
|
705 | 683 | $this->SetAttribute(24, $state); |
706 | - } else |
|
707 | - { |
|
684 | + } |
|
685 | + else { |
|
708 | 686 | $this->SetAttribute(6, 1); // 1=Login |
709 | 687 | } |
710 | 688 | |
711 | - if (intval($udp_timeout) > 0) |
|
712 | - { |
|
689 | + if (intval($udp_timeout) > 0) { |
|
713 | 690 | $this->SetUdpTimeout($udp_timeout); |
714 | 691 | } |
715 | 692 | |
@@ -732,23 +709,21 @@ discard block |
||
732 | 709 | |
733 | 710 | $_socket_to_server = socket_create(AF_INET, SOCK_DGRAM, 17); // UDP packet = 17 |
734 | 711 | |
735 | - if ($_socket_to_server === FALSE) |
|
736 | - { |
|
712 | + if ($_socket_to_server === FALSE) { |
|
737 | 713 | $this->_last_error_code = socket_last_error(); |
738 | 714 | $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 | - { |
|
715 | + } |
|
716 | + elseif (FALSE === socket_connect($_socket_to_server, $this->_ip_radius_server, $this->_authentication_port)) { |
|
741 | 717 | $this->_last_error_code = socket_last_error(); |
742 | 718 | $this->_last_error_message = socket_strerror($this->_last_error_code); |
743 | - } elseif (FALSE === socket_write($_socket_to_server, $packet_data, $packet_length)) |
|
744 | - { |
|
719 | + } |
|
720 | + elseif (FALSE === socket_write($_socket_to_server, $packet_data, $packet_length)) { |
|
745 | 721 | $this->_last_error_code = socket_last_error(); |
746 | 722 | $this->_last_error_message = socket_strerror($this->_last_error_code); |
747 | - } else |
|
748 | - { |
|
723 | + } |
|
724 | + else { |
|
749 | 725 | $this->DebugInfo('<b>Packet type '.$this->_radius_packet_to_send.' ('.$this->GetRadiusPacketInfo($this->_radius_packet_to_send).')'.' sent</b>'); |
750 | - if ($this->_debug_mode) |
|
751 | - { |
|
726 | + if ($this->_debug_mode) { |
|
752 | 727 | $readable_attributes = ''; |
753 | 728 | foreach ($this->_attributes_to_send as $one_attribute_to_send) |
754 | 729 | { |
@@ -762,10 +737,8 @@ discard block |
||
762 | 737 | |
763 | 738 | $received_packet = chr(0); |
764 | 739 | |
765 | - if (!(FALSE === socket_select($read_socket_array, $write_socket_array, $except_socket_array, $this->_udp_timeout))) |
|
766 | - { |
|
767 | - if (in_array($_socket_to_server, $read_socket_array)) |
|
768 | - { |
|
740 | + if (!(FALSE === socket_select($read_socket_array, $write_socket_array, $except_socket_array, $this->_udp_timeout))) { |
|
741 | + if (in_array($_socket_to_server, $read_socket_array)) { |
|
769 | 742 | if (FALSE === ($received_packet = @socket_read($_socket_to_server, 1024))) { |
770 | 743 | // @ used, than no error is displayed if the connection is closed by the remote host |
771 | 744 | { |
@@ -773,13 +746,13 @@ discard block |
||
773 | 746 | } |
774 | 747 | $this->_last_error_code = socket_last_error(); |
775 | 748 | $this->_last_error_message = socket_strerror($this->_last_error_code); |
776 | - } else |
|
777 | - { |
|
749 | + } |
|
750 | + else { |
|
778 | 751 | socket_close($_socket_to_server); |
779 | 752 | } |
780 | 753 | } |
781 | - } else |
|
782 | - { |
|
754 | + } |
|
755 | + else { |
|
783 | 756 | socket_close($_socket_to_server); |
784 | 757 | } |
785 | 758 | } |
@@ -788,8 +761,7 @@ discard block |
||
788 | 761 | |
789 | 762 | $this->DebugInfo('<b>Packet type '.$this->_radius_packet_received.' ('.$this->GetRadiusPacketInfo($this->_radius_packet_received).')'.' received</b>'); |
790 | 763 | |
791 | - if ($this->_radius_packet_received > 0) |
|
792 | - { |
|
764 | + if ($this->_radius_packet_received > 0) { |
|
793 | 765 | $this->_identifier_received = intval(ord(substr($received_packet, 1, 1))); |
794 | 766 | $packet_length = (intval(ord(substr($received_packet, 2, 1))) * 256) + (intval(ord(substr($received_packet, 3, 1)))); |
795 | 767 | $this->_response_authenticator = substr($received_packet, 4, 16); |
@@ -804,15 +776,14 @@ discard block |
||
804 | 776 | $attribute_value = $this->DecodeAttribute($attribute_raw_value, $attribute_type); |
805 | 777 | |
806 | 778 | $attribute_info = $this->GetAttributesInfo($attribute_type); |
807 | - if (26 == $attribute_type) |
|
808 | - { |
|
779 | + if (26 == $attribute_type) { |
|
809 | 780 | $vendor_array = $this->DecodeVendorSpecificContent($attribute_value); |
810 | 781 | foreach ($vendor_array as $vendor_one) |
811 | 782 | { |
812 | 783 | $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 | 784 | } |
814 | - } else |
|
815 | - { |
|
785 | + } |
|
786 | + else { |
|
816 | 787 | $this->DebugInfo('Attribute '.$attribute_type.' ('.$attribute_info[0].'), length '.($attribute_length - 2).', format '.$attribute_info[1].', value <em>'.$attribute_value.'</em>'); |
817 | 788 | } |
818 | 789 |
@@ -11,47 +11,47 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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: |
@@ -133,10 +133,13 @@ discard block |
||
133 | 133 | public function isAlive() { |
134 | 134 | $pid = pcntl_waitpid( $this->pid, $status, WNOHANG ); |
135 | 135 | |
136 | - if ($pid === 0) { // child is still alive |
|
136 | + if ($pid === 0) { |
|
137 | +// child is still alive |
|
137 | 138 | return true; |
138 | - } else { |
|
139 | - if (pcntl_wifexited($status) && $this->exitCode == -1) { // normal exit |
|
139 | + } |
|
140 | + else { |
|
141 | + if (pcntl_wifexited($status) && $this->exitCode == -1) { |
|
142 | +// normal exit |
|
140 | 143 | $this->exitCode = pcntl_wexitstatus($status); |
141 | 144 | } |
142 | 145 | return false; |
@@ -196,12 +199,17 @@ discard block |
||
196 | 199 | $results = null; |
197 | 200 | $pid = pcntl_fork(); |
198 | 201 | |
199 | - if( $pid == -1 ) { //error forking, no child is created |
|
202 | + if( $pid == -1 ) { |
|
203 | +//error forking, no child is created |
|
200 | 204 | throw new Exception( $this->getError( Thread::COULD_NOT_FORK ), Thread::COULD_NOT_FORK ); |
201 | - }else if ( $pid ) {// parent |
|
205 | + } |
|
206 | + else if ( $pid ) { |
|
207 | +// parent |
|
202 | 208 | $this->pid = $pid; |
203 | 209 | |
204 | - } else { // child |
|
210 | + } |
|
211 | + else { |
|
212 | +// child |
|
205 | 213 | $this->pid = posix_getpid();//pid (child) |
206 | 214 | $this->ppid = posix_getppid();//pid (parent) |
207 | 215 | |
@@ -209,13 +217,15 @@ discard block |
||
209 | 217 | $array_args = func_get_args(); |
210 | 218 | if ( !empty( $array_args ) ) { |
211 | 219 | $results = call_user_func_array( $this->runnable, $array_args ); |
212 | - }else{ |
|
220 | + } |
|
221 | + else { |
|
213 | 222 | $results = call_user_func( $this->runnable ); |
214 | 223 | } |
215 | 224 | |
216 | 225 | $pipe = "/tmp/pipe_".$this->pid;//pid is known by parent |
217 | 226 | |
218 | - if(!file_exists($pipe)) {//child talks to parent using this pipe |
|
227 | + if(!file_exists($pipe)) { |
|
228 | +//child talks to parent using this pipe |
|
219 | 229 | umask(0); |
220 | 230 | posix_mkfifo($pipe, 0600); |
221 | 231 | } |