<?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/
// ----------------------------------------------------------------------
?>
<div class="title"><img src="images/ipaddress.gif" alt="IP Address" align="bottom"> <?php echo TXT_IP_ADDRESS; ?></div>
<?php
if (!isset($action))
{
$requestcount=mysql_query("SELECT count(*) FROM $name_table_ip_address") or die ("ERROR!");
$all_ip_addresses = mysql_fetch_array($requestcount);
if ((!isset($num)) && (!isset($start)))
{
$num = 20;
$start = 1;
$num2 = $num;
$startnext = $start + $num;
if ($all_ip_addresses[0] < $num)
{
$next = "";
$previous = "";
}
else
{
$next = "<input type=\"button\" onClick=\"window.location='index.php?include=mainview&page=ip_address&start=$startnext&num=$num'\" value=\"".TXT_NEXT."\" style=\"margin:0px;border: 1px solid #c0c0c0;background-color: #f6f6f6;\">";
$previous = "";
}
}
else if ($start=="1")
{
$start = 1;
$num2 = $num;
$startnext = $start + $num;
}
else
{
$num2 = $num + $start;
$startnext = $start + $num;
$startprevious = $start - $num;
if ($startnext > $all_ip_addresses[0])
{
$previous = "<input type=\"button\" onClick=\"window.location='index.php?include=mainview&page=ip_address&start=$startprevious&num=$num'\" value=\"".TXT_PREVIOUS."\" style=\"margin:0px;border: 1px solid #c0c0c0;background-color: #f6f6f6;\">";
$next = "";
}
else
{
$next = "<input type=\"button\" onClick=\"window.location='index.php?include=mainview&page=ip_address&start=$startnext&num=$num'\" value=\"".TXT_NEXT."\" style=\"margin:0px;border: 1px solid #c0c0c0;background-color: #f6f6f6;\">";
$previous = "<input type=\"button\" onClick=\"window.location='index.php?include=mainview&page=ip_address&start=$startprevious&num=$num'\" value=\"".TXT_PREVIOUS."\" style=\"margin:0px;border: 1px solid #c0c0c0;background-color: #f6f6f6;\">";
}
}
?>
<form action="index.php?include=mainview&page=ip_address&action=delete&delete=multiple" method="post" style="border:0px; margin:0px; padding:0px;" onsubmit="return confirm('Are you sure you want to delete the selected items?');">
<table class="subtitle" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="70%"><h4><img src="images/ipaddress.gif" alt="IP Address" align="top"> <?php echo TXT_ALL_IP_ADDRESSES; ?> <span style="font-weight:normal;font-size: 80%;margin-left: 20px;"><?php echo TXT_RESULTS; ?> <b><?php echo "$start"; ?></b> - <b><?php echo "$num2"; ?></b> <?php echo TXT_OF; ?> <b><?php echo "$all_ip_addresses[0]";?></b></span></h4></td>
<td width="30%" style="text-align:right"><input type="button" onClick="window.location='index.php?include=mainview&page=ip_address&action=add'" value="<?php echo TXT_ADD; ?>" style="margin:0px;border: 1px solid #c0c0c0;background-color: #f6f6f6;"> <input type="button" onClick="window.location='index.php?include=mainview&page=ip_address&display=all&start=1&num=<?php echo $all_ip_addresses[0]; ?>'" value="<?php echo TXT_DISPLAY_ALL; ?>" style="margin:0px;border: 1px solid #c0c0c0;background-color: #f6f6f6;"> <?php if (!isset($display)) echo "$previous $next";?> <input type="submit" value="<?php echo TXT_DELETE_SELECTED; ?>" name="send_remove_ann" id="removeChecked" style="margin:0px;border: 1px solid #c0c0c0;background-color: #f6f6f6;" disabled></td>
<tr>
</table>
<table class="sortable list" id="sortable" width="100%" cellspacing="2" cellpadding="3">
<tr class="list_title">
<td class="unsortable" width="2%" valign="top"><input type="checkbox" onclick="checkAllFields(1);" id="checkAll" style="border:0px;"></td>
<td width="10%" valign="top"><?php echo TXT_IP_ADDRESS; ?></td>
<td width="11%" valign="top"><?php echo TXT_MAC_ADDRESS; ?></td>
<td width="14%" valign="top"><?php echo TXT_SUBNET; ?></td>
<td width="15%" valign="top"><?php echo TXT_NAME; ?></td>
<td width="26%" valign="top"><?php echo TXT_DESCRIPTION; ?></td>
<td width="10%" valign="top"><?php echo TXT_STATUS; ?></td>
<td class="unsortable" width="12%" valign="top"><?php echo TXT_ACTION; ?></td>
</tr>
<?php
$list1 = "list1";
$list2 = "list2";
$line_count = 0;
$start_sql = $start - 1;
$request=mysql_query("SELECT * FROM $name_table_ip_address ORDER BY id,ip ASC LIMIT $start_sql,$num") or die ("ERROR!");
while($tmp_request=mysql_fetch_array($request))
{
$line_color = ($line_count % 2) ? $list1 : $list2;
?>
<tr class="<?php echo "$line_color"; ?>">
<td width="2%" valign="top"><input class="boxes" type="checkbox" value="<?php echo $tmp_request['id']; ?>" name="delAnn[]" onclick="checkAllFields(2);" style="border:0px;"></td>
<td width="10%" valign="top"><?php print("<a href=\"index.php?include=mainview&page=ip_address&action=view&id=$tmp_request[id]\">$tmp_request[ip]</a>"); ?></td>
<td width="10%" valign="top"><?php print("$tmp_request[mac_address]"); ?></td>
<td width="15%" valign="top"><?php
$request2=mysql_query("SELECT id,name FROM $name_table_subnet WHERE id=$tmp_request[subnet_id]") or die ("ERROR!");
while($tmp_request2=mysql_fetch_array($request2))
{
echo "<a href=\"index.php?include=mainview&page=subnet&action=view&id=$tmp_request2[id]\">$tmp_request2[name]</a>";
}
?></td>
<td width="15%" valign="top"><?php echo $tmp_request['name']; ?></td>
<td width="26%" valign="top"><?php echo $tmp_request['description']; ?></td>
<td width="10%" valign="top" align="center"><?php
switch ($tmp_request['status'])
{
case '0':
echo "<p style='margin:0px;background:#0000ff;color:#fff'>".TXT_ASSIGNED."</p>";
break;
case '1':
echo "<p style='margin:0px;background:#00ff00;color:#fff'>".TXT_UNUSED."</p>";
break;
case '2':
echo "<p style='margin:0px;background:#ff0000;color:#fff'>".TXT_RESERVED."</p>";
break;
}
?></td>
<td width="12%" valign="top">[ <?php print("<a href=\"index.php?include=mainview&page=ip_address&action=edit&id=$tmp_request[id]\">".TXT_EDIT."</a>"); ?> ] [ <?php print("<a href=\"index.php?include=mainview&page=ip_address&action=delete&id=$tmp_request[id]\">".TXT_DELETE."</a>"); ?> ]</td>
</tr>
<?php
$line_count++;
}
?>
</table>
</form>
<br><center><a href="javascript:history.go(-1);"><?php echo TXT_BACK; ?></a></center>
<?php
}
else if ($action == "view")
{
include("ip_address/view.php");
}
else
{
$request=mysql_query("SELECT administrator FROM $name_table_users WHERE username=\"$login\"") or die ("ERROR!");
while($tmp_request=mysql_fetch_array($request))
{
$user_privilege = $tmp_request['administrator'];
}
if (($user_privilege=="1") || ($user_privilege=="2"))
{
if ($action == "add")
{
include("ip_address/add.php");
}
else if ($action == "edit")
{
include("ip_address/edit.php");
}
else if ($action == "delete")
{
include("ip_address/delete.php");
}
else
{
include("pagenotfound.php");
}
}
else
{
echo "<center><div id=\"status\" style=\"color:red\"><img src=\"images/forbidden.png\" alt=\"FORBIDDEN\"><br><br>";
echo TXT_FORBIDDEN;
echo "</div></center>";
}
}
?>