#!/usr/local/bin/perl require "getopts.pl"; require 'ctime.pl'; $Version="MakeHtmlStatTable 1.0"; $maintainer="Jens Elkner"; $email="elkner\@irb.cs.uni-magdeburg.de"; #---------------------------------WWW Index-------------------------------- # The names of all statfiles @www_files = ("l.html","c.html","g.html","r.html","a.html","p.html"); # The Names for http-links in the same Order as above @www_abrev = ("L","C","G","R","A","P"); #The description for the abbriavation in the same order as above @www_desc = ( "Lite Web Log Report   (about 10 ± 3 KBytes)", "Complete Web Log Report   (about 1024 ± 300 KBytes)", "Graphic Web Log Report   (about 100 ± 15 KBytes)", "Referring URL Statistics   (about 180 ± 50 KBytes)", "WWW Browser Agent Statistics   (about 220 ± 50 KBytes)", "Proxy Access Statistics   (about 10 ± 5 KBytes)" ); #---------------------------------FTP Index--------------------------------- # The names of all statfiles @ftp_files = ("l.html","c.html","g.html"); # The Names for http-links in the same Order as above @ftp_abrev = ("L","C","G"); #The description for the abbriavation in the same order as above @ftp_desc = ( "Lite Web Log Report    (about 10 +- 3 KBytes)", "Complete Web Log Report    (about 1024 +- 300 KBytes)", "Graphic Web Log Report    (about 100 +- 15 KBytes)" ); #------------------------------Start------------------------- &Initialize; if ($header) { print OUT
; close(HEADER); } else { print OUT " \n", "$tmp Statistics of $server\n\n\n\\n
", "

$tmp Statistics of $server

\n\n", "
\n

\n"; } print OUT "

\n

\n
\n
\n

\n", "\n", "\n", "\n", "\n\n
\n", # "
Note: The current month is not included in total statistics!\n", "
 \n"; $tmp = $thisyear; $end = $thisyear - $years; while ( $tmp > $end ) { push(@allyears,$tmp); $tmp--; } foreach (@allyears) { print OUT " $_\n"; } $month=0; foreach (@allmonth) { $month++; $s_month = ($month < 10) ? "0".$month : $month; print OUT "
$_\n"; foreach (@allyears) { $year = $_; $year =~ s/^..//; print OUT " \n"; $txt = ""; $count=0; foreach (@files) { if ( -f "$path/${year}${s_month}/$_" ) { $txt .= " ". $abrev[$count]."\n"; } $count++; } if ($txt eq "") { $txt = "  \n"; } print OUT $txt; } } print OUT "
TOTAL\n"; foreach (@allyears) { $year = $_; $year =~ s/^..//; print OUT " \n"; $txt = ""; $count=0; foreach (@files) { if ( -f "$path/total${year}/$_" ) { $txt .= " ". $abrev[$count]."\n"; } $count++; } if ($txt eq "") { print OUT "  \n"; } else { print OUT $txt; } } $tmp = &ctime(time); print OUT "
\n


\n
\n", "Note:
\n", "If you can't see a table or the links within the table you should\n", "change to a HTML 3.0 capable Browser (Netscape is recommended).
\n", "
\n"; if ($trailer) { print OUT ; close(TRAILER); } else { print OUT "
\n", $maintainer, " <", $email, ">
\n", "\nLast modified: ", $tmp, "\n", " "; } sub Initialize { $result = &Getopts('H:ho:p:s:T:t:v'); @allmonth = ("Januar", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ); &Usage if $opt_h; &Version if $opt_v; # Header file - will be inserted at the very beginning of the Output file if ($opt_H) { $header = $opt_H; if ( ! open(HEADER,$header)) { die "Can not read header file $header\n"; } } # Output file, where the generated HTML File $output = $opt_o ? $opt_o : "-" ; # system path, where the html stat files are located $path = $opt_p ? $opt_p : "."; die "$path does not exist!\n" if ( ! -d $path ); if ( ! open(OUT,">$path/$output") ) { close(HEADER) if $header; die "Can not open output file $output\n"; } # Trailer file - will be appended at the end of the Output file if ($opt_T) { $trailer = $opt_T; if ( ! open(TRAILER,$trailer) ) { close(HEADER) if $header; close(OUT); die "Can not read trailer file $trailer\n"; } } # Name of the server $server = $opt_s if $opt_s; # Type of Table $type = $opt_t ? $opt_t : "www"; if ( ($type ne "www") && ($type ne "ftp") ) { die "Unknown type $type !\n"; } # Type of Table $years = $opt_y ? $opt_y : 3; if ( (! ($years =~ m#^\d+$#o) || ($years < 1) )) { die "Need to know how many years - use a number > 0 !\n"; } if ($type eq "www") { @files = @www_files; @abrev = @www_abrev; @desc = @www_desc; $tmp = "WWW"; } if ($type eq "ftp") { @files = @ftp_files; @abrev = @ftp_abrev; @desc = @ftp_desc; $tmp = "FTP"; } $thisyear = &ctime(time); chop $thisyear; $thisyear =~ s/^.*(\d{4})$/$1/; } sub Usage { die <<"EndUsage"; $Version Usage: makeHtmlStatTable.pl [-h] [-v] [-H file] [-o file] -p path [-s name] [-T file] [-t type] [-y years] Options: -h Display this message and quit. -v Display version and quit. -H file This header file will be inserted at the very beginning of the generated file -o file File where to store generated results (default = STDOUT) -p path System path, where the html stat files are located -s name Name of the Server (only used, if there is no header file) -T file This trailer file will be appended at the End of the generated file -t type Type of the stat html table (default = www) -y years How many years do you want to have in the generated table (default = 3) EndUsage } sub Version { die << "EndVersion"; $Version EndVersion }