Location: PHPKode > projects > OpenDataCenter Network Management System > include/mainview_page/subnet.php
<?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/subnetwork.gif" alt="Subnet" align="bottom"> <?php echo TXT_SUBNET; ?></div>

<?php
if (!isset($action))
{
?>
<form action="index.php?include=mainview&page=subnet&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="60%"><h4><img src="images/subnetwork.gif" alt="Subnet" align="top"> <?php echo TXT_ALL_SUBNETS; ?></h4></td>
		<td width="40%" style="text-align:right"><input type="button" onClick="window.location='index.php?include=mainview&page=subnet&action=manually_add'" value="<?php echo TXT_MANUALLY; ?> <?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=subnet&action=automatically_add'" value="<?php echo TXT_AUTOMATICALLY; ?> <?php echo TXT_ADD; ?>" style="margin:0px;border: 1px solid #c0c0c0;background-color: #f6f6f6;"> <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="15%" valign="top"><?php echo TXT_NAME; ?></td>
		<td width="25%" valign="top"><?php echo TXT_NETWORK; ?></td>
		<td width="10%" valign="top"><?php echo TXT_ADDRESS; ?></td>
		<td width="10%" valign="top"><?php echo TXT_MASK; ?></td>
		<td width="8%" valign="top"><?php echo TXT_STATUS; ?></td>
		<td width="18%" valign="top"><?php echo TXT_DESCRIPTION; ?></td>
		<td class="unsortable" width="12%" valign="top"><?php echo TXT_ACTION; ?></td>
	</tr>
<?php
	$list1 = "list1"; 
	$list2 = "list2"; 
	$line_count = 0; 

	$request=mysql_query("SELECT * FROM $name_table_subnet ORDER BY network_id,id ASC") 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="15%" valign="top"><?php print("<a href=\"index.php?include=mainview&page=subnet&action=view&id=$tmp_request[id]\">$tmp_request[name]</a>"); ?></td>
			<td width="25%" valign="top"><?php 
			
			$request2=mysql_query("SELECT id,name,address,mask FROM $name_table_network WHERE id=$tmp_request[network_id]");
			
			while ($tmp_request2=mysql_fetch_array($request2))
			{
				$cidr = find_net($tmp_request2['address'],$tmp_request2['mask']);
				echo "<a href=\"index.php?include=mainview&page=network&action=view&id=$tmp_request2[id]\">$tmp_request2[name] ($tmp_request2[address]$cidr[cidr])</a>";
			}


			?></td>
			<td width="10%" valign="top"><?php echo $tmp_request['address']; ?></td>
			<td width="10%" valign="top"><?php echo $tmp_request['mask']; ?></td>
			<td width="8%" valign="top" align="center"><?php			
			switch ($tmp_request['status'])
			{
				case '0':
				echo "<p style='margin:0px;background:#0000ff;color:#fff'>";
				echo TXT_ASSIGNED;
				echo "</p>";
				break;

				case '1':
				echo "<p style='margin:0px;background:#00ff00;color:#fff'>";
				echo TXT_UNUSED;
				echo "</p>";
				break;

				case '2':
				echo "<p style='margin:0px;background:#ff0000;color:#fff'>";
				echo TXT_RESERVED;
				echo "</p>";
				break;
			}
			?></td>
			<td width="18%" valign="top"><?php echo $tmp_request['description']; ?></td>
			<td width="12%" valign="top">[ <?php print("<a href=\"index.php?include=mainview&page=subnet&action=edit&id=$tmp_request[id]\">"); echo TXT_EDIT; echo "</a>"; ?> ] [ <?php print("<a href=\"index.php?include=mainview&page=subnet&action=delete&id=$tmp_request[id]\">"); echo TXT_DELETE; echo "</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("subnet/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 == "manually_add")
		{
			include("subnet/manually_add.php");
		}
		else if ($action == "automatically_add")
		{
			include("subnet/automatically_add.php");
		}
		else if ($action == "edit")
		{
			include("subnet/edit.php");
		}
		else if ($action == "delete")
		{
			include("subnet/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_ACTION; echo "</div></center>";
	}
}
?>
Return current item: OpenDataCenter Network Management System