Changeset 426 for trunk


Ignore:
Timestamp:
10/11/12 15:15:58 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Fix up addRec, updateRec, and delRec in dns-rpc.cgi. See #43.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dns-rpc.cgi

    r416 r426  
    356356  _commoncheck(\%args, 'y');
    357357
     358  # add records in the zone's default location if none is specified
     359  if (!$args{location} && $args{defrec} eq 'n') {
     360    $args{location} = DNSDB::getZoneLocation($dbh, $args{revrec}, $args{parent_id});
     361  }
     362
     363  my @recargs = ($dbh, $args{defrec}, $args{revrec}, $args{parent_id},
     364        \$args{name}, \$args{type}, \$args{address}, $args{ttl}, $args{location});
     365  if ($args{type} == $DNSDB::reverse_typemap{MX} or $args{type} == $DNSDB::reverse_typemap{SRV}) {
     366    push @recargs, $args{distance};
     367    if ($args{type} == $DNSDB::reverse_typemap{SRV}) {
     368      push @recargs, $args{weight};
     369      push @recargs, $args{port};
     370    }
     371  }
     372
     373  my ($code, $msg) = DNSDB::addRec(@recargs);
     374
     375  die $msg if $code eq 'FAIL';
     376  return $msg;
     377}
     378
     379sub updateRec {
     380  my %args = @_;
     381
     382  _commoncheck(\%args, 'y');
     383
    358384  # note dist, weight, port are not required on all types;  will be ignored if not needed.
    359   my ($code, $msg) = DNSDB::addRec($dbh, $args{def}, $args{domid}, $args{host}, $DNSDB::typemap{$args{type}},
    360         $args{val}, $args{ttl}, $args{dist}, $args{weight}, $args{port});
    361 
    362   die $msg if $code eq 'FAIL';
    363 }
    364 
    365 sub updateRec {
    366   my %args = @_;
    367 
    368   _commoncheck(\%args, 'y');
    369 
    370   # note dist, weight, port are not required on all types;  will be ignored if not needed.
    371   my ($code, $msg) = DNSDB::updateRec($dbh, $args{def}, $args{recid}, $args{host}, $DNSDB::typemap{$args{type}},
    372         $args{val}, $args{ttl}, $args{dist}, $args{weight}, $args{port});
    373 
    374   die $msg if $code eq 'FAIL';
     385  # parent_id is the "primary" zone we're updating;  necessary for forward/reverse voodoo
     386  my ($code, $msg) = DNSDB::updateRec($dbh, $args{defrec}, $args{revrec}, $args{id}, $args{parent_id},
     387        \$args{name}, \$args{type}, \$args{address}, $args{ttl}, $args{location},
     388        $args{distance}, $args{weight}, $args{port});
     389
     390  die $msg if $code eq 'FAIL';
     391  return $msg;
    375392}
    376393
     
    380397  _commoncheck(\%args, 'y');
    381398
    382   my ($code, $msg) = DNSDB::delRec($dbh, $args{def}, $args{recid});
    383 
    384   die $msg if $code eq 'FAIL';
     399  my ($code, $msg) = DNSDB::delRec($dbh, $args{defrec}, $args{recrev}, $args{id});
     400
     401  die $msg if $code eq 'FAIL';
     402  return $msg;
    385403}
    386404
Note: See TracChangeset for help on using the changeset viewer.