Changeset 534 for trunk/cgi-bin/IPDB.pm


Ignore:
Timestamp:
10/31/12 16:51:18 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Clean up and merge SQL for block-edit page into getBlockData.
Fortunately, the enhancement does not affect previous uses of
that sub. See #34.
Also tweak the template with a whitespace nitpick and to escape
HTML-funky characters in the circuit ID, description, notes, or
restricted data. Still need to confirm these can be reversed
on submission. See The Ticket That Won't Die, #3.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/IPDB.pm

    r533 r534  
    11841184
    11851185## IPDB::getBlockData()
    1186 # Return custid, type, city, and description for a block
     1186# Get CIDR or IP, custid, type, city, circuit ID, description, notes, modification time, private/restricted
     1187# data, for a CIDR block or pool IP
     1188# Also returns SWIP status flag for CIDR blocks
     1189# Takes the block/IP to look up
     1190# Returns an arrayref to a list of hashrefs
    11871191sub getBlockData {
    11881192  my $dbh = shift;
    11891193  my $block = shift;
    11901194
    1191   my $binfo = $dbh->selectrow_hashref("SELECT cidr,custid,type,city,description FROM searchme".
    1192         " WHERE cidr = ?", undef, ($block) );
     1195  my $cidr = new NetAddr::IP $block;
     1196
     1197  my $keycol = 'cidr';
     1198  my $blocktable = 'allocations';
     1199  my $poolip = 0;
     1200
     1201  # Pool IP and IPv6 check all in one!  Still needs to be tightened
     1202  # up a little for the as-yet-unhandled case of IPv6 IP pools
     1203  if ($cidr->bits == 32 && $cidr->masklen == 32) {
     1204    $poolip = 1;
     1205    $keycol = 'ip';
     1206    $blocktable = 'poolips';
     1207  }
     1208  my $binfo = $dbh->selectrow_hashref("SELECT $keycol AS block, custid, type, city, circuitid, description,".
     1209        " notes, modifystamp AS lastmod, privdata".($poolip ? '' : ', swip')." FROM $blocktable".
     1210        " WHERE $keycol = ?", undef, ($block) );
    11931211  return $binfo;
    11941212} # end getBlockData()
Note: See TracChangeset for help on using the changeset viewer.