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

109 lines
2.7 KiB
PHP
Raw Normal View History

2011-10-18 14:41:19 +00:00
<?php
2011-10-18 14:41:19 +00:00
if ($_vars['action'] == "expunge" && $_SESSION['userlevel'] >= '10') { dbFetchCell("TRUNCATE TABLE `syslog`"); }
print_optionbar_start('25');
$pagetitle[] = "Syslog";
?>
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
foreach (dbFetchRows("SELECT DISTINCT `program` FROM `syslog` 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
foreach (get_all_devices() as $hostname)
{
echo("<option value='".getidbyname($hostname)."'");
2008-12-09 13:55:41 +00:00
if (getidbyname($hostname) == $_POST['device']) { echo("selected"); }
echo(">".$hostname."</option>");
2008-11-26 12:55:55 +00:00
}
?>
</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
}
echo('<div class="panel panel-default panel-condensed">
<div class="panel-heading">
<strong>Eventlog entries</strong>
</div>
<table class="table table-hover table-condensed table-striped">');
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']));
2012-04-06 13:56:23 +00:00
2011-03-17 16:35:18 +00:00
include("includes/print-syslog.inc.php");
}
echo("</table>
</div>");
2007-04-03 14:10:23 +00:00
2011-05-12 22:33:43 +00:00
?>