##################################################################### # W H O ' S O N L I N E # by JPDeni # Written: 30 Jun 2000 # Re-wrote for DBMan SQL Version 1 by shann123 3-16-04 ##################################################################### # This mod will allow you to add a link to the footer which will # display the userids of those who are currently logged in to the # database. # # Included is a "true logoff," which removes the session file for the # user when he logs off the database. Also, since many users do not # log off when they leave the database, their session ids will be # after 10 or 20 minutes of inactivity. ##################################################################### # # In *.cfg, set $auth_time = 600; # (10 minutes) # or $auth_time = 1200; # (20 minutes) ##################################################################### # # In db.cgi, sub main, change elsif ($in{'logoff'}) { &auth_logging('logged off') if ($auth_logging); $auth_logoff ? (print "Location: $auth_logoff\n\n") : (print "Location: $db_script_url\n\n"); } # to elsif ($in{'logoff'}) { my $uid = $DBH->quote($db_uid); $query = qq! DELETE FROM $db_table_session WHERE session_id = $uid !; $DBH->do($query) or &cgierr("Unable to clear session info. Reason: " . $DBH->errstr . ". Query: $query"); &auth_logging('logged off') if ($auth_logging); $auth_logoff ? (print "Location: $auth_logoff\n\n") : (print "Location: $db_script_url\n\n"); } ##################################################################### # # In db.cgi, sub main after if ($in{'add_form'}) { if ($per_add) { &html_add_form; } else { &html_unauth; } } # add elsif ($in{'whos_online'}) { if ($per_view) { &html_whos_online; } else { &html_unauth; } } ##################################################################### # # In html.pl, sub html_footer, add print qq!| Who's Online ! if ($per_view); ##################################################################### # # In html.pl, add a new subroutine # (For those using the default html.pl file. The one for the "user-friendly" html.pl file follows.) sub html_whos_online { # -------------------------------------------------------- my (@files,$file); &html_print_headers; print qq|
| $html_title: Who's Online | |
<$font>The following users are currently logged in to the database:
|;
if ($in{'whos_online'}) {
$query = qq!
SELECT * FROM $db_table_session
ORDER BY session_id ASC
!;
my $sth = $DBH->prepare($query);
$sth->execute();
#while ($row = $sth->fetchrow_hashref) {
while (my $row = $sth->fetchrow_hashref) {
#$playername = $data[0];
#$sex = $data[1];
print qq|$row->{session_id} | |
<$font>The following users are currently logged in to the database:
|;
if ($in{'whos_online'}) {
$query = qq!
SELECT * FROM $db_table_session
ORDER BY session_id ASC
!;
my $sth = $DBH->prepare($query);
$sth->execute();
#while ($row = $sth->fetchrow_hashref) {
while (my $row = $sth->fetchrow_hashref) {
#$playername = $data[0];
#$sex = $data[1];
print qq|$row->{session_id}
|;
}
$sth->finish;
}
print qq|