auto reformatted

This commit is contained in:
Andreas Gohr
2012-11-22 11:27:27 +01:00
parent eadbd043f1
commit 35e687b331
22 changed files with 1392 additions and 1543 deletions

View File

@ -3,20 +3,20 @@
* Options for logstats plugin
*/
$conf['accesslog'] = 'data/access.log'; // Acces log file name to use
$conf['visit_time'] = 30; // time in minutes of a visit
$conf['referer'] = 'complete_link'; // display choice for the refereer
$conf['top_url_number_of_lines']= 30;
$conf['auto_compute_stats']= TRUE;
$conf['top_user_agents_number_of_lines']= 30;
$conf['top_entries_number_of_lines']= 10;
$conf['top_kbytes_number_of_lines']= 5;
$conf['top_referers_number_of_lines']= 30;
$conf['referer_regular_expr'] = '"Google={\'/google\.[^f][^r]/\'}"';
$conf['user_agent'] = 'all_line'; // display choice for the user agent
$conf['user_agent_keywords'] = '"firefox=Mozilla Firefox"'."\n".'"msie=Microsoft Internet Explorer"';
$conf['line_number'] = 10000; // number of line to analyse per request
$conf['memory_cache'] = 'data/cache'; // Where to cache the generated statistics
$conf['accesslog'] = 'data/access.log'; // Acces log file name to use
$conf['visit_time'] = 30; // time in minutes of a visit
$conf['referer'] = 'complete_link'; // display choice for the refereer
$conf['top_url_number_of_lines'] = 30;
$conf['auto_compute_stats'] = TRUE;
$conf['top_user_agents_number_of_lines'] = 30;
$conf['top_entries_number_of_lines'] = 10;
$conf['top_kbytes_number_of_lines'] = 5;
$conf['top_referers_number_of_lines'] = 30;
$conf['referer_regular_expr'] = '"Google={\'/google\.[^f][^r]/\'}"';
$conf['user_agent'] = 'all_line'; // display choice for the user agent
$conf['user_agent_keywords'] = '"firefox=Mozilla Firefox"'."\n".'"msie=Microsoft Internet Explorer"';
$conf['line_number'] = 10000; // number of line to analyse per request
$conf['memory_cache'] = 'data/cache'; // Where to cache the generated statistics
/*refereer (total OU nom de domaine OU Expression regulieres
user agent (ligne complete OU moteur affichage OU mots clef)

View File

@ -1,24 +1,24 @@
<?php
/**
* Metadata for configuration manager plugin
* Additions for the StatDisplay plugin
*
* @author Maxime FONDA && Thibault COULLET
*/
/**
* Metadata for configuration manager plugin
* Additions for the StatDisplay plugin
*
* @author Maxime FONDA && Thibault COULLET
*/
$meta['accesslog'] = array('string');
$meta['auto_compute_stats'] = array('onoff');
$meta['line_number'] = array('numeric');
$meta['visit_time'] = array('numeric');
$meta['top_url_number_of_lines'] = array('numeric');
$meta['top_kbytes_number_of_lines'] = array('numeric');
$meta['top_entries_number_of_lines'] = array('numeric');
$meta['referer'] = array('multichoice','_choices' => array('complete_link','domain'));
$meta['top_referers_number_of_lines'] = array('numeric');
$meta['regular_use'] = array('onoff');
$meta['referer_regular_expr'] = array('');
$meta['user_agent'] = array('multichoice','_choices' => array('all_line','display','keyword'));
$meta['top_user_agents_number_of_lines'] = array('numeric');
$meta['user_agent_keywords'] = array('');
$meta['memory_cache'] = array('string');
$meta['accesslog'] = array('string');
$meta['auto_compute_stats'] = array('onoff');
$meta['line_number'] = array('numeric');
$meta['visit_time'] = array('numeric');
$meta['top_url_number_of_lines'] = array('numeric');
$meta['top_kbytes_number_of_lines'] = array('numeric');
$meta['top_entries_number_of_lines'] = array('numeric');
$meta['referer'] = array('multichoice', '_choices' => array('complete_link', 'domain'));
$meta['top_referers_number_of_lines'] = array('numeric');
$meta['regular_use'] = array('onoff');
$meta['referer_regular_expr'] = array('');
$meta['user_agent'] = array('multichoice', '_choices' => array('all_line', 'display', 'keyword'));
$meta['top_user_agents_number_of_lines'] = array('numeric');
$meta['user_agent_keywords'] = array('');
$meta['memory_cache'] = array('string');
?>

View File

@ -8,229 +8,216 @@
*/
include 'init_gd.php';
function draw_bar($im,$top_left_x,$top_left_y,$width,$height,$scale,$value,$color)
{
$black=ImageColorAllocate($im,0,0,0);
$y1=$top_left_y+$height-($scale*$value);
$x2=$top_left_x+$width;
$y2=$top_left_y+$height;
imagefilledrectangle($im,$top_left_x,$y1,$x2,$y2,$color);
imagerectangle($im,$top_left_x,$y1,$x2,$y2,$black);
function draw_bar($im, $top_left_x, $top_left_y, $width, $height, $scale, $value, $color) {
$black = ImageColorAllocate($im, 0, 0, 0);
$y1 = $top_left_y + $height - ($scale * $value);
$x2 = $top_left_x + $width;
$y2 = $top_left_y + $height;
imagefilledrectangle($im, $top_left_x, $y1, $x2, $y2, $color);
imagerectangle($im, $top_left_x, $y1, $x2, $y2, $black);
}
function make_total_histogram($im,$top_left_x,$top_left_y,$width,$height,$padding,$datas,$size)
{
$width=$width-2*$padding;
$height=$height-2*$padding;
$top_left_x=$top_left_x+$padding;
$top_left_y=$top_left_y+$padding;
function make_total_histogram($im, $top_left_x, $top_left_y, $width, $height, $padding, $datas, $size) {
$width = $width - 2 * $padding;
$height = $height - 2 * $padding;
$top_left_x = $top_left_x + $padding;
$top_left_y = $top_left_y + $padding;
// Set the colors
$blue = ImageColorAllocate($im, 0, 0, 255);
$dark_green = ImageColorAllocate($im, 0, 125, 0);
$clear_blue = ImageColorAllocate($im, 100, 255, 240);
$black = ImageColorAllocate($im, 0, 0, 0);
// Set the colors
$blue=ImageColorAllocate($im,0,0,255);
$dark_green=ImageColorAllocate($im,0,125,0);
$clear_blue=ImageColorAllocate($im,100,255,240);
$black=ImageColorAllocate($im,0,0,0);
$max = 0;
$max=0;
//Find all maximums
$max = max($max, max($datas['hits']), max($datas['pages']), max($datas['files']));
$scale = $height / $max;
//Find all maximums
$max=max($max,max($datas['hits']),max($datas['pages']),max($datas['files']));
$scale=$height/$max;
//Show lengend
imagestringup($im, 3, $top_left_x - $padding - 15, $top_left_y + $height, 'Pages', $clear_blue);
imagestringup($im, 2, $top_left_x - $padding - 15, $top_left_y + $height - 38, '/', $black);
imagestringup($im, 3, $top_left_x - $padding - 15, $top_left_y + $height - 48, 'Files', $blue);
imagestringup($im, 2, $top_left_x - $padding - 15, $top_left_y + $height - 85, '/', $black);
imagestringup($im, 3, $top_left_x - $padding - 15, $top_left_y + $height - 95, 'Hits', $dark_green);
imagestringup($im, 2, $top_left_x - $padding - 15, $top_left_y - $padding + strlen($max) * 6, $max, $black);
//Show lengend
imagestringup($im,3,$top_left_x-$padding-15,$top_left_y+$height,'Pages',$clear_blue);
imagestringup($im,2,$top_left_x-$padding-15,$top_left_y+$height-38,'/',$black);
imagestringup($im,3,$top_left_x-$padding-15,$top_left_y+$height-48,'Files',$blue);
imagestringup($im,2,$top_left_x-$padding-15,$top_left_y+$height-85,'/',$black);
imagestringup($im,3,$top_left_x-$padding-15,$top_left_y+$height-95,'Hits',$dark_green);
imagestringup($im,2,$top_left_x-$padding-15,$top_left_y-$padding+strlen($max)*6,$max,$black);
$part_width = $width / ($size + 1 - $GLOBALS['begin_for']);
$part_spacing = 0.2 * $part_width;
$bar_offset = intval($part_spacing);
$bar_width = ($part_width - $part_spacing) - ($bar_offset * 2);
$part_width=$width/($size+1-$GLOBALS['begin_for']);
$part_spacing=0.2*$part_width;
$bar_offset=intval($part_spacing);
$bar_width=($part_width-$part_spacing)-($bar_offset*2);
//Draw the Histogram
for($i=$GLOBALS['begin_for'];$i<=$size;$i++)
{
if(!isset($datas['hits'][$i]))
{
$datas['hits'][$i]=0;
$datas['pages'][$i]=0;
$datas['files'][$i]=0;
}
draw_bar($im,$top_left_x+($i-$GLOBALS['begin_for'])*$part_width,$top_left_y,$bar_width,$height,$scale,$datas['hits'][$i],$dark_green);
draw_bar($im,($top_left_x+($i-$GLOBALS['begin_for'])*$part_width)+$bar_offset,$top_left_y,$bar_width,$height,$scale,$datas['files'][$i],$blue);
draw_bar($im,($top_left_x+($i-$GLOBALS['begin_for'])*$part_width)+2*$bar_offset,$top_left_y,$bar_width,$height,$scale,$datas['pages'][$i],$clear_blue);
}
//Draw the Histogram
for($i = $GLOBALS['begin_for']; $i <= $size; $i++) {
if(!isset($datas['hits'][$i])) {
$datas['hits'][$i] = 0;
$datas['pages'][$i] = 0;
$datas['files'][$i] = 0;
}
draw_bar($im, $top_left_x + ($i - $GLOBALS['begin_for']) * $part_width, $top_left_y, $bar_width, $height, $scale, $datas['hits'][$i], $dark_green);
draw_bar($im, ($top_left_x + ($i - $GLOBALS['begin_for']) * $part_width) + $bar_offset, $top_left_y, $bar_width, $height, $scale, $datas['files'][$i], $blue);
draw_bar($im, ($top_left_x + ($i - $GLOBALS['begin_for']) * $part_width) + 2 * $bar_offset, $top_left_y, $bar_width, $height, $scale, $datas['pages'][$i], $clear_blue);
}
}
function make_total_visits_histogram($im,$top_left_x,$top_left_y,$width,$height,$padding,$datas,$size)
{
$width=$width-2*$padding;
$height=$height-2*$padding;
$top_left_x=$top_left_x+$padding;
$top_left_y=$top_left_y+$padding;
function make_total_visits_histogram($im, $top_left_x, $top_left_y, $width, $height, $padding, $datas, $size) {
$width = $width - 2 * $padding;
$height = $height - 2 * $padding;
$top_left_x = $top_left_x + $padding;
$top_left_y = $top_left_y + $padding;
// Set the colors
$yellow = ImageColorAllocate($im, 255, 255, 0);
$black = ImageColorAllocate($im, 0, 0, 0);
// Set the colors
$yellow=ImageColorAllocate($im,255,255,0);
$black=ImageColorAllocate($im,0,0,0);
$max = 0;
$max=0;
//Find the maximum
$max = max($datas['visits']);
$scale = $height / $max;
//Find the maximum
$max=max($datas['visits']);
$scale=$height/$max;
//Show lengend
imagestringup($im, 3, $top_left_x - $padding - 15, $top_left_y + $padding + $height, 'Visits', $yellow);
imagestringup($im, 2, $top_left_x - $padding - 15, $top_left_y - $padding + strlen($max) * 6, $max, $black);
//Show lengend
imagestringup($im,3,$top_left_x-$padding-15,$top_left_y+$padding+$height,'Visits',$yellow);
imagestringup($im,2,$top_left_x-$padding-15,$top_left_y-$padding+strlen($max)*6,$max,$black);
$part_width = $width / ($size + 1 - $GLOBALS['begin_for']);
$part_spacing = 0.2 * $part_width;
$part_width=$width/($size+1-$GLOBALS['begin_for']);
$part_spacing=0.2*$part_width;
//Draw the Histogram
for($i=$GLOBALS['begin_for'];$i<=$size;$i++)
{
if(!isset($datas['visits'][$i]))
$datas['visits'][$i]=0;
draw_bar($im,$top_left_x+($i-$GLOBALS['begin_for'])*$part_width,$top_left_y,$part_width-$part_spacing,$height,$scale,$datas['visits'][$i],$yellow);
}
//Draw the Histogram
for($i = $GLOBALS['begin_for']; $i <= $size; $i++) {
if(!isset($datas['visits'][$i]))
$datas['visits'][$i] = 0;
draw_bar($im, $top_left_x + ($i - $GLOBALS['begin_for']) * $part_width, $top_left_y, $part_width - $part_spacing, $height, $scale, $datas['visits'][$i], $yellow);
}
}
function make_total_bytes_histogram($im,$top_left_x,$top_left_y,$width,$height,$padding,$datas,$size)
{
$width=$width-2*$padding;
$height=$height-2*$padding;
$top_left_x=$top_left_x+$padding;
$top_left_y=$top_left_y+$padding;
function make_total_bytes_histogram($im, $top_left_x, $top_left_y, $width, $height, $padding, $datas, $size) {
$width = $width - 2 * $padding;
$height = $height - 2 * $padding;
$top_left_x = $top_left_x + $padding;
$top_left_y = $top_left_y + $padding;
// Set the colors
$red = ImageColorAllocate($im, 255, 0, 0);
$black = ImageColorAllocate($im, 0, 0, 0);
// Set the colors
$red=ImageColorAllocate($im,255,0,0);
$black=ImageColorAllocate($im,0,0,0);
$max = 0;
$max=0;
//Find the maximum
$max = max($datas['bytes']);
$scale = $height / $max;
//Find the maximum
$max=max($datas['bytes']);
$scale=$height/$max;
//Show lengend
imagestringup($im, 3, $top_left_x - $padding - 15, $top_left_y + $padding + $height, 'KBytes', $red);
imagestringup($im, 2, $top_left_x - $padding - 15, $top_left_y - $padding + strlen(intval($max)) * 6, intval($max), $black);
//Show lengend
imagestringup($im,3,$top_left_x-$padding-15,$top_left_y+$padding+$height,'KBytes',$red);
imagestringup($im,2,$top_left_x-$padding-15,$top_left_y-$padding+strlen(intval($max))*6,intval($max),$black);
$part_width = $width / ($size + 1 - $GLOBALS['begin_for']);
$part_spacing = 0.2 * $part_width;
$part_width=$width/($size+1-$GLOBALS['begin_for']);
$part_spacing=0.2*$part_width;
//Draw the Histogram
for($i=$GLOBALS['begin_for'];$i<=$size;$i++)
{
if(!isset($datas['bytes'][$i]))
$datas['bytes'][$i]=0;
draw_bar($im,$top_left_x+($i-$GLOBALS['begin_for'])*$part_width,$top_left_y,$part_width-$part_spacing,$height,$scale,$datas['bytes'][$i],$red);
$position=$top_left_x+($i-$GLOBALS['begin_for'])*$part_width+$part_width/2-strlen($i)*4;
imagestring($im,2,$position,$top_left_y+$padding+$height,$i,$black);
}
//Draw the Histogram
for($i = $GLOBALS['begin_for']; $i <= $size; $i++) {
if(!isset($datas['bytes'][$i]))
$datas['bytes'][$i] = 0;
draw_bar($im, $top_left_x + ($i - $GLOBALS['begin_for']) * $part_width, $top_left_y, $part_width - $part_spacing, $height, $scale, $datas['bytes'][$i], $red);
$position = $top_left_x + ($i - $GLOBALS['begin_for']) * $part_width + $part_width / 2 - strlen($i) * 4;
imagestring($im, 2, $position, $top_left_y + $padding + $height, $i, $black);
}
}
function draw_border($im,$top_left_x,$top_left_y,$top_right_x,$top_right_y,$bottom_left_x,$bottom_left_y)
{
// Set the colors
$hard_grey=ImageColorAllocate($im,80,80,80);
$white=ImageColorAllocate($im,255,255,255);
$black=ImageColorAllocate($im,0,0,0);
function draw_border($im, $top_left_x, $top_left_y, $top_right_x, $top_right_y, $bottom_left_x, $bottom_left_y) {
// Set the colors
$hard_grey = ImageColorAllocate($im, 80, 80, 80);
$white = ImageColorAllocate($im, 255, 255, 255);
$black = ImageColorAllocate($im, 0, 0, 0);
//A black and white border
imageline($im,$top_left_x,$top_left_y,$top_right_x,$top_right_y,$white);
imageline($im,$top_right_x,$top_right_y,$top_right_x,$bottom_left_y,$white);
imageline($im,$top_right_x,$bottom_left_y,$bottom_left_x,$bottom_left_y,$white);
imageline($im,$bottom_left_x,$bottom_left_y,$top_left_x,$top_left_y,$white);
imageline($im,$top_left_x+1,$top_left_y+1,$top_right_x-1,$top_right_y+1,$black);
imageline($im,$top_right_x+1,$top_right_y+1,$top_right_x+1,$bottom_left_y+1,$black);
imageline($im,$top_right_x+1,$bottom_left_y+1,$bottom_left_x+1,$bottom_left_y+1,$black);
imageline($im,$bottom_left_x+1,$bottom_left_y-1,$top_left_x+1,$top_left_y+1,$black);
//A black and white border
imageline($im, $top_left_x, $top_left_y, $top_right_x, $top_right_y, $white);
imageline($im, $top_right_x, $top_right_y, $top_right_x, $bottom_left_y, $white);
imageline($im, $top_right_x, $bottom_left_y, $bottom_left_x, $bottom_left_y, $white);
imageline($im, $bottom_left_x, $bottom_left_y, $top_left_x, $top_left_y, $white);
imageline($im, $top_left_x + 1, $top_left_y + 1, $top_right_x - 1, $top_right_y + 1, $black);
imageline($im, $top_right_x + 1, $top_right_y + 1, $top_right_x + 1, $bottom_left_y + 1, $black);
imageline($im, $top_right_x + 1, $bottom_left_y + 1, $bottom_left_x + 1, $bottom_left_y + 1, $black);
imageline($im, $bottom_left_x + 1, $bottom_left_y - 1, $top_left_x + 1, $top_left_y + 1, $black);
//A scale drawn in the background
$scale_y=$top_left_y+(($bottom_left_y-$top_left_y)/3);
imageline($im,$top_left_x+2,$scale_y,$top_right_x-1,$scale_y,$hard_grey);
$scale_y=$top_left_y+2*(($bottom_left_y-$top_left_y)/3);
imageline($im,$top_left_x+2,$scale_y,$top_right_x-1,$scale_y,$hard_grey);
//A scale drawn in the background
$scale_y = $top_left_y + (($bottom_left_y - $top_left_y) / 3);
imageline($im, $top_left_x + 2, $scale_y, $top_right_x - 1, $scale_y, $hard_grey);
$scale_y = $top_left_y + 2 * (($bottom_left_y - $top_left_y) / 3);
imageline($im, $top_left_x + 2, $scale_y, $top_right_x - 1, $scale_y, $hard_grey);
}
function total_histogram($total_tab,$img_width,$img_height,$caption,$size)
{
header("Content-type: image/png");
function total_histogram($total_tab, $img_width, $img_height, $caption, $size) {
header("Content-type: image/png");
// Create image and Set the colors
$im=imagecreatetruecolor(intval($img_width),intval($img_height));
$grey=ImageColorAllocate($im,180,180,180);
$little_grey=ImageColorAllocate($im,220,220,220);
$hard_grey=ImageColorAllocate($im,60,60,60);
$blue=ImageColorAllocate($im,0,0,255);
// Create image and Set the colors
$im = imagecreatetruecolor(intval($img_width), intval($img_height));
$grey = ImageColorAllocate($im, 180, 180, 180);
$little_grey = ImageColorAllocate($im, 220, 220, 220);
$hard_grey = ImageColorAllocate($im, 60, 60, 60);
$blue = ImageColorAllocate($im, 0, 0, 255);
$margin=20; //graph margin
$padding=10; //Histogram padding
$border_size=3; //main border size
$ratio=0.45;
$margin = 20; //graph margin
$padding = 10; //Histogram padding
$border_size = 3; //main border size
$ratio = 0.45;
//Fill the graph with grey background
$im=imagecreatetruecolor(intval($img_width),intval($img_height));
imagefill($im,0,0,$grey);
//Fill the graph with grey background
$im = imagecreatetruecolor(intval($img_width), intval($img_height));
imagefill($im, 0, 0, $grey);
//Color the first part of the main border
$borger_top_left=array(0,$img_height,
0,0,
$img_width,0,
$img_width-$border_size,$border_size,
$border_size,$border_size,
$border_size,$img_height-$border_size,
);
ImageFilledPolygon($im, $borger_top_left, 6, $little_grey);
//Color the second part of the main border
$border_top_right=array(0,$img_height,
$img_width,$img_height,
$img_width,0,
$img_width-$border_size,$border_size,
$img_width-$border_size,$img_height-$border_size,
$border_size,$img_height-$border_size,
);
ImageFilledPolygon($im,$border_top_right,6,$hard_grey);
//Color the first part of the main border
$borger_top_left = array(
0, $img_height,
0, 0,
$img_width, 0,
$img_width - $border_size, $border_size,
$border_size, $border_size,
$border_size, $img_height - $border_size,
);
ImageFilledPolygon($im, $borger_top_left, 6, $little_grey);
//writing caption
imagestring($im, 3, $margin, 6, $caption, $blue);
//Color the second part of the main border
$border_top_right = array(
0, $img_height,
$img_width, $img_height,
$img_width, 0,
$img_width - $border_size, $border_size,
$img_width - $border_size, $img_height - $border_size,
$border_size, $img_height - $border_size,
);
ImageFilledPolygon($im, $border_top_right, 6, $hard_grey);
//create 3 borders for 3 histograms
draw_border($im,$margin,$margin,$img_width-$margin,$margin,$margin,$margin+($img_height-2*$margin)*$ratio);
make_total_histogram($im,$margin,$margin,$img_width-2*$margin,($img_height-2*$margin)*$ratio,$padding,$total_tab,$size);
$y_foo=$margin+($img_height-2*$margin)*$ratio+($img_height-2*$margin)*(1-$ratio)/2;
draw_border($im,$margin,$margin+($img_height-2*$margin)*$ratio,$img_width-$margin,$margin+($img_height-2*$margin)*$ratio,$margin,$y_foo);
make_total_visits_histogram($im,$margin,$margin+($img_height-2*$margin)*$ratio,($img_width-2*$margin),($img_height-2*$margin)*(1-$ratio)/2,$padding,$total_tab,$size);
draw_border($im,$margin,$y_foo,$img_width-$margin,$y_foo,$margin,$img_height-$margin);
make_total_bytes_histogram($im,$margin,$y_foo,$img_width-2*$margin,($img_height-2*$margin)*(1-$ratio)/2,$padding,$total_tab,$size);
imagepng($im); //Show the histogram created
imagedestroy($im); //Free the memory and destroy the histogram
//writing caption
imagestring($im, 3, $margin, 6, $caption, $blue);
//create 3 borders for 3 histograms
draw_border($im, $margin, $margin, $img_width - $margin, $margin, $margin, $margin + ($img_height - 2 * $margin) * $ratio);
make_total_histogram($im, $margin, $margin, $img_width - 2 * $margin, ($img_height - 2 * $margin) * $ratio, $padding, $total_tab, $size);
$y_foo = $margin + ($img_height - 2 * $margin) * $ratio + ($img_height - 2 * $margin) * (1 - $ratio) / 2;
draw_border($im, $margin, $margin + ($img_height - 2 * $margin) * $ratio, $img_width - $margin, $margin + ($img_height - 2 * $margin) * $ratio, $margin, $y_foo);
make_total_visits_histogram($im, $margin, $margin + ($img_height - 2 * $margin) * $ratio, ($img_width - 2 * $margin), ($img_height - 2 * $margin) * (1 - $ratio) / 2, $padding, $total_tab, $size);
draw_border($im, $margin, $y_foo, $img_width - $margin, $y_foo, $margin, $img_height - $margin);
make_total_bytes_histogram($im, $margin, $y_foo, $img_width - 2 * $margin, ($img_height - 2 * $margin) * (1 - $ratio) / 2, $padding, $total_tab, $size);
imagepng($im); //Show the histogram created
imagedestroy($im); //Free the memory and destroy the histogram
}
$caption=$_GET['title'].' for '.$_SERVER['SERVER_NAME'];
if ($_GET['type']==24)
{
$tabindex='heure';
$GLOBALS['begin_for']=0;
$_GET['type']--;
}
else
{
$tabindex='jour';
$GLOBALS['begin_for']=1;
}
total_histogram($tableau[$_GET['month']][$tabindex],600,550,$caption,$_GET['type']);
$caption = $_GET['title'].' for '.$_SERVER['SERVER_NAME'];
if($_GET['type'] == 24) {
$tabindex = 'heure';
$GLOBALS['begin_for'] = 0;
$_GET['type']--;
} else {
$tabindex = 'jour';
$GLOBALS['begin_for'] = 1;
}
total_histogram($tableau[$_GET['month']][$tabindex], 600, 550, $caption, $_GET['type']);
?>

View File

@ -7,12 +7,10 @@
* @author Thibault Coullet <thibault.coullet@ensi-bourges.fr>
*/
function daily($month)
{
if (isset($_SESSION['statdisplay'][$month]))
{
$tableau=$_SESSION['statdisplay'];
$msg='<table cellspacing="0"> <tr><td colspan="11" class="titre" bgcolor="#BABABA">Daily statistics for '.str_replace("_"," ",$month).'</td></tr>
function daily($month) {
if(isset($_SESSION['statdisplay'][$month])) {
$tableau = $_SESSION['statdisplay'];
$msg = '<table cellspacing="0"> <tr><td colspan="11" class="titre" bgcolor="#BABABA">Daily statistics for '.str_replace("_", " ", $month).'</td></tr>
<tr>
<td class="titre" bgcolor="#BABABA">Day</td>
<td class="titre" colspan="2" bgcolor="green">hits</td>
@ -22,27 +20,26 @@ $msg='<table cellspacing="0"> <tr><td colspan="11" class="titre" bgcolor="#BABAB
<td class="titre" colspan="2" bgcolor="red">Kbytes</td>
</tr>';
for ($i=1;$i<=31;$i++)
{
if ($tableau[$month]['jour']['hits'][$i]>0)
{
$msg.= '<tr>
for($i = 1; $i <= 31; $i++) {
if($tableau[$month]['jour']['hits'][$i] > 0) {
$msg .= '<tr>
<td align="center">'.$i.'</td>
<td class="valeur" >'.$tableau[$month]['jour']['hits'][$i].'</td>
<td class="pourcent" >'.number_format($tableau[$month]['jour']['hits'][$i]*100/$tableau[$month]['resume']['hits'],2).'%</td>
<td class="pourcent" >'.number_format($tableau[$month]['jour']['hits'][$i] * 100 / $tableau[$month]['resume']['hits'], 2).'%</td>
<td class="valeur" >'.$tableau[$month]['jour']['files'][$i].'</td>
<td class="pourcent" >'.number_format($tableau[$month]['jour']['files'][$i]*100/$tableau[$month]['resume']['files'],2).'%</td>
<td class="pourcent" >'.number_format($tableau[$month]['jour']['files'][$i] * 100 / $tableau[$month]['resume']['files'], 2).'%</td>
<td class="valeur" >'.$tableau[$month]['jour']['pages'][$i].'</td>
<td class="pourcent" >'.number_format($tableau[$month]['jour']['pages'][$i]*100/$tableau[$month]['resume']['pages'],2).'%</td>
<td class="pourcent" >'.number_format($tableau[$month]['jour']['pages'][$i] * 100 / $tableau[$month]['resume']['pages'], 2).'%</td>
<td class="valeur" >'.$tableau[$month]['jour']['visits'][$i].'</td>
<td class="pourcent" >'.number_format($tableau[$month]['jour']['visits'][$i]*100/$tableau[$month]['resume']['visits'],2).'%</td>
<td class="valeur" >'.number_format($tableau[$month]['jour']['bytes'][$i],2).'</td>
<td class="pourcent" >'.number_format($tableau[$month]['jour']['bytes'][$i]*100/$tableau[$month]['resume']['bytes'],2).'%</td>
<td class="pourcent" >'.number_format($tableau[$month]['jour']['visits'][$i] * 100 / $tableau[$month]['resume']['visits'], 2).'%</td>
<td class="valeur" >'.number_format($tableau[$month]['jour']['bytes'][$i], 2).'</td>
<td class="pourcent" >'.number_format($tableau[$month]['jour']['bytes'][$i] * 100 / $tableau[$month]['resume']['bytes'], 2).'%</td>
</tr>';
}
}
$msg .= '</table>';
return $msg;
}
}
$msg.= '</table>';
return $msg;
}
}
?>

View File

@ -7,12 +7,10 @@
* @author Thibault Coullet <thibault.coullet@ensi-bourges.fr>
*/
function hourly($month)
{
if (isset($_SESSION['statdisplay'][$month]))
{
$tableau=$_SESSION['statdisplay'];
$msg = '<table cellspacing="0"> <tr><td colspan="11" class="titre" bgcolor="#BABABA">Hourly statistics for '.str_replace("_"," ",$month).'</td></tr>
function hourly($month) {
if(isset($_SESSION['statdisplay'][$month])) {
$tableau = $_SESSION['statdisplay'];
$msg = '<table cellspacing="0"> <tr><td colspan="11" class="titre" bgcolor="#BABABA">Hourly statistics for '.str_replace("_", " ", $month).'</td></tr>
<tr>
<td class="titre" bgcolor="#BABABA">Hour</td>
<td class="titre" colspan="2" bgcolor="green">hits</td>
@ -21,27 +19,26 @@ $msg = '<table cellspacing="0"> <tr><td colspan="11" class="titre" bgcolor="#BAB
<td class="titre" colspan="2" bgcolor="yellow">visits</td>
<td class="titre" colspan="2" bgcolor="red">Kbytes</td>
</tr>';
for ($i=0;$i<=23;$i++)
{
if ($tableau[$month]['heure']['hits'][$i]>0)
{
$msg .= '<tr>
for($i = 0; $i <= 23; $i++) {
if($tableau[$month]['heure']['hits'][$i] > 0) {
$msg .= '<tr>
<td align="center">'.$i.'</td>
<td class="valeur">'.$tableau[$month]['heure']['hits'][$i].'</td>
<td class="pourcent">'.number_format($tableau[$month]['heure']['hits'][$i]*100/$tableau[$month]['resume']['hits'],2).'%</td>
<td class="pourcent">'.number_format($tableau[$month]['heure']['hits'][$i] * 100 / $tableau[$month]['resume']['hits'], 2).'%</td>
<td class="valeur">'.$tableau[$month]['heure']['files'][$i].'</td>
<td class="pourcent">'.number_format($tableau[$month]['heure']['files'][$i]*100/$tableau[$month]['resume']['files'],2).'%</td>
<td class="pourcent">'.number_format($tableau[$month]['heure']['files'][$i] * 100 / $tableau[$month]['resume']['files'], 2).'%</td>
<td class="valeur">'.$tableau[$month]['heure']['pages'][$i].'</td>
<td class="pourcent">'.number_format($tableau[$month]['heure']['pages'][$i]*100/$tableau[$month]['resume']['pages'],2).'%</td>
<td class="pourcent">'.number_format($tableau[$month]['heure']['pages'][$i] * 100 / $tableau[$month]['resume']['pages'], 2).'%</td>
<td class="valeur">'.$tableau[$month]['heure']['visits'][$i].'</td>
<td class="pourcent">'.number_format($tableau[$month]['heure']['visits'][$i]*100/$tableau[$month]['resume']['visits'],2).'%</td>
<td class="valeur">'.number_format($tableau[$month]['heure']['bytes'][$i],2).'</td>
<td class="pourcent">'.number_format($tableau[$month]['heure']['bytes'][$i]*100/$tableau[$month]['resume']['bytes'],2).'%</td>
<td class="pourcent">'.number_format($tableau[$month]['heure']['visits'][$i] * 100 / $tableau[$month]['resume']['visits'], 2).'%</td>
<td class="valeur">'.number_format($tableau[$month]['heure']['bytes'][$i], 2).'</td>
<td class="pourcent">'.number_format($tableau[$month]['heure']['bytes'][$i] * 100 / $tableau[$month]['resume']['bytes'], 2).'%</td>
</tr>';
}
}
$msg .= '</table>';
return $msg;
}
}
$msg .= '</table>';
return $msg;
}
}
?>

175
init.php
View File

@ -7,119 +7,99 @@
* @author Thibault Coullet <thibault.coullet@ensi-bourges.fr>
*/
$statdisplay_memory_cache1 = DOKU_INC . $this->getConf('memory_cache') . '/statdisplay_memory_cache1.php';
$statdisplay_memory_cache2 = DOKU_INC . $this->getConf('memory_cache') . '/statdisplay_memory_cache2.php';
$statdisplay_memory_cache1 = DOKU_INC.$this->getConf('memory_cache').'/statdisplay_memory_cache1.php';
$statdisplay_memory_cache2 = DOKU_INC.$this->getConf('memory_cache').'/statdisplay_memory_cache2.php';
if (!function_exists("date_to_timestamp"))
{function date_to_timestamp($time_string)
{
$date_string=trim($time_string,"[");
$date=explode('/',$date_string);
$hour=explode(':',$date[2]);
$date[0]=trim($date[0],"0");
return mktime($hour[1],$hour[2],$hour[3],$month[$date[1]],$date[0],$hour[0]);
}
if(!function_exists("date_to_timestamp")) {
function date_to_timestamp($time_string) {
$date_string = trim($time_string, "[");
$date = explode('/', $date_string);
$hour = explode(':', $date[2]);
$date[0] = trim($date[0], "0");
return mktime($hour[1], $hour[2], $hour[3], $month[$date[1]], $date[0], $hour[0]);
}
}
if (file_exists($log_path))
{
if (is_readable($log_path))
$fichier_log=fopen($log_path,'r');
if(file_exists($log_path)) {
if(is_readable($log_path))
$fichier_log = fopen($log_path, 'r');
else
exit ('Permission denied on log file '.$log_path);
}
else
{
exit ('Permission denied on log file '.$log_path);
} else {
exit('Cannot open Logstats plugin log file : '.$log_path);
}
if (!file_exists($statdisplay_memory_cache1))
{
$fichier_sauv=fopen($statdisplay_memory_cache1,'wr+');
if(!file_exists($statdisplay_memory_cache1)) {
$fichier_sauv = fopen($statdisplay_memory_cache1, 'wr+');
fclose($fichier_sauv);
}
if (!file_exists($statdisplay_memory_cache2))
{
$fichier_sauv=fopen($statdisplay_memory_cache2,'wr+');
if(!file_exists($statdisplay_memory_cache2)) {
$fichier_sauv = fopen($statdisplay_memory_cache2, 'wr+');
fclose($fichier_sauv);
}
if (filemtime($statdisplay_memory_cache1) >= filemtime($statdisplay_memory_cache2))
{
$file=fopen($statdisplay_memory_cache1,'r');
fseek($file,-2,SEEK_END);
if (fgets($file)=="?>") //fichier 1 correctement ecrit
if(filemtime($statdisplay_memory_cache1) >= filemtime($statdisplay_memory_cache2)) {
$file = fopen($statdisplay_memory_cache1, 'r');
fseek($file, -2, SEEK_END);
if(fgets($file) == "?>") //fichier 1 correctement ecrit
{
fclose($file);
require $statdisplay_memory_cache1;
if ($_SESSION['need_update'] and ( $log_offset<filesize($log_path) or !isset($log_offset)) )
{
$need_update=TRUE;
$fichier_sauv=fopen($statdisplay_memory_cache2,'wr+');
if (!flock($fichier_sauv,LOCK_EX))
exit('failed to lock memory file ' . $statdisplay_memory_cache2);
}
fclose($file);
require $statdisplay_memory_cache1;
if($_SESSION['need_update'] and ($log_offset < filesize($log_path) or !isset($log_offset))) {
$need_update = TRUE;
$fichier_sauv = fopen($statdisplay_memory_cache2, 'wr+');
if(!flock($fichier_sauv, LOCK_EX))
exit('failed to lock memory file '.$statdisplay_memory_cache2);
}
} else {
fclose($file);
$file = fopen($statdisplay_memory_cache2, 'r');
fseek($file, -2, SEEK_END);
if(fgets($file) == "?>") //fichier 2 correctement ecrit
require $statdisplay_memory_cache2;
fclose($file);
if($_SESSION['need_update'] and ($log_offset < filesize($log_path) or !isset($log_offset))) {
$need_update = TRUE;
$fichier_sauv = fopen($statdisplay_memory_cache1, 'wr+');
if(!flock($fichier_sauv, LOCK_EX))
exit('failed to lock memory file '.$statdisplay_memory_cache1);
}
}
else
} else if(filemtime($statdisplay_memory_cache2) >= filemtime($statdisplay_memory_cache1)) {
$file = fopen($statdisplay_memory_cache2, 'r');
fseek($file, -2, SEEK_END);
if(fgets($file) == "?>") //fichier 2 correctement ecrit
{
fclose($file);
$file=fopen($statdisplay_memory_cache2,'r');
fseek($file,-2,SEEK_END);
if (fgets($file)=="?>") //fichier 2 correctement ecrit
require $statdisplay_memory_cache2;
fclose($file);
require $statdisplay_memory_cache2;
fclose($file);
if ($_SESSION['need_update'] and ( $log_offset<filesize($log_path) or !isset($log_offset)) )
{
$need_update=TRUE;
$fichier_sauv=fopen($statdisplay_memory_cache1,'wr+');
if (!flock($fichier_sauv,LOCK_EX))
exit('failed to lock memory file ' . $statdisplay_memory_cache1);
}
if($_SESSION['need_update'] and ($log_offset < filesize($log_path) or !isset($log_offset))) {
$need_update = TRUE;
$fichier_sauv = fopen($statdisplay_memory_cache1, 'wr+');
if(!flock($fichier_sauv, LOCK_EX))
exit('failed to lock memory file '.$statdisplay_memory_cache1);
}
} else {
fclose($file);
$file = fopen($statdisplay_memory_cache1, 'r');
fseek($file, -2, SEEK_END);
if(fgets($file) == "?>") //fichier 1 correctement ecrit
require $statdisplay_memory_cache1;
fclose($file);
if($_SESSION['need_update'] and ($log_offset < filesize($log_path) or !isset($log_offset))) {
$need_update = TRUE;
$fichier_sauv = fopen($statdisplay_memory_cache2, 'wr+');
if(!flock($fichier_sauv, LOCK_EX))
exit('failed to lock memory file '.$statdisplay_memory_cache2);
}
}
}
else if (filemtime($statdisplay_memory_cache2) >= filemtime($statdisplay_memory_cache1))
{
$file=fopen($statdisplay_memory_cache2,'r');
fseek($file,-2,SEEK_END);
if (fgets($file)=="?>") //fichier 2 correctement ecrit
{
fclose($file);
require $statdisplay_memory_cache2;
if ($_SESSION['need_update'] and ( $log_offset<filesize($log_path) or !isset($log_offset)) )
{
$need_update=TRUE;
$fichier_sauv=fopen($statdisplay_memory_cache1,'wr+');
if (!flock($fichier_sauv,LOCK_EX))
exit('failed to lock memory file '. $statdisplay_memory_cache1);
}
}
else
{
fclose($file);
$file=fopen($statdisplay_memory_cache1,'r');
fseek($file,-2,SEEK_END);
if (fgets($file)=="?>") //fichier 1 correctement ecrit
require $statdisplay_memory_cache1;
fclose($file);
if ($_SESSION['need_update'] and ( $log_offset<filesize($log_path) or !isset($log_offset)) )
{
$need_update=TRUE;
$fichier_sauv=fopen($statdisplay_memory_cache2,'wr+');
if (!flock($fichier_sauv,LOCK_EX))
exit('failed to lock memory file '. $statdisplay_memory_cache2);
}
}
}
else
{
$fichier_sauv=fopen($statdisplay_memory_cache1,'wr+');
if (!flock($fichier_sauv,LOCK_EX))
exit('failed to lock memory file ' . $statdisplay_memory_cache1);
} else {
$fichier_sauv = fopen($statdisplay_memory_cache1, 'wr+');
if(!flock($fichier_sauv, LOCK_EX))
exit('failed to lock memory file '.$statdisplay_memory_cache1);
}
// Writing php file for generation of images
@ -139,9 +119,8 @@ if (!file_exists($statdisplay_resume_histogram))
}
*/
if (isset($log_offset))
fseek($fichier_log,$log_offset,SEEK_SET);
if(isset($log_offset))
fseek($fichier_log, $log_offset, SEEK_SET);
?>

View File

@ -12,60 +12,50 @@
require "./conf/default.php";
require "../../../conf/local.php";
$statdisplay_memory_cache1 = "../../../" . $conf['memory_cache'] . "/statdisplay_memory_cache1.php";
$statdisplay_memory_cache2 = "../../../" . $conf['memory_cache'] . "/statdisplay_memory_cache2.php";
$statdisplay_memory_cache1 = "../../../".$conf['memory_cache']."/statdisplay_memory_cache1.php";
$statdisplay_memory_cache2 = "../../../".$conf['memory_cache']."/statdisplay_memory_cache2.php";
if(!file_exists($statdisplay_memory_cache1)) {
$fichier_sauv = fopen($statdisplay_memory_cache1, 'wr+');
fclose($fichier_sauv);
}
if (!file_exists($statdisplay_memory_cache1))
{
$fichier_sauv=fopen($statdisplay_memory_cache1,'wr+');
fclose($fichier_sauv);
}
if(!file_exists($statdisplay_memory_cache2)) {
$fichier_sauv = fopen($statdisplay_memory_cache2, 'wr+');
fclose($fichier_sauv);
}
if (!file_exists($statdisplay_memory_cache2))
{
$fichier_sauv=fopen($statdisplay_memory_cache2,'wr+');
fclose($fichier_sauv);
}
if(filemtime($statdisplay_memory_cache1) >= filemtime($statdisplay_memory_cache2)) {
$file = fopen($statdisplay_memory_cache1, 'r');
fseek($file, -2, SEEK_END);
if(fgets($file) == "?>") //fichier 1 correctement ecrit
{
fclose($file);
require $statdisplay_memory_cache1;
} else {
fclose($file);
$file = fopen($statdisplay_memory_cache2, 'r');
fseek($file, -2, SEEK_END);
if(fgets($file) == "?>") //fichier 2 correctement ecrit
require $statdisplay_memory_cache2;
if (filemtime($statdisplay_memory_cache1) >= filemtime($statdisplay_memory_cache2))
{
$file=fopen($statdisplay_memory_cache1,'r');
fseek($file,-2,SEEK_END);
if (fgets($file)=="?>") //fichier 1 correctement ecrit
{
fclose($file);
require $statdisplay_memory_cache1;
}
else
{
fclose($file);
$file=fopen($statdisplay_memory_cache2,'r');
fseek($file,-2,SEEK_END);
if (fgets($file)=="?>") //fichier 2 correctement ecrit
require $statdisplay_memory_cache2;
fclose($file);
}
}
else if (filemtime($statdisplay_memory_cache2) >= filemtime($statdisplay_memory_cache1))
{
$file=fopen($statdisplay_memory_cache2,'r');
fseek($file,-2,SEEK_END);
if (fgets($file)=="?>") //fichier 2 correctement ecrit
{
fclose($file);
require $statdisplay_memory_cache2;
}
else
{
fclose($file);
$file=fopen($statdisplay_memory_cache1,'r');
fseek($file,-2,SEEK_END);
if (fgets($file)=="?>") //fichier 1 correctement ecrit
require $statdisplay_memory_cache1;
fclose($file);
}
}
fclose($file);
}
} else if(filemtime($statdisplay_memory_cache2) >= filemtime($statdisplay_memory_cache1)) {
$file = fopen($statdisplay_memory_cache2, 'r');
fseek($file, -2, SEEK_END);
if(fgets($file) == "?>") //fichier 2 correctement ecrit
{
fclose($file);
require $statdisplay_memory_cache2;
} else {
fclose($file);
$file = fopen($statdisplay_memory_cache1, 'r');
fseek($file, -2, SEEK_END);
if(fgets($file) == "?>") //fichier 1 correctement ecrit
require $statdisplay_memory_cache1;
fclose($file);
}
}
?>

View File

@ -3,24 +3,24 @@
* English language file
*/
$lang['accesslog'] = 'Logfile location';
$lang['visit_time'] = 'Visits duration (minutes)';
$lang['accesslog'] = 'Logfile location';
$lang['visit_time'] = 'Visits duration (minutes)';
$lang['top_user_agents_number_of_lines'] = 'Number of lines for the user agents TOP classification';
$lang['top_referers_number_of_lines'] = 'Number of lines for the referrers TOP classification';
$lang['top_kbytes_number_of_lines'] = 'Number of lines for the URLs TOP classification by kbytes';
$lang['top_url_number_of_lines'] = 'Number of lines for the URLs TOP classification by hits';
$lang['top_entries_number_of_lines'] = 'Number of lines for the entries pages TOP classification';
$lang['referer'] = 'Referrers informations';
$lang['auto_compute_stats'] = 'Automatic statistics update';
$lang['regular_use'] = 'Use reguler expressions for referers';
$lang['referer_o_complete_link'] = 'Complete links';
$lang['referer_o_domain'] = 'domain names';
$lang['referer_o_regular_expr'] = 'match with regular expression';
$lang['referer_regular_expr'] = 'Regular expressions used to match refereer';
$lang['user_agent'] = 'display choice for user agents';
$lang['user_agent_o_all_line'] = 'all informations';
$lang['user_agent_o_display'] = 'display engine only';
$lang['user_agent_o_keyword'] = 'keyword search';
$lang['user_agent_keywords'] = 'Keywords used to match user agents';
$lang['line_number'] = 'Lines to analyse per request';
$lang['memory_cache'] = 'Location of dokuwiki\'s cache';
$lang['top_referers_number_of_lines'] = 'Number of lines for the referrers TOP classification';
$lang['top_kbytes_number_of_lines'] = 'Number of lines for the URLs TOP classification by kbytes';
$lang['top_url_number_of_lines'] = 'Number of lines for the URLs TOP classification by hits';
$lang['top_entries_number_of_lines'] = 'Number of lines for the entries pages TOP classification';
$lang['referer'] = 'Referrers informations';
$lang['auto_compute_stats'] = 'Automatic statistics update';
$lang['regular_use'] = 'Use reguler expressions for referers';
$lang['referer_o_complete_link'] = 'Complete links';
$lang['referer_o_domain'] = 'domain names';
$lang['referer_o_regular_expr'] = 'match with regular expression';
$lang['referer_regular_expr'] = 'Regular expressions used to match refereer';
$lang['user_agent'] = 'display choice for user agents';
$lang['user_agent_o_all_line'] = 'all informations';
$lang['user_agent_o_display'] = 'display engine only';
$lang['user_agent_o_keyword'] = 'keyword search';
$lang['user_agent_keywords'] = 'Keywords used to match user agents';
$lang['line_number'] = 'Lines to analyse per request';
$lang['memory_cache'] = 'Location of dokuwiki\'s cache';

View File

@ -3,24 +3,24 @@
* french language file
*/
$lang['accesslog'] = 'Emplacement du fichier de log';
$lang['visit_time'] = 'Temps d\'une visite en minutes';
$lang['accesslog'] = 'Emplacement du fichier de log';
$lang['visit_time'] = 'Temps d\'une visite en minutes';
$lang['top_user_agents_number_of_lines'] = 'Nombre de ligne du classement des navigateurs';
$lang['top_referers_number_of_lines'] = 'Nombre de ligne du classement des referrers';
$lang['top_kbytes_number_of_lines'] = 'Nombre de ligne du classement des urls pas Kbytes';
$lang['top_url_number_of_lines'] = 'Nombre de ligne du classement des urls par hits';
$lang['top_entries_number_of_lines'] = 'Nombre de ligne du classement des pages d\'entrées';
$lang['referer'] = 'Informations sur les refereers';
$lang['auto_compute_stats'] = 'Mise a jour automatique des statistiques';
$lang['referer_o_complete_link'] = 'Liens complets';
$lang['referer_o_domain'] = 'Noms de domaines';
$lang['referer_o_regular_expr'] = 'Par expressions régulières';
$lang['regular_use'] = 'Utiliser les expressions regulières suivantes';
$lang['referer_regular_expr'] = 'Expressions régulières utilisées pour trouver les "refereers"';
$lang['user_agent'] = 'Informations sur les navigateurs';
$lang['user_agent_o_all_line'] = 'toutes';
$lang['user_agent_o_display'] = 'type de navigateur';
$lang['user_agent_o_keyword'] = 'reconnaissance par mots clé';
$lang['user_agent_keywords'] = 'Mots clés utilisés pour reconnaître les navigateurs';
$lang['line_number'] = 'Nombre de lignes à analyser par requête';
$lang['memory_cache'] = 'Emplacement du cache dokuwiki';
$lang['top_referers_number_of_lines'] = 'Nombre de ligne du classement des referrers';
$lang['top_kbytes_number_of_lines'] = 'Nombre de ligne du classement des urls pas Kbytes';
$lang['top_url_number_of_lines'] = 'Nombre de ligne du classement des urls par hits';
$lang['top_entries_number_of_lines'] = 'Nombre de ligne du classement des pages d\'entrées';
$lang['referer'] = 'Informations sur les refereers';
$lang['auto_compute_stats'] = 'Mise a jour automatique des statistiques';
$lang['referer_o_complete_link'] = 'Liens complets';
$lang['referer_o_domain'] = 'Noms de domaines';
$lang['referer_o_regular_expr'] = 'Par expressions régulières';
$lang['regular_use'] = 'Utiliser les expressions regulières suivantes';
$lang['referer_regular_expr'] = 'Expressions régulières utilisées pour trouver les "refereers"';
$lang['user_agent'] = 'Informations sur les navigateurs';
$lang['user_agent_o_all_line'] = 'toutes';
$lang['user_agent_o_display'] = 'type de navigateur';
$lang['user_agent_o_keyword'] = 'reconnaissance par mots clé';
$lang['user_agent_keywords'] = 'Mots clés utilisés pour reconnaître les navigateurs';
$lang['line_number'] = 'Nombre de lignes à analyser par requête';
$lang['memory_cache'] = 'Emplacement du cache dokuwiki';

View File

@ -7,25 +7,23 @@
* @author Thibault Coullet <thibault.coullet@ensi-bourges.fr>
*/
function summary($month)
{
if (isset($_SESSION['statdisplay'][$month]))
{
$tableau=$_SESSION['statdisplay'];
$nb_jours=count($tableau[$month]['jour']['hits']);
$msg= '<table cellspacing="0"> <tr><td colspan="3" class="titre" bgcolor="#BABABA">Monthly statistics for '.str_replace("_"," ",$month).'</td></tr>';
$msg .= '<tr><td align="left">Total hits</td><td colspan="2" align="right">'.$tableau[$month]['resume']['hits'].'</td></tr>
function summary($month) {
if(isset($_SESSION['statdisplay'][$month])) {
$tableau = $_SESSION['statdisplay'];
$nb_jours = count($tableau[$month]['jour']['hits']);
$msg = '<table cellspacing="0"> <tr><td colspan="3" class="titre" bgcolor="#BABABA">Monthly statistics for '.str_replace("_", " ", $month).'</td></tr>';
$msg .= '<tr><td align="left">Total hits</td><td colspan="2" align="right">'.$tableau[$month]['resume']['hits'].'</td></tr>
<tr><td align="left">Total files</td><td colspan="2" align="right">'.$tableau[$month]['resume']['files'].'</td></tr>
<tr><td align="left">Total pages</td><td colspan="2" align="right">'.$tableau[$month]['resume']['pages'].'</td></tr>
<tr><td align="left">Total visits</td><td colspan="2" align="right">'.$tableau[$month]['resume']['visits'].'</td></tr>
<tr><td align="left">Total Kbytes</td><td colspan="2" align="right">'.intval($tableau[$month]['resume']['bytes']).'</td></tr>
<tr><td align="center" bgcolor="#BABABA"></td><td class="titre" bgcolor="#BABABA">avg</td><td class="titre" bgcolor="#BABABA">max</td></tr>
<tr><td align="left">Hits per hours</td><td align="right">'.intval($tableau[$month]['resume']['hits']/24).'</td><td align="right">'.max($tableau[$month]['heure']['hits']).'</td></tr>
<tr><td align="left">Hits per day</td><td align="right">'.intval($tableau[$month]['resume']['hits']/$nb_jours).'</td><td align="right">'.max($tableau[$month]['jour']['hits']).'</td></tr>
<tr><td align="left">Files per day</td><td align="right">'.intval($tableau[$month]['resume']['files']/$nb_jours).'</td><td align="right">'.max($tableau[$month]['jour']['files']).'</td></tr>
<tr><td align="left">Pages per day</td><td align="right">'.intval($tableau[$month]['resume']['pages']/$nb_jours).'</td><td align="right">'.max($tableau[$month]['jour']['pages']).'</td></tr>
<tr><td align="left">Visits per day</td><td align="right">'.intval($tableau[$month]['resume']['visits']/$nb_jours).'</td><td align="right">'.max($tableau[$month]['jour']['visits']).'</td></tr>
<tr><td align="left">Kbytes per day</td><td align="right">'.intval($tableau[$month]['resume']['bytes']/$nb_jours).'</td><td align="right">'.intval(max($tableau[$month]['jour']['bytes'])).'</td></tr>
<tr><td align="left">Hits per hours</td><td align="right">'.intval($tableau[$month]['resume']['hits'] / 24).'</td><td align="right">'.max($tableau[$month]['heure']['hits']).'</td></tr>
<tr><td align="left">Hits per day</td><td align="right">'.intval($tableau[$month]['resume']['hits'] / $nb_jours).'</td><td align="right">'.max($tableau[$month]['jour']['hits']).'</td></tr>
<tr><td align="left">Files per day</td><td align="right">'.intval($tableau[$month]['resume']['files'] / $nb_jours).'</td><td align="right">'.max($tableau[$month]['jour']['files']).'</td></tr>
<tr><td align="left">Pages per day</td><td align="right">'.intval($tableau[$month]['resume']['pages'] / $nb_jours).'</td><td align="right">'.max($tableau[$month]['jour']['pages']).'</td></tr>
<tr><td align="left">Visits per day</td><td align="right">'.intval($tableau[$month]['resume']['visits'] / $nb_jours).'</td><td align="right">'.max($tableau[$month]['jour']['visits']).'</td></tr>
<tr><td align="left">Kbytes per day</td><td align="right">'.intval($tableau[$month]['resume']['bytes'] / $nb_jours).'</td><td align="right">'.intval(max($tableau[$month]['jour']['bytes'])).'</td></tr>
<tr><td colspan="3" class="titre" bgcolor="#BABABA">Hits by response code</td></tr>
<tr><td align="left">Code 200 OK</td><td colspan="2" align="right">'.$tableau[$month]['resume']['200'].'</td></tr>
<tr><td align="left">Code 206 Partial content</td><td colspan="2" align="right">'.$tableau[$month]['resume']['206'].'</td></tr>
@ -36,7 +34,8 @@ $msg .= '<tr><td align="left">Total hits</td><td colspan="2" align="right">'.$t
<tr><td align="left">Code 404 Not found</td><td colspan="2" align="right">'.$tableau[$month]['resume']['404'].'</td></tr>
<tr><td align="left">Code 408 Request timeout</td><td colspan="2" align="right">'.$tableau[$month]['resume']['408'].'</td></tr>
</table>';
return $msg;
}
return $msg;
}
}
?>

View File

@ -7,78 +7,78 @@
* @author Thibault Coullet <thibault.coullet@ensi-bourges.fr>
*/
function draw_loading_bar($im, $x, $y, $width, $height) {
$blue = ImageColorAllocate($im, 0, 0, 255);
$clear_blue = ImageColorAllocate($im, 120, 120, 250);
$size = min($width, $height);
function draw_loading_bar($im,$x,$y,$width,$height)
{
$blue=ImageColorAllocate($im,0,0,255);
$clear_blue=ImageColorAllocate($im,120,120,250);
$size=min($width,$height);
while($x < $width) {
$clear_blue_poly = array(
$x, $y,
$x + $size, $y,
$x, $y + $size,
);
ImageFilledPolygon($im, $clear_blue_poly, 3, $clear_blue);
while($x<$width)
{
$clear_blue_poly=array($x,$y,
$x+$size,$y,
$x,$y+$size,
);
ImageFilledPolygon($im, $clear_blue_poly, 3, $clear_blue);
$blue_poly = array(
$x + $size, $y,
$x + $size, $y + $size,
$x, $y + $size
);
ImageFilledPolygon($im, $blue_poly, 3, $blue);
$blue_poly=array($x+$size,$y,
$x+$size,$y+$size,
$x,$y+$size
);
ImageFilledPolygon($im, $blue_poly, 3, $blue);
$blue_poly = array(
$x + $size, $y,
$x + $size + $size, $y,
$x + $size, $y + $size,
);
ImageFilledPolygon($im, $blue_poly, 3, $blue);
$blue_poly=array($x+$size,$y,
$x+$size+$size,$y,
$x+$size,$y+$size,
);
ImageFilledPolygon($im, $blue_poly, 3, $blue);
$clear_blue_poly = array(
$x + $size + $size, $y,
$x + $size + $size, $y + $size,
$x + $size, $y + $size
);
ImageFilledPolygon($im, $clear_blue_poly, 3, $clear_blue);
$clear_blue_poly=array($x+$size+$size,$y,
$x+$size+$size,$y+$size,
$x+$size,$y+$size
);
ImageFilledPolygon($im, $clear_blue_poly, 3, $clear_blue);
$x=$x+2*$size;
}
$x = $x + 2 * $size;
}
}
function draw_white_bar($im,$x,$y,$width,$height,$value,$max)
{
$white=ImageColorAllocate($im,255,255,255);
$x2=$x+$width;
$x=$x+($value/$max*$width);
function draw_white_bar($im, $x, $y, $width, $height, $value, $max) {
$white = ImageColorAllocate($im, 255, 255, 255);
$x2 = $x + $width;
$x = $x + ($value / $max * $width);
imagefilledrectangle($im,$x,$y,$x2,$y+$height,$white);
imagefilledrectangle($im, $x, $y, $x2, $y + $height, $white);
}
function loading($img_width,$img_height,$value,$max)
{
header("Content-type: image/png");
// Create image and Set the colors
$img_width=max($img_width,260);
$img_height=max($img_height,30);
$im=imagecreatetruecolor(intval($img_width),intval($img_height));
$blue=ImageColorAllocate($im,0,0,255);
$white=ImageColorAllocate($im,255,255,255);
$grey=ImageColorAllocate($im,155,155,155);
$black=ImageColorAllocate($im,0,0,0);
imagefill($im,0,0,$white);
$padding=20;
draw_loading_bar($im,0,0,$img_width,$img_height-$padding);
draw_white_bar($im,0,0,$img_width,$img_height-$padding,$value,$max);
imagerectangle($im,0,0,$img_width-1,$img_height-$padding,$grey);
$caption="Percentage of logfile analyzed : ".number_format(($value/$max*100))."%";
$x=$img_width/2-strlen($caption)*3.5;
imagestring($im, 3, $x, $img_height-15, $caption, $black);
function loading($img_width, $img_height, $value, $max) {
header("Content-type: image/png");
// Create image and Set the colors
$img_width = max($img_width, 260);
$img_height = max($img_height, 30);
$im = imagecreatetruecolor(intval($img_width), intval($img_height));
$blue = ImageColorAllocate($im, 0, 0, 255);
$white = ImageColorAllocate($im, 255, 255, 255);
$grey = ImageColorAllocate($im, 155, 155, 155);
$black = ImageColorAllocate($im, 0, 0, 0);
imagefill($im, 0, 0, $white);
imagepng($im); //Show the histogram created
imagedestroy($im); //Free the memory and destroy the histogram
$padding = 20;
draw_loading_bar($im, 0, 0, $img_width, $img_height - $padding);
draw_white_bar($im, 0, 0, $img_width, $img_height - $padding, $value, $max);
imagerectangle($im, 0, 0, $img_width - 1, $img_height - $padding, $grey);
$caption = "Percentage of logfile analyzed : ".number_format(($value / $max * 100))."%";
$x = $img_width / 2 - strlen($caption) * 3.5;
imagestring($im, 3, $x, $img_height - 15, $caption, $black);
imagepng($im); //Show the histogram created
imagedestroy($im); //Free the memory and destroy the histogram
}
loading(10,10,$_GET['value'],$_GET['max']);
loading(10, 10, $_GET['value'], $_GET['max']);
?>

View File

@ -7,253 +7,238 @@
* @author Thibault Coullet <thibault.coullet@ensi-bourges.fr>
*/
function draw_bar($im,$top_left_x,$top_left_y,$width,$height,$scale,$value,$color)
{
$black=ImageColorAllocate($im,0,0,0);
$y1=$top_left_y+$height-($scale*$value);
$x2=$top_left_x+$width;
$y2=$top_left_y+$height;
imagefilledrectangle($im,$top_left_x,$y1,$x2,$y2,$color);
imagerectangle($im,$top_left_x,$y1,$x2,$y2,$black);
function draw_bar($im, $top_left_x, $top_left_y, $width, $height, $scale, $value, $color) {
$black = ImageColorAllocate($im, 0, 0, 0);
$y1 = $top_left_y + $height - ($scale * $value);
$x2 = $top_left_x + $width;
$y2 = $top_left_y + $height;
imagefilledrectangle($im, $top_left_x, $y1, $x2, $y2, $color);
imagerectangle($im, $top_left_x, $y1, $x2, $y2, $black);
}
function make_total_histogram($im,$top_left_x,$top_left_y,$width,$height,$padding,$datas)
{
$width=$width-2*$padding;
$height=$height-2*$padding;
$top_left_x=$top_left_x+$padding;
$top_left_y=$top_left_y+$padding;
function make_total_histogram($im, $top_left_x, $top_left_y, $width, $height, $padding, $datas) {
$width = $width - 2 * $padding;
$height = $height - 2 * $padding;
$top_left_x = $top_left_x + $padding;
$top_left_y = $top_left_y + $padding;
// Set the colors
$blue = ImageColorAllocate($im, 0, 0, 255);
$dark_green = ImageColorAllocate($im, 0, 125, 0);
$clear_blue = ImageColorAllocate($im, 100, 255, 240);
$black = ImageColorAllocate($im, 0, 0, 0);
// Set the colors
$blue=ImageColorAllocate($im,0,0,255);
$dark_green=ImageColorAllocate($im,0,125,0);
$clear_blue=ImageColorAllocate($im,100,255,240);
$black=ImageColorAllocate($im,0,0,0);
$max = 0;
$max=0;
//Find all maximums
foreach($datas as $sub_tab) {
$max = max($max, $sub_tab['resume']['hits'], $sub_tab['resume']['files'], $sub_tab['resume']['pages']);
}
$scale = $height / $max;
//Find all maximums
foreach($datas as $sub_tab)
{
$max=max($max,$sub_tab['resume']['hits'],$sub_tab['resume']['files'],$sub_tab['resume']['pages']);
}
$scale=$height/$max;
//Show lengend
imagestringup($im, 3, $top_left_x - $padding - 15, $top_left_y + $height, 'Pages', $clear_blue);
imagestringup($im, 2, $top_left_x - $padding - 15, $top_left_y + $height - 38, '/', $black);
imagestringup($im, 3, $top_left_x - $padding - 15, $top_left_y + $height - 48, 'Files', $blue);
imagestringup($im, 2, $top_left_x - $padding - 15, $top_left_y + $height - 85, '/', $black);
imagestringup($im, 3, $top_left_x - $padding - 15, $top_left_y + $height - 95, 'Hits', $dark_green);
imagestringup($im, 2, $top_left_x - $padding - 15, $top_left_y - $padding + strlen($max) * 6, $max, $black);
//Show lengend
imagestringup($im,3,$top_left_x-$padding-15,$top_left_y+$height,'Pages',$clear_blue);
imagestringup($im,2,$top_left_x-$padding-15,$top_left_y+$height-38,'/',$black);
imagestringup($im,3,$top_left_x-$padding-15,$top_left_y+$height-48,'Files',$blue);
imagestringup($im,2,$top_left_x-$padding-15,$top_left_y+$height-85,'/',$black);
imagestringup($im,3,$top_left_x-$padding-15,$top_left_y+$height-95,'Hits',$dark_green);
imagestringup($im,2,$top_left_x-$padding-15,$top_left_y-$padding+strlen($max)*6,$max,$black);
$part_width = $width / count($datas);
$part_spacing = 0.2 * $part_width;
$bar_offset = intval($part_spacing);
$bar_width = ($part_width - $part_spacing) - ($bar_offset * 2);
$part_width=$width/count($datas);
$part_spacing=0.2*$part_width;
$bar_offset=intval($part_spacing);
$bar_width=($part_width-$part_spacing)-($bar_offset*2);
//Draw the Histogram
$i=0;
foreach($datas as $key => $sub_tab)
{
$key=explode("_",$key);
$key=$key[0];
foreach($sub_tab['resume'] as $sub_key => $value)
{
if($sub_key == "hits")
$hits_value=$value;
if($sub_key == "files")
$files_value=$value;
if($sub_key == "pages")
$pages_value=$value;
}
draw_bar($im,$top_left_x+$i*$part_width,$top_left_y,$bar_width,$height,$scale,$hits_value,$dark_green);
draw_bar($im,($top_left_x+$i*$part_width)+$bar_offset,$top_left_y,$bar_width,$height,$scale,$files_value,$blue);
draw_bar($im,($top_left_x+$i*$part_width)+2*$bar_offset,$top_left_y,$bar_width,$height,$scale,$pages_value,$clear_blue);
imagestring($im,2,($top_left_x+$i*$part_width)+(($part_width-$part_spacing)/2)-10,$top_left_y+$height+$padding+2,$key,$black);
$i++;
}
//Draw the Histogram
$i = 0;
foreach($datas as $key => $sub_tab) {
$key = explode("_", $key);
$key = $key[0];
foreach($sub_tab['resume'] as $sub_key => $value) {
if($sub_key == "hits")
$hits_value = $value;
if($sub_key == "files")
$files_value = $value;
if($sub_key == "pages")
$pages_value = $value;
}
draw_bar($im, $top_left_x + $i * $part_width, $top_left_y, $bar_width, $height, $scale, $hits_value, $dark_green);
draw_bar($im, ($top_left_x + $i * $part_width) + $bar_offset, $top_left_y, $bar_width, $height, $scale, $files_value, $blue);
draw_bar($im, ($top_left_x + $i * $part_width) + 2 * $bar_offset, $top_left_y, $bar_width, $height, $scale, $pages_value, $clear_blue);
imagestring($im, 2, ($top_left_x + $i * $part_width) + (($part_width - $part_spacing) / 2) - 10, $top_left_y + $height + $padding + 2, $key, $black);
$i++;
}
}
function make_total_visits_histogram($im,$top_left_x,$top_left_y,$width,$height,$padding,$datas)
{
$width=$width-2*$padding;
$height=$height-2*$padding;
$top_left_x=$top_left_x+$padding;
$top_left_y=$top_left_y+$padding;
function make_total_visits_histogram($im, $top_left_x, $top_left_y, $width, $height, $padding, $datas) {
$width = $width - 2 * $padding;
$height = $height - 2 * $padding;
$top_left_x = $top_left_x + $padding;
$top_left_y = $top_left_y + $padding;
// Set the colors
$yellow = ImageColorAllocate($im, 255, 255, 0);
$black = ImageColorAllocate($im, 0, 0, 0);
// Set the colors
$yellow=ImageColorAllocate($im,255,255,0);
$black=ImageColorAllocate($im,0,0,0);
$max = 0;
$max=0;
//Find the maximum
foreach($datas as $sub_tab) {
$max = max($max, $sub_tab['resume']['visits']);
}
$scale = $height / $max;
//Find the maximum
foreach($datas as $sub_tab)
{
$max=max($max,$sub_tab['resume']['visits']);
}
$scale=$height/$max;
//Show lengend
imagestring($im, 3, $top_left_x + $width - 30, $top_left_y - $padding - 15, 'Visits', $yellow);
imagestringup($im, 2, $top_left_x + $width + $padding, $top_left_y - $padding + strlen($max) * 6, $max, $black);
//Show lengend
imagestring($im,3,$top_left_x+$width-30,$top_left_y-$padding-15,'Visits',$yellow);
imagestringup($im,2,$top_left_x+$width+$padding,$top_left_y-$padding+strlen($max)*6,$max,$black);
$part_width = $width / count($datas);
$part_spacing = 0.2 * $part_width;
$part_width=$width/count($datas);
$part_spacing=0.2*$part_width;
//Draw the Histogram
$i=0;
foreach($datas as $key => $sub_tab)
{
draw_bar($im,$top_left_x+$i*$part_width,$top_left_y,$part_width-$part_spacing,$height,$scale,$sub_tab['resume']['visits'],$yellow);
$i++;
}
//Draw the Histogram
$i = 0;
foreach($datas as $key => $sub_tab) {
draw_bar($im, $top_left_x + $i * $part_width, $top_left_y, $part_width - $part_spacing, $height, $scale, $sub_tab['resume']['visits'], $yellow);
$i++;
}
}
function make_total_bytes_histogram($im,$top_left_x,$top_left_y,$width,$height,$padding,$datas)
{
$width=$width-2*$padding;
$height=$height-2*$padding;
$top_left_x=$top_left_x+$padding;
$top_left_y=$top_left_y+$padding;
function make_total_bytes_histogram($im, $top_left_x, $top_left_y, $width, $height, $padding, $datas) {
$width = $width - 2 * $padding;
$height = $height - 2 * $padding;
$top_left_x = $top_left_x + $padding;
$top_left_y = $top_left_y + $padding;
// Set the colors
$red = ImageColorAllocate($im, 255, 0, 0);
$black = ImageColorAllocate($im, 0, 0, 0);
// Set the colors
$red=ImageColorAllocate($im,255,0,0);
$black=ImageColorAllocate($im,0,0,0);
$max = 0;
$max=0;
//Find the maximum
foreach($datas as $sub_tab) {
$max = max($max, $sub_tab['resume']['bytes']);
}
//Find the maximum
foreach($datas as $sub_tab)
{
$max=max($max,$sub_tab['resume']['bytes']);
}
$scale=$height/$max;
$scale = $height / $max;
//Show lengend
imagestring($im,3,$top_left_x+$width-30,$top_left_y+$padding+$height,'KBytes',$red);
imagestringup($im,2,$top_left_x+$width+$padding,$top_left_y-$padding+strlen(intval($max))*6,intval($max),$black);
//Show lengend
imagestring($im, 3, $top_left_x + $width - 30, $top_left_y + $padding + $height, 'KBytes', $red);
imagestringup($im, 2, $top_left_x + $width + $padding, $top_left_y - $padding + strlen(intval($max)) * 6, intval($max), $black);
$part_width=$width/count($datas);
$part_spacing=0.2*$part_width;
//Draw the Histogram
$i=0;
foreach($datas as $key => $sub_tab)
{
draw_bar($im,$top_left_x+$i*$part_width,$top_left_y,$part_width-$part_spacing,$height,$scale,$sub_tab['resume']['bytes'],$red);
$i++;
}
$part_width = $width / count($datas);
$part_spacing = 0.2 * $part_width;
//Draw the Histogram
$i = 0;
foreach($datas as $key => $sub_tab) {
draw_bar($im, $top_left_x + $i * $part_width, $top_left_y, $part_width - $part_spacing, $height, $scale, $sub_tab['resume']['bytes'], $red);
$i++;
}
}
function draw_border($im,$top_left_x,$top_left_y,$top_right_x,$top_right_y,$bottom_left_x,$bottom_left_y)
{
// Set the colors
$hard_grey=ImageColorAllocate($im,80,80,80);
$white=ImageColorAllocate($im,255,255,255);
$black=ImageColorAllocate($im,0,0,0);
function draw_border($im, $top_left_x, $top_left_y, $top_right_x, $top_right_y, $bottom_left_x, $bottom_left_y) {
// Set the colors
$hard_grey = ImageColorAllocate($im, 80, 80, 80);
$white = ImageColorAllocate($im, 255, 255, 255);
$black = ImageColorAllocate($im, 0, 0, 0);
//A black and white border
imageline($im,$top_left_x,$top_left_y,$top_right_x,$top_right_y,$white);
imageline($im,$top_right_x,$top_right_y,$top_right_x,$bottom_left_y,$white);
imageline($im,$top_right_x,$bottom_left_y,$bottom_left_x,$bottom_left_y,$white);
imageline($im,$bottom_left_x,$bottom_left_y,$top_left_x,$top_left_y,$white);
imageline($im,$top_left_x+1,$top_left_y+1,$top_right_x-1,$top_right_y+1,$black);
imageline($im,$top_right_x+1,$top_right_y+1,$top_right_x+1,$bottom_left_y+1,$black);
imageline($im,$top_right_x+1,$bottom_left_y+1,$bottom_left_x+1,$bottom_left_y+1,$black);
imageline($im,$bottom_left_x+1,$bottom_left_y-1,$top_left_x+1,$top_left_y+1,$black);
//A black and white border
imageline($im, $top_left_x, $top_left_y, $top_right_x, $top_right_y, $white);
imageline($im, $top_right_x, $top_right_y, $top_right_x, $bottom_left_y, $white);
imageline($im, $top_right_x, $bottom_left_y, $bottom_left_x, $bottom_left_y, $white);
imageline($im, $bottom_left_x, $bottom_left_y, $top_left_x, $top_left_y, $white);
imageline($im, $top_left_x + 1, $top_left_y + 1, $top_right_x - 1, $top_right_y + 1, $black);
imageline($im, $top_right_x + 1, $top_right_y + 1, $top_right_x + 1, $bottom_left_y + 1, $black);
imageline($im, $top_right_x + 1, $bottom_left_y + 1, $bottom_left_x + 1, $bottom_left_y + 1, $black);
imageline($im, $bottom_left_x + 1, $bottom_left_y - 1, $top_left_x + 1, $top_left_y + 1, $black);
//A scale drawn in the background
$scale_y=$top_left_y+(($bottom_left_y-$top_left_y)/3);
imageline($im,$top_left_x+2,$scale_y,$top_right_x-1,$scale_y,$hard_grey);
$scale_y=$top_left_y+2*(($bottom_left_y-$top_left_y)/3);
imageline($im,$top_left_x+2,$scale_y,$top_right_x-1,$scale_y,$hard_grey);
//A scale drawn in the background
$scale_y = $top_left_y + (($bottom_left_y - $top_left_y) / 3);
imageline($im, $top_left_x + 2, $scale_y, $top_right_x - 1, $scale_y, $hard_grey);
$scale_y = $top_left_y + 2 * (($bottom_left_y - $top_left_y) / 3);
imageline($im, $top_left_x + 2, $scale_y, $top_right_x - 1, $scale_y, $hard_grey);
}
function total_histogram($total_tab,$img_width,$img_height,$caption)
{
header("Content-type: image/png");
function total_histogram($total_tab, $img_width, $img_height, $caption) {
header("Content-type: image/png");
// Create image and Set the colors
$im=imagecreatetruecolor(intval($img_width),intval($img_height));
$grey=ImageColorAllocate($im,180,180,180);
$little_grey=ImageColorAllocate($im,220,220,220);
$hard_grey=ImageColorAllocate($im,60,60,60);
$blue=ImageColorAllocate($im,0,0,255);
// Create image and Set the colors
$im = imagecreatetruecolor(intval($img_width), intval($img_height));
$grey = ImageColorAllocate($im, 180, 180, 180);
$little_grey = ImageColorAllocate($im, 220, 220, 220);
$hard_grey = ImageColorAllocate($im, 60, 60, 60);
$blue = ImageColorAllocate($im, 0, 0, 255);
$margin=20; //graph margin
$padding=10; //Histogram padding
$border_size=3; //main border size
$ratio=0.66;
$margin = 20; //graph margin
$padding = 10; //Histogram padding
$border_size = 3; //main border size
$ratio = 0.66;
//Fill the graph with grey background
$im=imagecreatetruecolor(intval($img_width),intval($img_height));
imagefill($im,0,0,$grey);
//Fill the graph with grey background
$im = imagecreatetruecolor(intval($img_width), intval($img_height));
imagefill($im, 0, 0, $grey);
//Color the first part of the main border
$borger_top_left=array(0,$img_height,
0,0,
$img_width,0,
$img_width-$border_size,$border_size,
$border_size,$border_size,
$border_size,$img_height-$border_size,
);
ImageFilledPolygon($im, $borger_top_left, 6, $little_grey);
//Color the second part of the main border
$border_top_right=array(0,$img_height,
$img_width,$img_height,
$img_width,0,
$img_width-$border_size,$border_size,
$img_width-$border_size,$img_height-$border_size,
$border_size,$img_height-$border_size,
);
ImageFilledPolygon($im,$border_top_right,6,$hard_grey);
//Color the first part of the main border
$borger_top_left = array(
0, $img_height,
0, 0,
$img_width, 0,
$img_width - $border_size, $border_size,
$border_size, $border_size,
$border_size, $img_height - $border_size,
);
ImageFilledPolygon($im, $borger_top_left, 6, $little_grey);
//writing caption
imagestring($im, 3, $margin, 6, $caption, $blue);
//Color the second part of the main border
$border_top_right = array(
0, $img_height,
$img_width, $img_height,
$img_width, 0,
$img_width - $border_size, $border_size,
$img_width - $border_size, $img_height - $border_size,
$border_size, $img_height - $border_size,
);
ImageFilledPolygon($im, $border_top_right, 6, $hard_grey);
//create 3 borders for 3 histograms
draw_border($im,$margin,$margin,$margin+(($img_width-2*$margin)*$ratio),$margin,$margin,$img_height-$margin);
make_total_histogram($im,$margin,$margin,($img_width-2*$margin)*$ratio,$img_height-2*$margin,$padding,$total_tab);
draw_border($im,$margin+(($img_width-2*$margin)*$ratio),$margin,$img_width-$margin,$margin,$margin+(($img_width-2*$margin)*$ratio),$margin+(($img_height-2*$margin)/2));
make_total_visits_histogram($im,$margin+(($img_width-2*$margin)*$ratio),$margin,($img_width-2*$margin)*(1-$ratio),($img_height-2*$margin)/2,$padding,$total_tab);
draw_border($im,$margin+(($img_width-2*$margin)*$ratio),$margin+(($img_height-2*$margin)/2),$img_width-$margin,$margin+(($img_height-2*$margin)/2),$margin+(($img_width-2*$margin)*$ratio),$img_height-$margin);
make_total_bytes_histogram($im,$margin+(($img_width-2*$margin)*$ratio),$margin+(($img_height-2*$margin)/2),($img_width-2*$margin)*(1-$ratio),($img_height-2*$margin)/2,$padding,$total_tab);
imagepng($im); //Show the histogram created
imagedestroy($im); //Free the memory and destroy the histogram
//writing caption
imagestring($im, 3, $margin, 6, $caption, $blue);
//create 3 borders for 3 histograms
draw_border($im, $margin, $margin, $margin + (($img_width - 2 * $margin) * $ratio), $margin, $margin, $img_height - $margin);
make_total_histogram($im, $margin, $margin, ($img_width - 2 * $margin) * $ratio, $img_height - 2 * $margin, $padding, $total_tab);
draw_border($im, $margin + (($img_width - 2 * $margin) * $ratio), $margin, $img_width - $margin, $margin, $margin + (($img_width - 2 * $margin) * $ratio), $margin + (($img_height - 2 * $margin) / 2));
make_total_visits_histogram($im, $margin + (($img_width - 2 * $margin) * $ratio), $margin, ($img_width - 2 * $margin) * (1 - $ratio), ($img_height - 2 * $margin) / 2, $padding, $total_tab);
draw_border($im, $margin + (($img_width - 2 * $margin) * $ratio), $margin + (($img_height - 2 * $margin) / 2), $img_width - $margin, $margin + (($img_height - 2 * $margin) / 2), $margin + (($img_width - 2 * $margin) * $ratio), $img_height - $margin);
make_total_bytes_histogram($im, $margin + (($img_width - 2 * $margin) * $ratio), $margin + (($img_height - 2 * $margin) / 2), ($img_width - 2 * $margin) * (1 - $ratio), ($img_height - 2 * $margin) / 2, $padding, $total_tab);
imagepng($im); //Show the histogram created
imagedestroy($im); //Free the memory and destroy the histogram
}
include 'init_gd.php';
if($_GET['begin']=="")
$new_tab=$tableau;
if($_GET['begin'] == "")
$new_tab = $tableau;
//Cut the table to the interesting part
if($_GET['begin']!="")
{
$flag=0;
$end_flag=0;
foreach($tableau as $key => $sub_tab)
{
if($flag==0 AND $key==$_GET['begin'])
$flag=1;
if($flag==1 AND $_GET['end']!="" AND $key==$_GET['end'])
$end_flag=1;
if($end_flag==1 AND $key!=$_GET['end'])
$flag=0;
if($flag==1)
$new_tab[$key]=$sub_tab;
}
if($_GET['begin'] != "") {
$flag = 0;
$end_flag = 0;
foreach($tableau as $key => $sub_tab) {
if($flag == 0 AND $key == $_GET['begin'])
$flag = 1;
if($flag == 1 AND $_GET['end'] != "" AND $key == $_GET['end'])
$end_flag = 1;
if($end_flag == 1 AND $key != $_GET['end'])
$flag = 0;
if($flag == 1)
$new_tab[$key] = $sub_tab;
}
}
total_histogram($new_tab,550,300,'Usage summary for '.$_SERVER['SERVER_NAME']);
total_histogram($new_tab, 550, 300, 'Usage summary for '.$_SERVER['SERVER_NAME']);
?>

View File

@ -7,253 +7,238 @@
* @author Thibault Coullet <thibault.coullet@ensi-bourges.fr>
*/
function draw_bar($im,$top_left_x,$top_left_y,$width,$height,$scale,$value,$color)
{
$black=ImageColorAllocate($im,0,0,0);
$y1=$top_left_y+$height-($scale*$value);
$x2=$top_left_x+$width;
$y2=$top_left_y+$height;
imagefilledrectangle($im,$top_left_x,$y1,$x2,$y2,$color);
imagerectangle($im,$top_left_x,$y1,$x2,$y2,$black);
function draw_bar($im, $top_left_x, $top_left_y, $width, $height, $scale, $value, $color) {
$black = ImageColorAllocate($im, 0, 0, 0);
$y1 = $top_left_y + $height - ($scale * $value);
$x2 = $top_left_x + $width;
$y2 = $top_left_y + $height;
imagefilledrectangle($im, $top_left_x, $y1, $x2, $y2, $color);
imagerectangle($im, $top_left_x, $y1, $x2, $y2, $black);
}
function make_total_histogram($im,$top_left_x,$top_left_y,$width,$height,$padding,$datas)
{
$width=$width-2*$padding;
$height=$height-2*$padding;
$top_left_x=$top_left_x+$padding;
$top_left_y=$top_left_y+$padding;
function make_total_histogram($im, $top_left_x, $top_left_y, $width, $height, $padding, $datas) {
$width = $width - 2 * $padding;
$height = $height - 2 * $padding;
$top_left_x = $top_left_x + $padding;
$top_left_y = $top_left_y + $padding;
// Set the colors
$blue = ImageColorAllocate($im, 0, 0, 255);
$dark_green = ImageColorAllocate($im, 0, 125, 0);
$clear_blue = ImageColorAllocate($im, 100, 255, 240);
$black = ImageColorAllocate($im, 0, 0, 0);
// Set the colors
$blue=ImageColorAllocate($im,0,0,255);
$dark_green=ImageColorAllocate($im,0,125,0);
$clear_blue=ImageColorAllocate($im,100,255,240);
$black=ImageColorAllocate($im,0,0,0);
$max = 0;
$max=0;
//Find all maximums
foreach($datas as $sub_tab) {
$max = max($max, $sub_tab['resume']['hits'], $sub_tab['resume']['files'], $sub_tab['resume']['pages']);
}
$scale = $height / $max;
//Find all maximums
foreach($datas as $sub_tab)
{
$max=max($max,$sub_tab['resume']['hits'],$sub_tab['resume']['files'],$sub_tab['resume']['pages']);
}
$scale=$height/$max;
//Show lengend
imagestringup($im, 3, $top_left_x - $padding - 15, $top_left_y + $height, 'Pages', $clear_blue);
imagestringup($im, 2, $top_left_x - $padding - 15, $top_left_y + $height - 38, '/', $black);
imagestringup($im, 3, $top_left_x - $padding - 15, $top_left_y + $height - 48, 'Files', $blue);
imagestringup($im, 2, $top_left_x - $padding - 15, $top_left_y + $height - 85, '/', $black);
imagestringup($im, 3, $top_left_x - $padding - 15, $top_left_y + $height - 95, 'Hits', $dark_green);
imagestringup($im, 2, $top_left_x - $padding - 15, $top_left_y - $padding + strlen($max) * 6, $max, $black);
//Show lengend
imagestringup($im,3,$top_left_x-$padding-15,$top_left_y+$height,'Pages',$clear_blue);
imagestringup($im,2,$top_left_x-$padding-15,$top_left_y+$height-38,'/',$black);
imagestringup($im,3,$top_left_x-$padding-15,$top_left_y+$height-48,'Files',$blue);
imagestringup($im,2,$top_left_x-$padding-15,$top_left_y+$height-85,'/',$black);
imagestringup($im,3,$top_left_x-$padding-15,$top_left_y+$height-95,'Hits',$dark_green);
imagestringup($im,2,$top_left_x-$padding-15,$top_left_y-$padding+strlen($max)*6,$max,$black);
$part_width = $width / count($datas);
$part_spacing = 0.2 * $part_width;
$bar_offset = intval($part_spacing);
$bar_width = ($part_width - $part_spacing) - ($bar_offset * 2);
$part_width=$width/count($datas);
$part_spacing=0.2*$part_width;
$bar_offset=intval($part_spacing);
$bar_width=($part_width-$part_spacing)-($bar_offset*2);
//Draw the Histogram
$i=0;
foreach($datas as $key => $sub_tab)
{
$key=explode("_",$key);
$key=$key[0];
foreach($sub_tab['resume'] as $sub_key => $value)
{
if($sub_key == "hits")
$hits_value=$value;
if($sub_key == "files")
$files_value=$value;
if($sub_key == "pages")
$pages_value=$value;
}
draw_bar($im,$top_left_x+$i*$part_width,$top_left_y,$bar_width,$height,$scale,$hits_value,$dark_green);
draw_bar($im,($top_left_x+$i*$part_width)+$bar_offset,$top_left_y,$bar_width,$height,$scale,$files_value,$blue);
draw_bar($im,($top_left_x+$i*$part_width)+2*$bar_offset,$top_left_y,$bar_width,$height,$scale,$pages_value,$clear_blue);
imagestring($im,2,($top_left_x+$i*$part_width)+(($part_width-$part_spacing)/2)-10,$top_left_y+$height+$padding+2,$key,$black);
$i++;
}
//Draw the Histogram
$i = 0;
foreach($datas as $key => $sub_tab) {
$key = explode("_", $key);
$key = $key[0];
foreach($sub_tab['resume'] as $sub_key => $value) {
if($sub_key == "hits")
$hits_value = $value;
if($sub_key == "files")
$files_value = $value;
if($sub_key == "pages")
$pages_value = $value;
}
draw_bar($im, $top_left_x + $i * $part_width, $top_left_y, $bar_width, $height, $scale, $hits_value, $dark_green);
draw_bar($im, ($top_left_x + $i * $part_width) + $bar_offset, $top_left_y, $bar_width, $height, $scale, $files_value, $blue);
draw_bar($im, ($top_left_x + $i * $part_width) + 2 * $bar_offset, $top_left_y, $bar_width, $height, $scale, $pages_value, $clear_blue);
imagestring($im, 2, ($top_left_x + $i * $part_width) + (($part_width - $part_spacing) / 2) - 10, $top_left_y + $height + $padding + 2, $key, $black);
$i++;
}
}
function make_total_visits_histogram($im,$top_left_x,$top_left_y,$width,$height,$padding,$datas)
{
$width=$width-2*$padding;
$height=$height-2*$padding;
$top_left_x=$top_left_x+$padding;
$top_left_y=$top_left_y+$padding;
function make_total_visits_histogram($im, $top_left_x, $top_left_y, $width, $height, $padding, $datas) {
$width = $width - 2 * $padding;
$height = $height - 2 * $padding;
$top_left_x = $top_left_x + $padding;
$top_left_y = $top_left_y + $padding;
// Set the colors
$yellow = ImageColorAllocate($im, 255, 255, 0);
$black = ImageColorAllocate($im, 0, 0, 0);
// Set the colors
$yellow=ImageColorAllocate($im,255,255,0);
$black=ImageColorAllocate($im,0,0,0);
$max = 0;
$max=0;
//Find the maximum
foreach($datas as $sub_tab) {
$max = max($max, $sub_tab['resume']['visits']);
}
$scale = $height / $max;
//Find the maximum
foreach($datas as $sub_tab)
{
$max=max($max,$sub_tab['resume']['visits']);
}
$scale=$height/$max;
//Show lengend
imagestring($im, 3, $top_left_x + $width - 30, $top_left_y - $padding - 15, 'Visits', $yellow);
imagestringup($im, 2, $top_left_x + $width + $padding, $top_left_y - $padding + strlen($max) * 6, $max, $black);
//Show lengend
imagestring($im,3,$top_left_x+$width-30,$top_left_y-$padding-15,'Visits',$yellow);
imagestringup($im,2,$top_left_x+$width+$padding,$top_left_y-$padding+strlen($max)*6,$max,$black);
$part_width = $width / count($datas);
$part_spacing = 0.2 * $part_width;
$part_width=$width/count($datas);
$part_spacing=0.2*$part_width;
//Draw the Histogram
$i=0;
foreach($datas as $key => $sub_tab)
{
draw_bar($im,$top_left_x+$i*$part_width,$top_left_y,$part_width-$part_spacing,$height,$scale,$sub_tab['resume']['visits'],$yellow);
$i++;
}
//Draw the Histogram
$i = 0;
foreach($datas as $key => $sub_tab) {
draw_bar($im, $top_left_x + $i * $part_width, $top_left_y, $part_width - $part_spacing, $height, $scale, $sub_tab['resume']['visits'], $yellow);
$i++;
}
}
function make_total_bytes_histogram($im,$top_left_x,$top_left_y,$width,$height,$padding,$datas)
{
$width=$width-2*$padding;
$height=$height-2*$padding;
$top_left_x=$top_left_x+$padding;
$top_left_y=$top_left_y+$padding;
function make_total_bytes_histogram($im, $top_left_x, $top_left_y, $width, $height, $padding, $datas) {
$width = $width - 2 * $padding;
$height = $height - 2 * $padding;
$top_left_x = $top_left_x + $padding;
$top_left_y = $top_left_y + $padding;
// Set the colors
$red = ImageColorAllocate($im, 255, 0, 0);
$black = ImageColorAllocate($im, 0, 0, 0);
// Set the colors
$red=ImageColorAllocate($im,255,0,0);
$black=ImageColorAllocate($im,0,0,0);
$max = 0;
$max=0;
//Find the maximum
foreach($datas as $sub_tab) {
$max = max($max, $sub_tab['resume']['bytes']);
}
//Find the maximum
foreach($datas as $sub_tab)
{
$max=max($max,$sub_tab['resume']['bytes']);
}
$scale=$height/$max;
$scale = $height / $max;
//Show lengend
imagestring($im,3,$top_left_x+$width-30,$top_left_y+$padding+$height,'KBytes',$red);
imagestringup($im,2,$top_left_x+$width+$padding,$top_left_y-$padding+strlen(intval($max))*6,intval($max),$black);
//Show lengend
imagestring($im, 3, $top_left_x + $width - 30, $top_left_y + $padding + $height, 'KBytes', $red);
imagestringup($im, 2, $top_left_x + $width + $padding, $top_left_y - $padding + strlen(intval($max)) * 6, intval($max), $black);
$part_width=$width/count($datas);
$part_spacing=0.2*$part_width;
//Draw the Histogram
$i=0;
foreach($datas as $key => $sub_tab)
{
draw_bar($im,$top_left_x+$i*$part_width,$top_left_y,$part_width-$part_spacing,$height,$scale,$sub_tab['resume']['bytes'],$red);
$i++;
}
$part_width = $width / count($datas);
$part_spacing = 0.2 * $part_width;
//Draw the Histogram
$i = 0;
foreach($datas as $key => $sub_tab) {
draw_bar($im, $top_left_x + $i * $part_width, $top_left_y, $part_width - $part_spacing, $height, $scale, $sub_tab['resume']['bytes'], $red);
$i++;
}
}
function draw_border($im,$top_left_x,$top_left_y,$top_right_x,$top_right_y,$bottom_left_x,$bottom_left_y)
{
// Set the colors
$hard_grey=ImageColorAllocate($im,80,80,80);
$white=ImageColorAllocate($im,255,255,255);
$black=ImageColorAllocate($im,0,0,0);
function draw_border($im, $top_left_x, $top_left_y, $top_right_x, $top_right_y, $bottom_left_x, $bottom_left_y) {
// Set the colors
$hard_grey = ImageColorAllocate($im, 80, 80, 80);
$white = ImageColorAllocate($im, 255, 255, 255);
$black = ImageColorAllocate($im, 0, 0, 0);
//A black and white border
imageline($im,$top_left_x,$top_left_y,$top_right_x,$top_right_y,$white);
imageline($im,$top_right_x,$top_right_y,$top_right_x,$bottom_left_y,$white);
imageline($im,$top_right_x,$bottom_left_y,$bottom_left_x,$bottom_left_y,$white);
imageline($im,$bottom_left_x,$bottom_left_y,$top_left_x,$top_left_y,$white);
imageline($im,$top_left_x+1,$top_left_y+1,$top_right_x-1,$top_right_y+1,$black);
imageline($im,$top_right_x+1,$top_right_y+1,$top_right_x+1,$bottom_left_y+1,$black);
imageline($im,$top_right_x+1,$bottom_left_y+1,$bottom_left_x+1,$bottom_left_y+1,$black);
imageline($im,$bottom_left_x+1,$bottom_left_y-1,$top_left_x+1,$top_left_y+1,$black);
//A black and white border
imageline($im, $top_left_x, $top_left_y, $top_right_x, $top_right_y, $white);
imageline($im, $top_right_x, $top_right_y, $top_right_x, $bottom_left_y, $white);
imageline($im, $top_right_x, $bottom_left_y, $bottom_left_x, $bottom_left_y, $white);
imageline($im, $bottom_left_x, $bottom_left_y, $top_left_x, $top_left_y, $white);
imageline($im, $top_left_x + 1, $top_left_y + 1, $top_right_x - 1, $top_right_y + 1, $black);
imageline($im, $top_right_x + 1, $top_right_y + 1, $top_right_x + 1, $bottom_left_y + 1, $black);
imageline($im, $top_right_x + 1, $bottom_left_y + 1, $bottom_left_x + 1, $bottom_left_y + 1, $black);
imageline($im, $bottom_left_x + 1, $bottom_left_y - 1, $top_left_x + 1, $top_left_y + 1, $black);
//A scale drawn in the background
$scale_y=$top_left_y+(($bottom_left_y-$top_left_y)/3);
imageline($im,$top_left_x+2,$scale_y,$top_right_x-1,$scale_y,$hard_grey);
$scale_y=$top_left_y+2*(($bottom_left_y-$top_left_y)/3);
imageline($im,$top_left_x+2,$scale_y,$top_right_x-1,$scale_y,$hard_grey);
//A scale drawn in the background
$scale_y = $top_left_y + (($bottom_left_y - $top_left_y) / 3);
imageline($im, $top_left_x + 2, $scale_y, $top_right_x - 1, $scale_y, $hard_grey);
$scale_y = $top_left_y + 2 * (($bottom_left_y - $top_left_y) / 3);
imageline($im, $top_left_x + 2, $scale_y, $top_right_x - 1, $scale_y, $hard_grey);
}
function total_histogram($total_tab,$img_width,$img_height,$caption)
{
header("Content-type: image/png");
function total_histogram($total_tab, $img_width, $img_height, $caption) {
header("Content-type: image/png");
// Create image and Set the colors
$im=imagecreatetruecolor(intval($img_width),intval($img_height));
$grey=ImageColorAllocate($im,180,180,180);
$little_grey=ImageColorAllocate($im,220,220,220);
$hard_grey=ImageColorAllocate($im,60,60,60);
$blue=ImageColorAllocate($im,0,0,255);
// Create image and Set the colors
$im = imagecreatetruecolor(intval($img_width), intval($img_height));
$grey = ImageColorAllocate($im, 180, 180, 180);
$little_grey = ImageColorAllocate($im, 220, 220, 220);
$hard_grey = ImageColorAllocate($im, 60, 60, 60);
$blue = ImageColorAllocate($im, 0, 0, 255);
$margin=20; //graph margin
$padding=10; //Histogram padding
$border_size=3; //main border size
$ratio=0.66;
$margin = 20; //graph margin
$padding = 10; //Histogram padding
$border_size = 3; //main border size
$ratio = 0.66;
//Fill the graph with grey background
$im=imagecreatetruecolor(intval($img_width),intval($img_height));
imagefill($im,0,0,$grey);
//Fill the graph with grey background
$im = imagecreatetruecolor(intval($img_width), intval($img_height));
imagefill($im, 0, 0, $grey);
//Color the first part of the main border
$borger_top_left=array(0,$img_height,
0,0,
$img_width,0,
$img_width-$border_size,$border_size,
$border_size,$border_size,
$border_size,$img_height-$border_size,
);
ImageFilledPolygon($im, $borger_top_left, 6, $little_grey);
//Color the second part of the main border
$border_top_right=array(0,$img_height,
$img_width,$img_height,
$img_width,0,
$img_width-$border_size,$border_size,
$img_width-$border_size,$img_height-$border_size,
$border_size,$img_height-$border_size,
);
ImageFilledPolygon($im,$border_top_right,6,$hard_grey);
//Color the first part of the main border
$borger_top_left = array(
0, $img_height,
0, 0,
$img_width, 0,
$img_width - $border_size, $border_size,
$border_size, $border_size,
$border_size, $img_height - $border_size,
);
ImageFilledPolygon($im, $borger_top_left, 6, $little_grey);
//writing caption
imagestring($im, 3, $margin, 6, $caption, $blue);
//Color the second part of the main border
$border_top_right = array(
0, $img_height,
$img_width, $img_height,
$img_width, 0,
$img_width - $border_size, $border_size,
$img_width - $border_size, $img_height - $border_size,
$border_size, $img_height - $border_size,
);
ImageFilledPolygon($im, $border_top_right, 6, $hard_grey);
//create 3 borders for 3 histograms
draw_border($im,$margin,$margin,$margin+(($img_width-2*$margin)*$ratio),$margin,$margin,$img_height-$margin);
make_total_histogram($im,$margin,$margin,($img_width-2*$margin)*$ratio,$img_height-2*$margin,$padding,$total_tab);
draw_border($im,$margin+(($img_width-2*$margin)*$ratio),$margin,$img_width-$margin,$margin,$margin+(($img_width-2*$margin)*$ratio),$margin+(($img_height-2*$margin)/2));
make_total_visits_histogram($im,$margin+(($img_width-2*$margin)*$ratio),$margin,($img_width-2*$margin)*(1-$ratio),($img_height-2*$margin)/2,$padding,$total_tab);
draw_border($im,$margin+(($img_width-2*$margin)*$ratio),$margin+(($img_height-2*$margin)/2),$img_width-$margin,$margin+(($img_height-2*$margin)/2),$margin+(($img_width-2*$margin)*$ratio),$img_height-$margin);
make_total_bytes_histogram($im,$margin+(($img_width-2*$margin)*$ratio),$margin+(($img_height-2*$margin)/2),($img_width-2*$margin)*(1-$ratio),($img_height-2*$margin)/2,$padding,$total_tab);
imagepng($im); //Show the histogram created
imagedestroy($im); //Free the memory and destroy the histogram
//writing caption
imagestring($im, 3, $margin, 6, $caption, $blue);
//create 3 borders for 3 histograms
draw_border($im, $margin, $margin, $margin + (($img_width - 2 * $margin) * $ratio), $margin, $margin, $img_height - $margin);
make_total_histogram($im, $margin, $margin, ($img_width - 2 * $margin) * $ratio, $img_height - 2 * $margin, $padding, $total_tab);
draw_border($im, $margin + (($img_width - 2 * $margin) * $ratio), $margin, $img_width - $margin, $margin, $margin + (($img_width - 2 * $margin) * $ratio), $margin + (($img_height - 2 * $margin) / 2));
make_total_visits_histogram($im, $margin + (($img_width - 2 * $margin) * $ratio), $margin, ($img_width - 2 * $margin) * (1 - $ratio), ($img_height - 2 * $margin) / 2, $padding, $total_tab);
draw_border($im, $margin + (($img_width - 2 * $margin) * $ratio), $margin + (($img_height - 2 * $margin) / 2), $img_width - $margin, $margin + (($img_height - 2 * $margin) / 2), $margin + (($img_width - 2 * $margin) * $ratio), $img_height - $margin);
make_total_bytes_histogram($im, $margin + (($img_width - 2 * $margin) * $ratio), $margin + (($img_height - 2 * $margin) / 2), ($img_width - 2 * $margin) * (1 - $ratio), ($img_height - 2 * $margin) / 2, $padding, $total_tab);
imagepng($im); //Show the histogram created
imagedestroy($im); //Free the memory and destroy the histogram
}
#include 'init_gd.php';
if($_GET['begin']=="")
$new_tab=$tableau;
if($_GET['begin'] == "")
$new_tab = $tableau;
//Cut the table to the interesting part
if($_GET['begin']!="")
{
$flag=0;
$end_flag=0;
foreach($tableau as $key => $sub_tab)
{
if($flag==0 AND $key==$_GET['begin'])
$flag=1;
if($flag==1 AND $_GET['end']!="" AND $key==$_GET['end'])
$end_flag=1;
if($end_flag==1 AND $key!=$_GET['end'])
$flag=0;
if($flag==1)
$new_tab[$key]=$sub_tab;
}
if($_GET['begin'] != "") {
$flag = 0;
$end_flag = 0;
foreach($tableau as $key => $sub_tab) {
if($flag == 0 AND $key == $_GET['begin'])
$flag = 1;
if($flag == 1 AND $_GET['end'] != "" AND $key == $_GET['end'])
$end_flag = 1;
if($end_flag == 1 AND $key != $_GET['end'])
$flag = 0;
if($flag == 1)
$new_tab[$key] = $sub_tab;
}
}
total_histogram($new_tab,550,300,'Usage summary for '.$_SERVER['SERVER_NAME']);
total_histogram($new_tab, 550, 300, 'Usage summary for '.$_SERVER['SERVER_NAME']);
?>

296
stat.php
View File

@ -8,175 +8,163 @@
*/
include 'init.php';
if ($need_update)
{
while(feof($fichier_log)==0 && $log_pos<$nb_lignes_traitement)
{
$ligne=fgets($fichier_log);
$log_pos++;
if ($ligne=="")
break;
$champs=explode(' ',$ligne);
$date_string=trim($champs[3],"[");
$date=explode('/',$date_string);
$hour=explode(':',$date[2]);
$date[0]=ltrim($date[0],"0");
$month_year=$date[1].'_'.$hour[0];
$tmp=explode('?',$champs[6]);//enleve les variables GET
$champs[6]=$tmp[0];
if ($champs[8]==200)
{
if (!isset($tableau[$month_year]['url']['is_page'][$champs[6]]))
{
if (stristr($champs[6],".php")!=NULL || stristr($champs[6],".htm")!=NULL || stristr($champs[6],".xhtml")!=NULL ||stristr($champs[6],".asp")!=NULL || strstr($champs[6],".")==NULL)
{
$tableau[$month_year]['url']['is_page'][$champs[6]]=TRUE;
$tableau[$month_year]['resume']['nb_pages']++;
}
else
$tableau[$month_year]['url']['is_page'][$champs[6]]=FALSE;
}
if($need_update) {
while(feof($fichier_log) == 0 && $log_pos < $nb_lignes_traitement) {
$ligne = fgets($fichier_log);
$log_pos++;
if($ligne == "")
break;
$champs = explode(' ', $ligne);
$date_string = trim($champs[3], "[");
$date = explode('/', $date_string);
$hour = explode(':', $date[2]);
$date[0] = ltrim($date[0], "0");
$month_year = $date[1].'_'.$hour[0];
$tmp = explode('?', $champs[6]); //enleve les variables GET
$champs[6] = $tmp[0];
if($champs[8] == 200) {
if(!isset($tableau[$month_year]['url']['is_page'][$champs[6]])) {
if(stristr($champs[6], ".php") != NULL || stristr($champs[6], ".htm") != NULL || stristr($champs[6], ".xhtml") != NULL || stristr($champs[6], ".asp") != NULL || strstr($champs[6], ".") == NULL) {
$tableau[$month_year]['url']['is_page'][$champs[6]] = TRUE;
$tableau[$month_year]['resume']['nb_pages']++;
} else
$tableau[$month_year]['url']['is_page'][$champs[6]] = FALSE;
}
if($tableau[$month_year]['url']['is_page'][$champs[6]]) {
$tableau[$month_year]['jour']['pages'][$date[0]]++;
$tableau[$month_year]['resume']['pages']++;
$tableau[$month_year]['heure']['pages'][intval($hour[1])]++;
$tableau[$month_year]['url']['bytes'][$champs[6]] += ($champs[9] / 1024);
}
$tableau[$month_year]['jour']['files'][$date[0]]++;
$tableau[$month_year]['resume']['files']++;
$tableau[$month_year]['heure']['files'][intval($hour[1])]++;
$tableau[$month_year]['resume']['bytes'] += ($champs[9] / 1024);
$tableau[$month_year]['heure']['bytes'][intval($hour[1])] += ($champs[9] / 1024);
$tableau[$month_year]['jour']['bytes'][$date[0]] += ($champs[9] / 1024);
if ($tableau[$month_year]['url']['is_page'][$champs[6]])
{
$tableau[$month_year]['jour']['pages'][$date[0]]++;
$tableau[$month_year]['resume']['pages']++;
$tableau[$month_year]['heure']['pages'][intval($hour[1])]++;
$tableau[$month_year]['url']['bytes'][$champs[6]]+=($champs[9]/1024);
}
$tableau[$month_year]['jour']['files'][$date[0]]++;
$tableau[$month_year]['resume']['files']++;
$tableau[$month_year]['heure']['files'][intval($hour[1])]++;
$tableau[$month_year]['resume']['bytes']+=($champs[9]/1024);
$tableau[$month_year]['heure']['bytes'][intval($hour[1])]+=($champs[9]/1024);
$tableau[$month_year]['jour']['bytes'][$date[0]]+=($champs[9]/1024);
//Bloc gestion des visites & pages d'entree
$tmp=date_to_timestamp($date_string);
if (!isset($ip[$champs[0]]) || ($ip[$champs[0]]+$duree_visite) < $tmp)
{
$tableau[$month_year]['jour']['visits'][$date[0]]++;
$tableau[$month_year]['resume']['visits']++;
$tableau[$month_year]['heure']['visits'][intval($hour[1])]++;
if ($tableau[$month_year]['url']['is_page'][$champs[6]])
{
$tableau[$month_year]['entree'][$champs[6]]++;
$tableau[$month_year]['resume']['entree']++;
}
$ip[$champs[0]]=$tmp;
}
$_SESSION['last_visit']=$tmp;
$tmp = date_to_timestamp($date_string);
if(!isset($ip[$champs[0]]) || ($ip[$champs[0]] + $duree_visite) < $tmp) {
$tableau[$month_year]['jour']['visits'][$date[0]]++;
$tableau[$month_year]['resume']['visits']++;
$tableau[$month_year]['heure']['visits'][intval($hour[1])]++;
if($tableau[$month_year]['url']['is_page'][$champs[6]]) {
$tableau[$month_year]['entree'][$champs[6]]++;
$tableau[$month_year]['resume']['entree']++;
}
$ip[$champs[0]] = $tmp;
}
$_SESSION['last_visit'] = $tmp;
if (strstr($champs[10],'"http')!=NULL) //Referrers
{
$champs[10]=trim($champs[10],'"');
$tmp=explode('?',$champs[10]);
$referer=$tmp[0];
$tableau[$month_year]['referers_url'][$referer]++;
$tmp=explode('/',$referer);
$referer1=$tmp[2];
$tableau[$month_year]['referers_domain'][$referer1]++;
$tableau[$month_year]['referers_total']++;
}
}//fin du if ==200
if(strstr($champs[10], '"http') != NULL) //Referrers
{
$champs[10] = trim($champs[10], '"');
$tmp = explode('?', $champs[10]);
$referer = $tmp[0];
$tableau[$month_year]['referers_url'][$referer]++;
$tmp = explode('/', $referer);
$referer1 = $tmp[2];
$tableau[$month_year]['referers_domain'][$referer1]++;
$tableau[$month_year]['referers_total']++;
}
}
//fin du if ==200
$tableau[$month_year]['jour']['hits'][$date[0]]++; //Dans tt les cas on augmente hits
$tableau[$month_year]['resume']['hits']++;
$tableau[$month_year]['heure']['hits'][intval($hour[1])]++;
if ($tableau[$month_year]['url']['is_page'][$champs[6]])
$tableau[$month_year]['url']['hits'][$champs[6]]++;
if (!is_numeric($champs[7]))
$tableau[$month_year]['resume'][$champs[8]]++;
else if (!is_numeric($champs[6]))
$tableau[$month_year]['resume'][$champs[7]]++;
$tableau[$month_year]['jour']['hits'][$date[0]]++; //Dans tt les cas on augmente hits
$tableau[$month_year]['resume']['hits']++;
$tableau[$month_year]['heure']['hits'][intval($hour[1])]++;
if($tableau[$month_year]['url']['is_page'][$champs[6]])
$tableau[$month_year]['url']['hits'][$champs[6]]++;
if (strlen($champs[11])>4)
{
$champs[11]=trim($champs[11],"\";\n");
$tableau[$month_year]['agents_moteur'][$champs[11]]++;
}
if(!is_numeric($champs[7]))
$tableau[$month_year]['resume'][$champs[8]]++;
else if(!is_numeric($champs[6]))
$tableau[$month_year]['resume'][$champs[7]]++;
$champs=explode('"',$ligne);
if (strlen($champs[5])>4)
$tableau[$month_year]['agents_complet'][$champs[5]]++;
if(strlen($champs[11]) > 4) {
$champs[11] = trim($champs[11], "\";\n");
$tableau[$month_year]['agents_moteur'][$champs[11]]++;
}
}
//Fin de la boucle While
$champs = explode('"', $ligne);
if(strlen($champs[5]) > 4)
$tableau[$month_year]['agents_complet'][$champs[5]]++;
fwrite($fichier_sauv,"<?PHP\n");
foreach($tableau as $index => $valeur)
{
for($a=1;$a<=31;$a++)
{
if (isset($valeur['jour']['hits'][$a]))
fwrite($fichier_sauv,'$tableau[\''.$index.'\'][\'jour\'][\'hits\'][\''.$a.'\'] = '.$valeur['jour']['hits'][$a].";\n");
if (isset($valeur['jour']['files'][$a]))
fwrite($fichier_sauv,'$tableau[\''.$index.'\'][\'jour\'][\'files\'][\''.$a.'\'] = '.$valeur['jour']['files'][$a].";\n");
if (isset($valeur['jour']['pages'][$a]))
fwrite($fichier_sauv,'$tableau[\''.$index.'\'][\'jour\'][\'pages\'][\''.$a.'\'] = '.$valeur['jour']['pages'][$a].";\n");
if (isset($valeur['jour']['visits'][$a]))
fwrite($fichier_sauv,'$tableau[\''.$index.'\'][\'jour\'][\'visits\'][\''.$a.'\'] = '.$valeur['jour']['visits'][$a].";\n");
if (isset($valeur['jour']['bytes'][$a]))
fwrite($fichier_sauv,'$tableau[\''.$index.'\'][\'jour\'][\'bytes\'][\''.$a.'\'] = '.$valeur['jour']['bytes'][$a].";\n");
}
for($a=0;$a<=23;$a++)
{
if (isset($valeur['heure']['hits'][$a]))
fwrite($fichier_sauv,'$tableau[\''.$index.'\'][\'heure\'][\'hits\'][\''.$a.'\'] = '.$valeur['heure']['hits'][$a].";\n");
if (isset($valeur['heure']['files'][$a]))
fwrite($fichier_sauv,'$tableau[\''.$index.'\'][\'heure\'][\'files\'][\''.$a.'\'] = '.$valeur['heure']['files'][$a].";\n");
if (isset($valeur['heure']['pages'][$a]))
fwrite($fichier_sauv,'$tableau[\''.$index.'\'][\'heure\'][\'pages\'][\''.$a.'\'] = '.$valeur['heure']['pages'][$a].";\n");
if (isset($valeur['heure']['visits'][$a]))
fwrite($fichier_sauv,'$tableau[\''.$index.'\'][\'heure\'][\'visits\'][\''.$a.'\'] = '.$valeur['heure']['visits'][$a].";\n");
if (isset($valeur['heure']['bytes'][$a]))
fwrite($fichier_sauv,'$tableau[\''.$index.'\'][\'heure\'][\'bytes\'][\''.$a.'\'] = '.$valeur['heure']['bytes'][$a].";\n");
}
foreach($valeur['url']['hits'] as $nom => $val)
fwrite($fichier_sauv,'$tableau[\''.$index.'\'][\'url\'][\'hits\'][\''.$nom.'\'] = '.$val.";\n");
foreach($valeur['url']['bytes'] as $nom => $val)
fwrite($fichier_sauv,'$tableau[\''.$index.'\'][\'url\'][\'bytes\'][\''.$nom.'\'] = '.$val.";\n");
foreach($valeur['resume'] as $nom => $val)
fwrite($fichier_sauv,'$tableau[\''.$index.'\'][\'resume\'][\''.$nom.'\'] = '.$val.";\n");
foreach($valeur['referers_url'] as $nom => $val)
fwrite($fichier_sauv,'$tableau[\''.$index.'\'][\'referers_url\'][\''.$nom.'\'] = '.$val.";\n");
foreach($valeur['referers_domain'] as $nom => $val)
fwrite($fichier_sauv,'$tableau[\''.$index.'\'][\'referers_domain\'][\''.$nom.'\'] = '.$val.";\n");
foreach($valeur['agents_moteur'] as $nom => $val)
fwrite($fichier_sauv,'$tableau[\''.$index.'\'][\'agents_moteur\'][\''.$nom.'\'] = '.$val.";\n");
foreach($valeur['agents_complet'] as $nom => $val)
fwrite($fichier_sauv,'$tableau[\''.$index.'\'][\'agents_complet\'][\''.$nom.'\'] = '.$val.";\n");
foreach($valeur['entree'] as $nom => $val)
fwrite($fichier_sauv,'$tableau[\''.$index.'\'][\'entree\'][\''.$nom.'\'] = '.$val.";\n");
fwrite($fichier_sauv,'$tableau[\''.$index.'\'][\'referers_total\'] =
\''.$valeur['referers_total']."';\n");
}
}
//Fin de la boucle While
if (isset($_SESSION['last_visit']))
fwrite($fichier_sauv,'$_SESSION[\'last_visit\'] = \''.$_SESSION['last_visit']."';\n");
fwrite($fichier_sauv, "<?PHP\n");
foreach($tableau as $index => $valeur) {
for($a = 1; $a <= 31; $a++) {
if(isset($valeur['jour']['hits'][$a]))
fwrite($fichier_sauv, '$tableau[\''.$index.'\'][\'jour\'][\'hits\'][\''.$a.'\'] = '.$valeur['jour']['hits'][$a].";\n");
if(isset($valeur['jour']['files'][$a]))
fwrite($fichier_sauv, '$tableau[\''.$index.'\'][\'jour\'][\'files\'][\''.$a.'\'] = '.$valeur['jour']['files'][$a].";\n");
if(isset($valeur['jour']['pages'][$a]))
fwrite($fichier_sauv, '$tableau[\''.$index.'\'][\'jour\'][\'pages\'][\''.$a.'\'] = '.$valeur['jour']['pages'][$a].";\n");
if(isset($valeur['jour']['visits'][$a]))
fwrite($fichier_sauv, '$tableau[\''.$index.'\'][\'jour\'][\'visits\'][\''.$a.'\'] = '.$valeur['jour']['visits'][$a].";\n");
if(isset($valeur['jour']['bytes'][$a]))
fwrite($fichier_sauv, '$tableau[\''.$index.'\'][\'jour\'][\'bytes\'][\''.$a.'\'] = '.$valeur['jour']['bytes'][$a].";\n");
}
foreach($ip as $nom => $val)
{
if (($val+$duree_visite)>$_SESSION['last_visit'])
fwrite($fichier_sauv,'$ip[\''.$nom.'\'] = '.$val.";\n");
}
for($a = 0; $a <= 23; $a++) {
if(isset($valeur['heure']['hits'][$a]))
fwrite($fichier_sauv, '$tableau[\''.$index.'\'][\'heure\'][\'hits\'][\''.$a.'\'] = '.$valeur['heure']['hits'][$a].";\n");
if(isset($valeur['heure']['files'][$a]))
fwrite($fichier_sauv, '$tableau[\''.$index.'\'][\'heure\'][\'files\'][\''.$a.'\'] = '.$valeur['heure']['files'][$a].";\n");
if(isset($valeur['heure']['pages'][$a]))
fwrite($fichier_sauv, '$tableau[\''.$index.'\'][\'heure\'][\'pages\'][\''.$a.'\'] = '.$valeur['heure']['pages'][$a].";\n");
if(isset($valeur['heure']['visits'][$a]))
fwrite($fichier_sauv, '$tableau[\''.$index.'\'][\'heure\'][\'visits\'][\''.$a.'\'] = '.$valeur['heure']['visits'][$a].";\n");
if(isset($valeur['heure']['bytes'][$a]))
fwrite($fichier_sauv, '$tableau[\''.$index.'\'][\'heure\'][\'bytes\'][\''.$a.'\'] = '.$valeur['heure']['bytes'][$a].";\n");
}
foreach($valeur['url']['hits'] as $nom => $val)
fwrite($fichier_sauv, '$tableau[\''.$index.'\'][\'url\'][\'hits\'][\''.$nom.'\'] = '.$val.";\n");
foreach($valeur['url']['bytes'] as $nom => $val)
fwrite($fichier_sauv, '$tableau[\''.$index.'\'][\'url\'][\'bytes\'][\''.$nom.'\'] = '.$val.";\n");
foreach($valeur['resume'] as $nom => $val)
fwrite($fichier_sauv, '$tableau[\''.$index.'\'][\'resume\'][\''.$nom.'\'] = '.$val.";\n");
foreach($valeur['referers_url'] as $nom => $val)
fwrite($fichier_sauv, '$tableau[\''.$index.'\'][\'referers_url\'][\''.$nom.'\'] = '.$val.";\n");
foreach($valeur['referers_domain'] as $nom => $val)
fwrite($fichier_sauv, '$tableau[\''.$index.'\'][\'referers_domain\'][\''.$nom.'\'] = '.$val.";\n");
foreach($valeur['agents_moteur'] as $nom => $val)
fwrite($fichier_sauv, '$tableau[\''.$index.'\'][\'agents_moteur\'][\''.$nom.'\'] = '.$val.";\n");
foreach($valeur['agents_complet'] as $nom => $val)
fwrite($fichier_sauv, '$tableau[\''.$index.'\'][\'agents_complet\'][\''.$nom.'\'] = '.$val.";\n");
foreach($valeur['entree'] as $nom => $val)
fwrite($fichier_sauv, '$tableau[\''.$index.'\'][\'entree\'][\''.$nom.'\'] = '.$val.";\n");
fwrite(
$fichier_sauv, '$tableau[\''.$index.'\'][\'referers_total\'] =
\''.$valeur['referers_total']."';\n"
);
}
if(isset($_SESSION['last_visit']))
fwrite($fichier_sauv, '$_SESSION[\'last_visit\'] = \''.$_SESSION['last_visit']."';\n");
if (isset($month_year))
$_SESSION['last_month'] = $month_year;
fwrite($fichier_sauv,'$_SESSION[\'last_month\'] = \''.$_SESSION['last_month']."';\n");
foreach($ip as $nom => $val) {
if(($val + $duree_visite) > $_SESSION['last_visit'])
fwrite($fichier_sauv, '$ip[\''.$nom.'\'] = '.$val.";\n");
}
fwrite($fichier_sauv,'$log_offset = '.ftell($fichier_log).";\n?>");
if(isset($month_year))
$_SESSION['last_month'] = $month_year;
fwrite($fichier_sauv, '$_SESSION[\'last_month\'] = \''.$_SESSION['last_month']."';\n");
fclose($fichier_sauv);
fwrite($fichier_sauv, '$log_offset = '.ftell($fichier_log).";\n?>");
fclose($fichier_sauv);
}
$lod=fstat($fichier_log);
$progress['max']=$lod['size'];
$progress['value']=ftell($fichier_log);
$lod = fstat($fichier_log);
$progress['max'] = $lod['size'];
$progress['value'] = ftell($fichier_log);
fclose($fichier_log);
$_SESSION['statdisplay']=$tableau;
$_SESSION['progress']=$progress;
$_SESSION['statdisplay'] = $tableau;
$_SESSION['progress'] = $progress;
?>

View File

@ -1,16 +1,19 @@
.valeur {
font-weight:bold;
text-align:right;
.valeur {
font-weight: bold;
text-align: right;
}
.pourcent {
font-size:x-small;
text-align:right;
font-size: x-small;
text-align: right;
}
.titre {
text-align:center;
font-weight:bold;
text-align: center;
font-weight: bold;
}
table,td {
border:2px inset black;
border-collapse:collapse;
table, td {
border: 2px inset black;
border-collapse: collapse;
}

View File

@ -1,307 +1,274 @@
<?php
/**
*
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author J.-F. Lalande <jean-francois.lalande@ensi-bourges.fr>
* @author Maxime Fonda <maxime.fonda@ensi-bourges.fr>
* @author Thibault Coullet <thibault.coullet@ensi-bourges.fr>
*/
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'syntax.php');
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'syntax.php');
/**
/**
* All DokuWiki plugins to extend the parser/rendering mechanism
* need to inherit from this class
*/
class syntax_plugin_statdisplay extends DokuWiki_Syntax_Plugin {
class syntax_plugin_statdisplay extends DokuWiki_Syntax_Plugin {
/**
/**
* return some info
*/
function getInfo(){
return array(
'author' => 'Maxime Fonda - Thibault Coullet - J.-F. Lalande',
'email' => 'jean-francois.lalande@ensi-bourges.fr,maxime.fonda@ensi-bourges.fr,thibault.coullet@ensi-bourges.fr',
'date' => '26/06/2008',
'name' => 'Dokuwiki statdisplay plugin',
'desc' => 'Displays log statistics about your Dokuwiki',
'url' => 'http://perso.ensi-bourges.fr/jfl/doku.php?id=wiki:statdisplay',
);
}
function getInfo() {
return array(
'author' => 'Maxime Fonda - Thibault Coullet - J.-F. Lalande',
'email' => 'jean-francois.lalande@ensi-bourges.fr,maxime.fonda@ensi-bourges.fr,thibault.coullet@ensi-bourges.fr',
'date' => '26/06/2008',
'name' => 'Dokuwiki statdisplay plugin',
'desc' => 'Displays log statistics about your Dokuwiki',
'url' => 'http://perso.ensi-bourges.fr/jfl/doku.php?id=wiki:statdisplay',
);
}
/**
/**
* What kind of syntax are we?
*/
function getType(){
return 'substition';
}
function getType() {
return 'substition';
}
/**
/**
* What about paragraphs?
*/
function getPType(){
return 'block';
}
function getPType() {
return 'block';
}
/**
/**
* Where to sort in?
*/
function getSort(){
return 155;
}
*/
function getSort() {
return 155;
}
/**
/**
* Connect pattern to lexer
*/
function connectTo($mode) {
$this->Lexer->addSpecialPattern('\{\{statdisplay>compute stats\}\}',$mode,'plugin_statdisplay');
$this->Lexer->addSpecialPattern('\{\{statdisplay>all[^}]*\}\}',$mode,'plugin_statdisplay');
$this->Lexer->addSpecialPattern('\{\{statdisplay>month by day[^}]*\}\}',$mode,'plugin_statdisplay');
$this->Lexer->addSpecialPattern('\{\{statdisplay>month by hour[^}]*\}\}',$mode,'plugin_statdisplay');
$this->Lexer->addSpecialPattern('\{\{statdisplay>one month[^}]*\}\}',$mode,'plugin_statdisplay');
$this->Lexer->addSpecialPattern('\{\{statdisplay>top bytes[^}]*\}\}',$mode,'plugin_statdisplay');
$this->Lexer->addSpecialPattern('\{\{statdisplay>top urls[^}]*\}\}',$mode,'plugin_statdisplay');
$this->Lexer->addSpecialPattern('\{\{statdisplay>top entries[^}]*\}\}',$mode,'plugin_statdisplay');
$this->Lexer->addSpecialPattern('\{\{statdisplay>top referers[^}]*\}\}',$mode,'plugin_statdisplay');
$this->Lexer->addSpecialPattern('\{\{statdisplay>user agents[^}]*\}\}',$mode,'plugin_statdisplay');
$this->Lexer->addSpecialPattern('\{\{statdisplay>progress bar\}\}',$mode,'plugin_statdisplay');
}
function connectTo($mode) {
$this->Lexer->addSpecialPattern('\{\{statdisplay>compute stats\}\}', $mode, 'plugin_statdisplay');
$this->Lexer->addSpecialPattern('\{\{statdisplay>all[^}]*\}\}', $mode, 'plugin_statdisplay');
$this->Lexer->addSpecialPattern('\{\{statdisplay>month by day[^}]*\}\}', $mode, 'plugin_statdisplay');
$this->Lexer->addSpecialPattern('\{\{statdisplay>month by hour[^}]*\}\}', $mode, 'plugin_statdisplay');
$this->Lexer->addSpecialPattern('\{\{statdisplay>one month[^}]*\}\}', $mode, 'plugin_statdisplay');
$this->Lexer->addSpecialPattern('\{\{statdisplay>top bytes[^}]*\}\}', $mode, 'plugin_statdisplay');
$this->Lexer->addSpecialPattern('\{\{statdisplay>top urls[^}]*\}\}', $mode, 'plugin_statdisplay');
$this->Lexer->addSpecialPattern('\{\{statdisplay>top entries[^}]*\}\}', $mode, 'plugin_statdisplay');
$this->Lexer->addSpecialPattern('\{\{statdisplay>top referers[^}]*\}\}', $mode, 'plugin_statdisplay');
$this->Lexer->addSpecialPattern('\{\{statdisplay>user agents[^}]*\}\}', $mode, 'plugin_statdisplay');
$this->Lexer->addSpecialPattern('\{\{statdisplay>progress bar\}\}', $mode, 'plugin_statdisplay');
}
/**
/**
* Handle the match
*/
function handle($match, $state, $pos, &$handler){
function handle($match, $state, $pos, &$handler) {
return array($match,$state,$pos,$duree_visite);
}
return array($match, $state, $pos, $duree_visite);
}
/**
/**
* Create output
*/
function render($format, &$renderer, $data) {
function render($format, &$renderer, $data) {
$statdisplay_daily_histogram = DOKU_URL . 'lib/plugins/statdisplay/daily_histogram.php';
$statdisplay_resume_histogram = DOKU_URL . 'lib/plugins/statdisplay/resume_histogram.php';
$statdisplay_progress_bar = DOKU_URL . 'lib/plugins/statdisplay/progressbar.php';
$statdisplay_daily_histogram = DOKU_URL.'lib/plugins/statdisplay/daily_histogram.php';
$statdisplay_resume_histogram = DOKU_URL.'lib/plugins/statdisplay/resume_histogram.php';
$statdisplay_progress_bar = DOKU_URL.'lib/plugins/statdisplay/progressbar.php';
$tmp_users=explode ('"',$this->getConf('user_agent_keywords'));
for ($i=1;$i<count($tmp_users);$i+=2)
{
$tmp2_users=explode('=',$tmp_users[$i]);
$tab_agent[$tmp2_users[0]] = $tmp2_users[1];
}
$tmp_users = explode('"', $this->getConf('user_agent_keywords'));
for($i = 1; $i < count($tmp_users); $i += 2) {
$tmp2_users = explode('=', $tmp_users[$i]);
$tab_agent[$tmp2_users[0]] = $tmp2_users[1];
}
$tmp_referers=explode('"',$this->getConf('referer_regular_expr'));
for ($i=1;$i<count($tmp_referers);$i+=2)
{
$nom=explode('=',$tmp_referers[$i]);
$nom=$nom[0];
$tmp2_referers=explode('\'',$tmp_referers[$i]);
for ($j=1;$j<count($tmp2_referers);$j+=2)
$tab_referers[$nom][$tmp2_referers[$j]] = 1;
}
$tmp_referers = explode('"', $this->getConf('referer_regular_expr'));
for($i = 1; $i < count($tmp_referers); $i += 2) {
$nom = explode('=', $tmp_referers[$i]);
$nom = $nom[0];
$tmp2_referers = explode('\'', $tmp_referers[$i]);
for($j = 1; $j < count($tmp2_referers); $j += 2)
$tab_referers[$nom][$tmp2_referers[$j]] = 1;
}
$nb_lignes_traitement = $this->getConf('line_number');
$log_path = $this->getConf('accesslog');
$duree_visite = 60*$this->getConf('visit_time');
$flag_graph = FALSE;
$nb_lignes_traitement = $this->getConf('line_number');
$log_path = $this->getConf('accesslog');
$duree_visite = 60 * $this->getConf('visit_time');
$flag_graph = FALSE;
if ($data[0]=='{{statdisplay>compute stats}}' || $this->getConf('auto_compute_stats'))
{
$_SESSION['need_update']=TRUE;
//$renderer->doc.= '<link rel="stylesheet" type="text/css" href="/lib/plugins/statdisplay/style.css" />';
}
include_once 'stat.php';
if($data[0] == '{{statdisplay>compute stats}}' || $this->getConf('auto_compute_stats')) {
$_SESSION['need_update'] = TRUE;
//$renderer->doc.= '<link rel="stylesheet" type="text/css" href="/lib/plugins/statdisplay/style.css" />';
}
include_once 'stat.php';
$param = explode('?', $data[0]);
$param = $param[1];
$param = trim($param, '}');
if(strstr($data[0], 'graph') != NULL)
$flag_graph = TRUE;
$param = explode(' ', $param);
$param=explode('?',$data[0]);
$param=$param[1];
$param=trim ($param,'}');
if (strstr($data[0],'graph')!= NULL)
$flag_graph=TRUE;
$param=explode(' ',$param);
if($param[0] == 'graph') {
if($param[1] != '')
$required = $param[1];
else
$required = $_SESSION['last_month'];
} else if($param[0] != '')
$required = $param[0];
else
$required = $_SESSION['last_month'];
if ($param[0]=='graph')
{
if ($param[1] != '')
$required= $param[1];
else
$required = $_SESSION['last_month'];
}
else if ($param[0] != '')
$required= $param[0];
else
$required = $_SESSION['last_month'];
if($data[0] == '{{statdisplay>progress bar}}') {
//$renderer->doc .= '<img src="lib/plugins/statdisplay/progressbar.php?max='.$_SESSION['progress']['max'].'&amp;value='.$_SESSION['progress']['value'].'" alt="progress bar"></img>';
$renderer->doc .= "<img src=\"";
$renderer->doc .= ml(
$statdisplay_progress_bar
."?max=".$_SESSION['progress']['max'].
"&value=".$_SESSION['progress']['value']
);
$renderer->doc .= "\" alt=\"progress bar\"></img>";
}
if ($data[0]=='{{statdisplay>progress bar}}')
{
//$renderer->doc .= '<img src="lib/plugins/statdisplay/progressbar.php?max='.$_SESSION['progress']['max'].'&amp;value='.$_SESSION['progress']['value'].'" alt="progress bar"></img>';
if(strstr($data[0], '{{statdisplay>one month') != NULL) {
if($flag_graph)
$renderer->doc .= 'Cannot display graph statistics for one month';
else {
include_once 'month_summary.php';
$renderer->doc .= summary($required);
}
}
$renderer->doc .= "<img src=\"";
$renderer->doc .= ml($statdisplay_progress_bar
. "?max=".$_SESSION['progress']['max'] .
"&value=".$_SESSION['progress']['value']);
$renderer->doc .= "\" alt=\"progress bar\"></img>";
}
if(strstr($data[0], '{{statdisplay>user agents') != NULL) {
if($flag_graph)
$renderer->doc .= 'Cannot display graph statistics for user agents';
else {
include_once 'user_agents.php';
$renderer->doc .= user_agents($required, $this->getConf('user_agent'), $tab_agent, $this->getConf('top_user_agents_number_of_lines'));
}
}
if (strstr($data[0],'{{statdisplay>one month')!=NULL)
{
if ($flag_graph)
$renderer->doc .= 'Cannot display graph statistics for one month';
else
{
include_once 'month_summary.php';
$renderer->doc .= summary($required);
}
}
if(strstr($data[0], '{{statdisplay>top referers') != NULL) {
if($flag_graph)
$renderer->doc .= 'Cannot display graph statistics for top referers';
else {
include_once 'top_referers.php';
$renderer->doc .= top_referers($required, $this->getConf('referer'), $this->getConf('top_referers_number_of_lines'), $tab_referers, $this->getConf('regular_use'));
}
}
if(strstr($data[0], '{{statdisplay>month by day') != NULL) {
if($flag_graph) {
if(isset($_SESSION['statdisplay'][$required])) {
//$renderer->doc .= '<img src="' . $statdisplay_daily_histogram . '?title='.str_replace("_"," ",$required).' Daily Statistics&amp;type=31&amp;month='.$required.'" alt="month by day"></img>';
$renderer->doc .= "<img src=\"";
$renderer->doc .= ml(
$statdisplay_daily_histogram
.'?title='.str_replace("_", " ", $required).
' Daily Statistics&type=31&month='.$required
);
$renderer->doc .= "\" alt=\"month by day\"></img>";
}
} else {
include_once 'daily_statistics.php';
$renderer->doc .= daily($required);
}
}
if (strstr($data[0],'{{statdisplay>user agents')!=NULL)
{
if ($flag_graph)
$renderer->doc .= 'Cannot display graph statistics for user agents';
else
{
include_once 'user_agents.php';
$renderer->doc .= user_agents($required,$this->getConf('user_agent'),$tab_agent,$this->getConf('top_user_agents_number_of_lines'));
}
}
if(strstr($data[0], '{{statdisplay>month by hour') != NULL) {
if($flag_graph) {
if(isset($_SESSION['statdisplay'][$required])) {
//$renderer->doc .= '<img src="' . $statdisplay_daily_histogram . '?title='.str_replace("_"," ",$required).' Hourly Statistics&amp;type=24&amp;month='.$required.'" alt="month by hour"></img>';
$renderer->doc .= "<img src=\"";
$renderer->doc .= ml(
$statdisplay_daily_histogram
.'?title='.str_replace("_", " ", $required).
' Hourly Statistics&type=24&month='.$required
);
$renderer->doc .= "\" alt=\"month by hour\"></img>";
if (strstr($data[0],'{{statdisplay>top referers')!=NULL)
{
if ($flag_graph)
$renderer->doc .= 'Cannot display graph statistics for top referers';
else
{
include_once 'top_referers.php';
$renderer->doc .= top_referers($required,$this->getConf('referer'),$this->getConf('top_referers_number_of_lines'),$tab_referers,$this->getConf('regular_use'));
}
}
}
} else {
include_once 'hourly_statistics.php';
$renderer->doc .= hourly($required);
}
}
if (strstr($data[0],'{{statdisplay>month by day') != NULL)
{
if ($flag_graph)
{
if (isset($_SESSION['statdisplay'][$required]))
{
//$renderer->doc .= '<img src="' . $statdisplay_daily_histogram . '?title='.str_replace("_"," ",$required).' Daily Statistics&amp;type=31&amp;month='.$required.'" alt="month by day"></img>';
$renderer->doc .= "<img src=\"";
$renderer->doc .= ml($statdisplay_daily_histogram
. '?title=' . str_replace("_"," ",$required) .
' Daily Statistics&type=31&month='.$required);
$renderer->doc .= "\" alt=\"month by day\"></img>";
}
}
else
{
include_once 'daily_statistics.php';
$renderer->doc .= daily($required);
}
}
if(strstr($data[0], '{{statdisplay>top bytes') != NULL) {
if($flag_graph)
$renderer->doc .= 'Cannot display graph statistics for top bytes';
else {
include_once 'top_bytes.php';
$renderer->doc .= top_bytes($required, $this->getConf('top_kbytes_number_of_lines'));
}
}
if (strstr($data[0],'{{statdisplay>month by hour') != NULL)
{
if ($flag_graph)
{
if (isset($_SESSION['statdisplay'][$required]))
{
//$renderer->doc .= '<img src="' . $statdisplay_daily_histogram . '?title='.str_replace("_"," ",$required).' Hourly Statistics&amp;type=24&amp;month='.$required.'" alt="month by hour"></img>';
$renderer->doc .= "<img src=\"";
$renderer->doc .= ml($statdisplay_daily_histogram
. '?title=' . str_replace("_"," ",$required) .
' Hourly Statistics&type=24&month='.$required);
$renderer->doc .= "\" alt=\"month by hour\"></img>";
if(strstr($data[0], '{{statdisplay>top urls') != NULL) {
if($flag_graph)
$renderer->doc .= 'Cannot display graph statistics for top url';
else {
include_once 'top_url.php';
$renderer->doc .= top_url($required, $this->getConf('top_url_number_of_lines'));
}
}
}
}
else
{
include_once 'hourly_statistics.php';
$renderer->doc .= hourly($required);
}
}
if(strstr($data[0], '{{statdisplay>top entries') != NULL) {
if($flag_graph)
$renderer->doc .= 'Cannot display graph statistics for user agents';
else {
include_once 'top_entries.php';
$renderer->doc .= top_entries($required, $this->getConf('top_entries_number_of_lines'));
}
}
if (strstr($data[0],'{{statdisplay>top bytes') != NULL)
{
if ($flag_graph)
$renderer->doc .= 'Cannot display graph statistics for top bytes';
else
{
include_once 'top_bytes.php';
$renderer->doc .= top_bytes($required,$this->getConf('top_kbytes_number_of_lines'));
}
}
if(strstr($data[0], '{{statdisplay>all') != NULL) {
$param = explode('?', $data[0]);
$param = $param[1];
$param = trim($param, '}');
if(strstr($data[0], 'graph') != NULL)
$flag_graph = TRUE;
$param = explode(' ', $param);
if (strstr($data[0],'{{statdisplay>top urls') != NULL)
{
if ($flag_graph)
$renderer->doc .= 'Cannot display graph statistics for top url';
else
{
include_once 'top_url.php';
$renderer->doc .= top_url($required,$this->getConf('top_url_number_of_lines'));
}
}
if($param[0] == 'graph') {
$begin = $param[1];
$end = $param[2];
} else if($param[1] == 'graph') {
$begin = $param[0];
$end = $param[2];
} else //param[2]=='graph' ou pas
{
$begin = $param[0];
$end = $param[1];
}
if (strstr($data[0],'{{statdisplay>top entries') != NULL)
{
if ($flag_graph)
$renderer->doc .= 'Cannot display graph statistics for user agents';
else
{
include_once 'top_entries.php';
$renderer->doc .= top_entries($required,$this->getConf('top_entries_number_of_lines'));
}
}
if($flag_graph and isset($_SESSION['statdisplay'])) {
//$renderer->doc .= '<img src="' . $statdisplay_resume_histogram . '?begin='.$begin.'&amp;end='.$end.'" alt="All months graph"></img>';
$renderer->doc .= "<img src=\"";
$renderer->doc .= ml(
$statdisplay_resume_histogram
."?begin=".$begin."&end=".$end
);
$renderer->doc .= "\" alt=\"All months graph\"></img>";
} else {
include_once 'total_summary.php';
$renderer->doc .= total_summary($begin, $end);
}
}
if (strstr($data[0],'{{statdisplay>all') != NULL)
{
$param=explode('?',$data[0]);
$param=$param[1];
$param=trim ($param,'}');
if (strstr($data[0],'graph')!= NULL)
$flag_graph=TRUE;
$param=explode(' ',$param);
return true;
}
}
if ($param[0]=='graph')
{
$begin= $param[1];
$end=$param[2];
}
else if ($param[1]=='graph')
{
$begin= $param[0];
$end=$param[2];
}
else //param[2]=='graph' ou pas
{
$begin= $param[0];
$end=$param[1];
}
if ($flag_graph and isset($_SESSION['statdisplay']))
{
//$renderer->doc .= '<img src="' . $statdisplay_resume_histogram . '?begin='.$begin.'&amp;end='.$end.'" alt="All months graph"></img>';
$renderer->doc .= "<img src=\"";
$renderer->doc .= ml($statdisplay_resume_histogram
. "?begin=" . $begin."&end=".$end);
$renderer->doc .= "\" alt=\"All months graph\"></img>";
}
else
{
include_once 'total_summary.php';
$renderer->doc .= total_summary($begin,$end);
}
}
return true;
}
}
?>

View File

@ -7,35 +7,33 @@
* @author Thibault Coullet <thibault.coullet@ensi-bourges.fr>
*/
function top_bytes($month,$nb_lines)
{
if (isset($_SESSION['statdisplay'][$month]))
{
arsort($_SESSION['statdisplay'][$month]['url']['bytes']);
$i=1;
foreach($_SESSION['statdisplay'][$month]['url']['bytes'] as $index =>$inter2)
{
if ($i>$nb_lines)
break;
$msg1 .= '<tr><td align="center">'.$i.'</td>
function top_bytes($month, $nb_lines) {
if(isset($_SESSION['statdisplay'][$month])) {
arsort($_SESSION['statdisplay'][$month]['url']['bytes']);
$i = 1;
foreach($_SESSION['statdisplay'][$month]['url']['bytes'] as $index => $inter2) {
if($i > $nb_lines)
break;
$msg1 .= '<tr><td align="center">'.$i.'</td>
<td align="left">'.$index.'</td>
<td class="valeur">'.$_SESSION['statdisplay'][$month]['url']['hits'][$index].'</td>
<td class="pourcent">'.number_format($_SESSION['statdisplay'][$month]['url']['hits'][$index]*100/$_SESSION['statdisplay'][$month]['resume']['hits'],2).'%</td>
<td class="valeur">'.number_format($inter2,2).'</td>
<td class="pourcent">'.number_format($inter2*100/$_SESSION['statdisplay'][$month]['resume']['bytes'],2).'%</td>
<td class="pourcent">'.number_format($_SESSION['statdisplay'][$month]['url']['hits'][$index] * 100 / $_SESSION['statdisplay'][$month]['resume']['hits'], 2).'%</td>
<td class="valeur">'.number_format($inter2, 2).'</td>
<td class="pourcent">'.number_format($inter2 * 100 / $_SESSION['statdisplay'][$month]['resume']['bytes'], 2).'%</td>
</tr>';
$i++;
}
$i++;
}
$msg = '<table cellspacing="0"> <tr><td colspan="6" class="titre" bgcolor="#BABABA">Top '.$nb_lines.' of '.count($_SESSION['statdisplay'][$month]['url']['hits']).' URLs for '.str_replace("_"," ",$month).' by Kbytes</td></tr>';
$msg .= '<tr>
$msg = '<table cellspacing="0"> <tr><td colspan="6" class="titre" bgcolor="#BABABA">Top '.$nb_lines.' of '.count($_SESSION['statdisplay'][$month]['url']['hits']).' URLs for '.str_replace("_", " ", $month).' by Kbytes</td></tr>';
$msg .= '<tr>
<td class="titre" bgcolor="#BABABA">#</td>
<td class="titre" bgcolor="yellow">url</td>
<td class="titre" colspan="2" bgcolor="green">hits</td>
<td class="titre" colspan="2" bgcolor="red">Kbytes</td>
</tr>';
$msg .= $msg1.'</table><br />';
return $msg;
}
$msg .= $msg1.'</table><br />';
return $msg;
}
}
?>

View File

@ -7,35 +7,31 @@
* @author Thibault Coullet <thibault.coullet@ensi-bourges.fr>
*/
function top_entries($month,$nb_lines)
{
if (isset($_SESSION['statdisplay'][$month]))
{
arsort($_SESSION['statdisplay'][$month]['entree']);
function top_entries($month, $nb_lines) {
if(isset($_SESSION['statdisplay'][$month])) {
arsort($_SESSION['statdisplay'][$month]['entree']);
$i=1;
foreach($_SESSION['statdisplay'][$month]['entree'] as $index =>$inter2)
{
if ( $i<=$nb_lines)
{
$msg1.= '<tr>
$i = 1;
foreach($_SESSION['statdisplay'][$month]['entree'] as $index => $inter2) {
if($i <= $nb_lines) {
$msg1 .= '<tr>
<td align="center">'.$i.'</td>
<td align="left">'.$index.'</td>
<td class="valeur">'.$inter2.'</td>
<td class="pourcent">'.number_format($inter2*100/$_SESSION['statdisplay'][$month]['resume']['entree'],2).'%</td>
<td class="pourcent">'.number_format($inter2 * 100 / $_SESSION['statdisplay'][$month]['resume']['entree'], 2).'%</td>
</tr>';
$i++;
}
else
break;
}
$msg ='<table cellspacing="0"> <tr><td colspan="6" class="titre" bgcolor="#BABABA">Top '.($i-1).' of '.count($_SESSION['statdisplay'][$month]['entree']).' total Entry pages for '.str_replace('_',' ',$month).'</td></tr>
$i++;
} else
break;
}
$msg = '<table cellspacing="0"> <tr><td colspan="6" class="titre" bgcolor="#BABABA">Top '.($i - 1).' of '.count($_SESSION['statdisplay'][$month]['entree']).' total Entry pages for '.str_replace('_', ' ', $month).'</td></tr>
<tr>
<td class="titre" bgcolor="#BABABA">#</td>
<td class="titre" bgcolor="yellow">url</td>
<td class="titre" colspan="2" bgcolor="green">Entries</td>
</tr>'.$msg1.'</table><br />';
return $msg;
}
return $msg;
}
}
?>

View File

@ -7,65 +7,55 @@
* @author Thibault Coullet <thibault.coullet@ensi-bourges.fr>
*/
function top_referers($month,$choice,$nb_lines,$tab_referers,$association)
{
if (isset($_SESSION['statdisplay'][$month]))
{
switch ($choice)
{
case 'complete_link':
$tab=$_SESSION['statdisplay'][$month]['referers_url'];
break;
case 'domain':
$tab=$_SESSION['statdisplay'][$month]['referers_domain'];
default:
break;
}
function top_referers($month, $choice, $nb_lines, $tab_referers, $association) {
if(isset($_SESSION['statdisplay'][$month])) {
switch($choice) {
case 'complete_link':
$tab = $_SESSION['statdisplay'][$month]['referers_url'];
break;
case 'domain':
$tab = $_SESSION['statdisplay'][$month]['referers_domain'];
default:
break;
}
if ($association)
{
foreach ($tab as $referer => $value)
{
foreach($tab_referers as $nom => $inter)
{
foreach ($inter as $nom1 => $inter1)
{
if (preg_match($nom1,$referer) >0)
{
$tab[$nom]+=$value;
unset($tab[$referer]);
break 2;
}
}
}
}
}
if($association) {
foreach($tab as $referer => $value) {
foreach($tab_referers as $nom => $inter) {
foreach($inter as $nom1 => $inter1) {
if(preg_match($nom1, $referer) > 0) {
$tab[$nom] += $value;
unset($tab[$referer]);
break 2;
}
}
}
}
}
arsort($tab);
$i=1;
foreach($tab as $index =>$inter2)
{
if ( $i<=$nb_lines)
{
$msg1 .= '<tr>
arsort($tab);
$i = 1;
foreach($tab as $index => $inter2) {
if($i <= $nb_lines) {
$msg1 .= '<tr>
<td align="center">'.$i.'</td>
<td align="left">'.$index.'</td>
<td class="valeur">'.$inter2.'</td>
<td
class="pourcent">'.number_format($inter2*100/$_SESSION['statdisplay'][$month]['referers_total'],2).'%</td>
class="pourcent">'.number_format($inter2 * 100 / $_SESSION['statdisplay'][$month]['referers_total'], 2).'%</td>
</tr>';
$i++;
}
else
break;
}
$msg = '<table cellspacing="0"> <tr><td colspan="4" class="titre" bgcolor="#BABABA">Top '.($i-1).' of '.count($tab).' total Referers for '.str_replace('_',' ',$month).'</td></tr><tr>
$i++;
} else
break;
}
$msg = '<table cellspacing="0"> <tr><td colspan="4" class="titre" bgcolor="#BABABA">Top '.($i - 1).' of '.count($tab).' total Referers for '.str_replace('_', ' ', $month).'</td></tr><tr>
<td class="titre" bgcolor="#BABABA">#</td>
<td class="titre" bgcolor="yellow">url</td>
<td class="titre" colspan="2" bgcolor="green">hits</td>
</tr>'.$msg1.'</table><br />';
return $msg;
}
return $msg;
}
}
?>

View File

@ -7,32 +7,29 @@
* @author Thibault Coullet <thibault.coullet@ensi-bourges.fr>
*/
function top_url($month,$nb_lines)
{
if (isset($_SESSION['statdisplay'][$month]))
{
arsort($_SESSION['statdisplay'][$month]['url']['hits']);
$i=1;
foreach($_SESSION['statdisplay'][$month]['url']['hits'] as $index =>$inter2)
{
if ($i>$nb_lines)
break;
$msg1 .= '<tr>
function top_url($month, $nb_lines) {
if(isset($_SESSION['statdisplay'][$month])) {
arsort($_SESSION['statdisplay'][$month]['url']['hits']);
$i = 1;
foreach($_SESSION['statdisplay'][$month]['url']['hits'] as $index => $inter2) {
if($i > $nb_lines)
break;
$msg1 .= '<tr>
<td align="center">'.$i.'</td>
<td align="left">'.$index.'</td>
<td class="valeur">'.$inter2.'</td>
<td class="pourcent">'.number_format($inter2*100/$_SESSION['statdisplay'][$month]['resume']['hits'],2).'%</td>
<td class="valeur">'.number_format($_SESSION['statdisplay'][$month]['url']['bytes'][$index],2).'</td>
<td class="pourcent">'.number_format($_SESSION['statdisplay'][$month]['url']['bytes'][$index]*100/$_SESSION['statdisplay'][$month]['resume']['bytes'],2).'%</td>
<td class="pourcent">'.number_format($inter2 * 100 / $_SESSION['statdisplay'][$month]['resume']['hits'], 2).'%</td>
<td class="valeur">'.number_format($_SESSION['statdisplay'][$month]['url']['bytes'][$index], 2).'</td>
<td class="pourcent">'.number_format($_SESSION['statdisplay'][$month]['url']['bytes'][$index] * 100 / $_SESSION['statdisplay'][$month]['resume']['bytes'], 2).'%</td>
</tr>';
$i++;
}
$msg = '<table cellspacing="0"> <tr><td colspan="6" class="titre" bgcolor="#BABABA">Top '.($i-1).' of '.count($_SESSION['statdisplay'][$month]['url']['hits']).' PAGES for '.str_replace("_"," ",$month).' by Hits</td></tr>';
$msg .= '<tr><td class="titre" bgcolor="#BABABA">#</td><td class="titre" bgcolor="yellow">url</td>
$i++;
}
$msg = '<table cellspacing="0"> <tr><td colspan="6" class="titre" bgcolor="#BABABA">Top '.($i - 1).' of '.count($_SESSION['statdisplay'][$month]['url']['hits']).' PAGES for '.str_replace("_", " ", $month).' by Hits</td></tr>';
$msg .= '<tr><td class="titre" bgcolor="#BABABA">#</td><td class="titre" bgcolor="yellow">url</td>
<td class="titre" colspan="2" bgcolor="green">hits</td><td class="titre" colspan="2" bgcolor="red">Kbytes</td></tr>';
$msg.=$msg1.'</table><br />';
return $msg;
}
$msg .= $msg1.'</table><br />';
return $msg;
}
}
?>

View File

@ -7,32 +7,28 @@
* @author Thibault Coullet <thibault.coullet@ensi-bourges.fr>
*/
function total_summary($begin,$end)
{
if (isset($_SESSION['statdisplay']))
{
$tableau=$_SESSION['statdisplay'];
if($begin=="")
$new_tab=$tableau;
function total_summary($begin, $end) {
if(isset($_SESSION['statdisplay'])) {
$tableau = $_SESSION['statdisplay'];
if($begin == "")
$new_tab = $tableau;
//Cut the table to the interesting part
if($begin!="")
{
$flag=0;
$end_flag=0;
foreach($tableau as $key => $sub_tab)
{
if($flag==0 AND $key==$begin)
$flag=1;
if($flag==1 AND $end!="" AND $key==$end)
$end_flag=1;
if($end_flag==1 AND $key!=$end)
$flag=0;
if($flag==1)
$new_tab[$key]=$sub_tab;
}
}
if($begin != "") {
$flag = 0;
$end_flag = 0;
foreach($tableau as $key => $sub_tab) {
if($flag == 0 AND $key == $begin)
$flag = 1;
if($flag == 1 AND $end != "" AND $key == $end)
$end_flag = 1;
if($end_flag == 1 AND $key != $end)
$flag = 0;
if($flag == 1)
$new_tab[$key] = $sub_tab;
}
}
$msg = '<table cellspacing="0"><tr><td colspan="10" class="titre" bgcolor="#BABABA">Summary by month</td></tr>
$msg = '<table cellspacing="0"><tr><td colspan="10" class="titre" bgcolor="#BABABA">Summary by month</td></tr>
<tr><td rowspan="2" class="titre" bgcolor="#BABABA">Month</td><td colspan="4" class="titre" bgcolor="#BABABA">Daily Average</td>
<td colspan="6" class="titre" bgcolor="#BABABA">Monthly Totals</td></tr>
<tr><td class="titre" bgcolor="green">Hits</td><td class="titre" bgcolor="blue">Files</td>
@ -41,20 +37,21 @@ $msg = '<table cellspacing="0"><tr><td colspan="10" class="titre" bgcolor="#BABA
<td class="titre" bgcolor="cyan">Pages</td><td class="titre" bgcolor="blue">Files</td>
<td class="titre" bgcolor="green">Hits</td></tr>';
foreach($new_tab as $month => $value)
$msg.= '<tr><td align="right" >'.str_replace('_',' ',$month).'</td>
<td align="right">'.intval($value['resume']['hits']/count($value['jour']['hits'])).'</td>
<td align="right">'.intval($value['resume']['files']/count($value['jour']['hits'])).'</td>
<td align="right">'.intval($value['resume']['pages']/count($value['jour']['hits'])).'</td>
<td align="right">'.intval($value['resume']['visits']/count($value['jour']['hits'])).'</td>
foreach($new_tab as $month => $value)
$msg .= '<tr><td align="right" >'.str_replace('_', ' ', $month).'</td>
<td align="right">'.intval($value['resume']['hits'] / count($value['jour']['hits'])).'</td>
<td align="right">'.intval($value['resume']['files'] / count($value['jour']['hits'])).'</td>
<td align="right">'.intval($value['resume']['pages'] / count($value['jour']['hits'])).'</td>
<td align="right">'.intval($value['resume']['visits'] / count($value['jour']['hits'])).'</td>
<td align="right">'.intval($value['resume']['bytes']).'</td>
<td align="right">'.$value['resume']['visits'].'</td>
<td align="right">'.$value['resume']['pages'].'</td>
<td align="right">'.$value['resume']['files'].'</td>
<td align="right">'.$value['resume']['hits'].'</td></tr>';
$msg .= '</table>';
return $msg;
}
$msg .= '</table>';
return $msg;
}
}
?>

View File

@ -7,13 +7,11 @@
* @author Thibault Coullet <thibault.coullet@ensi-bourges.fr>
*/
function user_agents($month,$choice,$tabagent,$nb_line)
{
if (isset($_SESSION['statdisplay'][$month]))
{
$msg .= '<table cellspacing="0">
function user_agents($month, $choice, $tabagent, $nb_line) {
if(isset($_SESSION['statdisplay'][$month])) {
$msg .= '<table cellspacing="0">
<tr>
<td colspan="4" class="titre" bgcolor="#BABABA"> User agents for '.str_replace('_',' ',$month).'
<td colspan="4" class="titre" bgcolor="#BABABA"> User agents for '.str_replace('_', ' ', $month).'
</td>
</tr>
<tr>
@ -25,48 +23,44 @@ $msg .= '<table cellspacing="0">
</td>
</tr>';
switch ($choice)
{
case 'keyword':
$user=$_SESSION['statdisplay'][$month]['agents_complet'];
foreach ($user as $name => $value)
{
foreach($tabagent as $nom => $inter)
{
if (stristr($name,$nom) != NULL)
{
$users[$inter]+=$value;
break ;
}
}
}
break;
case 'display':
$users=$_SESSION['statdisplay'][$month]['agents_moteur'];
break;
case 'all_line':
$users=$_SESSION['statdisplay'][$month]['agents_complet'];
break;
default :
break;
}
arsort($users);
$i=1;
switch($choice) {
case 'keyword':
$user = $_SESSION['statdisplay'][$month]['agents_complet'];
foreach($user as $name => $value) {
foreach($tabagent as $nom => $inter) {
if(stristr($name, $nom) != NULL) {
$users[$inter] += $value;
break;
}
}
}
break;
case 'display':
$users = $_SESSION['statdisplay'][$month]['agents_moteur'];
break;
case 'all_line':
$users = $_SESSION['statdisplay'][$month]['agents_complet'];
break;
default :
break;
}
foreach($users as $nom => $valeur)
{
if ($i > $nb_line)
break;
arsort($users);
$i = 1;
$msg .= '<tr><td align="center">'.$i."</td>\n<td align=\"left\">";
$msg .= $nom;
$msg .= "</td>\n<td class=\"valeur\">".$valeur."</td>\n<td class=\"pourcent\">".
number_format($valeur*100/$_SESSION['statdisplay'][$month]['resume']['hits'],2)."%</td></tr>\n";
$i++;
}
$msg .= '</table>';
return $msg;
}
foreach($users as $nom => $valeur) {
if($i > $nb_line)
break;
$msg .= '<tr><td align="center">'.$i."</td>\n<td align=\"left\">";
$msg .= $nom;
$msg .= "</td>\n<td class=\"valeur\">".$valeur."</td>\n<td class=\"pourcent\">".
number_format($valeur * 100 / $_SESSION['statdisplay'][$month]['resume']['hits'], 2)."%</td></tr>\n";
$i++;
}
$msg .= '</table>';
return $msg;
}
}
?>