#if defined(ENABLE_WWW) #include #include #include #include "bbs.h" extern struct bbs_config conf; char *www_last10() { size_t n = 0; stralloc page = EMPTY_STRALLOC; struct last10_callers callers[10]; FILE *fptr = fopen("last10v2.dat", "rb"); if (fptr != NULL) { for ( ; n < 10; ++n) if (fread(&callers[n], sizeof(callers[n]), 1, fptr) != sizeof(callers[n])) break; fclose(fptr); } stralloc_copys(&page, "

Last 10 Callers

\n"); stralloc_cats(&page, "
\n"); for (size_t i = 0; i < n; ++i) { struct tm called; char buffer[32]; stralloc_cats(&page, "
"); stralloc_cats(&page, callers[i].name); stralloc_cats(&page, "
"); stralloc_cats(&page, callers[i].location); stralloc_cats(&page, "
"); stralloc_cats(&page, "
"); localtime_r(&callers[i].time, &called); if (conf.date_style == 1) strftime(buffer, sizeof buffer, "%H:%M %m-%d-%y", &called); else strftime(buffer, sizeof buffer, "%H:%M %d-%m-%y", &called); stralloc_cats(&page, buffer); stralloc_cats(&page, "
\n"); if (callers[i].calls == 1) { stralloc_cats(&page, "
"); } stralloc_cats(&page, "
\n"); } stralloc_cats(&page, "
\n"); stralloc_0(&page); return page.s; } #endif