<?php

/*
** SellaNMS
** $Id: elementviewer_template.php,v 1.6 2006/01/24 07:08:09 sella Exp $
** Copyright (c) 2001 Digital Genesis Software, LLC. All Rights Reserved.
** Released under the GPL Version 2 License.
** http://www.digitalgenesis.com
*/

require_once('../config/config.php');
require_once('../libs/dgsutil/cgi.php');
require_once('../libs/util.php');

function print_oid($oid) {
	if ($oid) {
		printf('%s', $oid);
	} else {
		printf('unknown');
	}
}

function print_down_interface_count($db, $router) {
	if ($router) {
		$sql = sprintf('SELECT count(id) AS down FROM event_target WHERE event_target.element = %d AND event_target.interface IS NOT NULL', $router);
	
		$result = mysql_query($sql, $db);
		$row = mysql_fetch_array($result);

		printf('%d', $row['down']);
	} else {
		printf('unknown');
	}
}

$data = getFormData();

$db = mysql_connect($config['databaseServer'], $config['databaseUsername'], $config['databasePassword']);
mysql_select_db($config['databaseName'], $db);

if ($data['router']) {
	$sql = sprintf('SELECT variable, value FROM element_data WHERE element = %d', $data['router']);

	$result = mysql_query($sql, $db);
	while ($row = mysql_fetch_array($result)) {
		$info[$row['variable']] = $row['value'];
	}
}

?>
	<TABLE WIDTH="100%" CELLSPACING="1" CELLPADDING="0" BORDER="0">
		<TR CLASS="tbltitle">
			<TD COLSPAN="2">Element Information: <?php print_oid($info['.1.3.6.1.2.1.1.5.0']); ?></TD>
		</TR>
		<TR CLASS="tblhdr">
			<TD NOWRAP>Name</TD>
			<TD CLASS="tblentry" WIDTH="100%" NOWRAP><?php print_oid($info['.1.3.6.1.2.1.1.5.0']); ?></TD>
		</TR>
		<TR CLASS="tblhdr">
			<TD NOWRAP>Type</TD>
			<TD CLASS="tblentry" WIDTH="100%" NOWRAP><?php print_oid($info['.1.3.6.1.2.1.1.2.0']); ?></TD>
		</TR>
		<TR CLASS="tblhdr">
			<TD NOWRAP>Contact</TD>
			<TD CLASS="tblentry" WIDTH="100%" NOWRAP><?php print_oid($info['.1.3.6.1.2.1.1.4.0']); ?></TD>
		</TR>
		<TR CLASS="tblhdr">
			<TD NOWRAP>Location</TD>
			<TD CLASS="tblentry" WIDTH="100%" NOWRAP><?php print_oid($info['.1.3.6.1.2.1.1.6.0']); ?></TD>
		</TR>
	</TABLE>
<?php

/*
** Local Variables:
** c-basic-offset: 3
** tab-width: 3
** End:
** vim:
** vim: noet ts=3 sw=3
*/

?>
