Changeset 4 for trunk


Ignore:
Timestamp:
08/31/09 16:16:27 (15 years ago)
Author:
Kris Deugau
Message:

/trunk

checkpoint

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r3 r4  
    362362  my $type = shift;
    363363  my $id = shift;
     364  my $nrecs = shift || 'all';
     365  my $nstart = shift || 0;
     366
     367## for order, need to map input to column names
     368  my $order = shift || 'host';
    364369
    365370  my $sql = "select record_id,host,type,val,distance,weight,port,ttl from";
     
    369374    $sql .= " records where domain_id=$id";
    370375  }
    371   $sql .= " and not type=$reverse_typemap{SOA}";
     376  $sql .= " and not type=$reverse_typemap{SOA} order by $order";
     377  $sql .= " limit $nrecs offset $nstart" if $nstart ne 'all';
     378
    372379  my $sth = $dbh->prepare($sql);
    373380  $sth->execute;
  • trunk/dns.cgi

    r3 r4  
    6060my $footer = HTML::Template->new(filename => "$templatedir/footer.tmpl");
    6161
     62## hmm.  may want to move this so we can redirect after adding/deleting/etc
    6263print "Content-type: text/html\n\n", $header->output;
    6364
     
    136137        ( (($offset+1)*$perpage) > $count ? $count : (($offset+1)*$perpage) )
    137138        ));
     139##fixme
     140  $page->param(id => 1);
    138141  my @domlist;
    139142  $sth = $dbh->prepare("select domain_id,domain,status,groups.name from domains".
     
    160163} elsif ($webvar{page} eq 'reclist') {
    161164
    162 #} elsif ($webvar{page} eq 'domdetail') {
     165  # Handle record list for both default records (per-group) and live domain records
    163166
    164167  $page->param(defrec => $webvar{defrec});
     168  $page->param(id => $webvar{id});
     169  $page->param(curpage => 'reclist');
     170
     171# select count(*) from (default_)?records where (group|domain)_id=?
     172    my $sth = $dbh->prepare("SELECT count(*) FROM ".
     173        ($webvar{defrec} eq 'y' ? 'default_' : '')."records ".
     174        "WHERE ".($webvar{defrec} eq 'y' ? 'group' : 'domain')."_id=? ".
     175        "AND NOT type=$reverse_typemap{SOA}");
     176    $sth->execute($webvar{id});
     177    my ($count) = ($sth->fetchrow_array);
     178
     179  $page->param(ntot => $count);
     180  $page->param(nfirst => 1);
     181  $page->param(nlast => 10);
     182
     183##fixme
     184  if ($offset eq 'all') {
     185    print "foo!  wanna see'em all\n";
     186  } else {
     187    # all these bits only have sensible behaviour if offset is numeric. err, probably.
     188    if ($count > $perpage) {
     189      # if there are more results than the default, always show the "all" link
     190      $page->param(navall => 1);
     191
     192      if ($offset > 0) {
     193        $page->param(navfirst => 1);
     194        $page->param(navprev => 1);
     195        $page->param(prevoffs => $offset-1);
     196      }
     197
     198      # show "next" and "last" links if we're not on the last page of results
     199      if ( (($offset+1) * $perpage - $count) < 0 ) {
     200        $page->param(navnext => 1);
     201        $page->param(nextoffs => $offset+1);
     202        $page->param(navlast => 1);
     203        $page->param(lastoffs => int $count/$perpage);
     204      }
     205    }
     206  }
    165207
    166208##fixme
    167209  $page->param(domain => domainName($dbh,$webvar{id}));
    168   $page->param(grpid => 1);
     210  $page->param(id => $webvar{id});
    169211##fixme
    170212
     213  $page->param(defrec => $webvar{defrec});
    171214  if ($webvar{defrec} eq 'y') {
    172     $page->param(id => $webvar{grpid}); ##fixme, hack! hack!
    173215    showdomain('y',1);
    174216  } else {
    175     $page->param(id => $webvar{id});
    176217    showdomain('n',$webvar{id});
    177218  }
    178219
    179 } elsif ($webvar{page} eq 'defrecs') {
    180 
    181   showdomain('def',1);
    182   $page->param(defrec => 'y');
    183 
    184   my $sth = $dbh->prepare("select * from default_records");
    185   $sth->execute;
    186 print "<pre>\n";
    187   while (my @data = $sth->fetchrow_array) {
    188     foreach (@data) { print; print "\t" };
    189     print "\n";
    190   }
    191 print "</pre>\n";
    192 
    193220} elsif ($webvar{page} eq 'newdomain') {
     221
    194222  # weesa gonna discard parent_group_id for now
    195223  my $sth = $dbh->prepare("select group_id,parent_group_id,name from groups order by group_id");
     
    214242
    215243} elsif ($webvar{page} eq 'addrec') {
    216   print "wanna add<br>DEBUG: $webvar{parentid}<br>\n";
    217244
    218245  my @recargs = ($dbh,$webvar{defrec},$webvar{parentid},$webvar{name},$webvar{type},$webvar{address},$webvar{ttl});
     
    251278  my @tmp = getrecdata($dbh,$webvar{id},$webvar{defrec});
    252279
    253  
    254280} elsif ($webvar{page} eq 'delrec') {
    255281
     
    400426  $page->param(ttl      => $soa{ttl});
    401427
     428##fixme!
     429my $roffset = 0;
     430
    402431#  my @foo2 = getDomRecs($dbh,'def',1);
    403   my $foo2 = getDomRecs($dbh,$def,$id);
     432  my $foo2 = getDomRecs($dbh,$def,$id,$perpage,$webvar{offset});
     433
     434#  $sth = $dbh->prepare("select domain_id,domain,status,groups.name from domains".
     435#       " inner join groups on domains.group_id=groups.group_id".
     436#       " order by domain".($offset eq 'all' ? '' : " limit $perpage offset ".$offset*$perpage));
     437#  $sth->execute;
     438#  my $rownum = 0;
     439#  while (my @data = $sth->fetchrow_array) {
     440#    my %row;
     441#    $row{domainid} = $data[0];
     442#    $row{domain} = $data[1];
     443#    $row{status} = ($data[2] ? 'Active' : 'Inactive');
     444#    $row{group} = $data[3];
     445#    $row{bg} = ($rownum++)%2;
     446##    $row{mkactive} = ($data[2] eq 'inactive' ? 1 : 0);
     447#    $row{mkactive} = !$data[2];
     448#    $row{sid} = $sid;
     449#    $row{offset} = $offset;
    404450
    405451  my $row = 0;
     
    434480    $page->param(parentid => 1);
    435481  } else {
     482print "DEBUG: foobar:  parentid $webvar{parentid}<br>\n";
    436483    $page->param(parentid => $webvar{parentid});
    437484  }
  • trunk/templates/domlist.tmpl

    r3 r4  
    4242        <td width="1%" nowrap><TMPL_VAR name=group></td>
    4343        <td width="1%" nowrap align=center><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=domlist<TMPL_IF NAME=offset>&offset=<TMPL_VAR NAME=offset></TMPL_IF>&id=<TMPL_VAR NAME=domainid>&action=<TMPL_IF NAME=mkactive>domon<TMPL_ELSE>domoff</TMPL_IF>"><TMPL_IF NAME=mkactive>activate<TMPL_ELSE>deactivate</TMPL_IF></a></td>
    44         <td width="1%" nowrap align=center><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=del&id=<TMPL_VAR NAME=domainid>&defrec=w"><img src="images/trash2.png" border=0></a></td>
     44        <td width="1%" nowrap align=center><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=deldom&id=<TMPL_VAR NAME=domainid>&defrec=w"><img src="images/trash2.png" border=0></a></td>
    4545</tr>
    4646</TMPL_LOOP>
  • trunk/templates/fpnla.tmpl

    r2 r4  
    1 <TMPL_IF navfirst><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=<TMPL_VAR NAME=curpage>&offset=0"><img src="images/frev.png" border=0>first</a><TMPL_ELSE><img src="images/frev.png" border=0>first</TMPL_IF>&nbsp;
    2 <TMPL_IF navprev><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=<TMPL_VAR NAME=curpage>&offset=<TMPL_VAR NAME=prevoffs>"><img src="images/rev.png" border=0>previous</a><TMPL_ELSE><img src="images/rev.png" border=0>previous</TMPL_IF>&nbsp;
    3 <TMPL_IF navnext><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=<TMPL_VAR NAME=curpage>&offset=<TMPL_VAR NAME=nextoffs>">next<img src="images/fwd.png" border=0></a><TMPL_ELSE>next<img src="images/fwd.png" border=0></TMPL_IF>&nbsp;
    4 <TMPL_IF navlast><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=<TMPL_VAR NAME=curpage>&offset=<TMPL_VAR NAME=lastoffs>">last<img src="images/ffwd.png" border=0></a><TMPL_ELSE>last<img src="images/ffwd.png" border=0></TMPL_IF>&nbsp;
    5 <TMPL_IF navall><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=<TMPL_VAR NAME=curpage>">all</a><TMPL_ELSE>all</TMPL_IF>
     1<TMPL_IF navfirst><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=<TMPL_VAR NAME=curpage>&offset=0<TMPL_IF id>&id=<TMPL_VAR NAME=id></TMPL_IF><TMPL_IF defrec>&defrec=<TMPL_VAR NAME=defrec></TMPL_IF>"><img src="images/frev.png" border=0>first</a><TMPL_ELSE><img src="images/frev.png" border=0>first</TMPL_IF>&nbsp;
     2<TMPL_IF navprev><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=<TMPL_VAR NAME=curpage>&offset=<TMPL_VAR NAME=prevoffs><TMPL_IF id>&id=<TMPL_VAR NAME=id></TMPL_IF><TMPL_IF defrec>&defrec=<TMPL_VAR NAME=defrec></TMPL_IF>"><img src="images/rev.png" border=0>previous</a><TMPL_ELSE><img src="images/rev.png" border=0>previous</TMPL_IF>&nbsp;
     3<TMPL_IF navnext><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=<TMPL_VAR NAME=curpage>&offset=<TMPL_VAR NAME=nextoffs><TMPL_IF id>&id=<TMPL_VAR NAME=id></TMPL_IF><TMPL_IF defrec>&defrec=<TMPL_VAR NAME=defrec></TMPL_IF>">next<img src="images/fwd.png" border=0></a><TMPL_ELSE>next<img src="images/fwd.png" border=0></TMPL_IF>&nbsp;
     4<TMPL_IF navlast><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=<TMPL_VAR NAME=curpage>&offset=<TMPL_VAR NAME=lastoffs><TMPL_IF id>&id=<TMPL_VAR NAME=id></TMPL_IF><TMPL_IF defrec>&defrec=<TMPL_VAR NAME=defrec></TMPL_IF>">last<img src="images/ffwd.png" border=0></a><TMPL_ELSE>last<img src="images/ffwd.png" border=0></TMPL_IF>&nbsp;
     5<TMPL_IF navall><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=<TMPL_VAR NAME=curpage>&offset=all<TMPL_IF id>&id=<TMPL_VAR NAME=id></TMPL_IF><TMPL_IF defrec>&defrec=<TMPL_VAR NAME=defrec></TMPL_IF>">all</a><TMPL_ELSE>all</TMPL_IF>
  • trunk/templates/menu.tmpl

    r2 r4  
    44<a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=useradmin">Users</a><br />
    55<a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=log">Log</a><br />
    6 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=reclist&grpid=<TMPL_VAR NAME=grpid>&defrec=y">Default Records</a><br />
     6<a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=reclist&id=<TMPL_VAR NAME=id>&defrec=y">Default Records</a><br />
    77<a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=axfr">AXFR Import</a><br />
    88<hr>
Note: See TracChangeset for help on using the changeset viewer.