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


Ignore:
Timestamp:
10/24/12 16:34:36 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Clean up and move SQL for static IP pool list to IPDB.pm. See #34.

  • Rename listPool in main.cgi to showPool, so that we can:
  • Add listPool sub in IPDB.pm
  • Convert getBlockData to return a hashref instead of an array, and update the one extant call

Tweak template to use odd for row colors

File:
1 edited

Legend:

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

    r527 r528  
    2727        &initIPDBGlobals &connectDB &finish &checkDBSanity
    2828        &addMaster
    29         &listSummary &listMaster &listRBlock &listFree
     29        &listSummary &listMaster &listRBlock &listFree &listPool
    3030        &getRoutedCity
    3131        &allocateBlock &deleteBlock &getBlockData
     
    4040                &initIPDBGlobals &connectDB &finish &checkDBSanity
    4141                &addMaster
    42                 &listSummary &listMaster &listRBlock &listFree
     42                &listSummary &listMaster &listRBlock &listFree &listPool
    4343                &getRoutedCity
    4444                &allocateBlock &deleteBlock &getBlockData
     
    443443  return \@flist;
    444444} # end listFree()
     445
     446
     447## IPDB::listPool()
     448#
     449sub listPool {
     450  my $dbh = shift;
     451  my $pool = shift;
     452
     453  my $sth = $dbh->prepare("SELECT ip,custid,available,description,type".
     454        " FROM poolips WHERE pool = ? ORDER BY ip");
     455  $sth->execute($pool);
     456  my @poolips;
     457  while (my ($ip,$custid,$available,$desc,$type) = $sth->fetchrow_array) {
     458    my %row = (
     459        ip => $ip,
     460        custid => $custid,
     461        available => $available,
     462        desc => $desc,
     463        delme => $available eq 'n'
     464        );
     465    push @poolips, \%row;
     466  }
     467  return \@poolips;
     468} # end listPool()
    445469
    446470
     
    972996  my $block = shift;
    973997
    974   my $sth = $dbh->prepare("select cidr,custid,type,city,description from searchme".
    975         " where cidr='$block'");
    976   $sth->execute();
    977   return $sth->fetchrow_array();
     998  my $binfo = $dbh->selectrow_hashref("SELECT cidr,custid,type,city,description FROM searchme".
     999        " WHERE cidr = ?", undef, ($block) );
     1000  return $binfo;
    9781001} # end getBlockData()
    9791002
Note: See TracChangeset for help on using the changeset viewer.