Changeset 523 for trunk/cgi-bin/main.cgi
- Timestamp:
- 10/19/12 17:32:12 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/main.cgi
r519 r523 90 90 my $page; 91 91 if (-e "$ENV{HTML_TEMPLATE_ROOT}/$webvar{action}.tmpl") { 92 $page = HTML::Template->new(filename => "$webvar{action}.tmpl" );92 $page = HTML::Template->new(filename => "$webvar{action}.tmpl", loop_context_vars => 1); 93 93 } else { 94 94 $page = HTML::Template->new(filename => "dunno.tmpl"); … … 218 218 # Initial display: Show master blocks with total allocated subnets, total free subnets 219 219 sub showSummary { 220 my %allocated; 221 my %free; 222 my %routed; 223 my %bigfree; 224 225 # Count the allocations. 226 $sth = $ip_dbh->prepare("select count(*) from allocations where cidr <<= ?"); 227 foreach my $master (@masterblocks) { 228 $sth->execute("$master"); 229 $sth->bind_columns(\$allocated{"$master"}); 230 $sth->fetch(); 231 } 232 233 # Count routed blocks 234 $sth = $ip_dbh->prepare("select count(*) from routed where cidr <<= ?"); 235 foreach my $master (@masterblocks) { 236 $sth->execute("$master"); 237 $sth->bind_columns(\$routed{"$master"}); 238 $sth->fetch(); 239 } 240 241 # Count the free blocks. 242 $sth = $ip_dbh->prepare("select count(*) from freeblocks where cidr <<= ? and ". 243 "(routed='y' or routed='n')"); 244 foreach my $master (@masterblocks) { 245 $sth->execute("$master"); 246 $sth->bind_columns(\$free{"$master"}); 247 $sth->fetch(); 248 } 249 250 # Find the largest free block in each master 251 $sth = $ip_dbh->prepare("select maskbits from freeblocks where cidr <<= ? and ". 252 "(routed='y' or routed='n') order by maskbits limit 1"); 253 foreach my $master (@masterblocks) { 254 $sth->execute("$master"); 255 $sth->bind_columns(\$bigfree{"$master"}); 256 $sth->fetch(); 257 } 258 259 # Assemble the data to stuff into the template. 260 my @masterlist; 261 my $rowclass=0; 262 foreach my $master (@masterblocks) { 263 my %row = ( 264 rowclass => $rowclass++ % 2, 265 master => "$master", 266 routed => $routed{"$master"}, 267 allocated => $allocated{"$master"}, 268 free => $free{"$master"}, 269 bigfree => ( ($bigfree{"$master"} eq '') ? ("<NONE>") : ("/".$bigfree{"$master"}) ) 270 ); 271 push (@masterlist, \%row); 272 } 273 $page->param(masterlist => \@masterlist); 220 my $masterlist = listSummary($ip_dbh); 221 $page->param(masterlist => $masterlist); 274 222 275 223 $page->param(addmaster => ($IPDBacl{$authuser} =~ /a/) ); 276 277 224 } # showSummary 278 225
Note:
See TracChangeset
for help on using the changeset viewer.