", $text);
// Rolling log options
//====================
$text = "
\n
";
$ns->tablerender("
".RL_LAN_011."
", $text);
}
//====================================================================
// LOG VIEW MENU
//====================================================================
if (($action == "rolllog") || ($action == "adminlog") || ($action == "auditlog"))
{
$from = intval(varset($qs[1], 0)); // First entry to display
$amount = max(varset($pref['sys_log_perpage'], 20),5); // Number of entries per page
// Array decides which filters are active for each log. There are 4 columns total. All but 'datetimes' occupy 2. Must specify multiple of 4 columns - add 'blank' if necessary
$active_filters = array('adminlog' => array('datetimes'=>0,'ipfilter'=>0,'userfilter'=>0,'eventfilter'=>0,'priority'=>0),
'auditlog' => array('datetimes'=>0,'ipfilter'=>0,'userfilter'=>0,'eventfilter'=>0,'blank'=>2),
'rolllog' => array('datetimes'=>0,'ipfilter'=>0,'userfilter'=>0,'eventfilter'=>0,'priority'=>0,'callerfilter'=>0,'blank'=>2));
// Arrays determine column widths, headings, displayed fields for each log
$col_widths = array('adminlog' => array(18,4,14,7,15,8,14,20), // Date - Pri - IP - UID - User - Code - Event - Info
'auditlog' => array(18,14,7,15,8,14,24),
'rolllog' => array(15,4,12,6,12,7,13,13,18)); // Date - Pri - IP - UID - User - Code - Caller - Event - Info
$col_titles = array('adminlog' => array(RL_LAN_019,RL_LAN_032,RL_LAN_020,RL_LAN_021,RL_LAN_022,RL_LAN_023,RL_LAN_025,RL_LAN_033),
'auditlog' => array(RL_LAN_019,RL_LAN_020,RL_LAN_021,RL_LAN_022,RL_LAN_023,RL_LAN_025,RL_LAN_033),
'rolllog' => array(RL_LAN_019,RL_LAN_032,RL_LAN_020,RL_LAN_021,RL_LAN_022,RL_LAN_023,RL_LAN_024,RL_LAN_025,RL_LAN_033));
$col_fields = array('adminlog' => array('cf_datestring','dblog_type','dblog_ip','dblog_user_id','user_name','dblog_eventcode','dblog_title','dblog_remarks'),
'auditlog' => array('cf_datestring','dblog_ip','dblog_user_id','dblog_user_name','dblog_eventcode','dblog_title','dblog_remarks'),
'rolllog' => array('cf_datestring','dblog_type','dblog_ip','dblog_user_id','dblog_user_name','dblog_eventcode','dblog_caller','dblog_title','dblog_remarks'));
// Check things
if ($start_time >= $end_time)
{ // Make end time beginning of tomorrow
$tempdate = getdate();
$end_time = mktime(0,0,0,$tempdate['mon'],$tempdate['mday']+1,$tempdate['year']); // Seems odd, but mktime will work this out OK
// (or so the manual says)
}
// Now work out the query - only use those filters which are displayed
$qry = '';
$and_array = array();
foreach ($active_filters[$action] as $fname=>$fpars)
{
switch ($fname)
{
case 'datetimes' :
if ($start_enabled && ($start_time > 0)) $and_array[] = "`dblog_datestamp` >= ".intval($start_time);
if ($end_enabled && ($end_time > 0)) $and_array[] = "`dblog_datestamp` <= ".intval($end_time);
break;
case 'ipfilter' :
if ($ipaddress_filter != "")
{
if (substr($ipaddress_filter,-1) == '*')
{ // Wildcard to handle - mySQL uses %
$and_array[] = "`dblog_ip` LIKE '".substr($ipaddress_filter,0,-1)."%' ";
}
else
{
$and_array[] = "`dblog_ip`= '".$ipaddress_filter."' ";
}
}
break;
case 'userfilter' :
if ($user_filter != '') $and_array[] = "`dblog_user_id` = ".intval($user_filter);
break;
case 'eventfilter' :
if ($event_filter != '')
{
if (substr($event_filter,-1) == '*')
{ // Wildcard to handle - mySQL uses %
$and_array[] = " `dblog_eventcode` LIKE '".substr($event_filter,0,-1)."%' ";
}
else
{
$and_array[] = "`dblog_eventcode`= '".$event_filter."' ";
}
}
break;
case 'callerfilter' :
if ($caller_filter != '')
{
if (substr($caller_filter,-1) == '*')
{ // Wildcard to handle - mySQL uses %
$and_array[] = "`dblog_caller` LIKE '".substr($caller_filter,0,-1)."%' ";
}
else
{
$and_array[] = "`dblog_caller`= '".$caller_filter."' ";
}
}
break;
case 'priority' :
if (($pri_filter_val != "") && ($pri_filter_cond != "") && ($pri_filter_cond != "xx"))
{
switch ($pri_filter_cond)
{
case "lt" :
$and_array[] = "`dblog_type` <= '{$pri_filter_val}' ";
break;
case "eq" :
$and_array[] = "`dblog_type` = '{$pri_filter_val}' ";
break;
case "gt" :
$and_array[] = "`dblog_type` >= '{$pri_filter_val}' ";
break;
}
}
break;
}
}
if (count($and_array)) $qry = " WHERE ".implode(' AND ',$and_array);
$num_entry = $sql->db_Count($log_db_table[$action], "(*)", $qry);
if ($from > $num_entry) $from = 0; // We may be on a later page
$qry = "SELECT dbl.*,u.user_name FROM #".$log_db_table[$action]." AS dbl LEFT JOIN #user AS u ON dbl.dblog_user_id=u.user_id".$qry." ORDER BY {$sort_field} ".$sort_order." LIMIT {$from}, {$amount} ";
// Start by putting up the filter boxes
$text = "
";
// Next bit is the actual log display - the arrays define column widths, titles, fields etc for each log
$column_count = count($col_widths[$action]);
$text .= "