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

<?php
if (!isset($action))
{
?>
<form action="index.php?include=mainview&page=network&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/network.gif" alt="Network" align="top"> <?php echo TXT_ALL_NETWORKS; ?></h4></td>
		<td width="30%" style="text-align:right"><input type="button" onClick="window.location='index.php?include=mainview&page=network&action=add'" value="<?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 class="unsortable" width="20%" valign="top"><?php echo TXT_NAME; ?></td>
		<td width="10%" valign="top"><?php echo TXT_ADDRESS; ?></td>
		<td width="12%" valign="top"><?php echo TXT_MASK; ?></td>
		<td width="34%" valign="top"><?php echo TXT_DESCRIPTION; ?></td>
		<td class="unsortable" width="12%" valign="top"><?php echo TXT_ACTION; ?></td>
	</tr>
</table>
<?php
	$list1 = "list1"; 
	$list2 = "list2"; 
	$line_count = 0; 
	$i = 0;
	$request=mysql_query("SELECT * FROM $name_table_network ORDER BY name ASC") or die ("ERROR!");

	while($tmp_request=mysql_fetch_array($request))
	{
		$line_color = ($line_count % 2) ? $list1 : $list2;
		
		$requestcount=mysql_query("SELECT count(status) FROM $name_table_subnet WHERE network_id=$tmp_request[id]") or die ("ERROR!");
		$all_subnet = mysql_fetch_array($requestcount);
		
		$requestcount_assigned=mysql_query("SELECT count(status) FROM $name_table_subnet WHERE network_id=$tmp_request[id] AND status='0'") or die ("ERROR!");
		$all_subnet_assigned = mysql_fetch_array($requestcount_assigned);
		
		$requestcount_unused=mysql_query("SELECT count(status) FROM $name_table_subnet WHERE network_id=$tmp_request[id] AND status='1'") or die ("ERROR!");
		$all_subnet_unused = mysql_fetch_array($requestcount_unused);	
		
		$requestcount_reserved=mysql_query("SELECT count(status) FROM $name_table_subnet WHERE network_id=$tmp_request[id] AND status='2'") or die ("ERROR!");
		$all_subnet_reserved = mysql_fetch_array($requestcount_reserved);			

		
	?>
	<table class="list" width="100%" cellspacing="2" cellpadding="3">
		<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="20%" valign="top"><?php print("<a href='#' onclick=\"displayelement('ajaxcontentarea_$i');urlredirectdiv('ajax_view.php?what=displaysubnet&id=$tmp_request[id]','ajaxcontentarea_$i');\"><img id='arrow_$i' src=\"images/arrow_up.gif\" border='0' align='top' onclick=\"changeimage('images/arrow_up.gif','images/arrow_down.gif','arrow_$i');\"></a><a href=\"index.php?include=mainview&page=network&action=view&id=$tmp_request[id]\">$tmp_request[name]</a>"); 
			
			if ((($all_subnet_assigned[0]!=$all_subnet[0]) || ($all_subnet[0]==0)))
			{
				echo " (<font style='background-color:#0000ff;color:#fff;'>$all_subnet_assigned[0]</font> | <font style='background-color:#00ff00;color:#fff;'>$all_subnet_unused[0]</font> | <font style='background-color:#ff0000;color:#fff;'>$all_subnet_reserved[0]</font> / $all_subnet[0])";
			}
			
			?></td>
			<td width="10%" valign="top"><?php echo $tmp_request['address']; ?></td>
			<td width="12%" valign="top"><?php echo $tmp_request['mask']; $net = find_net($tmp_request['address'],$tmp_request['mask']); echo " (".$net['cidr'].")";?></td>
			<td width="34%" valign="top"><?php echo $tmp_request['description']; ?></td>
			<td width="12%" valign="top">[ <?php print("<a href=\"index.php?include=mainview&page=network&action=edit&id=$tmp_request[id]\">"); echo TXT_EDIT; echo "</a>"; ?> ] [ <?php print("<a href=\"index.php?include=mainview&page=network&action=delete&id=$tmp_request[id]\">"); echo TXT_DELETE; echo "</a>"; ?> ]</td>	
		</tr>
	</table>
	<?php	
		echo "<div style=\"display:none;position:relative;margin-left: 20px;background-color:#ededed;\" id=\"ajaxcontentarea_$i\"></div>";
			$line_count++;
			$i++;
	}
?>
</form>
<br><center><a href="javascript:history.go(-1);"><?php echo TXT_BACK; ?></a></center>
<?php
}
else if ($action == "view")
{
	include("network/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("network/add.php");
		}
		else if ($action == "edit")
		{
			include("network/edit.php");
		}
		else if ($action == "delete")
		{
			include("network/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