@@ -114,16 +114,23 @@ public function __construct (Database_PDO $database, $settings = null) {
114
114
$ this ->Database = $ database ;
115
115
# initialize Result
116
116
$ this ->Result = new Result ();
117
+
117
118
# fetch settings
118
- $ this ->settings = is_null ($ this ->settings ) ? $ this ->get_settings () : (object ) $ this ->settings ;
119
+ $ settings = is_null ($ this ->settings ) ? $ this ->get_settings () : (object ) $ this ->settings ;
120
+ $ config = Config::ValueOf ('config ' );
121
+
122
+ $ this ->ping_type = $ config ['method ' ];
123
+ $ this ->ping_path = ($ this ->ping_type == "ping " ) ? $ config ['pingpath ' ] : '' ;
124
+ $ this ->fping_path = ($ this ->ping_type == "fping " ) ? $ config ['pingpath ' ] : '' ;
125
+
119
126
# set type
120
- $ this ->reset_scan_method ($ this ->settings -> scanPingType );
127
+ $ this ->reset_scan_method ($ this ->ping_type );
121
128
# set OS type
122
129
$ this ->set_os_type ();
123
130
# set php exec
124
131
$ this ->set_php_exec ();
125
132
# Log object
126
- $ this ->Log = new Logging ($ this ->Database , $ this -> settings );
133
+ $ this ->Log = new Logging ($ this ->Database , $ settings );
127
134
128
135
if ($ errmsg = php_feature_missing (null , ['exec ' ]))
129
136
$ this ->Result ->show ("danger " , $ errmsg , true );
@@ -268,17 +275,17 @@ public function ping_address ($address, $count=1, $timeout = 1) {
268
275
* @return void
269
276
*/
270
277
protected function ping_address_method_ping ($ address ) {
271
- # verify ping path
272
- $ this ->ping_verify_path ($ this ->settings ->scanPingPath );
273
-
274
278
# if ipv6 append 6
275
- if ($ this ->identify_address ($ address )=="IPv6 " ) { $ this ->settings ->scanPingPath = $ this ->settings ->scanPingPath ."6 " ; }
279
+ $ ping_path = ($ this ->identify_address ($ address )=="IPv6 " ) ? $ this ->ping_path ."6 " : $ this ->ping_path ;
280
+
281
+ # verify ping path
282
+ $ this ->ping_verify_path ($ ping_path );
276
283
277
284
# set ping command based on OS type
278
- if ($ this ->os_type == "FreeBSD " ) { $ cmd = $ this -> settings -> scanPingPath ." -c $ this ->icmp_count -W " .($ this ->icmp_timeout *1000 )." $ address 1>/dev/null 2>&1 " ; }
279
- elseif ($ this ->os_type == "Linux " ) { $ cmd = $ this -> settings -> scanPingPath ." -c $ this ->icmp_count -W $ this ->icmp_timeout $ address 1>/dev/null 2>&1 " ; }
280
- elseif ($ this ->os_type == "Windows " ) { $ cmd = $ this -> settings -> scanPingPath ." -n $ this ->icmp_count -w " .($ this ->icmp_timeout *1000 )." $ address " ; }
281
- else { $ cmd = $ this -> settings -> scanPingPath ." -c $ this ->icmp_count -n $ address 1>/dev/null 2>&1 " ; }
285
+ if ($ this ->os_type == "FreeBSD " ) { $ cmd = $ ping_path ." -c $ this ->icmp_count -W " .($ this ->icmp_timeout *1000 )." $ address 1>/dev/null 2>&1 " ; }
286
+ elseif ($ this ->os_type == "Linux " ) { $ cmd = $ ping_path ." -c $ this ->icmp_count -W $ this ->icmp_timeout $ address 1>/dev/null 2>&1 " ; }
287
+ elseif ($ this ->os_type == "Windows " ) { $ cmd = $ ping_path ." -n $ this ->icmp_count -w " .($ this ->icmp_timeout *1000 )." $ address " ; }
288
+ else { $ cmd = $ ping_path ." -c $ this ->icmp_count -n $ address 1>/dev/null 2>&1 " ; }
282
289
283
290
# for IPv6 remove wait
284
291
if ($ this ->identify_address ($ address )=="IPv6 " ) {
@@ -374,14 +381,14 @@ protected function ping_address_method_pear ($address) {
374
381
* @return void
375
382
*/
376
383
public function ping_address_method_fping ($ address ) {
377
- # verify ping path
378
- $ this ->ping_verify_path ($ this ->settings ->scanFPingPath );
379
-
380
384
# if ipv6 append 6
381
- if ($ this ->identify_address ($ address )=="IPv6 " ) { $ this ->settings ->scanFPingPath = $ this ->settings ->scanFPingPath ."6 " ; }
385
+ $ fping_path = ($ this ->identify_address ($ address )=="IPv6 " ) ? $ this ->fping_path ."6 " : $ this ->fping_path ;
386
+
387
+ # verify ping path
388
+ $ this ->ping_verify_path ($ fping_path );
382
389
383
390
# set command
384
- $ cmd = $ this -> settings -> scanFPingPath ." -c $ this ->icmp_count -t " .($ this ->icmp_timeout *1000 )." $ address " ;
391
+ $ cmd = $ fping_path ." -c $ this ->icmp_count -t " .($ this ->icmp_timeout *1000 )." $ address " ;
385
392
# execute command, return $retval
386
393
exec ($ cmd , $ output , $ retval );
387
394
@@ -427,10 +434,14 @@ private function save_fping_rtt ($line) {
427
434
* @return void
428
435
*/
429
436
public function ping_address_method_fping_subnet ($ subnet_cidr , $ return_result = false ) {
437
+ # if ipv6 append 6
438
+ $ fping_path = ($ this ->identify_address ($ address )=="IPv6 " ) ? $ this ->fping_path ."6 " : $ this ->fping_path ;
439
+
430
440
# verify ping path
431
- $ this ->ping_verify_path ($ this ->settings ->scanFPingPath );
441
+ $ this ->ping_verify_path ($ fping_path );
442
+
432
443
# set command
433
- $ cmd = $ this -> settings -> scanFPingPath ." -c $ this ->icmp_count -t " .($ this ->icmp_timeout *1000 )." -Ag $ subnet_cidr " ;
444
+ $ cmd = $ fping_path ." -c $ this ->icmp_count -t " .($ this ->icmp_timeout *1000 )." -Ag $ subnet_cidr " ;
434
445
# execute command, return $retval
435
446
exec ($ cmd , $ output , $ retval );
436
447
0 commit comments