2012-07-18 Miguel de Dios <miguel.dedios@artica.es>

* include/javascript/pandora.js, include/functions_agents.php,
	include/functions_db.php, include/functions_html.php,
	include/db/postgresql.php, include/db/mysql.php,
	include/db/oracle.php: cleaned source code style and killed some
	unicorns and magical numbers.
	
	* operation/agentes/stat_win.php: a lot fixes, cleaned source code
	style, added magical widget for times for refresh. And yes I fixed
	the bug with jquery that failed with new graphs.
	
	Fixes: #3520966
	
	* operation/agentes/estado_ultimopaquete.php: fixed the links to
	window graph popup, now all the links have 10 minutes for the
	refresh.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6787 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-07-18 09:34:10 +00:00
parent 0a50fbcb1d
commit 8c3d85b507
10 changed files with 582 additions and 499 deletions

View File

@ -1,3 +1,21 @@
2012-07-18 Miguel de Dios <miguel.dedios@artica.es>
* include/javascript/pandora.js, include/functions_agents.php,
include/functions_db.php, include/functions_html.php,
include/db/postgresql.php, include/db/mysql.php,
include/db/oracle.php: cleaned source code style and killed some
unicorns and magical numbers.
* operation/agentes/stat_win.php: a lot fixes, cleaned source code
style, added magical widget for times for refresh. And yes I fixed
the bug with jquery that failed with new graphs.
Fixes: #3520966
* operation/agentes/estado_ultimopaquete.php: fixed the links to
window graph popup, now all the links have 10 minutes for the
refresh.
2012-07-17 Sergio Martin <sergio.martin@artica.es> 2012-07-17 Sergio Martin <sergio.martin@artica.es>
* include/javascript/jquery.scrollTo.js: Added jquery * include/javascript/jquery.scrollTo.js: Added jquery

View File

@ -529,12 +529,12 @@ function mysql_db_format_array_where_clause_sql ($values, $join = 'AND', $prefix
$query .= sprintf ('%s IN ("%s")', $field, implode ('", "', $value)); $query .= sprintf ('%s IN ("%s")', $field, implode ('", "', $value));
} }
else { else {
if ($value[0] == ">"){ if ($value[0] == ">") {
$value = substr($value,1,strlen($value)-1); $value = substr($value,1,strlen($value)-1);
$query .= sprintf ("%s > '%s'", $field, $value); $query .= sprintf ("%s > '%s'", $field, $value);
} }
else if ($value[0] == "<"){ else if ($value[0] == "<") {
if ($value[1] == ">"){ if ($value[1] == ">") {
$value = substr($value,2,strlen($value)-2); $value = substr($value,2,strlen($value)-2);
$query .= sprintf ("%s <> '%s'", $field, $value); $query .= sprintf ("%s <> '%s'", $field, $value);
} }
@ -690,7 +690,8 @@ function mysql_db_get_all_rows_filter ($table, $filter = array(), $fields = fals
$filter = ''; $filter = '';
} }
$sql = sprintf ('SELECT %s FROM %s %s', $fields, $table, $filter); $sql = sprintf ('SELECT %s
FROM %s %s', $fields, $table, $filter);
if ($returnSQL) if ($returnSQL)
return $sql; return $sql;
@ -1045,5 +1046,4 @@ function mysql_db_get_table_count($sql, $search_history_db = false) {
return $count; return $count;
} }
?> ?>

View File

@ -593,7 +593,6 @@ function oracle_db_format_array_where_clause_sql ($values, $join = 'AND', $prefi
} }
$i++; $i++;
continue; continue;
} }
else if (is_numeric ($field)) { else if (is_numeric ($field)) {
/* User provide the exact operation to do */ /* User provide the exact operation to do */

View File

@ -570,12 +570,12 @@ function postgresql_db_format_array_where_clause_sql ($values, $join = 'AND', $p
$query .= sprintf ("%s IN ('%s')", $field, implode ("', '", $value)); $query .= sprintf ("%s IN ('%s')", $field, implode ("', '", $value));
} }
else { else {
if ($value[0] == ">"){ if ($value[0] == ">") {
$value = substr($value,1,strlen($value)-1); $value = substr($value,1,strlen($value)-1);
$query .= sprintf ("%s > '%s'", $field, $value); $query .= sprintf ("%s > '%s'", $field, $value);
} }
else if ($value[0] == "<"){ else if ($value[0] == "<") {
if ($value[1] == ">"){ if ($value[1] == ">") {
$value = substr($value,2,strlen($value)-2); $value = substr($value,2,strlen($value)-2);
$query .= sprintf ("%s <> '%s'", $field, $value); $query .= sprintf ("%s <> '%s'", $field, $value);
} }

View File

@ -1658,28 +1658,27 @@ function agents_get_status($id_agent = 0, $noACLs = false) {
} }
if (! $status) if (! $status)
return -1; return AGENT_MODULE_STATUS_UNKNOW;
} }
// Status is 0 for normal, 1 for critical, 2 for warning and 3 for unknown. 4 for alert fired // Checking if any module has alert fired
// Checking if any module has alert fired (4) if (is_int(array_search(AGENT_MODULE_STATUS_CRITICAL_ALERT, $modules_status))) {
if (is_int(array_search(4,$modules_status))) { return AGENT_MODULE_STATUS_CRITICAL_ALERT;
return 4;
} }
// Checking if any module has critical status (1) // Checking if any module has critical status
elseif (is_int(array_search(1,$modules_status))) { elseif (is_int(array_search(AGENT_MODULE_STATUS_CRITICAL_BAD, $modules_status))) {
return 1; return AGENT_MODULE_STATUS_CRITICAL_BAD;
} }
// Checking if any module has warning status (2) // Checking if any module has warning status
elseif (is_int(array_search(2,$modules_status))) { elseif (is_int(array_search(AGENT_MODULE_STATUS_WARNING,$modules_status))) {
return 2; return AGENT_MODULE_STATUS_WARNING;
} }
// Checking if any module has unknown status (3) // Checking if any module has unknown status
elseif (is_int(array_search(3,$modules_status))) { elseif (is_int(array_search(AGENT_MODULE_STATUS_UNKNOW, $modules_status))) {
return 3; return AGENT_MODULE_STATUS_UNKNOW;
} }
else { else {
return 0; return AGENT_MODULE_STATUS_NORMAL;
} }
} }

View File

@ -843,7 +843,8 @@ function db_process_delete_temp ($table, $row, $value) {
$result = db_process_sql_delete ($table, $row.' = '.$value); $result = db_process_sql_delete ($table, $row.' = '.$value);
break; break;
case "oracle": case "oracle":
if (is_int ($value) || is_bool ($value) || is_float ($value) || is_double ($value)) { if (is_int ($value) || is_bool ($value) ||
is_float ($value) || is_double ($value)) {
$result = oracle_db_process_sql_delete_temp ($table, $row . ' = ' . $value); $result = oracle_db_process_sql_delete_temp ($table, $row . ' = ' . $value);
} }
else { else {
@ -1152,6 +1153,4 @@ function db_get_table_count($table, $search_history_db = false) {
break; break;
} }
} }
?> ?>

View File

@ -220,7 +220,7 @@ function html_print_select_groups($id_user = false, $privilege = "AR", $returnAl
unset($user_groups[$id_group]); unset($user_groups[$id_group]);
} }
if(empty($user_groups)) { if (empty($user_groups)) {
$user_groups_tree = array(); $user_groups_tree = array();
} }
else { else {
@ -266,8 +266,10 @@ function html_print_select_groups($id_user = false, $privilege = "AR", $returnAl
* *
* @return string HTML code if return parameter is true. * @return string HTML code if return parameter is true.
*/ */
function html_print_select ($fields, $name, $selected = '', $script = '', $nothing = '', $nothing_value = 0, $return = false, function html_print_select ($fields, $name, $selected = '', $script = '',
$multiple = false, $sort = true, $class = '', $disabled = false, $style = false, $option_style = false, $size = false) { $nothing = '', $nothing_value = 0, $return = false, $multiple = false,
$sort = true, $class = '', $disabled = false, $style = false,
$option_style = false, $size = false) {
$output = "\n"; $output = "\n";
@ -331,8 +333,8 @@ function html_print_select ($fields, $name, $selected = '', $script = '', $nothi
$optlabel = $label; $optlabel = $label;
if(is_array($label)) { if(is_array($label)) {
if (isset($label['optgroup'])) { if (isset($label['optgroup'])) {
if($label['optgroup'] != $lastopttype) { if ($label['optgroup'] != $lastopttype) {
if($lastopttype != '') { if ($lastopttype != '') {
$output .= '</optgroup>'; $output .= '</optgroup>';
} }
$output .= '<optgroup label="'.$label['optgroup'].'">'; $output .= '<optgroup label="'.$label['optgroup'].'">';
@ -346,7 +348,8 @@ function html_print_select ($fields, $name, $selected = '', $script = '', $nothi
if (is_array ($selected) && in_array ($value, $selected)) { if (is_array ($selected) && in_array ($value, $selected)) {
$output .= ' selected="selected"'; $output .= ' selected="selected"';
} }
elseif (is_numeric ($value) && is_numeric ($selected) && $value == $selected) { elseif (is_numeric ($value) && is_numeric ($selected) &&
$value == $selected) {
//This fixes string ($value) to int ($selected) comparisons //This fixes string ($value) to int ($selected) comparisons
$output .= ' selected="selected"'; $output .= ' selected="selected"';
} }
@ -354,7 +357,8 @@ function html_print_select ($fields, $name, $selected = '', $script = '', $nothi
//Needs type comparison otherwise if $selected = 0 and $value = "string" this would evaluate to true //Needs type comparison otherwise if $selected = 0 and $value = "string" this would evaluate to true
$output .= ' selected="selected"'; $output .= ' selected="selected"';
} }
if (is_array ($option_style) && in_array ($value, array_keys($option_style))) { if (is_array ($option_style) &&
in_array ($value, array_keys($option_style))) {
$output .= ' style="'.$option_style[$value].'"'; $output .= ' style="'.$option_style[$value].'"';
} }
if ($optlabel === '') { if ($optlabel === '') {
@ -364,7 +368,7 @@ function html_print_select ($fields, $name, $selected = '', $script = '', $nothi
$output .= '>'.$optlabel."</option>"; $output .= '>'.$optlabel."</option>";
} }
} }
if(is_array($label)){ if (is_array($label)) {
$output .= '</optgroup>'; $output .= '</optgroup>';
} }
} }
@ -455,7 +459,7 @@ function html_print_extended_select_for_time ($name, $selected = '', $script = '
SECONDS_1MONTH => __('months'), SECONDS_1MONTH => __('months'),
SECONDS_1YEAR => __('years')); SECONDS_1YEAR => __('years'));
if($unique_name === true) { if ($unique_name === true) {
$uniq_name = uniqid($name); $uniq_name = uniqid($name);
} }
else { else {
@ -527,10 +531,13 @@ function html_print_input_text_extended ($name, $value, $id, $alt, $size, $maxle
++$idcounter; ++$idcounter;
$valid_attrs = array ("accept", "disabled", "maxlength", "name", "readonly", "size", "value", $valid_attrs = array ("accept", "disabled", "maxlength",
"accesskey", "class", "dir", "id", "lang", "style", "tabindex", "title", "xml:lang", "name", "readonly", "size", "value", "accesskey",
"onfocus", "onblur", "onselect", "onchange", "onclick", "ondblclick", "onmousedown", "class", "dir", "id", "lang", "style", "tabindex",
"onmouseup", "onmouseover", "onmousemove", "onmouseout", "onkeypress", "onkeydown", "onkeyup"); "title", "xml:lang", "onfocus", "onblur", "onselect",
"onchange", "onclick", "ondblclick", "onmousedown",
"onmouseup", "onmouseover", "onmousemove", "onmouseout",
"onkeypress", "onkeydown", "onkeyup");
$output = '<input '.($password ? 'type="password" ' : 'type="text" '); $output = '<input '.($password ? 'type="password" ' : 'type="text" ');
@ -680,9 +687,10 @@ function html_print_input_image ($name, $src, $value, $style = '', $return = fal
$output = '<input id="image-'.$name.$idcounter.'" src="'.$src.'" style="'.$style.'" name="'.$name.'" type="image"'; $output = '<input id="image-'.$name.$idcounter.'" src="'.$src.'" style="'.$style.'" name="'.$name.'" type="image"';
//Valid attributes (invalid attributes get skipped) //Valid attributes (invalid attributes get skipped)
$attrs = array ("alt", "accesskey", "lang", "tabindex", "title", "xml:lang", $attrs = array ("alt", "accesskey", "lang", "tabindex",
"onclick", "ondblclick", "onmousedown", "onmouseup", "onmouseover", "onmousemove", "title", "xml:lang", "onclick", "ondblclick", "onmousedown",
"onmouseout", "onkeypress", "onkeydown", "onkeyup"); "onmouseup", "onmouseover", "onmousemove", "onmouseout",
"onkeypress", "onkeydown", "onkeyup");
foreach ($attrs as $attribute) { foreach ($attrs as $attribute) {
if (isset ($options[$attribute])) { if (isset ($options[$attribute])) {
@ -816,6 +824,7 @@ function html_print_textarea ($name, $rows, $columns, $value = '', $attributes =
if ($return) if ($return)
return $output; return $output;
echo $output; echo $output;
} }
@ -861,7 +870,8 @@ function html_print_table (&$table, $return = false) {
foreach ($table->align as $key => $aa) { foreach ($table->align as $key => $aa) {
if ($aa) { if ($aa) {
$align[$key] = ' text-align:'. $aa.';'; $align[$key] = ' text-align:'. $aa.';';
} else { }
else {
$align[$key] = ''; $align[$key] = '';
} }
} }
@ -879,7 +889,8 @@ function html_print_table (&$table, $return = false) {
foreach ($table->size as $key => $ss) { foreach ($table->size as $key => $ss) {
if ($ss) { if ($ss) {
$size[$key] = ' width:'. $ss .';'; $size[$key] = ' width:'. $ss .';';
} else { }
else {
$size[$key] = ''; $size[$key] = '';
} }
} }
@ -888,7 +899,8 @@ function html_print_table (&$table, $return = false) {
foreach ($table->style as $key => $st) { foreach ($table->style as $key => $st) {
if ($st) { if ($st) {
$style[$key] = ' '. $st .';'; $style[$key] = ' '. $st .';';
} else { }
else {
$style[$key] = ''; $style[$key] = '';
} }
} }
@ -934,7 +946,8 @@ function html_print_table (&$table, $return = false) {
if (empty ($table->tablealign) || $table->tablealign != 'left' || $table->tablealign != 'right') { if (empty ($table->tablealign) || $table->tablealign != 'left' || $table->tablealign != 'right') {
$table->tablealign = ''; $table->tablealign = '';
} else { }
else {
$table->tablealign = 'style="float:'.$table->tablealign.';"'; //Align is deprecated. Use float instead $table->tablealign = 'style="float:'.$table->tablealign.';"'; //Align is deprecated. Use float instead
} }
@ -1150,7 +1163,8 @@ function html_print_checkbox_extended ($name, $value, $checked, $disabled, $scri
//If duplicate names exist, it will start numbering. Otherwise it won't //If duplicate names exist, it will start numbering. Otherwise it won't
if (isset ($idcounter[$name])) { if (isset ($idcounter[$name])) {
$idcounter[$name]++; $idcounter[$name]++;
} else { }
else {
$idcounter[$name] = 0; $idcounter[$name] = 0;
} }

View File

@ -462,18 +462,18 @@ foreach ($modules as $module) {
$graph_label = io_safe_output($module["nombre"]); $graph_label = io_safe_output($module["nombre"]);
echo "<a href='javascript:" . echo "<a href='javascript:" .
"winopeng(\"operation/agentes/stat_win.php?type=$graph_type&period=" . (28 * SECONDS_1DAY) . "&id=".$module["id_agente_modulo"]."&label=".base64_encode($graph_label)."&refresh=180000\", \"month_".$win_handle."\")'>" . html_print_image('images/grafica_m.png' , true, array("border" => '0', "alt" => '')) . "</a>&nbsp;"; "winopeng(\"operation/agentes/stat_win.php?type=$graph_type&period=" . SECONDS_1MONTH . "&id=".$module["id_agente_modulo"]."&label=".base64_encode($graph_label)."&refresh=" . SECONDS_10MINUTES . "\", \"month_".$win_handle."\")'>" . html_print_image('images/grafica_m.png' , true, array("border" => '0', "alt" => '')) . "</a>&nbsp;";
$link ="winopeng(" . $link ="winopeng(" .
"'operation/agentes/stat_win.php?type=$graph_type&period=" . SECONDS_1WEEK . "&id=".$module["id_agente_modulo"]."&label=".base64_encode($graph_label)."&refresh=6000','week_".$win_handle."')"; "'operation/agentes/stat_win.php?type=$graph_type&period=" . SECONDS_1WEEK . "&id=".$module["id_agente_modulo"]."&label=".base64_encode($graph_label)."&refresh=" . SECONDS_10MINUTES . "','week_".$win_handle."')";
echo '<a href="javascript:'.$link.'">' . html_print_image("images/grafica_w.png", true, array("border" => '0', "alt" => '')) . '</a>&nbsp;'; echo '<a href="javascript:'.$link.'">' . html_print_image("images/grafica_w.png", true, array("border" => '0', "alt" => '')) . '</a>&nbsp;';
$link ="winopeng(" . $link ="winopeng(" .
"'operation/agentes/stat_win.php?type=$graph_type&period=" . SECONDS_1DAY . "&id=".$module["id_agente_modulo"]."&label=".base64_encode($graph_label)."&refresh=600','day_".$win_handle."')"; "'operation/agentes/stat_win.php?type=$graph_type&period=" . SECONDS_1DAY . "&id=".$module["id_agente_modulo"]."&label=".base64_encode($graph_label)."&refresh=" . SECONDS_10MINUTES . "','day_".$win_handle."')";
echo '<a href="javascript:'.$link.'">' . html_print_image("images/grafica_d.png", true, array("border" => '0', "alt" => '')) . '</a>&nbsp;'; echo '<a href="javascript:'.$link.'">' . html_print_image("images/grafica_d.png", true, array("border" => '0', "alt" => '')) . '</a>&nbsp;';
$link ="winopeng(" . $link ="winopeng(" .
"'operation/agentes/stat_win.php?type=$graph_type&period=" . SECONDS_1HOUR . "&id=".$module["id_agente_modulo"]."&label=".base64_encode($graph_label)."&refresh=60','hour_".$win_handle."')"; "'operation/agentes/stat_win.php?type=$graph_type&period=" . SECONDS_1HOUR . "&id=".$module["id_agente_modulo"]."&label=".base64_encode($graph_label)."&refresh=" . SECONDS_10MINUTES . "','hour_".$win_handle."')";
echo '<a href="javascript:'.$link.'">' . html_print_image("images/grafica_h.png", true, array("border" => '0', "alt" => "")) . '</a>'; echo '<a href="javascript:'.$link.'">' . html_print_image("images/grafica_h.png", true, array("border" => '0', "alt" => "")) . '</a>';
} }

View File

@ -43,34 +43,35 @@ $label = base64_decode(get_parameter('label', ''));
?> ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<?php <?php
// Parsing the refresh before sending any header // Parsing the refresh before sending any header
$refresh = (int) get_parameter ("refresh", -1); $refresh = (int) get_parameter ("refresh", -1);
if ($refresh > 0) { if ($refresh > 0) {
$query = ui_get_url_refresh (false); $query = ui_get_url_refresh (false);
echo '<meta http-equiv="refresh" content="'.$refresh.'; URL='.$query.'" />'; echo '<meta http-equiv="refresh" content="'.$refresh.'; URL='.$query.'" />';
} }
?> ?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Pandora FMS Graph (<?php echo modules_get_agentmodule_agent_name ($id) . ' - ' . $label; ?>)</title> <title>Pandora FMS Graph (<?php echo modules_get_agentmodule_agent_name ($id) . ' - ' . $label; ?>)</title>
<link rel="stylesheet" href="../../include/styles/pandora_minimal.css" type="text/css" /> <link rel="stylesheet" href="../../include/styles/pandora_minimal.css" type="text/css" />
<script type='text/javaScript' src='../../include/javascript/calendar.js'></script> <script type='text/javaScript' src='../../include/javascript/calendar.js'></script>
<script type='text/javascript' src='../../include/javascript/x_core.js'></script> <script type='text/javascript' src='../../include/javascript/x_core.js'></script>
<script type='text/javascript' src='../../include/javascript/x_event.js'></script> <script type='text/javascript' src='../../include/javascript/x_event.js'></script>
<script type='text/javascript' src='../../include/javascript/x_slide.js'></script> <script type='text/javascript' src='../../include/javascript/x_slide.js'></script>
<script type='text/javascript' src='../../include/javascript/pandora.js'></script> <script type='text/javascript' src='../../include/javascript/pandora.js'></script>
<script type='text/javascript' src='../../include/javascript/jquery.js'></script> <script type='text/javascript' src='../../include/javascript/jquery-1.7.1.js'></script>
<script type='text/javascript'><!-- <script type='text/javascript'>
var defOffset = 2; <!--
var defSlideTime = 220; var defOffset = 2;
var tnActive = 0; var defSlideTime = 220;
var visibleMargin = 45; var tnActive = 0;
var menuW = 400; var visibleMargin = 45;
var menuH = 310; var menuW = 400;
var showed = 0; var menuH = 310;
window.onload = function() { var showed = 0;
window.onload = function() {
var d; var d;
d = xGetElementById('divmenu'); d = xGetElementById('divmenu');
d.termNumber = 1; d.termNumber = 1;
@ -98,16 +99,13 @@ window.onload = function() {
$("#graph_menu_arrow").attr("src", <?php echo '"' . $config['homeurl'] . '"'; ?> + "/images/graphmenu_arrow.png"); $("#graph_menu_arrow").attr("src", <?php echo '"' . $config['homeurl'] . '"'; ?> + "/images/graphmenu_arrow.png");
} }
}); });
};
}; function docOnMousemoveIn(evt) {
function docOnMousemoveIn(evt) {
var e = new xEvent(evt); var e = new xEvent(evt);
var d = getTermEle(e.target); var d = getTermEle(e.target);
// if (!tnActive) { // no def is active // mouse is over a term, activate its def
// if (d) { // mouse is over a term, activate its def
if (showed == 0) { if (showed == 0) {
xSlideTo('divmenu', 0, xPageY(d), defSlideTime); xSlideTo('divmenu', 0, xPageY(d), defSlideTime);
showed = 1; showed = 1;
@ -116,11 +114,9 @@ function docOnMousemoveIn(evt) {
xSlideTo('divmenu', visibleMargin - menuW, xPageY(d), defSlideTime); xSlideTo('divmenu', visibleMargin - menuW, xPageY(d), defSlideTime);
showed = 0; showed = 0;
} }
// } }
// }
}
function docOnMousemove(evt) { function docOnMousemove(evt) {
var e = new xEvent(evt); var e = new xEvent(evt);
var d = getTermEle(e.target); var d = getTermEle(e.target);
if (!tnActive) { // no def is active if (!tnActive) { // no def is active
@ -135,85 +131,87 @@ function docOnMousemove(evt) {
tnActive = 0; tnActive = 0;
} }
} }
} }
function getTermEle(ele) { function getTermEle(ele) {
//window.status = ele; //window.status = ele;
while(ele && !ele.termNumber) { while(ele && !ele.termNumber) {
if (ele == document) return null; if (ele == document) return null;
ele = xParent(ele); ele = xParent(ele);
} }
return ele; return ele;
} }
function show_others() { function show_others() {
if (!$("#checkbox-avg_only").attr('checked')) { if (!$("#checkbox-avg_only").attr('checked')) {
$("#hidden-show_other").val(1); $("#hidden-show_other").val(1);
} }
else { else {
$("#hidden-show_other").val(0); $("#hidden-show_other").val(0);
} }
} }
//--> //-->
</script> </script>
</head> </head>
<body bgcolor="#ffffff" style='background:#ffffff;'> <body bgcolor="#ffffff" style='background:#ffffff;'>
<?php <?php
// Get input parameters // Get input parameters
$label = get_parameter ("label",""); $label = get_parameter ("label","");
if (!isset($_GET["period"]) OR (!isset($_GET["id"]))) { if (!isset($_GET["period"]) OR (!isset($_GET["id"]))) {
echo "<h3 class='error'>".__('There was a problem locating the source of the graph')."</h3>"; echo "<h3 class='error'>" .
__('There was a problem locating the source of the graph') .
"</h3>";
exit; exit;
} }
$period = get_parameter ( "period", SECONDS_1HOUR); $period = get_parameter ( "period", SECONDS_1HOUR);
$draw_alerts = get_parameter("draw_alerts", 0); $draw_alerts = get_parameter("draw_alerts", 0);
$avg_only = get_parameter ("avg_only", 1); $avg_only = get_parameter ("avg_only", 1);
$show_other = (bool)get_parameter('show_other', false); $show_other = (bool)get_parameter('show_other', false);
if ($show_other) { if ($show_other) {
$avg_only = 0; $avg_only = 0;
} }
$period = get_parameter ("period", 86400); $period = get_parameter ("period", 86400);
$id = get_parameter ("id", 0); $id = get_parameter ("id", 0);
$width = get_parameter ("width", 555); $width = get_parameter ("width", 555);
$height = get_parameter ("height", 245); $height = get_parameter ("height", 245);
$label = get_parameter ("label", ""); $label = get_parameter ("label", "");
$start_date = get_parameter ("start_date", date("Y-m-d")); $start_date = get_parameter ("start_date", date("Y-m-d"));
$draw_events = get_parameter ("draw_events", 0); $draw_events = get_parameter ("draw_events", 0);
$graph_type = get_parameter ("type", "sparse"); $graph_type = get_parameter ("type", "sparse");
$zoom = get_parameter ("zoom", 1); $zoom = get_parameter ("zoom", 1);
$baseline = get_parameter ("baseline", 0); $baseline = get_parameter ("baseline", 0);
$show_events_graph = get_parameter ("show_events_graph", 0); $show_events_graph = get_parameter ("show_events_graph", 0);
if ($zoom > 1) { if ($zoom > 1) {
$height = $height * ($zoom / 2.1); $height = $height * ($zoom / 2.1);
$width = $width * ($zoom / 1.4); $width = $width * ($zoom / 1.4);
echo "<script type='text/javascript'>window.resizeTo($width + 80, $height + 120);</script>"; echo "<script type='text/javascript'>window.resizeTo($width + 80, $height + 120);</script>";
} }
$utime = get_system_time (); $utime = get_system_time ();
$current = date("Y-m-d", $utime); $current = date("Y-m-d", $utime);
if ($start_date != $current) if ($start_date != $current)
$date = strtotime($start_date); $date = strtotime($start_date);
else else
$date = $utime; $date = $utime;
$urlImage = 'http://'; $urlImage = 'http://';
if ($config['https']) { if ($config['https']) {
$urlImage = 'https://'; $urlImage = 'https://';
} }
$urlImage .= $_SERVER['SERVER_NAME'] . $config['homeurl'] . '/'; $urlImage .= $_SERVER['SERVER_NAME'] . $config['homeurl'] . '/';
// log4x doesnt support flash yet // log4x doesnt support flash yet
// //
if ($config['flash_charts'] == 1) if ($config['flash_charts'] == 1)
echo '<div style="margin-left: 70px">'; echo '<div style="margin-left: 70px">';
else else
echo '<div style="margin-left: 50px">'; echo '<div style="margin-left: 50px">';
switch ($graph_type) { switch ($graph_type) {
case 'boolean': case 'boolean':
echo grafico_modulo_boolean ($id, $period, $draw_events, $width, $height, echo grafico_modulo_boolean ($id, $period, $draw_events, $width, $height,
$label, null, $draw_alerts, $avg_only, false, $date, false, $urlImage, 'adapter_'.$graph_type); $label, null, $draw_alerts, $avg_only, false, $date, false, $urlImage, 'adapter_'.$graph_type);
@ -246,75 +244,131 @@ switch ($graph_type) {
default: default:
echo fs_error_image ('../images'); echo fs_error_image ('../images');
break; break;
} }
echo '</div>'; echo '</div>';
//z-index is 1 because 2 made the calendar show under the divmenu. //z-index is 1 because 2 made the calendar show under the divmenu.
echo '<div id="divmenu" class="menu" style="z-index:1; height: 98%;"><b>'.__('Pandora FMS Graph configuration menu').'</b><br /><br />'.__('Please, make your changes and apply with the <i>Reload</i> button'); ?>
echo '<div style="float: left">'; <div id="divmenu" class="menu" style="z-index:1; height: 98%;">
echo '<form method="get" action="stat_win.php">'; <b> <?php echo __('Pandora FMS Graph configuration menu');?></b>
html_print_input_hidden ("id", $id); <br />
html_print_input_hidden ("label", $label); <br />
<?php
echo __('Please, make your changes and apply with the <i>Reload</i> button');
?>
<div style="float: left; width: 80%;">
<form method="get" action="stat_win.php">
<?php
html_print_input_hidden ("id", $id);
html_print_input_hidden ("label", $label);
if (isset($_GET["type"])) { if (isset($_GET["type"])) {
$type = get_parameter_get ("type"); $type = get_parameter_get ("type");
html_print_input_hidden ("type", $type); html_print_input_hidden ("type", $type);
} }
echo '<table class="databox_frame" cellspacing="5">'; ?>
echo '<tr><td>'.__('Refresh time').'</td><td colspan="2">'; <table class="databox_frame" cellspacing="5" width="100%">
<tr>
html_print_input_text ("refresh", $refresh, '', 5); <td><?php echo __('Refresh time');?></td>
<td>
echo '&nbsp;&nbsp;&nbsp;'.__('Avg. Only'); <?php
html_print_extended_select_for_time(
html_print_checkbox ("avg_only", 1, (bool) $avg_only, false, false, 'show_others()'); "refresh", $refresh, '', '', 0, 7);
html_print_input_hidden('show_other', 0); ?>
</td>
echo '<tr><td>'.__('Begin date').'</td><td>'; </tr>
<tr>
html_print_input_text ("start_date", substr ($start_date, 0, 10),'', 10); <td><?php echo __('Avg. Only'); ?></td>
html_print_image ("images/calendar_view_day.png", false, array ("onclick" => "scwShow(scwID('text-start_date'),this);")); <td>
<?php
echo '</td></tr><tr><td>'.__('Zoom factor').'</td>'; html_print_checkbox ("avg_only", 1, (bool) $avg_only, false, false, 'show_others()');
echo '<td>'; html_print_input_hidden('show_other', 0);
?>
$options = array (); </td>
$options[$zoom] = 'x'.$zoom; </tr>
$options[1] = 'x1'; <tr>
$options[2] = 'x2'; <td><?php echo __('Begin date'); ?></td>
$options[3] = 'x3'; <td>
$options[4] = 'x4'; <?php
html_print_input_text ("start_date", substr ($start_date, 0, 10),'', 10);
html_print_select ($options, "zoom", $zoom); html_print_image ("images/calendar_view_day.png", false, array ("onclick" => "scwShow(scwID('text-start_date'),this);"));
?>
echo '</td></tr><tr><td>'.__('Time range').'</td><td>'; </td>
</tr>
html_print_extended_select_for_time('period', $period, '', '', 0, 7); <tr>
<td><?php echo __('Zoom factor');?></td>
echo '</td></tr><tr><td>'.__('Show events').'</td><td>'; <td>
<?php
html_print_checkbox ("draw_events", 1, (bool) $draw_events); $options = array ();
$options[$zoom] = 'x'.$zoom;
echo '</td></tr><tr><td>'.__('Show alerts').'</td><td>'; $options[1] = 'x1';
$options[2] = 'x2';
html_print_checkbox ("draw_alerts", 1, (bool) $draw_alerts); $options[3] = 'x3';
$options[4] = 'x4';
if ($config['enterprise_installed'] && $graph_type == "sparse") { html_print_select ($options, "zoom", $zoom);
echo '</td></tr><tr><td>'.__('Draw baseline').'</td><td>'; ?>
</td>
</tr>
<tr>
<td><?php echo __('Time range'); ?></td>
<td>
<?php
html_print_extended_select_for_time('period',
$period, '', '', 0, 7);
?>
</td>
</tr>
<tr>
<td><?php echo __('Show events');?></td>
<td>
<?php
html_print_checkbox ("draw_events", 1, (bool) $draw_events);
?>
</td>
</tr>
<tr>
<td><?php echo __('Show alerts');?></td>
<td>
<?php
html_print_checkbox ("draw_alerts", 1, (bool) $draw_alerts);
?>
</td>
</tr>
<?php
if ($config['enterprise_installed'] && $graph_type == "sparse") {
echo '<tr>';
echo '<td>' . __('Draw baseline') . '</td>';
echo '<td>';
html_print_checkbox ("baseline", 1, (bool) $baseline); html_print_checkbox ("baseline", 1, (bool) $baseline);
} echo '</td>';
echo '</tr>';
echo '</td><td>'; }
?>
echo '</td></tr><tr><td>'.__('Show event graph').'</td><td>'; <tr>
html_print_checkbox ("show_events_graph", 1, (bool) $show_events_graph); <td><?php echo __('Show event graph');?></td>
<td>
echo '</td></tr>'; <?php
echo '<tr><td></td><td style="text-align: right">'; html_print_checkbox ("show_events_graph",
1, (bool) $show_events_graph);
html_print_submit_button (__('Reload'), "submit", false, 'class="sub next"'); ?>
</td>
echo '</td></tr></table></form></div><div id="show_menu" style="position: relative; border:1px solid #FFF; float: right; height: 50px; width: 50px;">' . html_print_image("images/graphmenu_arrow.png", true, array('id' => 'graph_menu_arrow')) . '<div></div></body></html>'; </tr>
?> <tr>
</body> <td></td>
<td style="text-align: right">
<?php
html_print_submit_button (__('Reload'), "submit", false, 'class="sub next"');
?>
</td>
</tr>
</table>
</form>
</div>
<div id="show_menu" style="position: relative; border:1px solid #FFF; float: right; height: 50px; width: 50px;">
<?php
html_print_image("images/graphmenu_arrow.png", false, array('id' => 'graph_menu_arrow'));
?>
<div>
</div>
</body>
</html> </html>