Changeset 272 for trunk/dns.cgi


Ignore:
Timestamp:
03/09/12 18:03:29 (13 years ago)
Author:
Kris Deugau
Message:

/trunk

Checkpoint; update record mostly patched up for reverse records.
See #26

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dns.cgi

    r270 r272  
    688688    $page->param(port           => $recdata->{port});
    689689    $page->param(ttl            => $recdata->{ttl});
    690     $page->param(typelist       => getTypelist($dbh, $webvar{revrec}, $webvar{type}));
     690    $page->param(typelist       => getTypelist($dbh, $webvar{revrec}, $recdata->{type}));
    691691
    692692  } elsif ($webvar{recact} eq 'update') {
     
    695695        unless ($permissions{admin} || $permissions{record_edit});
    696696
    697     # prevent out-of-domain records from getting added by appending the domain, or DOMAIN for default records
    698     my $pname = ($webvar{defrec} eq 'y' ? 'DOMAIN' : domainName($dbh,$webvar{parentid}));
    699     $webvar{name} =~ s/\.*$/\.$pname/ if $webvar{name} !~ /$pname$/;
     697#    # prevent out-of-domain records from getting added by appending the domain, or DOMAIN for default records
     698#    my $pname = ($webvar{defrec} eq 'y' ? 'DOMAIN' : domainName($dbh,$webvar{parentid}));
     699#    $webvar{name} =~ s/\.*$/\.$pname/ if $webvar{name} !~ /$pname$/;
    700700
    701701    # get current/previous record info so we can log "updated 'foo A 1.2.3.4' to 'foo A 2.3.4.5'"
    702702    my $oldrec = getRecLine($dbh, $webvar{defrec}, $webvar{revrec}, $webvar{id});
    703703
    704     my ($code,$msg) = updateRec($dbh,$webvar{defrec},$webvar{id},
    705         $webvar{name},$webvar{type},$webvar{address},$webvar{ttl},
     704    my ($code,$msg) = updateRec($dbh,$webvar{defrec},$webvar{revrec},$webvar{id},$webvar{parentid},
     705        \$webvar{name},\$webvar{type},\$webvar{address},$webvar{ttl},
    706706        $webvar{distance},$webvar{weight},$webvar{port});
    707707
    708     if ($code eq 'OK') {
    709 ##fixme: retrieve old record info for full logging of change
     708    if ($code eq 'OK' || $code eq 'WARN') {
     709      my $restr;
    710710      if ($webvar{defrec} eq 'y') {
    711         my $restr = "Updated default record from '$oldrec->{host} $typemap{$oldrec->{type}} $oldrec->{val}', TTL $oldrec->{ttl}\n".
     711        $restr = "Updated default record from '$oldrec->{host} $typemap{$oldrec->{type}} $oldrec->{val}', TTL $oldrec->{ttl}\n".
    712712                "to '$webvar{name} $typemap{$webvar{type}} $webvar{address}', TTL $webvar{ttl}";
    713713        logaction(0, $session->param("username"), $webvar{parentid}, $restr);
    714         changepage(page => "reclist", id => $webvar{parentid}, defrec => $webvar{defrec}, resultmsg => $restr);
    715714      } else {
    716         my $restr = "Updated record from '$oldrec->{host} $typemap{$oldrec->{type}} $oldrec->{val}', TTL $oldrec->{ttl}\n".
     715        $restr = "Updated record from '$oldrec->{host} $typemap{$oldrec->{type}} $oldrec->{val}', TTL $oldrec->{ttl}\n".
    717716                "to '$webvar{name} $typemap{$webvar{type}} $webvar{address}', TTL $webvar{ttl}";
    718717        logaction($webvar{parentid}, $session->param("username"),
     
    720719                        revrec => $webvar{revrec}, partype => 'group')),
    721720                $restr);
    722         changepage(page => "reclist", id => $webvar{parentid}, defrec => $webvar{defrec}, resultmsg => $restr);
    723       }
     721      }
     722      changepage(page => "reclist", id => $webvar{parentid}, defrec => $webvar{defrec},
     723        revrec => $webvar{revrec}, resultmsg => $restr, warnmsg => ($code ne 'OK' ? $msg : ''));
    724724    } else {
    725725      $page->param(failed       => 1);
     
    18081808  # than set them locally everywhere.
    18091809  foreach my $sessme ('resultmsg','warnmsg','errmsg') {
    1810     if ($params{$sessme}) {
     1810    if (my $tmp = $params{$sessme}) {
     1811      $tmp =~ s|\n|<br />\n|g;
    18111812      $session->param($sessme, $params{$sessme});
    18121813      delete $params{$sessme};
Note: See TracChangeset for help on using the changeset viewer.