"; $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 "
"; if (isset($chunkdata)) echo ""; if (isset($id_agent)) echo ""; if (isset($period)) echo ""; echo ""; echo ""; $color=0; for ($a=0; $a < count($module_array); $a++){ // Calculate table line color if ($color == 1){ $tdcolor = "datos"; $color = 0; } else { $tdcolor = "datos2"; $color = 1; } echo ""; echo ""; echo ""; echo ""; } echo "
".$lang_label["agent"]." ".$lang_label["module"]." Weight ".$lang_label["delete"]."
"; echo dame_nombre_agente($agent_array[$a]).""; echo dame_nombre_modulo_agentemodulo($module_array[$a]).""; echo $weight_array[$a].""; echo "
"; echo "
"; 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 ""; echo ""; if (isset($period)) echo ""; echo ""; echo ""; echo ""; // Show combo with agents echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; /* echo "
".$lang_label["source_agent"]."'; if (isset($chunkdata)) echo ""; echo ""; echo ""; // ----------------------- // SOURCE MODULE FORM // ----------------------- echo "
"; if (isset($chunkdata)) echo ""; if (isset($id_agent)) echo ""; echo "
"; echo "".$lang_label["modules"].""; echo ""; echo ""; echo "
"; echo "Factor"; echo ""; echo "Width"; echo ""; echo "
"; echo "Render now"; echo ""; echo "Height"; echo ""; switch ($period) { case 3600: $period_label = "Hour"; break; case 7200: $period_label = "2 Hours"; break; case 10800: $period_label = "3 Hours"; break; case 21600: $period_label = "6 Hours"; break; case 43200: $period_label = "12 Hours"; break; case 86400: $period_label = "Day"; break; case 172800: $period_label = "Two days"; break; case 345600: $period_label = "Four days"; break; case 604800: $period_label = "Last Week"; break; case 1296000: $period_label = "15 Days"; break; case 2592000: $period_label = "Last Month"; break; case 5184000: $period_label = "Two Month"; break; case 15552000: $period_label = "Six Months"; break; case 31104000: $period_label = "One year"; break; default: $period_label = "Day"; } echo "
"; echo "Period"; echo ""; echo ""; echo "Show events"; echo ""; echo "Show alert limit"; echo ""; echo ""; */ echo "
"; echo ""; echo "
"; // ----------------------- // STORE GRAPH FORM // ----------------------- // If we have something to save.. if (isset($module_array)){ echo "

".$lang_label["graph_store"]."

"; echo ""; echo ""; // hidden fields with data begin echo ""; echo ""; echo ""; echo ""; echo ""; for ($a=0; $a < count($module_array); $a++){ $id_agentemodulo = $module_array[$a]; $id_agentemodulo_w = $weight_array[$a]; echo ""; echo ""; } // hidden fields end echo ""; echo ""; echo "
".$lang_label["name"]; echo ""; echo ""; echo "".$lang_label["private"]; echo ""; echo ""; echo "
".$lang_label["description"]; echo ""; echo ""; echo "
"; echo ""; echo "
"; } ?>