<& /htmlheader &>

MOPS Alerts

Displaying <% scalar(@alerts) %> out of <% $n %> alerts (starting at position <% $start %>)

% foreach my $aref (@alerts) { % }
Channel Alert ID Publisher Alert Publish Date (UT)
% # Fix node name. % my $nodeID = $aref->{nodeID}; % $nodeID =~ s/$NODE_ROOT//; <% $nodeID %> <% $aref->{id} %> % # Fix publisher name % my $jid = substr($aref->{jid}, 0, index($aref->{jid}, "@" . $ALERT_SERVER)); <% $jid %> % # Fix date: we have here the number of millisecs since 1970. % my $sec; % my $min; % my $hour; % my $mday; % my $mon; % my $year; % my $wday; % my $yday; % my $isdst; % my $t = $aref->{creationDate} / 1000.0; % ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = gmtime($t); % my $creationDate = sprintf("%4d-%02d-%02dT%02d:%02d:%02d", $year+1900, $mon+1, $mday, $hour, $min, $sec); <% $creationDate %>

Pages: % my $i; % my $k; % for($i=1; $i<=$npages; $i++) { % $k = $MAX_ROWS * ($i - 1); % if($k eq $start) { <% $i %> % } else { <% $i %> % } # if % } # for % if($npages eq 0) { 1 % } <& /htmlfooter &> <%args> $start => 0 $instance => "" <%init> use DBI; use POSIX qw(ceil); my $DBSERVER = "mops00.ifa.hawaii.edu"; my $ALERT_SERVER = "mopshq2.ifa.hawaii.edu"; my $USER = "mops"; my $PASSWD = "mops"; my $DB = "openfire"; my $NODE_ROOT = "home/" . $ALERT_SERVER . "/"; my $MAX_ROWS = 50; my $npages = 0; my $aref; my @alerts; my $n; my $connectionStr = "dbi:mysql:host=" . $DBSERVER . ";database=" . $DB; my $dbh = DBI->connect($connectionStr, $USER, $PASSWD); # Retrieve the number of alerts. We could have $n passed on the URL, but we # cannot be sure that it would still be valid. $aref = $dbh->selectrow_hashref("select count(*) as n from ofPubsubItem where nodeID like '" . $NODE_ROOT . "%' and id like '". $instance ."%'", undef); $n = $aref->{n}; # How many pages to we need to display? $npages = ceil($n / $MAX_ROWS); # Now retrieve the requested number of rows. my $cur = $dbh->prepare("select serviceID, nodeID, id, jid, creationDate from ofPubsubItem where nodeID like '" . $NODE_ROOT . "%' and id like '". $instance ."%' order by creationDate desc limit " . $start ."," . $MAX_ROWS); $cur->{mysql_use_result} = 1; $cur->execute; while($aref = $cur->fetchrow_hashref) { push @alerts, $aref; }