<?php
// ----------------------------------------------------------------------
// Copyright (C) 2007 by GREGORY LE BRAS
// ----------------------------------------------------------------------
// LICENSE
//
// This file is part of ODCNMS - Open DataCenter Network Management System
//
// ODCNMS 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 2 of the License, or
// (at your option) any later version.
//
// Foobar 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 Foobar; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// ----------------------------------------------------------------------
// Original Author of file: GREGORY LE BRAS - http://www.odcnms.org/
// ----------------------------------------------------------------------
?>
<?php
if (!isset($edit))
{
$request=mysql_query("SELECT * FROM $name_table_network WHERE id=\"$_GET[id]\"") or die ("ERROR!");
while($tmp_request=mysql_fetch_array($request))
{
$address_array = explode(".",$tmp_request['address']);
$mask_array = explode(".",$tmp_request['mask']);
$cidr = find_net ($tmp_request['address'],$tmp_request['mask']);
$cidr = str_replace("/","",$cidr['cidr']);
?>
<form method="post" action="index.php?include=mainview&page=network&action=edit&edit=ok&id=<?php echo $id;?>" name="edit_network">
<fieldset class="form">
<legend><img src="images/edit.gif" alt="Edit" align="top"> <?php echo TXT_EDIT; ?> <?php echo TXT_NETWORK; ?></legend>
<label><?php echo TXT_NAME; ?></label>
<input type="text" name="name" size="50" value="<?php echo $tmp_request['name']; ?>"><br>
<label><?php echo TXT_ADDRESS; ?></label>
<input type="text" name="oct1" id="oct1" size="3" maxlength="3" value="<?php echo $address_array[0]; ?>" disabled><span style="top: -6px;position:relative;">.</span><input type="text" name="oct2" id="oct2" size="3" maxlength="3" value="<?php echo $address_array[1]; ?>" disabled><span style="top: -6px;position:relative;">.</span><input type="text" name="oct3" id="oct3" size="3" maxlength="3" value="<?php echo $address_array[2]; ?>" disabled><span style="top: -6px;position:relative;">.</span><input type="text" name="oct4" id="oct4" size="3" maxlength="3" value="<?php echo $address_array[3]; ?>" disabled><br>
<label><?php echo TXT_MASK; ?></label>
<input type="text" name="snm" id="snm1" size="3" maxlength="3" value="<?php echo $mask_array[0]; ?>" disabled><span style="top: -6px;position:relative;">.</span><input type="text" name="snm2" id="snm2" size="3" maxlength="3" value="<?php echo $mask_array[1]; ?>" disabled><span style="top: -6px;position:relative;">.</span><input type="text" name="snm3" id="snm3" size="3" maxlength="3" value="<?php echo $mask_array[2]; ?>" disabled><span style="top: -6px;position:relative;">.</span><input type="text" name="snm4" id="snm4" size="3" maxlength="3" value="<?php echo $mask_array[3]; ?>" disabled><span style="position:relative;top:-10px;"> or /</span><input type="text" name="snmbits" size="2" maxlength="2" value="<?php echo $cidr; ?>" disabled><br>
<label><?php echo TXT_DESCRIPTION; ?></label>
<textarea name="description" rows="10" cols="50"><?php echo $tmp_request['description']; ?></textarea><br>
<input type="submit" name="submit" value="<?php echo TXT_EDIT; ?>"> <input type="button" value="<?php echo TXT_BACK; ?>" onClick="javascript:history.go(-1);">
</fieldset>
</form>
<script language="JavaScript" type="text/javascript">
var frmvalidator = new Validator("edit_network");
frmvalidator.addValidation("name","req","Please enter the name of the network");
frmvalidator.addValidation("name","maxlen=255",
"Max length for name is 255");
frmvalidator.addValidation("oct1","req","Please enter the first part of the Address of the network");
frmvalidator.addValidation("oct1","num","Please enter numeric data for the first part of the Address of the network");
frmvalidator.addValidation("oct1","maxlen=3","Max length for the first part of the Address of the network is 3");
frmvalidator.addValidation("oct2","req","Please enter the second part of the Address of the network");
frmvalidator.addValidation("oct2","num","Please enter numeric data for the second part of the Address of the network");
frmvalidator.addValidation("oct2","maxlen=3","Max length for the second part of the Address of the network is 3");
frmvalidator.addValidation("oct3","req","Please enter the third part of the Address of the network");
frmvalidator.addValidation("oct3","num","Please enter numeric data for the third part of the Address of the network");
frmvalidator.addValidation("oct3","maxlen=3","Max length for the third part of the Address of the network is 3");
frmvalidator.addValidation("oct4","req","Please enter the fourth part of the Address of the network");
frmvalidator.addValidation("oct4","num","Please enter numeric data for the fourth part of the Address of the network");
frmvalidator.addValidation("oct4","maxlen=3","Max length for the fourth part of the Address of the network is 3");
frmvalidator.addValidation("snm1","req","Please enter the first part of the Mask of the network");
frmvalidator.addValidation("snm1","num","Please enter numeric data for the first part of the Mask of the network");
frmvalidator.addValidation("snm1","maxlen=3","Max length for the first part of the Mask of the network is 3");
frmvalidator.addValidation("snm2","req","Please enter the second part of the Mask of the network");
frmvalidator.addValidation("snm2","num","Please enter numeric data for the second part of the Mask of the network");
frmvalidator.addValidation("snm2","maxlen=3","Max length for the second part of the Mask of the network is 3");
frmvalidator.addValidation("snm3","req","Please enter the third part of the Mask of the network");
frmvalidator.addValidation("snm3","num","Please enter numeric data for the third part of the Mask of the network");
frmvalidator.addValidation("snm3","maxlen=3","Max length for the third part of the Mask of the network is 3");
frmvalidator.addValidation("snm4","req","Please enter the fourth part of the Mask of the network");
frmvalidator.addValidation("snm4","num","Please enter numeric data for the fourth part of the Mask of the network");
frmvalidator.addValidation("snm4","maxlen=3","Max length for the fourth part of the Mask of the network is 3");
</script>
<?php
}
}
else if ($edit=="ok")
{
$query=mysql_query("UPDATE $name_table_network SET name=\"$name\", description=\"$description\" WHERE id=$id");
if(!$query)
{
echo "<center><div id=\"status\" style=\"color:red\"><img src=\"images/warning.png\" alt=\"WARNING\"><br><br>";
echo TXT_DATABASE_ERROR;
echo "</div><br><a href=\"javascript:history.go(-2);\">";
echo TXT_BACK;
echo "</a></center>";
}
else
{
$currentdate = date('Y-m-d');
$currenttime = date("H:i:s");
user_log ($_SESSION['login'],$name_table_users,$name_table_users_log,"edit","network","$name ($id)",$mysql_hostname,$mysql_username,$mysql_password,$mysql_database);
foreach ($syslog_server as $arrayvalue)
{
$syslog = new Syslog();
$syslog->SetFacility(13);
$syslog->SetSeverity(5);
$syslog->SetProcess('odcnms');
$syslog->SetHostname('');
$syslog->SetFqdn('');
$syslog->SetIpFrom('');
$syslog->SetContent($currentdate.' '.$currenttime.' user: '.$_SESSION['login'].' - edit network '.$name.'('.$id.')');
$syslog->SetServer($arrayvalue);
$syslog->Send();
}
echo "<center><div id=\"status\" style=\"color:green\"><img src=\"images/info.png\" alt=\"INFO\"><br><br>";
echo TXT_SUCCESSFULLY_EDIT_NETWORK;
echo "</div><br><a href=\"javascript:history.go(-2);\">";
echo TXT_BACK;
echo "</a></center>";
}
}
?>