Changeset 323 for trunk/dns.cgi
- Timestamp:
- 04/29/12 18:20:17 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dns.cgi
r322 r323 96 96 $session->param('reclistsortby','host'); 97 97 $session->param('reclistorder','ASC'); 98 $session->param('logsortby','stamp'); 99 $session->param('logorder','DESC'); 98 100 } 99 101 … … 1497 1499 } elsif ($webvar{page} eq 'log') { 1498 1500 1499 ##fixme put in some real log-munching stuff1500 my $sql = "SELECT user_id, email, name, entry, date_trunc('second',stamp) FROM log WHERE ";1501 1501 my $id = $curgroup; # we do this because the group log may be called from (almost) any page, 1502 1502 # but the others are much more limited. this is probably non-optimal. 1503 1503 1504 1504 if ($webvar{ltype} && $webvar{ltype} eq 'user') { 1505 $sql .= "user_id=?"; 1505 ##fixme: where should we call this from? 1506 1506 $id = $webvar{id}; 1507 1507 if (!check_scope(id => $id, type => 'user')) { … … 1511 1511 $page->param(logfor => 'user '.userFullName($dbh,$id)); 1512 1512 } elsif ($webvar{ltype} && $webvar{ltype} eq 'dom') { 1513 $sql .= "domain_id=?";1514 1513 $id = $webvar{id}; 1515 1514 if (!check_scope(id => $id, type => 'domain')) { … … 1519 1518 $page->param(logfor => 'domain '.domainName($dbh,$id)); 1520 1519 } elsif ($webvar{ltype} && $webvar{ltype} eq 'rdns') { 1521 $sql .= "rdns_id=?";1522 1520 $id = $webvar{id}; 1523 1521 if (!check_scope(id => $id, type => 'revzone')) { … … 1528 1526 } else { 1529 1527 # Default to listing curgroup log 1530 $sql .= "group_id=?";1531 1528 $page->param(logfor => 'group '.groupName($dbh,$id)); 1532 1529 # note that scope limitations are applied via the change-group check; 1533 1530 # group log is always for the "current" group 1534 1531 } 1532 $webvar{ltype} = 'group' if !$webvar{ltype}; 1533 my $lcount = getLogCount($dbh, (id => $id, logtype => $webvar{ltype})) or push @debugbits, $DNSDB::errstr; 1534 1535 $page->param(id => $id); 1536 $page->param(ltype => $webvar{ltype}); 1537 1538 fill_fpnla($lcount); 1539 fill_pgcount($lcount, "log entries", ''); 1540 $page->param(curpage => $webvar{page}.($webvar{ltype} ? "&ltype=$webvar{ltype}" : '')); 1541 1542 $sortby = 'stamp'; 1543 $sortorder = 'DESC'; # newest-first; although filtering is probably going to be more useful than sorting 1544 # sort/order 1545 $session->param($webvar{page}.'sortby', $webvar{sortby}) if $webvar{sortby}; 1546 $session->param($webvar{page}.'order', $webvar{order}) if $webvar{order}; 1547 1548 $sortby = $session->param($webvar{page}.'sortby') if $session->param($webvar{page}.'sortby'); 1549 $sortorder = $session->param($webvar{page}.'order') if $session->param($webvar{page}.'order'); 1550 1551 # Set up the column headings with the sort info 1552 my @cols = ('fname','username','entry','stamp'); 1553 my %colnames = (fname => 'Name', username => 'Username/Email', entry => 'Log Entry', stamp => 'Date/Time'); 1554 fill_colheads($sortby, $sortorder, \@cols, \%colnames); 1555 1556 ##fixme: increase per-page limit or use separate limit for log? some ops give *lots* of entries... 1557 my $logentries = getLogEntries($dbh, (id => $id, logtype => $webvar{ltype}, 1558 offset => $webvar{offset}, sortby => $sortby, sortorder => $sortorder)); 1559 $page->param(logentries => $logentries); 1560 1535 1561 ##fixme: 1536 1562 # - filtering 1537 1563 # - show reverse zone column? 1538 # - pagination/limiting number of records - put newest-first so user 1539 # doesn't always need to go to the last page for recent activity? 1540 my $sth = $dbh->prepare($sql); 1541 $sth->execute($id); 1542 my @logbits; 1543 while (my ($uid, $email, $name, $entry, $stamp) = $sth->fetchrow_array) { 1544 my %row; 1545 $row{userfname} = $name; 1546 $row{userid} = $uid; 1547 $row{useremail} = $email; 1548 ($row{logentry} = $entry) =~ s/\n/<br>\n/g; 1549 ($row{logtime}) = ($stamp =~ /^(.+)-\d\d$/); 1550 push @logbits, \%row; 1551 } 1552 $page->param(logentries => \@logbits); 1564 # - on log record creation, bundle "parented" log actions (eg, "AXFR record blah for domain foo", 1565 # or "Add record bar for new domain baz") into one entry (eg, "AXFR domain foo", "Add domain baz")? 1566 # need a way to expand this into the complete list, and to exclude "child" entries 1553 1567 1554 1568 # scope check fail target
Note:
See TracChangeset
for help on using the changeset viewer.