From 22a4230dfc105e0160ba50e737a430ad60fb2cad Mon Sep 17 00:00:00 2001 From: Antoine Jacquet Date: Sat, 16 Nov 2002 00:00:00 +0100 Subject: [PATCH] version 0.42 * W3C validated HTML * better quote selection during nick alias * auto refresh (suggested by Charles Blackburn) --- README | 2 +- irssistats.c | 69 ++++++++++++++++++++++++++---------------- pix/valid-html401.gif | Bin 0 -> 2328 bytes 3 files changed, 44 insertions(+), 27 deletions(-) create mode 100644 pix/valid-html401.gif diff --git a/README b/README index 0a2c7be..67ca6e8 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -irssistats 0.41 +irssistats 0.42 site: http://royale.zerezo.com/programmation/irssistats/ mail: royale@zerezo.com diff --git a/irssistats.c b/irssistats.c index 1ddd0cc..b5792b1 100644 --- a/irssistats.c +++ b/irssistats.c @@ -6,6 +6,10 @@ #include #include +/* Options */ +#define REFRESH_TIME 3600 +#define W3C_LINK + /* Config */ #define MAXUSERS 5000 #define MAXNICKLENGTH 50 @@ -19,7 +23,7 @@ #define MINWORDLENGTH 5 /* irssistats */ -#define VERSION "0.41" +#define VERSION "0.42" #define URL "http://royale.zerezo.com/programmation/irssistats/" /* Counters */ @@ -98,7 +102,7 @@ char *keys[NBLANGUAGES][NBKEYS+1][2]= /* first key used for language name and ab { "AVGLETTERS", "lettres/lignes" }, { "HOURS", "heures" }, { "QUOTE", "message aléatoire" }, - { "TOPUSERSTIME", "Personnes les plus actives par période de la journée" }, + { "TOPUSERSTIME", "Personnes les plus actives par période de la journée" }, { "RANDTOPICS", "Quelques topics" }, { "CHANGEDBY", "changé par" }, { "NEWTOPIC", "nouveau topic" }, @@ -354,6 +358,7 @@ struct int hours[4]; char quote[MAXQUOTELENGTH+1]; int counters[NBCOUNTERS]; + int temp; } users[MAXUSERS]; int nbusers=0; @@ -481,6 +486,7 @@ int dichotomic(char *nick) for (j=0;j<4;j++) users[i].hours[j]=users[i-1].hours[j]; strcpy(users[i].quote,users[i-1].quote); for (j=0;j=0)) { - if (users[i].lines>temp) /* for nick alias, keep the random quote of the most used nick */ + if (users[i].temp>users[user].temp) /* for nick alias, keep the random quote of the most used nick */ { strcpy(users[user].quote,users[i].quote); - temp=users[i].lines; + users[user].temp=users[i].temp; } users[user].lines+=users[i].lines; users[user].letters+=users[i].letters; @@ -723,51 +730,56 @@ int main(int argc,char *argv[]) /*** HTML ***/ /* header */ + printf("\n\n"); printf("\n\n",VERSION,URL); - printf("\n\n\n\n"); + printf("<html>\n\n<head>\n<title>"); printf(L("HEADER"),channel,maintainer); - printf("\n\n\n"); - printf("\n\n
\n\n

",T("BGCOLOR"),T("TEXT"),T("LINK"),T("VLINK"),T("ALINK"),T("TITLE1")); + printf("\n\n"); +#ifdef REFRESH_TIME + printf("\n",REFRESH_TIME); +#endif + printf("\n\n\n"); + printf("\n\n
\n\n",T("BGCOLOR"),T("TEXT"),T("LINK"),T("VLINK"),T("ALINK"),T("TITLE1")); printf(L("HEADER"),channel,maintainer); - printf("

\n%s
\n

\n\n",ctime(&debut)); + printf("


\n%s
\n

\n\n",ctime(&debut)); /* legend */ - printf("

%s

\n\n\n",T("TITLE2"),L("LEGEND"),T("BGTABLE")); - for (i=0;i<4;i++) printf("\n",i+1,L("HOURS"),i*6,i*6+5); + printf("%s

\n
: %s %d-%d
\n\n",T("TITLE2"),L("LEGEND"),T("BGTABLE")); + for (i=0;i<4;i++) printf("\n",i+1,L("HOURS"),i*6,i*6+5); printf("\n
\"\" : %s %d-%d
\n

\n\n"); /* last days */ - printf("

%s

\n\n\n",T("TITLE2"),L("LASTDAYS")); + printf("%s

\n
\n\n",T("TITLE2"),L("LASTDAYS")); max=-1; for (i=30;i>=0;i--) if (lastdays[i].lines>max) max=lastdays[i].lines; for (i=30;i>=0;i--) { printf("\n"); } printf("\n\n"); for (i=30;i>=0;i--) - printf("\n",T("BGTABLE"),i); + printf("\n",T("BGTABLE"),i); printf("\n
%d
",lastdays[i].lines); - for (j=0;j<4;j++) if (lastdays[i].hours[j]!=0) printf("
",j+1,150*lastdays[i].hours[j]/max); + for (j=0;j<4;j++) if (lastdays[i].hours[j]!=0) printf("\"\"
",j+1,150*lastdays[i].hours[j]/max); printf("
%d%d
\n

\n\n"); /* top hours */ - printf("

%s

\n\n\n",T("TITLE2"),L("TOPHOURS")); + printf("%s

\n
\n\n",T("TITLE2"),L("TOPHOURS")); max=-1; for (i=0;i<24;i++) if (hours[i]>max) max=hours[i]; for (i=0;i<24;i++) { printf("\n"); } printf("\n\n"); for (i=0;i<24;i++) - printf("\n",T("BGTABLE"),i); + printf("\n",T("BGTABLE"),i); printf("\n
%.1f%%
",lines!=0?(float)100*hours[i]/lines:0); - if (hours[i]!=0) printf("
",i/6+1,150*hours[i]/max); + if (hours[i]!=0) printf("\"\"
",i/6+1,150*hours[i]/max); printf("
%d%d
\n

\n\n"); /* top users */ - printf("

%s

\n",T("TITLE2"),L("TOPUSERS")); + printf("%s

\n",T("TITLE2"),L("TOPUSERS")); printf("\n\n",T("BGTITLE"),L("NICK"),T("BGTITLE"),L("NBLINES"),T("BGTITLE"),L("HOURS"),T("BGTITLE"),L("AVGLETTERS"),T("BGTITLE"),L("QUOTE")); for (i=1;i<=NBUSERS;i++) { @@ -777,8 +789,8 @@ int main(int argc,char *argv[]) if (user!=-1) { printf("\n"); users[user].lines=-1; @@ -796,7 +808,7 @@ int main(int argc,char *argv[]) printf("

\n\n"); /* top users by time */ - printf("

%s

\n",T("TITLE2"),L("TOPUSERSTIME")); + printf("%s

\n",T("TITLE2"),L("TOPUSERSTIME")); printf("
%s%s%s%s%s
%d%s%d",T("BGTABLE"),i,T("BGTABLE"),users[user].nick,T("BGTABLE"),users[user].lines,T("BGTABLE")); - for (j=0;j<4;j++) if (users[user].hours[j]!=0) printf("",j+1,100*users[user].hours[j]/users[user].lines); - printf("%d\"",T("BGTABLE"),users[user].lines!=0?users[user].letters/users[user].lines:0,T("BGTABLE"),users[user].lines!=0?users[user].letters/users[user].lines:0,T("BGTABLE")); + for (j=0;j<4;j++) if (users[user].hours[j]!=0) printf("\"\"",j+1,100*users[user].hours[j]/users[user].lines); + printf("%d\"\"\"",T("BGTABLE"),users[user].lines!=0?users[user].letters/users[user].lines:0,T("BGTABLE"),users[user].lines!=0?users[user].letters/users[user].lines:0,T("BGTABLE")); printhtml(users[user].quote); printf("\"
\n"); for (i=0;i<4;i++) printf("",T("BGTITLE"),L("HOURS"),i*6,i*6+5); printf("\n"); @@ -820,7 +832,7 @@ int main(int argc,char *argv[]) printf("
%s %d-%d
\n

\n\n"); /* random topics */ - printf("

%s

\n",T("TITLE2"),L("RANDTOPICS")); + printf("%s

\n",T("TITLE2"),L("RANDTOPICS")); printf("\n\n",T("BGTITLE"),L("CHANGEDBY"),T("BGTITLE"),L("NEWTOPIC")); for (i=nbtopics=0;i--) { @@ -831,25 +843,27 @@ int main(int argc,char *argv[]) printf("
%s%s
\n

\n\n"); /* random urls */ - printf("

%s

\n",T("TITLE2"),L("RANDURLS")); + printf("%s

\n",T("TITLE2"),L("RANDURLS")); printf("\n\n",T("BGTITLE"),L("POSTEDBY"),T("BGTITLE"),L("POSTEDURL")); for (i=nburls=0;i--) { - printf("\n"); } printf("
%s%s
%s\"",T("BGTABLE"),urls[i].nick,T("BGTABLE"),urls[i].url); + printf("
%s\""); printhtml(urls[i].shorturl); printf("\"
\n

\n\n"); /* top words */ - printf("

%s

\n",T("TITLE2"),L("TOPWORDS")); + printf("%s

\n",T("TITLE2"),L("TOPWORDS")); printf("\n\n",T("BGTITLE"),L("WORD"),T("BGTITLE"),L("OCCURRENCES")); for (i=0;i\n",T("BGTABLE"),i+1,T("BGTABLE"),topwords[i].word,T("BGTABLE"),topwords[i].nb); printf("
%s%s
%d\"%s\"%d
\n

\n\n"); /* big numbers */ - printf("

%s

\n",T("TITLE2"),L("BIGNUMBERS")); + printf("%s

\n",T("TITLE2"),L("BIGNUMBERS")); printf("\n\n",T("BGTITLE"),L("NICK"),T("BGTITLE"),L("NUMBERS"),T("BGTITLE"),L("NBLINES")); for (i=0;i\n%s irssistats %s",L("FOOTER"),URL,VERSION); +#ifdef W3C_LINK + printf("

\n\n"); +#endif printf("\n\n\n\n\n\n\n"); return(0); diff --git a/pix/valid-html401.gif b/pix/valid-html401.gif new file mode 100644 index 0000000000000000000000000000000000000000..1270561e1721896ccfb103cacb714c940785dfaf GIT binary patch literal 2328 zcmd6m`BxK%7RLt&I0$GEfkXibTN6Rc2wGx&ErbSeC}Lq?6RjW#97SNcOe7M5BnqJliIqiI8l^Bu z0g3EZBZ(sni4Z7c(P6m5M2oPLVw6KMSi;~k4Tb6$)W~AI7By%PD~E9mY|){11I7?? z6N^YhAVnZr8s#*oNrxF()Xw9GLZWq;7%&opc&$U_(83y0PM|V|fMB@@MUBEo$K~nvm-p%sNyi5n4Eh560383WsPC(P>bl4zn8_3Ypb_jq(_$ff-Vc!V(Ro zup2QPm2o&AWQ=a3Z-;%Tq{8}LYM|&22jwX#(>eB zf?zc|qXc09IR!u@08xO9G@7iugXV8O$3e;EF!29Zl5v3(089p=KA?U0iFnWs%mM>a znj5=zgR@f5-sa<%D}3o!PQVN(B12tGn82eFIW^ z$FQ^@X}{mj@$P5C{wXD$3u10d7YBv)7p2$xgaiB5{Uc;&$=a}fjXbM4|3Ry3TD`(A zQWbCkA3UdO1;CiBk--!|zjxTV@zIOk2DD{U%l5628D}%v^1XI!EzIc3{!K6R4iP*N z241=QP3nc$S)F*pxfMi;uP~ydDelWdJ$u_?^9R0fEt@O!TNnTC<<_pT7SLbGm3e(? zY_&ezH<5U-z3%L0uHvBoVm|x)%jU`3U8HYtA0X}0mht(@*F#Z2ZN9I4(UGNzr5?=g zLZ>HK>akgAJHBdpcjZRyrA;>$yy{k_91D4!Fi1-!aPgF zoa#pOZAqv{%y&bo)Tn9E>Xk`8g7}1_u3@TtT|ummAh)z#>M|ptud#31iu=dEh}kbS z)`4_sw2PN+aF28N&4r`)4sFv)uLdlJB}0eHeAlj7Rg!Sw>f!QN+CicdlAX#a&fW05 ze*LM_5gA2cE%%f`IdcZWx7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