function CourbeParHeure($zoom = false) { $day = $_GET["DAY"]; if ($day == null) { $day = date('Y-m-d'); } @mkdir($_GET["BASEPATH"], 0755, true); $f_name = "day-global-{$day}.png"; if ($zoom) { $f_name = "day-global-{$day}-zoom.png"; } $fileName = "{$_GET["BASEPATH"]}/{$f_name}"; if (is_file($fileName)) { if (file_get_time_min($fileName) < 20) { return "{$_GET["IMGPATH"]}/{$f_name}"; } } @unlink($fileName); $q = new mysql(); $sql = "SELECT COUNT(ID) as tcount ,DATE_FORMAT(zDate,'%h') as thour \nFROM `mbx_con` WHERE DATE_FORMAT(zDate,'%Y-%m-%d')='{$day}' GROUP BY thour ORDER BY thour"; $results = $q->QUERY_SQL($sql, "artica_events"); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $ydata[] = $ligne["tcount"]; $xdata[] = $ligne["thour"]; } if (count($ydata) < 2) { $ydata[] = 1; $xdata[] = date('d'); } $width = 500; $height = 200; if ($zoom) { $width = 720; $height = 400; } $graph = new Graph($width, $height); $graph->SetScale('textlin'); $graph->title->Set("Connexions numbers {$day}"); $graph->title->SetColor('white'); $graph->xaxis->title->Set('hours'); $graph->xaxis->SetTickLabels($xdata); $graph->yaxis->title->Set('(connexions)'); $graph->SetBackgroundGradient('darkred:0.7', 'black', 2, BGRAD_MARGIN); $graph->SetPlotGradient('black', 'darkred:0.8', 2); $graph->xaxis->SetColor('lightgray'); $graph->yaxis->SetColor('lightgray'); $graph->xgrid->Show(); $lineplot = new LinePlot($ydata); $lineplot->SetWeight(2); $lineplot->SetColor('orange:0.9'); $lineplot->SetFillColor('white@0.7'); $lineplot->SetFillFromYMin(); $lineplot->SetWeight(2); $lineplot->SetFilled(true); $lineplot->SetFillFromYMin(true); $graph->Add($lineplot); $gdImgHandler = $graph->Stroke(_IMG_HANDLER); $graph->img->Stream($fileName); return "{$_GET["IMGPATH"]}/{$f_name}"; }
function courbe_today($domain) { $tpl = new templates(); $q = new mysql(); $dansguardian_events = "dansguardian_events_" . date('Ym'); $sql = "SELECT COUNT( ID ) AS tcount, sitename, DATE_FORMAT( zdate, '%H' ) AS thour , DATE_FORMAT( zdate, '%Y-%m-%d' ) AS tday\nFROM {$dansguardian_events}\nWHERE sitename = '{$domain}'\nGROUP BY thour , tday\nHAVING tday = DATE_FORMAT( NOW( ) , '%Y-%m-%d' )\nORDER BY thour"; $results = $q->QUERY_SQL($sql, "artica_events"); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $GLOBALS["stats-array-{$domain}"][] = "<tr>\n\t<td style='font-size:12px;font-weight:bold' nowrap>{$ligne["thour"]}:00</td>\n\t<td style='font-size:12px;font-weight:bold' nowrap>{$ligne["tcount"]} hits</td>\n\t</tr>\n\t"; $ydata[] = $ligne["tcount"]; $xdata[] = $ligne["hour"]; } $f_name = "day-squid-{$domain}.png"; $fileName = "ressources/logs/{$f_name}"; if (is_file($fileName)) { if (file_get_time_min($fileName) < 120) { return $fileName; } } $title = "{$domain} " . $tpl->_ENGINE_parse_body('{today}'); @unlink($fileName); $width = 500; $height = 200; if ($zoom) { $width = 720; $height = 400; } JpGraphError::SetImageFlag(false); $graph = new Graph($width, $height); $graph->SetScale('textlin'); $graph->title->Set($title); $graph->title->SetColor('white'); $graph->xaxis->title->Set('hours'); $graph->xaxis->SetTickLabels($xdata); $graph->yaxis->title->Set('(hits number)'); $graph->yaxis->scale->SetGrace(10); $graph->SetBackgroundGradient('darkred:0.7', 'black', 2, BGRAD_MARGIN); $graph->SetPlotGradient('black', 'darkred:0.8', 2); $graph->SetMargin(55, 20, 60, 20); //$graph->img->SetMargin(50,30,30,100); $graph->xaxis->SetColor('lightgray'); $graph->yaxis->SetColor('lightgray'); $graph->xgrid->Show(); $lineplot = new LinePlot($ydata); $lineplot->SetWeight(2); $lineplot->SetColor('orange:0.9'); $lineplot->SetFillColor('white@0.7'); $lineplot->SetFillFromYMin(); $lineplot->SetWeight(2); $lineplot->SetFilled(true); $lineplot->SetFillFromYMin(true); $graph->Add($lineplot); JpGraphError::SetImageFlag(false); try { $gdImgHandler = $graph->Stroke(_IMG_HANDLER); } catch (JpGraphException $e) { // .. do necessary cleanup // Send back error message // $e->Stroke(); } $graph->img->Stream($fileName); return $fileName; }
$n = count($datax); $xmin = $datax[0]; $xmax = $datax[$n - 1]; // // The code to setup a very basic graph // $graph = new Graph(400, 200); // We use an integer scale on the X-axis since the positions on the X axis // are assumed to be UNI timestamps $graph->SetScale('linlin', 0, 0, $xmin, $xmax); $graph->title->Set('Example with manual tick labels'); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 12); $graph->title->SetColor('white'); // Setup a abackground gradient $graph->SetBackgroundGradient('darkred:0.7', 'black', 2, BGRAD_MARGIN); $graph->SetPlotGradient('black', 'darkred:0.8', 2); // Make sure that the X-axis is always at the bottom of the scale // (By default the X-axis is alwys positioned at Y=0 so if the scale // doesn't happen to include 0 the axis will not be shown) $graph->xaxis->SetPos('min'); // Now set the tic positions $graph->xaxis->SetMajTickPositions($tickPositions, $tickLabels); // Use Times font $graph->xaxis->SetFont(FF_TIMES, FS_NORMAL, 11); $graph->yaxis->SetFont(FF_TIMES, FS_NORMAL, 9); // Set colors for axis $graph->xaxis->SetColor('lightgray'); $graph->yaxis->SetColor('lightgray'); // Add a X-grid $graph->xgrid->Show(); // Show ticks outwards
function courbeparmois($zoom = false) { $month = $_GET["MONTH"]; @mkdir($_GET["BASEPATH"], 0755, true); $f_name = "day-global-{$month}.png"; if ($zoom) { $f_name = "day-global-{$month}-zoom.png"; } $fileName = "{$_GET["BASEPATH"]}/{$f_name}"; if (is_file($fileName)) { if (file_get_time_min($fileName) < 120) { return "{$_GET["IMGPATH"]}/{$f_name}"; } } @unlink($fileName); $q = new mysql(); $sql = "SELECT SUM(emails) as tcount , DATE_FORMAT(DAY,'%d') as tday FROM `smtp_logs_day` WHERE DATE_FORMAT(DAY,'%Y-%m')='{$_GET["MONTH"]}' GROUP BY tday ORDER BY tday"; $results = $q->QUERY_SQL($sql, "artica_events"); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $ydata[] = $ligne["tcount"]; $xdata[] = $ligne["DAY"]; } if (count($ydata) < 2) { $ydata[] = 1; $xdata[] = date('d'); } $width = 500; $height = 200; if ($zoom) { $width = 720; $height = 400; } $graph = new Graph($width, $height); $graph->SetScale('textlin'); $graph->title->Set("Received Mails {$_GET["MONTH"]}"); $graph->title->SetColor('white'); $graph->xaxis->title->Set('days'); $graph->xaxis->SetTickLabels($xdata); $graph->yaxis->title->Set('(emails number)'); $graph->yaxis->scale->SetGrace(10); $graph->SetBackgroundGradient('darkred:0.7', 'black', 2, BGRAD_MARGIN); $graph->SetPlotGradient('black', 'darkred:0.8', 2); $graph->SetMargin(55, 20, 60, 20); //$graph->img->SetMargin(50,30,30,100); $graph->xaxis->SetColor('lightgray'); $graph->yaxis->SetColor('lightgray'); $graph->xgrid->Show(); $lineplot = new LinePlot($ydata); $lineplot->SetWeight(2); $lineplot->SetColor('orange:0.9'); $lineplot->SetFillColor('white@0.7'); $lineplot->SetFillFromYMin(); $lineplot->SetWeight(2); $lineplot->SetFilled(true); $lineplot->SetFillFromYMin(true); $graph->Add($lineplot); $gdImgHandler = $graph->Stroke(_IMG_HANDLER); $graph->img->Stream($fileName); return "{$_GET["IMGPATH"]}/{$f_name}"; }