2001-08-17 05:46:24 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
2001-11-10 17:14:16 +00:00
|
|
|
* $Id$
|
2001-08-17 05:46:24 +00:00
|
|
|
* Purpose ...............: All the file functions.
|
|
|
|
*
|
|
|
|
*****************************************************************************
|
2004-02-21 17:22:00 +00:00
|
|
|
* Copyright (C) 1997-2004
|
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-05-06 21:33:13 +00:00
|
|
|
#include "../lib/mbsedb.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "filesub.h"
|
|
|
|
#include "file.h"
|
|
|
|
#include "funcs.h"
|
2001-11-10 17:14:16 +00:00
|
|
|
#include "input.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "language.h"
|
|
|
|
#include "misc.h"
|
|
|
|
#include "timeout.h"
|
|
|
|
#include "exitinfo.h"
|
2001-11-10 17:14:16 +00:00
|
|
|
#include "whoson.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "change.h"
|
2003-04-12 11:12:26 +00:00
|
|
|
#include "dispfile.h"
|
2004-10-27 11:08:09 +00:00
|
|
|
#include "term.h"
|
2004-11-03 20:48:45 +00:00
|
|
|
#include "ttyio.h"
|
|
|
|
#include "openport.h"
|
2004-11-05 21:14:04 +00:00
|
|
|
#include "transfer.h"
|
2004-11-03 20:48:45 +00:00
|
|
|
|
2001-08-17 05:46:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
extern long arecno; /* File area number in xxxScan() functions */
|
|
|
|
int Strlen = 0;
|
|
|
|
int FileRecno = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-11-12 21:42:17 +00:00
|
|
|
int CheckFile(char *, int);
|
|
|
|
int CheckFile(char *File, int iArea)
|
|
|
|
{
|
2004-05-06 21:33:13 +00:00
|
|
|
struct _fdbarea *fdb_area = NULL;
|
|
|
|
|
|
|
|
if ((fdb_area = mbsedb_OpenFDB(iArea, 30)) == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check long and short filenames, case insensitive
|
|
|
|
*/
|
|
|
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
|
|
|
if (((strcasecmp(fdb.Name, File)) == 0) || ((strcasecmp(fdb.LName, File)) == 0)) {
|
|
|
|
mbsedb_CloseFDB(fdb_area);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mbsedb_CloseFDB(fdb_area);
|
2004-03-06 21:48:41 +00:00
|
|
|
return FALSE;
|
2001-11-12 21:42:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-08-17 05:46:24 +00:00
|
|
|
/*
|
|
|
|
* Show filelist from current area, called from the menu.
|
|
|
|
*/
|
|
|
|
void File_List()
|
|
|
|
{
|
2004-11-03 20:48:45 +00:00
|
|
|
int FileCount = 0;
|
|
|
|
unsigned FileBytes = 0;
|
|
|
|
_Tag T;
|
2004-05-06 21:33:13 +00:00
|
|
|
struct _fdbarea *fdb_area = NULL;
|
2004-11-03 20:48:45 +00:00
|
|
|
char temp[81];
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
iLineCount = 0;
|
|
|
|
WhosDoingWhat(FILELIST, NULL);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
Syslog('+', "Listing File Area # %d", iAreaNumber);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
if (Access(exitinfo.Security, area.LTSec) == FALSE) {
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2004-03-06 21:48:41 +00:00
|
|
|
/* You don't have enough security to list this area */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(YELLOW, BLACK, (char *) Language(236));
|
|
|
|
Enter(2);
|
2004-03-06 21:48:41 +00:00
|
|
|
Pause();
|
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
InitTag();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-05-06 21:33:13 +00:00
|
|
|
if ((fdb_area = mbsedb_OpenFDB(iAreaNumber, 30)) == NULL)
|
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
clear();
|
|
|
|
Header();
|
|
|
|
if (iLC(2) == 1) {
|
2004-05-06 21:33:13 +00:00
|
|
|
mbsedb_CloseFDB(fdb_area);
|
2004-03-06 21:48:41 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-05-06 21:33:13 +00:00
|
|
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
2004-03-06 21:48:41 +00:00
|
|
|
memset(&T, 0, sizeof(T));
|
|
|
|
T.Area = iAreaNumber;
|
|
|
|
T.Active = FALSE;
|
|
|
|
T.Size = fdb.Size;
|
|
|
|
strncpy(T.SFile, fdb.Name, 12);
|
|
|
|
strncpy(T.LFile, fdb.LName, 80);
|
|
|
|
SetTag(T);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
if (ShowOneFile() == 1) {
|
2004-05-06 21:33:13 +00:00
|
|
|
mbsedb_CloseFDB(fdb_area);
|
2004-03-06 21:48:41 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (fdb.Deleted) {
|
2004-03-06 21:48:41 +00:00
|
|
|
/* D E L E T E D */ /* Uploaded by: */
|
2004-11-03 20:48:45 +00:00
|
|
|
sprintf(temp, " -- %-12s %s [%4ld] %s%s\n", fdb.Name, (char *) Language(239),
|
2004-03-06 21:48:41 +00:00
|
|
|
fdb.TimesDL, (char *) Language(238), fdb.Uploader);
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTSTR(temp);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
FileCount++; /* Increase File Counter by 1 */
|
|
|
|
FileBytes += fdb.Size; /* Increase File Byte Count */
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
Mark();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2004-03-06 21:48:41 +00:00
|
|
|
/* Total Files: */
|
2004-11-03 20:48:45 +00:00
|
|
|
sprintf(temp, "%s%d / %d bytes", (char *) Language(242), FileCount, FileBytes);
|
|
|
|
pout(LIGHTCYAN, BLACK, temp);
|
|
|
|
Enter(2);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
iLineCount = 0;
|
2004-05-06 21:33:13 +00:00
|
|
|
mbsedb_CloseFDB(fdb_area);
|
2004-03-06 21:48:41 +00:00
|
|
|
Pause();
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Download files already tagged, called from the menu.
|
|
|
|
*/
|
|
|
|
void Download(void)
|
|
|
|
{
|
2004-05-06 21:33:13 +00:00
|
|
|
FILE *tf, *fd;
|
2004-11-06 16:27:46 +00:00
|
|
|
int rc = 0, i, Count = 0, OldArea;
|
|
|
|
char *local, *temp;
|
|
|
|
long Size = 0, CostSize = 0, dsize;
|
2004-05-06 21:33:13 +00:00
|
|
|
struct _fdbarea *fdb_area = NULL;
|
2004-11-06 16:27:46 +00:00
|
|
|
down_list *dl = NULL, *tmpf;
|
2002-04-22 19:56:01 +00:00
|
|
|
|
|
|
|
Enter(2);
|
|
|
|
OldArea = iAreaNumber;
|
2003-10-11 21:22:16 +00:00
|
|
|
WhosDoingWhat(DOWNLOAD, NULL);
|
2004-11-06 16:27:46 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Clean users tag directory.
|
|
|
|
*/
|
2004-05-08 14:55:40 +00:00
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
|
|
|
sprintf(temp, "-rf %s/%s/tag", CFG.bbs_usersdir, exitinfo.Name);
|
|
|
|
execute_pth((char *)"rm", temp, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
|
|
|
|
sprintf(temp, "%s/%s/tag", CFG.bbs_usersdir, exitinfo.Name);
|
|
|
|
CheckDir(temp);
|
2002-04-22 19:56:01 +00:00
|
|
|
|
|
|
|
if ((tf = fopen("taglist", "r+")) == NULL) {
|
|
|
|
Syslog('+', "Download command but no files marked");
|
|
|
|
/* No files marked for download. */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(LIGHTRED, BLACK, (char *) Language(258));
|
2001-08-17 05:46:24 +00:00
|
|
|
Enter(2);
|
2002-04-22 19:56:01 +00:00
|
|
|
Pause();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-11-06 16:27:46 +00:00
|
|
|
local = calloc(PATH_MAX, sizeof(char));
|
2002-04-22 19:56:01 +00:00
|
|
|
/* Checking your marked downloads, please wait... */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(LIGHTMAGENTA, BLACK, (char *) Language(255));
|
|
|
|
Enter(2);
|
2002-04-22 19:56:01 +00:00
|
|
|
|
|
|
|
ReadExitinfo();
|
|
|
|
while (fread(&Tag, sizeof(Tag), 1, tf) == 1) {
|
|
|
|
if (Tag.Active) {
|
|
|
|
|
|
|
|
SetFileArea(Tag.Area);
|
|
|
|
|
|
|
|
/*
|
2004-03-06 21:48:41 +00:00
|
|
|
* Check password for selected file FIXME: Where???
|
2002-04-22 19:56:01 +00:00
|
|
|
*/
|
2004-03-06 21:48:41 +00:00
|
|
|
memset(&fdb, 0, sizeof(fdb));
|
2004-05-06 21:33:13 +00:00
|
|
|
if ((fdb_area = mbsedb_OpenFDB(Tag.Area, 30)) != NULL) {
|
|
|
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
|
|
|
if (strcmp(fdb.LName, Tag.LFile) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
mbsedb_CloseFDB(fdb_area);
|
|
|
|
}
|
2002-04-22 19:56:01 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
if (strcmp(fdb.LName, Tag.LFile) == 0) {
|
|
|
|
Syslog('b', "Found file %s in area %d", fdb.LName, Tag.Area);
|
|
|
|
if (fdb.Deleted) {
|
2002-04-22 19:56:01 +00:00
|
|
|
/* Sorry that file is unavailable for download */
|
2004-11-03 20:48:45 +00:00
|
|
|
sprintf(temp, "%s (%s)", (char *) Language(248), fdb.LName);
|
|
|
|
poutCR(CFG.HiliteF, CFG.HiliteB, temp);
|
2002-04-22 19:56:01 +00:00
|
|
|
Tag.Active = FALSE;
|
2004-03-06 21:48:41 +00:00
|
|
|
Syslog('+', "File %s in area %d unavailable for download, deleted", fdb.LName, Tag.Area);
|
2002-04-22 19:56:01 +00:00
|
|
|
}
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-04-22 19:56:01 +00:00
|
|
|
if (Tag.Active) {
|
|
|
|
/*
|
|
|
|
* Create/Append file description list while we're
|
|
|
|
* busy checking. If the users doesn't want it we
|
|
|
|
* can unlink it aftwerwards. We also insert CR
|
|
|
|
* characters to please the poor DOS (M$oft) users.
|
|
|
|
*/
|
2004-11-06 16:27:46 +00:00
|
|
|
sprintf(local, "./tag/filedesc.%ld", exitinfo.Downloads % 256);
|
|
|
|
if ((fd = fopen(local, "a")) != NULL) {
|
2004-03-06 21:48:41 +00:00
|
|
|
fprintf(fd, "%s (%s)\r\n", fdb.LName, fdb.Name);
|
2002-04-22 19:56:01 +00:00
|
|
|
for (i = 0; i < 25; i++) {
|
2004-03-06 21:48:41 +00:00
|
|
|
if (strlen(fdb.Desc[i]) > 1)
|
|
|
|
fprintf(fd, " %s\r\n", fdb.Desc[i]);
|
2002-04-22 19:56:01 +00:00
|
|
|
}
|
|
|
|
fprintf(fd, "\r\n");
|
|
|
|
fclose(fd);
|
2004-11-06 16:27:46 +00:00
|
|
|
Syslog('b', "Added info to %s", local);
|
2002-04-22 19:56:01 +00:00
|
|
|
} else {
|
2004-11-06 16:27:46 +00:00
|
|
|
WriteError("Can't add info to %s", local);
|
2002-04-22 19:56:01 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-06 16:27:46 +00:00
|
|
|
sprintf(local, "%s/%s", sAreaPath, Tag.LFile);
|
|
|
|
add_download(&dl, local, Tag.LFile, Tag.Area, fdb.Size, FALSE);
|
|
|
|
|
2002-04-22 19:56:01 +00:00
|
|
|
Home();
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-04-22 19:56:01 +00:00
|
|
|
if (!Tag.Active) {
|
|
|
|
/*
|
|
|
|
* Update the download active flag in the
|
|
|
|
* taglist
|
|
|
|
*/
|
|
|
|
fseek(tf, - sizeof(Tag), SEEK_CUR);
|
|
|
|
fwrite(&Tag, sizeof(Tag), 1, tf);
|
|
|
|
Syslog('b', "Download file %s marked inactive in taglist", Tag.LFile);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Count file and sizes.
|
|
|
|
*/
|
|
|
|
Count++;
|
2004-03-06 21:48:41 +00:00
|
|
|
Size += fdb.Size;
|
|
|
|
if (!area.Free)
|
|
|
|
CostSize += fdb.Size;
|
2002-04-22 19:56:01 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-04-22 19:56:01 +00:00
|
|
|
}
|
2003-12-16 21:50:32 +00:00
|
|
|
fclose(tf);
|
|
|
|
|
2002-04-22 19:56:01 +00:00
|
|
|
/*
|
|
|
|
* If anything left to download...
|
|
|
|
*/
|
|
|
|
if (!Count) {
|
|
|
|
SetFileArea(OldArea);
|
|
|
|
unlink("taglist");
|
|
|
|
/* No files marked for download */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(LIGHTRED, BLACK, (char *) Language(258));
|
2002-04-22 19:56:01 +00:00
|
|
|
Enter(2);
|
2001-08-17 05:46:24 +00:00
|
|
|
Pause();
|
2004-11-03 20:48:45 +00:00
|
|
|
free(temp);
|
2004-11-06 16:27:46 +00:00
|
|
|
free(local);
|
|
|
|
tidy_download(&dl);
|
2002-04-22 19:56:01 +00:00
|
|
|
Syslog('+', "No files left to download");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-11-06 16:27:46 +00:00
|
|
|
/*
|
|
|
|
* Add descriptions file to the queue.
|
|
|
|
*/
|
|
|
|
sprintf(local, "%s/%s/tag/filedesc.%ld", CFG.bbs_usersdir, exitinfo.Name, exitinfo.Downloads % 256);
|
|
|
|
dsize = file_size(local);
|
|
|
|
sprintf(temp, "filedesc.%ld", exitinfo.Downloads % 256);
|
|
|
|
add_download(&dl, local, temp, 0, dsize, TRUE);
|
|
|
|
free(local);
|
|
|
|
|
2002-04-22 19:56:01 +00:00
|
|
|
/* You have */ /* files( */ /* bytes) marked for download */
|
2004-11-03 20:48:45 +00:00
|
|
|
sprintf(temp, "%s %d %s%ld %s", (char *) Language(249), Count, (char *) Language(280), Size, (char *) Language(281));
|
|
|
|
pout(YELLOW, BLACK, temp);
|
|
|
|
Enter(2);
|
2002-04-22 19:56:01 +00:00
|
|
|
|
|
|
|
if (!CheckBytesAvailable(CostSize)) {
|
|
|
|
SetFileArea(OldArea);
|
2004-11-03 20:48:45 +00:00
|
|
|
free(temp);
|
2004-11-06 16:27:46 +00:00
|
|
|
tidy_download(&dl);
|
2002-04-22 19:56:01 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Pause();
|
|
|
|
|
2004-11-06 16:27:46 +00:00
|
|
|
if ((rc = download(dl))) {
|
|
|
|
/*
|
|
|
|
* Download error
|
|
|
|
*/
|
2004-11-08 14:36:34 +00:00
|
|
|
Syslog('+', "Download error rc=%d", rc);
|
2002-04-22 19:56:01 +00:00
|
|
|
free(temp);
|
2004-11-06 16:27:46 +00:00
|
|
|
tidy_download(&dl);
|
|
|
|
return;
|
2002-04-22 19:56:01 +00:00
|
|
|
}
|
2004-11-06 16:27:46 +00:00
|
|
|
|
2002-04-22 19:56:01 +00:00
|
|
|
/*
|
|
|
|
* Checking the successfull sent files, they are missing from
|
|
|
|
* the ./tag directory. Failed files are still there.
|
|
|
|
*/
|
2004-11-06 16:27:46 +00:00
|
|
|
Enter(1);
|
2002-04-22 19:56:01 +00:00
|
|
|
/* Updating download counters, please wait ... */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(LIGHTCYAN, BLACK, (char *) Language(352));
|
2002-04-22 19:56:01 +00:00
|
|
|
Count = Size = 0;
|
|
|
|
|
2004-11-06 16:27:46 +00:00
|
|
|
/*
|
|
|
|
* Update downloadcounters, don't log anything because the state
|
|
|
|
* of sucessfull sent files is already logged by the download
|
|
|
|
* function.
|
|
|
|
*/
|
2002-04-22 19:56:01 +00:00
|
|
|
if ((tf = fopen("taglist", "r+")) != NULL) {
|
|
|
|
while (fread(&Tag, sizeof(Tag), 1, tf) == 1) {
|
2004-11-06 16:27:46 +00:00
|
|
|
PUTCHAR('.');
|
2002-04-22 19:56:01 +00:00
|
|
|
if (Tag.Active) {
|
2004-11-06 16:27:46 +00:00
|
|
|
for (tmpf = dl; tmpf; tmpf = tmpf->next) {
|
2004-11-08 14:36:34 +00:00
|
|
|
if (strcmp(tmpf->remote, Tag.LFile) == 0) {
|
2004-11-06 16:27:46 +00:00
|
|
|
if (tmpf->sent) {
|
|
|
|
|
|
|
|
Tag.Active = FALSE;
|
|
|
|
fseek(tf, - sizeof(Tag), SEEK_CUR);
|
|
|
|
fwrite(&Tag, sizeof(Tag), 1, tf);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Update the download counter and the last download date.
|
|
|
|
*/
|
|
|
|
SetFileArea(Tag.Area);
|
|
|
|
if ((fdb_area = mbsedb_OpenFDB(Tag.Area, 30))) {
|
|
|
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
|
|
|
if (strcmp(fdb.LName, Tag.LFile) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Size += fdb.Size;
|
|
|
|
fdb.TimesDL++;
|
|
|
|
fdb.LastDL = time(NULL);
|
|
|
|
if (mbsedb_LockFDB(fdb_area, 30)) {
|
|
|
|
fseek(fdb_area->fp, - fdbhdr.recsize, SEEK_CUR);
|
|
|
|
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
|
|
|
|
mbsedb_UnlockFDB(fdb_area);
|
|
|
|
}
|
|
|
|
mbsedb_CloseFDB(fdb_area);
|
|
|
|
Count++;
|
|
|
|
}
|
2004-05-06 21:33:13 +00:00
|
|
|
}
|
2004-11-06 16:27:46 +00:00
|
|
|
break;
|
2002-04-22 19:56:01 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-04-22 19:56:01 +00:00
|
|
|
}
|
2001-09-30 18:58:17 +00:00
|
|
|
}
|
2003-12-16 21:50:32 +00:00
|
|
|
fclose(tf);
|
2002-04-22 19:56:01 +00:00
|
|
|
}
|
2004-11-06 16:27:46 +00:00
|
|
|
Enter(2);
|
2002-04-22 19:56:01 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Update the users record.
|
|
|
|
*/
|
|
|
|
ReadExitinfo();
|
|
|
|
|
|
|
|
exitinfo.Downloads += Count; /* Increase download counter */
|
|
|
|
exitinfo.DownloadK += (Size / 1024); /* Increase amount download today */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Minus the amount downloaded today from downloadktoday
|
|
|
|
* if less than zero, it won't let the user download anymore.
|
|
|
|
*/
|
|
|
|
if (LIMIT.DownK || LIMIT.DownF) {
|
|
|
|
exitinfo.DownloadKToday -= (Size / 1024);
|
|
|
|
}
|
|
|
|
|
|
|
|
WriteExitinfo();
|
|
|
|
Pause();
|
|
|
|
SetFileArea(OldArea);
|
2004-11-06 16:27:46 +00:00
|
|
|
free(temp);
|
|
|
|
tidy_download(&dl);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Show Raw directory
|
|
|
|
*/
|
|
|
|
void File_RawDir(char *OpData)
|
|
|
|
{
|
2004-11-03 20:48:45 +00:00
|
|
|
DIR *dirp;
|
|
|
|
char *FileName, *temp, temp2[81];
|
|
|
|
int iFileCount = 0, LineCount = 2, iBytes = 0;
|
|
|
|
struct dirent *dp;
|
|
|
|
struct stat statfile;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
FileName = calloc(PATH_MAX, sizeof(char));
|
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
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 {
|
|
|
|
clear();
|
|
|
|
/* Filename Size Date */
|
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(261));
|
|
|
|
Enter(1);
|
|
|
|
fLine(78);
|
|
|
|
|
|
|
|
while ((dp = readdir( dirp )) != NULL ) {
|
|
|
|
sprintf(FileName, "%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;
|
|
|
|
|
|
|
|
sprintf(temp2, "%-54s " , dp->d_name);
|
|
|
|
pout(YELLOW, BLACK, temp2);
|
|
|
|
|
|
|
|
sprintf(temp2, "%-12ld", (long)(statfile.st_size));
|
|
|
|
pout(LIGHTMAGENTA, BLACK, temp2);
|
|
|
|
|
|
|
|
sprintf(temp2, "%-10s", StrDateDMY(statfile.st_mtime));
|
|
|
|
pout(LIGHTGREEN, BLACK, temp2);
|
|
|
|
}
|
|
|
|
Enter(1);
|
|
|
|
|
|
|
|
LineCount++;
|
|
|
|
if (LineCount == exitinfo.iScreenLen) {
|
|
|
|
Pause();
|
|
|
|
LineCount = 0;
|
|
|
|
}
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
|
|
|
|
colour(CFG.HiliteF, CFG.HiliteB);
|
|
|
|
fLine(78);
|
|
|
|
/* Total Files: */ /* Bytes */
|
|
|
|
sprintf(temp2, "%s %d, %d %s", (char *) Language(242), iFileCount, iBytes, (char *) Language(354));
|
|
|
|
pout(LIGHTGREEN, BLACK, temp2);
|
|
|
|
Enter(2);
|
|
|
|
|
|
|
|
Pause();
|
|
|
|
closedir(dirp);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(temp);
|
|
|
|
free(FileName);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Search for keyword, called from menu.
|
|
|
|
*/
|
|
|
|
int KeywordScan()
|
|
|
|
{
|
2004-05-06 21:33:13 +00:00
|
|
|
FILE *pAreas;
|
2004-03-06 21:48:41 +00:00
|
|
|
int i, z, y, Found, Count = 0;
|
|
|
|
char *Name, *tmpname, *BigDesc, temp[81];
|
|
|
|
_Tag T;
|
|
|
|
unsigned long OldArea;
|
2004-05-06 21:33:13 +00:00
|
|
|
struct _fdbarea *fdb_area = NULL;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
Name = calloc(81, sizeof(char));
|
|
|
|
tmpname = calloc(81, sizeof(char));
|
|
|
|
BigDesc = calloc(1230, sizeof(char));
|
|
|
|
OldArea = iAreaNumber;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
iLineCount = 2; /* Reset Line Counter to Zero */
|
|
|
|
arecno = 1; /* Reset Area Number to One */
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
Enter(2);
|
|
|
|
/* Enter keyword to use for Search: */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(LIGHTCYAN, BLACK, (char *) Language(267));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
colour(CFG.InputColourF, CFG.InputColourB);
|
|
|
|
GetstrC(Name, 80);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
if ((strcmp(Name, "")) == 0)
|
|
|
|
return 0;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
strcpy(tmpname, tl(Name));
|
|
|
|
strcpy(Name, "");
|
|
|
|
y = strlen(tmpname);
|
|
|
|
for (z = 0; z < y; z++) {
|
|
|
|
if (tmpname[z] != '*') {
|
|
|
|
sprintf(temp, "%c", tmpname[z]);
|
|
|
|
strcat(Name, temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-03-06 21:48:41 +00:00
|
|
|
}
|
|
|
|
Syslog('+', "KeywordScan(): \"%s\"", Name);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
clear();
|
|
|
|
/* File search by keyword */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(WHITE, BLACK, (char *) Language(268));
|
2004-03-06 21:48:41 +00:00
|
|
|
Enter(1);
|
|
|
|
InitTag();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
if ((pAreas = OpenFareas(FALSE)) == NULL)
|
|
|
|
return 0;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
while (fread(&area, areahdr.recsize, 1, pAreas) == 1) {
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0)) {
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-05-06 21:33:13 +00:00
|
|
|
if ((fdb_area = mbsedb_OpenFDB(arecno, 30))) {
|
2004-03-06 21:48:41 +00:00
|
|
|
Nopper();
|
|
|
|
Found = FALSE;
|
|
|
|
Sheader();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-05-06 21:33:13 +00:00
|
|
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
2004-03-06 21:48:41 +00:00
|
|
|
for (i = 0; i < 25; i++)
|
|
|
|
sprintf(BigDesc, "%s%s", BigDesc, *(fdb.Desc + i));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
if ((strstr(fdb.Name,Name) != NULL) || (strstr(tl(BigDesc), Name) != NULL)) {
|
|
|
|
|
|
|
|
if (!Found) {
|
|
|
|
Enter(2);
|
|
|
|
if (iLC(2) == 1) {
|
|
|
|
free(BigDesc);
|
|
|
|
free(Name);
|
|
|
|
free(tmpname);
|
|
|
|
SetFileArea(OldArea);
|
|
|
|
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(BigDesc);
|
|
|
|
free(Name);
|
|
|
|
free(tmpname);
|
|
|
|
SetFileArea(OldArea);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
strcpy(BigDesc, ""); /* Clear BigDesc */
|
|
|
|
|
|
|
|
} /* while */
|
|
|
|
|
2004-05-06 21:33:13 +00:00
|
|
|
mbsedb_CloseFDB(fdb_area);
|
2004-03-06 21:48:41 +00:00
|
|
|
if (Found) {
|
|
|
|
Enter(2);
|
|
|
|
if (iLC(2) == 1) {
|
|
|
|
free(BigDesc);
|
|
|
|
free(Name);
|
|
|
|
free(tmpname);
|
|
|
|
SetFileArea(OldArea);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} /* End check for LTSec */
|
|
|
|
} /* if access */
|
|
|
|
arecno++; /* Go to next file area */
|
|
|
|
} /* End of Main */
|
|
|
|
|
|
|
|
Syslog('+', "Found %d files", Count);
|
|
|
|
free(BigDesc);
|
|
|
|
free(Name);
|
|
|
|
free(tmpname);
|
|
|
|
fclose(pAreas);
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2004-03-06 21:48:41 +00:00
|
|
|
if (Count)
|
|
|
|
Mark();
|
|
|
|
else
|
|
|
|
Pause();
|
|
|
|
SetFileArea(OldArea);
|
|
|
|
return 1;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Search for a file, called from the menu.
|
|
|
|
*/
|
|
|
|
int FilenameScan()
|
|
|
|
{
|
2004-05-06 21:33:13 +00:00
|
|
|
FILE *pAreas;
|
2002-11-23 16:48:54 +00:00
|
|
|
int Found, Count = 0;
|
2004-03-08 20:51:04 +00:00
|
|
|
char mask[256];
|
2002-11-23 16:48:54 +00:00
|
|
|
char *Name;
|
|
|
|
_Tag T;
|
|
|
|
unsigned long OldArea;
|
2004-05-06 21:33:13 +00:00
|
|
|
struct _fdbarea *fdb_area = NULL;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-23 16:48:54 +00:00
|
|
|
Name = calloc(81, sizeof(char));
|
|
|
|
OldArea = iAreaNumber;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-23 16:48:54 +00:00
|
|
|
iLineCount = 2; /* Reset Line Counter to Zero */
|
|
|
|
arecno = 1; /* Reset Area Number to One */
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-23 16:48:54 +00:00
|
|
|
Enter(2);
|
|
|
|
/* Accepts wildcards such as : *.zip, *.gz, *.* */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(WHITE, BLACK, (char *) Language(269));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-23 16:48:54 +00:00
|
|
|
Enter(2);
|
|
|
|
/* Enter filename to search for : */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(LIGHTCYAN, BLACK, (char *) Language(271));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-23 16:48:54 +00:00
|
|
|
colour(CFG.InputColourF, CFG.InputColourB);
|
|
|
|
GetstrC(Name, 80);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-23 16:48:54 +00:00
|
|
|
if ((strcmp(Name, "")) == 0) {
|
|
|
|
free(Name);
|
|
|
|
return 0;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-03-08 20:51:04 +00:00
|
|
|
strcpy(mask, re_mask(Name, TRUE));
|
2002-11-23 16:48:54 +00:00
|
|
|
Syslog('+', "FilenameScan(): \"%s\" -> \"%s\"", Name, mask);
|
|
|
|
free(Name);
|
|
|
|
re_comp(mask);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-23 16:48:54 +00:00
|
|
|
clear();
|
|
|
|
/* File Search by Filename */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(WHITE, BLACK, (char *) Language(272));
|
2002-11-23 16:48:54 +00:00
|
|
|
Enter(1);
|
|
|
|
InitTag();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-23 16:48:54 +00:00
|
|
|
if ((pAreas = OpenFareas(FALSE)) == NULL)
|
|
|
|
return 0;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-23 16:48:54 +00:00
|
|
|
while (fread(&area, areahdr.recsize, 1, pAreas) == 1) {
|
|
|
|
if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0)) {
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-05-06 21:33:13 +00:00
|
|
|
if ((fdb_area = mbsedb_OpenFDB(arecno, 30))) {
|
2002-11-23 16:48:54 +00:00
|
|
|
Found = FALSE;
|
|
|
|
Sheader();
|
|
|
|
Nopper();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-05-06 21:33:13 +00:00
|
|
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
2004-03-06 21:48:41 +00:00
|
|
|
if (re_exec(fdb.Name) || re_exec(fdb.LName)) {
|
2002-11-23 16:48:54 +00:00
|
|
|
if (!Found) {
|
|
|
|
Enter(2);
|
|
|
|
if (iLC(2) == 1) {
|
|
|
|
SetFileArea(OldArea);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
Found = TRUE;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-23 16:48:54 +00:00
|
|
|
memset(&T, 0, sizeof(T));
|
|
|
|
T.Area = arecno;
|
|
|
|
T.Active = FALSE;
|
2004-03-06 21:48:41 +00:00
|
|
|
T.Size = fdb.Size;
|
|
|
|
strncpy(T.SFile, fdb.Name, 12);
|
|
|
|
strncpy(T.LFile, fdb.LName, 81);
|
2002-11-23 16:48:54 +00:00
|
|
|
SetTag(T);
|
|
|
|
Count++;
|
|
|
|
if (ShowOneFile() == 1) {
|
|
|
|
SetFileArea(OldArea);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-23 16:48:54 +00:00
|
|
|
} /* End of while */
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-05-06 21:33:13 +00:00
|
|
|
mbsedb_CloseFDB(fdb_area);
|
2002-11-23 16:48:54 +00:00
|
|
|
if (Found) {
|
|
|
|
Enter(2);
|
|
|
|
if (iLC(2) == 1) {
|
|
|
|
SetFileArea(OldArea);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-23 16:48:54 +00:00
|
|
|
} /* End Check for LTSec */
|
|
|
|
} /* if access */
|
|
|
|
arecno++; /* Go to next file area */
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-23 16:48:54 +00:00
|
|
|
} /* End of Main */
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-23 16:48:54 +00:00
|
|
|
Syslog('+', "Found %d files", Count);
|
|
|
|
fclose(pAreas);
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2002-11-23 16:48:54 +00:00
|
|
|
if (Count)
|
|
|
|
Mark();
|
|
|
|
else
|
|
|
|
Pause();
|
|
|
|
SetFileArea(OldArea);
|
|
|
|
return 1;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Scan for new files, called from menu.
|
|
|
|
*/
|
|
|
|
int NewfileScan(int AskStart)
|
|
|
|
{
|
2004-05-06 21:33:13 +00:00
|
|
|
FILE *pAreas;
|
2003-12-16 21:50:32 +00:00
|
|
|
long ifDate, itDate;
|
|
|
|
char *temp, *Date;
|
|
|
|
int Found, Count = 0;
|
|
|
|
_Tag T;
|
2004-05-06 21:33:13 +00:00
|
|
|
struct _fdbarea *fdb_area = NULL;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-16 21:50:32 +00:00
|
|
|
Date = calloc(81, sizeof(char));
|
|
|
|
temp = calloc(81, sizeof(char));
|
|
|
|
|
|
|
|
iLineCount = 2;
|
|
|
|
arecno = 1; /* Reset Area Number to One */
|
|
|
|
|
|
|
|
if (AskStart) {
|
2001-08-17 05:46:24 +00:00
|
|
|
Enter(2);
|
2003-12-16 21:50:32 +00:00
|
|
|
/* Search for new since your last call [Y/n]: */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(LIGHTCYAN, BLACK, (char *) Language(273));
|
2003-12-16 21:50:32 +00:00
|
|
|
colour(CFG.InputColourF, CFG.InputColourB);
|
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (toupper(Readkey()) == Keystroke(273, 1)) {
|
2003-12-16 21:50:32 +00:00
|
|
|
Enter(1);
|
|
|
|
/* Enter new date to search for [DD-MM-YYYY]: */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(GREEN, BLACK, (char *) Language(274));
|
2003-12-16 21:50:32 +00:00
|
|
|
colour(CFG.InputColourF, CFG.InputColourB);
|
|
|
|
GetDate(temp, 10);
|
2004-11-03 20:48:45 +00:00
|
|
|
} else {
|
2003-12-16 21:50:32 +00:00
|
|
|
strcpy(temp, LastLoginDate);
|
2004-11-03 20:48:45 +00:00
|
|
|
}
|
|
|
|
} else {
|
2003-12-16 21:50:32 +00:00
|
|
|
strcpy(temp, LastLoginDate);
|
2004-11-03 20:48:45 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-16 21:50:32 +00:00
|
|
|
Syslog('+', "NewfileScan() since %s", temp);
|
|
|
|
clear();
|
|
|
|
/* File Search by Date */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(WHITE, BLACK, (char *) Language(275));
|
2003-12-16 21:50:32 +00:00
|
|
|
Enter(2);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-16 21:50:32 +00:00
|
|
|
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);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-16 21:50:32 +00:00
|
|
|
InitTag();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-16 21:50:32 +00:00
|
|
|
if ((pAreas = OpenFareas(FALSE)) == NULL)
|
|
|
|
return 0;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-16 21:50:32 +00:00
|
|
|
while (fread(&area, areahdr.recsize, 1, pAreas) == 1) {
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-16 21:50:32 +00:00
|
|
|
if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0) && (area.New)) {
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-05-06 21:33:13 +00:00
|
|
|
if ((fdb_area = mbsedb_OpenFDB(arecno, 30))) {
|
2003-12-16 21:50:32 +00:00
|
|
|
Sheader();
|
|
|
|
Found = FALSE;
|
|
|
|
Nopper();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-05-06 21:33:13 +00:00
|
|
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
2004-03-06 21:48:41 +00:00
|
|
|
strcpy(temp, StrDateDMY(fdb.UploadDate)); /* Realloc Space for Date */
|
2003-12-16 21:50:32 +00:00
|
|
|
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) {
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(2);
|
2003-12-16 21:50:32 +00:00
|
|
|
if (iLC(2) == 1) {
|
|
|
|
free(Date);
|
|
|
|
free(temp);
|
2004-05-06 21:33:13 +00:00
|
|
|
mbsedb_CloseFDB(fdb_area);
|
2003-12-16 21:50:32 +00:00
|
|
|
fclose(pAreas);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
Found = TRUE;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-16 21:50:32 +00:00
|
|
|
memset(&T, 0, sizeof(T));
|
|
|
|
T.Area = arecno;
|
|
|
|
T.Active = FALSE;
|
2004-03-06 21:48:41 +00:00
|
|
|
T.Size = fdb.Size;
|
|
|
|
strncpy(T.SFile, fdb.Name, 12);
|
|
|
|
strncpy(T.LFile, fdb.LName, 80);
|
2003-12-16 21:50:32 +00:00
|
|
|
SetTag(T);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-16 21:50:32 +00:00
|
|
|
Count++;
|
|
|
|
if (ShowOneFile() == 1) {
|
|
|
|
free(Date);
|
|
|
|
free(temp);
|
2004-05-06 21:33:13 +00:00
|
|
|
mbsedb_CloseFDB(fdb_area);
|
2003-12-16 21:50:32 +00:00
|
|
|
fclose(pAreas);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
} /* End of if */
|
|
|
|
} /* End of while */
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-05-06 21:33:13 +00:00
|
|
|
mbsedb_CloseFDB(fdb_area);
|
|
|
|
|
2003-12-16 21:50:32 +00:00
|
|
|
/*
|
|
|
|
* Add 2 blank lines after found files.
|
|
|
|
*/
|
|
|
|
if (Found) {
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(2);
|
2003-12-16 21:50:32 +00:00
|
|
|
if (iLC(2) == 1) {
|
|
|
|
free(Date);
|
|
|
|
free(temp);
|
|
|
|
fclose(pAreas);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-16 21:50:32 +00:00
|
|
|
} /* End of open filebase */
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-16 21:50:32 +00:00
|
|
|
} /* End of check new files scan */
|
|
|
|
arecno++; /* Go to next file area */
|
|
|
|
} /* End of Main */
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-16 21:50:32 +00:00
|
|
|
if (Count)
|
|
|
|
Syslog('+', "Found %d new files", Count);
|
|
|
|
fclose(pAreas);
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2003-12-16 21:50:32 +00:00
|
|
|
if (Count)
|
|
|
|
Mark();
|
|
|
|
else
|
|
|
|
Pause();
|
|
|
|
|
|
|
|
free(temp);
|
|
|
|
free(Date);
|
|
|
|
return 1;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Upload a file.
|
|
|
|
*/
|
|
|
|
int Upload()
|
|
|
|
{
|
2004-11-06 22:01:51 +00:00
|
|
|
int Area, rc;
|
2004-11-03 20:48:45 +00:00
|
|
|
unsigned long OldArea;
|
2004-11-06 22:01:51 +00:00
|
|
|
char *arc, *temp;
|
|
|
|
up_list *up = NULL, *tmpf;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
WhosDoingWhat(UPLOAD, NULL);
|
|
|
|
Enter(1);
|
|
|
|
Area = OldArea = iAreaNumber;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* If there is a special upload area for the current area
|
|
|
|
* then select it.
|
|
|
|
*/
|
|
|
|
if (area.Upload)
|
|
|
|
Area = area.Upload;
|
|
|
|
SetFileArea(Area);
|
|
|
|
Syslog('+', "Upload area is %d %s", Area, area.Name);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* Check upload access for the real upload directory.
|
|
|
|
*/
|
|
|
|
if (!Access(exitinfo.Security, area.UPSec)) {
|
|
|
|
Enter(1);
|
|
|
|
/* You do not have enough access to upload to this area */
|
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(278));
|
|
|
|
Enter(2);
|
2001-08-17 05:46:24 +00:00
|
|
|
SetFileArea(OldArea);
|
|
|
|
Pause();
|
2004-11-03 20:48:45 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
clear();
|
|
|
|
Enter(2);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-06 22:01:51 +00:00
|
|
|
rc = upload(&up);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-06 22:01:51 +00:00
|
|
|
if (rc) {
|
|
|
|
Syslog('+', "Upload failed, rc=%d", rc);
|
2004-11-03 20:48:45 +00:00
|
|
|
SetFileArea(OldArea);
|
|
|
|
return 0;
|
|
|
|
}
|
2004-11-06 22:01:51 +00:00
|
|
|
Syslog('b', "upload done, start checks");
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(2);
|
|
|
|
pout(CFG.UnderlineColourF, CFG.UnderlineColourB, (char *)"Checking your upload(s)");
|
|
|
|
Enter(1);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-06 22:01:51 +00:00
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
|
|
|
for (tmpf = up; tmpf; tmpf = tmpf->next) {
|
|
|
|
sprintf(temp, "%s/%s/upl", CFG.bbs_usersdir, exitinfo.Name);
|
|
|
|
chdir(temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-06 22:01:51 +00:00
|
|
|
Syslog('b', "Checking upload %s", tmpf->filename);
|
|
|
|
if ((arc = GetFileType(tmpf->filename)) == NULL) {
|
|
|
|
/*
|
|
|
|
* If the filetype is unknown, it is probably
|
|
|
|
* a textfile or so. Import it direct.
|
|
|
|
*/
|
|
|
|
Syslog('b', "Unknown file type");
|
|
|
|
if (!ScanDirect(basename(tmpf->filename)))
|
|
|
|
ImportFile(tmpf->filename, Area, FALSE, tmpf->size);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* We figured out the type of the uploaded file.
|
|
|
|
*/
|
|
|
|
Syslog('b', "File type is %s", arc);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-06 22:01:51 +00:00
|
|
|
/*
|
|
|
|
* MS-DOS executables are handled direct.
|
|
|
|
*/
|
|
|
|
if ((strcmp("EXE", arc) == 0) || (strcmp("COM", arc) == 0)) {
|
|
|
|
if (!ScanDirect(basename(tmpf->filename)))
|
|
|
|
ImportFile(tmpf->filename, Area, FALSE, tmpf->size);
|
|
|
|
} else {
|
|
|
|
switch (ScanArchive(basename(tmpf->filename), arc)) {
|
|
|
|
case 0: ImportFile(tmpf->filename, Area, TRUE, tmpf->size);
|
|
|
|
break;
|
|
|
|
case 1: break;
|
|
|
|
case 2: break;
|
|
|
|
case 3: /*
|
|
|
|
* No valid unarchiver found, just import after scanning,
|
|
|
|
* may catch macro viri.
|
|
|
|
*/
|
|
|
|
if (!ScanDirect(basename(tmpf->filename)))
|
|
|
|
ImportFile(tmpf->filename, Area, FALSE, tmpf->size);
|
|
|
|
break;
|
2004-11-03 20:48:45 +00:00
|
|
|
}
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
}
|
|
|
|
|
2004-11-06 22:01:51 +00:00
|
|
|
tidy_upload(&up);
|
|
|
|
free(temp);
|
2004-11-03 20:48:45 +00:00
|
|
|
Home();
|
|
|
|
SetFileArea(OldArea);
|
|
|
|
Pause();
|
|
|
|
return 1;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2004-11-03 20:48:45 +00:00
|
|
|
* Function will download a specific file
|
2001-08-17 05:46:24 +00:00
|
|
|
*/
|
2004-11-03 20:48:45 +00:00
|
|
|
int DownloadDirect(char *Name, int Wait)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2004-11-06 16:27:46 +00:00
|
|
|
int rc = 0;
|
|
|
|
long Size;
|
|
|
|
down_list *dl = NULL;
|
2004-11-03 20:48:45 +00:00
|
|
|
|
|
|
|
if ((Size = file_size(Name)) == -1) {
|
|
|
|
WriteError("No file %s", Name);
|
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, (char *)"File not found");
|
|
|
|
Enter(2);
|
|
|
|
Pause();
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-06 16:27:46 +00:00
|
|
|
Syslog('+', "Download direct %s", Name);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-06 16:27:46 +00:00
|
|
|
add_download(&dl, Name, basename(Name), 0, Size, FALSE);
|
2004-11-03 20:48:45 +00:00
|
|
|
WhosDoingWhat(DOWNLOAD, NULL);
|
|
|
|
|
2004-11-06 16:27:46 +00:00
|
|
|
if ((rc = download(dl))) {
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
2004-11-06 16:27:46 +00:00
|
|
|
* Error
|
2004-11-03 20:48:45 +00:00
|
|
|
*/
|
2004-11-06 16:27:46 +00:00
|
|
|
Syslog('+', "Download failed rc=%d", rc);
|
|
|
|
poutCR(LIGHTRED, BLACK, (char *)Language(353));
|
|
|
|
} else {
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* Update the users record. The file is free, so only statistics.
|
|
|
|
*/
|
|
|
|
ReadExitinfo();
|
|
|
|
exitinfo.Downloads++; /* Increase download counter */
|
|
|
|
WriteExitinfo();
|
|
|
|
}
|
2004-11-06 16:27:46 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (Wait)
|
|
|
|
Pause();
|
|
|
|
return rc;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2004-11-03 20:48:45 +00:00
|
|
|
* Function will list users home directory
|
2001-08-17 05:46:24 +00:00
|
|
|
*/
|
2004-11-03 20:48:45 +00:00
|
|
|
void List_Home()
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2004-11-03 20:48:45 +00:00
|
|
|
DIR *dirp;
|
|
|
|
char *FileName, *temp;
|
|
|
|
int iFileCount = 0, iBytes = 0;
|
|
|
|
struct dirent *dp;
|
|
|
|
struct stat statfile;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
FileName = calloc(PATH_MAX, sizeof(char));
|
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
iLineCount = 2;
|
|
|
|
clear();
|
|
|
|
sprintf(temp, "%s/%s/wrk", CFG.bbs_usersdir, exitinfo.Name);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
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 */
|
|
|
|
sprintf(temp, " %s", (char *) Language(291));
|
|
|
|
pout(BLUE, LIGHTGRAY, temp);
|
|
|
|
sprintf(temp, "%-51s", exitinfo.sUserName);
|
|
|
|
pout(RED, LIGHTGRAY, temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
Enter(1);
|
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
while ((dp = readdir( dirp )) != NULL ) {
|
|
|
|
sprintf(temp, "%s/%s/wrk", CFG.bbs_usersdir, exitinfo.Name);
|
|
|
|
sprintf(FileName, "%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;
|
|
|
|
sprintf(temp, "%-20s", dp->d_name);
|
|
|
|
pout(YELLOW, BLACK, temp);
|
|
|
|
sprintf(temp, "%-12ld", (long)(statfile.st_size));
|
|
|
|
pout(LIGHTMAGENTA, BLACK, temp);
|
|
|
|
sprintf(temp, "%s ", StrDateDMY(statfile.st_mtime));
|
|
|
|
pout(LIGHTGREEN, BLACK, temp);
|
|
|
|
sprintf(temp, "%s", StrTimeHMS(statfile.st_mtime));
|
|
|
|
pout(LIGHTCYAN, BLACK, temp);
|
|
|
|
Enter(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (iLC(1) == 1)
|
2001-08-17 05:46:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(2);
|
|
|
|
/* Total Files: */ /* Bytes */
|
|
|
|
sprintf(temp, "%s%d / %d %s", (char *) Language(242), iFileCount, iBytes, (char *) Language(354));
|
|
|
|
pout(LIGHTCYAN, BLACK, temp);
|
|
|
|
Enter(1);
|
|
|
|
Pause();
|
|
|
|
closedir(dirp);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
free(temp);
|
|
|
|
free(FileName);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Delete files from home directory
|
|
|
|
*/
|
|
|
|
void Delete_Home()
|
|
|
|
{
|
2004-11-06 22:01:51 +00:00
|
|
|
char *temp, *temp1, msg[81];
|
2004-11-03 20:48:45 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
|
|
|
temp1 = calloc(PATH_MAX, sizeof(char));
|
|
|
|
|
|
|
|
sprintf(temp, "%s/%s/wrk/", CFG.bbs_usersdir, exitinfo.Name);
|
|
|
|
|
|
|
|
Enter(1);
|
|
|
|
/* Please enter filename to delete: */
|
|
|
|
pout(9, 0, (char *) Language(292));
|
|
|
|
colour(CFG.InputColourF, CFG.InputColourB);
|
|
|
|
GetstrC(temp1, 80);
|
|
|
|
|
|
|
|
if (strcmp(temp1, "") == 0) {
|
2001-08-17 05:46:24 +00:00
|
|
|
free(temp);
|
|
|
|
free(temp1);
|
2004-11-03 20:48:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (temp1[0] == '.') {
|
|
|
|
Enter(1);
|
|
|
|
/* Sorry you may not delete hidden files ...*/
|
|
|
|
pout(12, 0, (char *) Language(293));
|
|
|
|
} else {
|
|
|
|
strcat(temp, temp1);
|
|
|
|
|
|
|
|
if ((access(temp, R_OK)) == 0) {
|
|
|
|
Enter(1);
|
|
|
|
/* Delete file: */ /* Are you Sure? [Y/n]: */
|
2004-11-06 22:01:51 +00:00
|
|
|
sprintf(msg, "%s %s, %s", (char *) Language(368), temp1, (char *) Language(369));
|
|
|
|
pout(LIGHTGREEN, BLACK, msg);
|
2004-11-03 20:48:45 +00:00
|
|
|
i = toupper(Readkey());
|
|
|
|
|
|
|
|
if (i == Keystroke(369, 0) || i == 13) {
|
|
|
|
i = unlink(temp);
|
|
|
|
|
|
|
|
if (i == -1) {
|
|
|
|
Enter(1);
|
|
|
|
/* Unable to delete file ... */
|
|
|
|
pout(LIGHTRED, BLACK, (char *) Language(294));
|
|
|
|
} else {
|
|
|
|
Syslog('+', "Delete %s from homedir", temp1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Enter(2);
|
|
|
|
/* Aborting ... */
|
|
|
|
pout(DARKGRAY, BLACK, (char *) Language(116));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Enter(1);
|
|
|
|
/* Invalid filename, please try again ... */
|
|
|
|
pout(LIGHTRED, BLACK, (char *) Language(295));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Enter(2);
|
|
|
|
free(temp);
|
|
|
|
free(temp1);
|
|
|
|
Pause();
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function allows user to download from his/her home directory
|
|
|
|
* but still does all the necessary checks
|
|
|
|
*/
|
|
|
|
int Download_Home()
|
|
|
|
{
|
2004-11-03 20:48:45 +00:00
|
|
|
char *temp, *File;
|
|
|
|
struct stat statfile;
|
|
|
|
int rc;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
File = calloc(PATH_MAX, sizeof(char));
|
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
WhosDoingWhat(DOWNLOAD, NULL);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
|
|
|
/* Please enter filename: */
|
|
|
|
pout(YELLOW, BLACK, (char *) Language(245));
|
|
|
|
colour(CFG.InputColourF, CFG.InputColourB);
|
|
|
|
GetstrC(File, 80);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (( strcmp(File, "")) == 0) {
|
|
|
|
Enter(2);
|
|
|
|
/* No filename entered, Aborting. */
|
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(246));
|
|
|
|
Enter(2);
|
|
|
|
Pause();
|
|
|
|
free(File);
|
|
|
|
free(temp);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (*(File) == '/' || *(File) == ' ') {
|
|
|
|
Enter(2);
|
|
|
|
/* Illegal Filename! */
|
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(247));
|
|
|
|
Enter(2);
|
|
|
|
Pause();
|
|
|
|
free(File);
|
|
|
|
free(temp);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* Get path for users home directory
|
|
|
|
*/
|
|
|
|
sprintf(temp, "%s/%s/wrk/%s", CFG.bbs_usersdir, exitinfo.Name, File);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (stat(temp, &statfile) != 0) {
|
|
|
|
Enter(2);
|
|
|
|
/* File does not exist, please try again ...*/
|
|
|
|
pout(LIGHTRED, BLACK, (char *) Language(296));
|
|
|
|
Enter(2);
|
|
|
|
Pause();
|
2001-08-17 05:46:24 +00:00
|
|
|
free(File);
|
|
|
|
free(temp);
|
2004-11-03 20:48:45 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = DownloadDirect(temp, TRUE);
|
|
|
|
|
|
|
|
free(File);
|
|
|
|
free(temp);
|
|
|
|
return rc;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function will upload to users home directory
|
|
|
|
*/
|
|
|
|
int Upload_Home()
|
|
|
|
{
|
2004-11-06 22:01:51 +00:00
|
|
|
char *temp, *arc;
|
|
|
|
int rc = 0, Count = 0;
|
|
|
|
up_list *up = NULL, *tmpf;
|
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
WhosDoingWhat(UPLOAD, NULL);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
clear();
|
|
|
|
Enter(2);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-06 22:01:51 +00:00
|
|
|
rc = upload(&up);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-06 22:01:51 +00:00
|
|
|
if (rc) {
|
|
|
|
Syslog('+', "Upload home failed, rc=%d", rc);
|
2004-11-03 20:48:45 +00:00
|
|
|
Home();
|
|
|
|
return 1;
|
|
|
|
}
|
2004-11-06 22:01:51 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
Syslog('b', "Start checking uploaded files");
|
|
|
|
Enter(2);
|
|
|
|
pout(CFG.UnderlineColourF, CFG.UnderlineColourB, (char *)"Checking your upload(s)");
|
|
|
|
Enter(2);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-06 22:01:51 +00:00
|
|
|
for (tmpf = up; tmpf; tmpf = tmpf->next) {
|
|
|
|
sprintf(temp, "%s/%s/upl", CFG.bbs_usersdir, exitinfo.Name);
|
|
|
|
chdir(temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-06 22:01:51 +00:00
|
|
|
Syslog('b', "Checking upload %s", tmpf->filename);
|
|
|
|
if ((arc = GetFileType(tmpf->filename)) == NULL) {
|
|
|
|
/*
|
|
|
|
* If the filetype is unknown, it is probably
|
|
|
|
* a textfile or so. Import it direct.
|
|
|
|
*/
|
|
|
|
Syslog('b', "Unknown file type");
|
|
|
|
ImportHome(basename(tmpf->filename));
|
|
|
|
Count++;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* We figured out the type of the uploaded file.
|
|
|
|
*/
|
|
|
|
Syslog('b', "File type is %s", arc);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-06 22:01:51 +00:00
|
|
|
/*
|
|
|
|
* MS-DOS executables are handled direct.
|
|
|
|
*/
|
|
|
|
if ((strcmp("EXE", arc) == 0) || (strcmp("COM", arc) == 0)) {
|
|
|
|
if (!ScanDirect(basename(tmpf->filename))) {
|
|
|
|
ImportHome(basename(tmpf->filename));
|
|
|
|
Count++;
|
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
} else {
|
2004-11-06 22:01:51 +00:00
|
|
|
switch(ScanArchive(basename(tmpf->filename), arc)) {
|
|
|
|
case 0: ImportHome(basename(tmpf->filename));
|
|
|
|
Count++;
|
|
|
|
break;
|
|
|
|
case 1: break;
|
|
|
|
case 2: break;
|
|
|
|
case 3: /*
|
|
|
|
* No valid unarchiver found, just import
|
|
|
|
*/
|
|
|
|
ImportHome(basename(tmpf->filename));
|
|
|
|
Count++;
|
|
|
|
break;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
}
|
|
|
|
Home();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
ReadExitinfo();
|
2004-11-06 22:01:51 +00:00
|
|
|
exitinfo.Uploads += Count;
|
2004-11-03 20:48:45 +00:00
|
|
|
WriteExitinfo();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-06 22:01:51 +00:00
|
|
|
tidy_upload(&up);
|
2004-11-03 20:48:45 +00:00
|
|
|
Pause();
|
|
|
|
free(temp);
|
2004-11-06 22:01:51 +00:00
|
|
|
return rc;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Select filearea, called from menu.
|
|
|
|
*/
|
|
|
|
void FileArea_List(char *Option)
|
|
|
|
{
|
2004-11-03 20:48:45 +00:00
|
|
|
FILE *pAreas;
|
|
|
|
int iAreaCount = 6, Recno = 1, iOldArea, iAreaNum = 0;
|
|
|
|
int iGotArea = FALSE; /* Flag to check if user typed in area */
|
|
|
|
long offset;
|
|
|
|
char *temp;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* Save old area, incase he picks a invalid area
|
|
|
|
*/
|
|
|
|
iOldArea = iAreaNumber;
|
|
|
|
if ((pAreas = OpenFareas(FALSE)) == NULL)
|
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* Count howmany records there are
|
|
|
|
*/
|
|
|
|
fseek(pAreas, 0, SEEK_END);
|
|
|
|
iAreaNum = (ftell(pAreas) - areahdr.hdrsize) / areahdr.recsize;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* If there are menu options, select area direct.
|
|
|
|
*/
|
|
|
|
if (strlen(Option) != 0) {
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (strcmp(Option, "F+") == 0) {
|
|
|
|
while (TRUE) {
|
|
|
|
iAreaNumber++;
|
|
|
|
if (iAreaNumber > iAreaNum)
|
|
|
|
iAreaNumber = 1;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
offset = areahdr.hdrsize + ((iAreaNumber - 1) * areahdr.recsize);
|
|
|
|
if (fseek(pAreas, offset, 0) != 0) {
|
|
|
|
printf("Can't move pointer here");
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
fread(&area, areahdr.recsize, 1, pAreas);
|
|
|
|
if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0))
|
|
|
|
break;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
|
|
|
|
if (strcmp(Option, "F-") == 0) {
|
|
|
|
while (TRUE) {
|
|
|
|
iAreaNumber--;
|
|
|
|
if (iAreaNumber < 1)
|
|
|
|
iAreaNumber = iAreaNum;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
offset = areahdr.hdrsize + ((iAreaNumber - 1) * areahdr.recsize);
|
|
|
|
if (fseek(pAreas, offset, 0) != 0) {
|
|
|
|
printf("Can't move pointer here");
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
fread(&area, areahdr.recsize, 1, pAreas);
|
|
|
|
if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SetFileArea(iAreaNumber);
|
|
|
|
Syslog('+', "File area %lu %s", iAreaNumber, sAreaDesc);
|
|
|
|
fclose(pAreas);
|
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* Interactive mode
|
|
|
|
*/
|
|
|
|
clear();
|
|
|
|
Enter(1);
|
|
|
|
/* File Areas */
|
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(298));
|
|
|
|
Enter(2);
|
|
|
|
temp = calloc(81, sizeof(char));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
fseek(pAreas, areahdr.hdrsize, 0);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
while (fread(&area, areahdr.recsize, 1, pAreas) == 1) {
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if ((Access(exitinfo.Security, area.LTSec)) && (area.Available)) {
|
|
|
|
area.Name[31] = '\0';
|
|
|
|
sprintf(temp, "%5d", Recno);
|
|
|
|
pout(WHITE, BLACK, temp);
|
|
|
|
sprintf(temp, " %c ", 46);
|
|
|
|
pout(LIGHTBLUE, BLACK, temp);
|
|
|
|
sprintf(temp, "%-31s", area.Name);
|
|
|
|
pout(CYAN, BLACK, temp);
|
|
|
|
iAreaCount++;
|
|
|
|
|
|
|
|
if ((iAreaCount % 2) == 0) {
|
|
|
|
Enter(1);
|
|
|
|
} else {
|
|
|
|
PUTCHAR(' ');
|
|
|
|
}
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
Recno++;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if ((iAreaCount / 2) == exitinfo.iScreenLen) {
|
|
|
|
/* More (Y/n/=/Area #): */
|
|
|
|
pout(CFG.MoreF, CFG.MoreB, (char *) Language(207));
|
|
|
|
/*
|
|
|
|
* Ask user for Area or enter to continue
|
|
|
|
*/
|
|
|
|
colour(CFG.InputColourF, CFG.InputColourB);
|
|
|
|
GetstrC(temp, 7);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (toupper(*(temp)) == Keystroke(207, 1))
|
|
|
|
break;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if ((strcmp(temp, "")) != 0) {
|
|
|
|
iGotArea = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
iAreaCount = 2;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* If user type in area above during area listing
|
|
|
|
* don't ask for it again
|
|
|
|
*/
|
|
|
|
if (!iGotArea) {
|
|
|
|
Enter(1);
|
|
|
|
/* Select Area: */
|
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(232));
|
|
|
|
colour(CFG.InputColourF, CFG.InputColourB);
|
|
|
|
GetstrC(temp, 80);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* Check if user pressed ENTER
|
|
|
|
*/
|
|
|
|
if ((strcmp(temp, "")) == 0) {
|
|
|
|
fclose(pAreas);
|
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
iAreaNumber = atoi(temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* Do a check in case user enters a negative value
|
|
|
|
*/
|
|
|
|
if (iAreaNumber < 1)
|
|
|
|
iAreaNumber = 1;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
offset = areahdr.hdrsize + ((iAreaNumber - 1) * areahdr.recsize);
|
|
|
|
if (fseek(pAreas, offset, 0) != 0)
|
|
|
|
printf("Can't move pointer there.");
|
|
|
|
else
|
|
|
|
fread(&area, areahdr.recsize, 1, pAreas);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* Do a check if area is greater or less number than allowed,
|
|
|
|
* security access level, is oke, and the area is active.
|
|
|
|
*/
|
|
|
|
if (iAreaNumber > iAreaNum || iAreaNumber < 1 ||
|
2001-08-17 05:46:24 +00:00
|
|
|
(Access(exitinfo.Security, area.LTSec) == FALSE) ||
|
|
|
|
(strlen(area.Name) == 0)) {
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
|
|
|
/* Invalid area specified - Please try again ...*/
|
|
|
|
pout(LIGHTRED, BLACK, (char *) Language(233));
|
|
|
|
Enter(2);
|
|
|
|
Pause();
|
|
|
|
fclose(pAreas);
|
|
|
|
iAreaNumber = iOldArea;
|
2001-08-17 05:46:24 +00:00
|
|
|
SetFileArea(iAreaNumber);
|
2004-11-03 20:48:45 +00:00
|
|
|
free(temp);
|
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
SetFileArea(iAreaNumber);
|
|
|
|
Syslog('+', "File area %lu %s", iAreaNumber, sAreaDesc);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* Check if file area has a password, if it does ask user for it
|
|
|
|
*/
|
|
|
|
if ((strlen(area.Password)) > 2) {
|
|
|
|
Enter(2);
|
|
|
|
/* Please enter Area Password: */
|
|
|
|
pout(WHITE, BLACK, (char *) Language(299));
|
|
|
|
colour(CFG.InputColourF, CFG.InputColourB);
|
|
|
|
GetstrC(temp, 20);
|
|
|
|
Enter(1);
|
|
|
|
|
|
|
|
if ((strcmp(temp, area.Password)) != 0) {
|
|
|
|
/* Password is incorrect */
|
|
|
|
pout(LIGHTRED, BLACK, (char *) Language(234));
|
|
|
|
Syslog('!', "Incorrect File Area # %d password given: %s", iAreaNumber, temp);
|
|
|
|
SetFileArea(iOldArea);
|
|
|
|
} else {
|
|
|
|
/* Password is correct */
|
|
|
|
pout(WHITE, BLACK, (char *) Language(235));
|
|
|
|
}
|
|
|
|
Enter(2);
|
|
|
|
Pause();
|
|
|
|
}
|
|
|
|
|
|
|
|
free(temp);
|
|
|
|
fclose(pAreas);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Show filelist from current area, called from the menu.
|
|
|
|
*/
|
|
|
|
void Copy_Home()
|
|
|
|
{
|
2004-03-06 21:48:41 +00:00
|
|
|
char *File, *temp1, *temp2;
|
|
|
|
int err, Found = FALSE;
|
2004-05-06 21:33:13 +00:00
|
|
|
struct _fdbarea *fdb_area = NULL;
|
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
File = calloc(81, sizeof(char));
|
|
|
|
temp1 = calloc(PATH_MAX, sizeof(char));
|
|
|
|
temp2 = calloc(PATH_MAX, sizeof(char));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2004-03-06 21:48:41 +00:00
|
|
|
/* Please enter filename: */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(YELLOW, BLACK, (char *) Language(245));
|
2004-03-06 21:48:41 +00:00
|
|
|
colour(CFG.InputColourF, CFG.InputColourB);
|
|
|
|
GetstrC(File, 80);
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(2);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
if ((strcmp(File, "")) == 0) {
|
|
|
|
/* No filename entered, Aborting. */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(246));
|
|
|
|
Enter(2);
|
2004-03-06 21:48:41 +00:00
|
|
|
Pause();
|
|
|
|
free(File);
|
|
|
|
free(temp1);
|
|
|
|
free(temp2);
|
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
if (*(File) == '/' || *(File) == ' ') {
|
|
|
|
/* Illegal Filename! */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(247));
|
|
|
|
Enter(2);
|
2004-03-06 21:48:41 +00:00
|
|
|
Pause();
|
|
|
|
free(File);
|
|
|
|
free(temp1);
|
|
|
|
free(temp2);
|
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
if (Access(exitinfo.Security, area.DLSec) == FALSE) {
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(YELLOW, BLACK, (char *) Language(236));
|
|
|
|
Enter(2);
|
2004-03-06 21:48:41 +00:00
|
|
|
Pause();
|
|
|
|
free(File);
|
|
|
|
free(temp1);
|
|
|
|
free(temp2);
|
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-05-06 21:33:13 +00:00
|
|
|
if ((fdb_area = mbsedb_OpenFDB(iAreaNumber, 30)) == NULL) {
|
|
|
|
free(File);
|
2004-03-06 21:48:41 +00:00
|
|
|
free(temp1);
|
|
|
|
free(temp2);
|
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-05-06 21:33:13 +00:00
|
|
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
2004-03-06 21:48:41 +00:00
|
|
|
if ((strcasecmp(File, fdb.Name) == 0) || (strcasecmp(File, fdb.LName) == 0)) {
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
Found = TRUE;
|
|
|
|
if (((fdb.Size + Quota()) > (CFG.iQuota * 1048576))) {
|
|
|
|
/* You have not enough diskspace free to copy this file */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(279));
|
|
|
|
Enter(1);
|
2004-03-06 21:48:41 +00:00
|
|
|
Syslog('+', "Copy homedir, not enough quota");
|
|
|
|
} else {
|
|
|
|
sprintf(temp1, "%s/%s", area.Path, fdb.LName); /* Use real longname here */
|
|
|
|
sprintf(temp2, "%s/%s/wrk/%s", CFG.bbs_usersdir, exitinfo.Name, File);
|
|
|
|
colour(CFG.TextColourF, CFG.TextColourB);
|
|
|
|
/* Start copy: */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(289));
|
|
|
|
PUTSTR(File);
|
|
|
|
PUTCHAR(' ');
|
2004-03-06 21:48:41 +00:00
|
|
|
|
|
|
|
Syslog('b', "Copy from : %s", temp1);
|
|
|
|
Syslog('b', "Copy to : %s", temp2);
|
|
|
|
|
|
|
|
if ((err = file_cp(temp1, temp2))) {
|
|
|
|
/* Failed! */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(353));
|
2004-03-06 21:48:41 +00:00
|
|
|
WriteError("Copy %s to homedir failed, code %d", File, err);
|
|
|
|
} else {
|
|
|
|
/* Ok */
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTSTR((char *) Language(200));
|
2004-03-06 21:48:41 +00:00
|
|
|
Syslog('+', "Copied %s from area %d to homedir", File, iAreaNumber);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2004-03-06 21:48:41 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-03-06 21:48:41 +00:00
|
|
|
}
|
2004-05-06 21:33:13 +00:00
|
|
|
mbsedb_CloseFDB(fdb_area);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
if (!Found) {
|
|
|
|
/* File does not exist, please try again ... */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(296));
|
|
|
|
Enter(1);
|
2004-03-06 21:48:41 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
Pause();
|
|
|
|
free(File);
|
|
|
|
free(temp1);
|
|
|
|
free(temp2);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Edit the list of tagged files.
|
|
|
|
*/
|
|
|
|
void EditTaglist()
|
|
|
|
{
|
2004-11-03 20:48:45 +00:00
|
|
|
FILE *tf;
|
|
|
|
int i, x, Fg, Count;
|
|
|
|
char *temp;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if ((tf = fopen("taglist", "r+")) == NULL) {
|
|
|
|
Enter(1);
|
|
|
|
/* No files tagged. */
|
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(361));
|
|
|
|
Enter(2);
|
|
|
|
Pause();
|
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
temp = calloc(81, sizeof(char));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
while (TRUE) {
|
|
|
|
clear();
|
|
|
|
fseek(tf, 0, SEEK_SET);
|
|
|
|
Count = 0;
|
|
|
|
/* # Area Active File Size Cost */
|
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(355));
|
|
|
|
Enter(1);
|
|
|
|
colour(LIGHTGREEN, BLACK);
|
|
|
|
fLine(48);
|
|
|
|
|
|
|
|
while ((fread(&Tag, sizeof(Tag), 1, tf) == 1)) {
|
|
|
|
Count++;
|
|
|
|
|
|
|
|
if (Tag.Active)
|
|
|
|
Fg = WHITE;
|
|
|
|
else
|
|
|
|
Fg = LIGHTGRAY;
|
|
|
|
|
|
|
|
sprintf(temp, "%3d ", Count);
|
|
|
|
pout(Fg, BLACK, temp);
|
|
|
|
|
|
|
|
Fg--;
|
|
|
|
sprintf(temp, "%5ld ", Tag.Area);
|
|
|
|
pout(Fg, BLACK, temp);
|
|
|
|
|
|
|
|
Fg--;
|
|
|
|
if (Tag.Active)
|
|
|
|
/* Yes */
|
|
|
|
sprintf(temp, "%-6s ", (char *) Language(356));
|
|
|
|
else
|
|
|
|
/* No */
|
|
|
|
sprintf(temp, "%-6s ", (char *) Language(357));
|
|
|
|
pout(Fg, BLACK, temp);
|
|
|
|
|
|
|
|
Fg--;
|
|
|
|
sprintf(temp, "%-12s", Tag.SFile);
|
|
|
|
pout(Fg, BLACK, temp);
|
|
|
|
|
|
|
|
Fg--;
|
|
|
|
sprintf(temp, " %8ld", (long)(Tag.Size));
|
|
|
|
pout(Fg, BLACK, temp);
|
|
|
|
|
|
|
|
Fg--;
|
|
|
|
sprintf(temp, " %5d", Tag.Cost);
|
|
|
|
pout(Fg, BLACK, temp);
|
|
|
|
Enter(1);
|
|
|
|
}
|
|
|
|
colour(LIGHTGREEN, BLACK);
|
|
|
|
fLine(48);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/* (T)oggle active, (E)rase all, (ENTER) to continue: */
|
|
|
|
pout(WHITE, RED, (char *) Language(358));
|
|
|
|
|
|
|
|
i = toupper(Readkey());
|
|
|
|
colour(CFG.CRColourF, CFG.CRColourB);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (i == Keystroke(358, 0)) {
|
|
|
|
Enter(2);
|
|
|
|
/* Enter file number, 1.. */
|
|
|
|
sprintf(temp, "%s%d ", (char *) Language(359), Count);
|
|
|
|
PUTSTR(temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
GetstrC(temp, 5);
|
|
|
|
x = atoi(temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if ((x > 0) && (x <= Count)) {
|
|
|
|
if (fseek(tf, (x - 1) * sizeof(Tag), SEEK_SET) == 0) {
|
|
|
|
if (fread(&Tag, sizeof(Tag), 1, tf) == 1) {
|
2001-08-17 05:46:24 +00:00
|
|
|
if (Tag.Active)
|
2004-11-03 20:48:45 +00:00
|
|
|
Tag.Active = FALSE;
|
2001-08-17 05:46:24 +00:00
|
|
|
else
|
2004-11-03 20:48:45 +00:00
|
|
|
Tag.Active = TRUE;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
fseek(tf,(x - 1) * sizeof(Tag), SEEK_SET);
|
|
|
|
fwrite(&Tag, sizeof(Tag), 1, tf);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
}
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (i == Keystroke(358, 1)) {
|
|
|
|
fclose(tf);
|
|
|
|
unlink("taglist");
|
|
|
|
free(temp);
|
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if ((i == '\r') || (i == '\n')) {
|
|
|
|
fclose(tf);
|
|
|
|
free(temp);
|
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2003-02-07 20:49:01 +00:00
|
|
|
* View a file in the current area, menu 103.
|
2003-04-12 11:12:26 +00:00
|
|
|
* If a file name is given, display direct,
|
|
|
|
* else ask for filename to view.
|
2001-08-17 05:46:24 +00:00
|
|
|
*/
|
2003-04-12 11:12:26 +00:00
|
|
|
void ViewFile(char *name)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2003-04-12 11:12:26 +00:00
|
|
|
char *File, *temp, *arc;
|
|
|
|
int count, total, rc, found = FALSE;
|
2004-05-06 21:33:13 +00:00
|
|
|
FILE *fp;
|
|
|
|
struct _fdbarea *fdb_area = NULL;
|
2003-04-12 11:12:26 +00:00
|
|
|
|
|
|
|
Syslog('+', "ViewFile(%s)", printable(name, 0));
|
|
|
|
|
|
|
|
if (Access(exitinfo.Security, area.LTSec) == FALSE) {
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2003-04-12 11:12:26 +00:00
|
|
|
/* You don't have enough security to list this area */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(YELLOW, BLACK, (char *) Language(236));
|
|
|
|
Enter(2);
|
2003-04-12 11:12:26 +00:00
|
|
|
Pause();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
File = calloc(PATH_MAX, sizeof(char));
|
|
|
|
|
|
|
|
if ((name != NULL) && strlen(name)) {
|
|
|
|
strcpy(File, name);
|
|
|
|
} else {
|
|
|
|
Enter(2);
|
|
|
|
/* Please enter filename: */
|
|
|
|
pout(YELLOW, BLACK, (char *) Language(245));
|
|
|
|
colour(CFG.InputColourF, CFG.InputColourB);
|
|
|
|
GetstrC(File, 80);
|
|
|
|
|
|
|
|
if ((strcmp(File, "")) == 0) {
|
|
|
|
free(File);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*(File) == '.' || *(File) == '*' || *(File) == ' ' || *(File) == '/') {
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2003-04-12 11:12:26 +00:00
|
|
|
/* Illegal Filename! */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(247));
|
|
|
|
Enter(2);
|
2003-04-12 11:12:26 +00:00
|
|
|
Pause();
|
|
|
|
free(File);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Strlen = strlen(File);
|
|
|
|
Strlen--;
|
|
|
|
|
|
|
|
if (*(File + Strlen) == '.' || *(File + Strlen) == '/' || *(File + Strlen) == ' ') {
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2003-04-12 11:12:26 +00:00
|
|
|
/* Illegal Filename! */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(247));
|
|
|
|
Enter(2);
|
2003-04-12 11:12:26 +00:00
|
|
|
Pause();
|
|
|
|
free(File);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((!strcmp(File, "files.bbs")) || (!strcmp(File, "00index")) || (strstr(File, (char *)".html"))) {
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2003-04-12 11:12:26 +00:00
|
|
|
/* Illegal Filename! */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(247));
|
|
|
|
Enter(2);
|
2003-04-12 11:12:26 +00:00
|
|
|
Pause();
|
|
|
|
free(File);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now check if this file is present
|
|
|
|
*/
|
2004-05-06 21:33:13 +00:00
|
|
|
if ((fdb_area = mbsedb_OpenFDB(iAreaNumber, 30)) == NULL) {
|
2003-04-12 11:12:26 +00:00
|
|
|
free(File);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-05-06 21:33:13 +00:00
|
|
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
2004-03-06 21:48:41 +00:00
|
|
|
if (((strcasecmp(File, fdb.Name) == 0) || (strcasecmp(File, fdb.LName) == 0)) && (!fdb.Deleted)) {
|
2003-04-12 11:12:26 +00:00
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-05-06 21:33:13 +00:00
|
|
|
mbsedb_CloseFDB(fdb_area);
|
2003-04-12 11:12:26 +00:00
|
|
|
|
|
|
|
if (!found) {
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2003-04-12 11:12:26 +00:00
|
|
|
/* File does not exist, please try again ... */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(296));
|
|
|
|
Enter(2);
|
2003-04-12 11:12:26 +00:00
|
|
|
free(File);
|
|
|
|
Pause();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
sprintf(File, "%s/%s", sAreaPath, fdb.LName);
|
2003-04-12 11:12:26 +00:00
|
|
|
arc = GetFileType(File);
|
2004-03-06 21:48:41 +00:00
|
|
|
Syslog('+', "File to view: %s, type %s", fdb.LName, printable(arc, 0));
|
2003-04-12 11:12:26 +00:00
|
|
|
|
|
|
|
if (arc != NULL) {
|
|
|
|
found = FALSE;
|
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
|
|
|
sprintf(temp, "%s/etc/archiver.data", getenv("MBSE_ROOT"));
|
|
|
|
|
|
|
|
if ((fp = fopen(temp, "r")) != NULL) {
|
|
|
|
fread(&archiverhdr, sizeof(archiverhdr), 1, fp);
|
|
|
|
while (fread(&archiver, archiverhdr.recsize, 1, fp) == 1) {
|
|
|
|
if ((strcmp(arc, archiver.name) == 0) && (archiver.available)) {
|
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!found || (strlen(archiver.varc) == 0)) {
|
|
|
|
Syslog('+', "No archiver view for %s available", File);
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2003-04-12 11:12:26 +00:00
|
|
|
/* Archiver not available */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, Language(442));
|
|
|
|
Enter(2);
|
2003-04-12 11:12:26 +00:00
|
|
|
free(File);
|
|
|
|
free(temp);
|
|
|
|
Pause();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Archiver viewer is available. Make a temp file which we will
|
|
|
|
* display to the user.
|
|
|
|
*/
|
|
|
|
sprintf(temp, "%s/%s/temptxt", CFG.bbs_usersdir, exitinfo.Name);
|
2004-03-02 20:47:23 +00:00
|
|
|
rc = execute_str(archiver.varc, File, NULL, (char *)"/dev/null", temp, (char *)"/dev/null");
|
2003-04-12 11:12:26 +00:00
|
|
|
Syslog('+', "Display temp file %s", temp);
|
|
|
|
DisplayTextFile(temp);
|
|
|
|
unlink(temp);
|
|
|
|
free(temp);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Most likely a textfile, first check.
|
|
|
|
*/
|
|
|
|
total = count = 0;
|
|
|
|
if ((fp = fopen(File, "r"))) {
|
|
|
|
while (TRUE) {
|
|
|
|
rc = fgetc(fp);
|
|
|
|
if (rc == EOF)
|
|
|
|
break;
|
|
|
|
total++;
|
|
|
|
if (isascii(rc))
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
if (((count * 10) / total) < 8) {
|
|
|
|
Syslog('+', "This is not a ASCII textfile");
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, Language(17));
|
|
|
|
Enter(2);
|
2003-04-12 11:12:26 +00:00
|
|
|
Pause();
|
|
|
|
free(File);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Syslog('+', "Display text file %s", File);
|
|
|
|
DisplayTextFile(File);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(File);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|