Changeset 101 for trunk


Ignore:
Timestamp:
07/06/11 17:17:46 (13 years ago)
Author:
Kris Deugau
Message:

/trunk

dns.cgi:

Prefill <domain> or DOMAIN in Hostname field on add record page
Set initial TTL correctly based on SOA record rather than hardcoded defaults

DNSDB.pm:

Tweak retrieval code to pull SOA's serial from distance field

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r94 r101  
    5858
    5959# Halfway sane defaults for SOA, TTL, etc.
     60# serial defaults to 0 for convenience.
     61# value will be either YYYYMMDDNN for BIND/etc, or auto-internal for tinydns
    6062our %def = qw (
    6163        contact hostmaster.DOMAIN
    6264        prins   ns1.myserver.com
     65        serial  0
    6366        soattl  86400
    6467        refresh 10800
     
    976979  my %ret;
    977980
    978   my $sql = "select record_id,host,val,ttl from";
     981  # (ab)use distance and weight columns to store SOA data
     982
     983  my $sql = "SELECT record_id,host,val,ttl,distance from";
    979984  if ($def eq 'def' or $def eq 'y') {
    980     $sql .= " default_records where group_id=$id and type=$reverse_typemap{SOA}";
     985    $sql .= " default_records WHERE group_id=? AND type=$reverse_typemap{SOA}";
    981986  } else {
    982987    # we're editing a live SOA record;  find based on domain
    983     $sql .= " records where domain_id=$id and type=$reverse_typemap{SOA}";
     988    $sql .= " records WHERE domain_id=? AND type=$reverse_typemap{SOA}";
    984989  }
    985990  my $sth = $dbh->prepare($sql);
    986   $sth->execute;
    987 
    988   my ($recid,$host,$val,$ttl) = $sth->fetchrow_array();
     991  $sth->execute($id);
     992
     993  my ($recid,$host,$val,$ttl,$serial) = $sth->fetchrow_array();
    989994  my ($prins,$contact) = split /:/, $host;
    990995  my ($refresh,$retry,$expire,$minttl) = split /:/, $val;
     
    992997  $ret{recid}   = $recid;
    993998  $ret{ttl}     = $ttl;
     999  $ret{serial}  = $serial;
    9941000  $ret{prins}   = $prins;
    9951001  $ret{contact} = $contact;
  • trunk/dns.cgi

    r98 r101  
    3737
    3838my @debugbits;  # temp, to be spit out near the end of processing
    39 my $debugenv = 1;
     39my $debugenv = 0;
    4040
    4141# Let's do these templates right...
     
    12691269  no warnings qw( uninitialized );
    12701270
    1271   $page->param(name     => $webvar{name});
     1271##todo:  allow BIND-style bare names, ASS-U-ME that the name is within the domain?
     1272# prefill <domain> or DOMAIN in "Host" space for new records
     1273  my $domroot = ($webvar{defrec} eq 'y' ? 'DOMAIN' : domainName($dbh,$webvar{parentid}));
     1274  $page->param(name     => $domroot);
    12721275  $page->param(address  => $webvar{address});
    12731276  $page->param(distance => $webvar{distance})
     
    12751278  $page->param(weight   => $webvar{weight}) if $webvar{type} == $reverse_typemap{SRV};
    12761279  $page->param(port     => $webvar{port}) if $webvar{type} == $reverse_typemap{SRV};
    1277   $page->param(ttl      => ($webvar{ttl} ? $webvar{ttl} : $DNSDB::def{minttl}));
     1280# retrieve the right ttl instead of falling (way) back to the hardcoded system default
     1281  my %soa = getSOA($dbh,$webvar{defrec},$webvar{parentid});
     1282  $page->param(ttl      => ($webvar{ttl} ? $webvar{ttl} : $soa{minttl}));
    12781283}
    12791284
     
    16771682
    16781683##fixme: push SQL into DNSDB.pm
     1684##fixme: add bits to retrieve group/domain name info to retain after entity is deleted?
    16791685  my $sth = $dbh->prepare("SELECT user_id, firstname || ' ' || lastname FROM users WHERE username=?");
    16801686  $sth->execute($username);
Note: See TracChangeset for help on using the changeset viewer.