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; }
} switch ($numargs) { case 1: $msg = sprintf($ea[0], $argv[0]); break; case 2: $msg = sprintf($ea[0], $argv[0], $argv[1]); break; case 3: $msg = sprintf($ea[0], $argv[0], $argv[1], $argv[2]); break; case 4: $msg = sprintf($ea[0], $argv[0], $argv[1], $argv[2], $argv[3]); break; case 5: $msg = sprintf($ea[0], $argv[0], $argv[1], $argv[2], $argv[3], $argv[4]); break; case 0: default: $msg = sprintf($ea[0]); break; } return $msg; } } // Setup the default handler global $__jpg_OldHandler; $__jpg_OldHandler = set_exception_handler(array('Amenadiel\\JpGraph\\Util\\JpGraphException', 'defaultHandler')); if (!USE_IMAGE_ERROR_HANDLER) { JpGraphError::SetImageFlag(false); }
function courbe_month() { $tpl = new templates(); $q = new mysql(); $sql = "SELECT COUNT(ID) as tcount, DATE_FORMAT(zDate,'%d') as tday FROM fetchmail_events WHERE MONTH(zDate)=MONTH(NOW()) \nAND YEAR (zDate)=YEAR(NOW()) 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["tday"]; } $f_name = "month-fetchmail.png"; $fileName = "ressources/logs/{$f_name}"; /* if(is_file($fileName)){ if(file_get_time_min($fileName)<120){return $fileName;} }*/ @unlink($fileName); $title = "{$domain} " . $tpl->_ENGINE_parse_body('{this_month}'); $YNAME = $tpl->_ENGINE_parse_body("{emails_number}"); $XNAME = $tpl->_ENGINE_parse_body("{days}"); $width = 500; $height = 200; $graph = new Graph($width, $height); try { $graph->img->SetColor("red@0.9"); $graph->SetMarginColor('#FFFFFF'); $graph->SetScale('textlin'); $graph->title->Set($title); $graph->title->SetColor('#005447'); $graph->xaxis->title->Set($XNAME); $graph->xaxis->SetTickLabels($xdata); $graph->yaxis->title->Set($YNAME); $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->xaxis->SetColor('black'); $graph->yaxis->SetColor('black'); $graph->xgrid->Show(); $lineplot = new LinePlot($ydata); $lineplot->SetWeight(2); $lineplot->SetColor('#005447'); $lineplot->SetFillColor('green@0.5'); //$lineplot->SetFillColor('white@0.9'); $lineplot->SetFillFromYMin(); $lineplot->SetWeight(3); $lineplot->SetFilled(true); $lineplot->SetFillFromYMin(true); $graph->Add($lineplot); JpGraphError::SetImageFlag(false); $gdImgHandler = $graph->Stroke(_IMG_HANDLER); } catch (JpGraphException $e) { // .. do necessary cleanup // Send back error message // $e->Stroke(); } $graph->img->Stream($fileName); return $fileName; }