- Timestamp:
- 09/23/11 13:00:51 (13 years ago)
- Location:
- branches/htmlform
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/htmlform/cgi-bin/snCalc.cgi
r447 r499 5 5 use CGI::Carp qw(fatalsToBrowser); 6 6 use CGI::Simple; 7 use HTML::Template; 7 8 use NetAddr::IP; 8 9 use CommonWeb qw(:ALL);; … … 23 24 print "Content-Type: text/html\n\n"; 24 25 25 open(HTML, "../startsn.html")|| die "Could not open startsn.html :$!"; 26 my $start = join('', <HTML>); 27 close(HTML); 28 print $start; 26 ##fixme: need better method to find templates. 27 $ENV{HTML_TEMPLATE_ROOT} = $ENV{SCRIPT_FILENAME}; 28 $ENV{HTML_TEMPLATE_ROOT} =~ s|cgi-bin/snCalc.cgi||; 29 30 my $page = HTML::Template->new(filename => "templates/subnet-calc.tmpl"); 29 31 30 32 # Clean up input so we don't divide by zero or something equally silly … … 44 46 my $postnet = new NetAddr::IP "0.0.0.0/$gtinput"; 45 47 46 print qq(<div class="center"> 47 <table align="center" cellspacing="3" cellpadding="3"> 48 <tr> 49 <td class="heading" align="center">Results for /$ltinput</td> 50 <td class="heading" align="center">Results for /$input</td> 51 <td class="heading" align="center">Results for /$gtinput</td> 52 </tr> 53 ); 48 $page->param(prenet => $ltinput); 49 $page->param(net => $input); 50 $page->param(postnet => $gtinput); 51 $page->param(premask => $prenet->mask); 52 $page->param(mask => $net->mask); 53 $page->param(postmask => $postnet->mask); 54 $page->param(prewildcard => scalar($prenet->wildcard)); 55 $page->param(wildcard => scalar($net->wildcard)); 56 $page->param(postwildcard => scalar($postnet->wildcard)); 54 57 55 print qq(<tr><td valign="top">\n). 56 qq( <div class="mask">).$prenet->mask."</div>\n". 57 qq( <div class="wildcard">).$prenet->wildcard."</div>\n". 58 getranges($ltinput). 59 qq(</td>\n<td valign="top" bgcolor="#d0e0e0">\n). 60 qq( <div class="mask">).$net->mask."</div>\n". 61 qq( <div class="wildcard">).$net->wildcard."</div>\n". 62 getranges($input). 63 qq(</td>\n<td valign="top">). 64 qq( <div class="mask">).$postnet->mask."</div>\n". 65 qq( <div class="wildcard">).$postnet->wildcard."</div>\n". 66 getranges($gtinput); 58 my @prenets; 59 foreach (getranges($ltinput)) { 60 my %row = (netrange => $_); 61 push (@prenets, \%row); 62 } 63 $page->param(prenets => \@prenets); 64 my @nets; 65 foreach (getranges($input)) { 66 my %row = (netrange => $_); 67 push (@nets, \%row); 68 } 69 $page->param(nets => \@nets); 70 my @postnets; 71 foreach (getranges($gtinput)) { 72 my %row = (netrange => $_); 73 push @postnets, \%row; 74 } 75 $page->param(postnets => \@postnets); 67 76 68 print "</td></tr>\n</table>\n"; 69 70 print qq(<input type="button" value="Back" onclick="history.go(-1)" class="heading"> 71 </div> 72 </body> 73 </html> 74 ); 77 print $page->output; 75 78 76 79 # Just In Case … … 95 98 sub getranges { 96 99 my $masklen = shift; 97 my $ret = '';100 my @ret; 98 101 my $super; 99 102 if ($masklen < 8) { … … 107 110 } 108 111 foreach my $net ($super->split($masklen)) { 109 $ret .= "\t".xrange($net,$masklen)."<br />\n";112 push @ret, xrange($net,$masklen); 110 113 } 111 return $ret;114 return @ret; 112 115 } # getranges() -
branches/htmlform/ipdb.css
r469 r499 169 169 } 170 170 171 .ljust { 172 text-align: left; 173 } 174 .topalign { 175 vertical-align: top; 176 } 177 171 178 .small { 172 179 font-size: 60%; … … 198 205 background: #ffff00; 199 206 } 207 208 .altbg { 209 background: #d0e0e0; 210 }
Note:
See TracChangeset
for help on using the changeset viewer.