Changeset 524 for trunk/cgi-bin/main.cgi
- Timestamp:
- 10/22/12 17:10:07 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/main.cgi
r523 r524 233 233 234 234 $page->param(master => $webvar{block}); 235 236 my %allocated;237 my %free;238 my %cities;239 my %bigfree;240 241 my $master = new NetAddr::IP $webvar{block};242 my @localmasters;243 244 # Fetch only the blocks relevant to this master245 $sth = $ip_dbh->prepare("select cidr,city from routed where cidr <<= '$master' order by cidr");246 $sth->execute();247 248 my $i=0;249 while (my @data = $sth->fetchrow_array()) {250 my $cidr = new NetAddr::IP $data[0];251 $localmasters[$i++] = $cidr;252 $free{"$cidr"} = 0;253 $allocated{"$cidr"} = 0;254 $bigfree{"$cidr"} = 128;255 # Retain the routing destination256 $cities{"$cidr"} = $data[1];257 }258 259 # Check if there were actually any blocks routed from this master260 if ($i > 0) {261 262 # Count the allocations263 $sth = $ip_dbh->prepare("select count(*) from allocations where cidr <<= ?");264 foreach my $master (@localmasters) {265 $sth->execute("$master");266 $sth->bind_columns(\$allocated{"$master"});267 $sth->fetch();268 }269 270 # Count the free blocks.271 $sth = $ip_dbh->prepare("select count(*) from freeblocks where cidr <<= ? and ".272 "(routed='y' or routed='n')");273 foreach my $master (@localmasters) {274 $sth->execute("$master");275 $sth->bind_columns(\$free{"$master"});276 $sth->fetch();277 }278 279 # Get the size of the largest free block280 $sth = $ip_dbh->prepare("select maskbits from freeblocks where cidr <<= ? and ".281 "(routed='y' or routed='n') order by maskbits limit 1");282 foreach my $master (@localmasters) {283 $sth->execute("$master");284 $sth->bind_columns(\$bigfree{"$master"});285 $sth->fetch();286 }287 288 my @routed;289 my $rowclass = 0;290 foreach my $master (@localmasters) {291 my %row = (292 rowclass => $rowclass++ % 2,293 block => "$master",294 city => $cities{"$master"},295 nsubs => $allocated{"$master"},296 nfree => $free{"$master"},297 lfree => ( ($bigfree{"$master"} eq 128) ? ("<NONE>") : ("/".$bigfree{"$master"}) )298 );299 push @routed, \%row;300 }301 $page->param(routedlist => \@routed);302 303 } # end check for existence of routed blocks in master304 305 235 $page->param(delmaster => ($IPDBacl{$authuser} =~ /d/)); 306 236 307 # Snag the free blocks. 308 my $count = 0; 309 $sth = $ip_dbh->prepare("select cidr from freeblocks where cidr <<='$master' and ". 310 "routed='n' order by cidr"); 311 $sth->execute(); 312 my @unrouted; 313 my $rowclass = 0; 314 while (my @data = $sth->fetchrow_array()) { 315 my $cidr = new NetAddr::IP $data[0]; 316 my %row = ( 317 rowclass => $rowclass++ % 2, 318 fblock => "$cidr", 319 frange => $cidr->range 320 ); 321 push @unrouted, \%row; 322 } 323 $page->param(unrouted => \@unrouted); 324 237 my $rlist = listMaster($ip_dbh, $webvar{block}); 238 $page->param(routedlist => $rlist); 239 240 my $flist = listFree($ip_dbh, $webvar{block}, 'n'); 241 $page->param(unrouted => $flist); 325 242 } # showMaster 326 243
Note:
See TracChangeset
for help on using the changeset viewer.