Skip to content

Commit 7c4fc26

Browse files
authored
Merge pull request #30 from yaleman/master
Fixes for issues #27 #28 #29
2 parents da2b218 + 0e2eed4 commit 7c4fc26

File tree

2 files changed

+7
-38
lines changed

2 files changed

+7
-38
lines changed

functions/classes/class.Scan.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ protected function ping_address_method_ping ($address) {
372372
# set ping command based on OS type
373373
if (PHP_OS == "FreeBSD" || PHP_OS == "NetBSD") { $cmd = $this->config->pingpath." -c $this->icmp_count -W ".($this->icmp_timeout*1000)." $address 1>/dev/null 2>&1"; }
374374
elseif(PHP_OS == "Linux" || PHP_OS == "OpenBSD") { $cmd = $this->config->pingpath." -c $this->icmp_count -w $this->icmp_timeout $address 1>/dev/null 2>&1"; }
375-
elseif(PHP_OS == "WIN32" || PHP_OS == "Windows" || PHP_OS == "WINNT") { $cmd = $this->config->pingpath." -n $this->icmp_count -I ".($this->icmp_timeout*1000)." $address 1>/dev/null 2>&1"; }
375+
elseif(PHP_OS == "WIN32" || PHP_OS == "Windows" || PHP_OS == "WINNT") { $cmd = $this->config->pingpath." -n $this->icmp_count -I ".($this->icmp_timeout*1000)." $address"; }
376376
else { $cmd = $this->config->pingpath." -c $this->icmp_count -n $address 1>/dev/null 2>&1"; }
377377

378378
# execute command, return $retval

functions/classes/class.phpipamAgent.php

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ public function mysql_scan_update_host_statuses () {
635635
* @return void
636636
*/
637637
private function update_subnet_status_scantime ($subnet_id) {
638-
try { $this->Database->updateObject("subnets", array("id"=>$id, "lastScan"=>$this->nowdate), "id"); }
638+
try { $this->Database->updateObject("subnets", array("id"=>$subnet_id, "lastScan"=>$this->nowdate), "id"); }
639639
catch (Exception $e) {}
640640
}
641641

@@ -762,7 +762,7 @@ private function mysql_check_slaves ($subnetId) {
762762
// int check
763763
if(!is_numeric($subnetId)) { return false; }
764764
// check
765-
try { $count = $this->Database->numObjectsFilter("subnets", "masterSubnetId", $subnetid); }
765+
try { $count = $this->Database->numObjectsFilter("subnets", "masterSubnetId", $subnetId); }
766766
catch (Exception $e) {
767767
$this->Result->show("danger", _("Error: ").$e->getMessage());
768768
return false;
@@ -980,42 +980,12 @@ private function mysql_scan_discover_hosts_fping_nonthreaded ($subnets, $address
980980
* @access private
981981
* @param mixed $subnets
982982
* @param mixed $addresses
983-
* @return void
983+
* @return $subnets
984984
*/
985985
private function mysql_scan_discover_hosts_ping_nonthreaded ($subnets, $addresses) {
986-
$z = 0; //addresses array index
987-
988-
/*
989-
//run per MAX_THREADS
990-
for ($m=0; $m<=sizeof($addresses); $m += $this->config->threads) {
991-
// create threads
992-
$threads = array();
993-
994-
//fork processes
995-
for ($i = 0; $i <= $this->config->threads && $i <= sizeof($addresses); $i++) {
996-
//only if index exists!
997-
if(isset($addresses[$z])) {
998-
//start new thread
999-
$threads[$z] = new Thread( 'ping_address' );
1000-
$threads[$z]->start( $this->transform_to_dotted( $addresses[$z]['ip_addr']) );
1001-
$z++; //next index
1002-
}
1003-
}
1004986

1005-
// wait for all the threads to finish
1006-
while( !empty( $threads ) ) {
1007-
foreach( $threads as $index => $thread ) {
1008-
if( ! $thread->isAlive() ) {
1009-
//unset dead hosts
1010-
if($thread->getExitCode() != 0) {
1011-
unset($addresses[$index]);
1012-
}
1013-
//remove thread
1014-
unset( $threads[$index]);
1015-
}
1016-
}
1017-
usleep(200000);
1018-
}
987+
for ($i = 0; $i <= sizeof($addresses); $i++) {
988+
ping_address( $this->transform_to_dotted( $addresses[$z]['ip_addr']) );
1019989
}
1020990

1021991
//ok, we have all available addresses, rekey them
@@ -1030,7 +1000,6 @@ private function mysql_scan_discover_hosts_ping_nonthreaded ($subnets, $addresse
10301000
}
10311001
}
10321002
}
1033-
*/
10341003

10351004
// return result
10361005
return $subnets;
@@ -1048,7 +1017,7 @@ private function mysql_scan_discovered_write_to_db ($subnets) {
10481017
$discovered = 0; //for mailing
10491018

10501019
# reset db connection for ping / pear
1051-
if ($this->can_type!=="fping") {
1020+
if ($this->scan_type!=="fping") {
10521021
unset($this->Database);
10531022
$this->Database = new Database_PDO ();
10541023
}

0 commit comments

Comments
 (0)