New Last 10 Callers

This commit is contained in:
Andrew Pamment
2018-02-25 16:25:53 +10:00
parent ac4c525415
commit 70dcde1f75
12 changed files with 62 additions and 18 deletions

View File

@@ -672,7 +672,7 @@ void record_last10_callers(struct user_record *user) {
struct last10_callers callers[10];
int i,j;
FILE *fptr = fopen("last10.dat", "rb");
FILE *fptr = fopen("last10v2.dat", "rb");
if (fptr != NULL) {
for (i=0;i<10;i++) {
@@ -690,13 +690,13 @@ void record_last10_callers(struct user_record *user) {
strcpy(new_entry.name, user->loginname);
strcpy(new_entry.location, user->location);
new_entry.time = time(NULL);
new_entry.calls = user->timeson;
if (i == 10) {
j = 1;
} else {
j = 0;
}
fptr = fopen("last10.dat", "wb");
fptr = fopen("last10v2.dat", "wb");
for (;j<i;j++) {
fwrite(&callers[j], sizeof(struct last10_callers), 1, fptr);
}
@@ -710,7 +710,7 @@ void display_last10_callers(struct user_record *user) {
int i,z;
struct tm l10_time;
FILE *fptr = fopen("last10.dat", "rb");
FILE *fptr = fopen("last10v2.dat", "rb");
time_t l10_timet;
s_printf("\e[2J\e[1;1H");
@@ -735,9 +735,9 @@ void display_last10_callers(struct user_record *user) {
l10_timet = callers[z].time;
localtime_r(&l10_timet, &l10_time);
if (conf.date_style == 1) {
s_printf(get_string(4), 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);
s_printf(get_string(4), 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, (callers[z].calls == 1 ? 'N' : ' '));
} else {
s_printf(get_string(4), 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);
s_printf(get_string(4), 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, (callers[z].calls == 1 ? 'N' : ' '));
}
}
s_printf(get_string(5));

View File

@@ -43,6 +43,7 @@ struct last10_callers {
char name[17];
char location[33];
time_t time;
int calls;
}__attribute__((packed));
struct text_file {

View File

@@ -87,7 +87,7 @@ int l_bbsReadLast10(lua_State *L) {
struct last10_callers l10;
FILE *fptr;
fptr = fopen("last10.dat", "rb");
fptr = fopen("last10v2.dat", "rb");
if (!fptr) {
return 0;
}
@@ -100,8 +100,8 @@ int l_bbsReadLast10(lua_State *L) {
lua_pushstring(L, l10.name);
lua_pushstring(L, l10.location);
lua_pushnumber(L, l10.time);
return 3;
lua_pushnumber(L, l10.calls);
return 4;
}
int l_bbsGetEmailCount(lua_State *L) {

View File

@@ -17,7 +17,7 @@ char *www_last10() {
int i,z;
struct tm l10_time;
FILE *fptr = fopen("last10.dat", "rb");
FILE *fptr = fopen("last10v2.dat", "rb");
if (fptr != NULL) {
@@ -56,9 +56,17 @@ char *www_last10() {
for (z=0;z<i;z++) {
localtime_r(&callers[z].time, &l10_time);
if (conf.date_style == 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>\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);
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);
}
} 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);
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);
}
}
if (len + strlen(buffer) > max_len - 1) {
max_len += 4096;