Added session_flags column to phpgw_sessions

This commit is contained in:
jengo 2001-02-28 15:58:26 +00:00
parent c3e29775ab
commit e959832db1
7 changed files with 207 additions and 152 deletions

View File

@ -1,100 +1,118 @@
<?php <?php
/**************************************************************************\ /**************************************************************************\
* phpGroupWare - administration * * phpGroupWare - administration *
* http://www.phpgroupware.org * * http://www.phpgroupware.org *
* -------------------------------------------- * * -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it * * 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 * * 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 * * Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. * * option) any later version. *
\**************************************************************************/ \**************************************************************************/
/* $Id$ */ /* $Id$ */
$phpgw_info = array(); $phpgw_info['flags'] = array(
$phpgw_info["flags"] = array("currentapp" => "admin", "enable_nextmatchs_class" => True); 'currentapp' => 'admin',
include("../header.inc.php"); 'enable_nextmatchs_class' => True
);
include('../header.inc.php');
$phpgw->template->set_file(array("list" => "accesslog.tpl", $phpgw->template->set_file(array(
"row" => "accesslog_row.tpl")); 'list' => 'accesslog.tpl',
'row' => 'accesslog_row.tpl'
));
$show_maxlog = 30; $show_maxlog = 30;
$phpgw->template->set_var("th_bg",$phpgw_info["theme"]["th_bg"]); $phpgw->template->set_var('th_bg',$phpgw_info['theme']['th_bg']);
$phpgw->template->set_var("lang_last_x_logins",lang("Last x logins",$show_maxlog)); $phpgw->template->set_var('lang_last_x_logins',lang('Last x logins',$show_maxlog));
$phpgw->template->set_var("lang_loginid",lang("LoginID")); $phpgw->template->set_var('lang_loginid',lang('LoginID'));
$phpgw->template->set_var("lang_ip",lang("IP")); $phpgw->template->set_var('lang_ip',lang('IP'));
$phpgw->template->set_var("lang_login",lang("Login")); $phpgw->template->set_var('lang_login',lang('Login'));
$phpgw->template->set_var("lang_logout",lang("Logout")); $phpgw->template->set_var('lang_logout',lang('Logout'));
$phpgw->template->set_var("lang_total",lang("Total")); $phpgw->template->set_var('lang_total',lang('Total'));
$phpgw->db->query("select loginid,ip,li,lo from phpgw_access_log order by li desc " $phpgw->db->query("select loginid,ip,li,lo from phpgw_access_log order by li desc "
. "limit $show_maxlog"); . "limit $show_maxlog");
while ($phpgw->db->next_record()) { while ($phpgw->db->next_record())
{
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
$phpgw->template->set_var('tr_color',$tr_color);
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color); if ($phpgw->db->f('li') && $phpgw->db->f('lo'))
$phpgw->template->set_var("tr_color",$tr_color); {
$total = ($phpgw->db->f('lo') - $phpgw->db->f('li'));
if ($total > 86400 && $total > 172800)
{
$total = gmdate('z \d\a\y\s - G:i:s',$total);
}
else if ($total > 172800)
{
$total = gmdate('z \d\a\y - G:i:s',$total);
}
else
{
$total = gmdate('G:i:s',$total);
}
}
else
{
$total = '&nbsp;';
}
// In case there was a problem creating there session. eg, bad login time if ($phpgw->db->f('li'))
// I still want it to be printed here. This will alert the admin there {
// is a problem. $li = $phpgw->common->show_date($phpgw->db->f('li'));
if ($phpgw->db->f("li") && $phpgw->db->f("lo")) { }
$total = ($phpgw->db->f("lo") - $phpgw->db->f("li")); else
if ($total > 86400 && $total > 172800) { {
$total = gmdate("z \d\a\y\s - G:i:s",$total); $li = '&nbsp;';
} else if ($total > 172800) { }
$total = gmdate("z \d\a\y - G:i:s",$total);
} else { if ($phpgw->db->f('lo') != '')
$total = gmdate("G:i:s",$total); {
} $lo = $phpgw->common->show_date($phpgw->db->f('lo'));
} else { }
$total = "&nbsp;"; else
} {
$lo = '&nbsp;';
}
if (ereg('@',$phpgw->db->f('loginid')))
{
$t = split('@',$phpgw->db->f('loginid'));
$loginid = $t[0];
}
else
{
$loginid = $phpgw->db->f('loginid');
}
if ($phpgw->db->f("li")) { $phpgw->template->set_var('row_loginid',$loginid);
$li = $phpgw->common->show_date($phpgw->db->f("li")); $phpgw->template->set_var('row_ip',$phpgw->db->f('ip'));
} else { $phpgw->template->set_var('row_li',$li);
$li = "&nbsp;"; $phpgw->template->set_var('row_lo',$lo);
} $phpgw->template->set_var('row_total',$total);
if ($phpgw->db->f("lo") != '') { $phpgw->template->parse('rows','row',True);
$lo = $phpgw->common->show_date($phpgw->db->f("lo")); }
} else {
$lo = "&nbsp;";
}
if (ereg("@",$phpgw->db->f("loginid"))) { $phpgw->db->query("select count(*) from phpgw_access_log");
$t = split("@",$phpgw->db->f("loginid")); $phpgw->db->next_record();
$loginid = $t[0]; $total = $phpgw->db->f(0);
} else {
$loginid = $phpgw->db->f("loginid");
}
$phpgw->template->set_var("row_loginid",$loginid); $phpgw->db->query("select count(*) from phpgw_access_log where lo!=''");
$phpgw->template->set_var("row_ip",$phpgw->db->f("ip")); $phpgw->db->next_record();
$phpgw->template->set_var("row_li",$li); $loggedout = $phpgw->db->f(0);
$phpgw->template->set_var("row_lo",$lo);
$phpgw->template->set_var("row_total",$total);
$phpgw->template->parse("rows","row",True); $percent = round((10000 * ($loggedout / $total)) / 100);
}
$phpgw->db->query("select count(*) from phpgw_access_log"); $phpgw->template->set_var('bg_color',$phpgw_info['themes']['bg_color']);
$phpgw->db->next_record(); $phpgw->template->set_var('footer_total',lang('Total records') . ': ' . $total);
$total = $phpgw->db->f(0); $phpgw->template->set_var('lang_percent',lang('Percent of users that logged out') . ': ' . $percent . '%');
$phpgw->db->query("select count(*) from phpgw_access_log where lo!=''"); $phpgw->template->pparse('out','list');
$phpgw->db->next_record();
$loggedout = $phpgw->db->f(0);
$percent = round((10000 * ($loggedout / $total)) / 100); $phpgw->common->phpgw_footer();
$phpgw->template->set_var("bg_color",$phpgw_info["themes"]["bg_color"]);
$phpgw->template->set_var("footer_total",lang("Total records") . ": $total");
$phpgw->template->set_var("lang_percent",lang("Percent of users that logged out") . ": $percent%");
$phpgw->template->pparse("out","list");
$phpgw->common->phpgw_footer();
?> ?>

View File

@ -1,87 +1,102 @@
<?php <?php
/**************************************************************************\ /**************************************************************************\
* phpGroupWare - administration * * phpGroupWare - administration *
* http://www.phpgroupware.org * * http://www.phpgroupware.org *
* -------------------------------------------- * * -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it * * 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 * * 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 * * Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. * * option) any later version. *
\**************************************************************************/ \**************************************************************************/
/* $Id$ */ /* $Id$ */
$phpgw_info = array(); $phpgw_info['flags'] = array(
$phpgw_info["flags"] = array("currentapp" => "admin", "enable_nextmatchs_class" => True); 'currentapp' => 'admin',
include("../header.inc.php"); 'enable_nextmatchs_class' => True
);
include('../header.inc.php');
$phpgw->template->set_file(array("list" => "currentusers.tpl", $phpgw->template->set_file(array(
"row" => "currentusers_row.tpl")); 'list' => 'currentusers.tpl',
'row' => 'currentusers_row.tpl'
));
if (! $start) { if (! $start)
$start = 0; {
} $start = 0;
}
$limit = $phpgw->db->limit($start); $limit = $phpgw->db->limit($start);
$phpgw->db->query("select count(*) from phpgw_sessions",__LINE__,__FILE__); $phpgw->db->query("select count(*) from phpgw_sessions where session_flags != 'A'",__LINE__,__FILE__);
$phpgw->db->next_record(); $phpgw->db->next_record();
$total = $phpgw->db->f(0); $total = $phpgw->db->f(0);
$phpgw->template->set_var("lang_current_users",lang("List of current users")); $phpgw->template->set_var('lang_current_users',lang('List of current users'));
$phpgw->template->set_var("bg_color",$phpgw_info["theme"][bg_color]); $phpgw->template->set_var('bg_color',$phpgw_info['theme'][bg_color]);
$phpgw->template->set_var("left_next_matchs",$phpgw->nextmatchs->left("currentusers.php",$start,$total)); $phpgw->template->set_var('left_next_matchs',$phpgw->nextmatchs->left('currentusers.php',$start,$total));
$phpgw->template->set_var("right_next_matchs",$phpgw->nextmatchs->right("currentusers.php",$start,$total)); $phpgw->template->set_var('right_next_matchs',$phpgw->nextmatchs->right('currentusers.php',$start,$total));
$phpgw->template->set_var("th_bg",$phpgw_info["theme"]["th_bg"]); $phpgw->template->set_var('th_bg',$phpgw_info['theme']['th_bg']);
$phpgw->template->set_var("sort_loginid",$phpgw->nextmatchs->show_sort_order($sort,"session_lid",$order, $phpgw->template->set_var('sort_loginid',$phpgw->nextmatchs->show_sort_order($sort,'session_lid',$order,
"currentusers.php",lang("LoginID"))); 'currentusers.php',lang('LoginID')));
$phpgw->template->set_var("sort_ip",$phpgw->nextmatchs->show_sort_order($sort,"session_ip",$order, $phpgw->template->set_var('sort_ip',$phpgw->nextmatchs->show_sort_order($sort,'session_ip',$order,
"currentusers.php",lang("IP"))); 'currentusers.php',lang('IP')));
$phpgw->template->set_var("sort_login_time",$phpgw->nextmatchs->show_sort_order($sort,"session_logintime",$order, $phpgw->template->set_var('sort_login_time',$phpgw->nextmatchs->show_sort_order($sort,'session_logintime',$order,
"currentusers.php",lang("Login Time"))); 'currentusers.php',lang('Login Time')));
$phpgw->template->set_var("sort_action",$phpgw->nextmatchs->show_sort_order($sort,"session_action",$order, $phpgw->template->set_var('sort_action',$phpgw->nextmatchs->show_sort_order($sort,'session_action',$order,
"currentusers.php",lang("Action"))); 'currentusers.php',lang('Action')));
$phpgw->template->set_var("sort_idle",$phpgw->nextmatchs->show_sort_order($sort,"session_dla",$order, $phpgw->template->set_var('sort_idle',$phpgw->nextmatchs->show_sort_order($sort,'session_dla',$order,
"currentusers.php",lang("idle"))); 'currentusers.php',lang('idle')));
$phpgw->template->set_var("lang_kill",lang("Kill")); $phpgw->template->set_var('lang_kill',lang('Kill'));
if ($order) { if ($order)
$ordermethod = "order by $order $sort"; {
} else { $ordermethod = "order by $order $sort";
$ordermethod = "order by session_dla asc"; }
} else
{
$ordermethod = 'order by session_dla asc';
}
$phpgw->db->query("select * from phpgw_sessions $ordermethod " . $phpgw->db->limit($start),__LINE__,__FILE__); $phpgw->db->query("select * from phpgw_sessions where session_flags != 'A' $ordermethod " . $phpgw->db->limit($start),__LINE__,__FILE__);
$i = 0; $i = 0;
while ($phpgw->db->next_record()) { while ($phpgw->db->next_record())
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color); {
$phpgw->template->set_var("tr_color",$tr_color); $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
$phpgw->template->set_var('tr_color',$tr_color);
if (ereg("@",$phpgw->db->f("session_lid"))) { if (ereg('@',$phpgw->db->f('session_lid')))
$t = split("@",$phpgw->db->f("session_lid")); {
$loginid = $t[0]; $t = split('@',$phpgw->db->f('session_lid'));
} else { $loginid = $t[0];
$loginid = $phpgw->db->f("session_lid"); }
} else
{
$loginid = $phpgw->db->f('session_lid');
}
$phpgw->template->set_var("row_loginid",$loginid); $phpgw->template->set_var('row_loginid',$loginid);
$phpgw->template->set_var("row_ip",$phpgw->db->f("session_ip")); $phpgw->template->set_var('row_ip',$phpgw->db->f('session_ip'));
$phpgw->template->set_var("row_logintime",$phpgw->common->show_date($phpgw->db->f("session_logintime"))); $phpgw->template->set_var('row_logintime',$phpgw->common->show_date($phpgw->db->f('session_logintime')));
$phpgw->template->set_var("row_action",$phpgw->strip_html($phpgw->db->f("session_action"))); $phpgw->template->set_var('row_action',$phpgw->strip_html($phpgw->db->f('session_action')));
$phpgw->template->set_var("row_idle",gmdate("G:i:s",(time() - $phpgw->db->f("session_dla")))); $phpgw->template->set_var('row_idle',gmdate('G:i:s',(time() - $phpgw->db->f('session_dla'))));
if ($phpgw->db->f("session_id") != $phpgw_info["user"]["sessionid"]) { if ($phpgw->db->f('session_id') != $phpgw_info['user']['sessionid'])
$phpgw->template->set_var("row_kill",'<a href="' . $phpgw->link("killsession.php","ksession=" {
. $phpgw->db->f("session_id") . "&kill=true") . "\">" . lang("Kill").'</a>'); $phpgw->template->set_var('row_kill','<a href="' . $phpgw->link('killsession.php','ksession='
} else { . $phpgw->db->f('session_id') . '&kill=true') . '">' . lang('Kill').'</a>');
$phpgw->template->set_var("row_kill","&nbsp;"); }
} else
{
$phpgw->template->set_var('row_kill','&nbsp;');
}
$phpgw->template->parse("rows","row",True); $phpgw->template->parse('rows','row',True);
} }
$phpgw->template->pparse("out","list"); $phpgw->template->pparse('out','list');
$phpgw->common->phpgw_footer(); $phpgw->common->phpgw_footer();
?> ?>

View File

@ -60,6 +60,7 @@
session_logintime int(11), session_logintime int(11),
session_dla int(11), session_dla int(11),
session_action varchar(255), session_action varchar(255),
session_flags char(2),
UNIQUE sessionid (session_id) UNIQUE sessionid (session_id)
)"; )";
$phpgw_setup->db->query($sql); $phpgw_setup->db->query($sql);

View File

@ -1211,6 +1211,16 @@
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre14'; $phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre14';
} }
$test[] = '0.9.10pre14';
function upgrade0_9_10pre14()
{
global $phpgw_info, $phpgw_setup;
$phpgw_setup->db->query("alter table phpgw_sessions add column session_flags char(2)");
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre15';
}
reset ($test); reset ($test);
while (list ($key, $value) = each ($test)){ while (list ($key, $value) = each ($test)){
if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == $value) { if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == $value) {

View File

@ -59,6 +59,7 @@
session_logintime int, session_logintime int,
session_dla int, session_dla int,
session_action varchar(255), session_action varchar(255),
session_flags char(2),
unique(session_id) unique(session_id)
)"; )";
$phpgw_setup->db->query($sql); $phpgw_setup->db->query($sql);

View File

@ -1329,6 +1329,16 @@
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre14'; $phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre14';
} }
$test[] = '0.9.10pre14';
function upgrade0_9_10pre14()
{
global $phpgw_info, $phpgw_setup;
$phpgw_setup->db->query("alter table phpgw_sessions add column session_flags char(2)");
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre15';
}
reset ($test); reset ($test);
while (list ($key, $value) = each ($test)){ while (list ($key, $value) = each ($test)){
if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == $value) { if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == $value) {

View File

@ -11,5 +11,5 @@
/* $Id$ */ /* $Id$ */
$phpgw_info["server"]["versions"]["phpgwapi"] = "0.9.10pre14"; $phpgw_info["server"]["versions"]["phpgwapi"] = "0.9.10pre15";
$phpgw_info["server"]["versions"]["current_header"] = "1.11"; $phpgw_info["server"]["versions"]["current_header"] = "1.11";