1<?php
2
3// Pandora FMS - http://pandorafms.com
4// ==================================================
5// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
6// Please see http://pandorafms.org for full contribution list
7
8// This program is free software; you can redistribute it and/or
9// modify it under the terms of the GNU General Public License
10// as published by the Free Software Foundation for version 2.
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14// GNU General Public License for more details.
15
16
17if (! isset($_SESSION['id_usuario'])) {
18	session_start();
19	//session_write_close();
20}
21
22require_once ('../../include/config.php');
23require_once ($config['homedir'] . '/include/auth/mysql.php');
24require_once ($config['homedir'] . '/include/functions.php');
25require_once ($config['homedir'] . '/include/functions_db.php');
26require_once ($config['homedir'] . '/include/functions_reporting.php');
27require_once ($config['homedir'] . '/include/functions_graph.php');
28require_once ($config['homedir'] . '/include/functions_modules.php');
29require_once ($config['homedir'] . '/include/functions_agents.php');
30require_once ($config['homedir'] . '/include/functions_tags.php');
31
32check_login ();
33
34$user_language = get_user_language ($config['id_user']);
35if (file_exists ('../../include/languages/'.$user_language.'.mo')) {
36	$l10n = new gettext_reader (new CachedFileReader ('../../include/languages/'.$user_language.'.mo'));
37	$l10n->load_tables();
38}
39
40$id = get_parameter('id');
41$label = get_parameter ("label");
42
43// TODO - Put ACL here
44?>
45<html>
46	<head>
47		<?php
48		// Parsing the refresh before sending any header
49		$refresh = (int) get_parameter ("refr", -1);
50		if ($refresh > 0) {
51			$query = ui_get_url_refresh (false);
52			echo '<meta http-equiv="refresh" content="'.$refresh.'; URL='.$query.'" />';
53		}
54		?>
55		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
56		<title>Pandora FMS Snapshot data view for module (<?php echo $label; ?>)</title>
57		<script type='text/javascript' src='../../include/javascript/jquery-1.7.1.js'></script>
58	</head>
59	<body style='background:#000; color: #ccc;'>
60		<?php
61		$row = db_get_row_sql("SELECT *
62			FROM tagente_estado
63			WHERE id_agente_modulo = $id");
64
65		echo "<h2 id='title_snapshot_view'>";
66		echo __("Current data at");
67		echo " ";
68		echo $row["timestamp"];
69		echo "</h2>";
70		$datos = io_safe_output($row["datos"]);
71		$datos = preg_replace ('/\n/i','<br>',$datos);
72		$datos =  preg_replace ('/\s/i','&nbsp;',$datos);
73		echo "<div id='result_div' style='width: 100%; height: 100%; overflow: scroll; padding: 10px; font-size: 14px; line-height: 16px; font-family: mono,monospace; text-align: left'>";
74		echo $datos;
75		echo "</div>";
76		?>
77		<script type="text/javascript">
78			function getScrollbarWidth() {
79				var div = $('<div style="width:50px;height:50px;overflow:hidden;position:absolute;top:-200px;left:-200px;"><div style="height:100px;"></div></div>');
80				$('body').append(div);
81				var w1 = $('div', div).innerWidth();
82				div.css('overflow-y', 'auto');
83				var w2 = $('div', div).innerWidth();
84				$(div).remove();
85
86				return (w1 - w2);
87			}
88
89			$(document).ready(function() {
90				width = $("#result_div").css("width");
91				width = width.replace("px", "");
92				width = parseInt(width);
93				$("#result_div").css("width", (width - getScrollbarWidth()) + "px");
94
95				height = $("#result_div").css("height");
96				height = height.replace("px", "");
97				height = parseInt(height);
98				$("#result_div").css("height", (height - getScrollbarWidth() - $("#title_snapshot_view").height() - 16) + "px");
99			});
100		</script>
101	</body>
102</html>