Changeset 722 for trunk


Ignore:
Timestamp:
06/13/16 16:06:41 (8 years ago)
Author:
Kris Deugau
Message:

/trunk

Checkpoint adding global record search. See #57.

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r720 r722  
    48824882  return $loglist;
    48834883} # end getLogEntries()
     4884
     4885
     4886## DNSDB::recSearchCount()
     4887# Get a total count for a global record search
     4888## DNSDB::recSearch()
     4889# Find records matching the search string
     4890sub recSearch {
     4891  my $self = shift;
     4892  my $dbh = $self->{dbh};
     4893
     4894  my %args = @_;
     4895
     4896my $sql = q(
     4897SELECT r.domain_id,d.domain,g1.group_name AS domgroup,r.rdns_id,z.revnet AS revzone,g2.group_name AS
     4898revgroup,r.host,t.name AS rectype,r.val,l.description AS location
     4899FROM records r
     4900LEFT JOIN domains d ON r.domain_id = d.domain_id
     4901  LEFT JOIN groups g1 ON d.group_id = g1.group_id
     4902LEFT JOIN revzones z ON r.rdns_id = z.rdns_id
     4903  LEFT JOIN groups g2 on z.group_id = g2.group_id
     4904JOIN rectypes t ON r.type = t.val
     4905LEFT JOIN locations l ON r.location = l.location
     4906WHERE r.type <> 6 AND (r.host ~* ? OR r.val ~* ?)
     4907);
     4908
     4909# Limit scope based on group
     4910if ($args{group} != 1) {
     4911  my @grouplist;
     4912  $self->getChildren($args{group}, \@grouplist);
     4913  my $groupset = join(',', $args{group}, @grouplist);
     4914  # oh my aching HEAD.  there has to be a better way to do conditions on joined tables...
     4915  $sql .= "AND (
     4916  (g1.group_id IN ($groupset) AND g2.group_id IN ($groupset)) OR
     4917  (g1.group_id IN ($groupset) AND g2.group_id IS NULL) OR
     4918  (g1.group_id IS NULL AND g2.group_id IN ($groupset))
     4919  )
     4920";
     4921}
     4922
     4923my $foo = q(
     4924SELECT r.domain_id,d.domain,g1.group_name AS domgroup,r.rdns_id,z.revnet AS revzone,g2.group_name AS
     4925revgroup,r.host,t.name AS rectype,r.val,l.description AS location
     4926FROM records r
     4927LEFT JOIN domains d on r.domain_id = d.domain_id
     4928  LEFT JOIN groups g1 on d.group_id = g1.group_id
     4929LEFT JOIN revzones z on r.rdns_id = z.rdns_id
     4930  LEFT JOIN groups g2 on z.group_id = g2.group_id
     4931JOIN rectypes t ON r.type = t.val
     4932LEFT JOIN locations l ON r.location = l.location
     4933WHERE r.type <> 6 AND (r.host ~* 'kings' OR r.val ~* 'kings');
     4934);
     4935#ORDER BY record_id
     4936
     4937#warn "$sql\n";
     4938# safety valve.  probably need a way to flag this back to the caller.
     4939if (!$args{searchfor} || $args{searchfor} =~ /^.{0,2}$/) { $sql .= "LIMIT 10"; }
     4940
     4941#$sql .= "LIMIT 20" if $sql !~ /LIMIT/;
     4942
     4943  return $dbh->selectall_arrayref($sql, { Slice => {} }, $args{searchfor}, $args{searchfor}) or warn $dbh->errstr;
     4944} # end recSearch()
    48844945
    48854946
  • trunk/dns.cgi

    r709 r722  
    18591859  DONELOG: ;
    18601860
     1861} elsif ($webvar{page} eq 'recsearch') {
     1862
     1863##FIXME
     1864##FIXME  Limit scope of search!!
     1865##FIXME
     1866
     1867#  my $count = $dnsdb->recSearchCount(searchfor => $webvar{searchfor});
     1868
     1869  $page->param(searchfor => $webvar{searchfor});
     1870  my $recset = $dnsdb->recSearch(searchfor => $webvar{searchfor}, group => $logingroup);
     1871  $page->param(searchresults => $recset);
     1872
    18611873} # end $webvar{page} dance
    18621874
  • trunk/templates/dns.css

    r590 r722  
    3636        background-color: #F0F0F0;
    3737}
     38
     39/* Alternating row colours, now in CSS */
     40.altrows > tbody > tr {
     41        background-color: #D0E0E0;
     42}
     43.altrows > tbody > tr:nth-child(odd) {
     44        background-color: #FFFFFF;
     45}
     46.altrows > tbody > tr:nth-child(even) {
     47        background-color: #DDDDDD;
     48}
     49
    3850.container {
    3951        background-color: #FFFFFF;
  • trunk/templates/menu.tmpl

    r638 r722  
    3131<!-- hmm:  <TMPL_VAR NAME=groupname> -->
    3232<hr />
     33Find records(s):
     34<form action="<TMPL_VAR NAME=script_self>&amp;page=recsearch" method="POST">
     35<input name="searchfor" />
     36<input type="submit" value=" Search " />
     37</form>
     38<hr />
    3339<a href="<TMPL_VAR NAME=script_self>&amp;page=dnsq">DNS Query</a><br />
    3440<a href="<TMPL_VAR NAME=script_self>&amp;page=whoisq">WHOIS Query</a><br />
Note: See TracChangeset for help on using the changeset viewer.