<?php
include_once('include/class_history_links.inc');
include_once("include/dbconnect.php");
include_once("include/functions.php");
$config = new ReadConfig;
$general = $config->General('gui_debug');
$save_edit = "";
if (isset($_POST["ip"]))
$ip_edit = trim($_POST["ip"]);
if (isset($_POST["host"]))
$host_edit = trim($_POST["host"]);
if (isset($_POST["save"]))
$save_edit = $_POST["save"];
if (isset($_POST["host_id"]))
$host_id = $_POST["host_id"];
if ($save_edit == "Save")
{
$comment_edit = $_POST['comment_edit'];
$query = "UPDATE hosts SET comment = '$comment_edit' WHERE host_id = '$host_id';";
$result = mysql_query($query) or die (mysql_error());
include("menu.html");
echo "<h1>Date Saved</h1>";
$return = $h->get_history_go(-1);
echo "<p> <p><div align='center'><h2><a href='$return'>Return $host_edit ($ip_edit)</a></h2></div>";
return;
} else {
$query = "SELECT host_id,ip,hostname,DATE(FROM_UNIXTIME(d_last_scan)) as Date,TIME(FROM_UNIXTIME(d_last_scan)) as Time,ping,priority,comment FROM hosts WHERE host_id = '$host_id'";
$result = mysql_query($query) or die (mysql_error());
while ($linea = mysql_fetch_array($result, MYSQL_ASSOC)) {
$host_id = $linea["host_id"];
$priority_edit = $linea["priority"];
$ip_edit = $linea["ip"];
$host_edit = $linea["hostname"];
$d_last_scan_edit = "$linea[Date] $linea[Time]";
$ping_edit = $linea["ping"];
$comment_edit = $linea["comment"];
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Add comment to host</title>
</head>
<body>
<table class="cancerbero">
<!--<table style="background-color: rgb(0, 0, 153); width: 100%; text-align: left;" border="0" cellpadding="1" cellspacing="1"> -->
<tbody>
<form action="table_host_edit.php" method="post">
<tr>
<td colspan="3">
<h1>Add comment to host</h1><br>
</td>
</tr>
<tr>
<?php if ($general['gui_debug'] == 1) echo "<td style='vertical-align: middle; background-color: rgb(255, 255, 150);'><h2>Host_id: $host_id</h2></td>"; ?>
<td style='vertical-align: middle; background-color: rgb(255, 204, 153);'><h2>IP: <?php echo $ip_edit ?></h2></td>
<td style='vertical-align: middle; background-color: rgb(255, 204, 153);'><h2>Last Scanned: <?php echo $d_last_scan_edit ?><h2/></td>
</tr>
<tr>
<?php if ($general['gui_debug'] == 1) echo "<td style='vertical-align: middle; background-color: rgb(255, 255, 150);'><h2>Priority: $priority_edit</h2></td>"; ?>
<td style='vertical-align: top; background-color: rgb(255, 204, 153);'><h2>Hostname: <?php echo $host_edit ?></h2></td>
<td style='vertical-align: middle; background-color: rgb(255, 204, 153);'><h2>Pings Failed: <?php echo $ping_edit ?><h2/></td>
</tr>
<tr>
<td colspan="3" rowspan="1" style='vertical-align: top; background-color: rgb(255, 204, 153);'><h2>Comment: <input type="text" name="comment_edit" value="<?php echo $comment_edit ?>" size="100" maxlength="255"></h2></td>
</tr>
<tr>
<td colspan="3" rowspan="1" style='text-align: right; vertical-align: top; background-color: rgb(255, 204, 153);'>
<input type="hidden" name="host_id" value="<?php echo $host_id ?>">
<input type="hidden" name="hostname" value="<?php echo $host_edit ?>">
<input type="hidden" name="ip" value="<?php echo $ip_edit ?>">
<input type="submit" name="save" value="Save">
<input type="reset" name="reset" value="Reset">
</td>
</tr>
</form>
</table>
</body>
</html>