2001-08-17 05:46:24 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
2001-11-04 16:41:54 +00:00
|
|
|
* $Id$
|
2001-08-17 05:46:24 +00:00
|
|
|
* Purpose ...............: Creates allfiles listings
|
|
|
|
*
|
|
|
|
*****************************************************************************
|
2007-03-02 21:28:28 +00:00
|
|
|
* Copyright (C) 1997-2007
|
2001-08-17 05:46:24 +00:00
|
|
|
*
|
|
|
|
* Michiel Broek FIDO: 2:280/2802
|
|
|
|
* Beekmansbos 10
|
|
|
|
* 1971 BV IJmuiden
|
|
|
|
* the Netherlands
|
|
|
|
*
|
|
|
|
* This file is part of MBSE BBS.
|
|
|
|
*
|
|
|
|
* This BBS is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
* later version.
|
|
|
|
*
|
|
|
|
* MBSE BBS is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with MBSE BBS; see the file COPYING. If not, write to the Free
|
2003-08-15 20:05:34 +00:00
|
|
|
* Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
2001-08-17 05:46:24 +00:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2002-06-30 12:48:44 +00:00
|
|
|
#include "../config.h"
|
2004-02-21 17:22:00 +00:00
|
|
|
#include "../lib/mbselib.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "../lib/mbse.h"
|
2002-01-07 19:16:03 +00:00
|
|
|
#include "../lib/users.h"
|
2004-02-21 17:22:00 +00:00
|
|
|
#include "../lib/mbsedb.h"
|
2005-08-11 15:14:26 +00:00
|
|
|
#include "dlcount.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "mball.h"
|
|
|
|
|
|
|
|
|
2002-06-19 20:31:35 +00:00
|
|
|
extern int do_quiet; /* Suppress screen output */
|
2001-08-17 05:46:24 +00:00
|
|
|
int do_zip = FALSE; /* Create ZIP archives */
|
|
|
|
int do_list = FALSE; /* Create filelist */
|
|
|
|
extern int e_pid; /* Pid of child */
|
|
|
|
extern int show_log; /* Show logging */
|
|
|
|
time_t t_start; /* Start time */
|
|
|
|
time_t t_end; /* End time */
|
|
|
|
struct tm *l_date; /* Structure for Date */
|
|
|
|
|
|
|
|
|
|
|
|
void ProgName()
|
|
|
|
{
|
2005-08-19 19:46:55 +00:00
|
|
|
if (do_quiet)
|
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-08-19 19:46:55 +00:00
|
|
|
mbse_colour(WHITE, BLACK);
|
|
|
|
printf("\nMBALL: MBSE BBS %s Allfiles Listing Creator\n", VERSION);
|
|
|
|
mbse_colour(YELLOW, BLACK);
|
|
|
|
printf(" %s\n", COPYRIGHT);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void die(int onsig)
|
|
|
|
{
|
2003-08-03 14:42:12 +00:00
|
|
|
/*
|
|
|
|
* First check if a child is running, if so, kill it.
|
|
|
|
*/
|
|
|
|
if (e_pid) {
|
|
|
|
if ((kill(e_pid, SIGTERM)) == 0)
|
|
|
|
Syslog('+', "SIGTERM to pid %d succeeded", e_pid);
|
|
|
|
else {
|
|
|
|
if ((kill(e_pid, SIGKILL)) == 0)
|
|
|
|
Syslog('+', "SIGKILL to pid %d succeded", e_pid);
|
|
|
|
else
|
|
|
|
WriteError("$Failed to kill pid %d", e_pid);
|
|
|
|
}
|
|
|
|
|
2001-08-17 05:46:24 +00:00
|
|
|
/*
|
2003-08-03 14:42:12 +00:00
|
|
|
* In case the child had the tty in raw mode...
|
2001-08-17 05:46:24 +00:00
|
|
|
*/
|
2004-03-02 20:47:23 +00:00
|
|
|
execute_pth((char *)"stty", (char *)"sane", (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
|
2003-08-03 14:42:12 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-08-03 14:42:12 +00:00
|
|
|
signal(onsig, SIG_IGN);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-08-03 14:42:12 +00:00
|
|
|
if (onsig) {
|
|
|
|
if (onsig <= NSIG)
|
|
|
|
WriteError("Terminated on signal %d (%s)", onsig, SigName[onsig]);
|
|
|
|
else
|
|
|
|
WriteError("Terminated with error %d", onsig);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-08-03 14:42:12 +00:00
|
|
|
ulockprogram((char *)"mball");
|
|
|
|
t_end = time(NULL);
|
|
|
|
Syslog(' ', "MBALL finished in %s", t_elapsed(t_start, t_end));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-08-03 14:42:12 +00:00
|
|
|
if (!do_quiet) {
|
2005-08-19 19:46:55 +00:00
|
|
|
mbse_colour(LIGHTGRAY, BLACK);
|
2003-08-03 14:42:12 +00:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
ExitClient(onsig);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Help()
|
|
|
|
{
|
2005-08-19 19:46:55 +00:00
|
|
|
do_quiet = FALSE;
|
|
|
|
ProgName();
|
|
|
|
|
|
|
|
mbse_colour(LIGHTCYAN, BLACK);
|
|
|
|
printf("\nUsage: mball [command] <options>\n\n");
|
|
|
|
mbse_colour(LIGHTBLUE, BLACK);
|
|
|
|
printf(" Commands are:\n\n");
|
|
|
|
mbse_colour(CYAN, BLACK);
|
|
|
|
printf(" l list Create allfiles and newfiles lists\n");
|
|
|
|
mbse_colour(LIGHTBLUE, BLACK);
|
|
|
|
printf("\n Options are:\n\n");
|
|
|
|
mbse_colour(CYAN, BLACK);
|
|
|
|
printf(" -q -quiet Quiet mode\n");
|
|
|
|
printf(" -z -zip Create .zip archives\n");
|
|
|
|
mbse_colour(LIGHTGRAY, BLACK);
|
|
|
|
printf("\n");
|
|
|
|
die(MBERR_COMMANDLINE);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2003-08-03 14:42:12 +00:00
|
|
|
int i;
|
|
|
|
char *cmd;
|
|
|
|
struct passwd *pw;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-08-03 14:42:12 +00:00
|
|
|
InitConfig();
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_TermInit(1, 80, 24);
|
2003-08-03 14:42:12 +00:00
|
|
|
t_start = time(NULL);
|
|
|
|
umask(000);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-08-03 14:42:12 +00:00
|
|
|
/*
|
|
|
|
* Catch all signals we can, and ignore the rest.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < NSIG; i++) {
|
2007-09-02 11:17:31 +00:00
|
|
|
if ((i == SIGHUP) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV) || (i == SIGTERM) || (i == SIGIOT))
|
2003-08-03 14:42:12 +00:00
|
|
|
signal(i, (void (*))die);
|
2004-04-09 18:31:22 +00:00
|
|
|
else if (i == SIGCHLD)
|
|
|
|
signal(i, SIG_DFL);
|
2003-12-04 22:07:33 +00:00
|
|
|
else if ((i != SIGKILL) && (i != SIGSTOP))
|
2003-08-03 14:42:12 +00:00
|
|
|
signal(i, SIG_IGN);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-04 22:07:33 +00:00
|
|
|
if (argc < 2)
|
2003-08-03 14:42:12 +00:00
|
|
|
Help();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-08-03 14:42:12 +00:00
|
|
|
cmd = xstrcpy((char *)"Command line: mball");
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-08-03 14:42:12 +00:00
|
|
|
for (i = 1; i < argc; i++) {
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-08-03 14:42:12 +00:00
|
|
|
cmd = xstrcat(cmd, (char *)" ");
|
|
|
|
cmd = xstrcat(cmd, argv[i]);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-08-03 14:42:12 +00:00
|
|
|
if (!strncasecmp(argv[i], "l", 1))
|
|
|
|
do_list = TRUE;
|
|
|
|
if (!strncasecmp(argv[i], "-q", 2))
|
|
|
|
do_quiet = TRUE;
|
|
|
|
if (!strncasecmp(argv[i], "-z", 2))
|
|
|
|
do_zip = TRUE;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-08-03 14:42:12 +00:00
|
|
|
if (!do_list)
|
|
|
|
Help();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-08-03 14:42:12 +00:00
|
|
|
ProgName();
|
|
|
|
pw = getpwuid(getuid());
|
2003-09-09 19:39:51 +00:00
|
|
|
InitClient(pw->pw_name, (char *)"mball", CFG.location, CFG.logfile,
|
|
|
|
CFG.util_loglevel, CFG.error_log, CFG.mgrlog, CFG.debuglog);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-08-03 14:42:12 +00:00
|
|
|
Syslog(' ', " ");
|
|
|
|
Syslog(' ', "MBALL v%s", VERSION);
|
|
|
|
Syslog(' ', cmd);
|
|
|
|
free(cmd);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-08-03 14:42:12 +00:00
|
|
|
if (!do_quiet) {
|
2005-08-19 19:46:55 +00:00
|
|
|
mbse_colour(CYAN, BLACK);
|
2003-08-03 14:42:12 +00:00
|
|
|
printf("\n");
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-08-03 14:42:12 +00:00
|
|
|
if (lockprogram((char *)"mball")) {
|
2001-08-17 05:46:24 +00:00
|
|
|
if (!do_quiet)
|
2003-08-03 14:42:12 +00:00
|
|
|
printf("Can't lock mball, abort.\n");
|
|
|
|
die(MBERR_NO_PROGLOCK);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (do_list) {
|
2005-08-11 15:14:26 +00:00
|
|
|
dlcount();
|
2003-08-03 14:42:12 +00:00
|
|
|
Masterlist();
|
|
|
|
if (do_zip)
|
|
|
|
MakeArc();
|
|
|
|
CreateSema((char *)"mailin");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!do_quiet)
|
|
|
|
printf("Done!\n");
|
|
|
|
|
|
|
|
die(MBERR_OK);
|
|
|
|
return 0;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-03-02 21:28:28 +00:00
|
|
|
void MidLine(char *txt, FILE *fp, FILE *up, int doit)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2007-03-02 21:28:28 +00:00
|
|
|
char temp[256];
|
2005-08-19 19:46:55 +00:00
|
|
|
int x, y, z;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-08-19 19:46:55 +00:00
|
|
|
if (!doit)
|
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-08-19 19:46:55 +00:00
|
|
|
z = strlen(txt);
|
|
|
|
x = 77 - z;
|
|
|
|
x /= 2;
|
2007-03-02 21:28:28 +00:00
|
|
|
strcpy(temp, "\xB3");
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-08-19 19:46:55 +00:00
|
|
|
for (y = 0; y < x; y++)
|
|
|
|
strcat(temp, " ");
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2007-03-02 21:28:28 +00:00
|
|
|
strncat(temp, txt, 255);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2007-03-02 21:28:28 +00:00
|
|
|
for (y = strlen(temp); y < 78; y++)
|
|
|
|
strncat(temp, " ", 255);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2007-03-02 21:28:28 +00:00
|
|
|
strncat(temp, "\xB3\r\n", 255);
|
|
|
|
fprintf(fp, temp);
|
|
|
|
fprintf(up, chartran(temp));
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-03-02 21:28:28 +00:00
|
|
|
void TopBox(FILE *fp, FILE *up, int doit)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2007-03-02 21:28:28 +00:00
|
|
|
int y;
|
|
|
|
char temp[256];
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-08-19 19:46:55 +00:00
|
|
|
if (!doit)
|
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2007-03-02 21:28:28 +00:00
|
|
|
strcpy(temp, "\r\n\xDA");
|
2005-08-19 19:46:55 +00:00
|
|
|
for(y = 0; y < 77; y++)
|
2007-03-02 21:28:28 +00:00
|
|
|
strncat(temp, "\xC4", 255);
|
|
|
|
strncat(temp, "\xBF\r\n", 255);
|
|
|
|
fprintf(fp, temp);
|
|
|
|
fprintf(up, chartran(temp));
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-03-02 21:28:28 +00:00
|
|
|
void BotBox(FILE *fp, FILE *up, int doit)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2007-03-02 21:28:28 +00:00
|
|
|
int y;
|
|
|
|
char temp[256];
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-08-19 19:46:55 +00:00
|
|
|
if (!doit)
|
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2007-03-02 21:28:28 +00:00
|
|
|
strcpy(temp, "\xC0");
|
2005-08-19 19:46:55 +00:00
|
|
|
for (y = 0; y < 77; y++)
|
2007-03-02 21:28:28 +00:00
|
|
|
strncat(temp, "\xC4", 255);
|
|
|
|
strncat(temp, "\xD9\r\n\r\n", 255);
|
|
|
|
fprintf(fp, temp);
|
|
|
|
fprintf(up, chartran(temp));
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-06-16 12:07:49 +00:00
|
|
|
void WriteFiles(FILE *fp, FILE *fu, FILE *np, FILE *nu, int New, char *temp)
|
|
|
|
{
|
|
|
|
fprintf(fp, "%s\r\n", temp);
|
|
|
|
fprintf(fu, "%s\r\n", chartran(temp));
|
|
|
|
if (New) {
|
|
|
|
fprintf(np, "%s\r\n", temp);
|
|
|
|
fprintf(nu, "%s\r\n", chartran(temp));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-08-17 05:46:24 +00:00
|
|
|
void Masterlist()
|
|
|
|
{
|
2007-03-02 21:28:28 +00:00
|
|
|
FILE *fp, *np, *fu, *nu, *pAreas, *pHeader;
|
2002-02-12 20:03:36 +00:00
|
|
|
int AreaNr = 0, z, x = 0, New;
|
2005-10-11 20:49:41 +00:00
|
|
|
unsigned int AllFiles = 0, AllKBytes = 0, NewFiles = 0, NewKBytes = 0;
|
|
|
|
unsigned int AllAreaFiles, AllAreaBytes, popdown, down, NewAreaFiles, NewAreaBytes;
|
2005-08-30 17:45:31 +00:00
|
|
|
char *sAreas, temp[PATH_MAX], pop[81];
|
2004-05-07 14:31:47 +00:00
|
|
|
struct _fdbarea *fdb_area = NULL;
|
2002-02-12 20:03:36 +00:00
|
|
|
|
|
|
|
sAreas = calloc(PATH_MAX, sizeof(char));
|
|
|
|
|
|
|
|
IsDoing("Create Allfiles list");
|
|
|
|
|
2005-08-30 17:45:31 +00:00
|
|
|
snprintf(sAreas, PATH_MAX, "%s/etc/fareas.data", getenv("MBSE_ROOT"));
|
2002-02-12 20:03:36 +00:00
|
|
|
|
|
|
|
if(( pAreas = fopen (sAreas, "r")) == NULL) {
|
|
|
|
WriteError("Can't open File Areas File: %s", sAreas);
|
2005-08-19 19:46:55 +00:00
|
|
|
mbse_colour(LIGHTGRAY, BLACK);
|
2002-10-20 20:58:55 +00:00
|
|
|
die(MBERR_GENERAL);
|
2002-02-12 20:03:36 +00:00
|
|
|
}
|
|
|
|
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");
|
2002-10-20 20:58:55 +00:00
|
|
|
die(MBERR_GENERAL);
|
2002-02-12 20:03:36 +00:00
|
|
|
}
|
|
|
|
if ((np = fopen("newfiles.tmp", "a+")) == NULL) {
|
|
|
|
WriteError("$Can't open newfiles.tmp");
|
|
|
|
fclose(fp);
|
2002-10-20 20:58:55 +00:00
|
|
|
die(MBERR_GENERAL);
|
2002-02-12 20:03:36 +00:00
|
|
|
}
|
2007-03-02 21:28:28 +00:00
|
|
|
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');
|
2002-02-12 20:03:36 +00:00
|
|
|
|
2007-03-02 21:28:28 +00:00
|
|
|
TopBox(fp, fu, TRUE);
|
|
|
|
TopBox(np, nu, TRUE);
|
2005-08-30 17:45:31 +00:00
|
|
|
snprintf(temp, 81, "All available files at %s", CFG.bbs_name);
|
2007-03-02 21:28:28 +00:00
|
|
|
MidLine(temp, fp, fu, TRUE);
|
2005-08-30 17:45:31 +00:00
|
|
|
snprintf(temp, 81, "New available files since %d days at %s", CFG.newdays, CFG.bbs_name);
|
2007-03-02 21:28:28 +00:00
|
|
|
MidLine(temp, np, nu, TRUE);
|
|
|
|
BotBox(fp, fu, TRUE);
|
|
|
|
BotBox(np, nu, TRUE);
|
2002-02-12 20:03:36 +00:00
|
|
|
|
2005-08-30 17:45:31 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s/etc/header.txt", getenv("MBSE_ROOT"));
|
2002-02-12 20:03:36 +00:00
|
|
|
if (( pHeader = fopen(temp, "r")) != NULL) {
|
|
|
|
Syslog('+', "Inserting %s", temp);
|
|
|
|
|
|
|
|
while( fgets(temp, 80 ,pHeader) != NULL) {
|
2003-12-04 22:07:33 +00:00
|
|
|
Striplf(temp);
|
|
|
|
fprintf(fp, "%s\r\n", temp);
|
|
|
|
fprintf(np, "%s\r\n", temp);
|
2007-03-02 21:28:28 +00:00
|
|
|
fprintf(fu, "%s\r\n", chartran(temp));
|
|
|
|
fprintf(nu, "%s\r\n", chartran(temp));
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-12-04 22:07:33 +00:00
|
|
|
fclose(pHeader);
|
2002-02-12 20:03:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
2004-05-07 14:31:47 +00:00
|
|
|
if ((fdb_area = mbsedb_OpenFDB(AreaNr, 30)) == 0) {
|
2005-08-19 19:46:55 +00:00
|
|
|
WriteError("Can't open Area %d (%s)! Skipping ...", AreaNr, area.Name);
|
2002-02-12 20:03:36 +00:00
|
|
|
} else {
|
|
|
|
popdown = 0;
|
2004-05-07 14:31:47 +00:00
|
|
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
2004-03-06 21:48:41 +00:00
|
|
|
if (!fdb.Deleted) {
|
2002-02-12 20:03:36 +00:00
|
|
|
/*
|
|
|
|
* The next is to reduce system load.
|
|
|
|
*/
|
|
|
|
x++;
|
|
|
|
if (CFG.slow_util && do_quiet && ((x % 3) == 0))
|
2004-01-25 10:57:35 +00:00
|
|
|
msleep(1);
|
2002-02-12 20:03:36 +00:00
|
|
|
AllFiles++;
|
|
|
|
AllAreaFiles++;
|
2004-03-06 21:48:41 +00:00
|
|
|
AllAreaBytes += fdb.Size;
|
|
|
|
down = fdb.TimesDL;
|
2002-02-12 20:03:36 +00:00
|
|
|
if (down > popdown) {
|
|
|
|
popdown = down;
|
2005-08-30 17:45:31 +00:00
|
|
|
snprintf(pop, 81, "%s", fdb.Name);
|
2002-02-12 20:03:36 +00:00
|
|
|
}
|
2004-03-06 21:48:41 +00:00
|
|
|
if (((t_start - fdb.UploadDate) / 84400) <= CFG.newdays) {
|
2002-02-12 20:03:36 +00:00
|
|
|
NewFiles++;
|
|
|
|
NewAreaFiles++;
|
2004-03-06 21:48:41 +00:00
|
|
|
NewAreaBytes += fdb.Size;
|
2002-02-12 20:03:36 +00:00
|
|
|
}
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
2002-02-12 20:03:36 +00:00
|
|
|
AllKBytes += AllAreaBytes / 1024;
|
|
|
|
NewKBytes += NewAreaBytes / 1024;
|
2002-02-02 10:23:13 +00:00
|
|
|
|
2002-02-12 20:03:36 +00:00
|
|
|
/*
|
|
|
|
* If there are files to report do it.
|
|
|
|
*/
|
|
|
|
if (AllAreaFiles) {
|
2007-03-02 21:28:28 +00:00
|
|
|
TopBox(fp, fu, TRUE);
|
|
|
|
TopBox(np, nu, NewAreaFiles);
|
2002-02-12 20:03:36 +00:00
|
|
|
|
2005-08-30 17:45:31 +00:00
|
|
|
snprintf(temp, 81, "Area %d - %s", AreaNr, area.Name);
|
2007-03-02 21:28:28 +00:00
|
|
|
MidLine(temp, fp, fu, TRUE);
|
|
|
|
MidLine(temp, np, nu, NewAreaFiles);
|
2002-02-12 20:03:36 +00:00
|
|
|
|
2005-08-30 17:45:31 +00:00
|
|
|
snprintf(temp, 81, "File Requests allowed");
|
2007-03-02 21:28:28 +00:00
|
|
|
MidLine(temp, fp, fu, area.FileReq);
|
|
|
|
MidLine(temp, np, nu, area.FileReq && NewAreaFiles);
|
2002-02-12 20:03:36 +00:00
|
|
|
|
2005-10-11 20:49:41 +00:00
|
|
|
snprintf(temp, 81, "%d KBytes in %d files", AllAreaBytes / 1024, AllAreaFiles);
|
2007-03-02 21:28:28 +00:00
|
|
|
MidLine(temp, fp, fu, TRUE);
|
2005-10-11 20:49:41 +00:00
|
|
|
snprintf(temp, 81, "%d KBytes in %d files", NewAreaBytes / 1024, NewAreaFiles);
|
2007-03-02 21:28:28 +00:00
|
|
|
MidLine(temp, np, nu, NewAreaFiles);
|
2002-02-12 20:03:36 +00:00
|
|
|
if (popdown) {
|
2005-08-30 17:45:31 +00:00
|
|
|
snprintf(temp, 81, "Most popular file is %s", pop);
|
2007-03-02 21:28:28 +00:00
|
|
|
MidLine(temp, fp, fu, TRUE);
|
2002-02-12 20:03:36 +00:00
|
|
|
}
|
|
|
|
|
2007-03-02 21:28:28 +00:00
|
|
|
BotBox(fp, fu, TRUE);
|
|
|
|
BotBox(np, nu, NewAreaFiles);
|
2002-02-12 20:03:36 +00:00
|
|
|
|
2004-05-07 14:31:47 +00:00
|
|
|
fseek(fdb_area->fp, fdbhdr.hdrsize, SEEK_SET);
|
|
|
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
2004-03-06 21:48:41 +00:00
|
|
|
if (!fdb.Deleted) {
|
|
|
|
New = (((t_start - fdb.UploadDate) / 84400) <= CFG.newdays);
|
2007-03-02 21:28:28 +00:00
|
|
|
|
2007-06-19 18:49:29 +00:00
|
|
|
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:"");
|
2007-06-16 12:07:49 +00:00
|
|
|
WriteFiles(fp, fu, np, nu, New, temp);
|
|
|
|
|
2004-03-18 19:55:39 +00:00
|
|
|
for (z = 0; z < 25; z++) {
|
2004-03-06 21:48:41 +00:00
|
|
|
if (strlen(fdb.Desc[z])) {
|
|
|
|
if ((fdb.Desc[z][0] == '@') && (fdb.Desc[z][1] == 'X')) {
|
2007-06-19 18:49:29 +00:00
|
|
|
snprintf(temp, 81, " %s", fdb.Desc[z]+4);
|
2002-02-12 20:03:36 +00:00
|
|
|
} else {
|
2007-06-19 18:49:29 +00:00
|
|
|
snprintf(temp, 81, " %s", fdb.Desc[z]);
|
2002-02-12 20:03:36 +00:00
|
|
|
}
|
2007-06-16 12:07:49 +00:00
|
|
|
WriteFiles(fp, fu, np, nu, New, temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-02-12 20:03:36 +00:00
|
|
|
}
|
2007-06-16 12:07:49 +00:00
|
|
|
|
2004-03-18 19:55:39 +00:00
|
|
|
if (strlen(fdb.Magic)) {
|
2007-06-19 18:49:29 +00:00
|
|
|
snprintf(temp, 81, " Magic filerequest: %s", fdb.Magic);
|
2007-06-16 12:07:49 +00:00
|
|
|
WriteFiles(fp, fu, np, nu, New, temp);
|
2004-03-18 19:55:39 +00:00
|
|
|
}
|
2007-06-19 18:49:29 +00:00
|
|
|
WriteFiles(fp, fu, np, nu, New, (char *)"");
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-02-12 20:03:36 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-05-07 14:31:47 +00:00
|
|
|
mbsedb_CloseFDB(fdb_area);
|
|
|
|
}
|
2002-02-12 20:03:36 +00:00
|
|
|
}
|
|
|
|
} /* End of While Loop Checking for Areas Done */
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-12 20:03:36 +00:00
|
|
|
fclose(pAreas);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2007-03-02 21:28:28 +00:00
|
|
|
TopBox(fp, fu, TRUE);
|
|
|
|
TopBox(np, nu, TRUE);
|
2005-10-11 20:49:41 +00:00
|
|
|
snprintf(temp, 81, "Total %d files, %d KBytes", AllFiles, AllKBytes);
|
2007-03-02 21:28:28 +00:00
|
|
|
MidLine(temp, fp, fu, TRUE);
|
2005-10-11 20:49:41 +00:00
|
|
|
snprintf(temp, 81, "Total %d files, %d KBytes", NewFiles, NewKBytes);
|
2007-03-02 21:28:28 +00:00
|
|
|
MidLine(temp, np, nu, TRUE);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2007-03-02 21:28:28 +00:00
|
|
|
MidLine((char *)"", fp, fu, TRUE);
|
|
|
|
MidLine((char *)"", np, nu, TRUE);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-08-30 17:45:31 +00:00
|
|
|
snprintf(temp, 81, "Created by MBSE BBS v%s (%s-%s) at %s", VERSION, OsName(), OsCPU(), StrDateDMY(t_start));
|
2007-03-02 21:28:28 +00:00
|
|
|
MidLine(temp, fp, fu, TRUE);
|
|
|
|
MidLine(temp, np, nu, TRUE);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2007-03-02 21:28:28 +00:00
|
|
|
BotBox(fp, fu, TRUE);
|
|
|
|
BotBox(np, nu, TRUE);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-08-30 17:45:31 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s/etc/footer.txt", getenv("MBSE_ROOT"));
|
2002-02-12 20:03:36 +00:00
|
|
|
if(( pHeader = fopen(temp, "r")) != NULL) {
|
|
|
|
Syslog('+', "Inserting %s", temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-12 20:03:36 +00:00
|
|
|
while( fgets(temp, 80 ,pHeader) != NULL) {
|
|
|
|
Striplf(temp);
|
|
|
|
fprintf(fp, "%s\r\n", temp);
|
|
|
|
fprintf(np, "%s\r\n", temp);
|
2007-03-02 21:28:28 +00:00
|
|
|
fprintf(fu, "%s\r\n", chartran(temp));
|
|
|
|
fprintf(nu, "%s\r\n", chartran(temp));
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-12-04 22:07:33 +00:00
|
|
|
fclose(pHeader);
|
2002-02-12 20:03:36 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-12 20:03:36 +00:00
|
|
|
fclose(fp);
|
|
|
|
fclose(np);
|
2007-03-02 21:28:28 +00:00
|
|
|
fclose(fu);
|
|
|
|
fclose(nu);
|
|
|
|
chartran_close();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-12 20:03:36 +00:00
|
|
|
if ((rename("allfiles.tmp", "allfiles.txt")) == 0)
|
|
|
|
unlink("allfiles.tmp");
|
|
|
|
if ((rename("newfiles.tmp", "newfiles.txt")) == 0)
|
|
|
|
unlink("newfiles.tmp");
|
2007-03-02 21:28:28 +00:00
|
|
|
if ((rename("allfiles.ump", "allfiles.utf")) == 0)
|
|
|
|
unlink("allfiles.ump");
|
|
|
|
if ((rename("newfiles.ump", "newfiles.utf")) == 0)
|
|
|
|
unlink("newfiles.ump");
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-12 20:03:36 +00:00
|
|
|
Syslog('+', "Allfiles: %ld, %ld MBytes", AllFiles, AllKBytes / 1024);
|
|
|
|
Syslog('+', "Newfiles: %ld, %ld MBytes", NewFiles, NewKBytes / 1024);
|
|
|
|
free(sAreas);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MakeArc()
|
|
|
|
{
|
2005-08-19 19:46:55 +00:00
|
|
|
char *cmd;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-08-19 19:46:55 +00:00
|
|
|
if (!getarchiver((char *)"ZIP")) {
|
|
|
|
WriteError("ZIP Archiver not available");
|
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-08-19 19:46:55 +00:00
|
|
|
cmd = xstrcpy(archiver.farc);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-08-19 19:46:55 +00:00
|
|
|
if (cmd == NULL) {
|
|
|
|
WriteError("ZIP archive command not available");
|
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-08-19 19:46:55 +00:00
|
|
|
Nopper();
|
|
|
|
if (!do_quiet)
|
|
|
|
printf("Creating allfiles.zip\n");
|
2007-03-02 21:28:28 +00:00
|
|
|
if (!execute_str(cmd, (char *)"allfiles.zip allfiles.txt allfiles.utf", (char *)NULL, (char *)"/dev/null",
|
2001-08-17 05:46:24 +00:00
|
|
|
(char *)"/dev/null", (char *)"/dev/null") == 0)
|
2005-08-19 19:46:55 +00:00
|
|
|
WriteError("Create allfiles.zip failed");
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-08-19 19:46:55 +00:00
|
|
|
Nopper();
|
|
|
|
if (!do_quiet)
|
|
|
|
printf("Creating newfiles.zip\n");
|
2007-03-02 21:28:28 +00:00
|
|
|
if (!execute_str(cmd, (char *)"newfiles.zip newfiles.txt newfiles.utf", (char *)NULL, (char *)"/dev/null",
|
2001-08-17 05:46:24 +00:00
|
|
|
(char *)"/dev/null", (char *)"/dev/null") == 0)
|
2005-08-19 19:46:55 +00:00
|
|
|
WriteError("Create newfiles.zip failed");
|
|
|
|
|
|
|
|
free(cmd);
|
|
|
|
cmd = NULL;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|