Changeset 287


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

/trunk

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

Location:
trunk
Files:
2 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
  • trunk/dns.cgi

    r286 r287  
    677677
    678678    if ($code eq 'OK' || $code eq 'WARN') {
    679       my $restr;
    680       if ($webvar{defrec} eq 'y') {
    681         $restr = "Added default record '$webvar{name} $typemap{$webvar{type}}";
    682         $restr .= " [distance $webvar{distance}]" if $typemap{$webvar{type}} eq 'MX';
    683         $restr .= " [priority $webvar{distance}] [weight $webvar{weight}] [port $webvar{port}]"
    684                 if $typemap{$webvar{type}} eq 'SRV';
    685         $restr .= " $webvar{address}', TTL $webvar{ttl}";
    686         logaction(0, $session->param("username"), $webvar{parentid}, $restr);
    687       } else {
    688         $restr = "Added record '$webvar{name} $typemap{$webvar{type}}";
    689         $restr .= " [distance $webvar{distance}]" if $typemap{$webvar{type}} eq 'MX';
    690         $restr .= " [priority $webvar{distance}] [weight $webvar{weight}] [port $webvar{port}]"
    691                 if $typemap{$webvar{type}} eq 'SRV';
    692         $restr .= " $webvar{address}', TTL $webvar{ttl}";
    693         logaction($webvar{parentid}, $session->param("username"),
    694                 parentID($dbh, (id => $webvar{parentid}, type => 'domain', revrec => $webvar{revrec})), $restr);
    695       }
    696679      my %pageparams = (page => "reclist", id => $webvar{parentid},
    697680        defrec => $webvar{defrec}, revrec => $webvar{revrec});
    698       $pageparams{warnmsg} = $msg."<br><br>\n".$restr if $code eq 'WARN';
    699       $pageparams{resultmsg} = $restr if $code eq 'OK';
     681      $pageparams{warnmsg} = $msg."<br><br>\n".$DNSDB::resultstr if $code eq 'WARN';
     682      $pageparams{resultmsg} = $DNSDB::resultstr if $code eq 'OK';
    700683      changepage(%pageparams);
    701684    } else {
Note: See TracChangeset for help on using the changeset viewer.