From 2cb1563f63386b35a69e460051aa9b4a2851d104 Mon Sep 17 00:00:00 2001
From: ftimme <ft@falkotimme.com>
Date: Wed, 30 May 2012 07:30:44 -0400
Subject: [PATCH] - Added (clickable) placeholders to client messaging function. - Added check so that the client password isn't inserted into the message (for security reasons).

---
 interface/web/monitor/show_sys_state.php |  101 ++++++++++++++++++++++++++++----------------------
 1 files changed, 57 insertions(+), 44 deletions(-)

diff --git a/interface/web/monitor/show_sys_state.php b/interface/web/monitor/show_sys_state.php
index ec3bf8e..634880c 100644
--- a/interface/web/monitor/show_sys_state.php
+++ b/interface/web/monitor/show_sys_state.php
@@ -69,7 +69,7 @@
 $app->tpl->setVar("state_data",$output);
 $app->tpl->setVar("state_type",$stateType);
 $app->tpl->setVar("list_head_txt",$title);
-$app->tpl->setVar("list_desc_txt",$description);
+$app->tpl->setVar("list_desc_txt",(isset($description) ? $description : ''));
 $app->tpl->setVar("monTransRefreshsq", $monTransRefreshsq);
 
 /*
@@ -196,7 +196,10 @@
 	$ispcData = null;
 	foreach($records as $record) {
 		/* get the state from the db-data */
-		_processDbState($record['type'], $serverId, &$serverState, &$messages);
+		$tmp = _processDbState($record['type'], $serverId, $serverState, $messages);
+		$serverState = $tmp['serverState'];
+		$messages = $tmp['messages'];
+		
 		/* if we have the os-info, get it */
 		if ($record['type'] == 'os_info') {
 			$osData = unserialize($record['data']);
@@ -234,7 +237,7 @@
 	/*
 	 * Info of a "normal" Server or a OpenVz-Host
 	*/
-	$html_server .= '<div class="systemmonitor-state state-' . $serverState . '">';
+	$html_server = '<div class="systemmonitor-state state-' . $serverState . '">';
 	$html_server .= '<div class="systemmonitor-device device-server">';
 	$html_server .= '<div class="systemmonitor-content icons32 ico-' . $serverState . '">';
 	$html_server .= $app->lng("monitor_serverstate_server_txt") . ': ' . $serverName;
@@ -252,11 +255,11 @@
 	}
 
 	$html_server .= $app->lng("monitor_serverstate_state_txt") . ': ' . $serverState . ' (';
-	$html_server .= sizeof($messages[$app->lng("monitor_serverstate_listunknown_txt")]) . ' ' . $app->lng("monitor_serverstate_unknown_txt") . ', ';
-	$html_server .= sizeof($messages[$app->lng("monitor_serverstate_listinfo_txt")]) . ' ' . $app->lng("monitor_serverstate_info_txt") . ', ';
-	$html_server .= sizeof($messages[$app->lng("monitor_serverstate_listwarning_txt")]) . ' ' . $app->lng("monitor_serverstate_warning_txt") . ', ';
-	$html_server .= sizeof($messages[$app->lng("monitor_serverstate_listcritical_txt")]) . ' ' . $app->lng("monitor_serverstate_critical_txt") . ', ';
-	$html_server .= sizeof($messages[$app->lng("monitor_serverstate_listerror_txt")]) . ' ' . $app->lng("monitor_serverstate_error_txt") . '';
+	$html_server .= sizeof((isset($messages[$app->lng("monitor_serverstate_listunknown_txt")]) ? $messages[$app->lng("monitor_serverstate_listunknown_txt")] : array())) . ' ' . $app->lng("monitor_serverstate_unknown_txt") . ', ';
+	$html_server .= sizeof((isset($messages[$app->lng("monitor_serverstate_listinfo_txt")]) ? $messages[$app->lng("monitor_serverstate_listinfo_txt")] : array())) . ' ' . $app->lng("monitor_serverstate_info_txt") . ', ';
+	$html_server .= sizeof((isset($messages[$app->lng("monitor_serverstate_listwarning_txt")]) ? $messages[$app->lng("monitor_serverstate_listwarning_txt")] : array())) . ' ' . $app->lng("monitor_serverstate_warning_txt") . ', ';
+	$html_server .= sizeof((isset($messages[$app->lng("monitor_serverstate_listcritical_txt")]) ? $messages[$app->lng("monitor_serverstate_listcritical_txt")] : array())) . ' ' . $app->lng("monitor_serverstate_critical_txt") . ', ';
+	$html_server .= sizeof((isset($messages[$app->lng("monitor_serverstate_listerror_txt")]) ? $messages[$app->lng("monitor_serverstate_listerror_txt")] : array())) . ' ' . $app->lng("monitor_serverstate_error_txt") . '';
 	$html_server .= ')<br />';
 
 	/*
@@ -264,13 +267,11 @@
 	*/
 	$html_verbose = $html_server;
 	foreach($messages as $key => $state) {
-		{
-			$html_verbose .= $key . ':<br />';
-			foreach ($state as $msg) {
-				$html_verbose .= $msg . '<br />';
-			}
-			$html_verbose .= '<br />';
+		$html_verbose .= $key . ':<br />';
+		foreach ($state as $msg) {
+			$html_verbose .= $msg . '<br />';
 		}
+		$html_verbose .= '<br />';
 	}
 
 	/*
@@ -299,7 +300,7 @@
 }
 
 /*
- * gets the state from the db and process it
+* gets the state from the db and process it
 */
 function _processDbState($type, $serverId, $serverState, $messages) {
 	global $app;
@@ -308,10 +309,17 @@
     * Always the NEWEST record of each monitoring is responsible for the
     * state
 	*/
-// get the State from the DB
+	// get the State from the DB
 	$record = $app->db->queryOneRecord("SELECT state FROM monitor_data WHERE type = '" . $type . "' and server_id = " . $serverId . " order by created desc");
-// change the new state to the highest state
-	$serverState = _setState($serverState, $record['state']);
+
+	// change the new state to the highest state
+	/*
+	* Monitoring the user_beancounter of a VE is not as easy as i thought, so for now ignore
+	* this state (if we have a better solution)
+	*/
+	if ($type != 'openvz_beancounter') {
+		$serverState = _setState($serverState, $record['state']);
+	}
 
 	/*
      * The message depands on the type and the state
@@ -449,32 +457,35 @@
 		}
 	}
 
-	if ($type == 'openvz_beancounter') {
-		switch ($record['state']) {
-			case 'ok':
-				$messages[$app->lng("monitor_serverstate_listok_txt")][] = $app->lng("monitor_serverstate_beancounterok_txt") . ' ' .
-						"<a href='#' onclick='loadContent(\"monitor/show_data.php?type=openvz_beancounter\");'>[" . $app->lng("monitor_serverstate_more_txt") . "]</a>";
-				break;
-			case 'info':
-				$messages[$app->lng("monitor_serverstate_listinfo_txt")][] = $app->lng("monitor_serverstate_beancounterinfo_txt") . ' ' .
-						"<a href='#' onclick='loadContent(\"monitor/show_data.php?type=openvz_beancounter\");'>[" . $app->lng("monitor_serverstate_more_txt") . "]</a>";
-				break;
-			case 'warning':
-				$messages[$app->lng("monitor_serverstate_listinfo_txt")][] = $app->lng("monitor_serverstate_beancounterwarning_txt") . ' ' .
-						"<a href='#' onclick='loadContent(\"monitor/show_data.php?type=openvz_beancounter\");'>[" . $app->lng("monitor_serverstate_more_txt") . "]</a>";
-				break;
-			case 'critical':
-				$messages[$app->lng("monitor_serverstate_listcritical_txt")][] = $app->lng("monitor_serverstate_beancountercritical_txt") . ' ' .
-						"<a href='#' onclick='loadContent(\"monitor/show_data.php?type=openvz_beancounter\");'>[" . $app->lng("monitor_serverstate_more_txt") . "]</a>";
-				break;
-			case 'error':
-				$messages[$app->lng("monitor_serverstate_listerror_txt")][] = $app->lng("monitor_serverstate_beancountererror_txt") . ' ' .
-						"<a href='#' onclick='loadContent(\"monitor/show_data.php?type=openvz_beancounter\");'>[" . $app->lng("monitor_serverstate_more_txt") . "]</a>";
-				break;
-			default:
-				break;
-		}
-	}
+	/*
+	 * ignore, until we find a better solution
+	 */
+//	if ($type == 'openvz_beancounter') {
+//		switch ($record['state']) {
+//			case 'ok':
+//				$messages[$app->lng("monitor_serverstate_listok_txt")][] = $app->lng("monitor_serverstate_beancounterok_txt") . ' ' .
+//						"<a href='#' onclick='loadContent(\"monitor/show_data.php?type=openvz_beancounter\");'>[" . $app->lng("monitor_serverstate_more_txt") . "]</a>";
+//				break;
+//			case 'info':
+//				$messages[$app->lng("monitor_serverstate_listinfo_txt")][] = $app->lng("monitor_serverstate_beancounterinfo_txt") . ' ' .
+//						"<a href='#' onclick='loadContent(\"monitor/show_data.php?type=openvz_beancounter\");'>[" . $app->lng("monitor_serverstate_more_txt") . "]</a>";
+//				break;
+//			case 'warning':
+//				$messages[$app->lng("monitor_serverstate_listinfo_txt")][] = $app->lng("monitor_serverstate_beancounterwarning_txt") . ' ' .
+//						"<a href='#' onclick='loadContent(\"monitor/show_data.php?type=openvz_beancounter\");'>[" . $app->lng("monitor_serverstate_more_txt") . "]</a>";
+//				break;
+//			case 'critical':
+//				$messages[$app->lng("monitor_serverstate_listcritical_txt")][] = $app->lng("monitor_serverstate_beancountercritical_txt") . ' ' .
+//						"<a href='#' onclick='loadContent(\"monitor/show_data.php?type=openvz_beancounter\");'>[" . $app->lng("monitor_serverstate_more_txt") . "]</a>";
+//				break;
+//			case 'error':
+//				$messages[$app->lng("monitor_serverstate_listerror_txt")][] = $app->lng("monitor_serverstate_beancountererror_txt") . ' ' .
+//						"<a href='#' onclick='loadContent(\"monitor/show_data.php?type=openvz_beancounter\");'>[" . $app->lng("monitor_serverstate_more_txt") . "]</a>";
+//				break;
+//			default:
+//				break;
+//		}
+//	}
 
 
 	if ($type == 'mailq') {
@@ -566,6 +577,8 @@
 	if ($type == 'rkhunter') {
 		/* this type has no state */
 	}
+	
+	return array('serverState' => $serverState,'messages' => $messages);
 }
 
 /*

--
Gitblit v1.9.1