#!/usr/bin/perl # MimerDesk # Web based groupware and eLearning environment # www.mimerdesk.org # # Copyright (C) 2001 Ionstream Ltd. # www.ionstream.fi # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free # Software Foundation; either version 2 of the License, or (at your option) # any later version. # # This program is distributed with a hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # $Id: online.html,v 1.9 2002/07/17 13:17:21 inf Exp $ ########################################### # # # MimerDesk: Config - Info 1.0 # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # # (c) Ionstream Oy 1999 - 2001 # # # # Programmed by: Teemu Arina # # # ########################################### # Asetukset ################################## use strict; use vars qw ($APPLICATION $ACTIVEGRP $USER $IP $LAST_ACT $trans $FORWARDED $TIME_USED $IDLE $form $ref $sth); use lib::MimerDesk; use CGI::Carp "fatalsToBrowser"; sub print_template; $APPLICATION = 'Communication - Online Users'; # Program ################################## read_config('../config/mimerdesk.cfg'); initialize(); $config{'count_lastusers'} = '15'; $form = decode_multipart(); $form->{'ID'} =~ tr/0-9//cd; $form->{'auth'} =~ tr/0-9a-z//cd; ($USER, $IP, $LAST_ACT, $FORWARDED, $TIME_USED, $IDLE, $ACTIVEGRP) = authenticate($form->{'ID'}, $form->{'auth'}, $form->{'changeGroup'}); $trans = lib::MimerDesk->new_gettext(program => 'onlineusers',language => $config{'language'}); $APPLICATION = $trans->gettext('Communication - Online Users'); if ($form->{'quit'}) {redirect("$config{'loc_server'}$config{'bin_dir'}/index.html?ID=$form->{'ID'}&auth=$form->{'auth'}&quit=quit");} else {print_template("$config{'theme'}_onlineusers");} ################################## # Read template and process it # ################################## sub print_template { my ($template,$ref,$fulltemplate,$online_users, $last_users, %realnames,%onlinetimes); $template = shift; print_header('pragma'); $ref = get_template('maintemplate',$template); $ref->{'maintemplate'} =~ s/<>/$ref->{$template}/m; $fulltemplate = $ref->{'maintemplate'}; $ref = get_template('js_doClock', 'js_help', 'js_gotosite'); my $stuff = join "", ($ref->{'js_doClock'},$ref->{'js_help'},$ref->{'js_gotosite'}); $fulltemplate =~ s/<>/$stuff/ms; $fulltemplate = create_buttons($fulltemplate, 'Communication', 'Online Users', $form); my $current_date = time(); lock_tables('READ', 'sessions', 'logit', 'users'); db_list("SELECT sessions.USER,users.info,sessions.LAST_ACT FROM sessions,users where sessions.USER = users.nimi order by sessions.USER"); while (my $ref = $sth->fetchrow_hashref()) { my $idleTime = $current_date - $ref->{'LAST_ACT'}; $idleTime = $idleTime / 60; $idleTime = int ($idleTime + 0.5); # Pyöristä oikein next if $idleTime > $config{'idle_limit'}; $onlinetimes{$ref->{'USER'}} = $idleTime if !exists($onlinetimes{$ref->{'USER'}}) || $onlinetimes{$ref->{'USER'}} > $idleTime; $realnames{$ref->{'USER'}} = $ref->{'info'}; } db_end(); foreach (sort keys %onlinetimes) { $online_users .= tagged('a',{href => "profile_view.html?ID=$form->{'ID'}&auth=$form->{'auth'}&showprofile=$_", class => 'content', onMouseOver => 'doClock(); return true', content => tagged('b',{content => $_}). " ($realnames{$_})   "}). tagged('font',{color => 'gray',content => "$onlinetimes{$_} ".$trans->gettext("min idle")}). tag('br')."\n"; } db_list("select MESSAGE,TIMESTAMP from logit where MESSAGE like '\%logged in.' order by LINE DESC limit $config{'count_lastusers'}"); while (my $ref = $sth->fetchrow_hashref()) { $ref->{'TIMESTAMP'} =~ s/\//./g; $ref->{'MESSAGE'} =~ s/User (\S+) .*/$1/; my (undef,$min,$h,$day,$mon,$year) = utc_epoch2date($ref->{'TIMESTAMP'}); $ref->{'TIMESTAMP'} = "$year/$mon/$day $h:$min"; $last_users .= "$ref->{'TIMESTAMP'} - ".tagged('a',{href => "profile_view.html?ID=$form->{'ID'}&auth=$form->{'auth'}&showprofile=$ref->{'MESSAGE'}", class => 'blackTitleSec', onMouseOver => 'doClock(); return true', content => $ref->{'MESSAGE'}}).tag('br'); } db_end(); unlock_tables(); $online_users = "\n\n".$online_users."\n\n"; $fulltemplate =~ s/<>/$last_users/m; $fulltemplate =~ s/<>/$online_users/m; $fulltemplate =~ s/<>/$config{'count_lastusers'}/m; $fulltemplate =~ s/<>/minea/gm; $fulltemplate =~ s/<>/MimerDesk\: $APPLICATION/ms; $fulltemplate = replace_tags($fulltemplate, $USER, $form->{'auth'}, $form->{'ID'}, $TIME_USED); $fulltemplate = add_popups($fulltemplate, $USER, $form->{'auth'}, $form->{'ID'}); print $fulltemplate; db_end('disconnect'); exit; }