- Timestamp:
- 09/11/09 17:59:51 (15 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r10 r13 23 23 @ISA = qw(Exporter); 24 24 @EXPORT_OK = qw( 25 &initGlobals &connectDB &finish &addDomain &delDomain &domainName &g etSOA &getRecLine &getDomRecs26 & addRec &delRec &domStatus25 &initGlobals &connectDB &finish &addDomain &delDomain &domainName &grpName &getSOA &getRecLine 26 &getDomRecs &addRec &delRec &domStatus 27 27 %typemap %reverse_typemap 28 28 ); … … 30 30 @EXPORT = (); # Export nothing by default. 31 31 %EXPORT_TAGS = ( ALL => [qw( 32 &initGlobals &connectDB &finish &addDomain &delDomain &domainName &g etSOA &getRecLine &getDomRecs33 & addRec &delRec &domStatus32 &initGlobals &connectDB &finish &addDomain &delDomain &domainName &grpName &getSOA &getRecLine 33 &getDomRecs &addRec &delRec &domStatus 34 34 %typemap %reverse_typemap 35 35 )] … … 254 254 255 255 256 ## DNSDB::grpName() 257 # Return the domain name based on a domain ID 258 # Takes a database handle and the domain ID 259 # Returns the domain name or undef on failure 260 sub grpName { 261 $errstr = ''; 262 my $dbh = shift; 263 my $grpid = shift; 264 my $sth = $dbh->prepare("select name from groups where group_id=?"); 265 $sth->execute($grpid); 266 my ($grpname) = $sth->fetchrow_array(); 267 $errstr = $DBI::errstr if !$grpname; 268 return $grpname if $grpname; 269 } # end domainName 270 271 256 272 ## DNSDB::editRecord() 257 273 # Change an existing record -
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)); -
trunk/templates/menu.tmpl
r4 r13 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&id=<TMPL_VAR NAME= id>&defrec=y">Default Records</a><br />6 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=reclist&id=<TMPL_VAR NAME=grp>&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> -
trunk/templates/reclist.tmpl
r12 r13 27 27 <tr class="darkrowheader"> 28 28 <td colspan=2>Records</td> 29 <td align=right><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page= newrec&parentid=<TMPL_VAR NAME=id>&defrec=<TMPL_VAR NAME=defrec>">Add record</a>29 <td align=right><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=record&parentid=<TMPL_VAR NAME=id>&defrec=<TMPL_VAR NAME=defrec>&recact=new">Add record</a> 30 30 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=showlog&id=<TMPL_VAR NAME=id>&defrec=<TMPL_VAR NAME=defrec>">View log</a> 31 31 </td> … … 42 42 <TMPL_LOOP NAME=reclist> 43 43 <tr class="row<TMPL_VAR NAME=row>"> 44 <td width="20%" nowrap><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page= editrec&id=<TMPL_VAR NAME=record_id>&defrec=<TMPL_VAR NAME=defrec>"><TMPL_VAR NAME=host></a></td>44 <td width="20%" nowrap><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=record&parentid=<TMPL_VAR NAME=id>&defrec=<TMPL_VAR NAME=defrec>&recact=edit&id=<TMPL_VAR NAME=record_id>"><TMPL_VAR NAME=host></a></td> 45 45 <td width="5%" nowrap><TMPL_VAR NAME=type></td> 46 46 <td nowrap><TMPL_VAR NAME=val></td>
Note:
See TracChangeset
for help on using the changeset viewer.