diff --git a/html/includes/table/syslog.inc.php b/html/includes/table/syslog.inc.php new file mode 100644 index 000000000..ca041fe2a --- /dev/null +++ b/html/includes/table/syslog.inc.php @@ -0,0 +1,75 @@ += ?"; + $param[] = $_POST['from']; +} +if( !empty($_POST['to']) ) { + $where .= " AND timestamp <= ?"; + $param[] = $_POST['to']; +} + +if ($_SESSION['userlevel'] >= '5') +{ + $sql = "FROM syslog AS S"; + $sql .= " WHERE ".$where; +} else { + $sql = "FROM syslog AS S, devices_perms AS P"; + $sql .= "WHERE S.device_id = P.device_id AND P.user_id = ?"; + $sql .= $where; + $param = array_merge(array($_SESSION['user_id']), $param); +} + +$count_sql = "SELECT COUNT(timestamp) $sql"; +$total = dbFetchCell($count_sql,$param); +if (empty($total)) { + $total = 0; +} + +if (!isset($sort) || empty($sort)) { + $sort = 'timestamp DESC'; +} + +$sql .= " ORDER BY $sort"; + +if (isset($current)) { + $limit_low = ($current * $rowCount) - ($rowCount); + $limit_high = $rowCount; +} + +if ($rowCount != -1) { + $sql .= " LIMIT $limit_low,$limit_high"; +} + +$sql = "SELECT S.*, DATE_FORMAT(timestamp, '%Y-%m-%d %T') AS date $sql"; + +foreach (dbFetchRows($sql,$param) as $syslog) { + $dev = device_by_id_cache($syslog['device_id']); + $response[] = array('timestamp'=>$syslog['date'], + 'device_id'=>generate_device_link($dev, shorthost($dev['hostname'])), + 'program'=>$syslog['program'], + 'msg'=>htmlspecialchars($syslog['msg'])); +} + +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +echo _json_encode($output); +?> diff --git a/html/pages/syslog.inc.php b/html/pages/syslog.inc.php index ed2d09811..93a112ec1 100644 --- a/html/pages/syslog.inc.php +++ b/html/pages/syslog.inc.php @@ -1,108 +1,102 @@ = '10') { dbFetchCell("TRUNCATE TABLE `syslog`"); } +$no_refresh = TRUE; -print_optionbar_start('25'); +$param = array(); + +if ($vars['action'] == "expunge" && $_SESSION['userlevel'] >= '10') +{ + dbQuery("TRUNCATE TABLE `syslog`"); + print_message("syslog truncated"); +} $pagetitle[] = "Syslog"; +print_optionbar_start(); + ?> - -
- Syslog » - - - - - + +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
= '5') -{ - $sql = "SELECT *, DATE_FORMAT(timestamp, '%Y-%m-%d %T') AS date from syslog AS S"; - if (count($array)) - { - $sql .= " WHERE 1 ".$where; - } - $sql .= " ORDER BY timestamp DESC LIMIT 1000"; -} else { - $sql = "SELECT *, DATE_FORMAT(timestamp, '%Y-%m-%d %T') AS date from syslog AS S, devices_perms AS P"; - $sql .= "WHERE S.device_id = P.device_id AND P.user_id = ?"; - if (count($array)) - { - $sql .= " WHERE 1 ".$where; - } - $sql .= " ORDER BY timestamp DESC LIMIT 1000"; - - $array = array_merge(array($_SESSION['user_id']), $array); -} - -echo('
-
- Eventlog entries -
- '); - -foreach (dbFetchRows($sql, $array) as $entry) -{ - $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); - - include("includes/print-syslog.inc.php"); -} - -echo("
-
"); - ?> +
+ + + + + + + + + +
DatetimeHostnameProgramMessage
+
+