#include "out_formats.h" #include "out_xhtmlgen.h" #include #include #define SET_MAX_IMAGES (4) #define SET_MAX_HAPPY (6) #define SET_MAX_PER_ROW (5) int FUNCTION_NAME(FILE *outFile, t_stats *pStats, t_fisgconfig *pCfg) { char *hBarImages[SET_MAX_IMAGES] = { "blue-h.png", "green-h.png", "yellow-h.png", "red-h.png" }; char *vBarImages[SET_MAX_IMAGES] = { "blue-v.png", "green-v.png", "yellow-v.png", "red-v.png" }; t_ulint j, iRank; int i, iHour; t_float graphScale, happyScale, sadScale; t_user_entry *tmpUser; time_t tmpTime; struct tm *tmpLocalTime; char tmpTimeStr[SET_MAX_BUF]; t_str_index *tmpI; t_str_node *tmpS; /* Get time/date string */ time(&tmpTime); tmpLocalTime = localtime(&tmpTime); if (strftime(tmpTimeStr, sizeof(tmpTimeStr), pCfg->dateFormat, tmpLocalTime) == 0) { /* Unable to create string, make it empty */ tmpTimeStr[0] = 0; } /* Output stats as XHTML */ fprintf(outFile, HTML_DOCTYPE HTML_TAG "\n" " \n" " \n" ); fprintf(outFile, " \n" " \n" " " FISG_NAME " Statistics for %s%s%s\n" "\n" "\n", xhtml_cfg.cssPath, pCfg->ircChannel, (pCfg->ircNetwork) ? " @ " : "", (pCfg->ircNetwork) ? pCfg->ircNetwork : "" ); fprintf(outFile, "
\n" "
\n" "
\n" "

%s%s%s

\n" "

Statistics generated on %s

\n" /* "

During this %ld-day reporting period, a total of %ld different nicks/users were represented on %s.

\n" */ "

A total of %ld different nicks/users were represented on %s.

\n" "%s%s%s" "
\n", pCfg->ircChannel, (pCfg->ircNetwork) ? " @ " : "", (pCfg->ircNetwork) ? pCfg->ircNetwork : "", tmpTimeStr, /* pStats->nDays, */ pStats->usersList->n, pCfg->ircChannel, (pCfg->message) ? "

" : "", (pCfg->message) ? pCfg->message : "", (pCfg->message) ? "

\n" : "" ); /* * DAILY ACTIVITY */ if (pCfg->statActiveTimes) { if (pStats->activityPeak >= 0) if (pStats->fActivityPerHour[pStats->activityPeak] > 0) { fprintf(outFile, "\n" "
\n" "

Most active times

\n" " \n" " \n" ); graphScale = (100 / pStats->fActivityPerHour[pStats->activityPeak]); for (iHour = 0; iHour < SET_HOURS_DAY; iHour++) { fprintf(outFile, " %1.1f%%
" "\"%1.1f%%\"\n", pStats->fActivityPerHour[iHour], xhtml_cfg.dataPath, vBarImages[iHour / SET_DAY_DIVISOR], (int) (pStats->fActivityPerHour[iHour] * graphScale), pStats->fActivityPerHour[iHour]); } fprintf(outFile, " \n" " \n" ); for (iHour = 0; iHour < SET_HOURS_DAY; iHour++) { fprintf(outFile, " %i\n", (iHour == pStats->activityPeak) ? "hirank" : "rank", iHour); } fprintf(outFile, " \n" " \n" "\n" " \n" " \n" ); for (iHour = 0; iHour < SET_HOURS_DAY; iHour += SET_DAY_DIVISOR) { fprintf(outFile, " \"%i-%i\" = %i-%i\n", xhtml_cfg.dataPath, hBarImages[iHour / SET_DAY_DIVISOR], iHour, (iHour+SET_DAY_DIVISOR-1), iHour, (iHour+SET_DAY_DIVISOR-1)); } fprintf(outFile, " \n" " \n" "
\n" ); } } /* if (CFG_GEN_STAT_ACTIVE) */ /* * TOP TALKERS */ if (pCfg->statTopUsers) { fprintf(outFile, "\n" "
\n" "

Most active users

\n" " \n" " \n" " #\n" ); fprintf(outFile, "%s" " Nickname\n" " Lines\n" " Activity\n" " Words\n" " W/P\n" " C/W\n" "%s" "%s" " \n", (pCfg->showHappy) ? " ?\n" : "", (pCfg->showComment) ? " Comment\n" : "", (pCfg->showPicture) ? " Picture\n" : "" ); if (fabs(pStats->mostHappy->fHappiness) > 0) happyScale = fabs(pStats->mostHappy->fHappiness); else happyScale = 1.0f; if (fabs(pStats->mostSad->fHappiness) > 0) sadScale = fabs(pStats->mostSad->fHappiness); else sadScale = 1.0f; for (iRank = 0; iRank < ((pStats->usersList->n >= pCfg->showTopUserMax) ? pCfg->showTopUserMax : pStats->usersList->n); iRank++) { /* Get user */ tmpUser = pStats->usersList->ppIndex[iRank]; if (!tmpUser) break; /* Print one line */ fprintf(outFile, " \n" " %ld\n", (iRank + 1) ); if (pCfg->showHappy) { if (tmpUser->fHappiness > 0) j = 3 + (int) ((tmpUser->fHappiness * 3.0f) / happyScale); else j = 3 + (int) ((tmpUser->fHappiness * 2.0f) / sadScale); fprintf(outFile, " \"%ld\"\n", xhtml_cfg.dataPath, j, j); } /* Print user handle with link URL, if specified */ if (tmpUser->linkURL && pCfg->showURL) { fprintf(outFile, " linkURL); fprintf(outFile, "\">"); xml_fprintf_entitize(outFile, tmpUser->userHandle); fprintf(outFile, "\n"); } else { fprintf(outFile, " "); xml_fprintf_entitize(outFile, tmpUser->userHandle); fprintf(outFile, "\n"); } fprintf(outFile, " %ld\n" " ", tmpUser->nPublics ); for (iHour = 0; iHour < SET_HOURS_DAY; iHour += SET_DAY_DIVISOR) { graphScale = 0; for (j = 0; j < SET_DAY_DIVISOR; j++) graphScale += (tmpUser->fActivityPerHour[iHour + j] / 1.5f); if (graphScale >= 1.0f) { fprintf(outFile, "\"\"", xhtml_cfg.dataPath, hBarImages[iHour / SET_DAY_DIVISOR], (int) (graphScale)); } } fprintf(outFile, "\n" " %ld\n" " %1.2f\n" " %1.2f\n", tmpUser->nWords, tmpUser->fWordsPerPublic, tmpUser->fCharsPerWord ); if (pCfg->showComment) { fprintf(outFile, " "); if (tmpUser->sComment) xml_fprintf_entitize(outFile, tmpUser->sComment); fprintf(outFile, "\n"); } if (pCfg->showPicture) { fprintf(outFile, " "); if (tmpUser->picPath) { fprintf(outFile, "picPath); fprintf(outFile, "\">"); } fprintf(outFile, "\n"); } fprintf(outFile, " \n"); } fprintf(outFile, " \n" "\n" ); /* * ALMOST MADE IT... */ if (pCfg->statAlmostTop) { if (iRank < pStats->usersList->n) { fprintf(outFile, "

These didn't make it to the top:

\n" " \n" ); j = (pStats->usersList->n >= (iRank + pCfg->showAlmostMax)) ? (iRank + pCfg->showAlmostMax) : pStats->usersList->n; for (i = -1; iRank < j; iRank++) { /* Get user */ tmpUser = pStats->usersList->ppIndex[iRank]; if (!tmpUser) break; if (i < 1) { if (i >= 0) fprintf(outFile, " \n"); if ((j - iRank) >= SET_MAX_PER_ROW) fprintf(outFile, " \n"); i = SET_MAX_PER_ROW; } /* Print user handle with link URL, if specified */ if (tmpUser->linkURL && pCfg->showURL) { fprintf(outFile, " linkURL); fprintf(outFile, "\">"); xml_fprintf_entitize(outFile, tmpUser->userHandle); fprintf(outFile, " (%ld)\n", tmpUser->nPublics); } else { fprintf(outFile, " "); xml_fprintf_entitize(outFile, tmpUser->userHandle); fprintf(outFile, " (%ld)\n", tmpUser->nPublics); } i--; } if (i >= 0) fprintf(outFile, " \n"); fprintf(outFile, " \n" ); /* Rest of nicks */ if (iRank < pStats->usersList->n) { fprintf(outFile, "

There were also %ld other nicks

\n", (pStats->usersList->n - iRank) ); } } } /* if (CFG_GEN_STAT_ALMOST) */ fprintf(outFile, "
\n" "\n" ); } /* if (CFG_GEN_STAT_TOP) */ /* * MOST REFERENCED URLS */ tmpI = pStats->urlIndex; if (pCfg->statURLs && tmpI) { fprintf(outFile, "
\n" "

Most referenced URLs

\n" " \n" " \n" " #\n" " URL\n" " References\n" " \n" ); for (iRank = 0; iRank < ((tmpI->n >= pCfg->showURLsMax) ? pCfg->showURLsMax : tmpI->n); iRank++) { tmpS = tmpI->ppIndex[iRank]; fprintf(outFile, " %ld" "pcStr); fprintf(outFile, "\">http://"); xml_fprintf_entitize(outFile, tmpS->pcStr); fprintf(outFile, "%ld\n", tmpS->nUsed); } fprintf(outFile, " \n" "
\n" "\n" ); } /* * BIG NUMBERS */ if (pCfg->statBigNumbers) { fprintf(outFile, "
\n" "

Big Numbers

\n"); if (pStats->mostStupid && (pStats->mostStupid->nQuestions > 0)) { fprintf(outFile, "

\n" " Is %s stupid or just asking too many questions? %1.1f%% of his lines contained a question!\n" "

\n", pStats->mostStupid->userHandle, ((t_float) pStats->mostStupid->nQuestions / (t_float) pStats->mostStupid->nPublics) * 100.0f); } if (pStats->mostLoud && (pStats->mostLoud->nYelling > 0)) { fprintf(outFile, "

\n" " The loudest one was %s, who yelled %1.1f%% of the time." "

\n", pStats->mostLoud->userHandle, ((t_float) pStats->mostLoud->nYelling / (t_float) pStats->mostLoud->nPublics) * 100.0f); } if (pStats->mostURLs && (pStats->mostURLs->nURLs > 0)) { fprintf(outFile, "

\n" " Total of %ld URLs were pasted by %s!!\n" "

\n", pStats->mostURLs->nURLs, pStats->mostURLs->userHandle); } if (pStats->mostJoins && (pStats->mostJoins->nJoins > 0)) { fprintf(outFile, "

\n" " %s didn't know whether to stay. He/she joined the channel %ld times!\n" "

\n", pStats->mostJoins->userHandle, pStats->mostJoins->nJoins); } if (pStats->mostKicks && (pStats->mostKicks->nKicks > 0)) { fprintf(outFile, "

\n" " %s kicked the ass most, %ld times to be exact!\n" "

\n", pStats->mostKicks->userHandle, pStats->mostKicks->nKicks); } if (pStats->mostKicked && (pStats->mostKicked->nGotKicked > 0)) { fprintf(outFile, "

\n" " Obviously someone does not like %s, he/she was kicked %ld times!\n" "

\n", pStats->mostKicked->userHandle, pStats->mostKicked->nGotKicked); } if (pStats->mostCaps && (pStats->mostCaps->fCapsPercent > 0.1f)) { fprintf(outFile, "

\n" " %s is a clear caps-abuser, %1.1f%% of time he/she wrote in CAPS." "

\n", pStats->mostCaps->userHandle, pStats->mostCaps->fCapsPercent); } if (pStats->mostHappy) { fprintf(outFile, "

\n" " %s is either using drugs or is otherwise very happy person ;D" "

\n", pStats->mostHappy->userHandle); } if (pStats->mostSad) { fprintf(outFile, "

\n" " On the other hand %s seems to be quite sad :(" "

\n", pStats->mostSad->userHandle); } if (pStats->mostTopics && (pStats->mostTopics->nTopics > 0)) { fprintf(outFile, "

\n" " %s changed the topic %ld times!\n" "

\n", pStats->mostTopics->userHandle, pStats->mostTopics->nTopics); } fprintf(outFile, "
\n" "\n" ); } /* * LATEST TOPICS */ tmpI = pStats->topicIndex; if (pCfg->statTopics && tmpI) { fprintf(outFile, "
\n" "

Latest topics

\n" " \n" " \n" " Topic\n" " Set by\n" " \n" ); for (iRank = 0; iRank < ((tmpI->n >= pCfg->showTopicsMax) ? pCfg->showTopicsMax : tmpI->n); iRank++) { tmpS = tmpI->ppIndex[iRank]; fprintf(outFile, " "); xml_fprintf_entitize(outFile, tmpS->pcStr); fprintf(outFile, ""); if (tmpS->pData) { xml_fprintf_entitize(outFile, ((t_user_entry *) tmpS->pData)->userHandle); } fprintf(outFile, "\n"); } fprintf(outFile, " \n" "
\n" "\n" ); } /* * INFO footer */ fprintf(outFile, "
\n" "

Totals analyzed: %ld lines in %ld logfiles" " summing to appr. %1.2f MB.

\n" "

Statistics generated by " "" FISG_NAME " (" FISG_FULLNAME ") v" FISG_VERSION " " FISG_COPYRIGHT "

\n" "

Stats generated in %ld hours, %ld minutes and %ld seconds.

\n" "
\n", pStats->nLines, pStats->nLogFiles, ((t_float) pStats->nChars) / (1024.0f*1024.0f), (pStats->nTimeElapsed / (60*60)), (pStats->nTimeElapsed % (60*60)) / 60, (pStats->nTimeElapsed % (60*60)) % 60 ); /* Output HTML footer */ fprintf(outFile, "\n" "
\n" "
\n" "\n" "\n"); return 0; }