Just checking
This commit is contained in:
parent
8eafac306b
commit
628d5cf596
@ -58,6 +58,7 @@ v0.37.00 26-Dec-2002.
|
||||
mbfile:
|
||||
Move old files to another area failed, only the symbolic link
|
||||
was moved.
|
||||
Prepared for multilanguage html pages creation.
|
||||
|
||||
mbfido:
|
||||
Echomail from other zones showed the address of your own zone.
|
||||
|
@ -47,6 +47,9 @@
|
||||
extern int do_quiet; /* Suppress screen output */
|
||||
int lastfile; /* Last file number */
|
||||
long gfilepos = 0; /* Global file position */
|
||||
int TotalHtml = 0; /* Total html files */
|
||||
int AreasHtml = 0; /* Total html areas */
|
||||
|
||||
|
||||
|
||||
typedef struct _Index {
|
||||
@ -181,6 +184,7 @@ int comp_index(Findex **fap1, Findex **fap2)
|
||||
|
||||
|
||||
|
||||
void MacroRead(FILE *, FILE *);
|
||||
void MacroRead(FILE *fi, FILE *fp)
|
||||
{
|
||||
char *line, *temp;
|
||||
@ -329,32 +333,17 @@ void closepage(FILE *fa, char *Path, int inArea, int Current, FILE *fi)
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Build a sorted index for the file request processor.
|
||||
* Build html index pages for download.
|
||||
*/
|
||||
void Index(void)
|
||||
void ReqIndex(void);
|
||||
void ReqIndex(void)
|
||||
{
|
||||
FILE *pAreas, *pFile, *pIndex, *fa, *fb = NULL, *fm, *fp, *fi = NULL;
|
||||
unsigned long i, iAreas, iAreasNew = 0, record, KSize = 0L, aSize = 0;
|
||||
int iTotal = 0, AreaNr = 0, j, k, z, x = 0, Areas = 0;
|
||||
int Total = 0, aTotal = 0, inArea = 0, filenr;
|
||||
int fbAreas = 0, fbFiles = 0;
|
||||
char *sAreas, *fAreas, *newdir = NULL, *sIndex, *fn, *temp;
|
||||
char linebuf[1024], outbuf[1024], desc[6400];
|
||||
time_t last = 0L, later;
|
||||
Findex *fdx = NULL;
|
||||
Findex *tmp;
|
||||
struct FILEIndex idx;
|
||||
long fileptr = 0, fileptr1 = 0;
|
||||
|
||||
sAreas = calloc(PATH_MAX, sizeof(char));
|
||||
fAreas = calloc(PATH_MAX, sizeof(char));
|
||||
sIndex = calloc(PATH_MAX, sizeof(char));
|
||||
fn = calloc(PATH_MAX, sizeof(char));
|
||||
temp = calloc(PATH_MAX, sizeof(char));
|
||||
|
||||
later = time(NULL) + 86400;
|
||||
FILE *pAreas, *pFile, *pIndex, *fp;
|
||||
unsigned long i, iAreas, iAreasNew = 0, record;
|
||||
int iTotal = 0, j, z, x = 0;
|
||||
int fbAreas = 0, fbFiles = 0;
|
||||
char *sAreas, *fAreas, *newdir = NULL, *sIndex, *temp;
|
||||
Findex *fdx = NULL;
|
||||
Findex *tmp;
|
||||
struct FILEIndex idx;
|
||||
|
||||
IsDoing("Index files");
|
||||
if (!do_quiet) {
|
||||
@ -362,6 +351,11 @@ void Index(void)
|
||||
printf("Create index files...\n");
|
||||
}
|
||||
|
||||
sAreas = calloc(PATH_MAX, sizeof(char));
|
||||
fAreas = calloc(PATH_MAX, sizeof(char));
|
||||
sIndex = calloc(PATH_MAX, sizeof(char));
|
||||
temp = calloc(PATH_MAX, sizeof(char));
|
||||
|
||||
sprintf(sAreas, "%s/etc/fareas.data", getenv("MBSE_ROOT"));
|
||||
if ((pAreas = fopen (sAreas, "r")) == NULL) {
|
||||
WriteError("$Can't open %s", sAreas);
|
||||
@ -378,47 +372,9 @@ void Index(void)
|
||||
fseek(pAreas, 0, SEEK_END);
|
||||
iAreas = (ftell(pAreas) - areahdr.hdrsize) / areahdr.recsize;
|
||||
|
||||
/*
|
||||
* Check if we are able to create the index.html pages in the
|
||||
* download directories.
|
||||
*/
|
||||
if (strlen(CFG.ftp_base) && strlen(CFG.www_url) && strlen(CFG.www_author) && strlen(CFG.www_charset)) {
|
||||
sprintf(fn, "%s/index.temp", CFG.ftp_base);
|
||||
if ((fm = fopen(fn, "w")) == NULL) {
|
||||
Syslog('+', "Can't open %s, skipping html pages creation", fn);
|
||||
}
|
||||
} else {
|
||||
fm = NULL;
|
||||
Syslog('+', "FTP/HTML not defined, skipping html pages creation");
|
||||
}
|
||||
|
||||
if (fm) {
|
||||
if ((fi = OpenMacro("html.main", 'E', TRUE)) == NULL) {
|
||||
Syslog('+', "Can't open macro file, skipping html pages creation");
|
||||
fclose(fm);
|
||||
unlink(fn);
|
||||
}
|
||||
}
|
||||
|
||||
if (fm) {
|
||||
/*
|
||||
* Because these web pages are dynamic, ie. they change everytime you
|
||||
* receive new files and recreates these pages, extra HTTP headers are
|
||||
* send to the client about these pages. It forbids proxy servers to
|
||||
* cache these pages. The pages will expire within 24 hours. The pages
|
||||
* also have an author name, this is the bbs name, and a content
|
||||
* description for search engines. Automatic advertising.
|
||||
*/
|
||||
MacroVars("acd", "sdd", rfcdate(later), 0, 0);
|
||||
MacroRead(fi, fm);
|
||||
fileptr = ftell(fi);
|
||||
}
|
||||
|
||||
for (i = 1; i <= iAreas; i++) {
|
||||
|
||||
fseek(pAreas, ((i-1) * areahdr.recsize) + areahdr.hdrsize, SEEK_SET);
|
||||
fread(&area, areahdr.recsize, 1, pAreas);
|
||||
AreaNr++;
|
||||
|
||||
if (area.Available) {
|
||||
|
||||
@ -492,7 +448,6 @@ void Index(void)
|
||||
} else {
|
||||
fseek(pFile, 0, SEEK_SET);
|
||||
fbAreas++;
|
||||
|
||||
while (fread(&file, sizeof(file), 1, pFile) == 1) {
|
||||
if ((!file.Deleted) && (!file.Missing)) {
|
||||
fbFiles++;
|
||||
@ -507,42 +462,25 @@ void Index(void)
|
||||
}
|
||||
|
||||
/*
|
||||
* Create 00index file and index.html pages in each available download area.
|
||||
* Create 00index file.
|
||||
*/
|
||||
if (!area.CDrom && fm && (strncmp(CFG.ftp_base, area.Path, strlen(CFG.ftp_base)) == 0)) {
|
||||
if (!area.CDrom && (strncmp(CFG.ftp_base, area.Path, strlen(CFG.ftp_base)) == 0)) {
|
||||
|
||||
sprintf(temp, "%s/00index", area.Path);
|
||||
if ((fp = fopen(temp, "w")) == NULL) {
|
||||
WriteError("$Can't create %s", temp);
|
||||
} else {
|
||||
fseek(pFile, 0, SEEK_SET);
|
||||
Areas++;
|
||||
inArea = 0;
|
||||
while (fread(&file, sizeof(file), 1, pFile) == 1) {
|
||||
if ((!file.Deleted) && (!file.Missing))
|
||||
inArea++;
|
||||
}
|
||||
fseek(pFile, 0, SEEK_SET);
|
||||
|
||||
aSize = 0L;
|
||||
aTotal = 0;
|
||||
last = 0L;
|
||||
if ((fb = OpenMacro("html.areas", 'E', TRUE)) == NULL) {
|
||||
fa = NULL;
|
||||
} else {
|
||||
fa = newpage(area.Path, area.Name, later, inArea, aTotal, fb);
|
||||
fileptr1 = gfilepos;
|
||||
}
|
||||
while (fread(&file, sizeof(file), 1, pFile) == 1) {
|
||||
if ((!file.Deleted) && (!file.Missing)) {
|
||||
/*
|
||||
* The next is to reduce system load
|
||||
*/
|
||||
x++;
|
||||
Total++;
|
||||
aTotal++;
|
||||
if (CFG.slow_util && do_quiet && ((x % 3) == 0))
|
||||
usleep(1);
|
||||
|
||||
for (z = 0; z <= 25; z++) {
|
||||
if (strlen(file.Desc[z])) {
|
||||
if (z == 0)
|
||||
@ -556,122 +494,14 @@ void Index(void)
|
||||
fprintf(fp, "%s\n", file.Desc[z]);
|
||||
}
|
||||
}
|
||||
|
||||
MacroVars("efghijklm", "ddsssssds", 0, 0, "", "", "", "", "", 0, "");
|
||||
MacroVars("e", "d", aTotal);
|
||||
/*
|
||||
* Check if this is a .gif or .jpg file, if so then
|
||||
* check if a thumbnail file exists. If not try to
|
||||
* create a thumbnail file to add to the html listing.
|
||||
*/
|
||||
if (strstr(file.LName, ".gif") || strstr(file.LName, ".jpg") ||
|
||||
strstr(file.LName, ".GIF") || strstr(file.LName, ".JPG")) {
|
||||
sprintf(linebuf, "%s/%s", area.Path, file.Name);
|
||||
sprintf(outbuf, "%s/.%s", area.Path, file.Name);
|
||||
if (file_exist(outbuf, R_OK)) {
|
||||
if ((j = execute(CFG.www_convert, linebuf, outbuf,
|
||||
(char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null"))) {
|
||||
Syslog('+', "Failed to create thumbnail for %s, rc=% d", file.Name, j);
|
||||
} else {
|
||||
chmod(outbuf, 0644);
|
||||
}
|
||||
}
|
||||
sprintf(outbuf, "%s/%s%s/%s", CFG.www_url, CFG.www_link2ftp,
|
||||
area.Path+strlen(CFG.ftp_base), file.Name);
|
||||
sprintf(linebuf, "%s/%s%s/.%s", CFG.www_url, CFG.www_link2ftp,
|
||||
area.Path+strlen(CFG.ftp_base), file.Name);
|
||||
MacroVars("fghi", "dsss", 1, outbuf, file.LName, linebuf);
|
||||
} else {
|
||||
sprintf(outbuf, "%s/%s%s/%s", CFG.www_url, CFG.www_link2ftp,
|
||||
area.Path+strlen(CFG.ftp_base), file.Name);
|
||||
MacroVars("fghi", "dsss", 0, outbuf, file.LName, "");
|
||||
}
|
||||
sprintf(outbuf, "%lu Kb.", (long)(file.Size / 1024));
|
||||
MacroVars("jkl", "ssd", StrDateDMY(file.FileDate), outbuf, file.TimesDL+file.TimesFTP+file.TimesReq);
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
k = 0;
|
||||
for (j = 0; j < 25; j++)
|
||||
if (strlen(file.Desc[j])) {
|
||||
if (j) {
|
||||
sprintf(desc+k, "\n");
|
||||
k += 1;
|
||||
}
|
||||
sprintf(linebuf, "%s", To_Html(file.Desc[j]));
|
||||
html_massage(linebuf, outbuf);
|
||||
sprintf(desc+k, "%s", outbuf);
|
||||
k += strlen(outbuf);
|
||||
}
|
||||
MacroVars("m", "s", desc);
|
||||
fseek(fb, fileptr1, SEEK_SET);
|
||||
MacroRead(fb, fa);
|
||||
aSize += file.Size;
|
||||
MacroVars("efghijklm", "ddsssssds", 0, 0, "", "", "", "", "", 0, "");
|
||||
if (file.FileDate > last)
|
||||
last = file.FileDate;
|
||||
if ((aTotal % CFG.www_files_page) == 0) {
|
||||
closepage(fa, area.Path, inArea, aTotal, fb);
|
||||
fseek(fb, 0, SEEK_SET);
|
||||
fa = newpage(area.Path, area.Name, later, inArea, aTotal, fb);
|
||||
}
|
||||
} /* if (!file.deleted) */
|
||||
}
|
||||
}
|
||||
|
||||
if (aTotal == 0) {
|
||||
/*
|
||||
* Nothing written, skip skip fileblock
|
||||
*/
|
||||
while ((fgets(linebuf, 254, fb) != NULL) && ((linebuf[0]!='@') || (linebuf[1]!='|')));
|
||||
}
|
||||
|
||||
KSize += aSize / 1024;
|
||||
closepage(fa, area.Path, inArea, aTotal, fb);
|
||||
fclose(fb);
|
||||
fclose(fp);
|
||||
chmod(temp, 0644);
|
||||
|
||||
/*
|
||||
* If the time before there were more files in this area then now,
|
||||
* the number of html pages may de decreased. We try to delete these
|
||||
* files if they should exist.
|
||||
*/
|
||||
filenr = lastfile / CFG.www_files_page;
|
||||
while (TRUE) {
|
||||
filenr++;
|
||||
sprintf(linebuf, "%s/index%d.html", area.Path, filenr);
|
||||
if (unlink(linebuf))
|
||||
break;
|
||||
Syslog('+', "Removed obsolete %s", linebuf);
|
||||
}
|
||||
|
||||
sprintf(linebuf, "%s/%s%s/index.html", CFG.www_url, CFG.www_link2ftp, area.Path+strlen(CFG.ftp_base));
|
||||
if (aSize > 1048576)
|
||||
sprintf(outbuf, "%ld Mb.", aSize / 1048576);
|
||||
else
|
||||
sprintf(outbuf, "%ld Kb.", aSize / 1024);
|
||||
MacroVars("efghi", "dssds", AreaNr, linebuf, area.Name, aTotal, outbuf);
|
||||
if (last == 0L)
|
||||
MacroVars("j", "s", " ");
|
||||
else
|
||||
MacroVars("j", "s", StrDateDMY(last));
|
||||
fseek(fi, fileptr, SEEK_SET);
|
||||
MacroRead(fi, fm);
|
||||
}
|
||||
}
|
||||
fclose(pFile);
|
||||
|
||||
} /* if area.Available */
|
||||
}
|
||||
|
||||
if (fm) {
|
||||
sprintf(linebuf, "%ld Mb.", KSize / 1024);
|
||||
MacroVars("cd", "ds", Total, linebuf);
|
||||
MacroRead(fi, fm);
|
||||
fclose(fi);
|
||||
MacroClear();
|
||||
fclose(fm);
|
||||
sprintf(linebuf, "%s/index.html", CFG.ftp_base);
|
||||
rename(fn, linebuf);
|
||||
chmod(linebuf, 0644);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(pAreas);
|
||||
@ -684,20 +514,288 @@ void Index(void)
|
||||
|
||||
Syslog('+', "Index Areas [%5d] Files [%5d]", iAreasNew, iTotal);
|
||||
Syslog('+', "Files Areas [%5d] Files [%5d]", fbAreas, fbFiles);
|
||||
Syslog('+', "HTML Areas [%5d] Files [%5d]", Areas, Total);
|
||||
|
||||
free(sAreas);
|
||||
free(fAreas);
|
||||
free(sIndex);
|
||||
free(temp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Build a sorted index for the file request processor.
|
||||
* Build html index pages for download.
|
||||
*/
|
||||
void HtmlIndex(char *);
|
||||
void HtmlIndex(char *Lang)
|
||||
{
|
||||
FILE *pAreas, *pFile, *fa, *fb = NULL, *fm, *fi = NULL;
|
||||
unsigned long i, iAreas, KSize = 0L, aSize = 0;
|
||||
int AreaNr = 0, j, k, x = 0;
|
||||
int aTotal = 0, inArea = 0, filenr;
|
||||
char *sAreas, *fAreas, *fn;
|
||||
char linebuf[1024], outbuf[1024], desc[6400];
|
||||
time_t last = 0L, later;
|
||||
long fileptr = 0, fileptr1 = 0;
|
||||
|
||||
sAreas = calloc(PATH_MAX, sizeof(char));
|
||||
fAreas = calloc(PATH_MAX, sizeof(char));
|
||||
fn = calloc(PATH_MAX, sizeof(char));
|
||||
|
||||
AreasHtml = 0;
|
||||
TotalHtml = 0;
|
||||
later = time(NULL) + 86400;
|
||||
|
||||
IsDoing("Create html");
|
||||
if (!do_quiet) {
|
||||
colour(3, 0);
|
||||
printf("\rCreate html pages... \n");
|
||||
}
|
||||
|
||||
sprintf(sAreas, "%s/etc/fareas.data", getenv("MBSE_ROOT"));
|
||||
if ((pAreas = fopen (sAreas, "r")) == NULL) {
|
||||
WriteError("$Can't open %s", sAreas);
|
||||
die(MBERR_INIT_ERROR);
|
||||
}
|
||||
|
||||
fread(&areahdr, sizeof(areahdr), 1, pAreas);
|
||||
fseek(pAreas, 0, SEEK_END);
|
||||
iAreas = (ftell(pAreas) - areahdr.hdrsize) / areahdr.recsize;
|
||||
|
||||
/*
|
||||
* Check if we are able to create the index.html pages in the
|
||||
* download directories.
|
||||
*/
|
||||
if (strlen(CFG.ftp_base) && strlen(CFG.www_url) && strlen(CFG.www_author) && strlen(CFG.www_charset)) {
|
||||
sprintf(fn, "%s/index.temp", CFG.ftp_base);
|
||||
if ((fm = fopen(fn, "w")) == NULL) {
|
||||
Syslog('+', "Can't open %s, skipping html pages creation", fn);
|
||||
}
|
||||
} else {
|
||||
fm = NULL;
|
||||
Syslog('+', "FTP/HTML not defined, skipping html pages creation");
|
||||
}
|
||||
|
||||
if (fm) {
|
||||
if ((fi = OpenMacro("html.main", 'E', TRUE)) == NULL) {
|
||||
Syslog('+', "Can't open macro file, skipping html pages creation");
|
||||
fclose(fm);
|
||||
unlink(fn);
|
||||
}
|
||||
}
|
||||
|
||||
if (fm) {
|
||||
/*
|
||||
* Because these web pages are dynamic, ie. they change everytime you
|
||||
* receive new files and recreates these pages, extra HTTP headers are
|
||||
* send to the client about these pages. It forbids proxy servers to
|
||||
* cache these pages. The pages will expire within 24 hours. The pages
|
||||
* also have an author name, this is the bbs name, and a content
|
||||
* description for search engines. Automatic advertising.
|
||||
*/
|
||||
MacroVars("acd", "sdd", rfcdate(later), 0, 0);
|
||||
MacroRead(fi, fm);
|
||||
fileptr = ftell(fi);
|
||||
}
|
||||
|
||||
for (i = 1; i <= iAreas; i++) {
|
||||
|
||||
fseek(pAreas, ((i-1) * areahdr.recsize) + areahdr.hdrsize, SEEK_SET);
|
||||
fread(&area, areahdr.recsize, 1, pAreas);
|
||||
AreaNr++;
|
||||
|
||||
if (area.Available) {
|
||||
|
||||
if (!diskfree(CFG.freespace))
|
||||
die(MBERR_DISK_FULL);
|
||||
|
||||
if (!do_quiet) {
|
||||
printf("\r%4ld => %-44s \b\b\b\b", i, area.Name);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
sprintf(fAreas, "%s/fdb/fdb%ld.data", getenv("MBSE_ROOT"), i);
|
||||
|
||||
/*
|
||||
* Open the file database, if it doesn't exist,
|
||||
* abort, we even should have never got here.
|
||||
*/
|
||||
if ((pFile = fopen(fAreas, "r+")) == NULL) {
|
||||
WriteError("$Can't open %s", fAreas);
|
||||
die(MBERR_GENERAL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Create index.html pages in each available download area.
|
||||
*/
|
||||
if (!area.CDrom && fm && (strncmp(CFG.ftp_base, area.Path, strlen(CFG.ftp_base)) == 0)) {
|
||||
|
||||
fseek(pFile, 0, SEEK_SET);
|
||||
AreasHtml++;
|
||||
inArea = 0;
|
||||
while (fread(&file, sizeof(file), 1, pFile) == 1) {
|
||||
if ((!file.Deleted) && (!file.Missing))
|
||||
inArea++;
|
||||
}
|
||||
fseek(pFile, 0, SEEK_SET);
|
||||
|
||||
aSize = 0L;
|
||||
aTotal = 0;
|
||||
last = 0L;
|
||||
if ((fb = OpenMacro("html.areas", 'E', TRUE)) == NULL) {
|
||||
fa = NULL;
|
||||
} else {
|
||||
fa = newpage(area.Path, area.Name, later, inArea, aTotal, fb);
|
||||
fileptr1 = gfilepos;
|
||||
}
|
||||
|
||||
while (fread(&file, sizeof(file), 1, pFile) == 1) {
|
||||
if ((!file.Deleted) && (!file.Missing)) {
|
||||
/*
|
||||
* The next is to reduce system load
|
||||
*/
|
||||
x++;
|
||||
TotalHtml++;
|
||||
aTotal++;
|
||||
if (CFG.slow_util && do_quiet && ((x % 3) == 0))
|
||||
usleep(1);
|
||||
|
||||
MacroVars("efghijklm", "ddsssssds", 0, 0, "", "", "", "", "", 0, "");
|
||||
MacroVars("e", "d", aTotal);
|
||||
|
||||
/*
|
||||
* Check if this is a .gif or .jpg file, if so then
|
||||
* check if a thumbnail file exists. If not try to
|
||||
* create a thumbnail file to add to the html listing.
|
||||
*/
|
||||
if (strstr(file.LName, ".gif") || strstr(file.LName, ".jpg") ||
|
||||
strstr(file.LName, ".GIF") || strstr(file.LName, ".JPG")) {
|
||||
sprintf(linebuf, "%s/%s", area.Path, file.Name);
|
||||
sprintf(outbuf, "%s/.%s", area.Path, file.Name);
|
||||
if (file_exist(outbuf, R_OK)) {
|
||||
if ((j = execute(CFG.www_convert, linebuf, outbuf,
|
||||
(char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null"))) {
|
||||
Syslog('+', "Failed to create thumbnail for %s, rc=% d", file.Name, j);
|
||||
} else {
|
||||
chmod(outbuf, 0644);
|
||||
}
|
||||
}
|
||||
sprintf(outbuf, "%s/%s%s/%s", CFG.www_url, CFG.www_link2ftp,
|
||||
area.Path+strlen(CFG.ftp_base), file.Name);
|
||||
sprintf(linebuf, "%s/%s%s/.%s", CFG.www_url, CFG.www_link2ftp,
|
||||
area.Path+strlen(CFG.ftp_base), file.Name);
|
||||
MacroVars("fghi", "dsss", 1, outbuf, file.LName, linebuf);
|
||||
} else {
|
||||
sprintf(outbuf, "%s/%s%s/%s", CFG.www_url, CFG.www_link2ftp,
|
||||
area.Path+strlen(CFG.ftp_base), file.Name);
|
||||
MacroVars("fghi", "dsss", 0, outbuf, file.LName, "");
|
||||
}
|
||||
|
||||
sprintf(outbuf, "%lu Kb.", (long)(file.Size / 1024));
|
||||
MacroVars("jkl", "ssd", StrDateDMY(file.FileDate), outbuf, file.TimesDL+file.TimesFTP+file.TimesReq);
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
k = 0;
|
||||
for (j = 0; j < 25; j++)
|
||||
if (strlen(file.Desc[j])) {
|
||||
if (j) {
|
||||
sprintf(desc+k, "\n");
|
||||
k += 1;
|
||||
}
|
||||
sprintf(linebuf, "%s", To_Html(file.Desc[j]));
|
||||
html_massage(linebuf, outbuf);
|
||||
sprintf(desc+k, "%s", outbuf);
|
||||
k += strlen(outbuf);
|
||||
}
|
||||
MacroVars("m", "s", desc);
|
||||
fseek(fb, fileptr1, SEEK_SET);
|
||||
MacroRead(fb, fa);
|
||||
aSize += file.Size;
|
||||
MacroVars("efghijklm", "ddsssssds", 0, 0, "", "", "", "", "", 0, "");
|
||||
if (file.FileDate > last)
|
||||
last = file.FileDate;
|
||||
if ((aTotal % CFG.www_files_page) == 0) {
|
||||
closepage(fa, area.Path, inArea, aTotal, fb);
|
||||
fseek(fb, 0, SEEK_SET);
|
||||
fa = newpage(area.Path, area.Name, later, inArea, aTotal, fb);
|
||||
}
|
||||
} /* if (!file.deleted) */
|
||||
}
|
||||
if (aTotal == 0) {
|
||||
/*
|
||||
* Nothing written, skip skip fileblock
|
||||
*/
|
||||
while ((fgets(linebuf, 254, fb) != NULL) && ((linebuf[0]!='@') || (linebuf[1]!='|')));
|
||||
}
|
||||
|
||||
KSize += aSize / 1024;
|
||||
closepage(fa, area.Path, inArea, aTotal, fb);
|
||||
fclose(fb);
|
||||
|
||||
/*
|
||||
* If the time before there were more files in this area then now,
|
||||
* the number of html pages may de decreased. We try to delete these
|
||||
* files if they should exist.
|
||||
*/
|
||||
filenr = lastfile / CFG.www_files_page;
|
||||
while (TRUE) {
|
||||
filenr++;
|
||||
sprintf(linebuf, "%s/index%d.html", area.Path, filenr);
|
||||
if (unlink(linebuf))
|
||||
break;
|
||||
Syslog('+', "Removed obsolete %s", linebuf);
|
||||
}
|
||||
|
||||
sprintf(linebuf, "%s/%s%s/index.html", CFG.www_url, CFG.www_link2ftp, area.Path+strlen(CFG.ftp_base));
|
||||
if (aSize > 1048576)
|
||||
sprintf(outbuf, "%ld Mb.", aSize / 1048576);
|
||||
else
|
||||
sprintf(outbuf, "%ld Kb.", aSize / 1024);
|
||||
MacroVars("efghi", "dssds", AreaNr, linebuf, area.Name, aTotal, outbuf);
|
||||
if (last == 0L)
|
||||
MacroVars("j", "s", " ");
|
||||
else
|
||||
MacroVars("j", "s", StrDateDMY(last));
|
||||
fseek(fi, fileptr, SEEK_SET);
|
||||
MacroRead(fi, fm);
|
||||
}
|
||||
fclose(pFile);
|
||||
|
||||
} /* if area.Available */
|
||||
}
|
||||
|
||||
if (fm) {
|
||||
sprintf(linebuf, "%ld Mb.", KSize / 1024);
|
||||
MacroVars("cd", "ds", TotalHtml, linebuf);
|
||||
MacroRead(fi, fm);
|
||||
fclose(fi);
|
||||
MacroClear();
|
||||
fclose(fm);
|
||||
sprintf(linebuf, "%s/index.html", CFG.ftp_base);
|
||||
rename(fn, linebuf);
|
||||
chmod(linebuf, 0644);
|
||||
}
|
||||
|
||||
fclose(pAreas);
|
||||
|
||||
if (!do_quiet) {
|
||||
printf("\r \r");
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
free(sIndex);
|
||||
free(sAreas);
|
||||
free(fAreas);
|
||||
free(fn);
|
||||
free(temp);
|
||||
RemoveSema((char *)"reqindex");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Index(void)
|
||||
{
|
||||
ReqIndex();
|
||||
HtmlIndex(NULL);
|
||||
Syslog('+', "HTML Areas [%5d] Files [%5d]", AreasHtml, TotalHtml);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user