Compare commits

..

No commits in common. "master" and "v0.2" have entirely different histories.
master ... v0.2

3 changed files with 2 additions and 38 deletions

15
LICENSE
View File

@ -1,15 +0,0 @@
Copyright (C) 2014 Jack-Benny Persson <jack-benny@cyberinfo.se>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

View File

@ -5,10 +5,6 @@ will get with a 26 bit netmask, simply run the script as below:
php netcalc.php 26
Or you `chmod +x netcalc.php` and run it as below:
./netcalc.php 26
The above command will give you the following outut:
Netmask

21
netcalc.php Executable file → Normal file
View File

@ -1,4 +1,3 @@
#!/usr/bin/php
<?php
/*
@ -57,22 +56,8 @@ function print_netmask($number)
}
unset($i);
// Special cases when netmask is 0 or 32
if ($mask == 0)
{
// If the network mask is 0, then just put 32 zeros in the string
$binary = "00000000000000000000000000000000";
}
elseif ($mask == 32)
{
// If the network mask is 32, then just put 32 ones in the string
$binary = "11111111111111111111111111111111";
}
else
{
// Else put the ones and zeros together in a binary string
$binary = "$ones$zeros";
}
// Put it together in a binary string
$binary = "$ones$zeros";
// Make it dotted binary format
$dotted_binary = substr_replace($binary, ".", 8, 0);
@ -100,8 +85,6 @@ function print_values($value)
$base=32-$value;
$netsize=pow(2, $base);
$hosts=$netsize-2;
// We don't want negative values
if ($hosts < 0)
{
$hosts = 0;