Changeset 15 for trunk


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

/trunk

checkpoint

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r13 r15  
    6868sub connectDB {
    6969  $errstr = '';
    70   my ($dbname,$user,$pass) = @_;
     70  my $dbname = shift;
     71  my $user = shift;
     72  my $pass = shift;
    7173  my $dbh;
    7274  my $DSN = "DBI:Pg:dbname=$dbname";
     
    385387  }
    386388  $sql .= " and not type=$reverse_typemap{SOA} order by $order";
     389##fixme:  need to set nstart properly (offset is not internally multiplied with limit)
    387390  $sql .= " limit $nrecs offset $nstart" if $nstart ne 'all';
    388391
     
    440443  my $sql = "insert into ".($defrec eq 'y' ? 'default_' : '')."records ($fields) values ($vallist)";
    441444# something is bugging me about this...
    442 print "DEBUG: $sql<br>\n";
     445#warn "DEBUG: $sql";
    443446  my $sth = $dbh->prepare($sql);
    444447  $sth->execute;
  • 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
  • trunk/templates/record.tmpl

    r14 r15  
    66
    77<TMPL_IF edit_failed><span class="errmsg">Error <TMPL VAR NAME=recact> record: <TMPL_VARNAME=errmsg></span></TMPL_IF>
    8 <form action="dns.cgi">
     8<form action="dns.cgi" method="POST">
    99<input type="hidden" name="page" value="record">
    1010<input type="hidden" name="defrec" value="<TMPL_VAR NAME=defrec>">
    1111<input type="hidden" name="sid" value="<TMPL_VAR NAME=sid>">
    1212<input type="hidden" name="parentid" value="<TMPL_VAR NAME=parentid>">
    13 
     13<input type="hidden" name="recact" value="<TMPL_VAR NAME=recact>">
    1414        <table border=0 bgcolor="white">
    1515
     
    1717
    1818        <table border=0 width="100%">
    19         <tr class="tableheader"><td align="center" colspan=2><TMPL_VAR NAME=recact> <TMPL_VAR NAME=domain></td></tr>
     19        <tr class="tableheader"><td align="center" colspan=2><TMPL_VAR NAME=todo> <TMPL_VAR NAME=domain></td></tr>
    2020        <tr class="datalinelight">
    2121                <td>Hostname</td>
Note: See TracChangeset for help on using the changeset viewer.