diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 1b512c5625..ffd135a543 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2014-05-23 Vanessa Gil + + * include/functions_forecast.php: Fixed division by zero. + + * operation/visual_console/public_console.php: Fixed link + to public visual console. + 2014-05-22 Sergio Martin * include/functions_graph.php: Fix end of unknown diff --git a/pandora_console/include/functions_forecast.php b/pandora_console/include/functions_forecast.php index 9394526b3d..0b8c2f4cce 100644 --- a/pandora_console/include/functions_forecast.php +++ b/pandora_console/include/functions_forecast.php @@ -116,18 +116,31 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe // 3.2 Standard deviation for Y: sqrt((Sum(Yi²)/Obs) - (avg Y)²) // Linear correlation coefficient: - $avg_x = $cont/$sum_xi; + if ($sum_xi != 0) { + $avg_x = $cont/$sum_xi; + } else { + $avg_x = 0; + } if ($sum_yi != 0) $avg_y = $cont/$sum_yi; else $avg_y = 0; - $covariance = $sum_xi_yi/$cont; - $dev_x = sqrt(($sum_xi2/$cont) - ($avg_x*$avg_x)); - $dev_y = sqrt(($sum_yi2/$cont) - ($avg_y*$avg_y)); + +/* + if ($cont != 0) { + $covariance = $sum_xi_yi/$cont; + $dev_x = sqrt(($sum_xi2/$cont) - ($avg_x*$avg_x)); + $dev_y = sqrt(($sum_yi2/$cont) - ($avg_y*$avg_y)); + } else { + $covariance = 0; + $dev_x = 0; + $dev_y = 0; + } // Prevents division by zero if ($dev_x != 0 and $dev_y != 0) { $linear_coef = $covariance / ($dev_x * $dev_y); } +*/ // Agent interval could be zero, 300 is the predefined if ($sum_obs == 0) { $agent_interval = SECONDS_5MINUTES; @@ -159,7 +172,12 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe $b = $b_num / $b_den; $a_num = ($sum_yi) - ($b * $sum_xi); - $a = $a_num / $cont; + + if ($cont != 0) { + $a = $a_num / $cont; + } else { + $a = 0; + } // Data inicialization $output_data = array(); diff --git a/pandora_console/operation/visual_console/public_console.php b/pandora_console/operation/visual_console/public_console.php index a668ee4ced..77b9e971ee 100644 --- a/pandora_console/operation/visual_console/public_console.php +++ b/pandora_console/operation/visual_console/public_console.php @@ -134,7 +134,10 @@ $(document).ready (function () { description: '', onExpiry: function () { href = ""; - href = href + "&refr="; + $exists_refr = href.indexOf("refr"); + if ($exists_refr == -1) { + href = href + "&refr="; + } $(document).attr ("location", href); } } @@ -146,4 +149,4 @@ $(document).ready (function () { draw_lines (lines, 'layout_map'); }); /* ]]> */ - \ No newline at end of file +