mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 08:02:41 +02:00
Rebased from upstream
This commit is contained in:
@@ -86,7 +86,16 @@ function auth_usermanagement() {
|
||||
function adduser($username) {
|
||||
// Check to see if user is already added in the database
|
||||
if (!user_exists_in_db($username)) {
|
||||
return dbInsert(array('username' => $username, 'user_id' => get_userid($username), 'level' => "0", 'can_modify_passwd' => 0, 'twofactor' => 0), 'users');
|
||||
$userid = dbInsert(array('username' => $username, 'user_id' => get_userid($username), 'level' => "0", 'can_modify_passwd' => 0, 'twofactor' => 0), 'users');
|
||||
if ($userid == false) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
foreach (dbFetchRows('select notifications.* from notifications where not exists( select 1 from notifications_attribs where notifications.notifications_id = notifications_attribs.notifications_id and notifications_attribs.user_id = ?) order by notifications.notifications_id desc',array($userid)) as $notif) {
|
||||
dbInsert(array('notifications_id'=>$notif['notifications_id'],'user_id'=>$userid,'key'=>'read','value'=>1),'notifications_attribs');
|
||||
}
|
||||
}
|
||||
return $userid;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
|
||||
@@ -44,11 +44,20 @@ function auth_usermanagement() {
|
||||
}
|
||||
|
||||
|
||||
function adduser($username, $password, $level, $email='', $realname='', $can_modify_passwd='1') {
|
||||
function adduser($username, $password, $level, $email='', $realname='', $can_modify_passwd=1, $description='', $twofactor=0) {
|
||||
if (!user_exists($username)) {
|
||||
$hasher = new PasswordHash(8, false);
|
||||
$encrypted = $hasher->HashPassword($password);
|
||||
return dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname), 'users');
|
||||
$userid = dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname, 'can_modify_passwd' => $can_modify_passwd, 'descr' => $description, 'twofactor' => $twofactor), 'users');
|
||||
if ($userid == false) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
foreach (dbFetchRows('select notifications.* from notifications where not exists( select 1 from notifications_attribs where notifications.notifications_id = notifications_attribs.notifications_id and notifications_attribs.user_id = ?) order by notifications.notifications_id desc',array($userid)) as $notif) {
|
||||
dbInsert(array('notifications_id'=>$notif['notifications_id'],'user_id'=>$userid,'key'=>'read','value'=>1),'notifications_attribs');
|
||||
}
|
||||
}
|
||||
return $userid;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
|
||||
@@ -104,7 +104,16 @@ function adduser($username, $password, $level, $email='', $realname='', $can_mod
|
||||
if (!user_exists($username)) {
|
||||
$hasher = new PasswordHash(8, false);
|
||||
$encrypted = $hasher->HashPassword($password);
|
||||
return dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname, 'can_modify_passwd' => $can_modify_passwd, 'descr' => $description, 'twofactor' => $twofactor), 'users');
|
||||
$userid = dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname, 'can_modify_passwd' => $can_modify_passwd, 'descr' => $description, 'twofactor' => $twofactor), 'users');
|
||||
if ($userid == false) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
foreach (dbFetchRows('select notifications.* from notifications where not exists( select 1 from notifications_attribs where notifications.notifications_id = notifications_attribs.notifications_id and notifications_attribs.user_id = ?) order by notifications.notifications_id desc',array($userid)) as $notif) {
|
||||
dbInsert(array('notifications_id'=>$notif['notifications_id'],'user_id'=>$userid,'key'=>'read','value'=>1),'notifications_attribs');
|
||||
}
|
||||
}
|
||||
return $userid;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
|
||||
@@ -30,7 +30,7 @@ if ($config['map']['engine'] == 'leaflet') {
|
||||
<div class="col-sm-4">
|
||||
<label for="init_lat" class="control-label">Initial Latitude: </label>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" name="init_lat" id="input_lat_'.$unique_id.'" value="'.$widget_settings['init_lat'].'" placeholder="ie. 51.4800 for Greenwich">
|
||||
</div>
|
||||
</div>
|
||||
@@ -46,7 +46,7 @@ if ($config['map']['engine'] == 'leaflet') {
|
||||
<div class="col-sm-4">
|
||||
<label for="init_zoom" class="control-label">Initial Zoom: </label>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="col-sm-8">
|
||||
<select class="form-control" name="init_zoom" id="select_zoom'.$unique_id.'">
|
||||
';
|
||||
for ($i=0; $i<19; $i++) {
|
||||
@@ -65,10 +65,35 @@ if ($config['map']['engine'] == 'leaflet') {
|
||||
<div class="col-sm-4">
|
||||
<label for="group_radius" class="control-label">Grouping radius: </label>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" name="group_radius" id="input_radius_'.$unique_id.'" value="'.$widget_settings['group_radius'].'" placeholder="default 80">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-4">
|
||||
<label for="status" class="control-label">Show devices: </label>
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<select class="form-control" name="status" id="status_'.$unique_id.'">';
|
||||
|
||||
$temp_output .= '<option value="0,1"';
|
||||
if ($widget_settings['status'] == '0,1') {
|
||||
$temp_output .= ' selected';
|
||||
}
|
||||
$temp_output .= '>Up + Down</option>
|
||||
<option value="1"';
|
||||
if ($widget_settings['status'] == '1') {
|
||||
$temp_output .= ' selected';
|
||||
}
|
||||
$temp_output .= '>Up</option>
|
||||
<option value="0"';
|
||||
if ($widget_settings['status'] == '0') {
|
||||
$temp_output .= ' selected';
|
||||
}
|
||||
$temp_output .= '>Down</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2">
|
||||
<button type="submit" class="btn btn-default">Set</button>
|
||||
@@ -101,6 +126,9 @@ if ($config['map']['engine'] == 'leaflet') {
|
||||
else {
|
||||
$group_radius = 80;
|
||||
}
|
||||
if (empty($widget_settings['status']) && $widget_settings['status'] != '0') {
|
||||
$widget_settings['status'] = '0,1';
|
||||
}
|
||||
$map_init = "[" . $init_lat . ", " . $init_lng . "], " . sprintf("%01.0f", $init_zoom);
|
||||
$temp_output .= 'var map = L.map(\'leaflet-map\').setView('.$map_init.');
|
||||
L.tileLayer(\'//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png\', {
|
||||
@@ -122,24 +150,31 @@ var greenMarker = L.AwesomeMarkers.icon({
|
||||
// Checking user permissions
|
||||
if (is_admin() || is_read()) {
|
||||
// Admin or global read-only - show all devices
|
||||
$sql = "SELECT DISTINCT(`device_id`),`hostname`,`os`,`status`,`lat`,`lng` FROM `devices`
|
||||
$sql = "SELECT DISTINCT(`device_id`),`devices`.`location`,`hostname`,`os`,`status`,`lat`,`lng` FROM `devices`
|
||||
LEFT JOIN `locations` ON `devices`.`location`=`locations`.`location`
|
||||
WHERE `disabled`=0 AND `ignore`=0 AND `lat` != '' AND `lng` != ''
|
||||
WHERE `disabled`=0 AND `ignore`=0 AND ((`lat` != '' AND `lng` != '') OR (`devices`.`location` REGEXP '\[[0-9\.\, ]+\]'))
|
||||
AND `status` IN (".$widget_settings['status'].")
|
||||
ORDER BY `status` ASC, `hostname`";
|
||||
}
|
||||
else {
|
||||
// Normal user - grab devices that user has permissions to
|
||||
$sql = "SELECT DISTINCT(`devices`.`device_id`) as `device_id`,`hostname`,`os`,`status`,`lat`,`lng`
|
||||
$sql = "SELECT DISTINCT(`devices`.`device_id`) as `device_id`,`devices`.`location`,`hostname`,`os`,`status`,`lat`,`lng`
|
||||
FROM `devices_perms`, `devices`
|
||||
LEFT JOIN `locations` ON `devices`.`location`=`locations`.`location`
|
||||
WHERE `disabled`=0 AND `ignore`=0 AND `lat` != '' AND `lng` != ''
|
||||
WHERE `disabled`=0 AND `ignore`=0 AND ((`lat` != '' AND `lng` != '') OR (`devices`.`location` REGEXP '\[[0-9\.\, ]+\]'))
|
||||
AND `devices`.`device_id` = `devices_perms`.`device_id`
|
||||
AND `devices_perms`.`user_id` = ?
|
||||
AND `devices_perms`.`user_id` = ? AND `status` IN (".$widget_settings['status'].")
|
||||
ORDER BY `status` ASC, `hostname`";
|
||||
$param[] = $_SESSION['user_id'];
|
||||
}
|
||||
foreach (dbFetchRows($sql, array($_SESSION['user_id'])) as $map_devices) {
|
||||
foreach (dbFetchRows($sql, $param) as $map_devices) {
|
||||
$icon = 'greenMarker';
|
||||
$z_offset = 0;
|
||||
$tmp_loc = parse_location($map_devices['location']);
|
||||
if (!empty($tmp_loc['lat']) && !empty($tmp_loc['lng'])) {
|
||||
$map_devices['lat'] = $tmp_loc['lat'];
|
||||
$map_devices['lng'] = $tmp_loc['lng'];
|
||||
}
|
||||
if ($map_devices['status'] == 0) {
|
||||
$icon = 'redMarker';
|
||||
$z_offset = 10000; // move marker to foreground
|
||||
|
||||
@@ -78,7 +78,10 @@ if ($device['location']) {
|
||||
}
|
||||
}
|
||||
|
||||
$loc = dbFetchRow("SELECT `lat`,`lng` FROM `locations` WHERE `location`=? LIMIT 1", array($device['location']));
|
||||
$loc = parse_location($device['location']);
|
||||
if (!is_array($loc)) {
|
||||
$loc = dbFetchRow("SELECT `lat`,`lng` FROM `locations` WHERE `location`=? LIMIT 1", array($device['location']));
|
||||
}
|
||||
if (is_array($loc)) {
|
||||
echo '<tr>
|
||||
<td>Lat / Lng</td>
|
||||
|
||||
@@ -24,9 +24,9 @@ $image = getImage($device);
|
||||
|
||||
echo '
|
||||
<tr bgcolor="'.$device_colour.'" class="alert '.$class.'">
|
||||
<td width="40" align=center valign=middle style="padding: 21px;">'.$image.'</td>
|
||||
<td width="40" align=center valign=middle style="padding: 21px;"><span class="device_icon">'.$image.'</span></td>
|
||||
<td valign=middle style="padding: 0 15px;"><span style="font-size: 20px;">'.generate_device_link($device).'</span>
|
||||
<br />'.$device['location'].'</td>
|
||||
<br />'.generate_link($device['location'], array('page' => 'devices', 'location' => $device['location'])).'</td>
|
||||
<td>';
|
||||
|
||||
if (isset($config['os'][$device['os']]['over'])) {
|
||||
|
||||
@@ -30,10 +30,13 @@ $config_extra = mres($_POST['config_extra']);
|
||||
$config_room_id = mres($_POST['config_room_id']);
|
||||
$config_from = mres($_POST['config_from']);
|
||||
$config_userkey = mres($_POST['config_userkey']);
|
||||
$config_user = mres($_POST['config_user']);
|
||||
$config_to = mres($_POST['config_to']);
|
||||
$config_token = mres($_POST['config_token']);
|
||||
$status = 'error';
|
||||
$message = 'Error with config';
|
||||
|
||||
if ($action == 'remove' || $action == 'remove-slack' || $action == 'remove-hipchat' || $action == 'remove-pushover' || $action == 'remove-boxcar') {
|
||||
if ($action == 'remove' || $action == 'remove-slack' || $action == 'remove-hipchat' || $action == 'remove-pushover' || $action == 'remove-boxcar' || $action == 'remove-clickatell' || $action == 'remove-playsms') {
|
||||
$config_id = mres($_POST['config_id']);
|
||||
if (empty($config_id)) {
|
||||
$message = 'No config id passed';
|
||||
@@ -52,6 +55,12 @@ if ($action == 'remove' || $action == 'remove-slack' || $action == 'remove-hipch
|
||||
elseif ($action == 'remove-boxcar') {
|
||||
dbDelete('config', "`config_name` LIKE 'alert.transports.boxcar.$config_id.%'");
|
||||
}
|
||||
elseif ($action == 'remove-clickatell') {
|
||||
dbDelete('config', "`config_name` LIKE 'alert.transports.clickatell.$config_id.%'");
|
||||
}
|
||||
elseif ($action == 'remove-playsms') {
|
||||
dbDelete('config', "`config_name` LIKE 'alert.transports.playsms.$config_id.%'");
|
||||
}
|
||||
|
||||
$status = 'ok';
|
||||
$message = 'Config item removed';
|
||||
@@ -156,6 +165,66 @@ else if ($action == 'add-boxcar') {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ($action == 'add-clickatell') {
|
||||
if (empty($config_value)) {
|
||||
$message = 'No Clickatell token provided';
|
||||
}
|
||||
elseif (empty($config_to)) {
|
||||
$message = 'No mobile numbers provided';
|
||||
}
|
||||
else {
|
||||
$config_id = dbInsert(array('config_name' => 'alert.transports.clickatell.', 'config_value' => $config_value, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $config_value, 'config_descr' => 'Clickatell Transport'), 'config');
|
||||
if ($config_id > 0) {
|
||||
dbUpdate(array('config_name' => 'alert.transports.clickatell.'.$config_id.'.token'), 'config', 'config_id=?', array($config_id));
|
||||
$status = 'ok';
|
||||
$message = 'Config item created';
|
||||
$mobiles = explode('\n', $config_to);
|
||||
$x=0;
|
||||
foreach ($mobiles as $mobile) {
|
||||
if (!empty($mobile)) {
|
||||
dbInsert(array('config_name' => 'alert.transports.clickatell.'.$config_id.'.to.'.$x, 'config_value' => $mobile, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $v, 'config_descr' => 'Clickatell mobile'), 'config');
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$message = 'Could not create config item';
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($action == 'add-playsms') {
|
||||
if (empty($config_value)) {
|
||||
$message = 'No PlaySMS URL provided';
|
||||
}
|
||||
elseif (empty($config_user)) {
|
||||
$message = 'No PlaySMS User provided';
|
||||
}
|
||||
elseif (empty($config_to)) {
|
||||
$message = 'No mobile numbers provided';
|
||||
}
|
||||
else {
|
||||
$config_id = dbInsert(array('config_name' => 'alert.transports.playsms.', 'config_value' => $config_value, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $config_value, 'config_descr' => 'PlaySMS Transport'), 'config');
|
||||
if ($config_id > 0) {
|
||||
dbUpdate(array('config_name' => 'alert.transports.playsms.'.$config_id.'.url'), 'config', 'config_id=?', array($config_id));
|
||||
$additional_id['from'] = dbInsert(array('config_name' => 'alert.transports.playsms.'.$config_id.'.from', 'config_value' => $config_from, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $config_from, 'config_descr' => 'PlaySMS From'), 'config');
|
||||
$additional_id['user'] = dbInsert(array('config_name' => 'alert.transports.playsms.'.$config_id.'.user', 'config_value' => $config_user, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $config_user, 'config_descr' => 'PlaySMS User'), 'config');
|
||||
$additional_id['token'] = dbInsert(array('config_name' => 'alert.transports.playsms.'.$config_id.'.token', 'config_value' => $config_token, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $config_token, 'config_descr' => 'PlaySMS Token'), 'config');
|
||||
$status = 'ok';
|
||||
$message = 'Config item created';
|
||||
$mobiles = explode('\n', $config_to);
|
||||
$x=0;
|
||||
foreach ($mobiles as $mobile) {
|
||||
if (!empty($mobile)) {
|
||||
dbInsert(array('config_name' => 'alert.transports.playsms.'.$config_id.'.to.'.$x, 'config_value' => $mobile, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $v, 'config_descr' => 'PlaySMS mobile'), 'config');
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$message = 'Could not create config item';
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (empty($config_group) || empty($config_sub_group) || empty($config_name) || empty($config_value)) {
|
||||
$message = 'Missing config name or value';
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/* Copyright (C) 2015 Daniel Preussker, QuxLabs UG <preussker@quxlabs.com>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/**
|
||||
* Notification Page
|
||||
* @author Daniel Preussker
|
||||
* @copyright 2015 Daniel Preussker, QuxLabs UG
|
||||
* @license GPL
|
||||
* @package LibreNMS
|
||||
* @subpackage Notifications
|
||||
*/
|
||||
|
||||
$status = 'error';
|
||||
$message = 'unknown error';
|
||||
if (isset($_REQUEST['notification_id']) && isset($_REQUEST['action'])) {
|
||||
if ($_REQUEST['action'] == 'read' && dbInsert(array('notifications_id'=>$_REQUEST['notification_id'],'user_id'=>$_SESSION['user_id'],'key'=>'read','value'=>1),'notifications_attribs')) {
|
||||
$status = 'ok';
|
||||
$message = 'Set as Read';
|
||||
}
|
||||
elseif ($_SESSION['userlevel'] == 10 && $_REQUEST['action'] == 'stick' && dbInsert(array('notifications_id'=>$_REQUEST['notification_id'],'user_id'=>$_SESSION['user_id'],'key'=>'sticky','value'=>1),'notifications_attribs')) {
|
||||
$status = 'ok';
|
||||
$message = 'Set as Sticky';
|
||||
}
|
||||
elseif ($_SESSION['userlevel'] == 10 && $_REQUEST['action'] == 'unstick' && dbUpdate(array('key'=>'sticky','value'=>0),'notifications_attribs','notifications_id = ? && user_id = ?',array($_REQUEST['notification_id'],$_SESSION['user_id']))) {
|
||||
$status = 'ok';
|
||||
$message = 'Removed Sticky';
|
||||
}
|
||||
}
|
||||
elseif ($_REQUEST['action'] == 'create' && $_SESSION['userlevel'] == 10 && (isset($_REQUEST['title']) && isset($_REQUEST['body']))) {
|
||||
if (dbInsert(array('title'=>$_REQUEST['title'],'body'=>$_REQUEST['body'],'checksum'=>hash('sha512',$_SESSION['user_id'].'.LOCAL.'.$_REQUEST['title']),'source'=>$_SESSION['user_id']),'notifications')) {
|
||||
$status = 'ok';
|
||||
$message = 'Created';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$status = 'error';
|
||||
$message = 'ERROR: Missing Params';
|
||||
}
|
||||
|
||||
die(json_encode(array(
|
||||
'status' => $status,
|
||||
'message' => $message,
|
||||
)));
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS
|
||||
*
|
||||
* Copyright (c) 2015 Søren Friis Rosiak <sorenrosiak@gmail.com>
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
$status = 'error';
|
||||
$message = 'unknown error';
|
||||
$data_param = mres($_POST['data_param']);
|
||||
$query_param = mres($_POST['query_param']);
|
||||
if (isset($data_param) && isset($query_param)) {
|
||||
$status = 'ok';
|
||||
$message = 'Queried';
|
||||
$output = get_ripe_api_whois_data_json($data_param, $query_param);
|
||||
}
|
||||
else {
|
||||
$status = 'error';
|
||||
$message = 'ERROR: Could not query';
|
||||
}
|
||||
die(json_encode(array(
|
||||
'status' => $status,
|
||||
'message' => $message,
|
||||
'data_param' => $data_param,
|
||||
'query_param' => $query_param,
|
||||
'output' => $output
|
||||
)));
|
||||
@@ -25,23 +25,32 @@ $status = 'error';
|
||||
if (!is_numeric($config_id)) {
|
||||
$message = 'ERROR: No config item';
|
||||
}
|
||||
else if ($action == 'update-textarea') {
|
||||
elseif ($action == 'update-textarea') {
|
||||
$extras = explode(PHP_EOL, $_POST['config_value']);
|
||||
$x=0;
|
||||
foreach ($extras as $option) {
|
||||
list($k,$v) = explode('=', $option, 2);
|
||||
if (!empty($k) || !empty($v)) {
|
||||
if ($config_type == 'slack') {
|
||||
$db_id[] = dbInsert(array('config_name' => 'alert.transports.slack.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => 'alerting', 'config_sub_group' => 'transports', 'config_default' => $v, 'config_descr' => 'Slack Transport'), 'config');
|
||||
}
|
||||
else if ($config_type == 'hipchat') {
|
||||
elseif ($config_type == 'hipchat') {
|
||||
$db_id[] = dbInsert(array('config_name' => 'alert.transports.hipchat.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => 'alerting', 'config_sub_group' => 'transports', 'config_default' => $v, 'config_descr' => 'Hipchat Transport'), 'config');
|
||||
}
|
||||
else if ($config_type == 'pushover') {
|
||||
elseif ($config_type == 'pushover') {
|
||||
$db_id[] = dbInsert(array('config_name' => 'alert.transports.pushover.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => 'alerting', 'config_sub_group' => 'transports', 'config_default' => $v, 'config_descr' => 'Pushover Transport'), 'config');
|
||||
}
|
||||
elseif ($config_type == 'boxcar') {
|
||||
$db_id[] = dbInsert(array('config_name' => 'alert.transports.boxcar.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => 'alerting', 'config_sub_group' => 'transports', 'config_default' => $v, 'config_descr' => 'Boxcar Transport'), 'config');
|
||||
}
|
||||
elseif ($config_type == 'clickatell') {
|
||||
$db_id[] = dbInsert(array('config_name' => 'alert.transports.clickatell.to.'.$x, 'config_value' => $k, 'config_group' => 'alerting', 'config_sub_group' => 'transports', 'config_default' => $v, 'config_descr' => 'Clickatell Transport'), 'config');
|
||||
$x++;
|
||||
}
|
||||
elseif ($config_type == 'playsms') {
|
||||
$db_id[] = dbInsert(array('config_name' => 'alert.transports.playsms.to.'.$x, 'config_value' => $k, 'config_group' => 'alerting', 'config_sub_group' => 'transports', 'config_default' => $v, 'config_descr' => 'PlaySMS Transport'), 'config');
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,15 +63,21 @@ else if ($action == 'update-textarea') {
|
||||
if ($config_type == 'slack') {
|
||||
dbDelete('config', "(`config_name` LIKE 'alert.transports.slack.$config_id.%' AND `config_name` != 'alert.transports.slack.$config_id.url' AND `config_id` NOT IN ($db_inserts))");
|
||||
}
|
||||
else if ($config_type == 'hipchat') {
|
||||
elseif ($config_type == 'hipchat') {
|
||||
dbDelete('config', "(`config_name` LIKE 'alert.transports.hipchat.$config_id.%' AND (`config_name` != 'alert.transports.hipchat.$config_id.url' AND `config_name` != 'alert.transports.hipchat.$config_id.room_id' AND `config_name` != 'alert.transports.hipchat.$config_id.from') AND `config_id` NOT IN ($db_inserts))");
|
||||
}
|
||||
else if ($config_type == 'pushover') {
|
||||
elseif ($config_type == 'pushover') {
|
||||
dbDelete('config', "(`config_name` LIKE 'alert.transports.pushover.$config_id.%' AND (`config_name` != 'alert.transports.pushover.$config_id.appkey' AND `config_name` != 'alert.transports.pushover.$config_id.userkey') AND `config_id` NOT IN ($db_inserts))");
|
||||
}
|
||||
else if ($config_type == 'boxcar') {
|
||||
elseif ($config_type == 'boxcar') {
|
||||
dbDelete('config', "(`config_name` LIKE 'alert.transports.boxcar.$config_id.%' AND (`config_name` != 'alert.transports.boxcar.$config_id.access_token' AND `config_name` != 'alert.transports.boxcar.$config_id.userkey') AND `config_id` NOT IN ($db_inserts))");
|
||||
}
|
||||
elseif ($config_type == 'clickatell') {
|
||||
dbDelete('config', "(`config_name` LIKE 'alert.transports.clickatell.to.%' AND `config_id` NOT IN ($db_inserts))");
|
||||
}
|
||||
elseif ($config_type == 'playsms') {
|
||||
dbDelete('config', "(`config_name` LIKE 'alert.transports.playsms.to.%' AND `config_id` NOT IN ($db_inserts))");
|
||||
}
|
||||
}
|
||||
|
||||
$message = 'Config item has been updated:';
|
||||
|
||||
@@ -476,7 +476,7 @@ function generate_lazy_graph_tag($args) {
|
||||
$urlargs[] = $key."=".urlencode($arg);
|
||||
}
|
||||
|
||||
return '<img class="lazy" width="'.$w.'" height="'.$h.'" data-original="graph.php?' . implode('&',$urlargs).'" border="0" />';
|
||||
return '<img class="lazy graphs" width="'.$w.'" height="'.$h.'" data-original="graph.php?' . implode('&',$urlargs).'" border="0" />';
|
||||
|
||||
}//end generate_lazy_graph_tag()
|
||||
|
||||
@@ -1097,7 +1097,7 @@ function get_config_like_name($name) {
|
||||
$name = array($name);
|
||||
$items = array();
|
||||
foreach (dbFetchRows("SELECT * FROM `config` WHERE `config_name` LIKE '%?%'", array($name)) as $config_item) {
|
||||
$items[$config_item['config_name']] = $config_item;
|
||||
$items[$config_item['config_id']] = $config_item;
|
||||
}
|
||||
|
||||
return $items;
|
||||
@@ -1252,3 +1252,9 @@ function generate_dynamic_config_panel($title,$end_panel=true,$config_groups,$it
|
||||
}
|
||||
return $output;
|
||||
}//end generate_dynamic_config_panel()
|
||||
|
||||
function get_ripe_api_whois_data_json($ripe_data_param, $ripe_query_param) {
|
||||
$ripe_whois_url = 'https://stat.ripe.net/data/'. $ripe_data_param . '/data.json?resource=' . $ripe_query_param;
|
||||
return json_decode(file_get_contents($ripe_whois_url) , true);
|
||||
}//end get_ripe_api_whois_data_json()
|
||||
|
||||
|
||||
@@ -37,6 +37,22 @@ else {
|
||||
);
|
||||
}//end if
|
||||
|
||||
if($_SESSION['screen_width']) {
|
||||
if($_SESSION['screen_width'] < 1024 && $_SESSION['screen_width'] > 700) {
|
||||
$graph_array['width'] = round(($_SESSION['screen_width'] - 90 )/2,0);
|
||||
}
|
||||
else {
|
||||
if($_SESSION['screen_width'] > 1024) {
|
||||
$graph_array['width'] = round(($_SESSION['screen_width'] - 90 )/count($periods)+1,0);
|
||||
}
|
||||
else {
|
||||
$graph_array['width'] = $_SESSION['screen_width'] - 70;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$graph_array['height'] = round($graph_array['width'] /2.15);
|
||||
|
||||
$graph_array['to'] = $config['time']['now'];
|
||||
|
||||
$graph_data = array();
|
||||
|
||||
@@ -36,8 +36,8 @@ else {
|
||||
$mac = '';
|
||||
}
|
||||
|
||||
echo "<tr style=\"background-color: $row_colour;\" valign=top onmouseover=\"this.style.backgroundColor='$list_highlight';\" onmouseout=\"this.style.backgroundColor='$row_colour';\" onclick=\"location.href='".generate_port_url($port)."'\" style='cursor: pointer;'>
|
||||
<td valign=top width=350>";
|
||||
echo "<tr style=\"background-color: $row_colour;\" valign=top onmouseover=\"this.style.backgroundColor='$list_highlight';\" onmouseout=\"this.style.backgroundColor='$row_colour';\" style='cursor: pointer;'>
|
||||
<td valign=top width=350 onclick=\"location.href='".generate_port_url($port)."'\">";
|
||||
echo ' <span class=list-large>
|
||||
'.generate_port_link($port, $port['ifIndex'].'. '.$port['label'])." $error_img $mac
|
||||
</span><br /><span class=interface-desc>".$port['ifAlias'].'</span>';
|
||||
@@ -62,7 +62,7 @@ if ($port_details) {
|
||||
|
||||
echo '</span>';
|
||||
|
||||
echo '</td><td width=100>';
|
||||
echo "</td><td width=100 onclick=\"location.href='".generate_port_url($port)."'\" >";
|
||||
|
||||
if ($port_details) {
|
||||
$port['graph_type'] = 'port_bits';
|
||||
@@ -73,7 +73,7 @@ if ($port_details) {
|
||||
echo generate_port_link($port, "<img src='graph.php?type=port_errors&id=".$port['port_id'].'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=100&height=20&legend=no&bg='.str_replace('#', '', $row_colour)."'>");
|
||||
}
|
||||
|
||||
echo '</td><td width=120>';
|
||||
echo "</td><td width=120 onclick=\"location.href='".generate_port_url($port)."'\" >";
|
||||
|
||||
if ($port['ifOperStatus'] == 'up') {
|
||||
$port['in_rate'] = ($port['ifInOctets_rate'] * 8);
|
||||
@@ -86,7 +86,7 @@ if ($port['ifOperStatus'] == 'up') {
|
||||
<img src='images/icons/arrow_pps_out.png' align=absmiddle> ".format_bi($port['ifOutUcastPkts_rate']).'pps</span>';
|
||||
}
|
||||
|
||||
echo '</td><td width=75>';
|
||||
echo "</td><td width=75 onclick=\"location.href='".generate_port_url($port)."'\" >";
|
||||
if ($port['ifSpeed']) {
|
||||
echo '<span class=box-desc>'.humanspeed($port['ifSpeed']).'</span>';
|
||||
}
|
||||
@@ -130,19 +130,19 @@ if ($device['os'] == 'ios' || $device['os'] == 'iosxe') {
|
||||
}//end if
|
||||
|
||||
if ($port_adsl['adslLineCoding']) {
|
||||
echo '</td><td width=150>';
|
||||
echo "</td><td width=150 onclick=\"location.href='".generate_port_url($port)."'\" >";
|
||||
echo $port_adsl['adslLineCoding'].'/'.rewrite_adslLineType($port_adsl['adslLineType']);
|
||||
echo '<br />';
|
||||
echo 'Sync:'.formatRates($port_adsl['adslAtucChanCurrTxRate']).'/'.formatRates($port_adsl['adslAturChanCurrTxRate']);
|
||||
echo '<br />';
|
||||
echo 'Max:'.formatRates($port_adsl['adslAtucCurrAttainableRate']).'/'.formatRates($port_adsl['adslAturCurrAttainableRate']);
|
||||
echo '</td><td width=150>';
|
||||
echo "</td><td width=150 onclick=\"location.href='".generate_port_url($port)."'\" >";
|
||||
echo 'Atten:'.$port_adsl['adslAtucCurrAtn'].'dB/'.$port_adsl['adslAturCurrAtn'].'dB';
|
||||
echo '<br />';
|
||||
echo 'SNR:'.$port_adsl['adslAtucCurrSnrMgn'].'dB/'.$port_adsl['adslAturCurrSnrMgn'].'dB';
|
||||
}
|
||||
else {
|
||||
echo '</td><td width=150>';
|
||||
echo "</td><td width=150 onclick=\"location.href='".generate_port_url($port)."'\" >";
|
||||
if ($port['ifType'] && $port['ifType'] != '') {
|
||||
echo '<span class=box-desc>'.fixiftype($port['ifType']).'</span>';
|
||||
}
|
||||
@@ -158,7 +158,7 @@ else {
|
||||
echo '-';
|
||||
}
|
||||
|
||||
echo '</td><td width=150>';
|
||||
echo "</td><td width=150 onclick=\"location.href='".generate_port_url($port)."'\" >";
|
||||
if ($port['ifPhysAddress'] && $port['ifPhysAddress'] != '') {
|
||||
echo '<span class=box-desc>'.formatMac($port['ifPhysAddress']).'</span>';
|
||||
}
|
||||
@@ -176,13 +176,17 @@ else {
|
||||
}//end if
|
||||
|
||||
echo '</td>';
|
||||
echo '<td width=375 valign=top class=interface-desc>';
|
||||
echo '<td width=375 valign=top class="interface-desc">';
|
||||
|
||||
$neighborsCount=0;
|
||||
$nbLinks=0;
|
||||
if (strpos($port['label'], 'oopback') === false && !$graph_type) {
|
||||
foreach (dbFetchRows('SELECT * FROM `links` AS L, `ports` AS I, `devices` AS D WHERE L.local_port_id = ? AND L.remote_port_id = I.port_id AND I.device_id = D.device_id', array($if_id)) as $link) {
|
||||
// echo("<img src='images/16/connect.png' align=absmiddle alt='Directly Connected' /> " . generate_port_link($link, makeshortif($link['label'])) . " on " . generate_device_link($link, shorthost($link['hostname'])) . "</a><br />");
|
||||
// $br = "<br />";
|
||||
$int_links[$link['port_id']] = $link['port_id'];
|
||||
$int_links_phys[$link['port_id']] = 1;
|
||||
$nbLinks++;
|
||||
}
|
||||
|
||||
unset($br);
|
||||
@@ -233,10 +237,23 @@ if (strpos($port['label'], 'oopback') === false && !$graph_type) {
|
||||
}//end foreach
|
||||
}//end if
|
||||
|
||||
if(count($int_links) > 3)
|
||||
{
|
||||
echo '<div class="collapse-neighbors"><span class="neighbors-button glyphicon glyphicon-plus" aria-hidden="true"></span>
|
||||
<span class="neighbors-interface-list-firsts" style="display: inline;">';
|
||||
}
|
||||
|
||||
|
||||
if ($port_details && $config['enable_port_relationship'] === true && port_permitted($int_link,$device['device_id'])) {
|
||||
foreach ($int_links as $int_link) {
|
||||
$neighborsCount++;
|
||||
if($neighborsCount == 4)
|
||||
{
|
||||
echo '<span class="neighbors-list-continued" style="display: inline;"></br>[...]</span>';
|
||||
echo '</span>';
|
||||
echo '<span class="neighbors-interface-list" style="display: none;">';
|
||||
}
|
||||
$link_if = dbFetchRow('SELECT * from ports AS I, devices AS D WHERE I.device_id = D.device_id and I.port_id = ?', array($int_link));
|
||||
|
||||
echo "$br";
|
||||
|
||||
if ($int_links_phys[$int_link]) {
|
||||
@@ -304,6 +321,10 @@ if ($port_details && $config['enable_port_relationship'] === true && port_permit
|
||||
|
||||
unset($int_links, $int_links_v6, $int_links_v4, $int_links_phys, $br);
|
||||
|
||||
if($nbLinks > 3)
|
||||
{
|
||||
echo '</span></div>';
|
||||
}
|
||||
echo '</td></tr>';
|
||||
|
||||
// If we're showing graphs, generate the graph and print the img tags
|
||||
|
||||
@@ -47,7 +47,7 @@ else {
|
||||
<div class="collapse navbar-collapse" id="navHeaderCollapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="dropdown">
|
||||
<a href="<?php echo(generate_url(array('page'=>'overview'))); ?>" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-lightbulb-o fa-fw fa-lg fa-nav-icons"></i> Overview</a>
|
||||
<a href="<?php echo(generate_url(array('page'=>'overview'))); ?>" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-lightbulb-o fa-fw fa-lg fa-nav-icons hidden-md"></i> <span class="hidden-sm">Overview</span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="<?php echo(generate_url(array('page'=>'overview'))); ?>"><i class="fa fa-lightbulb-o fa-fw fa-lg"></i> Overview</a></li>
|
||||
<li class="dropdown-submenu">
|
||||
@@ -74,6 +74,12 @@ if ($_SESSION['userlevel'] >= '10') {
|
||||
<li><a href="<?php echo(generate_url(array('page'=>'availability-map'))); ?>"><i class="fa fa-arrow-circle-up fa-fw fa-lg"></i> Availability</a></li>
|
||||
<li><a href="<?php echo(generate_url(array('page'=>'map'))); ?>"><i class="fa fa-desktop fa-fw fa-lg"></i> Network</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown-submenu">
|
||||
<a href="<?php echo(generate_url(array('page'=>'overview'))); ?>"><i class="fa fa-wrench fa-fw fa-lg"></i> Tools</a>
|
||||
<ul class="dropdown-menu scrollable-menu">
|
||||
<li><a href="<?php echo(generate_url(array('page'=>'ripenccapi'))); ?>"><i class="fa fa-arrow-circle-up fa-fw fa-lg"></i> RIPE NCC API</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li role="presentation" class="divider"></li>
|
||||
<li><a href="<?php echo(generate_url(array('page'=>'eventlog'))); ?>"><i class="fa fa-book fa-fw fa-lg"></i> Eventlog</a></li>
|
||||
@@ -107,7 +113,7 @@ if ( dbFetchCell("SELECT 1 from `packages` LIMIT 1") ) {
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="devices/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-server fa-fw fa-lg fa-nav-icons"></i> Devices</a>
|
||||
<a href="devices/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-server fa-fw fa-lg fa-nav-icons hidden-md"></i> <span class="hidden-sm">Devices</span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li class="dropdown-submenu">
|
||||
<a href="devices/"><i class="fa fa-server fa-fw fa-lg"></i> All Devices</a>
|
||||
@@ -181,7 +187,7 @@ if ($_SESSION['userlevel'] >= '10') {
|
||||
if ($config['show_services']) {
|
||||
?>
|
||||
<li class="dropdown">
|
||||
<a href="services/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-cogs fa-fw fa-lg fa-nav-icons"></i> Services</a>
|
||||
<a href="services/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-cogs fa-fw fa-lg fa-nav-icons hidden-md"></i> <span class="hidden-sm">Services</span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="services/"><i class="fa fa-cogs fa-fw fa-lg"></i> All Services </a></li>
|
||||
|
||||
@@ -210,7 +216,7 @@ if ($_SESSION['userlevel'] >= '10') {
|
||||
|
||||
<!-- PORTS -->
|
||||
<li class="dropdown">
|
||||
<a href="ports/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-link fa-fw fa-lg fa-nav-icons"></i> Ports</a>
|
||||
<a href="ports/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-link fa-fw fa-lg fa-nav-icons hidden-md"></i> <span class="hidden-sm">Ports</span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="ports/"><i class="fa fa-link fa-fw fa-lg"></i> All Ports</a></li>
|
||||
|
||||
@@ -316,7 +322,7 @@ $menu_sensors = $used_sensors;
|
||||
?>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="health/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-heartbeat fa-fw fa-lg fa-nav-icons"></i> Health</a>
|
||||
<a href="health/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-heartbeat fa-fw fa-lg fa-nav-icons hidden-md"></i> <span class="hidden-sm">Health</span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="health/metric=mempool/"><i class="fa fa-gears fa-fw fa-lg"></i> Memory</a></li>
|
||||
<li><a href="health/metric=processor/"><i class="fa fa-desktop fa-fw fa-lg"></i> Processor</a></li>
|
||||
@@ -367,7 +373,7 @@ $app_list = dbFetchRows("SELECT DISTINCT(`app_type`) AS `app_type` FROM `applica
|
||||
if ($_SESSION['userlevel'] >= '5' && count($app_list) > "0") {
|
||||
?>
|
||||
<li class="dropdown">
|
||||
<a href="apps/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-tasks fa-fw fa-lg fa-nav-icons"></i> Apps</a>
|
||||
<a href="apps/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-tasks fa-fw fa-lg fa-nav-icons hidden-md"></i> <span class="hidden-sm">Apps</span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<?php
|
||||
|
||||
@@ -405,7 +411,7 @@ if ($_SESSION['userlevel'] >= '5' && ($routing_count['bgp']+$routing_count['ospf
|
||||
|
||||
?>
|
||||
<li class="dropdown">
|
||||
<a href="routing/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-arrows fa-fw fa-lg fa-nav-icons"></i> Routing</a>
|
||||
<a href="routing/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-arrows fa-fw fa-lg fa-nav-icons hidden-md"></i> <span class="hidden-sm">Routing</span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<?php
|
||||
$separator = 0;
|
||||
@@ -452,7 +458,7 @@ if ($_SESSION['userlevel'] >= '5' && ($routing_count['bgp']+$routing_count['ospf
|
||||
?>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-plug fa-fw fa-lg fa-nav-icons"></i> <span class="hidden-md hidden-sm">Plugins</span></a>
|
||||
<a href="#" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-plug fa-fw fa-lg fa-nav-icons hidden-md"></i> <span class="hidden-sm">Plugins</span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<?php
|
||||
Plugins::call('menu');
|
||||
@@ -482,6 +488,10 @@ if(is_file("includes/print-menubar-custom.inc.php")) {
|
||||
</div>
|
||||
</form>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<?php
|
||||
$notifications = new ObjCache('notifications');
|
||||
echo ' <li><a href="notifications/"><span class="badge count-notif">'.($notifications['sticky_count']+$notifications['count']).'</span></a></li>';
|
||||
?>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-cog fa-fw fa-lg fa-nav-icons"></i></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
Reference in New Issue
Block a user