diff --git a/src/bbs.c b/src/bbs.c index bba54ad..6828517 100644 --- a/src/bbs.c +++ b/src/bbs.c @@ -684,7 +684,12 @@ void record_last10_callers(struct user_record *user) { struct last10_callers callers[10]; int i, j; - FILE *fptr = fopen("last10v2.dat", "rb"); + + char last10_path[PATH_MAX]; + + snprintf(last10_path, PATH_MAX, "%s/last10v2.dat", conf.bbs_path); + + FILE *fptr = fopen(last10_path, "rb"); if (fptr != NULL) { for (i = 0; i < 10; i++) { @@ -708,7 +713,7 @@ void record_last10_callers(struct user_record *user) { } else { j = 0; } - fptr = fopen("last10v2.dat", "wb"); + fptr = fopen(last10_path, "wb"); for (; j < i; j++) { fwrite(&callers[j], sizeof(struct last10_callers), 1, fptr); } @@ -720,9 +725,14 @@ void record_last10_callers(struct user_record *user) { void display_last10_callers(struct user_record *user) { struct last10_callers callers[10]; + char last10_path[PATH_MAX]; + int i, z; struct tm l10_time; - FILE *fptr = fopen("last10v2.dat", "rb"); + + snprintf(last10_path, PATH_MAX, "%s/last10v2.dat", conf.bbs_path); + + FILE *fptr = fopen(last10_path, "rb"); time_t l10_timet; s_printf("\e[2J\e[1;1H"); @@ -779,6 +789,7 @@ void automessage_write() { FILE *fptr; char automsg[450]; char buffer[76]; + char automsg_path[PATH_MAX]; int i; struct tm timenow; time_t timen; @@ -802,7 +813,9 @@ void automessage_write() { strlcat(automsg, "\r\n", sizeof automsg); } - fptr = fopen("automessage.txt", "w"); + snprintf(automsg_path, PATH_MAX, "%s/automessage.txt", conf.bbs_path); + + fptr = fopen(automsg_path, "w"); if (fptr) { fwrite(automsg, strlen(automsg), 1, fptr); fclose(fptr); @@ -816,10 +829,14 @@ void automessage_display() { struct stat s; FILE *fptr; char buffer[90]; + char automsg_path[PATH_MAX]; int i; s_printf("\r\n\r\n"); - if (stat("automessage.txt", &s) == 0) { - fptr = fopen("automessage.txt", "r"); + + snprintf(automsg_path, PATH_MAX, "%s/automessage.txt", conf.bbs_path); + + if (stat(automsg_path, &s) == 0) { + fptr = fopen(automsg_path, "r"); if (fptr) { for (i = 0; i < 5; i++) { memset(buffer, 0, 90); diff --git a/src/www_last10.c b/src/www_last10.c index 3213542..3e666cc 100644 --- a/src/www_last10.c +++ b/src/www_last10.c @@ -12,8 +12,11 @@ char *www_last10() { size_t n = 0; stralloc page = EMPTY_STRALLOC; struct last10_callers callers[10]; + char last10_path[PATH_MAX]; - FILE *fptr = fopen("last10v2.dat", "rb"); + snprintf(last10_path, PATH_MAX, "%s/last10v2.dat", conf.bbs_path); + + FILE *fptr = fopen(last10_path, "rb"); if (fptr != NULL) { for (; n < 10; ++n) if (fread(&callers[n], sizeof(callers[n]), 1, fptr) != 1)