Changeset 17
- Timestamp:
- 09/30/09 16:54:10 (15 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r16 r17 257 257 258 258 ## DNSDB::grpName() 259 # Return the domain name based on a domainID260 # Takes a database handle and the domainID261 # Returns the domainname or undef on failure259 # Return the group name based on a group ID 260 # Takes a database handle and the group ID 261 # Returns the group name or undef on failure 262 262 sub grpName { 263 263 $errstr = ''; … … 388 388 $sql .= " and not type=$reverse_typemap{SOA} order by $order"; 389 389 ##fixme: need to set nstart properly (offset is not internally multiplied with limit) 390 $sql .= " limit $nrecs offset $nstart"if $nstart ne 'all';390 $sql .= " limit $nrecs offset ".($nstart*$nrecs) if $nstart ne 'all'; 391 391 392 392 my $sth = $dbh->prepare($sql); … … 457 457 sub updateRec { 458 458 $errstr = ''; 459 459 460 my $dbh = shift; 460 461 my $defrec = shift; … … 475 476 476 477 if ($type == $reverse_typemap{MX} || $type == $reverse_typemap{SRV}) { 477 $dist = shift 478 or return ('FAIL',"MX or SRV requires distance");478 $dist = shift; 479 return ('FAIL',"MX or SRV requires distance") if !defined($dist); 479 480 if ($type == $reverse_typemap{SRV}) { 480 my $weight = shift481 or return ('FAIL',"SRV requires weight");482 my $port = shift483 or return ('FAIL',"SRV requires port");481 $weight = shift; 482 return ('FAIL',"SRV requires weight") if !defined($weight); 483 $port = shift; 484 return ('FAIL',"SRV requires port") if !defined($port); 484 485 } 485 486 } … … 490 491 $sth->execute($host,$type,$val,$ttl,$dist,$weight,$port,$id); 491 492 492 return ('FAIL',$sth->errstr ) if $sth->err;493 return ('FAIL',$sth->errstr."<br>\n$errstr<br>\n") if $sth->err; 493 494 494 495 return ('OK','OK'); -
trunk/dns.cgi
r16 r17 49 49 } 50 50 51 my $group = ($webvar{gr p} ? $webvar{grp} : 1);51 my $group = ($webvar{group} ? $webvar{group} : 1); 52 52 # handle login redirect 53 53 if ($webvar{action} && $webvar{action} eq 'login') { … … 127 127 if ($webvar{defrec} eq 'y') { 128 128 ##fixme: hardcoded group 129 showdomain('y', 1);129 showdomain('y',$group); 130 130 } else { 131 131 showdomain('n',$webvar{id}); … … 209 209 $page->param(recact => "update"); 210 210 $page->param(parentid => $webvar{parentid}); 211 $page->param(id => $webvar{id}); 211 212 $page->param(defrec => $webvar{defrec}); 212 213 my $sth = $dbh->prepare("SELECT host,type,val,distance,weight,port,ttl FROM ". … … 229 230 230 231 if ($code eq 'OK') { 231 $page->param(failed => 1); 232 $page->param(errmsg => "testing"); 233 $page->param(wastrying => "updating"); 234 $page->param(todo => "Update record"); 235 $page->param(recact => "update"); 236 $page->param(parentid => $webvar{parentid}); 237 $page->param(defrec => $webvar{defrec}); 238 fill_recdata(); 239 # changepage(page => "reclist", id => $webvar{parentid}, defrec => $webvar{defrec}); 232 changepage(page => "reclist", id => $webvar{parentid}, defrec => $webvar{defrec}); 240 233 } else { 241 234 $page->param(failed => 1); … … 246 239 $page->param(parentid => $webvar{parentid}); 247 240 $page->param(defrec => $webvar{defrec}); 241 $page->param(id => $webvar{id}); 248 242 fill_recdata(); 249 243 } … … 251 245 252 246 if ($webvar{defrec} eq 'y') { 253 $page->param(dohere => " group ".grpName($dbh,$webvar{parentid}));247 $page->param(dohere => "default records in group ".grpName($dbh,$webvar{parentid})); 254 248 } else { 255 249 $page->param(dohere => domainName($dbh,$webvar{parentid})); … … 371 365 } 372 366 373 374 } 375 376 377 ## hmm. may want to move this so we can redirect after adding/deleting/etc 367 } elsif ($webvar{page} eq 'grpman') { 368 369 my $sth = $dbh->prepare("select count(*) from groups"); 370 $sth->execute; 371 my ($count) = ($sth->fetchrow_array); 372 373 # fill page count and first-previous-next-last-all bits 374 ##fixme - hardcoded group bit 375 fill_pgcount($count,"groups",''); 376 fill_fpnla($count); 377 378 my @grplist; 379 $sth = $dbh->prepare("SELECT g.group_id, g.group_name, g2.group_name, ". 380 "count(distinct(u.email)), count(distinct(d.domain)) ". 381 "FROM groups g ". 382 "INNER JOIN groups g2 ON g2.group_id=g.parent_group_id ". 383 "LEFT OUTER JOIN users u ON u.group_id=g.group_id ". 384 "LEFT OUTER JOIN domains d ON d.group_id=g.group_id ". 385 "GROUP BY g.group_id, g.group_name, g2.group_name ". 386 "ORDER BY g.group_name".($offset eq 'all' ? '' : " LIMIT $perpage OFFSET ".$offset*$perpage)); 387 388 $sth->execute; 389 my $rownum = 0; 390 while (my @data = $sth->fetchrow_array) { 391 my %row; 392 $row{grpid} = $data[0]; 393 $row{grpname} = $data[1]; 394 $row{pgrp} = $data[2]; 395 $row{nusers} = $data[3]; 396 $row{ndomains} = $data[4]; 397 $row{bg} = ($rownum++)%2; 398 $row{sid} = $sid; 399 push @grplist, \%row; 400 } 401 $page->param(grptable => \@grplist); 402 403 } elsif ($webvar{page} eq 'newgrp') { 404 405 } 406 407 408 # start output here so we can redirect pages. 378 409 print "Content-type: text/html\n\n", $header->output; 379 410 380 411 foreach (@debugbits) { print; } 381 412 382 $page->param(grp => $group) if $webvar{page} ne 'login'; 413 # common bits 414 if ($webvar{page} ne 'login') { 415 $page->param(grp => $group); 416 $page->param(grpname => grpName($dbh,$group)); 417 $page->param(curpage => $webvar{page}); 418 } 383 419 384 420 # spit it out … … 423 459 $domname = "DOMAIN"; 424 460 } else { 425 my $sth = $dbh->prepare(" select domain from domains where domain_id=$webvar{domain}");426 $sth->execute( );461 my $sth = $dbh->prepare("SELECT domain FROM domains WHERE domain_id=?"); 462 $sth->execute($webvar{domain}); 427 463 ($domname) = $sth->fetchrow_array(); 428 464 } 429 465 430 $page->param(domain 431 $page->param(defrec 432 $page->param(group 466 $page->param(domain => $domname); 467 $page->param(defrec => !$webvar{domain}); 468 $page->param(group => $DNSDB::group); 433 469 434 470 # defaults 435 $page->param(defcontact 436 $page->param(defns 437 $page->param(defsoattl 438 $page->param(defrefresh 439 $page->param(defretry 440 $page->param(defexpire 441 $page->param(defminttl 471 $page->param(defcontact => $DNSDB::def{contact}); 472 $page->param(defns => $DNSDB::def{prins}); 473 $page->param(defsoattl => $DNSDB::def{soattl}); 474 $page->param(defrefresh => $DNSDB::def{refresh}); 475 $page->param(defretry => $DNSDB::def{retry}); 476 $page->param(defexpire => $DNSDB::def{expire}); 477 $page->param(defminttl => $DNSDB::def{minttl}); 442 478 443 479 # there are probably better ways to do this. TMTOWTDI. … … 490 526 my $type = shift || $reverse_typemap{A}; 491 527 492 my $sth = $dbh->prepare(" select val,name from rectypes where stdflag=1 order bylistorder");528 my $sth = $dbh->prepare("SELECT val,name FROM rectypes WHERE stdflag=1 ORDER BY listorder"); 493 529 $sth->execute; 494 push @debugbits, "type $type";495 530 my @typelist; 496 531 while (my ($rval,$rname) = $sth->fetchrow_array()) { … … 518 553 ##fixme 519 554 if ($offset eq 'all') { 520 #print"foo! wanna see'em all\n";555 push @debugbits, "foo! wanna see'em all\n"; 521 556 } else { 522 557 # all these bits only have sensible behaviour if offset is numeric. err, probably. … … 559 594 560 595 sub listdomains { 561 my $sth = $dbh->prepare("select count(*) from domains"); 562 $sth->execute; 563 my ($count) = ($sth->fetchrow_array); 596 597 my $sth = $dbh->prepare("SELECT count(*) FROM domains WHERE group_id=?"); 598 $sth->execute($group); 599 my ($count) = $sth->fetchrow_array; 564 600 565 601 # fill page count and first-previous-next-last-all bits … … 571 607 $page->param(grp => 1); 572 608 my @domlist; 573 $sth = $dbh->prepare("select domain_id,domain,status,groups. name from domains".609 $sth = $dbh->prepare("select domain_id,domain,status,groups.group_name from domains". 574 610 " inner join groups on domains.group_id=groups.group_id". 575 611 " order by domain".($offset eq 'all' ? '' : " limit $perpage offset ".$offset*$perpage)); -
trunk/templates/domlist.tmpl
r12 r17 8 8 <tr><td><TMPL_INCLUDE NAME="pgcount.tmpl"></td> 9 9 <td> 10 <TMPL_IF navfirst><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=domlist&offset=0"><img src="images/frev.png" border=0>first</a><TMPL_ELSE><img src="images/frev.png" border=0>first</TMPL_IF> 11 <TMPL_IF navprev><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=domlist&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> 12 <TMPL_IF navnext><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=domlist&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> 13 <TMPL_IF navlast><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=domlist&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> 14 <TMPL_IF navall><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=domlist&offset=all">all</a><TMPL_ELSE>all</TMPL_IF> 10 <TMPL_INCLUDE NAME="fpnla.tmpl"> 15 11 </td><td align=right>insert search box here</td></tr> 16 12 -
trunk/templates/menu.tmpl
r13 r17 1 1 <td class="menu"> 2 <div class="menu">2 Current group: <TMPL_VAR NAME=grpname><br /> 3 3 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=domlist">Domains</a><br /> 4 4 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=useradmin">Users</a><br /> … … 7 7 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=axfr">AXFR Import</a><br /> 8 8 <hr> 9 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=grpman">Manage groups</a><br /> 10 <select name="group"> 11 <TMPL_LOOP NAME=grouplist><option value="<TMPL_VAR NAME=grpval>"<TMPL_IF NAME=grplist> selected</TMPL_IF>><TMPL_VAR NAME=grpname></option> 12 </TMPL_LOOP> 13 </select> 14 <hr> 9 15 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=dnsq">DNS Query</a><br /> 10 16 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=whoisq">WHOIS Query</a><br /> 11 </div>12 17 </td> -
trunk/templates/pgcount.tmpl
r12 r17 1 Listing <TMPL_VAR NAME=nfirst> - <TMPL_VAR NAME=npglast> of <TMPL_VAR NAME=ntot> <TMPL_VAR NAME=pgtype> in <TMPL_VAR NAME=parent>1 Listing <TMPL_VAR NAME=nfirst> - <TMPL_VAR NAME=npglast> of <TMPL_VAR NAME=ntot> <TMPL_VAR NAME=pgtype><TMPL_IF NAME=parent> in <TMPL_VAR NAME=parent></TMPL_IF> -
trunk/templates/record.tmpl
r16 r17 11 11 <input type="hidden" name="sid" value="<TMPL_VAR NAME=sid>"> 12 12 <input type="hidden" name="parentid" value="<TMPL_VAR NAME=parentid>"> 13 <input type="hidden" name="id" value="<TMPL_VAR NAME=id>"> 13 14 <input type="hidden" name="recact" value="<TMPL_VAR NAME=recact>"> 14 15 <table border=0 bgcolor="white">
Note:
See TracChangeset
for help on using the changeset viewer.