";
$res = mysql_query($sql);
if ($res){
$id_graph = mysql_insert_id();
if ($id_graph){
for ($a=0; $a < $module_number; $a++){
$id_agentemodulo = entrada_limpia($_POST["module_".$a]);
$id_agentemodulo_w = entrada_limpia($_POST["module_weight_".$a]);
$sql = "INSERT INTO tgraph_source (id_graph, id_agent_module, weight) VALUES
($id_graph, $id_agentemodulo, $id_agentemodulo_w)";
//echo "DEBUG $sql
";
mysql_query($sql);
}
echo "
".$lang_label["store_graph_suc"]."
";
} else
echo "".$lang_label["store_graph_error"]."
";
} else
echo "".$lang_label["store_graph_error"]."
";
}
if (isset($_GET["get_agent"])) {
$id_agent = $_POST["id_agent"];
if (isset($_POST["chunk"]))
$chunkdata = $_POST["chunk"];
}
if (isset($_GET["delete_module"] )) {
$chunkdata = $_POST["chunk"];
if (isset($chunkdata)) {
$chunk1 = array();
$chunk1 = split ("\|", $chunkdata);
$modules="";$weights="";
for ($a=0; $a < count($chunk1); $a++){
if (isset($_POST["delete_$a"])){
$id_module = $_POST["delete_$a"];
$deleted_id[]=$id_module;
}
}
$chunkdata2 = "";
$module_array = array();
$weight_array = array();
$agent_array = array();
for ($a=0; $a < count($chunk1); $a++){
$chunk2[$a] = array();
$chunk2[$a] = split ( ",", $chunk1[$a]);
$skip_module =0;
for ($b=0; $b < count($deleted_id); $b++){
if ($deleted_id[$b] == $chunk2[$a][1]){
$skip_module = 1;
}
}
if (($skip_module == 0) && (strpos($modules, $chunk2[$a][1]) == 0)){ // Skip
$module_array[] = $chunk2[$a][1];
$agent_array[] = $chunk2[$a][0];
$weight_array[] = $chunk2[$a][2];
if ($chunkdata2 == "")
$chunkdata2 .= $chunk2[$a][0].",".$chunk2[$a][1].",".$chunk2[$a][2];
else
$chunkdata2 .= "|".$chunk2[$a][0].",".$chunk2[$a][1].",".$chunk2[$a][2];
if ($modules !="")
$modules = $modules.",".$chunk2[$a][1];
else
$modules = $chunk2[$a][1];
if ($weights !="")
$weights = $weights.",".$chunk2[$a][2];
else
$weights = $chunk2[$a][2];
}
}
$chunkdata = $chunkdata2;
}
}
if ( (isset($_GET["add_module"]))){
$id_agent = $_POST["id_agent"];
$id_module = $_POST["id_module"];
if (isset($_POST["factor"]))
$factor = $_POST["factor"];
else
$factor = 1;
$period = $_POST["period"];
$render = $_POST["render"];
// $alerts = $_POST["alerts"];
if (isset($_POST["chunk"]))
$chunkdata = $_POST["chunk"];
$events = $_POST["events"];
$factor = $_POST["factor"];
if ($_POST["width"]!= "")
$width = $_POST["width"];
if ($_POST["height"]!= "")
$height = $_POST["height"];
if ($id_module > 0){
if (!isset($chunkdata) OR ($chunkdata == ""))
$chunkdata = "$id_agent,$id_module,$factor";
else
$chunkdata = $chunkdata."|$id_agent,$id_module,$factor";
}
}
// Parse CHUNK information into showable information
// Split id to get all parameters
if (! isset($_GET["delete_module"])){
if (isset($_POST["period"]))
$period = $_POST["period"];
if ((isset($chunkdata) )&& ($chunkdata != "")) {
$module_array = array();
$weight_array = array();
$agent_array = array();
$chunk1 = array();
$chunk1 = split ("\|", $chunkdata);
$modules="";$weights="";
for ($a=0; $a < count($chunk1); $a++){
$chunk2[$a] = array();
$chunk2[$a] = split ( ",", $chunk1[$a]);
if (strpos($modules, $chunk2[$a][1]) == 0){ // Skip dupes
$module_array[] = $chunk2[$a][1];
$agent_array[] = $chunk2[$a][0];
$weight_array[] = $chunk2[$a][2];
if ($modules !="")
$modules = $modules.",".$chunk2[$a][1];
else
$modules = $chunk2[$a][1];
if ($weights !="")
$weights = $weights.",".$chunk2[$a][2];
else
$weights = $chunk2[$a][2];
}
}
}
}
echo "".$lang_label["reporting"]." > ";
if (isset($chunk1)) {
echo $lang_label["graph_builder_modulelist"]."
";
echo "";
}
// --------------------------------------
// Parse chunkdata and render graph
// --------------------------------------
if (($render == 1) && (isset($modules))) {
// parse chunk
echo "".$lang_label["combined_image"]."
";
echo "";
echo "";
echo "";
echo " |
";
}
// -----------------------
// SOURCE AGENT TABLE/FORM
// -----------------------
if ( (!isset($_GET["add_module"]))){
echo $lang_label["graph_builder"]."";
} else {
echo "".$lang_label["graph_builder"]."
";
}
echo "";
// -----------------------
// STORE GRAPH FORM
// -----------------------
// If we have something to save..
if (isset($module_array)){
echo "".$lang_label["graph_store"]."
";
echo "";
}
?>