Files
librenms-librenms/html/pages/syslog.inc.php
T

98 lines
2.5 KiB
PHP
Raw Normal View History

2007-04-03 14:10:23 +00:00
<meta http-equiv="refresh" content="60">
2010-01-09 17:21:37 +00:00
2011-05-14 10:47:29 +00:00
<?php if ($_GET['opta'] == "expunge" && $_SESSION['userlevel'] >= '10') { dbFetchCell("TRUNCATE TABLE `syslog`"); } ?>
<?php print_optionbar_start('25'); ?>
2010-01-09 17:21:37 +00:00
2008-12-09 13:55:41 +00:00
<form method="post" action="">
<span style="font-weight: bold;">Syslog</span> &#187;
2008-11-26 12:55:55 +00:00
<label><strong>Search</strong>
<input type="text" name="string" id="string" value="<?php echo($_POST['string']); ?>" />
2008-11-26 12:55:55 +00:00
</label>
<label>
<strong>Program</strong>
<select name="program" id="program">
<option value="">All Programs</option>
<?php
2011-05-12 22:33:43 +00:00
foreach (dbFetchRows("SELECT `program` FROM `syslog` GROUP BY `program` ORDER BY `program`") as $data)
{
echo("<option value='".$data['program']."'");
2011-09-20 14:37:54 +00:00
if ($data['program'] == $_POST['program']) { echo("selected"); }
2008-12-09 13:55:41 +00:00
echo(">".$data['program']."</option>");
2008-11-26 12:55:55 +00:00
}
?>
</select>
</label>
<label>
<strong>Device</strong>
<select name="device" id="device">
<option value="">All Devices</option>
<?php
2011-05-12 22:33:43 +00:00
foreach (dbFetchRows("SELECT * FROM `devices` ORDER BY `hostname`") as $data)
{
2008-11-26 12:55:55 +00:00
echo("<option value='".$data['device_id']."'");
2008-12-09 13:55:41 +00:00
2011-09-20 14:37:54 +00:00
if ($data['device_id'] == $_POST['device']) { echo("selected"); }
2008-11-26 12:55:55 +00:00
echo(">".$data['hostname']."</option>");
}
?>
</select>
</label>
<input type=submit class=submit value=Search>
2008-11-26 12:55:55 +00:00
</form>
2009-09-07 11:07:59 +00:00
<?php
2007-04-03 14:10:23 +00:00
2010-01-09 17:21:37 +00:00
print_optionbar_end();
2011-03-17 16:35:18 +00:00
if ($_POST['string'])
{
2011-05-12 22:33:43 +00:00
$where = " AND S.msg LIKE ?";
$array[] = "%".$_POST['string']."%";
2008-12-09 13:55:41 +00:00
}
2011-03-17 16:35:18 +00:00
if ($_POST['program'])
{
2011-05-12 22:33:43 +00:00
$where .= " AND S.program = ?";
$array[] = $_POST['program'];
2008-12-09 13:55:41 +00:00
}
2011-05-17 21:35:29 +00:00
if (is_numeric($_POST['device']))
2011-03-17 16:35:18 +00:00
{
2011-05-17 21:35:29 +00:00
$where .= " AND S.device_id = ?";
2011-05-12 22:33:43 +00:00
$array[] = $_POST['device'];
2008-12-09 13:55:41 +00:00
}
2011-03-17 16:35:18 +00:00
if ($_SESSION['userlevel'] >= '5')
{
2011-05-17 22:10:23 +00:00
$sql = "SELECT *, DATE_FORMAT(timestamp, '%Y-%m-%d %T') AS date from syslog AS S";
2011-09-20 14:37:54 +00:00
if (count($array))
2011-05-17 21:35:29 +00:00
{
$sql .= " WHERE 1 ".$where;
}
$sql .= " ORDER BY timestamp DESC LIMIT 1000";
2009-08-12 15:20:20 +00:00
} else {
2011-05-17 22:10:23 +00:00
$sql = "SELECT *, DATE_FORMAT(timestamp, '%Y-%m-%d %T') AS date from syslog AS S, devices_perms AS P";
2011-05-17 21:35:29 +00:00
$sql .= "WHERE S.device_id = P.device_id AND P.user_id = ?";
2011-09-20 14:37:54 +00:00
if (count($array))
2011-05-17 21:35:29 +00:00
{
$sql .= " WHERE 1 ".$where;
}
$sql .= " ORDER BY timestamp DESC LIMIT 1000";
2011-05-12 22:33:43 +00:00
$array = array_merge(array($_SESSION['user_id']), $array);
2009-08-12 15:20:20 +00:00
}
2007-06-24 14:56:47 +00:00
echo("<table cellspacing=0 cellpadding=2 width=100%>");
2011-05-12 22:33:43 +00:00
foreach (dbFetchRows($sql, $array) as $entry)
2011-03-17 16:35:18 +00:00
{
$entry = array_merge($entry, device_by_id_cache($entry['device_id']));
2011-03-17 16:35:18 +00:00
include("includes/print-syslog.inc.php");
}
2007-06-24 14:56:47 +00:00
echo("</table>");
2007-04-03 14:10:23 +00:00
2011-05-12 22:33:43 +00:00
?>