$subArray) { $somma_traffico += array_sum ($subArray); } $testo_leg .= "(System) Traffico Totale: ".fsize($somma_traffico * 1024)."\n"; } // Create the graph $g = new Graph($l,$h); $g->SetMargin(60,20,50,80); $g->title->SetFont(FF_VERDANA); $g->title->Set("Traffico regola \"$servizio\""); $g->subtitle->Set("$testo_leg Banda garantita: ".fsize ($garantiti * 1024)."/s - Banda massima: ".fsize($limite * 1024)."/s\n$txt_sotto"); $g->SetShadow(); $g->SetScale('textlin'); $g->xaxis->SetLabelAngle(90); $g->yaxis->title->SetFont(FF_VERDANA); $g->yaxis->SetLabelFormatCallback('udm'); if ($dettaglio == "minuto") { $query = "SELECT id, nome, colore FROM firewall"; } else { $query = "SELECT id, nome, colore FROM firewall WHERE id > 0"; } $res = mysql_query( $query ); while ( list ($fwid, $fwnome, $fwcolore) = mysql_fetch_array($res)) { switch ($dettaglio) { case "minuto": $$fwnome = new LinePlot($ydata[$fwid]); $g->Add($$fwnome); $g->xaxis->SetTickLabels($xdata[$fwid]); $$fwnome->SetColor($fwcolore); $$fwnome->SetLegend ($fwnome); break; case "ora": case "giorno": $$fwnome = new BarPlot($ydata[$fwid]); $g->xaxis->SetTickLabels($xdata[$fwid]); $$fwnome->SetCSIMTargets($tag[$fwid],$alt[$fwid]); $barre[] = $$fwnome; break; } }; if ($dettaglio == "ora" || $dettaglio == "giorno") { // $gbarre = new GroupBarPlot ($barre); $gbarre = new AccBarPlot ($barre); $g->Add($gbarre); $res = mysql_query( $query ); while ( list ($fwid, $fwnome, $fwcolore) = mysql_fetch_array($res)) { $color1 = sprintf ("%s1",$fwcolore); $color2 = sprintf ("%s4",$fwcolore); $$fwnome->SetFillGradient($color1,$color2,GRAD_VERT); $$fwnome->SetFillColor($fwcolore); $$fwnome->SetColor($fwcolore); $$fwnome->SetLegend ($fwnome); } } if ($limite == $garantiti) { $spessore = 2; } else { $spessore = 1; } # Inserisco linea di Massimo if (($massimo / 1024 ) > $limite) { $llim = new PlotLine (HORIZONTAL,$limite, "red",$spessore); $g->Add($llim); } # Inserisco linea di Garantito if (($massimo / 1024) > $garantiti) { $lgar = new PlotLine (HORIZONTAL,$garantiti, "green",1); $g->Add($lgar); } # Inserisco linea di Media $lmedia = new PlotLine (HORIZONTAL,$med/1024, "yellow",1); $g->Add($lmedia); # Inserisco cambi di giorno for ($i = 0; $iAddLine($dayline); } $g->legend->Pos( 0.02,0.02,"right" ,"top"); $g->legend->SetColumns(1); $g->legend->SetFrameWeight(2); $g->legend->SetShadow(); $g->StrokeCSIM('graph.php','giorni'); function inslabel ($tempo, $fw, $data_dif) { global $xdata, $cambiogiorno; if ($data_dif <= 1) { if (date("H:i",$tempo) == "00:00") { $xdata[$fw][] = date ("d.m H:i",$tempo); if (!array_search(count($xdata[$fw]), $cambiogiorno)) { $cambiogiorno[] = count($xdata[$fw]); } } else if (date("i",$tempo) == "00") { $xdata[$fw][] = date ("H:i",$tempo); } else { $xdata[$fw][] = ""; } } else if ($data_dif <= 12) { if (date("H:i",$tempo) == "00:00") { $xdata[$fw][] = date ("d.m H:i",$tempo); if (!array_search(count($xdata[$fw]), $cambiogiorno)) { $cambiogiorno[] = count($xdata[$fw]); } } else if ((date("i",$tempo) == "00") && ( ( date("H",$tempo)%(floor(24/floor(24/$data_dif))) ) == 0 )) { $xdata[$fw][] = date ("H:i",$tempo); } else { $xdata[$fw][] = ""; } } else { if (date("H:i",$tempo) == "00:00") { $xdata[$fw][] = date ("d.m H:i",$tempo); } else { $xdata[$fw][] = ""; } } } function udm ($valore) { if ($valore) return fsize ($valore*1024); else return ""; } ?>