/* * Show the toberep database */ void ToBeRep(void) { char *temp; FILE *fp; struct _filerecord rep; if (do_quiet) return; IsDoing("Toberep"); mbse_colour(CYAN, BLACK); temp = calloc(PATH_MAX, sizeof(char)); snprintf(temp, PATH_MAX, "%s/etc/toberep.data", getenv("MBSE_ROOT")); if ((fp = fopen(temp, "r")) == NULL) { printf("No toberep database present\n"); } else { // 12345678901234567890123456789012345678901234567890123456789012345678901234567890 printf(" File echo Group File name Kbyte Date Announce\n"); printf("-------------------- ------------ ------------ ----- ---------- --------\n"); mbse_colour(LIGHTGRAY, BLACK); while (fread(&rep, sizeof(rep), 1, fp) == 1) { printf("%-20s %-12s %-12s %5d %s %s\n", rep.Echo, rep.Group, rep.Name, rep.SizeKb, StrDateDMY(rep.Fdate), rep.Announce ? "Yes":"No "); Syslog('f', "%-20s %-12s %-12s %5d %s %s", rep.Echo, rep.Group, rep.Name, rep.SizeKb, StrDateDMY(rep.Fdate), rep.Announce ? "Yes":"No "); } fclose(fp); } free(temp); }
void EditFile() { FHeader(); for (;;) { set_color(WHITE, BLACK); show_str( 7,16,12, fdb.Name); show_str( 8,16,64, fdb.LName); show_int( 9,16, fdb.Size); mbse_mvprintw(10,16, (char *)"%s %s", StrDateDMY(fdb.FileDate), StrTimeHM(fdb.FileDate)); mbse_mvprintw(11,16, (char *)"%s %s", StrDateDMY(fdb.LastDL), StrTimeHM(fdb.LastDL)); mbse_mvprintw(12,16, (char *)"%s %s", StrDateDMY(fdb.UploadDate), StrTimeHM(fdb.UploadDate)); show_str(13,16,20, fdb.TicArea); show_str(14,16,20, fdb.Magic); show_str(15,16,36, fdb.Uploader); show_int(16,16, fdb.TimesDL); show_str(17,16,15, fdb.Password); show_bool(15,75, fdb.Deleted); show_bool(16,75, fdb.NoKill); show_bool(17,75, fdb.Announced); switch(select_menu(6)) { case 0: return; case 1: E_STR( 15,16,35, fdb.Uploader, "The ^uploader^ of this file") case 2: E_INT( 16,16, fdb.TimesDL, "The number of times file is sent with ^download^") case 3: E_STR( 17,16,15, fdb.Password, "The ^password^ to protect this file with") case 4: E_BOOL(15,75, fdb.Deleted, "Should this this file be ^deleted^") case 5: E_BOOL(16,75, fdb.NoKill, "File can't be ^killed^ automatic") case 6: E_BOOL(17,75, fdb.Announced, "File is ^announced^ as new file") } } }
void Masterlist() { FILE *fp, *np, *fu, *nu, *pAreas, *pHeader; int AreaNr = 0, z, x = 0, New; unsigned int AllFiles = 0, AllKBytes = 0, NewFiles = 0, NewKBytes = 0; unsigned int AllAreaFiles, AllAreaBytes, popdown, down, NewAreaFiles, NewAreaBytes; char *sAreas, temp[PATH_MAX], pop[81]; struct _fdbarea *fdb_area = NULL; sAreas = calloc(PATH_MAX, sizeof(char)); IsDoing("Create Allfiles list"); snprintf(sAreas, PATH_MAX, "%s/etc/fareas.data", getenv("MBSE_ROOT")); if(( pAreas = fopen (sAreas, "r")) == NULL) { WriteError("Can't open File Areas File: %s", sAreas); mbse_colour(LIGHTGRAY, BLACK); die(MBERR_GENERAL); } fread(&areahdr, sizeof(areahdr), 1, pAreas); if (!do_quiet) printf("Processing file areas\n"); if ((fp = fopen("allfiles.tmp", "a+")) == NULL) { WriteError("$Can't open allfiles.tmp"); die(MBERR_GENERAL); } if ((np = fopen("newfiles.tmp", "a+")) == NULL) { WriteError("$Can't open newfiles.tmp"); fclose(fp); die(MBERR_GENERAL); } if ((fu = fopen("allfiles.ump", "a+")) == NULL) { WriteError("$Can't open allfiles.ump"); fclose(fp); fclose(np); die(MBERR_GENERAL); } if ((nu = fopen("newfiles.ump", "a+")) == NULL) { WriteError("$Can't open newfiles.ump"); fclose(fp); fclose(np); fclose(fu); die(MBERR_GENERAL); } chartran_init((char *)"CP437", (char *)"UTF-8", 'B'); TopBox(fp, fu, TRUE); TopBox(np, nu, TRUE); snprintf(temp, 81, "All available files at %s", CFG.bbs_name); MidLine(temp, fp, fu, TRUE); snprintf(temp, 81, "New available files since %d days at %s", CFG.newdays, CFG.bbs_name); MidLine(temp, np, nu, TRUE); BotBox(fp, fu, TRUE); BotBox(np, nu, TRUE); snprintf(temp, PATH_MAX, "%s/etc/header.txt", getenv("MBSE_ROOT")); if (( pHeader = fopen(temp, "r")) != NULL) { Syslog('+', "Inserting %s", temp); while( fgets(temp, 80 ,pHeader) != NULL) { Striplf(temp); fprintf(fp, "%s\r\n", temp); fprintf(np, "%s\r\n", temp); fprintf(fu, "%s\r\n", chartran(temp)); fprintf(nu, "%s\r\n", chartran(temp)); } fclose(pHeader); } while (fread(&area, areahdr.recsize, 1, pAreas) == 1) { AreaNr++; AllAreaFiles = 0; AllAreaBytes = 0; NewAreaFiles = 0; NewAreaBytes = 0; if (area.Available && (area.LTSec.level <= CFG.security.level)) { Nopper(); if ((fdb_area = mbsedb_OpenFDB(AreaNr, 30)) == 0) { WriteError("Can't open Area %d (%s)! Skipping ...", AreaNr, area.Name); } else { popdown = 0; while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) { if (!fdb.Deleted) { /* * The next is to reduce system load. */ x++; if (CFG.slow_util && do_quiet && ((x % 3) == 0)) msleep(1); AllFiles++; AllAreaFiles++; AllAreaBytes += fdb.Size; down = fdb.TimesDL; if (down > popdown) { popdown = down; snprintf(pop, 81, "%s", fdb.Name); } if (((t_start - fdb.UploadDate) / 84400) <= CFG.newdays) { NewFiles++; NewAreaFiles++; NewAreaBytes += fdb.Size; } } } AllKBytes += AllAreaBytes / 1024; NewKBytes += NewAreaBytes / 1024; /* * If there are files to report do it. */ if (AllAreaFiles) { TopBox(fp, fu, TRUE); TopBox(np, nu, NewAreaFiles); snprintf(temp, 81, "Area %d - %s", AreaNr, area.Name); MidLine(temp, fp, fu, TRUE); MidLine(temp, np, nu, NewAreaFiles); snprintf(temp, 81, "File Requests allowed"); MidLine(temp, fp, fu, area.FileReq); MidLine(temp, np, nu, area.FileReq && NewAreaFiles); snprintf(temp, 81, "%d KBytes in %d files", AllAreaBytes / 1024, AllAreaFiles); MidLine(temp, fp, fu, TRUE); snprintf(temp, 81, "%d KBytes in %d files", NewAreaBytes / 1024, NewAreaFiles); MidLine(temp, np, nu, NewAreaFiles); if (popdown) { snprintf(temp, 81, "Most popular file is %s", pop); MidLine(temp, fp, fu, TRUE); } BotBox(fp, fu, TRUE); BotBox(np, nu, NewAreaFiles); fseek(fdb_area->fp, fdbhdr.hdrsize, SEEK_SET); while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) { if (!fdb.Deleted) { New = (((t_start - fdb.UploadDate) / 84400) <= CFG.newdays); snprintf(temp, 81, "%s", fdb.LName); WriteFiles(fp, fu, np, nu, New, temp); snprintf(temp, 81, "%-12s%10u K %s [%04d] Uploader: %s", fdb.Name, (int)(fdb.Size / 1024), StrDateDMY(fdb.UploadDate), fdb.TimesDL, strlen(fdb.Uploader)?fdb.Uploader:""); WriteFiles(fp, fu, np, nu, New, temp); for (z = 0; z < 25; z++) { if (strlen(fdb.Desc[z])) { if ((fdb.Desc[z][0] == '@') && (fdb.Desc[z][1] == 'X')) { snprintf(temp, 81, " %s", fdb.Desc[z]+4); } else { snprintf(temp, 81, " %s", fdb.Desc[z]); } WriteFiles(fp, fu, np, nu, New, temp); } } if (strlen(fdb.Magic)) { snprintf(temp, 81, " Magic filerequest: %s", fdb.Magic); WriteFiles(fp, fu, np, nu, New, temp); } WriteFiles(fp, fu, np, nu, New, (char *)""); } } } mbsedb_CloseFDB(fdb_area); } } } /* End of While Loop Checking for Areas Done */ fclose(pAreas); TopBox(fp, fu, TRUE); TopBox(np, nu, TRUE); snprintf(temp, 81, "Total %d files, %d KBytes", AllFiles, AllKBytes); MidLine(temp, fp, fu, TRUE); snprintf(temp, 81, "Total %d files, %d KBytes", NewFiles, NewKBytes); MidLine(temp, np, nu, TRUE); MidLine((char *)"", fp, fu, TRUE); MidLine((char *)"", np, nu, TRUE); snprintf(temp, 81, "Created by MBSE BBS v%s (%s-%s) at %s", VERSION, OsName(), OsCPU(), StrDateDMY(t_start)); MidLine(temp, fp, fu, TRUE); MidLine(temp, np, nu, TRUE); BotBox(fp, fu, TRUE); BotBox(np, nu, TRUE); snprintf(temp, PATH_MAX, "%s/etc/footer.txt", getenv("MBSE_ROOT")); if(( pHeader = fopen(temp, "r")) != NULL) { Syslog('+', "Inserting %s", temp); while( fgets(temp, 80 ,pHeader) != NULL) { Striplf(temp); fprintf(fp, "%s\r\n", temp); fprintf(np, "%s\r\n", temp); fprintf(fu, "%s\r\n", chartran(temp)); fprintf(nu, "%s\r\n", chartran(temp)); } fclose(pHeader); } fclose(fp); fclose(np); fclose(fu); fclose(nu); chartran_close(); if ((rename("allfiles.tmp", "allfiles.txt")) == 0) unlink("allfiles.tmp"); if ((rename("newfiles.tmp", "newfiles.txt")) == 0) unlink("newfiles.tmp"); if ((rename("allfiles.ump", "allfiles.utf")) == 0) unlink("allfiles.ump"); if ((rename("newfiles.ump", "newfiles.utf")) == 0) unlink("newfiles.ump"); Syslog('+', "Allfiles: %ld, %ld MBytes", AllFiles, AllKBytes / 1024); Syslog('+', "Newfiles: %ld, %ld MBytes", NewFiles, NewKBytes / 1024); free(sAreas); }
void SaveLastCallers() { FILE *pGLC; char *sFileName, sFileDate[9], sDate[9]; struct stat statfile; /* * First check if we passed midnight, in that case we create a fresh file. */ sFileName = calloc(PATH_MAX, sizeof(char)); snprintf(sFileName, PATH_MAX, "%s/etc/lastcall.data", getenv("FTND_ROOT")); stat(sFileName, &statfile); snprintf(sFileDate, 9, "%s", StrDateDMY(statfile.st_mtime)); snprintf(sDate, 9, "%s", (char *) GetDateDMY()); if ((strcmp(sDate,sFileDate)) != 0) { unlink(sFileName); Syslog('+', "Erased old lastcall.data"); } /* * Check if file exists, if not create the file and write the fileheader. */ if ((pGLC = fopen(sFileName, "r")) == NULL) { if ((pGLC = fopen(sFileName, "w")) != NULL) { LCALLhdr.hdrsize = sizeof(LCALLhdr); LCALLhdr.recsize = sizeof(LCALL); fwrite(&LCALLhdr, sizeof(LCALLhdr), 1, pGLC); fclose(pGLC); Syslog('+', "Created new lastcall.data"); } } else { fclose(pGLC); } chmod(sFileName, 0660); /* * Now append a record */ if ((pGLC = fopen(sFileName,"a+")) == NULL) { WriteError("$Can't open %s", sFileName); return; } else { ReadExitinfo(); memset(&LCALL, 0, sizeof(LCALL)); snprintf(LCALL.UserName, 36, "%s", exitinfo.sUserName); snprintf(LCALL.Handle, 36, "%s", exitinfo.sHandle); snprintf(LCALL.Name, 9, "%s", exitinfo.Name); snprintf(LCALL.TimeOn, 6, "%s", StartTime); snprintf(LCALL.Device, 10, "%s", pTTY); LCALL.SecLevel = exitinfo.Security.level; LCALL.Calls = exitinfo.iTotalCalls; LCALL.CallTime = exitinfo.iConnectTime; LCALL.Download = LC_Download; LCALL.Upload = LC_Upload; LCALL.Read = LC_Read; LCALL.Wrote = LC_Wrote; LCALL.Chat = LC_Chat; LCALL.Olr = LC_Olr; LCALL.Door = LC_Door; snprintf(LCALL.Speed, 21, "%s", ttyinfo.speed); /* If true then set hidden so it doesn't display in lastcallers function */ LCALL.Hidden = exitinfo.Hidden; snprintf(LCALL.Location, 28, "%s", exitinfo.sLocation); rewind(pGLC); /* ???????????? */ fwrite(&LCALL, sizeof(LCALL), 1, pGLC); fclose(pGLC); } free(sFileName); }
void E_F(int areanr) { FILE *fil; char temp[PATH_MAX], help[81]; int i, y, o, records, Ondisk; static char *menu = (char *)"0"; int offset; time_t Time; struct stat statfile; unsigned int crc, crc1; clr_index(); snprintf(temp, PATH_MAX, "%s/var/fdb/file%d.data", getenv("MBSE_ROOT"), areanr); if ((fil = fopen(temp, "r+")) == NULL) { working(2, 0, 0); return; } if (! check_free()) return; fread(&fdbhdr, sizeof(fdbhdr), 1, fil); fseek(fil, 0, SEEK_END); records = ((ftell(fil) - fdbhdr.hdrsize) / fdbhdr.recsize); o = 0; for (;;) { clr_index(); set_color(WHITE, BLACK); mbse_mvprintw(5, 4, "14. EDIT FILES DATABASE"); y = 8; working(1, 0, 0); set_color(YELLOW, BLUE); mbse_mvprintw(7, 1, " Nr Filename Size Date Time Description "); /* 1234 12345678901234 12345678 12-34-1998 12:45 123456789012345678901234567890*/ set_color(CYAN, BLACK); for (i = 1; i <= 10; i++) { if ((o + i) <= records) { offset = (((o + i) - 1) * fdbhdr.recsize) + fdbhdr.hdrsize; fseek(fil, offset, SEEK_SET); fread(&fdb, fdbhdr.recsize, 1, fil); set_color(WHITE, BLACK); mbse_mvprintw(y, 1, (char *)"%4d.", o + i); snprintf(temp, PATH_MAX, "%s/%s", area.Path, fdb.LName); Ondisk = ((stat(temp, &statfile)) != -1); if (fdb.Deleted) set_color(LIGHTBLUE, BLACK); else if (Ondisk) set_color(CYAN, BLACK); else set_color(LIGHTRED, BLACK); mbse_mvprintw(y, 8, (char *)"%-14s", fdb.Name); if (Ondisk) { if (fdb.Size == statfile.st_size) set_color(CYAN, BLACK); else set_color(LIGHTRED, BLACK); mbse_mvprintw(y,23, (char *)"%8ld", fdb.Size); if (fdb.FileDate == statfile.st_mtime) set_color(CYAN, BLACK); else set_color(LIGHTRED, BLACK); Time = fdb.FileDate; mbse_mvprintw(y,32, (char *)"%s %s", StrDateDMY(Time), StrTimeHM(Time)); } set_color(CYAN, BLACK); snprintf(temp, 81, "%s", fdb.Desc[0]); temp[30] = '\0'; mbse_mvprintw(y,49, (char *)"%s", temp); y++; } } if (records) if (records > 10) snprintf(help, 81, "^1..%d^ Edit, ^-^ Return, ^N^/^P^ Page", records); else snprintf(help, 81, "^1..%d^ Edit, ^-^ Return", records); else snprintf(help, 81, "^-^ Return"); showhelp(help); while(TRUE) { mbse_mvprintw(LINES - 4, 6, "Enter your choice >"); menu = (char *)"-"; menu = edit_field(LINES - 4, 26, 6, '!', menu); mbse_locate(LINES - 4, 6); clrtoeol(); if (strncmp(menu, "-", 1) == 0) { fclose(fil); open_bbs(); return; } if (records > 10) { if (strncmp(menu, "N", 1) == 0) if ((o + 10) < records) { o += 10; break; } if (strncmp(menu, "P", 1) == 0) if ((o - 10) >= 0) { o -= 10; break; } } if ((atoi(menu) > 0) && (atoi(menu) <= records)) { working(1, 0, 0); offset = ((atoi(menu) - 1) * fdbhdr.recsize) + fdbhdr.hdrsize; fseek(fil, offset, SEEK_SET); fread(&fdb, fdbhdr.recsize, 1, fil); crc = 0xffffffff; crc = upd_crc32((char *)&fdb, crc, fdbhdr.recsize); o = ((atoi(menu) - 1) / 10) * 10; snprintf(temp, PATH_MAX, "%s/%s", area.Path, fdb.LName); EditFile(); crc1 = 0xffffffff; crc1 = upd_crc32((char *)&fdb, crc1, fdbhdr.recsize); if (crc != crc1) { if (yes_no((char *)"Record is changed, save") == 1) { working(1, 0, 0); fseek(fil, offset, SEEK_SET); fwrite(&fdb, fdbhdr.recsize, 1, fil); working(6, 0, 0); } } break; } } } }
void user(void) { FILE *pUsrConfig, *pLimits; int i, x, FoundName = FALSE, iFoundLimit = FALSE, IsNew = FALSE, logins = 0, Start; int l1, l2; char *token, temp[PATH_MAX], temp1[84], UserName[37], buf[128], *fullname; time_t LastLogin; struct stat st; grecno = 0; Syslog('+', "Unixmode login: %s", sUnixName); snprintf(temp, PATH_MAX, "%s/etc/users.data", getenv("FTND_ROOT")); if ((pUsrConfig = fopen(temp,"r+")) == NULL) { /* * This should not happen. */ WriteError("$Can't open %s", temp); PUTSTR((char *)"Can't open userfile, run \"newuser\" first"); Enter(1); ExitClient(FTNERR_OK); } fread(&usrconfighdr, sizeof(usrconfighdr), 1, pUsrConfig); while (fread(&usrconfig, usrconfighdr.recsize, 1, pUsrConfig) == 1) { if (strcmp(usrconfig.Name, sUnixName) == 0) { FoundName = TRUE; break; } else grecno++; } if (!FoundName) { fclose(pUsrConfig); snprintf(temp, PATH_MAX, "Unknown username: %s\r\n", sUnixName); PUTSTR(temp); /* FATAL ERROR: You are not in the BBS users file.*/ snprintf(temp, PATH_MAX, "%s\r\n", (char *) Language(389)); PUTSTR(temp); /* Please run 'newuser' to create an account */ snprintf(temp, PATH_MAX, "%s\r\n", (char *) Language(390)); PUTSTR(temp); Syslog('?', "FATAL: Could not find user in BBS users file."); Syslog('?', " and system is using unix accounts\n"); Free_Language(); ExitClient(FTNERR_OK); } /* * Copy username, split first and lastname. */ strncpy(UserName, usrconfig.sUserName, sizeof(UserName)-1); if ((strchr(UserName,' ') == NULL) && !CFG.iOneName) { token = strtok(UserName, " "); strncpy(FirstName, token, sizeof(FirstName)-1); token = strtok(NULL, "\0"); i = strlen(token); for (x = 2; x < i; x++) { if (token[x] == ' ') token[x] = '\0'; } strncpy(LastName, token, sizeof(LastName)-1); } else strncpy(FirstName, UserName, sizeof(FirstName)-1); strncpy(UserName, usrconfig.sUserName, sizeof(UserName)-1); Syslog('+', "%s On-Line from \"%s\", node %d", UserName, ttyinfo.comment, iNode); IsDoing("Just Logged In"); /* * Check some essential files, create them if they don't exist. */ ChkFiles(); /* * Setup users favourite language. */ utf8 = (usrconfig.Charset == FTNC_UTF8); Set_Language(usrconfig.iLanguage); Free_Language(); InitLanguage(); /* * User logged in, tell it to the server. Check if a location is * set, if Ask User location for new users is off, this field is * empty but we have to send something to the server. */ if (strlen(usrconfig.sLocation)) UserCity(mypid, usrconfig.Name, usrconfig.sLocation); else UserCity(mypid, usrconfig.Name, (char *)"N/A"); /* * Count simultaneous logins */ Start = TRUE; while (TRUE) { if (Start) snprintf(buf, 128, "GMON:1,1;"); else snprintf(buf, 128, "GMON:1,0;"); Start = FALSE; if (socket_send(buf) == 0) { strcpy(buf, socket_receive()); if (strncmp(buf, "100:0;", 6) == 0) break; /* No more data */ if (strstr(buf, "ftnbbs")) { /* * Only ftnbbs is wanted */ strtok(buf, ","); /* response */ strtok(NULL, ","); /* pid */ strtok(NULL, ","); /* tty */ fullname = xstrcpy(cldecode(strtok(NULL, ","))); /* username */ if (strcmp(fullname, usrconfig.Name) == 0) { logins++; } free(fullname); } } } if (CFG.max_logins && (logins > CFG.max_logins)) { Syslog('+', "User logins %d, allowed %d, disconnecting", logins, CFG.max_logins); colour(LIGHTRED, BLACK); snprintf(temp, PATH_MAX, "%s %d %s\r\n", (char *) Language(18), CFG.max_logins, (char *) Language(19)); PUTSTR(temp); Quick_Bye(FTNERR_INIT_ERROR); } /* * Set last file and message area so these numbers are saved when * the user hangs up or is logged off before het gets to the main * menu. Later in this function the areas are set permanent. */ iAreaNumber = usrconfig.iLastFileArea; iMsgAreaNumber = usrconfig.iLastMsgArea; /* * See if this user is the Sysop. */ strcpy(temp, UserName); strcpy(temp1, CFG.sysop_name); if ((strcasecmp(CFG.sysop_name, UserName)) == 0) { /* * If login name is sysop, set SYSOP true */ SYSOP = TRUE; Syslog('+', "Sysop is online"); } /* * Is this a new user? */ if (usrconfig.iTotalCalls == 0) IsNew = TRUE; /* * Pause after logo screen. */ alarm_on(); Pause(); if (usrconfig.Archiver[0] == '\0') { usrconfig.Archiver[0] = 'Z'; usrconfig.Archiver[1] = 'I'; usrconfig.Archiver[2] = 'P'; Syslog('+', "Setup default archiver ZIP"); } /* * Check users date format. We do it strict as we * need this to be good for several other purposes. * If it is correct, the users age is set in UserAge */ if (!Test_DOB(usrconfig.sDateOfBirth)) { Syslog('!', "Error in Date of Birth"); Chg_DOB(); strcpy(usrconfig.sDateOfBirth, exitinfo.sDateOfBirth); } /* * Check to see if user must expire */ snprintf(temp,PATH_MAX, "%s", (char *) GetDateDMY()); SwapDate(temp, usrconfig.sExpiryDate); /* Convert Date1 & Date2 to longs for compare */ l1 = atol(Date1); l2 = atol(Date2); if (l1 >= l2 && l2 != 0) { /* * If Expiry Date is the same as today expire to * Expire Sec level */ usrconfig.Security = usrconfig.ExpirySec; Syslog('!', "User is expired, resetting level"); /* * Show texfile to user telling him about this. */ DisplayFile((char *)"expired"); } free(Date1); free(Date2); /* * Copy limits.data into memory */ snprintf(temp, PATH_MAX, "%s/etc/limits.data", getenv("FTND_ROOT")); if ((pLimits = fopen(temp,"rb")) == NULL) { WriteError("$Can't open %s", temp); } else { fread(&LIMIThdr, sizeof(LIMIThdr), 1, pLimits); while (fread(&LIMIT, sizeof(LIMIT), 1, pLimits) == 1) { if (LIMIT.Security == usrconfig.Security.level) { iFoundLimit = TRUE; break; } } fclose(pLimits); } if (!iFoundLimit) { WriteError("Unknown Security Level in limits.data"); usrconfig.iTimeLeft = 0; /* Could not find limit, so set to Zero */ usrconfig.iTimeUsed = 0; /* Set to Zero as well */ } else { /* * Give user new time limit everyday, also new users get a new limit. */ snprintf(temp,PATH_MAX, "%s", (char *) GetDateDMY()); if (((strcmp(StrDateDMY(usrconfig.tLastLoginDate), temp)) != 0) || IsNew) { /* * If no timelimit set give user 24 hours. */ if (LIMIT.Time) usrconfig.iTimeLeft = LIMIT.Time; else usrconfig.iTimeLeft = 86400; usrconfig.iTimeUsed = 0; /* Set time used today to Zero */ usrconfig.iConnectTime = 0; /* Set connect time to Zero */ /* * Give user new bytes and files every day if needed. */ if (LIMIT.DownK) { usrconfig.DownloadKToday = LIMIT.DownK; } if (LIMIT.DownF) { usrconfig.DownloadsToday = LIMIT.DownF; } } } /* End of else */ usrconfig.iConnectTime = 0; /* Copy Users Protocol into Memory */ Set_Protocol(usrconfig.sProtocol); tlf(usrconfig.sProtocol); /* * Set last login Date and Time, copy previous session * values in memory. */ snprintf(LastLoginDate, 12, "%s", StrDateDMY(usrconfig.tLastLoginDate)); snprintf(LastLoginTime, 9, "%s", StrTimeHMS(usrconfig.tLastLoginDate)); LastLogin = usrconfig.tLastLoginDate; usrconfig.tLastLoginDate = ltime; /* Set current login to current date */ usrconfig.iTotalCalls++; /* * Update user record. */ if (fseek(pUsrConfig, usrconfighdr.hdrsize + (grecno * usrconfighdr.recsize), 0) != 0) { WriteError("Can't seek in %s/etc/users.data", getenv("FTND_ROOT")); } else { fwrite(&usrconfig, sizeof(usrconfig), 1, pUsrConfig); } fclose(pUsrConfig); /* * Write users structure to tmp file in ~/home/unixname/exitinfo * A copy of the userrecord is also in the variable exitinfo. */ if (! InitExitinfo()) Good_Bye(FTNERR_INIT_ERROR); /* * If user has not set a preferred character set, force this */ if (exitinfo.Charset == FTNC_NONE) { Chg_Charset(); } setlocale(LC_CTYPE, getlocale(exitinfo.Charset)); Syslog('b', "setlocale(LC_CTYPE, NULL) returns \"%s\"", printable(setlocale(LC_CTYPE, NULL), 0)); GetLastUser(); StartTime = xstrcpy(GetLocalHM()); ChangeHomeDir(exitinfo.Name, exitinfo.Email); Syslog('+', "User successfully logged into BBS"); Syslog('+', "Level %d (%s), %d mins. left, port %s", exitinfo.Security.level, LIMIT.Description, exitinfo.iTimeLeft, pTTY); Time2Go = time(NULL); Time2Go += exitinfo.iTimeLeft * 60; iUserTimeLeft = exitinfo.iTimeLeft; IsDoing("Welcome screens"); DisplayFile((char *)"mainlogo"); DisplayFile((char *)"welcome"); /* * The following files are only displayed if the user has * turned the Bulletins on. */ if (exitinfo.ieNEWS) { DisplayFile((char *)"welcome1"); DisplayFile((char *)"welcome2"); DisplayFile((char *)"welcome3"); DisplayFile((char *)"welcome4"); DisplayFile((char *)"welcome5"); DisplayFile((char *)"welcome6"); DisplayFile((char *)"welcome7"); DisplayFile((char *)"welcome8"); DisplayFile((char *)"welcome9"); snprintf(temp, PATH_MAX, "%s", (char *) GetDateDMY() ); if ((strcmp(exitinfo.sDateOfBirth, temp)) == 0) DisplayFile((char *)"birthday"); /* * Displays file if it exists DD-MM.A?? */ snprintf(temp, PATH_MAX, "%s", (char *) GetDateDMY()); strcpy(temp1, ""); strncat(temp1, temp, 5); snprintf(temp, PATH_MAX, "%s", temp1); DisplayFile(temp); /* * Displays users security file if it exists */ snprintf(temp, PATH_MAX, "sec%d", exitinfo.Security.level); DisplayFile(temp); /* * Display News file */ DisplayFile((char *)"news"); } /* * Display Onceonly file, first get the date of that * file, search order is the same as in DisplayFile() */ st.st_mtime = 0; snprintf(temp, PATH_MAX, "%s/share/int/txtfiles/%s/onceonly.ans", getenv("FTND_ROOT"), lang.lc); stat(temp, &st); if (st.st_mtime == 0) { snprintf(temp, PATH_MAX, "%s/share/int/txtfiles/%s/onceonly.ans", getenv("FTND_ROOT"), CFG.deflang); stat(temp, &st); } if (st.st_mtime == 0) { snprintf(temp, PATH_MAX, "%s/share/int/txtfiles/%s/onceonly.asc", getenv("FTND_ROOT"), lang.lc); stat(temp, &st); if (st.st_mtime == 0) { snprintf(temp, PATH_MAX, "%s/share/int/txtfiles/%s/onceonly.asc", getenv("FTND_ROOT"), CFG.deflang); stat(temp, &st); } } if ((st.st_mtime != 0) && (LastLogin < st.st_mtime)) DisplayFile((char *)"onceonly"); OLR_SyncTags(); if (exitinfo.MailScan) { IsDoing("New mail check"); CheckMail(); } /* * We don't show new files to new users. */ if (exitinfo.ieFILE && (!IsNew)) { IsDoing("New files check"); NewfileScan(FALSE); } /* * Copy last file Area in to current Area */ SetFileArea(exitinfo.iLastFileArea); /* * Copy Last Message Area in to Current Msg Area */ SetMsgArea(usrconfig.iLastMsgArea); SetEmailArea((char *)"mailbox"); /* * Set or Reset the DoNotDisturb flag, now is the time * we may be interrupted. */ UserSilent(usrconfig.DoNotDisturb); /* * Start the menu. */ menu(); }
/* * Scan for new files, called from menu. */ int NewfileScan(int AskStart) { FILE *pAreas; int ifDate, itDate; char *temp, *Date; int Found, Count = 0; _Tag T; struct _fdbarea *fdb_area = NULL; Date = calloc(81, sizeof(char)); temp = calloc(81, sizeof(char)); iLineCount = 2; arecno = 1; /* Reset Area Number to One */ if (AskStart) { Enter(2); /* Search for new since your last call [Y/n]: */ pout(LIGHTCYAN, BLACK, (char *) Language(273)); colour(CFG.InputColourF, CFG.InputColourB); if (toupper(Readkey()) == Keystroke(273, 1)) { Enter(1); /* Enter new date to search for [DD-MM-YYYY]: */ pout(GREEN, BLACK, (char *) Language(274)); colour(CFG.InputColourF, CFG.InputColourB); GetDate(temp, 10); } else { strcpy(temp, LastLoginDate); } } else { strcpy(temp, LastLoginDate); } Syslog('+', "NewfileScan() since %s", temp); clear(); /* File Search by Date */ pout(WHITE, BLACK, (char *) Language(275)); Enter(2); Date[0] = temp[6]; /* Swap the date around */ Date[1] = temp[7]; /* Instead of DD-MM-YYYY */ Date[2] = temp[8]; /* Let it equal YYYYMMDD */ Date[3] = temp[9]; /* Swap the date around */ Date[4] = temp[3]; /* Swap the date around */ Date[5] = temp[4]; /* because when you convert */ Date[6] = temp[0]; /* a string to an int you */ Date[7] = temp[1]; /* loose the front Zero */ Date[8] = '\0'; /* making the number smaller */ itDate = atol(Date); InitTag(); if ((pAreas = OpenFareas(FALSE)) == NULL) return 0; while (fread(&area, areahdr.recsize, 1, pAreas) == 1) { if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0) && (area.New)) { if ((fdb_area = mbsedb_OpenFDB(arecno, 30))) { Sheader(); Found = FALSE; Nopper(); while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) { strcpy(temp, StrDateDMY(fdb.UploadDate)); /* Realloc Space for Date */ Date[0] = temp[6]; /* Swap the date around */ Date[1] = temp[7]; /* Instead of DD-MM-YYYY */ Date[2] = temp[8]; /* Let it equal YYYYMMDD */ Date[3] = temp[9]; /* Swap the date around */ Date[4] = temp[3]; /* Swap the date around */ Date[5] = temp[4]; /* because when you convert */ Date[6] = temp[0]; /* a string to an int you */ Date[7] = temp[1]; /* loose the front Zero */ Date[8] = '\0'; /* making the number smaller */ /* and invalid to this cause */ ifDate = atol(Date); if (ifDate >= itDate) { if (!Found) { Enter(2); if (iLC(2) == 1) { free(Date); free(temp); mbsedb_CloseFDB(fdb_area); fclose(pAreas); return 1; } Found = TRUE; } memset(&T, 0, sizeof(T)); T.Area = arecno; T.Active = FALSE; T.Size = fdb.Size; strncpy(T.SFile, fdb.Name, 12); strncpy(T.LFile, fdb.LName, 80); SetTag(T); Count++; if (ShowOneFile() == 1) { free(Date); free(temp); mbsedb_CloseFDB(fdb_area); fclose(pAreas); return 1; } } /* End of if */ } /* End of while */ mbsedb_CloseFDB(fdb_area); /* * Add 2 blank lines after found files. */ if (Found) { Enter(2); if (iLC(2) == 1) { free(Date); free(temp); fclose(pAreas); return 1; } } } /* End of open filebase */ } /* End of check new files scan */ arecno++; /* Go to next file area */ } /* End of Main */ if (Count) Syslog('+', "Found %d new files", Count); fclose(pAreas); Enter(1); if (Count) Mark(); else Pause(); free(temp); free(Date); return 1; }
/* * Show Raw directory */ void File_RawDir(char *OpData) { DIR *dirp; char *FileName, *temp, temp2[81]; int iFileCount = 0, LineCount = 2, iBytes = 0; struct dirent *dp; struct stat statfile; FileName = calloc(PATH_MAX, sizeof(char)); temp = calloc(PATH_MAX, sizeof(char)); if ((strcmp(OpData, "/F")) == 0) strcpy(temp, sAreaPath); else strcpy(temp, OpData); if ((dirp = opendir(temp)) == NULL) { clear(); WriteError("$RawDir: Can't open dir: %s", temp); Enter(1); pout(LIGHTRED, BLACK, (char *)"Can't open directory for raw listing!"); Enter(2); Pause(); } else { if (utf8) chartran_init((char *)"CP437", (char *)"UTF-8", 'b'); clear(); /* Filename Size Date */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(261)); Enter(1); PUTSTR(chartran(fLine_str(78))); while ((dp = readdir( dirp )) != NULL ) { snprintf(FileName, PATH_MAX, "%s/%s", temp, dp->d_name); if (*(dp->d_name) != '.') { iFileCount++; if (stat(FileName, &statfile) != 0) { pout(LIGHTRED, BLACK, (char *)"Can't stat file "); PUTSTR(FileName); } else { iBytes += statfile.st_size; snprintf(temp2, 81, "%-54s " , dp->d_name); pout(YELLOW, BLACK, temp2); snprintf(temp2, 81, "%-12d", (int)(statfile.st_size)); pout(LIGHTMAGENTA, BLACK, temp2); snprintf(temp2, 81, "%-10s", StrDateDMY(statfile.st_mtime)); pout(LIGHTGREEN, BLACK, temp2); } Enter(1); LineCount++; if (LineCount == rows) { Pause(); LineCount = 0; } } } colour(CFG.HiliteF, CFG.HiliteB); PUTSTR(chartran(fLine_str(78))); /* Total Files: */ /* Bytes */ snprintf(temp2, 81, "%s %d, %d %s", (char *) Language(242), iFileCount, iBytes, (char *) Language(354)); pout(LIGHTGREEN, BLACK, temp2); Enter(2); Pause(); closedir(dirp); chartran_close(); } free(temp); free(FileName); }
/* * Function will list users home directory */ void List_Home() { DIR *dirp; char *FileName, *temp; int iFileCount = 0, iBytes = 0; struct dirent *dp; struct stat statfile; FileName = calloc(PATH_MAX, sizeof(char)); temp = calloc(PATH_MAX, sizeof(char)); iLineCount = 2; clear(); snprintf(temp, PATH_MAX, "%s/%s/wrk", CFG.bbs_usersdir, exitinfo.Name); if ((dirp = opendir(temp)) == NULL) { WriteError("$List_Home: Can't open dir: %s", temp); Enter(1); /* Can't open directory for listing: */ pout(LIGHTRED, BLACK, (char *) Language(290)); Enter(2); Pause(); } else { /* Home directory listing for */ snprintf(temp, 81, " %s", (char *) Language(291)); pout(BLUE, LIGHTGRAY, temp); snprintf(temp, 81, "%-51s", exitinfo.sUserName); pout(RED, LIGHTGRAY, temp); Enter(1); while ((dp = readdir( dirp )) != NULL ) { snprintf(temp, PATH_MAX, "%s/%s/wrk", CFG.bbs_usersdir, exitinfo.Name); snprintf(FileName, PATH_MAX, "%s/%s", temp, dp->d_name); /* * Check first letter of file for a ".", do not display hidden files * This includes the current directory and parent directory . & .. */ if (*(dp->d_name) != '.') { iFileCount++; if (stat(FileName, &statfile) != 0) { WriteError("$Can't stat file %s",FileName); } else { iBytes += statfile.st_size; snprintf(temp, 81, "%-20s", dp->d_name); pout(YELLOW, BLACK, temp); snprintf(temp, 81, "%-12d", (int)(statfile.st_size)); pout(LIGHTMAGENTA, BLACK, temp); snprintf(temp, 81, "%s ", StrDateDMY(statfile.st_mtime)); pout(LIGHTGREEN, BLACK, temp); snprintf(temp, 81, "%s", StrTimeHMS(statfile.st_mtime)); pout(LIGHTCYAN, BLACK, temp); Enter(1); } } if (iLC(1) == 1) return; } Enter(2); /* Total Files: */ /* Bytes */ snprintf(temp, 81, "%s%d / %d %s", (char *) Language(242), iFileCount, iBytes, (char *) Language(354)); pout(LIGHTCYAN, BLACK, temp); Enter(1); Pause(); closedir(dirp); } free(temp); free(FileName); }