Changeset 541 for trunk/cgi-bin/IPDB.pm
- Timestamp:
- 11/02/12 15:54:31 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/IPDB.pm
r536 r541 23 23 @ISA = qw(Exporter); 24 24 @EXPORT_OK = qw( 25 %disp_alloctypes %list_alloctypes %def_custids @citylist @poplist @masterblocks26 % allocated %free %routed %bigfree %IPDBacl %aclmsg25 %disp_alloctypes %list_alloctypes %def_custids @citylist @poplist 26 %IPDBacl %aclmsg 27 27 &initIPDBGlobals &connectDB &finish &checkDBSanity 28 28 &addMaster 29 29 &listSummary &listMaster &listRBlock &listFree &listPool 30 &get TypeList &getPoolSelect &findAllocateFrom30 &getMasterList &getTypeList &getPoolSelect &findAllocateFrom 31 31 &ipParent &subParent &blockParent &getRoutedCity 32 32 &allocateBlock &updateBlock &deleteBlock &getBlockData … … 38 38 %EXPORT_TAGS = ( ALL => [qw( 39 39 %disp_alloctypes %list_alloctypes %def_custids @citylist @poplist 40 @masterblocks %allocated %free %routed %bigfree%IPDBacl %aclmsg40 %IPDBacl %aclmsg 41 41 &initIPDBGlobals &connectDB &finish &checkDBSanity 42 42 &addMaster 43 43 &listSummary &listMaster &listRBlock &listFree &listPool 44 &get TypeList &getPoolSelect &findAllocateFrom44 &getMasterList &getTypeList &getPoolSelect &findAllocateFrom 45 45 &ipParent &subParent &blockParent &getRoutedCity 46 46 &allocateBlock &updateBlock &deleteBlock &getBlockData … … 58 58 our @citylist; 59 59 our @poplist; 60 our @masterblocks;61 our %allocated;62 our %free;63 our %routed;64 our %bigfree;65 60 our %IPDBacl; 66 61 … … 121 116 } 122 117 123 # Master block list124 $sth = $dbh->prepare("select cidr from masterblocks order by cidr");125 $sth->execute;126 return (undef,$sth->errstr) if $sth->err;127 for (my $i=0; my @data = $sth->fetchrow_array(); $i++) {128 $masterblocks[$i] = new NetAddr::IP $data[0];129 $allocated{"$masterblocks[$i]"} = 0;130 $free{"$masterblocks[$i]"} = 0;131 $bigfree{"$masterblocks[$i]"} = 128; # Larger number means smaller block.132 # Set to 128 to prepare for IPv6133 $routed{"$masterblocks[$i]"} = 0;134 }135 136 118 # Load ACL data. Specific username checks are done at a different level. 137 119 $sth = $dbh->prepare("select username,acl from users"); … … 469 451 return \@poolips; 470 452 } # end listPool() 453 454 455 ## IPDB::getMasterList() 456 # Get a list of master blocks, optionally including last-modified timestamps 457 # Takes an optional flag to indicate whether to include timestamps; 458 # 'm' includes ctime, all others (suggest 'c') do not. 459 # Returns an arrayref to a list of hashrefs 460 sub getMasterList { 461 my $dbh = shift; 462 my $stampme = shift || 'm'; # optional but should be set by caller for clarity 463 464 my $mlist = $dbh->selectall_arrayref("SELECT cidr AS master".($stampme eq 'm' ? ',mtime' : ''). 465 " FROM masterblocks ORDER BY cidr", { Slice => {} }); 466 return $mlist; 467 } # end getMasterList() 471 468 472 469
Note:
See TracChangeset
for help on using the changeset viewer.