2010-06-20 17:21:35 +00:00
|
|
|
<?php
|
|
|
|
|
2011-03-16 23:10:10 +00:00
|
|
|
if ($_POST['editing'])
|
|
|
|
{
|
|
|
|
if ($_SESSION['userlevel'] > "7")
|
|
|
|
{
|
2011-03-18 15:30:49 +00:00
|
|
|
$descr = mres($_POST['descr']);
|
|
|
|
$ignore = mres($_POST['ignore']);
|
|
|
|
$type = mres($_POST['type']);
|
|
|
|
$disabled = mres($_POST['disabled']);
|
|
|
|
$community = mres($_POST['community']);
|
|
|
|
$snmpver = mres($_POST['snmpver']);
|
|
|
|
$port = mres($_POST['port']);
|
|
|
|
$timeout = mres($_POST['timeout']);
|
|
|
|
$retries = mres($_POST['retries']);
|
|
|
|
|
|
|
|
#FIXME needs more sanity checking! and better feedback
|
|
|
|
$sql = "UPDATE `devices` SET `purpose` = '" . $descr . "', `community` = '" . $community . "', `type` = '$type'";
|
|
|
|
$sql .= ", `snmpver` = '" . $snmpver . "', `ignore` = '$ignore', `disabled` = '$disabled', `port` = '$port', ";
|
|
|
|
if ($timeout) { $sql .= "`timeout` = '$timeout', "; } else { $sql .= "`timeout` = NULL, "; }
|
|
|
|
if ($retries) { $sql .= "`retries` = '$retries'"; } else { $sql .= "`retries` = NULL"; }
|
|
|
|
$sql .= " WHERE `device_id` = '".$device['device_id']."'";
|
|
|
|
$query = mysql_query($sql);
|
|
|
|
|
|
|
|
$rows_updated = mysql_affected_rows();
|
|
|
|
|
|
|
|
if ($rows_updated > 0)
|
|
|
|
{
|
|
|
|
$update_message = mysql_affected_rows() . " 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;
|
|
|
|
}
|
2010-06-20 17:21:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$device = mysql_fetch_array(mysql_query("SELECT * FROM `devices` WHERE `device_id` = '".$device['device_id']."'"));
|
|
|
|
$descr = $device['purpose'];
|
|
|
|
|
2011-03-16 23:10:10 +00:00
|
|
|
if ($updated && $update_message)
|
|
|
|
{
|
2010-06-20 17:21:35 +00:00
|
|
|
print_message($update_message);
|
|
|
|
} elseif ($update_message) {
|
|
|
|
print_error($update_message);
|
|
|
|
}
|
|
|
|
|
|
|
|
echo("<table cellpadding=0 cellspacing=0><tr><td>
|
|
|
|
|
|
|
|
<h5>
|
|
|
|
<a href='?page=delhost&id=".$device['device_id']."'>
|
|
|
|
<img src='images/16/server_delete.png' align='absmiddle'>
|
|
|
|
Delete
|
|
|
|
</a>
|
|
|
|
</h5>
|
|
|
|
|
|
|
|
<form id='edit' name='edit' method='post' action=''>
|
|
|
|
<input type=hidden name='editing' value='yes'>
|
|
|
|
<table width='400' border='0'>
|
|
|
|
<tr>
|
|
|
|
<td><div align='right'>Description</div></td>
|
|
|
|
<td colspan='3'><input name='descr' size='32' value='" . $device['purpose'] . "'></input></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td width='300'><div align='right'>SNMP Community</div></td>
|
|
|
|
<td colspan='3'><input name='community' size='20' value='" . $device['community'] . "'></input>
|
2010-06-20 21:37:05 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><div align=right>SNMP Version</div></td>
|
|
|
|
<td><select name='snmpver'>
|
2010-06-20 17:21:35 +00:00
|
|
|
<option value='v1'>v1</option>
|
|
|
|
<option value='v2c'" . ($device['snmpver'] == 'v2c' ? 'selected=selected' : '') . ">v2c</option>
|
|
|
|
</select>
|
|
|
|
</td>
|
|
|
|
</tr>
|
2010-06-20 21:37:05 +00:00
|
|
|
<tr>
|
|
|
|
<td width='300'><div align='right'>SNMP Port</div></td>
|
|
|
|
<td colspan='3'><input name='port' size='20' value='" . $device['port'] . "'></input>
|
|
|
|
</td>
|
|
|
|
</tr>
|
2011-03-15 16:12:44 +00:00
|
|
|
<tr>
|
|
|
|
<td width='300'><div align='right'>SNMP Transport</div></td>
|
|
|
|
<td colspan='3'>
|
|
|
|
<select name='transport'>");
|
2011-03-16 23:10:10 +00:00
|
|
|
|
|
|
|
foreach ($config['snmp']['transports'] as $transport)
|
|
|
|
{
|
2011-03-15 16:12:44 +00:00
|
|
|
echo ("<option value='".$transport."'");
|
|
|
|
if ($transport == $device['transport']) { echo (" selected='selected'"); }
|
|
|
|
echo (">".$transport."</option>");
|
|
|
|
}
|
2011-03-16 23:10:10 +00:00
|
|
|
|
2011-03-15 16:12:44 +00:00
|
|
|
echo(" </select>
|
|
|
|
</td>
|
|
|
|
</tr>
|
2010-09-26 22:10:04 +00:00
|
|
|
<tr>
|
|
|
|
<td width='300'><div align='right'>SNMP Timeout</div></td>
|
2011-03-18 15:30:49 +00:00
|
|
|
<td colspan='3'><input name='timeout' size='20' value='" . ($device['timeout'] ? $device['timeout'] : '') . "'></input>
|
2010-09-26 22:10:04 +00:00
|
|
|
<em>seconds</em>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td width='300'><div align='right'>SNMP Retries</div></td>
|
2011-03-18 15:30:49 +00:00
|
|
|
<td colspan='3'><input name='retries' size='20' value='" . ($device['timeout'] ? $device['retries'] : '') . "'></input>
|
2010-09-26 22:10:04 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
2010-06-20 21:37:05 +00:00
|
|
|
|
2010-06-20 17:21:35 +00:00
|
|
|
<tr>
|
|
|
|
<td align='right'>
|
|
|
|
Type
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<select name='type'>");
|
|
|
|
|
|
|
|
$unknown = 1;
|
|
|
|
foreach ($device_types as $type)
|
|
|
|
{
|
2010-11-20 14:04:07 +00:00
|
|
|
echo(' <option value="'.$type.'"');
|
2010-06-20 17:21:35 +00:00
|
|
|
if ($device['type'] == $type)
|
|
|
|
{
|
2010-11-20 14:04:07 +00:00
|
|
|
echo('selected="1"');
|
2010-06-20 17:21:35 +00:00
|
|
|
$unknown = 0;
|
|
|
|
}
|
2010-11-20 14:04:07 +00:00
|
|
|
echo(' >' . ucfirst($type) . '</option>');
|
2010-06-20 17:21:35 +00:00
|
|
|
}
|
|
|
|
if ($unknown)
|
|
|
|
{
|
2010-11-20 14:04:07 +00:00
|
|
|
echo(' <option value="other">Other</option>');
|
2010-06-20 17:21:35 +00:00
|
|
|
}
|
|
|
|
echo("
|
|
|
|
</select>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><div align='right'>Disable</div></td>
|
|
|
|
<td><input name='disabled' type='checkbox' id='disabled' value='1'");
|
2011-03-16 23:10:10 +00:00
|
|
|
if ($device['disabled']) { echo("checked=checked"); }
|
2010-06-20 17:21:35 +00:00
|
|
|
echo("/></td>
|
|
|
|
<td><div align='right'>Ignore</div></td>
|
|
|
|
<td><input name='ignore' type='checkbox' id='disable' value='1'");
|
2011-03-16 23:10:10 +00:00
|
|
|
if ($device['ignore']) { echo("checked=checked"); }
|
2010-06-20 17:21:35 +00:00
|
|
|
echo("/></td>
|
|
|
|
</tr>");
|
|
|
|
|
|
|
|
echo('
|
|
|
|
</table>
|
|
|
|
<input type="submit" name="Submit" value="Save" />
|
|
|
|
<label><br />
|
|
|
|
</label>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
</td>
|
|
|
|
<td width="50"></td><td></td></tr></table>');
|
|
|
|
|
2011-03-16 23:10:10 +00:00
|
|
|
?>
|