mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 08:02:41 +02:00
Fix coding style part 2
This commit is contained in:
@@ -1,17 +1,15 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* LibreNMS
|
||||
*
|
||||
* Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk/fa>
|
||||
*
|
||||
* 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.
|
||||
* LibreNMS
|
||||
*
|
||||
* Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk/fa>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
require_once('includes/print-alert-rules.php');
|
||||
|
||||
?>
|
||||
require_once 'includes/print-alert-rules.php';
|
||||
|
||||
@@ -1,35 +1,48 @@
|
||||
<?php
|
||||
if ($_POST['editing'])
|
||||
{
|
||||
if ($_SESSION['userlevel'] > "7")
|
||||
{
|
||||
$override_sysContact_bool = mres($_POST['override_sysContact']);
|
||||
if (isset($_POST['sysContact'])) { $override_sysContact_string = mres($_POST['sysContact']); }
|
||||
$disable_notify = mres($_POST['disable_notify']);
|
||||
if ($_POST['editing']) {
|
||||
if ($_SESSION['userlevel'] > '7') {
|
||||
$override_sysContact_bool = mres($_POST['override_sysContact']);
|
||||
if (isset($_POST['sysContact'])) {
|
||||
$override_sysContact_string = mres($_POST['sysContact']);
|
||||
}
|
||||
|
||||
if ($override_sysContact_bool) { set_dev_attrib($device, 'override_sysContact_bool', '1'); } else { del_dev_attrib($device, 'override_sysContact_bool'); }
|
||||
if (isset($override_sysContact_string)) { set_dev_attrib($device, 'override_sysContact_string', $override_sysContact_string); };
|
||||
if ($disable_notify) { set_dev_attrib($device, 'disable_notify', '1'); } else { del_dev_attrib($device, 'disable_notify'); }
|
||||
$disable_notify = mres($_POST['disable_notify']);
|
||||
|
||||
$update_message = "Device alert settings updated.";
|
||||
$updated = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
include("includes/error-no-perm.inc.php");
|
||||
}
|
||||
if ($override_sysContact_bool) {
|
||||
set_dev_attrib($device, 'override_sysContact_bool', '1');
|
||||
}
|
||||
else {
|
||||
del_dev_attrib($device, 'override_sysContact_bool');
|
||||
}
|
||||
|
||||
if (isset($override_sysContact_string)) {
|
||||
set_dev_attrib($device, 'override_sysContact_string', $override_sysContact_string);
|
||||
};
|
||||
if ($disable_notify) {
|
||||
set_dev_attrib($device, 'disable_notify', '1');
|
||||
}
|
||||
else {
|
||||
del_dev_attrib($device, 'disable_notify');
|
||||
}
|
||||
|
||||
$update_message = 'Device alert settings updated.';
|
||||
$updated = 1;
|
||||
}
|
||||
else {
|
||||
include 'includes/error-no-perm.inc.php';
|
||||
}//end if
|
||||
}//end if
|
||||
|
||||
if ($updated && $update_message) {
|
||||
print_message($update_message);
|
||||
}
|
||||
else if ($update_message) {
|
||||
print_error($update_message);
|
||||
}
|
||||
|
||||
if ($updated && $update_message)
|
||||
{
|
||||
print_message($update_message);
|
||||
} elseif ($update_message) {
|
||||
print_error($update_message);
|
||||
}
|
||||
|
||||
$override_sysContact_bool = get_dev_attrib($device,'override_sysContact_bool');
|
||||
$override_sysContact_string = get_dev_attrib($device,'override_sysContact_string');
|
||||
$disable_notify = get_dev_attrib($device,'disable_notify');
|
||||
$override_sysContact_bool = get_dev_attrib($device, 'override_sysContact_bool');
|
||||
$override_sysContact_string = get_dev_attrib($device, 'override_sysContact_string');
|
||||
$disable_notify = get_dev_attrib($device, 'disable_notify');
|
||||
?>
|
||||
|
||||
<div class="row">
|
||||
@@ -45,26 +58,44 @@ $disable_notify = get_dev_attrib($device,'disable_notify');
|
||||
<div class="form-group">
|
||||
<label for="override_sysContact" class="col-sm-3 control-label">Override sysContact:</label>
|
||||
<div class="col-sm-6">
|
||||
<input onclick="edit.sysContact.disabled=!edit.override_sysContact.checked" type="checkbox" id="override_sysContact" name="override_sysContact"<?php if ($override_sysContact_bool) { echo(' checked="1"'); } ?> />
|
||||
<input onclick="edit.sysContact.disabled=!edit.override_sysContact.checked" type="checkbox" id="override_sysContact" name="override_sysContact"
|
||||
<?php
|
||||
if ($override_sysContact_bool) {
|
||||
echo ' checked="1"';
|
||||
};
|
||||
?>
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-3">
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<input id="sysContact" class="form-control" name="sysContact" size="32"<?php if (!$override_sysContact_bool) { echo(' disabled="1"'); } ?> value="<?php echo($override_sysContact_string); ?>" />
|
||||
<input id="sysContact" class="form-control" name="sysContact" size="32"
|
||||
<?php
|
||||
if (!$override_sysContact_bool) {
|
||||
echo ' disabled="1"';
|
||||
};
|
||||
?>
|
||||
value="<?php echo $override_sysContact_string; ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="disable_notify" class="col-sm-3 control-label">Disable all alerting for this host: </label>
|
||||
<div class="col-sm-6">
|
||||
<input id="disable_notify" type="checkbox" name="disable_notify"<?php if ($disable_notify) { echo(' checked="1"'); } ?> />
|
||||
<input id="disable_notify" type="checkbox" name="disable_notify"
|
||||
<?php
|
||||
if ($disable_notify) {
|
||||
echo ' checked="1"';
|
||||
};
|
||||
?>
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-default btn-sm" type="submit" name="Submit">Save</button>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
require_once("includes/modal/new_alert_rule.inc.php");
|
||||
require_once 'includes/modal/new_alert_rule.inc.php';
|
||||
?>
|
||||
<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#create-alert" data-device_id="<?php echo $device['device_id'];?>">Create new alert rule</button>
|
||||
<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#create-alert" data-device_id="<?php echo $device['device_id']; ?>">Create new alert rule</button>
|
||||
|
||||
@@ -1,112 +1,103 @@
|
||||
<?php
|
||||
|
||||
# Load our list of available applications
|
||||
if ($handle = opendir($config['install_dir'] . "/includes/polling/applications/"))
|
||||
{
|
||||
while (false !== ($file = readdir($handle)))
|
||||
{
|
||||
if ($file != "." && $file != ".." && strstr($file, ".inc.php"))
|
||||
{
|
||||
$applications[] = str_replace(".inc.php", "", $file);
|
||||
// Load our list of available applications
|
||||
if ($handle = opendir($config['install_dir'].'/includes/polling/applications/')) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if ($file != '.' && $file != '..' && strstr($file, '.inc.php')) {
|
||||
$applications[] = str_replace('.inc.php', '', $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
|
||||
closedir($handle);
|
||||
}
|
||||
|
||||
# Check if the form was POSTed
|
||||
if ($_POST['device'])
|
||||
{
|
||||
$updated = 0;
|
||||
$param[] = $device['device_id'];
|
||||
foreach (array_keys($_POST) as $key)
|
||||
{
|
||||
if (substr($key,0,4) == 'app_')
|
||||
{
|
||||
$param[] = substr($key,4);
|
||||
$enabled[] = substr($key,4);
|
||||
$replace[] = "?";
|
||||
// Check if the form was POSTed
|
||||
if ($_POST['device']) {
|
||||
$updated = 0;
|
||||
$param[] = $device['device_id'];
|
||||
foreach (array_keys($_POST) as $key) {
|
||||
if (substr($key, 0, 4) == 'app_') {
|
||||
$param[] = substr($key, 4);
|
||||
$enabled[] = substr($key, 4);
|
||||
$replace[] = '?';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($enabled)) {
|
||||
$updated += dbDelete('applications', "`device_id` = ? AND `app_type` NOT IN (".implode(",",$replace).")", $param);
|
||||
} else {
|
||||
$updated += dbDelete('applications', "`device_id` = ?", array($param));
|
||||
}
|
||||
|
||||
foreach (dbFetchRows( "SELECT `app_type` FROM `applications` WHERE `device_id` = ?", array($device['device_id'])) as $row)
|
||||
{
|
||||
$app_in_db[] = $row['app_type'];
|
||||
}
|
||||
|
||||
foreach ($enabled as $app)
|
||||
{
|
||||
if (!in_array($app,$app_in_db))
|
||||
{
|
||||
$updated += dbInsert(array('device_id' => $device['device_id'], 'app_type' => $app), 'applications');
|
||||
if (count($enabled)) {
|
||||
$updated += dbDelete('applications', '`device_id` = ? AND `app_type` NOT IN ('.implode(',', $replace).')', $param);
|
||||
}
|
||||
else {
|
||||
$updated += dbDelete('applications', '`device_id` = ?', array($param));
|
||||
}
|
||||
}
|
||||
|
||||
if ($updated)
|
||||
{
|
||||
print_message("Applications updated!");
|
||||
}
|
||||
else
|
||||
{
|
||||
print_message("No changes.");
|
||||
}
|
||||
foreach (dbFetchRows('SELECT `app_type` FROM `applications` WHERE `device_id` = ?', array($device['device_id'])) as $row) {
|
||||
$app_in_db[] = $row['app_type'];
|
||||
}
|
||||
|
||||
foreach ($enabled as $app) {
|
||||
if (!in_array($app, $app_in_db)) {
|
||||
$updated += dbInsert(array('device_id' => $device['device_id'], 'app_type' => $app), 'applications');
|
||||
}
|
||||
}
|
||||
|
||||
if ($updated) {
|
||||
print_message('Applications updated!');
|
||||
}
|
||||
else {
|
||||
print_message('No changes.');
|
||||
}
|
||||
}//end if
|
||||
|
||||
// Show list of apps with checkboxes
|
||||
echo '<div style="padding: 10px;">';
|
||||
|
||||
$apps_enabled = dbFetchRows('SELECT * from `applications` WHERE `device_id` = ? ORDER BY app_type', array($device['device_id']));
|
||||
if (count($apps_enabled)) {
|
||||
foreach ($apps_enabled as $application) {
|
||||
$app_enabled[] = $application['app_type'];
|
||||
}
|
||||
}
|
||||
|
||||
# Show list of apps with checkboxes
|
||||
echo('<div style="padding: 10px;">');
|
||||
|
||||
$apps_enabled = dbFetchRows("SELECT * from `applications` WHERE `device_id` = ? ORDER BY app_type", array($device['device_id']));
|
||||
if (count($apps_enabled))
|
||||
{
|
||||
foreach ($apps_enabled as $application)
|
||||
{
|
||||
$app_enabled[] = $application['app_type'];
|
||||
}
|
||||
}
|
||||
|
||||
echo("<div class='row'>
|
||||
<div class='col-md-4'>
|
||||
<form id='appedit' name='appedit' method='post' action='' role='form' class='form-horizontal'>
|
||||
<input type=hidden name=device value='".$device['device_id']."'>
|
||||
<table class='table table-condensed table-striped table-responsive'>
|
||||
echo "<div class='row'>
|
||||
<div class='col-md-4'>
|
||||
<form id='appedit' name='appedit' method='post' action='' role='form' class='form-horizontal'>
|
||||
<input type=hidden name=device value='".$device['device_id']."'>
|
||||
<table class='table table-condensed table-striped table-responsive'>
|
||||
<tr align=center>
|
||||
<th>Enable</th>
|
||||
<th>Application</th>
|
||||
<th>Enable</th>
|
||||
<th>Application</th>
|
||||
</tr>
|
||||
");
|
||||
";
|
||||
|
||||
$row = 1;
|
||||
|
||||
foreach ($applications as $app)
|
||||
{
|
||||
if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
|
||||
foreach ($applications as $app) {
|
||||
if (is_integer($row / 2)) {
|
||||
$row_colour = $list_colour_a;
|
||||
}
|
||||
else {
|
||||
$row_colour = $list_colour_b;
|
||||
}
|
||||
|
||||
echo(" <tr bgcolor=$row_colour>");
|
||||
echo(" <td>");
|
||||
echo(" <input type=checkbox" . (in_array($app,$app_enabled) ? ' checked="1"' : '') . " name='app_". $app ."'>");
|
||||
echo(" </td>");
|
||||
echo(" <td>". ucfirst($app) . "</td>");
|
||||
echo(" </tr>
|
||||
");
|
||||
echo " <tr bgcolor=$row_colour>";
|
||||
echo ' <td>';
|
||||
echo ' <input type=checkbox'.(in_array($app, $app_enabled) ? ' checked="1"' : '')." name='app_".$app."'>";
|
||||
echo ' </td>';
|
||||
echo ' <td>'.ucfirst($app).'</td>';
|
||||
echo ' </tr>
|
||||
';
|
||||
|
||||
$row++;
|
||||
$row++;
|
||||
}
|
||||
|
||||
echo('<tr>
|
||||
<td>
|
||||
echo '<tr>
|
||||
<td>
|
||||
<button type="submit" class="btn btn-default" value="Save">Save</button>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>');
|
||||
echo('</table>');
|
||||
echo('</form>');
|
||||
echo('</div>');
|
||||
echo('</div>');
|
||||
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>';
|
||||
echo '</table>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
||||
@@ -1,45 +1,51 @@
|
||||
<?php
|
||||
|
||||
if ($_POST['editing'])
|
||||
{
|
||||
if ($_SESSION['userlevel'] > "7")
|
||||
{
|
||||
$updated = 0;
|
||||
if ($_POST['editing']) {
|
||||
if ($_SESSION['userlevel'] > "7") {
|
||||
$updated = 0;
|
||||
|
||||
$override_sysLocation_bool = mres($_POST['override_sysLocation']);
|
||||
if (isset($_POST['sysLocation'])) { $override_sysLocation_string = mres($_POST['sysLocation']); }
|
||||
$override_sysLocation_bool = mres($_POST['override_sysLocation']);
|
||||
if (isset($_POST['sysLocation'])) {
|
||||
$override_sysLocation_string = mres($_POST['sysLocation']);
|
||||
}
|
||||
|
||||
if (get_dev_attrib($device,'override_sysLocation_bool') != $override_sysLocation_bool
|
||||
|| get_dev_attrib($device,'override_sysLocation_string') != $override_sysLocation_string)
|
||||
{
|
||||
$updated = 1;
|
||||
if (get_dev_attrib($device,'override_sysLocation_bool') != $override_sysLocation_bool
|
||||
|| get_dev_attrib($device,'override_sysLocation_string') != $override_sysLocation_string) {
|
||||
$updated = 1;
|
||||
}
|
||||
|
||||
if ($override_sysLocation_bool) {
|
||||
set_dev_attrib($device, 'override_sysLocation_bool', '1');
|
||||
}
|
||||
else {
|
||||
del_dev_attrib($device, 'override_sysLocation_bool');
|
||||
}
|
||||
if (isset($override_sysLocation_string)) {
|
||||
set_dev_attrib($device, 'override_sysLocation_string', $override_sysLocation_string);
|
||||
};
|
||||
|
||||
#FIXME needs more sanity checking! and better feedback
|
||||
|
||||
$param = array('purpose' => $_POST['descr'], 'type' => $_POST['type'], 'ignore' => $_POST['ignore'], 'disabled' => $_POST['disabled']);
|
||||
|
||||
$rows_updated = dbUpdate($param, 'devices', '`device_id` = ?', array($device['device_id']));
|
||||
|
||||
if ($rows_updated > 0 || $updated) {
|
||||
$update_message = "Device record updated.";
|
||||
$updated = 1;
|
||||
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id']));
|
||||
}
|
||||
elseif ($rows_updated = '-1') {
|
||||
$update_message = "Device record unchanged. No update necessary.";
|
||||
$updated = -1;
|
||||
}
|
||||
else {
|
||||
$update_message = "Device record update error.";
|
||||
}
|
||||
}
|
||||
|
||||
if ($override_sysLocation_bool) { set_dev_attrib($device, 'override_sysLocation_bool', '1'); } else { del_dev_attrib($device, 'override_sysLocation_bool'); }
|
||||
if (isset($override_sysLocation_string)) { set_dev_attrib($device, 'override_sysLocation_string', $override_sysLocation_string); };
|
||||
|
||||
#FIXME needs more sanity checking! and better feedback
|
||||
|
||||
$param = array('purpose' => $_POST['descr'], 'type' => $_POST['type'], 'ignore' => $_POST['ignore'], 'disabled' => $_POST['disabled']);
|
||||
|
||||
$rows_updated = dbUpdate($param, 'devices', '`device_id` = ?', array($device['device_id']));
|
||||
|
||||
if ($rows_updated > 0 || $updated)
|
||||
{
|
||||
$update_message = "Device record updated.";
|
||||
$updated = 1;
|
||||
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id']));
|
||||
} elseif ($rows_updated = '-1') {
|
||||
$update_message = "Device record unchanged. No update necessary.";
|
||||
$updated = -1;
|
||||
} else {
|
||||
$update_message = "Device record update error.";
|
||||
else {
|
||||
include 'includes/error-no-perm.inc.php';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
include("includes/error-no-perm.inc.php");
|
||||
}
|
||||
}
|
||||
|
||||
$descr = $device['purpose'];
|
||||
@@ -47,11 +53,11 @@ $descr = $device['purpose'];
|
||||
$override_sysLocation_bool = get_dev_attrib($device,'override_sysLocation_bool');
|
||||
$override_sysLocation_string = get_dev_attrib($device,'override_sysLocation_string');
|
||||
|
||||
if ($updated && $update_message)
|
||||
{
|
||||
print_message($update_message);
|
||||
} elseif ($update_message) {
|
||||
print_error($update_message);
|
||||
if ($updated && $update_message) {
|
||||
print_message($update_message);
|
||||
}
|
||||
elseif ($update_message) {
|
||||
print_error($update_message);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -91,20 +97,17 @@ if($config['enable_clear_discovery'] == 1) {
|
||||
<?php
|
||||
$unknown = 1;
|
||||
|
||||
foreach ($config['device_types'] as $type)
|
||||
{
|
||||
echo(' <option value="'.$type['type'].'"');
|
||||
if ($device['type'] == $type['type'])
|
||||
{
|
||||
echo(' selected="1"');
|
||||
$unknown = 0;
|
||||
}
|
||||
echo(' >' . ucfirst($type['type']) . '</option>');
|
||||
foreach ($config['device_types'] as $type) {
|
||||
echo(' <option value="'.$type['type'].'"');
|
||||
if ($device['type'] == $type['type']) {
|
||||
echo(' selected="1"');
|
||||
$unknown = 0;
|
||||
}
|
||||
echo(' >' . ucfirst($type['type']) . '</option>');
|
||||
}
|
||||
if ($unknown)
|
||||
{
|
||||
if ($unknown) {
|
||||
echo(' <option value="other">Other</option>');
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
@@ -113,7 +116,7 @@ foreach ($config['device_types'] as $type)
|
||||
<label for="sysLocation" class="col-sm-2 control-label">Override sysLocation:</label>
|
||||
<div class="col-sm-6">
|
||||
<div class="checkbox">
|
||||
<input onclick="edit.sysLocation.disabled=!edit.override_sysLocation.checked" type="checkbox" name="override_sysLocation"<?php if ($override_sysLocation_bool) { echo(' checked="1"'); } ?> />
|
||||
<input onclick="edit.sysLocation.disabled=!edit.override_sysLocation.checked" type="checkbox" name="override_sysLocation"<?php if ($override_sysLocation_bool) echo(' checked="1"'); ?> />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -121,19 +124,19 @@ foreach ($config['device_types'] as $type)
|
||||
<div class="col-sm-2">
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<input id="sysLocation" name="sysLocation" class="form-control" <?php if (!$override_sysLocation_bool) { echo(' disabled="1"'); } ?> value="<?php echo($override_sysLocation_string); ?>" />
|
||||
<input id="sysLocation" name="sysLocation" class="form-control" <?php if (!$override_sysLocation_bool) echo(' disabled="1"'); ?> value="<?php echo($override_sysLocation_string); ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="disabled" class="col-sm-2 control-label">Disable:</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="disabled" type="checkbox" id="disabled" value="1" <?php if ($device["disabled"]) { echo("checked=checked"); } ?> />
|
||||
<input name="disabled" type="checkbox" id="disabled" value="1" <?php if ($device["disabled"]) echo("checked=checked"); ?> />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="ignore" class="col-sm-2 control-label">Ignore</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="ignore" type="checkbox" id="ignore" value="1" <?php if ($device['ignore']) { echo("checked=checked"); } ?> />
|
||||
<input name="ignore" type="checkbox" id="ignore" value="1" <?php if ($device['ignore']) echo("checked=checked"); ?> />
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" name="Submit" class="btn btn-default">Save</button>
|
||||
|
||||
@@ -30,156 +30,158 @@
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php
|
||||
foreach ( dbFetchRows("SELECT * FROM sensors WHERE device_id = ? AND sensor_deleted='0'", array($device['device_id'])) as $sensor)
|
||||
{
|
||||
$rollback[] = array('sensor_id' => $sensor['sensor_id'], 'sensor_limit' => $sensor['sensor_limit'], 'sensor_limit_low' => $sensor['sensor_limit_low'], 'sensor_alert' => $sensor['sensor_alert']);
|
||||
if($sensor['sensor_alert'] == 1)
|
||||
{
|
||||
$alert_status = 'checked';
|
||||
}
|
||||
else
|
||||
{
|
||||
$alert_status = '';
|
||||
}
|
||||
if ($sensor['sensor_custom'] == 'No') {
|
||||
$custom = 'disabled';
|
||||
} else {
|
||||
$custom = '';
|
||||
}
|
||||
echo('
|
||||
<tr>
|
||||
<td>'.$sensor['sensor_class'].'</td>
|
||||
<td>'.$sensor['sensor_type'].'</td>
|
||||
<td>'.$sensor['sensor_descr'].'</td>
|
||||
<td>'.$sensor['sensor_current'].'</td>
|
||||
<td>
|
||||
<div class="form-group has-feedback">
|
||||
foreach (dbFetchRows("SELECT * FROM sensors WHERE device_id = ? AND sensor_deleted='0'", array($device['device_id'])) as $sensor) {
|
||||
$rollback[] = array(
|
||||
'sensor_id' => $sensor['sensor_id'],
|
||||
'sensor_limit' => $sensor['sensor_limit'],
|
||||
'sensor_limit_low' => $sensor['sensor_limit_low'],
|
||||
'sensor_alert' => $sensor['sensor_alert'],
|
||||
);
|
||||
if ($sensor['sensor_alert'] == 1) {
|
||||
$alert_status = 'checked';
|
||||
}
|
||||
else {
|
||||
$alert_status = '';
|
||||
}
|
||||
|
||||
if ($sensor['sensor_custom'] == 'No') {
|
||||
$custom = 'disabled';
|
||||
}
|
||||
else {
|
||||
$custom = '';
|
||||
}
|
||||
|
||||
echo '
|
||||
<tr>
|
||||
<td>'.$sensor['sensor_class'].'</td>
|
||||
<td>'.$sensor['sensor_type'].'</td>
|
||||
<td>'.$sensor['sensor_descr'].'</td>
|
||||
<td>'.$sensor['sensor_current'].'</td>
|
||||
<td>
|
||||
<div class="form-group has-feedback">
|
||||
<input type="text" class="form-control input-sm sensor" id="high-'.$sensor['device_id'].'" data-device_id="'.$sensor['device_id'].'" data-value_type="sensor_limit" data-sensor_id="'.$sensor['sensor_id'].'" value="'.$sensor['sensor_limit'].'">
|
||||
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="form-group has-feedback">
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="form-group has-feedback">
|
||||
<input type="text" class="form-control input-sm sensor" id="low-'.$sensor['device_id'].'" data-device_id="'.$sensor['device_id'].'" data-value_type="sensor_limit_low" data-sensor_id="'.$sensor['sensor_id'].'" value="'.$sensor['sensor_limit_low'].'">
|
||||
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" name="alert-status" data-device_id="'.$sensor['device_id'].'" data-sensor_id="'.$sensor['sensor_id'].'" '.$alert_status.'>
|
||||
</td>
|
||||
<td>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" name="alert-status" data-device_id="'.$sensor['device_id'].'" data-sensor_id="'.$sensor['sensor_id'].'" '.$alert_status.'>
|
||||
</td>
|
||||
<td>
|
||||
<a type="button" class="btn btn-danger btn-sm '.$custom.' remove-custom" id="remove-custom" name="remove-custom" data-sensor_id="'.$sensor['sensor_id'].'">Clear custom</a>
|
||||
</td>
|
||||
</tr>
|
||||
');
|
||||
</td>
|
||||
</tr>
|
||||
';
|
||||
}
|
||||
|
||||
?>
|
||||
</table>
|
||||
</form>
|
||||
<form id="alert-reset">
|
||||
<?php
|
||||
foreach($rollback as $reset_data)
|
||||
{
|
||||
echo ('
|
||||
<input type="hidden" name="sensor_id[]" value="'.$reset_data['sensor_id'].'">
|
||||
<input type="hidden" name="sensor_limit[]" value="'.$reset_data['sensor_limit'].'">
|
||||
<input type="hidden" name="sensor_limit_low[]" value="'.$reset_data['sensor_limit_low'].'">
|
||||
<input type="hidden" name="sensor_alert[]" value="'.$reset_data['sensor_alert'].'">
|
||||
');
|
||||
foreach ($rollback as $reset_data) {
|
||||
echo '
|
||||
<input type="hidden" name="sensor_id[]" value="'.$reset_data['sensor_id'].'">
|
||||
<input type="hidden" name="sensor_limit[]" value="'.$reset_data['sensor_limit'].'">
|
||||
<input type="hidden" name="sensor_limit_low[]" value="'.$reset_data['sensor_limit_low'].'">
|
||||
<input type="hidden" name="sensor_alert[]" value="'.$reset_data['sensor_alert'].'">
|
||||
';
|
||||
}
|
||||
?>
|
||||
<input type="hidden" name="type" value="sensor-alert-reset">
|
||||
<button id = "newThread" class="btn btn-primary btn-sm" type="submit">Reset values</button>
|
||||
</form>
|
||||
<script>
|
||||
$('#newThread').on('click', function(e){
|
||||
$('#newThread').on('click', function(e){
|
||||
e.preventDefault(); // preventing default click action
|
||||
var form = $('#alert-reset');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/ajax_form.php',
|
||||
data: form.serialize(),
|
||||
type: 'POST',
|
||||
url: '/ajax_form.php',
|
||||
data: form.serialize(),
|
||||
dataType: "html",
|
||||
success: function(data){
|
||||
//alert(data);
|
||||
location.reload(true);
|
||||
//alert(data);
|
||||
location.reload(true);
|
||||
},
|
||||
error:function(){
|
||||
//alert('bad');
|
||||
}
|
||||
error:function(){
|
||||
//alert('bad');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
|
||||
$( ".sensor" ).blur(function() {
|
||||
var sensor_type = $(this).attr('id');
|
||||
var device_id = $(this).data("device_id");
|
||||
var sensor_id = $(this).data("sensor_id");
|
||||
var value_type = $(this).data("value_type");
|
||||
var data = $(this).val();
|
||||
var $this = $(this);
|
||||
$.ajax({
|
||||
$( ".sensor" ).blur(function() {
|
||||
var sensor_type = $(this).attr('id');
|
||||
var device_id = $(this).data("device_id");
|
||||
var sensor_id = $(this).data("sensor_id");
|
||||
var value_type = $(this).data("value_type");
|
||||
var data = $(this).val();
|
||||
var $this = $(this);
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/ajax_form.php',
|
||||
data: { type: "health-update", device_id: device_id, data: data, sensor_id: sensor_id , value_type: value_type},
|
||||
dataType: "html",
|
||||
success: function(data){
|
||||
$this.closest('.form-group').addClass('has-success');
|
||||
$this.next().addClass('glyphicon-ok');
|
||||
setTimeout(function(){
|
||||
$this.closest('.form-group').removeClass('has-success');
|
||||
$this.next().removeClass('glyphicon-ok');
|
||||
}, 2000);
|
||||
},
|
||||
error:function(){
|
||||
$(this).closest('.form-group').addClass('has-error');
|
||||
$this.next().addClass('glyphicon-remove');
|
||||
setTimeout(function(){
|
||||
$this.closest('.form-group').removeClass('has-error');
|
||||
$this.next().removeClass('glyphicon-remove');
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
url: '/ajax_form.php',
|
||||
data: { type: "health-update", device_id: device_id, data: data, sensor_id: sensor_id , value_type: value_type},
|
||||
dataType: "html",
|
||||
success: function(data){
|
||||
$this.closest('.form-group').addClass('has-success');
|
||||
$this.next().addClass('glyphicon-ok');
|
||||
setTimeout(function(){
|
||||
$this.closest('.form-group').removeClass('has-success');
|
||||
$this.next().removeClass('glyphicon-ok');
|
||||
}, 2000);
|
||||
},
|
||||
error:function(){
|
||||
$(this).closest('.form-group').addClass('has-error');
|
||||
$this.next().addClass('glyphicon-remove');
|
||||
setTimeout(function(){
|
||||
$this.closest('.form-group').removeClass('has-error');
|
||||
$this.next().removeClass('glyphicon-remove');
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("[name='alert-status']").bootstrapSwitch('offColor','danger');
|
||||
$('input[name="alert-status"]').on('switchChange.bootstrapSwitch', function(event, state) {
|
||||
$("[name='alert-status']").bootstrapSwitch('offColor','danger');
|
||||
$('input[name="alert-status"]').on('switchChange.bootstrapSwitch', function(event, state) {
|
||||
event.preventDefault();
|
||||
var $this = $(this);
|
||||
var device_id = $(this).data("device_id");
|
||||
var sensor_id = $(this).data("sensor_id");
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/ajax_form.php',
|
||||
data: { type: "sensor-alert-update", device_id: device_id, sensor_id: sensor_id, state: state},
|
||||
dataType: "html",
|
||||
success: function(data){
|
||||
//alert('good');
|
||||
},
|
||||
error:function(){
|
||||
//alert('bad');
|
||||
}
|
||||
type: 'POST',
|
||||
url: '/ajax_form.php',
|
||||
data: { type: "sensor-alert-update", device_id: device_id, sensor_id: sensor_id, state: state},
|
||||
dataType: "html",
|
||||
success: function(data){
|
||||
//alert('good');
|
||||
},
|
||||
error:function(){
|
||||
//alert('bad');
|
||||
}
|
||||
});
|
||||
});
|
||||
$("[name='remove-custom']").on('click', function(event) {
|
||||
event.preventDefault();
|
||||
var $this = $(this);
|
||||
var sensor_id = $(this).data("sensor_id");
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
});
|
||||
$("[name='remove-custom']").on('click', function(event) {
|
||||
event.preventDefault();
|
||||
var $this = $(this);
|
||||
var sensor_id = $(this).data("sensor_id");
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/ajax_form.php',
|
||||
data: { type: "sensor-alert-update", sensor_id: sensor_id, sub_type: "remove-custom" },
|
||||
dataType: "html",
|
||||
success: function(data){
|
||||
$this.addClass('disabled');
|
||||
},
|
||||
error:function(){
|
||||
//alert('bad');
|
||||
}
|
||||
});
|
||||
error:function(){
|
||||
//alert('bad');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,31 +1,45 @@
|
||||
<?php
|
||||
|
||||
if ($_POST['editing'])
|
||||
{
|
||||
if ($_SESSION['userlevel'] > "7")
|
||||
{
|
||||
$ipmi_hostname = mres($_POST['ipmi_hostname']);
|
||||
$ipmi_username = mres($_POST['ipmi_username']);
|
||||
$ipmi_password = mres($_POST['ipmi_password']);
|
||||
if ($_POST['editing']) {
|
||||
if ($_SESSION['userlevel'] > '7') {
|
||||
$ipmi_hostname = mres($_POST['ipmi_hostname']);
|
||||
$ipmi_username = mres($_POST['ipmi_username']);
|
||||
$ipmi_password = mres($_POST['ipmi_password']);
|
||||
|
||||
if ($ipmi_hostname != '') { set_dev_attrib($device, 'ipmi_hostname', $ipmi_hostname); } else { del_dev_attrib($device, 'ipmi_hostname'); }
|
||||
if ($ipmi_username != '') { set_dev_attrib($device, 'ipmi_username', $ipmi_username); } else { del_dev_attrib($device, 'ipmi_username'); }
|
||||
if ($ipmi_password != '') { set_dev_attrib($device, 'ipmi_password', $ipmi_password); } else { del_dev_attrib($device, 'ipmi_password'); }
|
||||
if ($ipmi_hostname != '') {
|
||||
set_dev_attrib($device, 'ipmi_hostname', $ipmi_hostname);
|
||||
}
|
||||
else {
|
||||
del_dev_attrib($device, 'ipmi_hostname');
|
||||
}
|
||||
|
||||
$update_message = "Device IPMI data updated.";
|
||||
$updated = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
include("includes/error-no-perm.inc.php");
|
||||
}
|
||||
if ($ipmi_username != '') {
|
||||
set_dev_attrib($device, 'ipmi_username', $ipmi_username);
|
||||
}
|
||||
else {
|
||||
del_dev_attrib($device, 'ipmi_username');
|
||||
}
|
||||
|
||||
if ($ipmi_password != '') {
|
||||
set_dev_attrib($device, 'ipmi_password', $ipmi_password);
|
||||
}
|
||||
else {
|
||||
del_dev_attrib($device, 'ipmi_password');
|
||||
}
|
||||
|
||||
$update_message = 'Device IPMI data updated.';
|
||||
$updated = 1;
|
||||
}
|
||||
else {
|
||||
include 'includes/error-no-perm.inc.php';
|
||||
}//end if
|
||||
}//end if
|
||||
|
||||
if ($updated && $update_message) {
|
||||
print_message($update_message);
|
||||
}
|
||||
|
||||
if ($updated && $update_message)
|
||||
{
|
||||
print_message($update_message);
|
||||
} elseif ($update_message) {
|
||||
print_error($update_message);
|
||||
else if ($update_message) {
|
||||
print_error($update_message);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -37,19 +51,19 @@ if ($updated && $update_message)
|
||||
<div class="form-group">
|
||||
<label for="ipmi_hostname" class="col-sm-2 control-label">IPMI/BMC Hostname</label>
|
||||
<div class="col-sm-6">
|
||||
<input id="ipmi_hostname" name="ipmi_hostname" class="form-control" value="<?php echo(get_dev_attrib($device,'ipmi_hostname')); ?>" />
|
||||
<input id="ipmi_hostname" name="ipmi_hostname" class="form-control" value="<?php echo get_dev_attrib($device, 'ipmi_hostname'); ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="ipmi_username" class="col-sm-2 control-label">IPMI/BMC Username</label>
|
||||
<div class="col-sm-6">
|
||||
<input id="ipmi_username" name="ipmi_username" class="form-control" value="<?php echo(get_dev_attrib($device,'ipmi_username')); ?>" />
|
||||
<input id="ipmi_username" name="ipmi_username" class="form-control" value="<?php echo get_dev_attrib($device, 'ipmi_username'); ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="impi_password" class="col-sm-2 control-label">IPMI/BMC Password</label>
|
||||
<div class="col-sm-6">
|
||||
<input id="ipmi_password" name="ipmi_password" type="password" class="form-control" value="<?php echo(get_dev_attrib($device,'ipmi_password')); ?>" />
|
||||
<input id="ipmi_password" name="ipmi_password" type="password" class="form-control" value="<?php echo get_dev_attrib($device, 'ipmi_password'); ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-default btn-sm" type="submit" name="Submit">Save</button>
|
||||
|
||||
@@ -17,68 +17,57 @@
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
foreach ($config['poller_modules'] as $module => $module_status)
|
||||
{
|
||||
echo('
|
||||
foreach ($config['poller_modules'] as $module => $module_status) {
|
||||
echo('
|
||||
<tr>
|
||||
<td><strong>'.$module.'</strong></td>
|
||||
<td>
|
||||
');
|
||||
');
|
||||
|
||||
if($module_status == 1)
|
||||
{
|
||||
echo('<span class="text-success">Enabled</span>');
|
||||
}
|
||||
else
|
||||
{
|
||||
echo('<span class="text-danger">Disabled</span>');
|
||||
}
|
||||
if($module_status == 1) {
|
||||
echo('<span class="text-success">Enabled</span>');
|
||||
}
|
||||
else {
|
||||
echo('<span class="text-danger">Disabled</span>');
|
||||
}
|
||||
|
||||
echo('
|
||||
echo('
|
||||
</td>
|
||||
<td>
|
||||
');
|
||||
');
|
||||
|
||||
if (isset($attribs['poll_'.$module]))
|
||||
{
|
||||
if ($attribs['poll_'.$module])
|
||||
{
|
||||
echo('<span id="poller-module-'.$module.'" class="text-success">Enabled</span>');
|
||||
$module_checked = 'checked';
|
||||
if (isset($attribs['poll_'.$module])) {
|
||||
if ($attribs['poll_'.$module]) {
|
||||
echo('<span id="poller-module-'.$module.'" class="text-success">Enabled</span>');
|
||||
$module_checked = 'checked';
|
||||
}
|
||||
else {
|
||||
echo('<span id="poller-module-'.$module.'"class="text-danger">Disabled</span>');
|
||||
$module_checked = '';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo('<span id="poller-module-'.$module.'"class="text-danger">Disabled</span>');
|
||||
$module_checked = '';
|
||||
else {
|
||||
if($module_status == 1) {
|
||||
echo('<span id="poller-module-'.$module.'"class="text-success">Enabled</span>');
|
||||
$module_checked = 'checked';
|
||||
}
|
||||
else {
|
||||
echo('<span id="poller-module-'.$module.'"class="text-danger">Disabled</span>');
|
||||
$module_checked = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($module_status == 1)
|
||||
{
|
||||
echo('<span id="poller-module-'.$module.'"class="text-success">Enabled</span>');
|
||||
$module_checked = 'checked';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo('<span id="poller-module-'.$module.'"class="text-danger">Disabled</span>');
|
||||
$module_checked = '';
|
||||
}
|
||||
}
|
||||
|
||||
echo('
|
||||
echo('
|
||||
</td>
|
||||
<td>
|
||||
');
|
||||
');
|
||||
|
||||
echo('
|
||||
<input type="checkbox" name="poller-module" data-poller_module="'.$module.'" data-device_id="'.$device['device_id'].'" '.$module_checked.'>
|
||||
');
|
||||
echo('<input type="checkbox" name="poller-module" data-poller_module="'.$module.'" data-device_id="'.$device['device_id'].'" '.$module_checked.'>');
|
||||
|
||||
echo('
|
||||
echo('
|
||||
</td>
|
||||
</tr>
|
||||
');
|
||||
');
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -96,71 +85,56 @@ foreach ($config['poller_modules'] as $module => $module_status)
|
||||
|
||||
<?php
|
||||
|
||||
foreach ($config['discovery_modules'] as $module => $module_status)
|
||||
{
|
||||
|
||||
echo('
|
||||
foreach ($config['discovery_modules'] as $module => $module_status) {
|
||||
echo('
|
||||
<tr>
|
||||
<td>
|
||||
<strong>'.$module.'</strong>
|
||||
</td>
|
||||
<td>
|
||||
');
|
||||
');
|
||||
|
||||
if($module_status == 1)
|
||||
{
|
||||
echo('<span class="text-success">Enabled</span>');
|
||||
}
|
||||
else
|
||||
{
|
||||
echo('<span class="text-danger">Disabled</span>');
|
||||
}
|
||||
if($module_status == 1) {
|
||||
echo('<span class="text-success">Enabled</span>');
|
||||
}
|
||||
else {
|
||||
echo('<span class="text-danger">Disabled</span>');
|
||||
}
|
||||
|
||||
echo('
|
||||
echo('
|
||||
</td>
|
||||
<td>
|
||||
');
|
||||
<td>');
|
||||
|
||||
if (isset($attribs['discover_'.$module]))
|
||||
{
|
||||
if($attribs['discover_'.$module])
|
||||
{
|
||||
echo('<span id="discovery-module-'.$module.'" class="text-success">Enabled</span>');
|
||||
$module_checked = 'checked';
|
||||
if (isset($attribs['discover_'.$module])) {
|
||||
if($attribs['discover_'.$module]) {
|
||||
echo('<span id="discovery-module-'.$module.'" class="text-success">Enabled</span>');
|
||||
$module_checked = 'checked';
|
||||
}
|
||||
else {
|
||||
echo('<span id="discovery-module-'.$module.'" class="text-danger">Disabled</span>');
|
||||
$module_checked = '';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo('<span id="discovery-module-'.$module.'" class="text-danger">Disabled</span>');
|
||||
$module_checked = '';
|
||||
else {
|
||||
if($module_status == 1) {
|
||||
echo('<span id="discovery-module-'.$module.'" class="text-success">Enabled</span>');
|
||||
$module_checked = 'checked';
|
||||
}
|
||||
else {
|
||||
echo('<span id="discovery-module-'.$module.'" class="text-danger">Disabled</span>');
|
||||
$module_checked = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($module_status == 1)
|
||||
{
|
||||
echo('<span id="discovery-module-'.$module.'" class="text-success">Enabled</span>');
|
||||
$module_checked = 'checked';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo('<span id="discovery-module-'.$module.'" class="text-danger">Disabled</span>');
|
||||
$module_checked = '';
|
||||
}
|
||||
}
|
||||
|
||||
echo('
|
||||
echo('
|
||||
</td>
|
||||
<td>
|
||||
');
|
||||
<td>');
|
||||
|
||||
echo('
|
||||
<input type="checkbox" name="discovery-module" data-discovery_module="'.$module.'" data-device_id="'.$device['device_id'].'" '.$module_checked.'>
|
||||
');
|
||||
echo('<input type="checkbox" name="discovery-module" data-discovery_module="'.$module.'" data-device_id="'.$device['device_id'].'" '.$module_checked.'>');
|
||||
|
||||
echo('
|
||||
echo('
|
||||
</td>
|
||||
</tr>
|
||||
');
|
||||
</tr>');
|
||||
|
||||
}
|
||||
echo('
|
||||
|
||||
@@ -1,28 +1,26 @@
|
||||
<?php
|
||||
|
||||
echo('<div style="padding: 10px;">');
|
||||
echo '<div style="padding: 10px;">';
|
||||
|
||||
if ($_POST['ignoreport'])
|
||||
{
|
||||
if ($_SESSION['userlevel'] == '10')
|
||||
{
|
||||
include("includes/port-edit.inc.php");
|
||||
}
|
||||
if ($_POST['ignoreport']) {
|
||||
if ($_SESSION['userlevel'] == '10') {
|
||||
include 'includes/port-edit.inc.php';
|
||||
}
|
||||
}
|
||||
|
||||
if ($updated && $update_message)
|
||||
{
|
||||
print_message($update_message);
|
||||
} elseif ($update_message) {
|
||||
print_error($update_message);
|
||||
if ($updated && $update_message) {
|
||||
print_message($update_message);
|
||||
}
|
||||
else if ($update_message) {
|
||||
print_error($update_message);
|
||||
}
|
||||
|
||||
echo("<div style='float: left; width: 100%'>
|
||||
echo "<div style='float: left; width: 100%'>
|
||||
<form id='ignoreport' name='ignoreport' method='post' action='' role='form' class='form-inline'>
|
||||
<input type=hidden name='ignoreport' value='yes'>
|
||||
<input type=hidden name=device value='".$device['device_id']."'>");
|
||||
<input type=hidden name=device value='".$device['device_id']."'>";
|
||||
|
||||
echo("<table class='table table-condensed table-responsive table-striped'>
|
||||
echo "<table class='table table-condensed table-responsive table-striped'>
|
||||
<tr>
|
||||
<th>Index</th>
|
||||
<th>Name</th>
|
||||
@@ -41,14 +39,14 @@ echo("<table class='table table-condensed table-responsive table-striped'>
|
||||
<td><button type='submit' value='Toggle' class='btn btn-default btn-sm' id='ignore-toggle' title='Toggle alerting for all ports'/>Toggle</button><button type='submit' value='Select' class='btn btn-default btn-sm' id='ignore-select' title='Disable alerting on all ports'/>Select All</button></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
");
|
||||
";
|
||||
?>
|
||||
|
||||
<script>
|
||||
$('#disable-toggle').click(function(event) {
|
||||
// invert selection on all disable buttons
|
||||
event.preventDefault();
|
||||
$('input[name^="disabled_"]').trigger('click');
|
||||
$('input[name^="disabled_"]').trigger('click');
|
||||
});
|
||||
$('#ignore-toggle').click(function(event) {
|
||||
// invert selection on all ignore buttons
|
||||
@@ -100,46 +98,47 @@ echo("<table class='table table-condensed table-responsive table-striped'>
|
||||
</script>
|
||||
|
||||
<?php
|
||||
$row = 1;
|
||||
|
||||
$row=1;
|
||||
foreach (dbFetchRows('SELECT * FROM `ports` WHERE `device_id` = ? ORDER BY `ifIndex` ', array($device['device_id'])) as $port) {
|
||||
$port = ifLabel($port);
|
||||
|
||||
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? ORDER BY `ifIndex` ", array($device['device_id'])) as $port)
|
||||
{
|
||||
$port = ifLabel($port);
|
||||
if (is_integer($row / 2)) {
|
||||
$row_colour = $list_colour_a;
|
||||
}
|
||||
else {
|
||||
$row_colour = $list_colour_b;
|
||||
}
|
||||
|
||||
if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
|
||||
echo '<tr>';
|
||||
echo '<td>'.$port['ifIndex'].'</td>';
|
||||
echo '<td>'.$port['label'].'</td>';
|
||||
echo '<td>'.$port['ifAdminStatus'].'</td>';
|
||||
|
||||
echo("<tr>");
|
||||
echo("<td>". $port['ifIndex']."</td>");
|
||||
echo("<td>".$port['label'] . "</td>");
|
||||
echo("<td>". $port['ifAdminStatus']."</td>");
|
||||
// Mark interfaces which are OperDown (but not AdminDown) yet not ignored or disabled, or up yet ignored or disabled
|
||||
// - as to draw the attention to a possible problem.
|
||||
$isportbad = ($port['ifOperStatus'] == 'down' && $port['ifAdminStatus'] != 'down') ? 1 : 0;
|
||||
$dowecare = ($port['ignore'] == 0 && $port['disabled'] == 0) ? $isportbad : !$isportbad;
|
||||
$outofsync = $dowecare ? " class='red'" : '';
|
||||
|
||||
# Mark interfaces which are OperDown (but not AdminDown) yet not ignored or disabled, or up yet ignored or disabled
|
||||
# - as to draw the attention to a possible problem.
|
||||
$isportbad = ($port['ifOperStatus'] == 'down' && $port['ifAdminStatus'] != 'down') ? 1 : 0;
|
||||
$dowecare = ($port['ignore'] == 0 && $port['disabled'] == 0) ? $isportbad : !$isportbad;
|
||||
$outofsync = $dowecare ? " class='red'" : "";
|
||||
echo "<td><span name='operstatus_".$port['port_id']."'".$outofsync.'>'.$port['ifOperStatus'].'</span></td>';
|
||||
|
||||
echo("<td><span name='operstatus_".$port['port_id']."'".$outofsync.">". $port['ifOperStatus']."</span></td>");
|
||||
echo '<td>';
|
||||
echo "<input type=checkbox class='disable-check' name='disabled_".$port['port_id']."'".($port['disabled'] ? 'checked' : '').'>';
|
||||
echo "<input type=hidden name='olddis_".$port['port_id']."' value=".($port['disabled'] ? 1 : 0).'>';
|
||||
echo '</td>';
|
||||
|
||||
echo("<td>");
|
||||
echo("<input type=checkbox class='disable-check' name='disabled_".$port['port_id']."'".($port['disabled'] ? 'checked' : '').">");
|
||||
echo("<input type=hidden name='olddis_".$port['port_id']."' value=".($port['disabled'] ? 1 : 0).">");
|
||||
echo("</td>");
|
||||
echo '<td>';
|
||||
echo "<input type=checkbox class='ignore-check' name='ignore_".$port['port_id']."'".($port['ignore'] ? 'checked' : '').'>';
|
||||
echo "<input type=hidden name='oldign_".$port['port_id']."' value=".($port['ignore'] ? 1 : 0).'>';
|
||||
echo '</td>';
|
||||
echo '<td>'.$port['ifAlias'].'</td>';
|
||||
|
||||
echo("<td>");
|
||||
echo("<input type=checkbox class='ignore-check' name='ignore_".$port['port_id']."'".($port['ignore'] ? 'checked' : '').">");
|
||||
echo("<input type=hidden name='oldign_".$port['port_id']."' value=".($port['ignore'] ? 1 : 0).">");
|
||||
echo("</td>");
|
||||
echo("<td>".$port['ifAlias'] . "</td>");
|
||||
echo "</tr>\n";
|
||||
|
||||
echo("</tr>\n");
|
||||
$row++;
|
||||
}//end foreach
|
||||
|
||||
$row++;
|
||||
}
|
||||
|
||||
echo('</table>');
|
||||
echo('</form>');
|
||||
echo('</div>');
|
||||
|
||||
?>
|
||||
echo '</table>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
|
||||
@@ -1,29 +1,28 @@
|
||||
<?php
|
||||
|
||||
if (is_admin() === TRUE || is_read() === TRUE) {
|
||||
|
||||
if (is_admin() === true || is_read() === true) {
|
||||
if ($_POST['addsrv']) {
|
||||
if ($_SESSION['userlevel'] >= '10') {
|
||||
include("includes/service-add.inc.php");
|
||||
include 'includes/service-add.inc.php';
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST['delsrv']) {
|
||||
if ($_SESSION['userlevel'] >= '10') {
|
||||
include("includes/service-delete.inc.php");
|
||||
include 'includes/service-delete.inc.php';
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST['confirm-editsrv']) {
|
||||
echo "yeah";
|
||||
echo 'yeah';
|
||||
if ($_SESSION['userlevel'] >= '10') {
|
||||
include("includes/service-edit.inc.php");
|
||||
include 'includes/service-edit.inc.php';
|
||||
}
|
||||
}
|
||||
|
||||
if ($handle = opendir($config['install_dir'] . "/includes/services/")) {
|
||||
if ($handle = opendir($config['install_dir'].'/includes/services/')) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if ($file != "." && $file != ".." && !strstr($file, ".")) {
|
||||
if ($file != '.' && $file != '..' && !strstr($file, '.')) {
|
||||
$servicesform .= "<option value='$file'>$file</option>";
|
||||
}
|
||||
}
|
||||
@@ -31,17 +30,17 @@ if (is_admin() === TRUE || is_read() === TRUE) {
|
||||
closedir($handle);
|
||||
}
|
||||
|
||||
$dev = device_by_id_cache($device['device_id']);
|
||||
$devicesform = "<option value='" . $dev['device_id'] . "'>" . $dev['hostname'] . "</option>";
|
||||
$dev = device_by_id_cache($device['device_id']);
|
||||
$devicesform = "<option value='".$dev['device_id']."'>".$dev['hostname'].'</option>';
|
||||
|
||||
if ($updated) {
|
||||
print_message("Device Settings Saved");
|
||||
print_message('Device Settings Saved');
|
||||
}
|
||||
|
||||
if (dbFetchCell("SELECT COUNT(*) from `services` WHERE `device_id` = ?", array($device['device_id'])) > '0') {
|
||||
$i = "1";
|
||||
foreach (dbFetchRows("select * from services WHERE device_id = ? ORDER BY service_type", array($device['device_id'])) as $service) {
|
||||
$existform .= "<option value='" . $service['service_id'] . "'>" . $service['service_type'] . "</option>";
|
||||
if (dbFetchCell('SELECT COUNT(*) from `services` WHERE `device_id` = ?', array($device['device_id'])) > '0') {
|
||||
$i = '1';
|
||||
foreach (dbFetchRows('select * from services WHERE device_id = ? ORDER BY service_type', array($device['device_id'])) as $service) {
|
||||
$existform .= "<option value='".$service['service_id']."'>".$service['service_type'].'</option>';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,28 +48,29 @@ if (is_admin() === TRUE || is_read() === TRUE) {
|
||||
|
||||
if ($existform) {
|
||||
echo '<div class="col-sm-6">';
|
||||
if ($_POST['editsrv'] == "yes") {
|
||||
include_once "includes/print-service-edit.inc.php";
|
||||
} else {
|
||||
if ($_POST['editsrv'] == 'yes') {
|
||||
include_once 'includes/print-service-edit.inc.php';
|
||||
}
|
||||
else {
|
||||
echo "
|
||||
<h3><span class='label label-info threeqtr-width'>Edit / Delete Service</span></h3>
|
||||
<form method='post' action='' class='form-horizontal'>
|
||||
<h3><span class='label label-info threeqtr-width'>Edit / Delete Service</span></h3>
|
||||
<form method='post' action='' class='form-horizontal'>
|
||||
<div class='well well-lg'>
|
||||
<div class='form-group'>
|
||||
<label for='service' class='col-sm-2 control-label'>Type: </label>
|
||||
<div class='col-sm-4'>
|
||||
<select name='service' class='form-control input-sm'>
|
||||
$existform
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<div class='col-sm-offset-2 col-sm-4'>
|
||||
<button type='submit' class='btn btn-primary btn-sm' name='editsrv' id='editsrv' value='yes'>Edit</button> <button type='submit' class='btn btn-danger btn-sm' name='delsrv' id='delsrv' value='yes'>Delete</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<label for='service' class='col-sm-2 control-label'>Type: </label>
|
||||
<div class='col-sm-4'>
|
||||
<select name='service' class='form-control input-sm'>
|
||||
$existform
|
||||
</select>
|
||||
</div>
|
||||
</form>";
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<div class='col-sm-offset-2 col-sm-4'>
|
||||
<button type='submit' class='btn btn-primary btn-sm' name='editsrv' id='editsrv' value='yes'>Edit</button> <button type='submit' class='btn btn-danger btn-sm' name='delsrv' id='delsrv' value='yes'>Delete</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>";
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
@@ -78,8 +78,8 @@ if (is_admin() === TRUE || is_read() === TRUE) {
|
||||
|
||||
echo '<div class="col-sm-6">';
|
||||
|
||||
require_once "includes/print-service-add.inc.php";
|
||||
|
||||
} else {
|
||||
include("includes/error-no-perm.inc.php");
|
||||
}
|
||||
include_once 'includes/print-service-add.inc.php';
|
||||
}
|
||||
else {
|
||||
include 'includes/error-no-perm.inc.php';
|
||||
}
|
||||
|
||||
+178
-163
@@ -1,225 +1,240 @@
|
||||
<?php
|
||||
|
||||
if ($_POST['editing'])
|
||||
{
|
||||
if ($_SESSION['userlevel'] > "7")
|
||||
{
|
||||
$community = mres($_POST['community']);
|
||||
$snmpver = mres($_POST['snmpver']);
|
||||
$transport = $_POST['transport'] ? mres($_POST['transport']) : $transport = "udp";
|
||||
$port = $_POST['port'] ? mres($_POST['port']) : $config['snmp']['port'];
|
||||
$timeout = mres($_POST['timeout']);
|
||||
$retries = mres($_POST['retries']);
|
||||
$poller_group = mres($_POST['poller_group']);
|
||||
$v3 = array (
|
||||
'authlevel' => mres($_POST['authlevel']),
|
||||
'authname' => mres($_POST['authname']),
|
||||
'authpass' => mres($_POST['authpass']),
|
||||
'authalgo' => mres($_POST['authalgo']),
|
||||
'cryptopass' => mres($_POST['cryptopass']),
|
||||
'cryptoalgo' => mres($_POST['cryptoalgo'])
|
||||
);
|
||||
if ($_POST['editing']) {
|
||||
if ($_SESSION['userlevel'] > '7') {
|
||||
$community = mres($_POST['community']);
|
||||
$snmpver = mres($_POST['snmpver']);
|
||||
$transport = $_POST['transport'] ? mres($_POST['transport']) : $transport = 'udp';
|
||||
$port = $_POST['port'] ? mres($_POST['port']) : $config['snmp']['port'];
|
||||
$timeout = mres($_POST['timeout']);
|
||||
$retries = mres($_POST['retries']);
|
||||
$poller_group = mres($_POST['poller_group']);
|
||||
$v3 = array(
|
||||
'authlevel' => mres($_POST['authlevel']),
|
||||
'authname' => mres($_POST['authname']),
|
||||
'authpass' => mres($_POST['authpass']),
|
||||
'authalgo' => mres($_POST['authalgo']),
|
||||
'cryptopass' => mres($_POST['cryptopass']),
|
||||
'cryptoalgo' => mres($_POST['cryptoalgo']),
|
||||
);
|
||||
|
||||
#FIXME needs better feedback
|
||||
$update = array(
|
||||
'community' => $community,
|
||||
'snmpver' => $snmpver,
|
||||
'port' => $port,
|
||||
'transport' => $transport,
|
||||
'poller_group' => $poller_group
|
||||
);
|
||||
// FIXME needs better feedback
|
||||
$update = array(
|
||||
'community' => $community,
|
||||
'snmpver' => $snmpver,
|
||||
'port' => $port,
|
||||
'transport' => $transport,
|
||||
'poller_group' => $poller_group,
|
||||
);
|
||||
|
||||
if ($_POST['timeout']) { $update['timeout'] = $timeout; }
|
||||
else { $update['timeout'] = array('NULL'); }
|
||||
if ($_POST['retries']) { $update['retries'] = $retries; }
|
||||
else { $update['retries'] = array('NULL'); }
|
||||
|
||||
$update = array_merge($update, $v3);
|
||||
|
||||
$device_tmp = deviceArray($device['hostname'], $community, $snmpver, $port, $transport, $v3);
|
||||
if (isSNMPable($device_tmp)) {
|
||||
$rows_updated = dbUpdate($update, 'devices', '`device_id` = ?',array($device['device_id']));
|
||||
|
||||
if ($rows_updated > 0) {
|
||||
$update_message = $rows_updated . " Device record updated.";
|
||||
$updated = 1;
|
||||
} elseif ($rows_updated = '-1') {
|
||||
$update_message = "Device record unchanged. No update necessary.";
|
||||
$updated = -1;
|
||||
} else {
|
||||
$update_message = "Device record update error.";
|
||||
$updated = 0;
|
||||
if ($_POST['timeout']) {
|
||||
$update['timeout'] = $timeout;
|
||||
}
|
||||
else {
|
||||
$update['timeout'] = array('NULL');
|
||||
}
|
||||
} else {
|
||||
$update_message = "Could not connect to device with new SNMP details";
|
||||
$updated = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id']));
|
||||
if ($_POST['retries']) {
|
||||
$update['retries'] = $retries;
|
||||
}
|
||||
else {
|
||||
$update['retries'] = array('NULL');
|
||||
}
|
||||
|
||||
$update = array_merge($update, $v3);
|
||||
|
||||
$device_tmp = deviceArray($device['hostname'], $community, $snmpver, $port, $transport, $v3);
|
||||
if (isSNMPable($device_tmp)) {
|
||||
$rows_updated = dbUpdate($update, 'devices', '`device_id` = ?', array($device['device_id']));
|
||||
|
||||
if ($rows_updated > 0) {
|
||||
$update_message = $rows_updated.' Device record updated.';
|
||||
$updated = 1;
|
||||
}
|
||||
else if ($rows_updated = '-1') {
|
||||
$update_message = 'Device record unchanged. No update necessary.';
|
||||
$updated = -1;
|
||||
}
|
||||
else {
|
||||
$update_message = 'Device record update error.';
|
||||
$updated = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$update_message = 'Could not connect to device with new SNMP details';
|
||||
$updated = 0;
|
||||
}
|
||||
}//end if
|
||||
}//end if
|
||||
|
||||
$device = dbFetchRow('SELECT * FROM `devices` WHERE `device_id` = ?', array($device['device_id']));
|
||||
$descr = $device['purpose'];
|
||||
|
||||
echo('<div class="row">
|
||||
<div class="col-sm-6">');
|
||||
if ($updated && $update_message)
|
||||
{
|
||||
print_message($update_message);
|
||||
} elseif ($update_message) {
|
||||
print_error($update_message);
|
||||
echo '<div class="row">
|
||||
<div class="col-sm-6">';
|
||||
if ($updated && $update_message) {
|
||||
print_message($update_message);
|
||||
}
|
||||
else if ($update_message) {
|
||||
print_error($update_message);
|
||||
}
|
||||
echo(' </div>
|
||||
</div>');
|
||||
|
||||
echo("
|
||||
<form id='edit' name='edit' method='post' action='' role='form' class='form-horizontal'>
|
||||
<input type=hidden name='editing' value='yes'>
|
||||
<div class='form-group'>
|
||||
echo ' </div>
|
||||
</div>';
|
||||
|
||||
echo "
|
||||
<form id='edit' name='edit' method='post' action='' role='form' class='form-horizontal'>
|
||||
<input type=hidden name='editing' value='yes'>
|
||||
<div class='form-group'>
|
||||
<label for='snmpver' class='col-sm-2 control-label'>SNMP Details</label>
|
||||
<div class='col-sm-1'>
|
||||
<select id='snmpver' name='snmpver' class='form-control input-sm' onChange='changeForm();'>
|
||||
<option value='v1'>v1</option>
|
||||
<option value='v2c' " . ($device['snmpver'] == 'v2c' ? 'selected' : '') . ">v2c</option>
|
||||
<option value='v3' " . ($device['snmpver'] == 'v3' ? 'selected' : '') . ">v3</option>
|
||||
</select>
|
||||
<select id='snmpver' name='snmpver' class='form-control input-sm' onChange='changeForm();'>
|
||||
<option value='v1'>v1</option>
|
||||
<option value='v2c' ".($device['snmpver'] == 'v2c' ? 'selected' : '').">v2c</option>
|
||||
<option value='v3' ".($device['snmpver'] == 'v3' ? 'selected' : '').">v3</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class='col-sm-2'>
|
||||
<input type='text' name='port' placeholder='port' class='form-control input-sm'>
|
||||
<input type='text' name='port' placeholder='port' class='form-control input-sm'>
|
||||
</div>
|
||||
<div class='col-sm-1'>
|
||||
<select name='transport' id='transport' class='form-control input-sm'>");
|
||||
<select name='transport' id='transport' class='form-control input-sm'>";
|
||||
foreach ($config['snmp']['transports'] as $transport) {
|
||||
echo("<option value='".$transport."'");
|
||||
echo "<option value='".$transport."'";
|
||||
if ($transport == $device['transport']) {
|
||||
echo(" selected='selected'");
|
||||
echo " selected='selected'";
|
||||
}
|
||||
echo(">".$transport."</option>");
|
||||
|
||||
echo '>'.$transport.'</option>';
|
||||
}
|
||||
echo(" </select>
|
||||
|
||||
echo " </select>
|
||||
</div>
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<div class='col-sm-2'>
|
||||
</div>
|
||||
<div class='col-sm-1'>
|
||||
<input id='timeout' name='timeout' class='form-control input-sm' value='" . ($device['timeout'] ? $device['timeout'] : '') . "' placeholder='seconds' />
|
||||
<input id='timeout' name='timeout' class='form-control input-sm' value='".($device['timeout'] ? $device['timeout'] : '')."' placeholder='seconds' />
|
||||
</div>
|
||||
<div class='col-sm-1'>
|
||||
<input id='retries' name='retries' class='form-control input-sm' value='" . ($device['timeout'] ? $device['retries'] : '') . "' placeholder='retries' />
|
||||
<input id='retries' name='retries' class='form-control input-sm' value='".($device['timeout'] ? $device['retries'] : '')."' placeholder='retries' />
|
||||
</div>
|
||||
</div>
|
||||
<div id='snmpv1_2'>
|
||||
</div>
|
||||
<div id='snmpv1_2'>
|
||||
<div class='form-group'>
|
||||
<label class='col-sm-3 control-label text-left'><h4><strong>SNMPv1/v2c Configuration</strong></h4></label>
|
||||
<label class='col-sm-3 control-label text-left'><h4><strong>SNMPv1/v2c Configuration</strong></h4></label>
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<label for='community' class='col-sm-2 control-label'>SNMP Community</label>
|
||||
<div class='col-sm-4'>
|
||||
<input id='community' class='form-control' name='community' value='" . $device['community'] . "' />
|
||||
</div>
|
||||
<label for='community' class='col-sm-2 control-label'>SNMP Community</label>
|
||||
<div class='col-sm-4'>
|
||||
<input id='community' class='form-control' name='community' value='".$device['community']."' />
|
||||
</div>
|
||||
</div>
|
||||
<div id='snmpv3'>
|
||||
</div>
|
||||
</div>
|
||||
<div id='snmpv3'>
|
||||
<div class='form-group'>
|
||||
<label class='col-sm-3 control-label'><h4><strong>SNMPv3 Configuration</strong></h4></label>
|
||||
<label class='col-sm-3 control-label'><h4><strong>SNMPv3 Configuration</strong></h4></label>
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<label for='authlevel' class='col-sm-2 control-label'>Auth Level</label>
|
||||
<div class='col-sm-4'>
|
||||
<select id='authlevel' name='authlevel' class='form-control'>
|
||||
<option value='NoAuthNoPriv'>NoAuthNoPriv</option>
|
||||
<option value='AuthNoPriv' " . ($device['authlevel'] == "authNoPriv" ? 'selected' : '') . ">AuthNoPriv</option>
|
||||
<option value='AuthPriv' " . ($device['authlevel'] == "authPriv" ? 'selected' : '') . ">AuthPriv</option>
|
||||
</select>
|
||||
</div>
|
||||
<label for='authlevel' class='col-sm-2 control-label'>Auth Level</label>
|
||||
<div class='col-sm-4'>
|
||||
<select id='authlevel' name='authlevel' class='form-control'>
|
||||
<option value='NoAuthNoPriv'>NoAuthNoPriv</option>
|
||||
<option value='AuthNoPriv' ".($device['authlevel'] == 'authNoPriv' ? 'selected' : '').">AuthNoPriv</option>
|
||||
<option value='AuthPriv' ".($device['authlevel'] == 'authPriv' ? 'selected' : '').">AuthPriv</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<label for='authname' class='col-sm-2 control-label'>Auth User Name</label>
|
||||
<div class='col-sm-4'>
|
||||
<input type='text' id='authname' name='authname' class='form-control' value='" . $device['authname'] . "'>
|
||||
</div>
|
||||
<label for='authname' class='col-sm-2 control-label'>Auth User Name</label>
|
||||
<div class='col-sm-4'>
|
||||
<input type='text' id='authname' name='authname' class='form-control' value='".$device['authname']."'>
|
||||
</div>
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<label for='authpass' class='col-sm-2 control-label'>Auth Password</label>
|
||||
<div class='col-sm-4'>
|
||||
<input type='password' id='authpass' name='authpass' class='form-control' value='" . $device['authpass'] . "'>
|
||||
</div>
|
||||
<label for='authpass' class='col-sm-2 control-label'>Auth Password</label>
|
||||
<div class='col-sm-4'>
|
||||
<input type='password' id='authpass' name='authpass' class='form-control' value='".$device['authpass']."'>
|
||||
</div>
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<label for='authalgo' class='col-sm-2 control-label'>Auth Algorithm</label>
|
||||
<div class='col-sm-4'>
|
||||
<select id='authalgo' name='authalgo' class='form-control'>
|
||||
<option value='MD5'>MD5</option>
|
||||
<option value='SHA' " . ($device['authalgo'] === "SHA" ? 'selected' : '') . ">SHA</option>
|
||||
</select>
|
||||
</div>
|
||||
<label for='authalgo' class='col-sm-2 control-label'>Auth Algorithm</label>
|
||||
<div class='col-sm-4'>
|
||||
<select id='authalgo' name='authalgo' class='form-control'>
|
||||
<option value='MD5'>MD5</option>
|
||||
<option value='SHA' ".($device['authalgo'] === 'SHA' ? 'selected' : '').">SHA</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<label for='cryptopass' class='col-sm-2 control-label'>Crypto Password</label>
|
||||
<div class='col-sm-4'>
|
||||
<input type='password' id='cryptopass' name='cryptopass' class='form-control' value='" . $device['cryptopass'] . "'>
|
||||
</div>
|
||||
<label for='cryptopass' class='col-sm-2 control-label'>Crypto Password</label>
|
||||
<div class='col-sm-4'>
|
||||
<input type='password' id='cryptopass' name='cryptopass' class='form-control' value='".$device['cryptopass']."'>
|
||||
</div>
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<label for='cryptoalgo' class='col-sm-2 control-label'>Crypto Algorithm</label>
|
||||
<div class='col-sm-4'>
|
||||
<select id='cryptoalgo' name='cryptoalgo' class='form-control'>
|
||||
<option value='AES'>AES</option>
|
||||
<option value='DES' " . ($device['cryptoalgo'] === "DES" ? 'selected' : '') . ">DES</option>
|
||||
</select>
|
||||
</div>
|
||||
<label for='cryptoalgo' class='col-sm-2 control-label'>Crypto Algorithm</label>
|
||||
<div class='col-sm-4'>
|
||||
<select id='cryptoalgo' name='cryptoalgo' class='form-control'>
|
||||
<option value='AES'>AES</option>
|
||||
<option value='DES' ".($device['cryptoalgo'] === 'DES' ? 'selected' : '').'>DES</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>");
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
if ($config['distributed_poller'] === TRUE) {
|
||||
echo('
|
||||
<div class="form-group">
|
||||
<label for="poller_group" class="col-sm-2 control-label">Poller Group</label>
|
||||
<div class="col-sm-4">
|
||||
<select name="poller_group" id="poller_group" class="form-control input-sm">
|
||||
<option value="0"> Default poller group</option>
|
||||
');
|
||||
if ($config['distributed_poller'] === true) {
|
||||
echo '
|
||||
<div class="form-group">
|
||||
<label for="poller_group" class="col-sm-2 control-label">Poller Group</label>
|
||||
<div class="col-sm-4">
|
||||
<select name="poller_group" id="poller_group" class="form-control input-sm">
|
||||
<option value="0"> Default poller group</option>
|
||||
';
|
||||
|
||||
foreach (dbFetchRows("SELECT `id`,`group_name` FROM `poller_groups`") as $group) {
|
||||
echo '<option value="' . $group['id'] . '"';
|
||||
foreach (dbFetchRows('SELECT `id`,`group_name` FROM `poller_groups`') as $group) {
|
||||
echo '<option value="'.$group['id'].'"';
|
||||
if ($device['poller_group'] == $group['id']) {
|
||||
echo ' selected';
|
||||
}
|
||||
echo '>' . $group['group_name'] . '</option>';
|
||||
|
||||
echo '>'.$group['group_name'].'</option>';
|
||||
}
|
||||
|
||||
echo('
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
');
|
||||
}
|
||||
echo '
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
}//end if
|
||||
|
||||
|
||||
echo('
|
||||
<button type="submit" name="Submit" class="btn btn-default">Save</button>
|
||||
</form>
|
||||
');
|
||||
echo '
|
||||
<button type="submit" name="Submit" class="btn btn-default">Save</button>
|
||||
</form>
|
||||
';
|
||||
|
||||
?>
|
||||
<script>
|
||||
function changeForm() {
|
||||
snmpVersion = $("#snmpver").val();
|
||||
if(snmpVersion == 'v1' || snmpVersion == 'v2c') {
|
||||
$('#snmpv1_2').show();
|
||||
$('#snmpv3').hide();
|
||||
} else if(snmpVersion == 'v3') {
|
||||
$('#snmpv1_2').hide();
|
||||
$('#snmpv3').show();
|
||||
}
|
||||
function changeForm() {
|
||||
snmpVersion = $("#snmpver").val();
|
||||
if(snmpVersion == 'v1' || snmpVersion == 'v2c') {
|
||||
$('#snmpv1_2').show();
|
||||
$('#snmpv3').hide();
|
||||
}
|
||||
else if(snmpVersion == 'v3') {
|
||||
$('#snmpv1_2').hide();
|
||||
$('#snmpv3').show();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
if($snmpver == 'v3' || $device['snmpver'] == 'v3') {
|
||||
echo("$('#snmpv1_2').toggle();");
|
||||
} else {
|
||||
echo("$('#snmpv3').toggle();");
|
||||
}
|
||||
if ($snmpver == 'v3' || $device['snmpver'] == 'v3') {
|
||||
echo "$('#snmpv1_2').toggle();";
|
||||
}
|
||||
else {
|
||||
echo "$('#snmpv3').toggle();";
|
||||
}
|
||||
|
||||
?>
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user