Changeset 7 for trunk/dns.cgi
- Timestamp:
- 09/04/09 17:53:55 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dns.cgi
r5 r7 31 31 $q->parse_query_string; 32 32 33 my %webvar;34 33 # This is probably excessive fiddling, but it puts the parameters somewhere my fingers know about... 35 foreach ($q->param()) { 36 $webvar{$_} = $q->param($_); 37 } 34 my %webvar = $q->Vars; 38 35 39 36 my $sid = ($webvar{sid} ? $webvar{sid} : undef); … … 60 57 my $footer = HTML::Template->new(filename => "$templatedir/footer.tmpl"); 61 58 62 ## hmm. may want to move this so we can redirect after adding/deleting/etc63 print "Content-type: text/html\n\n", $header->output;64 65 59 # default 66 60 #my $perpage = 15; 67 my $perpage = 3;61 my $perpage = 4; 68 62 my $offset = ($webvar{offset} ? $webvar{offset} : 0); 69 63 … … 107 101 my ($count) = ($sth->fetchrow_array); 108 102 109 ##fixme 110 if ($offset eq 'all') { 111 print "foo! wanna see'em all\n"; 112 } else { 113 # all these bits only have sensible behaviour if offset is numeric. err, probably. 114 if ($count > $perpage) { 115 # if there are more results than the default, always show the "all" link 116 $page->param(navall => 1); 117 118 if ($offset > 0) { 119 $page->param(navfirst => 1); 120 $page->param(navprev => 1); 121 $page->param(prevoffs => $offset-1); 122 } 123 124 # show "next" and "last" links if we're not on the last page of results 125 if ( (($offset+1) * $perpage - $count) < 0 ) { 126 $page->param(navnext => 1); 127 $page->param(nextoffs => $offset+1); 128 $page->param(navlast => 1); 129 $page->param(lastoffs => int $count/$perpage); 130 } 131 } 132 } 103 fill_fpnla($count); 133 104 134 105 $page->param(ndomains => $count); … … 137 108 ( (($offset+1)*$perpage) > $count ? $count : (($offset+1)*$perpage) ) 138 109 )); 139 ##fixme 110 ##fixme - group 140 111 $page->param(id => 1); 141 112 my @domlist; … … 181 152 $page->param(nlast => 10); 182 153 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 } 154 fill_fpnla($count); # should put some params on this sub... 207 155 208 156 ##fixme … … 308 256 $page->param(domain => domainName($dbh,$webvar{id})); 309 257 # print some neato things? 258 259 # } else { 260 # #whether actually deleting or cancelling we redirect to the domain list, default format 261 310 262 } elsif ($webvar{del} eq 'ok') { 311 263 my ($code,$msg) = delDomain($dbh, $webvar{id}); … … 372 324 373 325 326 ## hmm. may want to move this so we can redirect after adding/deleting/etc 327 print "Content-type: text/html\n\n", $header->output; 328 374 329 # spit it out 375 330 print $page->output; … … 447 402 $page->param(ttl => $soa{ttl}); 448 403 449 ##fixme!450 my $roffset = 0;451 452 404 # my @foo2 = getDomRecs($dbh,'def',1); 453 405 my $foo2 = getDomRecs($dbh,$def,$id,$perpage,$webvar{offset}); 454 455 # $sth = $dbh->prepare("select domain_id,domain,status,groups.name from domains".456 # " inner join groups on domains.group_id=groups.group_id".457 # " order by domain".($offset eq 'all' ? '' : " limit $perpage offset ".$offset*$perpage));458 # $sth->execute;459 # my $rownum = 0;460 # while (my @data = $sth->fetchrow_array) {461 # my %row;462 # $row{domainid} = $data[0];463 # $row{domain} = $data[1];464 # $row{status} = ($data[2] ? 'Active' : 'Inactive');465 # $row{group} = $data[3];466 # $row{bg} = ($rownum++)%2;467 ## $row{mkactive} = ($data[2] eq 'inactive' ? 1 : 0);468 # $row{mkactive} = !$data[2];469 # $row{sid} = $sid;470 # $row{offset} = $offset;471 406 472 407 my $row = 0; … … 505 440 } 506 441 } 442 443 sub fill_fpnla { 444 my $count = shift; 445 ##fixme 446 if ($offset eq 'all') { 447 #print "foo! wanna see'em all\n"; 448 } else { 449 # all these bits only have sensible behaviour if offset is numeric. err, probably. 450 if ($count > $perpage) { 451 # if there are more results than the default, always show the "all" link 452 $page->param(navall => 1); 453 454 if ($offset > 0) { 455 $page->param(navfirst => 1); 456 $page->param(navprev => 1); 457 $page->param(prevoffs => $offset-1); 458 } 459 460 # show "next" and "last" links if we're not on the last page of results 461 if ( (($offset+1) * $perpage - $count) < 0 ) { 462 $page->param(navnext => 1); 463 $page->param(nextoffs => $offset+1); 464 $page->param(navlast => 1); 465 $page->param(lastoffs => int $count/$perpage -1); 466 } 467 } 468 } 469 }
Note:
See TracChangeset
for help on using the changeset viewer.