#!/usr/bin/perl -w # 0.14.3 # 0.15 25.09.2000 Added link to this wrapper # 0.16 07.11.2000 Get version from ipcalc # 0.17 09.01.2001 Added screenshot # 0.18 02.02.2001 Played with the html # 0.18.1 03.02.2001 Played even more with the html # 0.19 01.04.2001 Help text for wildcard netmask / Credits # 0.20 20.05.2001 Changed error messages # 0.21 19.06.2001 Adapted to new -c option # 0.22 30.07.2002 Stole javascript at dict.leo.org # 0.23 28.10.2004 Remove whitespace in input fields # Idea by David Shirlay David.Shirley(a)team.telstra.com $|=1; $ipcalc = "/home/f/a/falcon/bin/ipcalc"; $MAIL_ADDRESS=""; # history: # 200404 $actionurl = $ENV{'REQUEST_URI'}; use CGI; $query = new CGI; $host = $query->param('host'); $mask1 = $query->param('mask1'); $mask2 = $query->param('mask2'); $help = $query->param('help'); $host =~ s/ //g; $mask1 =~ s/ //g; $mask2 =~ s/ //g; $version = qx($ipcalc -v); chomp $version; if (! defined $host) { $host = ''; } if (! defined $mask1) { $mask1 = ''; $help = 1; } if (! defined $mask2) { $mask2 = ''; } if ($mask2 eq $mask1) { $mask2 = ''; } if ($host eq '') { $error .= " No host given\n"; $host = '192.168.0.1'; } $testhost = $host; $testhost =~ s/\.//g; if ($testhost !~ /^\d+$/) { $error .= " Illegal value for host ('$host')\n"; $host = '192.168.0.1'; } if ($mask1 eq '') { $error .= " No netmask given (using default netmask of your network's class)\n"; $mask1 = qx($ipcalc -c $host); } $testhost = $mask1; $testhost =~ s/\.//g; if ($testhost !~ /^\d+$/) { $error .= " Illegal value for netmask ('$mask1')\n"; $mask1 = 24; } if ($mask2 ne '') { $testhost = $mask2; $testhost =~ s/\.//g; if ($testhost !~ /^\d+$/) { $error .= " Illegal value for netmask for sub/supernet ('$mask2')\n"; $mask2 = ''; } } print $query->header; print << "EOF";
|
EOF
if (defined $error) {
$error =~ s/</gm;
$error =~ s/>/>/gm;
$error =~ s/\n/
/g;
print qq(\n);
print "$error
";
print qq(\n);
}
system("$ipcalc -h $host $mask1 $mask2");
print <<"EOF";
Download
CGI wrapper that produced this page.
Archive
2000-2004 Krischan Jodies
EOF