Changeset 101 for trunk/DNSDB.pm


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

File:
1 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;
Note: See TracChangeset for help on using the changeset viewer.