<?php
/**************************************************************************
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.
@Authors: Ryan Thompson(hide@address.com)
***************************************************************************/
include("./data.php");
$service['add_header'] = TRUE;
include("../config.inc.php");
include($here. "/class.admin.php");
$admin = new admin;
echo $layout->page_header;
echo $layout->service_header($text['service_name'] .' - '. $text['sessions'], $admin->nav_buttons());
if($_POST['drop_sessions'])
{
$i = 0;
while($i < count($_POST['drop']))
{
$sql = "DELETE FROM o_sessions WHERE session_id='". $_POST['drop'][$i] ."'";
$db->query($sql);
$i++;
}
echo "<b>". count($_POST['drop']) ."</b> session(s) dropped<p>";
}
$sql = "SELECT o_sessions.*,o_users.username,o_tracker.*,o_preferences.value FROM o_sessions
LEFT JOIN o_users ON o_sessions.user_id=o_users.user_id LEFT JOIN o_tracker ON
o_sessions.user_id=o_tracker.user_id LEFT JOIN o_preferences ON o_preferences.user_id=
o_users.user_id WHERE o_preferences.service='gl' AND o_preferences.preference='persistent'
ORDER BY o_sessions.user_id";
$db->query($sql);
$class = "list_header";
echo $buffer = $html->create_list(
$replace_header = array(
"STYLE" => $class,
"LINK" => $_SERVER['PHP_SELF'],
"DROP" => $text['drop'],
"USERNAME" => $text['username'],
"LOGIN_TIME" => $text['login_time'],
"SESSION_EXPIRE"=> $text['session_expire'],
"LAST_ACTIVE" => $text['last_active'],
"IDLE_TIME" => $text['idle_time']),
$O->dir ."/admin/html/sessions_hdr.html");
$j = 0;
while($db->fetch_results())
{
$class = $html->list_class($class);
$today = date('U');
$ghost_date = $today - 604800;
if(time() > $db->record['expires'])
{
$j++;
$class = "expired";
}
//MOVE TO FUNCTION
$now = time();
$last_action = $db->record['last_action_time'];
$idle_seconds = $now - $last_action;
$idle_time = $days = floor($idle_seconds / DAY_SEC);
$remainder = $idle_seconds % DAY_SEC;
$idle_time .= ":";
$idle_time .= str_pad($hours = floor($remainder / HOUR_SEC), 2 , '0', STR_PAD_LEFT); // printf('%02d', $hours = floor($remainder / HOUR_SEC));
$remainder = $remainder % HOUR_SEC;
$idle_time .= ":";
$min = floor($remainder / 60);
$idle_time .= str_pad($min, 2, '0', STR_PAD_LEFT); //printf('%02d', $min);
$idle_time .= ":";
$remainder = $remainder % 60;
$idle_time .= str_pad($remainder, 2 , '0', STR_PAD_LEFT); //printf('%02d', $remainder % 60);
//END FUNCTION
echo $buffer = $html->create_list(
$replace_header = array(
"STYLE" => $class,
"SESSION_ID" => $db->record['session_id'],
"USERNAME" => $O->create_link("/admin/edit_user.php?user={$db->record['user_id']}", $db->record['username'], $class),
"LOGIN_DATE" => date($date->short_date, $db->record['login_date']) ." - ". date($date->time, $db->record['login_date']),
"EXPIRES" => date($date->short_date. '-'. $date->time, $db->record['expires']),
"LAST_ACTIVE" => date($date->short_date, $db->record['last_action_time']) ." - ". date($date->time, $db->record['last_action_time']),
"IDLE_TIME" => $idle_time),
$O->dir ."/admin/html/sessions_list.html");
}
echo $buffer = $html->create_list(
$replace_header = array(
"STYLE" => $class,
"TOTAL_SESSIONS" => $text['total_sessions'],
"TOTAL_COUNT" => $db->num_rows,
"EXPIRED_SESSIONS" => $text['expired_sessions'],
"EXPIRED_COUNT" => $j,
"DROP_SESSIONS" => $text['drop_sessions']),
$O->dir ."/admin/html/sessions_ftr.html");
echo $layout->create_footer();
?>