Skip to content
Permalink
Browse files Browse the repository at this point in the history
Improve - Add a utility function to calculate the number of hosts in …
…a range or subnet.
  • Loading branch information
mark-unwin committed Sep 28, 2020
1 parent ad60e48 commit c7595cb
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions code_igniter/application/controllers/util.php
Expand Up @@ -73,6 +73,22 @@ public function index()
return;
}

public function subnet_size()
{
$command = "nmap -n -sL " . $_POST['subnet'];
exec($command, $output, $return_var);
$count = 0;
if ($return_var === 0) {
foreach ($output as $line) {
if (stripos($line, 'Nmap scan report for') === 0) {
$count = $count + 1;
}
}
}
echo $count;
return;
}

/**
* Process the supplied data and return a padded version string
*
Expand Down

0 comments on commit c7595cb

Please sign in to comment.