2009-09-07 11:07:59 +00:00
< ? php
2007-04-03 14:10:23 +00:00
2011-10-08 22:04:56 +00:00
$param = array ();
if ( $vars [ 'action' ] == " expunge " && $_SESSION [ 'userlevel' ] >= '10' )
{
mysql_query ( " TRUNCATE TABLE `eventlog` " );
print_message ( " Event log truncated " );
}
$numresults = 250 ;
2011-10-18 14:41:19 +00:00
$pagetitle [] = " Eventlog " ;
2011-10-08 22:04:56 +00:00
print_optionbar_start ();
if ( is_numeric ( $vars [ 'page' ]))
{
$start = $vars [ 'page' ] * $numresults ;
} else
{
$start = 0 ;
}
$where = " 1 " ;
if ( is_numeric ( $_POST [ 'device' ]))
{
$where .= ' AND E.host = ?' ;
$param [] = $_POST [ 'device' ];
}
if ( $_POST [ 'string' ])
{
$where .= " AND E.message LIKE ? " ;
$param [] = " % " . $_POST [ 'string' ] . " % " ;
}
2012-04-06 13:56:23 +00:00
2011-10-08 22:04:56 +00:00
?>
2014-01-13 10:05:19 +00:00
< form method = " post " action = " " class = " form-inline " role = " form " >
< div class = " form-group " >
< input type = " text " name = " string " id = " string " value = " <?php echo( $_POST['string'] ); ?> " placeholder = " Search " class = " form-control input-sm " />
</ div >
< div class = " form-group " >
< label >
< strong > Device </ strong >
</ label >
< select name = " device " id = " device " class = " form-control input-sm " >
< option value = " " > All Devices </ option >
< ? php
foreach ( get_all_devices () as $hostname )
{
echo ( " <option value=' " . getidbyname ( $hostname ) . " ' " );
if ( getidbyname ( $hostname ) == $_POST [ 'device' ]) { echo ( " selected " ); }
echo ( " > " . $hostname . " </option> " );
}
?>
</ select >
</ div >
< button type = " submit " class = " btn btn-default input-sm " > Search </ button >
2011-10-08 22:04:56 +00:00
</ form >
< ? php
print_optionbar_end ();
2010-02-14 01:35:54 +00:00
2011-03-17 00:09:20 +00:00
if ( $_SESSION [ 'userlevel' ] >= '5' )
{
2011-10-08 22:04:56 +00:00
$query = " SELECT *,DATE_FORMAT(datetime, '%D %b %Y %T') as humandate FROM `eventlog` AS E WHERE $where ORDER BY `datetime` DESC LIMIT $start , $numresults " ;
2007-06-24 14:56:47 +00:00
} else {
2011-10-08 22:04:56 +00:00
$query = " SELECT *,DATE_FORMAT(datetime, '%D %b %Y %T') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE $where AND E.host = P.device_id AND P.user_id = ? ORDER BY `datetime` DESC LIMIT $start , $numresults " ;
$param [] = $_SESSION [ 'user_id' ];
2007-06-24 14:56:47 +00:00
}
2014-01-13 10:05:19 +00:00
echo ( '<table class="table table-condensed">' );
2007-04-03 14:10:23 +00:00
2011-05-15 14:49:26 +00:00
foreach ( dbFetchRows ( $query , $param ) as $entry )
2011-03-17 00:09:20 +00:00
{
2011-03-17 16:35:18 +00:00
include ( " includes/print-event.inc.php " );
2007-04-03 14:10:23 +00:00
}
echo ( " </table> " );
2011-05-15 14:49:26 +00:00
?>