- Timestamp:
- 08/31/09 16:16:27 (15 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r3 r4 362 362 my $type = shift; 363 363 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'; 364 369 365 370 my $sql = "select record_id,host,type,val,distance,weight,port,ttl from"; … … 369 374 $sql .= " records where domain_id=$id"; 370 375 } 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 372 379 my $sth = $dbh->prepare($sql); 373 380 $sth->execute; -
trunk/dns.cgi
r3 r4 60 60 my $footer = HTML::Template->new(filename => "$templatedir/footer.tmpl"); 61 61 62 ## hmm. may want to move this so we can redirect after adding/deleting/etc 62 63 print "Content-type: text/html\n\n", $header->output; 63 64 … … 136 137 ( (($offset+1)*$perpage) > $count ? $count : (($offset+1)*$perpage) ) 137 138 )); 139 ##fixme 140 $page->param(id => 1); 138 141 my @domlist; 139 142 $sth = $dbh->prepare("select domain_id,domain,status,groups.name from domains". … … 160 163 } elsif ($webvar{page} eq 'reclist') { 161 164 162 #} elsif ($webvar{page} eq 'domdetail') { 165 # Handle record list for both default records (per-group) and live domain records 163 166 164 167 $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 } 165 207 166 208 ##fixme 167 209 $page->param(domain => domainName($dbh,$webvar{id})); 168 $page->param( grpid => 1);210 $page->param(id => $webvar{id}); 169 211 ##fixme 170 212 213 $page->param(defrec => $webvar{defrec}); 171 214 if ($webvar{defrec} eq 'y') { 172 $page->param(id => $webvar{grpid}); ##fixme, hack! hack!173 215 showdomain('y',1); 174 216 } else { 175 $page->param(id => $webvar{id});176 217 showdomain('n',$webvar{id}); 177 218 } 178 219 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 193 220 } elsif ($webvar{page} eq 'newdomain') { 221 194 222 # weesa gonna discard parent_group_id for now 195 223 my $sth = $dbh->prepare("select group_id,parent_group_id,name from groups order by group_id"); … … 214 242 215 243 } elsif ($webvar{page} eq 'addrec') { 216 print "wanna add<br>DEBUG: $webvar{parentid}<br>\n";217 244 218 245 my @recargs = ($dbh,$webvar{defrec},$webvar{parentid},$webvar{name},$webvar{type},$webvar{address},$webvar{ttl}); … … 251 278 my @tmp = getrecdata($dbh,$webvar{id},$webvar{defrec}); 252 279 253 254 280 } elsif ($webvar{page} eq 'delrec') { 255 281 … … 400 426 $page->param(ttl => $soa{ttl}); 401 427 428 ##fixme! 429 my $roffset = 0; 430 402 431 # 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; 404 450 405 451 my $row = 0; … … 434 480 $page->param(parentid => 1); 435 481 } else { 482 print "DEBUG: foobar: parentid $webvar{parentid}<br>\n"; 436 483 $page->param(parentid => $webvar{parentid}); 437 484 } -
trunk/templates/domlist.tmpl
r3 r4 42 42 <td width="1%" nowrap><TMPL_VAR name=group></td> 43 43 <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> 45 45 </tr> 46 46 </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> 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> 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> 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> 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> 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> 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> 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> 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 4 4 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=useradmin">Users</a><br /> 5 5 <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 /> 7 7 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=axfr">AXFR Import</a><br /> 8 8 <hr>
Note:
See TracChangeset
for help on using the changeset viewer.