<?php

/*
** SellaNMS
** $Id: traps.php,v 1.9 2005/03/31 18:57:12 sella Exp $
** Copyright (c) 2001 Digital Genesis Software, LLC. All Rights Reserved.
** Released under the GPL Version 2 License.
** http://www.digitalgenesis.com
*/

class Traps extends Module {
	function getContent($tabs) {
		global $lang;

		$file_name = sprintf("sella_nms-%s.%s", get_class($this), $this->cache_ext);

		for ($i = 0; $i < $tabs; $i++) {
			$indent .= "\t";
		}

		$content = "";

		$content .= sprintf("%s<TABLE WIDTH=\"100%%\" CELLSPACING=\"1\" CELLPADDING=\"0\" BORDER=\"0\">\n", $indent);
		$content .= sprintf("%s\t<TR>\n", $indent);
		$content .= sprintf("%s\t\t<TD COLSPAN=\"3\">\n", $indent);
		$content .= sprintf("%s\t\t\t%s\n", $indent, $lang['Received Network Traps']);
		$content .= sprintf("%s\t\t</TD>\n", $indent);
		$content .= sprintf("%s\t</TR>\n", $indent);
		$content .= sprintf("%s\t<TR>\n", $indent);
		$content .= sprintf("%s\t\t<TD>\n", $indent);
		$content .= sprintf("%s\t\t\t%s\n", $indent, $lang['Timestamp']);
		$content .= sprintf("%s\t\t</TD>\n", $indent);
		$content .= sprintf("%s\t\t<TD>\n", $indent);
		$content .= sprintf("%s\t\t\t%s\n", $indent, $lang['Element']);
		$content .= sprintf("%s\t\t</TD>\n", $indent);
		$content .= sprintf("%s\t\t<TD WIDTH=\"100%%\">\n", $indent);
		$content .= sprintf("%s\t\t\t%s\n", $indent, $lang['Description']);
		$content .= sprintf("%s\t\t</TD>\n", $indent);
		$content .= sprintf("%s\t</TR>\n", $indent);

		$traps = $this->getNetworkTraps();
		while(list($i, ) = each($traps)) {
			$content .= sprintf("%s\t<TR>\n", $indent);
			$content .= sprintf("%s\t\t<TD>\n", $indent);
			$content .= sprintf("%s\t\t\t%s\n", $indent, "Now");
			$content .= sprintf("%s\t\t</TD>\n", $indent);

			if ($elements[$i]['element']) {
				$content .= sprintf("%s\t\t<TD>\n", $indent);
				$content .= sprintf("%s\t\t\t%s\n", $indent, $traps[$i]['timestamp']);
				$content .= sprintf("%s\t\t</TD>\n", $indent);
				$content .= sprintf("%s\t\t<TD>\n", $indent);
				$content .= sprintf("%s\t\t\t%s\n", $indent, $traps[$i]['element']);
			} else {
				$content .= sprintf("%s\t\t<TD COLSPAN=\"2\">\n", $indent);
				$content .= sprintf("%s\t\t\t%s\n", $indent, $traps[$i]['description']);
			}
			$content .= sprintf("%s\t\t</TD>\n", $indent);
			$content .= sprintf("%s\t</TR>\n", $indent);
		}

		unset($traps);	

		$content .= sprintf("%s</TABLE>\n", $indent);

		return $content;
	}

	function shouldUpdate() {
		global $config;

		$module_name = get_class($this);

		global ${$module_name};
		$last_execution = time() - ${$module_name}['last_execution'];
		if (!$last_execution) {
			return true;
		}

		return false;
	}

	function getNetworkTraps() {
		global $config;

		$ret_val = array();

		return $ret_val;
	}
}

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

?>
