diff --git a/.gitignore b/.gitignore index b55fa24..a6be96e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ magicka msgs/* node* doors/* +last10.dat diff --git a/bbs.c b/bbs.c index f390ef6..7748dc6 100644 --- a/bbs.c +++ b/bbs.c @@ -313,6 +313,59 @@ void disconnect(int socket) { exit(0); } +void display_last10_callers(int socket, struct user_record *user, int record) { + struct last10_callers callers[10]; + struct last10_callers new_entry; + int i,z,j; + char buffer[256]; + struct tm l10_time; + FILE *fptr = fopen("last10.dat", "rb"); + + s_putstring(socket, "\r\n\e[1;37mLast 10 callers:\r\n"); + s_putstring(socket, "\e[1;30m-------------------------------------------------------------------------------\r\n"); + + if (fptr != NULL) { + + for (i=0;i<10;i++) { + if (fread(&callers[i], sizeof(struct last10_callers), 1, fptr) < 1) { + break; + } + } + + fclose(fptr); + } else { + i = 0; + } + + for (z=0;zloginname) != 0 && record) { + memset(&new_entry, 0, sizeof(struct last10_callers)); + strcpy(new_entry.name, user->loginname); + strcpy(new_entry.location, user->location); + new_entry.time = time(NULL); + + if (i == 10) { + j = 1; + } else { + j = 0; + } + fptr = fopen("last10.dat", "wb"); + for (;j