Exemplo n.º 1
0
function drawDiagram($img)
{
    global $num_horiz;
    $axes_color = imagecolorallocate($img, 0, 0, 0);
    $grid_color = imagecolorallocate($img, 204, 204, 204);
    $caption_color = imagecolorallocate($img, 0, 0, 0);
    $border_color = imagecolorallocate($img, 204, 204, 204);
    $background_color = imagecolorallocate($img, 255, 255, 255);
    $host_color = imagecolorallocate($img, 241, 29, 29);
    $hits_color = imagecolorallocate($img, 20, 203, 80);
    $visitors_color = imagecolorallocate($img, 29, 59, 241);
    $end_date = getLastDate();
    $start_date = strtotime("-28 day", $end_date);
    $max_data = getMaxData($start_date, $end_date);
    if ($max_data < 14 && $max_data != 0) {
        $num_horiz = $max_data;
    }
    imagefill($img, 0, 0, $background_color);
    imagerectangle($img, 0, 0, IMG_WIDTH - 1, IMG_HEIGHT - 1, $border_color);
    drawAxes($img, $axes_color);
    drawGrid($img, $grid_color);
    drawCaptions($img, $start_date, $max_data, $caption_color);
    drawGraphs($img, $start_date, $end_date, $max_data, $host_color, $hits_color, $visitors_color);
}
Exemplo n.º 2
0
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Content-type: image/png');
$img = imagecreatetruecolor(IMG_WIDTH, IMG_HEIGHT);
$axes_color = imagecolorallocate($img, 0, 0, 0);
$grid_color = imagecolorallocate($img, 233, 233, 233);
$caption_color = imagecolorallocate($img, 0, 0, 0);
$border_color = imagecolorallocate($img, 204, 204, 204);
$background_color = imagecolorallocate($img, 255, 255, 255);
$color1 = imagecolorallocate($img, 29, 59, 241);
$color2 = imagecolorallocate($img, 241, 29, 29);
$color3 = imagecolorallocate($img, 26, 180, 26);
imagefill($img, 0, 0, $background_color);
imagerectangle($img, 0, 0, IMG_WIDTH - 1, IMG_HEIGHT - 1, $border_color);
drawCaptions($img, $start_date, $end_date, $y_min, $y_max, $x_count, $y_count, $caption_color, $grid_color);
drawAxes($img, $axes_color);
drawGraphs($img, $items, $y_min, $y_delta, $color1, $color2, $color3);
drawLegend($img, $report, $caption_color, $color1, $color2, $color3, NETCAT_MODULE_STATS_OPENSTAT_VISITORS, NETCAT_MODULE_STATS_OPENSTAT_SESSIONS, NETCAT_MODULE_STATS_OPENSTAT_PAGEVIEWS);
imageinterlace($img, 1);
imagepng($img);
imagedestroy($img);
function drawAxes($img, $color)
{
    imageline($img, DIAGRAM_X, DIAGRAM_Y - 10, DIAGRAM_X, DIAGRAM_Y + DIAGRAM_HEIGHT, $color);
    imageline($img, DIAGRAM_X, DIAGRAM_Y + DIAGRAM_HEIGHT, DIAGRAM_X + DIAGRAM_WIDTH + 10, DIAGRAM_Y + DIAGRAM_HEIGHT, $color);
}
function drawCaptions($img, $start_date, $end_date, $y_min, $y_max, $x_count, $y_count, $text_color, $grind_color)
{
    global $level_of_detailing, $ttf_font_file, $nc_core;
    $y_start = DIAGRAM_Y + DIAGRAM_HEIGHT;
    $date_step = round(($end_date - $start_date) / ($x_count - 1));