Changeset 371 for trunk/cgi-bin/search.cgi
- Timestamp:
- 11/27/07 12:27:45 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/search.cgi
r370 r371 279 279 # which probably shouldn't be for reasons of sanity. 280 280 281 my $cols = "cidr,custid,type,city,description"; 282 281 283 if ($category eq 'all') { 282 284 283 285 print qq(<div class="heading">Showing all netblock and static-IP allocations</div><br>\n); 284 $sql = "select *from searchme";286 $sql = "select $cols from searchme"; 285 287 my $count = countRows($sql); 286 288 $sql .= " order by cidr limit $RESULTS_PER_PAGE offset $offset"; … … 293 295 # Query for a customer ID. Note that we can't restrict to "numeric-only" 294 296 # as we have non-numeric custIDs in the legacy data. :/ 295 $sql = "select *from searchme where custid ilike '%$query%' or oldcustid ilike '%$query%'";297 $sql = "select $cols from searchme where custid ilike '%$query%' or oldcustid ilike '%$query%'"; 296 298 my $count = countRows($sql); 297 299 $sql .= " order by cidr limit $RESULTS_PER_PAGE offset $offset"; … … 302 304 print qq(<div class="heading">Searching for descriptions containing '$query'</div><br>\n); 303 305 # Query based on description (includes "name" from old DB). 304 $sql = "select *from searchme where description ilike '%$query%'".306 $sql = "select $cols from searchme where description ilike '%$query%'". 305 307 " or custid ilike '%$query%'"; 306 308 my $count = countRows($sql); … … 320 322 # /0->/9 are silly to worry about right now. I don't think 321 323 # we'll be getting a class A anytime soon. <g> 322 $sql = "select *from searchme where cidr='$query'";324 $sql = "select $cols from searchme where cidr='$query'"; 323 325 queryResults($sql, $webvar{page}, 1); 324 326 } else { 325 327 #print "Finding all blocks with netmask /$maskbits, leading octet(s) $net<br>\n"; 326 328 # Partial match; beginning of subnet and maskbits are provided 327 $sql = "select *from searchme where text(cidr) like '$net%' and ".329 $sql = "select $cols from searchme where text(cidr) like '$net%' and ". 328 330 "text(cidr) like '%$maskbits'"; 329 331 my $count = countRows($sql); … … 336 338 my ($net,$ip) = ($query =~ /(\d{1,3}\.\d{1,3}\.\d{1,3}\.)(\d{1,3})/); 337 339 my $sfor = new NetAddr::IP $query; 338 $sth = $ip_dbh->prepare("select *from searchme where text(cidr) like '$net%'");340 $sth = $ip_dbh->prepare("select $cols from searchme where text(cidr) like '$net%'"); 339 341 $sth->execute; 340 342 while (my @data = $sth->fetchrow_array()) { 341 343 my $cidr = new NetAddr::IP $data[0]; 342 344 if ($cidr->contains($sfor)) { 343 queryResults("select *from searchme where cidr='$cidr'", $webvar{page}, 1);345 queryResults("select $cols from searchme where cidr='$cidr'", $webvar{page}, 1); 344 346 } 345 347 } 346 348 } elsif ($query =~ /^(\d{1,3}\.){1,3}\d{1,3}\.?$/) { 347 349 #print "Finding matches with leading octet(s) $query<br>\n"; 348 $sql = "select *from searchme where text(cidr) like '$query%'";350 $sql = "select $cols from searchme where text(cidr) like '$query%'"; 349 351 my $count = countRows($sql); 350 352 $sql .= " order by cidr limit $RESULTS_PER_PAGE offset $offset";
Note:
See TracChangeset
for help on using the changeset viewer.