<?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
$request=mysql_query("SELECT * FROM $name_table_device WHERE id=\"$id\"") or die ("ERROR!");
while($tmp_request=mysql_fetch_array($request))
{
$device_name = $tmp_request['name'];
?>
<table class="subtitle" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="80%"><h4><img src="images/device.gif" alt="Device" align="top"> <?php echo $tmp_request['name']; ?></h4></td>
<td width="10%" style="text-align:right">[ <a href="index.php?include=mainview&page=device&action=edit&id=<?php echo $id; ?>"><?php echo TXT_EDIT; ?></a> ]</td>
<td width="10%" style="text-align:right">[ <a href="index.php?include=mainview&page=device&action=delete&id=<?php echo $id; ?>"><?php echo TXT_DELETE; ?></a> ]</td>
<tr>
</table>
<table class="list" width="100%" cellspacing="2" cellpadding="3">
<tr class="list_title">
<td width="100%" style="font-weight:normal;"><b><?php echo TXT_DEFAULT; ?> <?php echo TXT_IP_ADDRESS; ?>:</b> <?php
$request2=mysql_query("SELECT id,ip FROM $name_table_ip_address WHERE id=$tmp_request[ip_address_id]") or die ("ERROR!");
while($tmp_request2=mysql_fetch_array($request2))
{
$ipaddress = $tmp_request2['ip'];
echo "<a href=\"index.php?include=mainview&page=ip_address&action=view&id=$tmp_request2[id]\">".$tmp_request2['ip']."</a>";
}
?>
</td>
</tr>
<tr class="list_title">
<td width="100%" style="font-weight:normal;"><b><?php echo TXT_LAYER; ?> :</b> <?php
$requestcountvlan=mysql_query("SELECT count(*) FROM $name_table_link_vlan_device WHERE device_id=$id") or die ("ERROR!");
$all_vlan = mysql_fetch_array($requestcountvlan);
if ($all_vlan[0]=="0")
{
$requestcountip=mysql_query("SELECT count(*) FROM $name_table_link_device_ip_address WHERE device_id=$id") or die ("ERROR!");
$all_ip= mysql_fetch_array($requestcountip);
if ($all_ip[0]=="0")
{
echo "2";
$display="vlan";
$display2="";
}
else
{
echo "3+";
$display="ip";
$display2="";
}
}
else
{
echo "2+";
$display="vlan";
$display2="ip";
}
?>
</td>
</tr>
<tr class="list_title">
<td width="100%" style="font-weight:normal;"><b><?php echo TXT_MANUFACTURER; ?> :</b> <?php
$request2=mysql_query("SELECT id,name,manufacturer_id FROM $name_table_model WHERE id=$tmp_request[model_id]") or die ("ERROR!");
while($tmp_request2=mysql_fetch_array($request2))
{
$request3=mysql_query("SELECT id,name FROM $name_table_manufacturer WHERE id=$tmp_request2[manufacturer_id]") or die ("ERROR!");
while($tmp_request3=mysql_fetch_array($request3))
{
echo "<a href=\"index.php?include=mainview&page=manufacturer&action=view&id=$tmp_request3[id]\">".$tmp_request3['name']."</a>";
}
}
?></td>
</tr>
<tr class="list_title">
<td width="100%" style="font-weight:normal;"><b><?php echo TXT_CATEGORY; ?> :</b> <?php
$request2=mysql_query("SELECT id,name,category_id FROM $name_table_model WHERE id=$tmp_request[model_id]") or die ("ERROR!");
while($tmp_request2=mysql_fetch_array($request2))
{
$request3=mysql_query("SELECT id,name FROM $name_table_category WHERE id=$tmp_request2[category_id]") or die ("ERROR!");
while($tmp_request3=mysql_fetch_array($request3))
{
echo "<a href=\"index.php?include=mainview&page=category&action=view&id=$tmp_request3[id]\">".$tmp_request3['name']."</a>";
}
}
?></td>
</tr>
<tr class="list_title">
<td width="100%" style="font-weight:normal;"><b><?php echo TXT_MODEL; ?> :</b> <?php
$request2=mysql_query("SELECT id,name FROM $name_table_model WHERE id=$tmp_request[model_id]") or die ("ERROR!");
while($tmp_request2=mysql_fetch_array($request2))
{
echo "<a href=\"index.php?include=mainview&page=model&action=view&id=$tmp_request2[id]\">".$tmp_request2['name']."</a>";
}
?></td>
</tr>
<tr class="list_title">
<td width="100%" style="font-weight:normal;"><b><?php echo TXT_LOCATION; ?> :</b> <?php
$request2=mysql_query("SELECT id,name,location_id FROM $name_table_rack WHERE id=$tmp_request[rack_id]") or die ("ERROR!");
while($tmp_request2=mysql_fetch_array($request2))
{
$request3=mysql_query("SELECT id,name FROM $name_table_location WHERE id=$tmp_request2[location_id]") or die ("ERROR!");
while($tmp_request3=mysql_fetch_array($request3))
{
echo "<a href=\"index.php?include=mainview&page=location&action=view&id=$tmp_request3[id]\">".$tmp_request3['name']."</a>";
}
}
?></td>
</tr>
<tr class="list_title">
<td width="100%" style="font-weight:normal;"><b><?php echo TXT_RACK; ?> :</b> <?php
$request2=mysql_query("SELECT id,name FROM $name_table_rack WHERE id=$tmp_request[rack_id]") or die ("ERROR!");
while($tmp_request2=mysql_fetch_array($request2))
{
echo "<a href=\"index.php?include=mainview&page=rack&action=view&id=$tmp_request2[id]\">".$tmp_request2['name']."</a>";
}
?></td>
</tr>
<tr class="list_title">
<td width="100%" style="font-weight:normal;"><b><?php echo TXT_SNMP_READ_COMMUNITY; ?> :</b> <?php echo $tmp_request['snmp_read_community']; ?></td>
</tr>
<tr class="list_title">
<td width="100%" style="font-weight:normal;"><b><?php echo TXT_SNMP_PORT; ?> :</b> <?php echo $tmp_request['snmp_port']; ?></td>
</tr>
<tr class="list_title">
<td width="100%" style="font-weight:normal;"><b><?php echo TXT_DESCRIPTION; ?> :</b> <?php echo $tmp_request['description']; ?></td>
</tr>
</table>
<?php
if ($display=="vlan")
{
?>
<table class="subtitle" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="90%"><h4><img src="images/vlan.gif" alt="vlan" align="top"> <?php echo TXT_ALL; ?> "<?php echo $device_name; ?>" <?php echo TXT_VLANS; ?></h4></td>
<tr>
</table>
<table class="sortable list" id="sortable" width="100%" cellspacing="2" cellpadding="3">
<tr class="list_title">
<td width="15%" valign="top"><?php echo TXT_NAME; ?></td>
<td width="15%" valign="top"><?php echo TXT_NUMBER; ?></td>
<td width="25%" valign="top"><?php echo TXT_SUBNET; ?></td>
<td width="26%" 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_vlan=mysql_query("SELECT * FROM $name_table_link_vlan_device WHERE device_id=$id") or die ("ERROR!");
while($tmp_request_vlan=mysql_fetch_array($request_vlan))
{
$request=mysql_query("SELECT * FROM $name_table_vlan WHERE id=$tmp_request_vlan[vlan_id] ORDER BY 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="15%" valign="top"><?php print("<a href=\"index.php?include=mainview&page=vlan&action=view&id=$tmp_request[id]\">$tmp_request[name]</a>"); ?></td>
<td width="15%" valign="top"><?php echo $tmp_request['number']; ?></td>
<td width="25%" valign="top"><?php
$request2=mysql_query("SELECT * FROM $name_table_link_subnet_vlan WHERE vlan_id=$tmp_request[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[subnet_id]\">";
$request3=mysql_query("SELECT * FROM $name_table_subnet WHERE id=$tmp_request2[subnet_id]") or die ("ERROR!");
while ($tmp_request3=mysql_fetch_array($request3))
{
$cidr = find_net($tmp_request3['address'],$tmp_request3['mask']);
echo "$tmp_request3[name] ($tmp_request3[address]$cidr[cidr])</a><br>";
}
}
?></td>
<td width="26%" valign="top"><?php echo $tmp_request['description']; ?></td>
<td width="12%" valign="top">[ <?php print("<a href=\"index.php?include=mainview&page=vlan&action=edit&id=$tmp_request[id]\">".TXT_EDIT."</a>"); ?> ] [ <?php print("<a href=\"index.php?include=mainview&page=vlan&action=delete&id=$tmp_request[id]\">".TXT_DELETE."</a>"); ?> ]</td>
</tr>
<?php
$line_count++;
}
}
?>
</table>
<?php
}
if ((($display2=="ip") && ($display=="vlan")) || (($display=="ip") && ($display2=="")))
{
?>
<table class="subtitle" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="90%"><h4><img src="images/ipaddress.gif" alt="ip_address" align="top"> <?php echo TXT_ALL; ?> "<?php echo $device_name; ?>" <?php echo TXT_IP_ADDRESSES; ?></h4></td>
<tr>
</table>
<table class="sortable list" id="sortable" width="100%" cellspacing="2" cellpadding="3">
<tr class="list_title">
<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;
$request_link_device_address = mysql_query("SELECT * FROM $name_table_link_device_ip_address WHERE device_id=$id") or die ("ERROR!");
while($tmp_request_link_device_address=mysql_fetch_array($request_link_device_address))
{
$request_address=mysql_query("SELECT * FROM $name_table_ip_address WHERE id=$tmp_request_link_device_address[ip_address_id] ORDER BY id,ip ASC") or die ("ERROR!");
while($tmp_request_address=mysql_fetch_array($request_address))
{
$line_color = ($line_count % 2) ? $list1 : $list2;
?>
<tr class="<?php echo "$line_color"; ?>">
<td width="10%" valign="top"><?php print("<a href=\"index.php?include=mainview&page=ip_address&action=view&id=$tmp_request_address[id]\">$tmp_request_address[ip]</a>"); ?></td>
<td width="10%" valign="top"><?php print("$tmp_request_address[mac_address]"); ?></td>
<td width="15%" valign="top"><?php
$request2=mysql_query("SELECT id,name FROM $name_table_subnet WHERE id=$tmp_request_address[subnet_id]") or die ("ERROR!");
while($tmp_request_address2=mysql_fetch_array($request2))
{
echo "<a href=\"index.php?include=mainview&page=subnet&action=view&id=$tmp_request_address2[id]\">$tmp_request_address2[name]</a>";
}
?></td>
<td width="15%" valign="top"><?php echo $tmp_request_address['name']; ?></td>
<td width="26%" valign="top"><?php echo $tmp_request_address['description']; ?></td>
<td width="10%" valign="top" align="center"><?php
switch ($tmp_request_address['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_address[id]\">".TXT_EDIT."</a>"); ?> ] [ <?php print("<a href=\"index.php?include=mainview&page=ip_address&action=delete&id=$tmp_request_address[id]\">".TXT_DELETE."</a>"); ?> ]</td>
</tr>
<?php
$line_count++;
}
}
?>
</table>
<?php
}
?>
<table class="subtitle" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="90%"><h4><img src="images/link.gif" alt="Link" align="top"> <?php echo TXT_LINK_BETWEEN_OTHER_DEVICES; ?></h4></td>
<td width="10%" align="right"><a href="#" onclick="javascript:urlredirectdiv('ajax_view.php?what=linkbetweendevices&id=<?php echo $id; ?>&ipaddress=<?php echo $ipaddress; ?>','linkdevicearea');displayelement('linkdevicearea');changeimage('images/arrow-up.gif','images/arrow-down.gif','arrow_link_devices');"><img src="images/arrow-up.gif" alt="Arrow" align="bottom" border="0" id="arrow_link_devices"></a></td>
<tr>
</table>
<div id="linkdevicearea" style="display:none;"></div>
<table class="subtitle" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%"><h4><img src="images/device.gif" alt="Device" align="top"> <?php echo TXT_DEVICE; ?> <?php echo TXT_VIEW; ?></h4></td>
<tr>
</table>
<a name="rack_view"></a>
<div id="ajaxcontentarea"></div>
<div id="rack_view">
<div class="rack">
<?php
$request7=mysql_query("SELECT * FROM $name_table_device WHERE id=$id ORDER BY id ASC") or die ("ERROR!");
while($tmp_request7=mysql_fetch_array($request7))
{
$request8=mysql_query("SELECT * FROM $name_table_model WHERE id=\"$tmp_request7[model_id]\"") or die ("ERROR!");
while($tmp_request8=mysql_fetch_array($request8))
{
switch($tmp_request8['height'])
{
case '1':
echo "<div class=\"device\" style=\"height:130px\"><h4><a href=\"#rack_view\" onclick=\"javascript:urlredirectdiv('ajax_view.php?what=device&id=$tmp_request7[id]','ajaxcontentarea');\">$tmp_request7[name] ($tmp_request8[height] U)</a></h4>";
break;
case '2':
echo "<div class=\"device\" style=\"height:260px\"><h4><a href=\"#rack_view\" onclick=\"javascript:urlredirectdiv('ajax_view.php?what=device&id=$tmp_request7[id]','ajaxcontentarea');\">$tmp_request7[name] ($tmp_request8[height] U)</a></h4>";
break;
case '3':
echo "<div class=\"device\" style=\"height:390px\"><h4><a href=\"#rack_view\" onclick=\"javascript:urlredirectdiv('ajax_view.php?what=device&id=$tmp_request7[id]','ajaxcontentarea');\">$tmp_request7[name] ($tmp_request8[height] U)</a></h4>";
break;
case '4':
echo "<div class=\"device\" style=\"height:520px\"><h4><a href=\"#rack_view\" onclick=\"javascript:urlredirectdiv('ajax_view.php?what=device&id=$tmp_request7[id]','ajaxcontentarea');\">$tmp_request7[name] ($tmp_request8[height] U)</a></h4>";
break;
default:
$other_height = $tmp_request8['height']*130;
echo "<div class=\"device\" style=\"height:".$other_height."px\"><h4><a href=\"#rack_view\" onclick=\"javascript:urlredirectdiv('ajax_view.php?what=device&id=$tmp_request7[id]','ajaxcontentarea');\">$tmp_request7[name] ($tmp_request8[height] U)</a></h4>";
break;
}
$request9=mysql_query("SELECT * FROM $name_table_slot WHERE device_id=\"$tmp_request7[id]\" ORDER BY id ASC") or die ("ERROR!");
while($tmp_request9=mysql_fetch_array($request9))
{
echo "<div class=\"slot\"><b><a href=\"#rack_view\" onclick=\"javascript:urlredirectdiv('ajax_view.php?what=slot&id=$tmp_request9[id]','ajaxcontentarea');\">".TXT_SLOT." $tmp_request9[number]</a></b>";
$request10=mysql_query("SELECT * FROM $name_table_interface WHERE slot_id=\"$tmp_request9[id]\" ORDER BY id ASC") or die ("ERROR!2");
$i = 1;
while($tmp_request10=mysql_fetch_array($request10))
{
$requestcount=mysql_query("SELECT count(*) FROM $name_table_link_interface_interface WHERE (interface_id=$tmp_request10[id] OR interface2_id=$tmp_request10[id])") or die ("ERROR!");
$count_interface = mysql_fetch_array($requestcount);
$requestcount_port_interface=mysql_query("SELECT count(*) FROM $name_table_link_port_interface WHERE interface_id=$tmp_request10[id]") or die ("ERROR!");
$count_port_interface = mysql_fetch_array($requestcount_port_interface);
if (($count_interface[0] > 0) || ($count_port_interface[0] > 0))
{
echo "<div class=\"interface_linked\"><a href=\"#rack_view\" onclick=\"javascript:urlredirectdiv('ajax_view.php?what=interface&id=$tmp_request10[id]','ajaxcontentarea');\">$i</a></div>";
}
else if (($count_interface[0]==0) || ($count_port_interface[0] == 0))
{
echo "<div class=\"interface\"><a href=\"#rack_view\" onclick=\"javascript:urlredirectdiv('ajax_view.php?what=interface&id=$tmp_request10[id]','ajaxcontentarea');\">$i</a></div>";
}
$i++;
}
echo "</div>";
}
}
echo "</div>";
}
?>
</div>
</div>
<br><center><a href="javascript:history.go(-1);"><?php echo TXT_BACK; ?></a></center>
<?php
}
?>