Changeset 13 for trunk/dns.cgi
- Timestamp:
- 09/11/09 17:59:51 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dns.cgi
r12 r13 22 22 use DNSDB qw(:ALL); 23 23 24 my @debugbits; # temp, to be spit out near the end of processing 25 24 26 # Let's do these templates right... 25 27 my $templatedir = "templates"; … … 34 36 my %webvar = $q->Vars; 35 37 38 # persistent stuff needed on most/all pages 36 39 my $sid = ($webvar{sid} ? $webvar{sid} : undef); 37 40 my $session = new CGI::Session("driver:File", $sid, {Directory => $sessiondir}); … … 46 49 } 47 50 51 my $group = ($webvar{grp} ? $webvar{grp} : 1); 48 52 # handle login redirect 49 53 if ($webvar{action} && $webvar{action} eq 'login') { … … 170 174 } 171 175 176 } elsif ($webvar{page} eq 'record') { 177 if ($webvar{recact} eq 'new') { 178 $page->param(recact => "Add record to"); 179 stdrecs(); 180 } elsif ($webvar{recact} eq 'edit') { 181 $page->param(recact => "Edit record in"); 182 my $sth = $dbh->prepare("SELECT host,type,val,distance,weight,port,ttl FROM ". 183 ($webvar{defrec} eq 'y' ? 'default_' : '')."records WHERE record_id=?"); 184 $sth->execute($webvar{id}); 185 my ($host,$type,$val,$distance,$weight,$port,$ttl) = $sth->fetchrow_array; 186 $page->param(name => $host); 187 $page->param(address => $val); 188 $page->param(distance => $distance); 189 $page->param(weight => $weight); 190 $page->param(port => $port); 191 $page->param(ttl => $ttl); 192 stdrecs($type); 193 } 194 if ($webvar{defrec} eq 'y') { 195 $page->param(domain => "group ".grpName($dbh,$webvar{parentid})); 196 } else { 197 $page->param(domain => domainName($dbh,$webvar{parentid})); 198 } 199 172 200 } elsif ($webvar{page} eq 'newrec') { 173 p rint"whee!\n";201 push @debugbits, "whee!\n"; 174 202 175 203 # populate most fields as needed. (eg, type list.) 176 newrec();204 stdrecs(); 177 205 178 206 } elsif ($webvar{page} eq 'addrec') { … … 186 214 } 187 215 } 188 push @recargs, 216 # wtf? 217 # push @recargs, 189 218 my ($code,$msg) = addRec(@recargs); 190 219 … … 195 224 $page->param(add_failed => 1); 196 225 $page->param(errmsg => $msg); 197 newrec(); # populate the form... er, mostly.226 stdrecs($webvar{type}); # populate the form... er, mostly. 198 227 $page->param(name => $webvar{name}); 199 228 $page->param(address => $webvar{address}); … … 291 320 print "Content-type: text/html\n\n", $header->output; 292 321 322 foreach (@debugbits) { print; } 323 324 $page->param(grp => $group); 325 293 326 # spit it out 294 327 print $page->output; … … 387 420 $rec->{type} = $typemap{$rec->{type}}; 388 421 $rec->{row} = $row % 2; 389 # Feh.390 422 $rec->{defrec} = $webvar{defrec}; 391 # And **FEH!!**392 423 $rec->{sid} = $webvar{sid}; 424 $rec->{id} = $id; 393 425 $row++; 394 426 } … … 396 428 } 397 429 398 sub newrec { 430 sub stdrecs { 431 my $type = shift || $reverse_typemap{A}; 432 399 433 my $sth = $dbh->prepare("select val,name from rectypes where stdflag=1 order by listorder"); 400 434 $sth->execute; 401 435 436 push @debugbits, "DEBUG: type $type\n"; 402 437 my @typelist; 403 438 while (my ($rval,$rname) = $sth->fetchrow_array()) { 404 439 my %row = ( recval => $rval, recname => $rname ); 405 $row{tselect} = 1 if $rval == $ webvar{type};440 $row{tselect} = 1 if $rval == $type; 406 441 push @typelist, \%row; 407 442 } … … 474 509 475 510 ##fixme - group 476 $page->param( id=> 1);511 $page->param(grp => 1); 477 512 my @domlist; 478 my$sth = $dbh->prepare("select domain_id,domain,status,groups.name from domains".513 $sth = $dbh->prepare("select domain_id,domain,status,groups.name from domains". 479 514 " inner join groups on domains.group_id=groups.group_id". 480 515 " order by domain".($offset eq 'all' ? '' : " limit $perpage offset ".$offset*$perpage));
Note:
See TracChangeset
for help on using the changeset viewer.