Changeset 420


Ignore:
Timestamp:
10/10/12 13:24:53 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Add a somewhat quick-n-dirty plaintext record list script that
generates a list suitable for copy-pasting. Also note, the
records are formatted to be pasteable directly into BIND zone
files, and anything else that can understand BIND-formatted
records.

Location:
trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r418 r420  
    33773377  # sort reverse zones on IP, correctly
    33783378  # do other fiddling with $args{sortby} while we're at it.
    3379   $args{sortby} = "r.$args{sortby}";
    3380   $args{sortby} = 'CAST (r.val AS inet)'
    3381         if $args{revrec} eq 'y' && $args{defrec} eq 'n' && $args{sortby} eq 'r.val';
    3382   $args{sortby} = 't.alphaorder' if $args{sortby} eq 'r.type';
     3379  # whee!  multisort means just passing comma-separated fields in sortby!
     3380  my $newsort = '';
     3381  foreach my $sf (split /,/, $args{sortby}) {
     3382    $sf = "r.$sf";
     3383    $sf =~ s/r\.val/CAST (r.val AS inet)/
     3384        if $args{revrec} eq 'y' && $args{defrec} eq 'n';
     3385    $sf =~ s/r\.type/t.alphaorder/;
     3386    $newsort .= ",$sf";
     3387  }
     3388  $newsort =~ s/^,//;
    33833389
    33843390  my $sql = "SELECT r.record_id,r.host,r.type,r.val,r.ttl";
     
    33913397  $sql .= " AND NOT r.type=$reverse_typemap{SOA}";
    33923398  $sql .= " AND host ~* ?" if $args{filter};
    3393   $sql .= " ORDER BY $args{sortby} $args{sortorder}";
     3399  $sql .= " ORDER BY $newsort $args{sortorder}";
    33943400  # ensure consistent ordering by sorting on record_id too
    33953401  $sql .= ", record_id $args{sortorder}";
  • trunk/templates/reclist.tmpl

    r397 r420  
    4040</tr>
    4141<tr class="darkrowheader">
    42         <td colspan="4">Records</td>
     42        <td colspan="3">Records</td>
     43        <td align="center"><a href="textrecs.cgi?sid=<TMPL_VAR NAME=sid>&amp;id=<TMPL_VAR NAME=id>&amp;defrec=<TMPL_VAR NAME=defrec>&amp;revrec=<TMPL_VAR NAME=revrec>">Plain text</a></td>
    4344<TMPL_IF record_create> <td align="right"><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&amp;page=record&amp;parentid=<TMPL_VAR NAME=id>&amp;defrec=<TMPL_VAR NAME=defrec>&amp;revrec=<TMPL_VAR NAME=revrec>&amp;recact=new">Add record</a></td></TMPL_IF>
    4445        <td align="right"><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&amp;page=log&amp;id=<TMPL_VAR NAME=id><TMPL_IF logdom>&amp;ltype=dom</TMPL_IF><TMPL_IF logrdns>&amp;ltype=rdns</TMPL_IF>">View log</a></td>
Note: See TracChangeset for help on using the changeset viewer.