package WebGUI::Operation::ActiveSessions; #------------------------------------------------------------------- # WebGUI is Copyright 2001-2005 Plain Black Corporation. #------------------------------------------------------------------- # Please read the legal notices (docs/legal.txt) and the license # (docs/license.txt) that came with this distribution before using # this software. #------------------------------------------------------------------- # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- use strict; use WebGUI::AdminConsole; use WebGUI::DateTime; use WebGUI::Grouping; use WebGUI::Icon; use WebGUI::International; use WebGUI::Paginator; use WebGUI::Privilege; use WebGUI::Session; use WebGUI::SQL; #------------------------------------------------------------------- sub www_killSession { return WebGUI::AdminConsole->new("activeSessions")->render(WebGUI::Privilege::adminOnly()) unless (WebGUI::Grouping::isInGroup(3)); WebGUI::Session::end($session{form}{sid}); return www_viewActiveSessions(); } #------------------------------------------------------------------- sub www_viewActiveSessions { return WebGUI::AdminConsole->new("activeSessions")->render(WebGUI::Privilege::adminOnly()) unless (WebGUI::Grouping::isInGroup(3)); my ($output, $p, @row, $i, $sth, %data); tie %data, 'Tie::CPHash'; $sth = WebGUI::SQL->read("select users.username,users.userId,userSession.sessionId,userSession.expires, userSession.lastPageView,userSession.lastIP from users,userSession where users.userId=userSession.userId and users.userId<>1 order by users.username,userSession.lastPageView desc"); while (%data = $sth->hash) { $row[$i] = ''.$data{username}.' ('.$data{userId}.')'; $row[$i] .= ''.$data{sessionId}.''; $row[$i] .= ''.epochToHuman($data{expires}).''; $row[$i] .= ''.epochToHuman($data{lastPageView}).''; $row[$i] .= ''.$data{lastIP}.''; $row[$i] .= ''.deleteIcon("op=killSession&sid=$data{sessionId}").''; $i++; } $sth->finish; $p = WebGUI::Paginator->new(WebGUI::URL::page('op=viewActiveSessions')); $p->setDataByArrayRef(\@row); $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= $p->getPage($session{form}{pn}); $output .= '
'.WebGUI::International::get(428).''.WebGUI::International::get(435).''.WebGUI::International::get(432).''.WebGUI::International::get(430).''.WebGUI::International::get(431).''.WebGUI::International::get(436).'
'; $output .= $p->getBarTraditional($session{form}{pn}); return WebGUI::AdminConsole->new("activeSessions")->render($output); } 1;