Changeset 15 for trunk/dns.cgi


Ignore:
Timestamp:
09/15/09 08:51:42 (15 years ago)
Author:
Kris Deugau
Message:

/trunk

checkpoint

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dns.cgi

    r13 r15  
    6161# default
    6262#my $perpage = 15;
    63 my $perpage = 4;
     63my $perpage = 3;
    6464my $offset = ($webvar{offset} ? $webvar{offset} : 0);
    6565
     
    7878initGlobals($dbh);
    7979
    80 # Default page is a login page
    81 my $page;       # to be initialized as an HTML::Template entity sooner or later
     80## Default page is a login page
     81#my $page;      # to be initialized as an HTML::Template entity sooner or later
    8282
    8383
    8484
    8585# decide which page to spit out...
    86 if (!$webvar{page}) {
    87   $page = HTML::Template->new(filename => "$templatedir/login.tmpl");
    88 } else {
    89   $page = HTML::Template->new(filename => "$templatedir/$webvar{page}.tmpl");
    90 }
     86$webvar{page} = 'login' if !$webvar{page};
     87#if (!$webvar{page}) {
     88#  $page = HTML::Template->new(filename => "$templatedir/login.tmpl");
     89#} else {
     90#}
     91
     92my $page = HTML::Template->new(filename => "$templatedir/$webvar{page}.tmpl");
    9193
    9294$page->param(sid => $sid);
     
    176178} elsif ($webvar{page} eq 'record') {
    177179  if ($webvar{recact} eq 'new') {
    178     $page->param(recact => "Add record to");
     180    $page->param(todo => "Add record to");
     181    $page->param(recact => "add");
    179182    stdrecs();
     183  } elsif ($webvar{recact} eq 'add') {
     184
     185    my @recargs = ($dbh,$webvar{defrec},$webvar{parentid},$webvar{name},$webvar{type},$webvar{address},$webvar{ttl});
     186    if ($webvar{type} == $reverse_typemap{MX} or $webvar{type} == $reverse_typemap{SRV}) {
     187      push @recargs, $webvar{distance};
     188      if ($webvar{type} == $reverse_typemap{SRV}) {
     189        push @recargs, $webvar{weight};
     190        push @recargs, $webvar{port};
     191      }
     192    }
     193  # wtf?
     194  #  push @recargs,
     195    my ($code,$msg) = addRec(@recargs);
     196
     197    if ($code eq 'OK') {
     198      changepage(page => "reclist", id => $webvar{parentid}, defrec => $webvar{defrec});
     199#      showdomain($webvar{defrec},$webvar{parentid});
     200  # NB: should **really** redirect here, in case of reload.  >_<  eyowch.
     201    } else {
     202      $page->param(add_failed => 1);
     203      $page->param(errmsg => $msg);
     204      stdrecs($webvar{type});   # populate the form... er, mostly.
     205      $page->param(name => $webvar{name});
     206      $page->param(address => $webvar{address});
     207      $page->param(distance => $webvar{distance})
     208        if ($webvar{type} == $reverse_typemap{MX} or $webvar{type} == $reverse_typemap{SRV});
     209      $page->param(weight => $webvar{weight}) if $webvar{type} == $reverse_typemap{SRV};
     210      $page->param(port => $webvar{port}) if $webvar{type} == $reverse_typemap{SRV};
     211    }
     212
     213    $page->param(defrec => $webvar{defrec});
     214
    180215  } elsif ($webvar{recact} eq 'edit') {
    181     $page->param(recact => "Edit record in");
     216
     217    $page->param(todo => "Edit record in");
    182218    my $sth = $dbh->prepare("SELECT host,type,val,distance,weight,port,ttl FROM ".
    183219        ($webvar{defrec} eq 'y' ? 'default_' : '')."records WHERE record_id=?");
     
    322358foreach (@debugbits) { print; }
    323359
    324 $page->param(grp => $group);
     360$page->param(grp => $group) if $webvar{page} ne 'login';
    325361
    326362# spit it out
Note: See TracChangeset for help on using the changeset viewer.