Changeset 17 for trunk/dns.cgi
- Timestamp:
- 09/30/09 16:54:10 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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));
Note:
See TracChangeset
for help on using the changeset viewer.