Ignore:
Timestamp:
01/02/15 17:26:32 (10 years ago)
Author:
Kris Deugau
Message:

/trunk

Minimally update search tool for new database layout. Still needs a major rewrite.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/search.cgi

    r526 r670  
    7878  $page = HTML::Template->new(filename => "search/compsearch.tmpl");
    7979} else {
    80   $page = HTML::Template->new(filename => "search/sresults.tmpl");
     80  $page = HTML::Template->new(filename => "search/sresults.tmpl", global_vars => 1);
     81  $page->param(webpath => $IPDB::webpath);
    8182}
    8283
     
    8485$header->param(version => $IPDB::VERSION);
    8586$header->param(addperm => $IPDBacl{$authuser} =~ /a/);
     87$header->param(webpath => $IPDB::webpath);
    8688print "Content-type: text/html\n\n", $header->output;
     89
     90# Columns actually returned.  Slightly better than hardcoding it
     91# in each (sub)select
     92my $cols = "cidr,custid,type,city,description,id,parent_id,available";
    8793
    8894# Handle the DB error first
     
    141147# Iff something has NOT been entered, we still include it but in
    142148# such a way that it does not actually filter anything out.
    143 
    144   # Columns actually returned.  Slightly better than hardcoding it
    145   # in each (sub)select
    146   my $cols = "cidr,custid,type,city,description";
    147149
    148150  # hack fix for undefined variables
     
    248250  # Node search.
    249251
    250   my $sql = "SELECT cidr,custid,type,city,description FROM searchme".
     252  my $sql = "SELECT $cols FROM searchme".
    251253        " WHERE cidr IN (SELECT block FROM noderef WHERE node_id=$webvar{node})";
    252254
     
    345347# 5) Invalid data which might be interpretable as an IP or something, but
    346348#    which probably shouldn't be for reasons of sanity.
    347 
    348   my $cols = "cidr,custid,type,city,description";
    349349
    350350  if ($category eq 'all') {
     
    469469  my $count = 0;
    470470  my @sresults;
    471   while (my ($block, $custid, $type, $city, $desc) = $sth->fetchrow_array) {
     471  while (my ($block, $custid, $type, $city, $desc, $id, $parent, $avail) = $sth->fetchrow_array) {
    472472    my %row = (
    473473        rowclass => $count++ % 2,
    474474        issub => ($type =~ /^.r$/ ? 1 : 0),
     475        ispool => ($type =~ /^.[pd]$/ ? 1 : 0),
     476        basetype => ($type =~ /^.i/ ? 'i' : 'b'),
     477        freeip => ($avail eq 'y'),
     478        parent => $parent,
    475479        block => $block,
    476         ispool => ($type =~ /^.[pd]$/ ? 1 : 0),
    477480        custid => $custid,
    478481        disptype => $disp_alloctypes{$type},
    479482        city => $city,
    480         desc => $desc
     483        desc => $desc,
     484        id => $id,
    481485        );
    482486    push @sresults, \%row;
Note: See TracChangeset for help on using the changeset viewer.