Changeset 287 for trunk/DNSDB.pm


Ignore:
Timestamp:
03/26/12 16:59:08 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Move action logging for addRec() into DNSDB.pm. See #35

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r286 r287  
    25022502  my $vallen = '?'.(',?'x$#vallist);
    25032503
     2504  # Put together the success log entry.  We have to use this horrible kludge
     2505  # because domain_id and rdns_id may or may not be present, and if they are,
     2506  # they're not at a guaranteed consistent index in the array.  wheee!
     2507  my %logdata;
     2508  my @ftmp = split /,/, $fields;
     2509  for (my $i=0; $i <= $#vallist; $i++) {
     2510    $logdata{domain_id} = $vallist[$i] if $ftmp[$i] eq 'domain_id';
     2511    $logdata{rdns_id} = $vallist[$i] if $ftmp[$i] eq 'rdns_id';
     2512  }
     2513  $logdata{group_id} = $id if $defrec eq 'y';
     2514  $logdata{group_id} = parentID($dbh,
     2515                (id => $id, type => ($revrec eq 'n' ? 'domain' : 'revzone'), revrec => $revrec) )
     2516        if $defrec eq 'n';
     2517  $logdata{entry} = "Added ".($defrec eq 'y' ? 'default record' : 'record')." '$$host $typemap{$$rectype}";
     2518  $logdata{entry} .= " [distance $dist]" if $typemap{$$rectype} eq 'MX';
     2519  $logdata{entry} .= " [priority $dist] [weight $weight] [port $port]"
     2520        if $typemap{$$rectype} eq 'SRV';
     2521  $logdata{entry} .= " $$val', TTL $ttl";
     2522
    25042523  # Allow transactions, and raise an exception on errors so we can catch it later.
    25052524  # Use local to make sure these get "reset" properly on exiting this block
     
    25102529    $dbh->do("INSERT INTO "._rectable($defrec, $revrec)." ($fields) VALUES ($vallen)",
    25112530        undef, @vallist);
     2531    _log($dbh, %logdata);
    25122532    $dbh->commit;
    25132533  };
     
    25182538  }
    25192539
     2540  $resultstr = $logdata{entry};
    25202541  return ($retcode, $retmsg);
    25212542
Note: See TracChangeset for help on using the changeset viewer.