Changeset 584 for trunk


Ignore:
Timestamp:
01/03/14 15:16:16 (11 years ago)
Author:
Kris Deugau
Message:

/trunk

Extend reverse-notation search matching to record list.

Note that this causes both the zone and record list searches to turn
up more entries than you might expect for a given search (n.m) as it
will match on both direct n.m and inverse m.n entries.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r583 r584  
    36373637  my %args = @_;
    36383638
    3639   my @filterargs;
    3640 
    3641   push @filterargs, $args{filter} if $args{filter};
    3642 
    36433639  # protection against bad or missing arguments
    36443640  $args{sortorder} = 'ASC' if !$args{sortorder} || !grep /^$args{sortorder}$/, ('ASC','DESC');
     
    36653661  $newsort =~ s/^,//;
    36663662
     3663  my @bindvars = ($args{id});
     3664  push @bindvars, ($args{filter},$args{filter}) if $args{filter};
     3665
    36673666##fixme:  do we need a knob to twist to switch from unix epoch to postgres time string?
    36683667  my $sql = "SELECT r.record_id,r.host,r.type,r.val,r.ttl";
     
    36753674  $sql .= "WHERE "._recparent($args{defrec},$args{revrec})." = ?";
    36763675  $sql .= " AND NOT r.type=$reverse_typemap{SOA}";
    3677   $sql .= " AND (r.host ~* ? OR r.val ~* ?)" if $args{filter};
     3676#    if ($self->{showrev_arpa} eq 'zone' || $self->{showrev_arpa} eq 'all') {
     3677      # Just In Case the UI is using formal .arpa notation, and someone enters something reversed,
     3678      # we want to match both the formal and natural zone name
     3679      $sql .= " AND (r.host ~* ? OR r.val ~* ? OR r.host ~* ? OR r.val ~* ?)" if $args{filter};
     3680      my $tmp = join('.',reverse(split(/\./,$args{filter})));
     3681      push @bindvars, ($tmp, $tmp) if $args{filter};
     3682#    } else {
     3683#      $sql .= " AND (r.host ~* ? OR r.val ~* ?)" if $args{filter};
     3684#    }
    36783685  $sql .= " ORDER BY $newsort $args{sortorder}";
    36793686  # ensure consistent ordering by sorting on record_id too
    36803687  $sql .= ", record_id $args{sortorder}";
    36813688  $sql .= ($args{offset} eq 'all' ? '' : " LIMIT $perpage OFFSET ".$args{offset}*$perpage);
    3682 
    3683   my @bindvars = ($args{id});
    3684   push @bindvars, ($args{filter},$args{filter}) if $args{filter};
    36853689
    36863690  my @working;
     
    37173721
    37183722  my @bindvars = ($id);
    3719   push @bindvars, $filter if $filter;
     3723  push @bindvars, ($filter,$filter) if $filter;
    37203724  my $sql = "SELECT count(*) FROM ".
    37213725        _rectable($defrec,$revrec).
    37223726        " WHERE "._recparent($defrec,$revrec)."=? ".
    3723         "AND NOT type=$reverse_typemap{SOA}".
    3724         ($filter ? " AND host ~* ?" : '');
     3727        "AND NOT type=$reverse_typemap{SOA}";
     3728#    if ($self->{showrev_arpa} eq 'zone' || $self->{showrev_arpa} eq 'all') {
     3729      # Just In Case the UI is using formal .arpa notation, and someone enters something reversed,
     3730      # we want to match both the formal and natural zone name
     3731      $sql .= " AND (host ~* ? OR val ~* ? OR host ~* ? OR val ~* ?)" if $filter;
     3732      my $tmp = join('.',reverse(split(/\./,$filter)));
     3733      push @bindvars, ($tmp, $tmp) if $filter;
     3734#    } else {
     3735#      $sql .= " AND (host ~* ? OR val ~* ?)" if $filter;
     3736#    }
     3737
    37253738  my ($count) = $dbh->selectrow_array($sql, undef, (@bindvars) );
    37263739
Note: See TracChangeset for help on using the changeset viewer.