fix path to last 10 and automessage

This commit is contained in:
Andrew Pamment 2018-10-18 21:03:52 +10:00
parent 321bf47ee8
commit ee194c102f
2 changed files with 27 additions and 7 deletions

View File

@ -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);

View File

@ -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)