2016-08-21 05:02:18 +00:00
|
|
|
#if defined(ENABLE_WWW)
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "bbs.h"
|
|
|
|
|
|
|
|
extern struct bbs_config conf;
|
|
|
|
|
|
|
|
char *www_last10() {
|
|
|
|
char *page;
|
|
|
|
int max_len;
|
|
|
|
int len;
|
|
|
|
char buffer[4096];
|
|
|
|
struct last10_callers callers[10];
|
|
|
|
|
2018-10-08 14:13:11 +00:00
|
|
|
int i, z;
|
2016-08-21 05:02:18 +00:00
|
|
|
struct tm l10_time;
|
2018-02-25 06:25:53 +00:00
|
|
|
FILE *fptr = fopen("last10v2.dat", "rb");
|
2016-08-21 05:02:18 +00:00
|
|
|
|
|
|
|
if (fptr != NULL) {
|
|
|
|
|
2018-10-08 14:13:11 +00:00
|
|
|
for (i = 0; i < 10; i++) {
|
2016-08-21 05:02:18 +00:00
|
|
|
if (fread(&callers[i], sizeof(struct last10_callers), 1, fptr) < 1) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fptr);
|
|
|
|
} else {
|
|
|
|
i = 0;
|
|
|
|
}
|
|
|
|
|
2018-10-09 15:55:13 +00:00
|
|
|
page = (char *)malloz(4096);
|
2016-08-21 05:02:18 +00:00
|
|
|
max_len = 4096;
|
|
|
|
len = 0;
|
2018-10-08 14:13:11 +00:00
|
|
|
|
2016-08-21 05:02:18 +00:00
|
|
|
sprintf(buffer, "<div class=\"content-header\"><h2>Last 10 Callers</h2></div>\n");
|
|
|
|
if (len + strlen(buffer) > max_len - 1) {
|
|
|
|
max_len += 4096;
|
|
|
|
page = (char *)realloc(page, max_len);
|
|
|
|
}
|
|
|
|
strcat(page, buffer);
|
|
|
|
len += strlen(buffer);
|
|
|
|
|
|
|
|
sprintf(buffer, "<div class=\"div-table\">\n");
|
|
|
|
if (len + strlen(buffer) > max_len - 1) {
|
|
|
|
max_len += 4096;
|
|
|
|
page = (char *)realloc(page, max_len);
|
|
|
|
}
|
|
|
|
strcat(page, buffer);
|
|
|
|
len += strlen(buffer);
|
2018-10-08 14:13:11 +00:00
|
|
|
|
|
|
|
for (z = 0; z < i; z++) {
|
2016-08-21 05:02:18 +00:00
|
|
|
localtime_r(&callers[z].time, &l10_time);
|
2017-10-03 02:09:50 +00:00
|
|
|
if (conf.date_style == 1) {
|
2018-02-25 06:25:53 +00:00
|
|
|
if (callers[z].calls == 1) {
|
|
|
|
sprintf(buffer, "<div class=\"last10-row\"><div class=\"last10-name\">%s</div><div class=\"last10-location\">%s</div><div class=\"last10-date\">%.2d:%.2d %.2d-%.2d-%.2d</div><div class=\"last10-new\"><img src=\"%sstatic/newuser.png\" /></div></div>\n", callers[z].name, callers[z].location, l10_time.tm_hour, l10_time.tm_min, l10_time.tm_mon + 1, l10_time.tm_mday, l10_time.tm_year - 100, conf.www_url);
|
|
|
|
} else {
|
|
|
|
sprintf(buffer, "<div class=\"last10-row\"><div class=\"last10-name\">%s</div><div class=\"last10-location\">%s</div><div class=\"last10-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", callers[z].name, callers[z].location, l10_time.tm_hour, l10_time.tm_min, l10_time.tm_mon + 1, l10_time.tm_mday, l10_time.tm_year - 100);
|
|
|
|
}
|
2017-10-03 02:09:50 +00:00
|
|
|
} else {
|
2018-02-25 06:25:53 +00:00
|
|
|
if (callers[z].calls == 1) {
|
|
|
|
sprintf(buffer, "<div class=\"last10-row\"><div class=\"last10-name\">%s</div><div class=\"last10-location\">%s</div><div class=\"last10-date\">%.2d:%.2d %.2d-%.2d-%.2d</div><div class=\"last10-new\"><img src=\"%sstatic/newuser.png\" /></div></div>\n", callers[z].name, callers[z].location, l10_time.tm_hour, l10_time.tm_min, l10_time.tm_mday, l10_time.tm_mon + 1, l10_time.tm_year - 100, conf.www_url);
|
|
|
|
} else {
|
|
|
|
sprintf(buffer, "<div class=\"last10-row\"><div class=\"last10-name\">%s</div><div class=\"last10-location\">%s</div><div class=\"last10-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", callers[z].name, callers[z].location, l10_time.tm_hour, l10_time.tm_min, l10_time.tm_mday, l10_time.tm_mon + 1, l10_time.tm_year - 100);
|
|
|
|
}
|
2017-10-03 02:09:50 +00:00
|
|
|
}
|
2016-08-21 05:02:18 +00:00
|
|
|
if (len + strlen(buffer) > max_len - 1) {
|
|
|
|
max_len += 4096;
|
|
|
|
page = (char *)realloc(page, max_len);
|
|
|
|
}
|
|
|
|
strcat(page, buffer);
|
|
|
|
len += strlen(buffer);
|
|
|
|
}
|
2018-10-08 14:13:11 +00:00
|
|
|
|
2016-08-21 05:02:18 +00:00
|
|
|
sprintf(buffer, "</div>\n");
|
|
|
|
if (len + strlen(buffer) > max_len - 1) {
|
|
|
|
max_len += 4096;
|
|
|
|
page = (char *)realloc(page, max_len);
|
|
|
|
}
|
|
|
|
strcat(page, buffer);
|
|
|
|
len += strlen(buffer);
|
2018-10-08 14:13:11 +00:00
|
|
|
|
2016-08-21 05:02:18 +00:00
|
|
|
return page;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|