From: Antoine Jacquet Date: Sat, 19 May 2007 22:00:00 +0000 (+0200) Subject: version 0.73 X-Git-Tag: v0.73 X-Git-Url: http://royale.zerezo.com/git/?p=irssistats;a=commitdiff_plain;h=bee112ed64c16e0642a15bce9f37a428cb062736;ds=sidebyside version 0.73 * added last weeks and last months options (suggested by Gouki) * fixed theme option when generating output * also reset last days statistics when generating output * fix german translation (reported by Nico) * close the last div when using custom footer --- diff --git a/CHANGELOG b/CHANGELOG index d8652c5..4f7ffd9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,12 @@ Change log file for irssistats +version 0.73 (2007-05-20) + * added last weeks and last months options (suggested by Gouki) + * fixed theme option when generating output + * also reset last days statistics when generating output + * fix german translation (reported by Nico) + * close the last div when using custom footer + version 0.72 (2006-03-25) * now supports statistics of russian words (patch by Pavel N.Kovalenko) * parsing more relaxed for modified log formats (patch by Micha Nelissen) diff --git a/README b/README index b584f69..062a010 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -irssistats 0.72 +irssistats 0.73 site: http://royale.zerezo.com/irssistats/ mail: royale@zerezo.com diff --git a/data/biseau.css b/data/biseau.css index e0f8333..cbbdda9 100644 --- a/data/biseau.css +++ b/data/biseau.css @@ -40,7 +40,7 @@ body { text-align: left; } -#irssistats_legend, #irssistats_lastdays, #irssistats_tophours, #irssistats_topusers, #irssistats_topuserstime, #irssistats_randtopics, #irssistats_randurls, #irssistats_topwords, #irssistats_bignumbers { +#irssistats_legend, #irssistats_lastdays, #irssistats_lastweeks, #irssistats_lastmonths, #irssistats_tophours, #irssistats_topusers, #irssistats_topuserstime, #irssistats_randtopics, #irssistats_randurls, #irssistats_topwords, #irssistats_bignumbers { background: #ffffff; margin: 10px; text-align: center; @@ -69,7 +69,7 @@ body { border: 0; } -#irssistats_legend p, #irssistats_lastdays p, #irssistats_tophours p, #irssistats_topusers p, #irssistats_topuserstime p, #irssistats_randtopics p, #irssistats_randurls p, #irssistats_topwords p, #irssistats_bignumbers p { +#irssistats_legend p, #irssistats_lastdays p, #irssistats_lastweeks p, #irssistats_lastmonths p, #irssistats_tophours p, #irssistats_topusers p, #irssistats_topuserstime p, #irssistats_randtopics p, #irssistats_randurls p, #irssistats_topwords p, #irssistats_bignumbers p { border-left: 6px #6b78a4 double; border-right: 2px #6b78a4 solid; margin: 0; diff --git a/data/damier.css b/data/damier.css index 393678d..57cced1 100644 --- a/data/damier.css +++ b/data/damier.css @@ -32,7 +32,7 @@ body { text-align: left; } -#irssistats_legend, #irssistats_lastdays, #irssistats_tophours, #irssistats_topusers, #irssistats_topuserstime, #irssistats_randtopics, #irssistats_randurls, #irssistats_topwords, #irssistats_bignumbers { +#irssistats_legend, #irssistats_lastdays, #irssistats_lastweeks, #irssistats_lastmonths, #irssistats_tophours, #irssistats_topusers, #irssistats_topuserstime, #irssistats_randtopics, #irssistats_randurls, #irssistats_topwords, #irssistats_bignumbers { background: #ffffff; border: 1px black solid; -moz-border-radius-topright: 20px; diff --git a/data/grayscale.css b/data/grayscale.css index f4dee01..321c496 100644 --- a/data/grayscale.css +++ b/data/grayscale.css @@ -11,7 +11,7 @@ body { margin: 20px 100px 20px 100px; } -#irssistats_header, #irssistats_legend, #irssistats_lastdays, #irssistats_tophours, #irssistats_topusers, #irssistats_topuserstime, #irssistats_randtopics, #irssistats_randurls, #irssistats_topwords, #irssistats_bignumbers, #irssistats_footer { +#irssistats_header, #irssistats_legend, #irssistats_lastdays, #irssistats_lastweeks, #irssistats_lastmonths, #irssistats_tophours, #irssistats_topusers, #irssistats_topuserstime, #irssistats_randtopics, #irssistats_randurls, #irssistats_topwords, #irssistats_bignumbers, #irssistats_footer { background: #ffffff; border: 1px #777777 dotted; } diff --git a/data/pisg.css b/data/pisg.css index 063409d..2d81db0 100644 --- a/data/pisg.css +++ b/data/pisg.css @@ -64,7 +64,7 @@ body { text-align: left; } -#irssistats_lastdays th, #irssistats_tophours th { +#irssistats_lastdays th, #irssistats_lastweeks th, #irssistats_lastmonths th, #irssistats_tophours th { font-weight: normal; color: #000000; background-color: #CCCCCC; @@ -80,7 +80,7 @@ body { background: #bcbcda; } -#irssistats_legend td, #irssistats_lastdays td, #irssistats_tophours td { +#irssistats_legend td, #irssistats_lastdays td, #irssistats_lastweeks td, #irssistats_lastmonths td, #irssistats_tophours td { text-align: center; background: inherit; } diff --git a/irssistats.1 b/irssistats.1 index 4416cbd..cff0d87 100644 --- a/irssistats.1 +++ b/irssistats.1 @@ -81,6 +81,14 @@ Default : lines Display quarters in top hours (smoother graphs) .IP "" 10 Default : no +.IP "weeks" 10 +Display last week statistics +.IP "" 10 +Default : no +.IP "months" 10 +Display last months statistics +.IP "" 10 +Default : no .IP "refresh_time" 10 Specifies the refresh time in seconds (0 to disable) .IP "" 10 @@ -168,4 +176,4 @@ Report bugs to royale@zerezo.com. .SH "AUTHOR" .PP Antoine Jacquet royale@zerezo.com -.\" created by instant / docbook-to-man, Sun 06 Feb 2005, 06:38 +.\" created by instant / docbook-to-man, Sun 20 May 2007, 18:12 diff --git a/irssistats.c b/irssistats.c index 66522e8..c4e9af2 100644 --- a/irssistats.c +++ b/irssistats.c @@ -1,5 +1,5 @@ /* - * irssistats version 0.72 + * irssistats version 0.73 * * This tool generates IRC stats based on irssi logs. * Usage: irssistats [/path/to/file.conf] @@ -49,7 +49,7 @@ #define MINWORDLENGTH 5 /* irssistats */ -#define VERSION "0.72" +#define VERSION "0.73" #define URL "http://royale.zerezo.com/irssistats/" /* Counters */ @@ -71,7 +71,7 @@ char *counters[NBCOUNTERS]={"C_SMILE","C_FROWN","C_EXCLAM","C_QUESTION","C_ME"," /* Languages */ #define NBLANGUAGES 11 -#define NBKEYS 39 +#define NBKEYS 41 char *keys[NBLANGUAGES][NBKEYS+1][2]= /* first key used for language name and abbreviation */ { { /* English language */ @@ -79,7 +79,9 @@ char *keys[NBLANGUAGES][NBKEYS+1][2]= /* first key used for language name and ab { "CHARSET", "ISO-8859-1" }, { "HEADER", "Statistics for %s by %s" }, { "LEGEND", "Legend" }, - { "LASTDAYS", "Lastdays statistics" }, + { "LASTDAYS", "Last days statistics" }, + { "LASTWEEKS", "Last weeks statistics" }, + { "LASTMONTHS", "Last months statistics" }, { "TOPHOURS", "Hourly statistics" }, { "TOPUSERS", "Most active people" }, { "OTHERS", "There are %d left not ranked..." }, @@ -122,6 +124,8 @@ char *keys[NBLANGUAGES][NBKEYS+1][2]= /* first key used for language name and ab { "HEADER", "Statistiques de %s par %s" }, { "LEGEND", "Légende" }, { "LASTDAYS", "Statistiques des derniers jours" }, + { "LASTWEEKS", "Statistiques des dernières semaines" }, + { "LASTMONTHS", "Statistiques des derniers mois" }, { "TOPHOURS", "Statistiques horaires" }, { "TOPUSERS", "Personnes les plus actives" }, { "OTHERS", "Il reste %d personnes non classées..." }, @@ -165,6 +169,8 @@ char *keys[NBLANGUAGES][NBKEYS+1][2]= /* first key used for language name and ab { "HEADER", "Statistiken für %s von %s" }, { "LEGEND", "Legende" }, { "LASTDAYS", "Statistik der letzten Tage" }, + { "LASTWEEKS", "Last weeks statistics" }, + { "LASTMONTHS", "Last months statistics" }, { "TOPHOURS", "Stündliche Statistik" }, { "TOPUSERS", "Die aktivsten Personen" }, { "OTHERS", "Es bleiben noch %d uneingetragene" }, @@ -192,7 +198,7 @@ char *keys[NBLANGUAGES][NBKEYS+1][2]= /* first key used for language name and ab { "C_EXCLAM", "schreit oft !" }, { "C_QUESTION", "stellt viele Fragen ?" }, { "C_ME", "mag /me'en" }, - { "C_TOPIC", "aendert oft das Topico" }, + { "C_TOPIC", "aendert oft das Topic" }, { "C_MODE", "aendert oft die Modes" }, { "C_KICK", "mag /kick'en" }, { "C_KICKED", "wird oft gekickt"}, @@ -208,6 +214,8 @@ char *keys[NBLANGUAGES][NBKEYS+1][2]= /* first key used for language name and ab { "HEADER", "Estadísticas de %s por %s" }, { "LEGEND", "Leyenda" }, { "LASTDAYS", "Estadísticas de los últimos días" }, + { "LASTWEEKS", "Last weeks statistics" }, + { "LASTMONTHS", "Last months statistics" }, { "TOPHOURS", "Estadísticas por horas" }, { "TOPUSERS", "Los que más escriben" }, { "OTHERS", "Hay %d más que no llegaron..." }, @@ -251,6 +259,8 @@ char *keys[NBLANGUAGES][NBKEYS+1][2]= /* first key used for language name and ab { "HEADER", "Statystyki dla %s zebrane przez %s" }, { "LEGEND", "Legenda" }, { "LASTDAYS", "Statystyki z ostatnich dni" }, + { "LASTWEEKS", "Last weeks statistics" }, + { "LASTMONTHS", "Last months statistics" }, { "TOPHOURS", "Statystyki godzinowe" }, { "TOPUSERS", "Najaktywniejsi" }, { "OTHERS", "Jest jeszcze %d nie sklasyfikowanych..." }, @@ -294,6 +304,8 @@ char *keys[NBLANGUAGES][NBKEYS+1][2]= /* first key used for language name and ab { "HEADER", "Statystyki dla %s przez %s" }, { "LEGEND", "Legenda" }, { "LASTDAYS", "Statystyki z ostatnich dni" }, + { "LASTWEEKS", "Last weeks statistics" }, + { "LASTMONTHS", "Last months statistics" }, { "TOPHOURS", "Statystyki godzinne" }, { "TOPUSERS", "Najaktywniejsi ludzie" }, { "OTHERS", "Zostalo jeszcze %d nie sklasyfikowanych..." }, @@ -337,6 +349,8 @@ char *keys[NBLANGUAGES][NBKEYS+1][2]= /* first key used for language name and ab { "HEADER", "Kanavan %s tilastot - %s" }, { "LEGEND", "Merkkien selitykset" }, { "LASTDAYS", "Viime päivien tilastot" }, + { "LASTWEEKS", "Last weeks statistics" }, + { "LASTMONTHS", "Last months statistics" }, { "TOPHOURS", "Tilastot tunneittain" }, { "TOPUSERS", "Aktiivisimmat ihmiset" }, { "OTHERS", "Jäljelle jäi %d joita ei listattu..." }, @@ -380,6 +394,8 @@ char *keys[NBLANGUAGES][NBKEYS+1][2]= /* first key used for language name and ab { "HEADER", "Statistiche per il canale %s di %s" }, { "LEGEND", "Legenda" }, { "LASTDAYS", "Statistiche degli ultimi giorni" }, + { "LASTWEEKS", "Last weeks statistics" }, + { "LASTMONTHS", "Last months statistics" }, { "TOPHOURS", "Statistiche in ore" }, { "TOPUSERS", "Utenti più attivi" }, { "OTHERS", "Ci sono %d utenti non classificati..." }, @@ -424,6 +440,8 @@ char *keys[NBLANGUAGES][NBKEYS+1][2]= /* first key used for language name and ab { "HEADER", "Statistieken voor %s door %s" }, { "LEGEND", "Legenda" }, { "LASTDAYS", "Statistieken van de laatste dagen" }, + { "LASTWEEKS", "Last weeks statistics" }, + { "LASTMONTHS", "Last months statistics" }, { "TOPHOURS", "Statistieken per uur" }, { "TOPUSERS", "Meest actieve mensen" }, { "OTHERS", "Er zijn nog %d mensen die de top niet haalden..." }, @@ -467,6 +485,8 @@ char *keys[NBLANGUAGES][NBKEYS+1][2]= /* first key used for language name and ab { "HEADER", "óÔÁÔÉÓÔÉËÁ ÄÌÑ %s ÏÔ %s" }, { "LEGEND", "ïÂÏÚÎÁÞÅÎÉÑ" }, { "LASTDAYS", "óÔÁÔÉÓÔÉËÁ ÐÏÓÌÅÄÎÉÈ ÄÎÅÊ" }, + { "LASTWEEKS", "Last weeks statistics" }, + { "LASTMONTHS", "Last months statistics" }, { "TOPHOURS", "ðÏÞÁÓÏ×ÁÑ ÓÔÁÔÉÓÔÉËÁ" }, { "TOPUSERS", "áËÔÉ×ÎÅÊÛÉÅ ÌÀÄÉ" }, { "OTHERS", "ïÓÔÁÌÏÓØ %d ÎÅÐÏÄÓÞÉÔÁÎÙÈ..." }, @@ -510,6 +530,8 @@ char *keys[NBLANGUAGES][NBKEYS+1][2]= /* first key used for language name and ab { "HEADER", "Statistika kanalile %s on koostanud %s" }, { "LEGEND", "Legend" }, { "LASTDAYS", "Viimaste päevade statistika" }, + { "LASTWEEKS", "Last weeks statistics" }, + { "LASTMONTHS", "Last months statistics" }, { "TOPHOURS", "Tunni statistika" }, { "TOPUSERS", "Kõige aktiivsemad inimesed" }, { "OTHERS", "%d inimest on rääkinud" }, @@ -574,6 +596,8 @@ time_t debut; int top_words=1; /* 0 = disabled */ int ranking=0; /* 0 = lines ; 1 = words ; 2 = letters */ int quarter=0; /* 1 = enabled */ +int months=0; /* 1 = enabled */ +int weeks=0; /* 1 = enabled */ int photo_size=60; struct user @@ -610,9 +634,10 @@ struct { int lines; int hours[4]; -} lastdays[31]; +} lastdays[31], lastweeks[31], lastmonths[31]; int days=0; char currday[16]; +int currwday=-1, currmon=-1; int hours[24*4]; int lines=0; @@ -862,6 +887,7 @@ void day_changed(char* date) { int i,j; char newday[16]; + struct tm currdate; memcpy(newday, date, 11); if (date[13]==':') @@ -886,6 +912,36 @@ void day_changed(char* date) memcpy(currday, newday, 15); if (debug==2) fprintf(stderr, "day %d changed to: %s\n", days, currday); + + /* try to parse the date for weeks/months stats */ + if (strptime(currday, "%a %b %d %Y", &currdate)) + { + /* each monday we change the week number */ + if (currdate.tm_wday == 1) + { + for (i=30;i>0;i--) + { + lastweeks[i].lines=lastweeks[i-1].lines; + for (j=0;j<4;j++) lastweeks[i].hours[j]=lastweeks[i-1].hours[j]; + } + lastweeks[0].lines=0; + for (j=0;j<4;j++) lastweeks[0].hours[j]=0; + } + /* if the month has changed */ + if (currdate.tm_mon != currmon && currmon > 0) + { + for (i=30;i>0;i--) + { + lastmonths[i].lines=lastmonths[i-1].lines; + for (j=0;j<4;j++) lastmonths[i].hours[j]=lastmonths[i-1].hours[j]; + } + lastmonths[0].lines=0; + for (j=0;j<4;j++) lastmonths[0].hours[j]=0; + } + currwday = currdate.tm_wday; + currmon = currdate.tm_mon; + + } } else { if (debug==2) fprintf(stderr, "but day did not change\n"); @@ -1088,6 +1144,10 @@ void parse_log(char *logfile) users[i].hours[hour/6]++; lastdays[0].lines++; lastdays[0].hours[hour/6]++; + lastweeks[0].lines++; + lastweeks[0].hours[hour/6]++; + lastmonths[0].lines++; + lastmonths[0].hours[hour/6]++; lines++; if (quarter) { @@ -1214,7 +1274,8 @@ void gen_xhtml(char *xhtmlfile) fprintf(fic,"\n\n",L("CHARSET")); if (refresh_time) fprintf(fic,"\n",refresh_time); - subtheme=strtok(theme,","); + strcpy(line, theme); + subtheme=strtok(line,","); fprintf(fic,"\n",subtheme,subtheme); while ((subtheme=strtok(NULL,","))!=NULL) fprintf(fic,"\n",subtheme,subtheme); @@ -1236,6 +1297,42 @@ void gen_xhtml(char *xhtmlfile) for (i=0;i<4;i++) fprintf(fic,"
%s %d-%d\n",i+1,L("HOURS"),i*6,i*6+5); fprintf(fic,"\n\n\n\n"); + if (months) + { + /* last months */ + fprintf(fic,"
\n

%s

\n\n\n",L("LASTMONTHS")); + max=-1; + for (i=30;i>=0;i--) if (lastmonths[i].lines>max) max=lastmonths[i].lines; + for (i=30;i>=0;i--) + { + fprintf(fic,"\n"); + } + fprintf(fic,"\n\n"); + for (i=30;i>=0;i--) + fprintf(fic,"\n",i); + fprintf(fic,"\n
%d",lastmonths[i].lines); + for (j=0;j<4;j++) if (lastmonths[i].hours[j]!=0) fprintf(fic,"
",j+1,150*lastmonths[i].hours[j]/max); + fprintf(fic,"
%d
\n
\n\n"); + } + + if (weeks) + { + /* last weeks */ + fprintf(fic,"
\n

%s

\n\n\n",L("LASTWEEKS")); + max=-1; + for (i=30;i>=0;i--) if (lastweeks[i].lines>max) max=lastweeks[i].lines; + for (i=30;i>=0;i--) + { + fprintf(fic,"\n"); + } + fprintf(fic,"\n\n"); + for (i=30;i>=0;i--) + fprintf(fic,"\n",i); + fprintf(fic,"\n
%d",lastweeks[i].lines); + for (j=0;j<4;j++) if (lastweeks[i].hours[j]!=0) fprintf(fic,"
",j+1,150*lastweeks[i].hours[j]/max); + fprintf(fic,"
%d
\n
\n\n"); + } + /* last days */ fprintf(fic,"
\n

%s

\n\n\n",L("LASTDAYS")); max=-1; @@ -1430,9 +1527,10 @@ void gen_xhtml(char *xhtmlfile) if (logo) fprintf(fic,"
\n\n"); /* end */ + fprintf(fic,"\n\n"); if (strcmp("none",footer)==0) { - fprintf(fic,"\n\n\n\n\n"); + fprintf(fic,"\n\n\n"); } else { @@ -1462,7 +1560,7 @@ void parse_config(char *configfile) char keyword[MAXLINELENGTH]; char value[MAXLINELENGTH]; int configlines=0; - int i; + int i,j; if (configfile!=NULL) { @@ -1627,8 +1725,22 @@ void parse_config(char *configfile) nburls=0; nbtopics=0; days=0; + currwday=-1; + currmon=-1; for (i=0;i<24*4;i++) hours[i]=0; lines=0; + for (i=0;i<31;i++) + { + lastdays[i].lines=0; + lastweeks[i].lines=0; + lastmonths[i].lines=0; + for (j=0;j<4;j++) + { + lastdays[i].hours[j]=0; + lastweeks[i].hours[j]=0; + lastmonths[i].hours[j]=0; + } + } freewords(&words); freeruswords(&ruswords); for (i=0;i + + weeks + + Display last week statistics + Default : no + + + + + months + + Display last months statistics + Default : no + + + refresh_time diff --git a/sample.configfile b/sample.configfile index d738852..963db35 100644 --- a/sample.configfile +++ b/sample.configfile @@ -32,17 +32,25 @@ theme : default,biseau,blue,dark,damier,grayscale,namour,niflheim,pisg,zeduel,ze # Allows you to disable top words list which is using a lot of memory # Default : yes -top_words : no +top_words : yes # Specifies which ranking method to use # Values : lines / words / letters # Default : lines -ranking : letters +ranking : lines # Display quarters in top hours (smoother graphs) # Default : no quarter : yes +# Display last weeks statistics +# Default : no +weeks : yes + +# Display last months statistics +# Default : no +months : yes + # Specifies the refresh time in seconds (0 to disable) # This option has no effect if you use a custom header : you'll have to include the refresh code yourself. # Default : 3600