<strong>Syslog entries</strong> </div> <table class="table table-hover table-condensed table-striped">'; foreach (dbFetchRows($sql) as $entry) { $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); unset($syslog_output); include 'includes/print-syslog.inc.php'; echo $syslog_output; } echo '</table>'; echo '</div>'; echo '</div>'; echo '</div>'; echo '</div>'; } else { if (is_admin() === true || is_read() === true) { $query = "SELECT *,DATE_FORMAT(datetime, '" . $config['dateformat']['mysql']['compact'] . "') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; $alertquery = 'SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id ORDER BY `time_logged` DESC LIMIT 0,15'; } else { $query = "SELECT *,DATE_FORMAT(datetime, '" . $config['dateformat']['mysql']['compact'] . "') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = P.device_id AND P.user_id = " . $_SESSION['user_id'] . ' ORDER BY `datetime` DESC LIMIT 0,15'; $alertquery = 'SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id RIGHT JOIN devices_perms ON alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = ' . $_SESSION['user_id'] . ' ORDER BY `time_logged` DESC LIMIT 0,15'; } echo '<div class="container-fluid"> <div class="row"> <div class="col-md-6"> </div> </div> <div class="row"> <div class="col-md-6 column"> <div class="panel panel-default panel-condensed">
} foreach (dbFetchRows($sql, $param) as $data) { if ($data['ifType']) { echo ' <option value="' . $data['ifType'] . '"'; if ($data['ifType'] == $vars['ifType']) { echo "selected"; } echo ">" . $data['ifType'] . "</option>"; } } ?> </select> <select name="port_descr_type" id="port_descr_type" class="form-control input-sm"> <option value="">All Port Types</option> <?php if (is_admin() === TRUE || is_read() === TRUE) { $sql = "SELECT `port_descr_type` FROM `ports` GROUP BY `port_descr_type` ORDER BY `port_descr_type`"; } else { $sql = "SELECT `port_descr_type` FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P`, `ports_perms` AS `PP` WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id`) OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `D`.`device_id`)) AND `D`.`device_id` = `I`.`device_id` GROUP BY `port_descr_type` ORDER BY `port_descr_type`"; $param[] = array($_SESSION['user_id'], $_SESSION['user_id']); } $ports = dbFetchRows($sql, $param); foreach ($ports as $data) { if ($data['port_descr_type']) { echo ' <option value="' . $data['port_descr_type'] . '"'; if ($data['port_descr_type'] == $vars['port_descr_type']) { echo "selected"; } echo ">" . ucfirst($data['port_descr_type']) . "</option>"; } }
function is_normal_user() { if (is_admin() === false && is_read() === false && is_demo_user() === false) { return true; } else { return false; } }
</div> <script> var grid = $("#mac-search").bootgrid({ ajax: true, templates: { header: "<div id=\"{{ctx.id}}\" class=\"{{css.header}}\"><div class=\"row\">"+ "<div class=\"col-sm-9 actionBar\"><span class=\"pull-left\">"+ "<form method=\"post\" action=\"\" class=\"form-inline\" role=\"form\">"+ "<div class=\"form-group\">"+ "<select name=\"device_id\" id=\"device_id\" class=\"form-control input-sm\">"+ "<option value=\"\">All Devices</option>"+ <?php $sql = 'SELECT `devices`.`device_id`,`hostname` FROM `devices`'; if (is_admin() === false && is_read() === false) { $sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`'; $where .= ' WHERE `DP`.`user_id`=?'; $param[] = $_SESSION['user_id']; } $sql .= " {$where} GROUP BY `hostname` ORDER BY `hostname`"; foreach (dbFetchRows($sql, $param) as $data) { echo '"<option value=\\"' . $data['device_id'] . '\\""+'; if ($data['device_id'] == $_POST['device_id']) { echo '" selected "+'; } echo '">' . $data['hostname'] . '</option>"+'; } ?> "</select>"+ "</div>"+
} }); }); </script> <style> .twitter-typeahead { width: 100%; } </style> '; } else { $interval = $widget_settings['time_interval']; (int) ($lastpoll_seconds = $interval * 60); (int) ($interface_count = $widget_settings['interface_count']); $params = array('user' => $_SESSION['user_id'], 'lastpoll' => array($lastpoll_seconds), 'count' => array($interface_count), 'filter' => $widget_settings['interface_filter'] ?: (int) 1); if (is_admin() || is_read()) { $query = ' SELECT p.*, devices.*, p.ifInOctets_rate + p.ifOutOctets_rate as total FROM ports as p INNER JOIN devices ON p.device_id = devices.device_id AND unix_timestamp() - p.poll_time <= :lastpoll AND ( p.ifType = :filter || 1 = :filter ) AND ( p.ifInOctets_rate > 0 || p.ifOutOctets_rate > 0 ) ORDER BY total DESC LIMIT :count '; } else { $query = ' SELECT ports.*, devices.*, ports.ifInOctets_rate + ports.ifOutOctets_rate as total FROM ports INNER JOIN devices ON ports.device_id = devices.device_id
<?php $graph_type = "mempool_usage"; $where = 1; $sql = " FROM `mempools` AS `M` LEFT JOIN `devices` AS `D` ON `M`.`device_id` = `D`.`device_id`"; if (is_admin() === FALSE && is_read() === FALSE) { $sql .= " LEFT JOIN `devices_perms` AS `DP` ON `M`.`device_id` = `DP`.`device_id`"; $where .= " AND `DP`.`user_id`=?"; $param[] = $_SESSION['user_id']; } $sql .= " WHERE {$where}"; if (isset($searchPhrase) && !empty($searchPhrase)) { $sql .= " AND (`hostname` LIKE '%{$searchPhrase}%' OR `mempool_descr` LIKE '%{$searchPhrase}%')"; } $count_sql = "SELECT COUNT(`mempool_id`) {$sql}"; $count = dbFetchCell($count_sql, $param); if (empty($count)) { $count = 0; } if (!isset($sort) || empty($sort)) { $sort = '`D`.`hostname`, `M`.`mempool_descr`'; } $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 * {$sql}";
function csv() { global $db; global $config; global $dbname; $sql = _post('sql'); if (empty($sql) || is_read($sql)) { $err = null; try { $table_data = $sql ? $db->queryAll($sql, $where) : []; } catch (PdoException $e) { $err = $e->errorInfo; } $file = '/tmp/' . uniqid() . '.csv'; $f = fopen($file, 'w'); foreach ($table_data ?: [] as $row) { fputcsv($f, $row); } fclose($f); readfile($file); } }