2001-08-17 05:46:24 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
2001-11-08 22:45:15 +00:00
|
|
|
* $Id$
|
2001-08-17 05:46:24 +00:00
|
|
|
* Purpose ...............: Main user login procedure. Checks for limits,
|
|
|
|
* new ratio's cats all the welcome screens, and
|
|
|
|
* does a lot of checking in general.
|
|
|
|
*
|
|
|
|
*****************************************************************************
|
2007-02-17 12:14:16 +00:00
|
|
|
* Copyright (C) 1997-2007
|
2001-08-17 05:46:24 +00:00
|
|
|
*
|
|
|
|
* Michiel Broek FIDO: 2:280/2802
|
|
|
|
* Beekmansbos 10
|
|
|
|
* 1971 BV IJmuiden
|
|
|
|
* the Netherlands
|
|
|
|
*
|
|
|
|
* This file is part of MBSE BBS.
|
|
|
|
*
|
|
|
|
* This BBS is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
* later version.
|
|
|
|
*
|
|
|
|
* MBSE BBS is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with MBSE BBS; see the file COPYING. If not, write to the Free
|
2003-08-15 20:05:34 +00:00
|
|
|
* Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
2001-08-17 05:46:24 +00:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2002-06-30 12:48:44 +00:00
|
|
|
#include "../config.h"
|
2004-02-21 17:22:00 +00:00
|
|
|
#include "../lib/mbselib.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "../lib/mbse.h"
|
2002-01-07 19:16:03 +00:00
|
|
|
#include "../lib/users.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "timeout.h"
|
|
|
|
#include "user.h"
|
2001-11-10 17:14:16 +00:00
|
|
|
#include "dispfile.h"
|
2001-11-12 21:42:17 +00:00
|
|
|
#include "funcs.h"
|
2001-11-10 17:14:16 +00:00
|
|
|
#include "input.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "misc.h"
|
|
|
|
#include "bye.h"
|
|
|
|
#include "file.h"
|
|
|
|
#include "mail.h"
|
|
|
|
#include "change.h"
|
|
|
|
#include "menu.h"
|
|
|
|
#include "exitinfo.h"
|
|
|
|
#include "language.h"
|
|
|
|
#include "offline.h"
|
|
|
|
#include "email.h"
|
2004-10-27 11:08:09 +00:00
|
|
|
#include "term.h"
|
2004-11-03 20:48:45 +00:00
|
|
|
#include "ttyio.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
|
|
|
|
|
2005-04-03 14:12:12 +00:00
|
|
|
|
2001-08-17 05:46:24 +00:00
|
|
|
extern int sock;
|
2005-10-07 20:42:35 +00:00
|
|
|
extern int cols;
|
|
|
|
extern int rows;
|
2001-08-17 05:46:24 +00:00
|
|
|
extern pid_t mypid;
|
2003-12-16 21:50:32 +00:00
|
|
|
char *StartTime = NULL;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
|
|
|
|
2001-11-10 17:14:16 +00:00
|
|
|
/*
|
|
|
|
* Non global function prototypes
|
2001-08-17 05:46:24 +00:00
|
|
|
*/
|
2001-11-10 17:14:16 +00:00
|
|
|
void SwapDate(char *, char *); /* Swap two Date strings around */
|
2001-08-17 05:46:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2001-11-12 21:42:17 +00:00
|
|
|
void GetLastUser(void);
|
|
|
|
void GetLastUser(void)
|
|
|
|
{
|
|
|
|
FILE *pCallerLog;
|
|
|
|
char *sDataFile;
|
|
|
|
|
|
|
|
sDataFile = calloc(PATH_MAX, sizeof(char));
|
2005-08-28 17:35:28 +00:00
|
|
|
snprintf(sDataFile, PATH_MAX, "%s/etc/sysinfo.data", getenv("MBSE_ROOT"));
|
2002-02-07 21:53:04 +00:00
|
|
|
/*
|
|
|
|
* Fix security in case it is wrong.
|
|
|
|
*/
|
|
|
|
chmod(sDataFile, 0660);
|
|
|
|
|
2001-11-12 21:42:17 +00:00
|
|
|
if((pCallerLog = fopen(sDataFile, "r+")) == NULL)
|
|
|
|
WriteError("GetLastUser: Can't open file: %s", sDataFile);
|
|
|
|
else {
|
|
|
|
fread(&SYSINFO, sizeof(SYSINFO), 1, pCallerLog);
|
|
|
|
|
|
|
|
/* Get lastcaller in memory */
|
|
|
|
strcpy(LastCaller, SYSINFO.LastCaller);
|
|
|
|
LastCallerTime = SYSINFO.LastTime;
|
|
|
|
|
|
|
|
/* Set next lastcaller (this user) */
|
|
|
|
if (!usrconfig.Hidden) {
|
|
|
|
strcpy(SYSINFO.LastCaller,exitinfo.sUserName);
|
|
|
|
SYSINFO.LastTime = time(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
SYSINFO.SystemCalls++;
|
|
|
|
switch(ttyinfo.type) {
|
|
|
|
case POTS:
|
|
|
|
SYSINFO.Pots++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ISDN:
|
|
|
|
SYSINFO.ISDN++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NETWORK:
|
|
|
|
SYSINFO.Network++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LOCAL:
|
|
|
|
SYSINFO.Local++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
rewind(pCallerLog);
|
|
|
|
fwrite(&SYSINFO, sizeof(SYSINFO), 1, pCallerLog);
|
|
|
|
|
|
|
|
fclose(pCallerLog);
|
|
|
|
}
|
|
|
|
free(sDataFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-08-17 05:46:24 +00:00
|
|
|
/*
|
2001-11-10 17:14:16 +00:00
|
|
|
* Function will take two date strings in the following format DD-MM-YYYY and
|
|
|
|
* swap them around in the following format YYYYMMDD
|
|
|
|
* ie. 01-02-1995 will become 19950201 so that the leading Zeros are not in
|
|
|
|
* the beginning as leading Zeros will fall away if you try compare the
|
|
|
|
* two with a if statement (Millenium proof).
|
2001-08-17 05:46:24 +00:00
|
|
|
*/
|
2001-11-10 17:14:16 +00:00
|
|
|
void SwapDate(char *Date3, char *Date4)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2001-11-10 17:14:16 +00:00
|
|
|
char *temp2, *temp3;
|
|
|
|
|
|
|
|
temp2 = calloc(10, sizeof(char));
|
|
|
|
temp3 = calloc(10, sizeof(char));
|
|
|
|
Date1 = calloc(10, sizeof(char));
|
|
|
|
Date2 = calloc(10, sizeof(char));
|
|
|
|
|
|
|
|
temp2[0] = Date3[6];
|
|
|
|
temp2[1] = Date3[7];
|
|
|
|
temp2[2] = Date3[8];
|
|
|
|
temp2[3] = Date3[9];
|
|
|
|
temp2[4] = Date3[3];
|
|
|
|
temp2[5] = Date3[4];
|
|
|
|
temp2[6] = Date3[0];
|
|
|
|
temp2[7] = Date3[1];
|
|
|
|
temp2[8] = '\0';
|
|
|
|
|
|
|
|
temp3[0] = Date4[6];
|
|
|
|
temp3[1] = Date4[7];
|
|
|
|
temp3[2] = Date4[8];
|
|
|
|
temp3[3] = Date4[9];
|
|
|
|
temp3[4] = Date4[3];
|
|
|
|
temp3[5] = Date4[4];
|
|
|
|
temp3[6] = Date4[0];
|
|
|
|
temp3[7] = Date4[1];
|
|
|
|
temp3[8] = '\0';
|
|
|
|
|
|
|
|
strcpy(Date1, temp2);
|
|
|
|
strcpy(Date2, temp3);
|
|
|
|
|
|
|
|
free(temp2);
|
|
|
|
free(temp3);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-10-07 20:42:35 +00:00
|
|
|
void user(void)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2002-11-11 12:55:14 +00:00
|
|
|
FILE *pUsrConfig, *pLimits;
|
2003-07-29 20:42:38 +00:00
|
|
|
int i, x, FoundName = FALSE, iFoundLimit = FALSE, IsNew = FALSE, logins = 0, Start;
|
2005-10-11 20:49:41 +00:00
|
|
|
int l1, l2;
|
2003-07-29 20:42:38 +00:00
|
|
|
char *token, temp[PATH_MAX], temp1[84], UserName[37], buf[128], *fullname;
|
2002-11-11 12:55:14 +00:00
|
|
|
time_t LastLogin;
|
|
|
|
struct stat st;
|
|
|
|
|
|
|
|
grecno = 0;
|
|
|
|
Syslog('+', "Unixmode login: %s", sUnixName);
|
|
|
|
|
2005-08-28 17:35:28 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s/etc/users.data", getenv("MBSE_ROOT"));
|
2003-05-10 11:51:43 +00:00
|
|
|
if ((pUsrConfig = fopen(temp,"r+")) == NULL) {
|
2002-11-11 12:55:14 +00:00
|
|
|
/*
|
|
|
|
* This should not happen.
|
|
|
|
*/
|
|
|
|
WriteError("$Can't open %s", temp);
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTSTR((char *)"Can't open userfile, run \"newuser\" first");
|
|
|
|
Enter(1);
|
2002-11-11 12:55:14 +00:00
|
|
|
ExitClient(MBERR_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
fread(&usrconfighdr, sizeof(usrconfighdr), 1, pUsrConfig);
|
|
|
|
while (fread(&usrconfig, usrconfighdr.recsize, 1, pUsrConfig) == 1) {
|
|
|
|
if (strcmp(usrconfig.Name, sUnixName) == 0) {
|
|
|
|
FoundName = TRUE;
|
|
|
|
break;
|
|
|
|
} else
|
|
|
|
grecno++;
|
|
|
|
}
|
2001-11-11 12:07:39 +00:00
|
|
|
|
2002-11-11 14:52:13 +00:00
|
|
|
if (!FoundName) {
|
2003-05-10 11:51:43 +00:00
|
|
|
fclose(pUsrConfig);
|
2005-08-28 17:35:28 +00:00
|
|
|
snprintf(temp, PATH_MAX, "Unknown username: %s\r\n", sUnixName);
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTSTR(temp);
|
2002-11-11 14:52:13 +00:00
|
|
|
/* FATAL ERROR: You are not in the BBS users file.*/
|
2005-08-28 17:35:28 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s\r\n", (char *) Language(389));
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTSTR(temp);
|
2002-11-11 14:52:13 +00:00
|
|
|
/* Please run 'newuser' to create an account */
|
2005-08-28 17:35:28 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s\r\n", (char *) Language(390));
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTSTR(temp);
|
2002-11-11 14:52:13 +00:00
|
|
|
Syslog('?', "FATAL: Could not find user in BBS users file.");
|
|
|
|
Syslog('?', " and system is using unix accounts\n");
|
2003-12-04 22:07:33 +00:00
|
|
|
Free_Language();
|
2002-11-11 14:52:13 +00:00
|
|
|
ExitClient(MBERR_OK);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-11 14:52:13 +00:00
|
|
|
/*
|
|
|
|
* Copy username, split first and lastname.
|
|
|
|
*/
|
2003-05-12 18:31:51 +00:00
|
|
|
strncpy(UserName, usrconfig.sUserName, sizeof(UserName)-1);
|
|
|
|
if ((strchr(UserName,' ') == NULL) && !CFG.iOneName) {
|
2002-11-11 14:52:13 +00:00
|
|
|
token = strtok(UserName, " ");
|
2003-05-12 18:31:51 +00:00
|
|
|
strncpy(FirstName, token, sizeof(FirstName)-1);
|
2002-11-11 14:52:13 +00:00
|
|
|
token = strtok(NULL, "\0");
|
|
|
|
i = strlen(token);
|
2003-05-12 18:31:51 +00:00
|
|
|
for (x = 2; x < i; x++) {
|
2002-11-11 14:52:13 +00:00
|
|
|
if (token[x] == ' ')
|
|
|
|
token[x] = '\0';
|
|
|
|
}
|
2003-05-12 18:31:51 +00:00
|
|
|
strncpy(LastName, token, sizeof(LastName)-1);
|
2002-11-11 14:52:13 +00:00
|
|
|
} else
|
2003-05-12 18:31:51 +00:00
|
|
|
strncpy(FirstName, UserName, sizeof(FirstName)-1);
|
|
|
|
strncpy(UserName, usrconfig.sUserName, sizeof(UserName)-1);
|
2005-10-08 17:58:23 +00:00
|
|
|
Syslog('+', "%s On-Line from \"%s\", node %d", UserName, ttyinfo.comment, iNode);
|
2002-11-11 14:52:13 +00:00
|
|
|
IsDoing("Just Logged In");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check some essential files, create them if they don't exist.
|
|
|
|
*/
|
|
|
|
ChkFiles();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup users favourite language.
|
|
|
|
*/
|
2007-02-25 20:28:00 +00:00
|
|
|
utf8 = (usrconfig.Charset == FTNC_UTF8);
|
2002-11-11 14:52:13 +00:00
|
|
|
Set_Language(usrconfig.iLanguage);
|
|
|
|
Free_Language();
|
|
|
|
InitLanguage();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* User logged in, tell it to the server. Check if a location is
|
|
|
|
* set, if Ask User location for new users is off, this field is
|
|
|
|
* empty but we have to send something to the server.
|
|
|
|
*/
|
|
|
|
if (strlen(usrconfig.sLocation))
|
|
|
|
UserCity(mypid, usrconfig.Name, usrconfig.sLocation);
|
|
|
|
else
|
|
|
|
UserCity(mypid, usrconfig.Name, (char *)"N/A");
|
|
|
|
|
2003-07-29 20:42:38 +00:00
|
|
|
/*
|
|
|
|
* Count simultaneous logins
|
|
|
|
*/
|
|
|
|
Start = TRUE;
|
|
|
|
while (TRUE) {
|
|
|
|
if (Start)
|
2005-08-28 17:35:28 +00:00
|
|
|
snprintf(buf, 128, "GMON:1,1;");
|
2003-07-29 20:42:38 +00:00
|
|
|
else
|
2005-08-28 17:35:28 +00:00
|
|
|
snprintf(buf, 128, "GMON:1,0;");
|
2003-07-29 20:42:38 +00:00
|
|
|
Start = FALSE;
|
|
|
|
if (socket_send(buf) == 0) {
|
|
|
|
strcpy(buf, socket_receive());
|
|
|
|
if (strncmp(buf, "100:0;", 6) == 0)
|
|
|
|
break; /* No more data */
|
|
|
|
if (strstr(buf, "mbsebbs")) {
|
|
|
|
/*
|
|
|
|
* Only mbsebbs is wanted
|
|
|
|
*/
|
2005-10-17 18:02:00 +00:00
|
|
|
strtok(buf, ","); /* response */
|
|
|
|
strtok(NULL, ","); /* pid */
|
|
|
|
strtok(NULL, ","); /* tty */
|
|
|
|
fullname = xstrcpy(cldecode(strtok(NULL, ","))); /* username */
|
2003-07-29 20:42:38 +00:00
|
|
|
if (strcmp(fullname, usrconfig.Name) == 0) {
|
|
|
|
logins++;
|
|
|
|
}
|
|
|
|
free(fullname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (CFG.max_logins && (logins > CFG.max_logins)) {
|
|
|
|
Syslog('+', "User logins %d, allowed %d, disconnecting", logins, CFG.max_logins);
|
|
|
|
colour(LIGHTRED, BLACK);
|
2005-08-28 17:35:28 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s %d %s\r\n", (char *) Language(18), CFG.max_logins, (char *) Language(19));
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTSTR(temp);
|
2003-07-29 20:42:38 +00:00
|
|
|
Quick_Bye(MBERR_INIT_ERROR);
|
|
|
|
}
|
|
|
|
|
2002-11-11 14:52:13 +00:00
|
|
|
/*
|
|
|
|
* Set last file and message area so these numbers are saved when
|
|
|
|
* the user hangs up or is logged off before het gets to the main
|
|
|
|
* menu. Later in this function the areas are set permanent.
|
|
|
|
*/
|
|
|
|
iAreaNumber = usrconfig.iLastFileArea;
|
|
|
|
iMsgAreaNumber = usrconfig.iLastMsgArea;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* See if this user is the Sysop.
|
|
|
|
*/
|
|
|
|
strcpy(temp, UserName);
|
|
|
|
strcpy(temp1, CFG.sysop_name);
|
|
|
|
if ((strcasecmp(CFG.sysop_name, UserName)) == 0) {
|
2001-08-17 05:46:24 +00:00
|
|
|
/*
|
2002-11-11 14:52:13 +00:00
|
|
|
* If login name is sysop, set SYSOP true
|
2001-08-17 05:46:24 +00:00
|
|
|
*/
|
2002-11-11 14:52:13 +00:00
|
|
|
SYSOP = TRUE;
|
|
|
|
Syslog('+', "Sysop is online");
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-11 14:52:13 +00:00
|
|
|
/*
|
|
|
|
* Is this a new user?
|
|
|
|
*/
|
|
|
|
if (usrconfig.iTotalCalls == 0)
|
|
|
|
IsNew = TRUE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Pause after logo screen.
|
|
|
|
*/
|
|
|
|
alarm_on();
|
|
|
|
Pause();
|
|
|
|
|
|
|
|
if (usrconfig.Archiver[0] == '\0') {
|
|
|
|
usrconfig.Archiver[0] = 'Z';
|
|
|
|
usrconfig.Archiver[1] = 'I';
|
|
|
|
usrconfig.Archiver[2] = 'P';
|
|
|
|
Syslog('+', "Setup default archiver ZIP");
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-11 14:52:13 +00:00
|
|
|
/*
|
|
|
|
* Check users date format. We do it strict as we
|
|
|
|
* need this to be good for several other purposes.
|
|
|
|
* If it is correct, the users age is set in UserAge
|
|
|
|
*/
|
|
|
|
if (!Test_DOB(usrconfig.sDateOfBirth)) {
|
|
|
|
Syslog('!', "Error in Date of Birth");
|
|
|
|
Chg_DOB();
|
|
|
|
strcpy(usrconfig.sDateOfBirth, exitinfo.sDateOfBirth);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-11 14:52:13 +00:00
|
|
|
/*
|
|
|
|
* Check to see if user must expire
|
|
|
|
*/
|
2005-08-28 17:35:28 +00:00
|
|
|
snprintf(temp,PATH_MAX, "%s", (char *) GetDateDMY());
|
2002-11-11 14:52:13 +00:00
|
|
|
SwapDate(temp, usrconfig.sExpiryDate);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-11 14:52:13 +00:00
|
|
|
/* Convert Date1 & Date2 to longs for compare */
|
|
|
|
l1 = atol(Date1);
|
|
|
|
l2 = atol(Date2);
|
2002-11-11 12:55:14 +00:00
|
|
|
|
2002-11-11 14:52:13 +00:00
|
|
|
if (l1 >= l2 && l2 != 0) {
|
|
|
|
/*
|
|
|
|
* If Expiry Date is the same as today expire to
|
|
|
|
* Expire Sec level
|
2001-08-17 05:46:24 +00:00
|
|
|
*/
|
2002-11-11 14:52:13 +00:00
|
|
|
usrconfig.Security = usrconfig.ExpirySec;
|
|
|
|
Syslog('!', "User is expired, resetting level");
|
2001-11-10 17:14:16 +00:00
|
|
|
/*
|
2002-11-11 14:52:13 +00:00
|
|
|
* Show texfile to user telling him about this.
|
2001-11-10 17:14:16 +00:00
|
|
|
*/
|
2002-11-11 14:52:13 +00:00
|
|
|
DisplayFile((char *)"expired");
|
|
|
|
}
|
2001-11-10 17:14:16 +00:00
|
|
|
|
2002-11-11 14:52:13 +00:00
|
|
|
free(Date1);
|
|
|
|
free(Date2);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-11 14:52:13 +00:00
|
|
|
/*
|
|
|
|
* Copy limits.data into memory
|
|
|
|
*/
|
2005-08-28 17:35:28 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s/etc/limits.data", getenv("MBSE_ROOT"));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-11 14:52:13 +00:00
|
|
|
if ((pLimits = fopen(temp,"rb")) == NULL) {
|
|
|
|
WriteError("$Can't open %s", temp);
|
|
|
|
} else {
|
|
|
|
fread(&LIMIThdr, sizeof(LIMIThdr), 1, pLimits);
|
|
|
|
|
|
|
|
while (fread(&LIMIT, sizeof(LIMIT), 1, pLimits) == 1) {
|
|
|
|
if (LIMIT.Security == usrconfig.Security.level) {
|
|
|
|
iFoundLimit = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2001-11-10 17:14:16 +00:00
|
|
|
}
|
2002-11-11 14:52:13 +00:00
|
|
|
fclose(pLimits);
|
|
|
|
}
|
2001-11-10 17:14:16 +00:00
|
|
|
|
2002-11-11 14:52:13 +00:00
|
|
|
if (!iFoundLimit) {
|
|
|
|
WriteError("Unknown Security Level in limits.data");
|
|
|
|
usrconfig.iTimeLeft = 0; /* Could not find limit, so set to Zero */
|
|
|
|
usrconfig.iTimeUsed = 0; /* Set to Zero as well */
|
|
|
|
} else {
|
2001-11-10 17:14:16 +00:00
|
|
|
/*
|
2002-11-11 14:52:13 +00:00
|
|
|
* Give user new time limit everyday, also new users get a new limit.
|
2001-11-10 17:14:16 +00:00
|
|
|
*/
|
2005-08-28 17:35:28 +00:00
|
|
|
snprintf(temp,PATH_MAX, "%s", (char *) GetDateDMY());
|
2002-11-11 14:52:13 +00:00
|
|
|
if (((strcmp(StrDateDMY(usrconfig.tLastLoginDate), temp)) != 0) || IsNew) {
|
|
|
|
/*
|
|
|
|
* If no timelimit set give user 24 hours.
|
|
|
|
*/
|
|
|
|
if (LIMIT.Time)
|
|
|
|
usrconfig.iTimeLeft = LIMIT.Time;
|
|
|
|
else
|
|
|
|
usrconfig.iTimeLeft = 86400;
|
|
|
|
usrconfig.iTimeUsed = 0; /* Set time used today to Zero */
|
|
|
|
usrconfig.iConnectTime = 0; /* Set connect time to Zero */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Give user new bytes and files every day if needed.
|
|
|
|
*/
|
2004-11-28 19:59:35 +00:00
|
|
|
if (LIMIT.DownK) {
|
2002-11-11 14:52:13 +00:00
|
|
|
usrconfig.DownloadKToday = LIMIT.DownK;
|
|
|
|
}
|
2004-11-28 19:59:35 +00:00
|
|
|
if (LIMIT.DownF) {
|
|
|
|
usrconfig.DownloadsToday = LIMIT.DownF;
|
|
|
|
}
|
2001-11-10 17:14:16 +00:00
|
|
|
}
|
2002-11-11 14:52:13 +00:00
|
|
|
} /* End of else */
|
|
|
|
|
|
|
|
usrconfig.iConnectTime = 0;
|
|
|
|
|
|
|
|
/* Copy Users Protocol into Memory */
|
|
|
|
Set_Protocol(usrconfig.sProtocol);
|
|
|
|
tlf(usrconfig.sProtocol);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set last login Date and Time, copy previous session
|
|
|
|
* values in memory.
|
|
|
|
*/
|
2005-08-28 17:35:28 +00:00
|
|
|
snprintf(LastLoginDate, 12, "%s", StrDateDMY(usrconfig.tLastLoginDate));
|
|
|
|
snprintf(LastLoginTime, 9, "%s", StrTimeHMS(usrconfig.tLastLoginDate));
|
2002-11-11 14:52:13 +00:00
|
|
|
LastLogin = usrconfig.tLastLoginDate;
|
|
|
|
usrconfig.tLastLoginDate = ltime; /* Set current login to current date */
|
|
|
|
usrconfig.iTotalCalls++;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Update user record.
|
|
|
|
*/
|
|
|
|
if (fseek(pUsrConfig, usrconfighdr.hdrsize + (grecno * usrconfighdr.recsize), 0) != 0) {
|
|
|
|
WriteError("Can't seek in %s/etc/users.data", getenv("MBSE_ROOT"));
|
|
|
|
} else {
|
|
|
|
fwrite(&usrconfig, sizeof(usrconfig), 1, pUsrConfig);
|
|
|
|
}
|
2003-05-10 11:51:43 +00:00
|
|
|
fclose(pUsrConfig);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-11 14:52:13 +00:00
|
|
|
/*
|
|
|
|
* Write users structure to tmp file in ~/home/unixname/exitinfo
|
|
|
|
* A copy of the userrecord is also in the variable exitinfo.
|
|
|
|
*/
|
|
|
|
if (! InitExitinfo())
|
|
|
|
Good_Bye(MBERR_INIT_ERROR);
|
|
|
|
|
2004-02-24 22:09:27 +00:00
|
|
|
/*
|
|
|
|
* If user has not set a preferred character set, force this
|
|
|
|
*/
|
|
|
|
if (exitinfo.Charset == FTNC_NONE) {
|
|
|
|
Chg_Charset();
|
|
|
|
}
|
|
|
|
|
2007-03-02 20:27:14 +00:00
|
|
|
// setlocale(LC_CTYPE, getlocale(exitinfo.Charset));
|
|
|
|
// Syslog('b', "setlocale(LC_CTYPE, NULL) returns \"%s\"", printable(setlocale(LC_CTYPE, NULL), 0));
|
2007-03-02 18:13:10 +00:00
|
|
|
|
2002-11-11 14:52:13 +00:00
|
|
|
GetLastUser();
|
|
|
|
StartTime = xstrcpy(GetLocalHM());
|
|
|
|
ChangeHomeDir(exitinfo.Name, exitinfo.Email);
|
|
|
|
|
|
|
|
Syslog('+', "User successfully logged into BBS");
|
2003-05-10 11:51:43 +00:00
|
|
|
Syslog('+', "Level %d (%s), %d mins. left, port %s", exitinfo.Security.level, LIMIT.Description, exitinfo.iTimeLeft, pTTY);
|
2002-11-11 14:52:13 +00:00
|
|
|
Time2Go = time(NULL);
|
2003-05-10 11:51:43 +00:00
|
|
|
Time2Go += exitinfo.iTimeLeft * 60;
|
2002-11-11 14:52:13 +00:00
|
|
|
iUserTimeLeft = exitinfo.iTimeLeft;
|
|
|
|
|
|
|
|
IsDoing("Welcome screens");
|
|
|
|
DisplayFile((char *)"mainlogo");
|
|
|
|
DisplayFile((char *)"welcome");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The following files are only displayed if the user has
|
|
|
|
* turned the Bulletins on.
|
|
|
|
*/
|
|
|
|
if (exitinfo.ieNEWS) {
|
|
|
|
DisplayFile((char *)"welcome1");
|
|
|
|
DisplayFile((char *)"welcome2");
|
|
|
|
DisplayFile((char *)"welcome3");
|
|
|
|
DisplayFile((char *)"welcome4");
|
|
|
|
DisplayFile((char *)"welcome5");
|
|
|
|
DisplayFile((char *)"welcome6");
|
|
|
|
DisplayFile((char *)"welcome7");
|
|
|
|
DisplayFile((char *)"welcome8");
|
|
|
|
DisplayFile((char *)"welcome9");
|
|
|
|
|
2005-08-28 17:35:28 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s", (char *) GetDateDMY() );
|
2002-11-11 14:52:13 +00:00
|
|
|
if ((strcmp(exitinfo.sDateOfBirth, temp)) == 0)
|
|
|
|
DisplayFile((char *)"birthday");
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2001-11-10 17:14:16 +00:00
|
|
|
/*
|
2002-11-11 14:52:13 +00:00
|
|
|
* Displays file if it exists DD-MM.A??
|
2001-11-10 17:14:16 +00:00
|
|
|
*/
|
2005-08-28 17:35:28 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s", (char *) GetDateDMY());
|
2002-11-11 14:52:13 +00:00
|
|
|
strcpy(temp1, "");
|
|
|
|
strncat(temp1, temp, 5);
|
2005-08-28 17:35:28 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s", temp1);
|
2002-11-11 14:52:13 +00:00
|
|
|
DisplayFile(temp);
|
|
|
|
|
2001-11-10 17:14:16 +00:00
|
|
|
/*
|
2002-11-11 14:52:13 +00:00
|
|
|
* Displays users security file if it exists
|
2001-11-10 17:14:16 +00:00
|
|
|
*/
|
2005-08-28 17:35:28 +00:00
|
|
|
snprintf(temp, PATH_MAX, "sec%d", exitinfo.Security.level);
|
2002-11-11 14:52:13 +00:00
|
|
|
DisplayFile(temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2001-11-10 17:14:16 +00:00
|
|
|
/*
|
2002-11-11 14:52:13 +00:00
|
|
|
* Display News file
|
2001-11-10 17:14:16 +00:00
|
|
|
*/
|
2002-11-11 14:52:13 +00:00
|
|
|
DisplayFile((char *)"news");
|
|
|
|
}
|
2001-11-10 17:14:16 +00:00
|
|
|
|
2002-11-11 14:52:13 +00:00
|
|
|
/*
|
|
|
|
* Display Onceonly file, first get the date of that
|
|
|
|
* file, search order is the same as in DisplayFile()
|
|
|
|
*/
|
|
|
|
st.st_mtime = 0;
|
2007-02-25 20:28:00 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s/share/int/txtfiles/%s/onceonly.ans", getenv("MBSE_ROOT"), lang.lc);
|
|
|
|
stat(temp, &st);
|
|
|
|
if (st.st_mtime == 0) {
|
|
|
|
snprintf(temp, PATH_MAX, "%s/share/int/txtfiles/%s/onceonly.ans", getenv("MBSE_ROOT"), CFG.deflang);
|
2002-11-11 14:52:13 +00:00
|
|
|
stat(temp, &st);
|
|
|
|
}
|
|
|
|
if (st.st_mtime == 0) {
|
2007-02-17 12:14:16 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s/share/int/txtfiles/%s/onceonly.asc", getenv("MBSE_ROOT"), lang.lc);
|
2002-11-11 14:52:13 +00:00
|
|
|
stat(temp, &st);
|
2001-11-10 17:14:16 +00:00
|
|
|
if (st.st_mtime == 0) {
|
2007-02-17 12:14:16 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s/share/int/txtfiles/%s/onceonly.asc", getenv("MBSE_ROOT"), CFG.deflang);
|
2002-11-11 14:52:13 +00:00
|
|
|
stat(temp, &st);
|
2001-11-10 17:14:16 +00:00
|
|
|
}
|
2002-11-11 14:52:13 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-11 14:52:13 +00:00
|
|
|
if ((st.st_mtime != 0) && (LastLogin < st.st_mtime))
|
|
|
|
DisplayFile((char *)"onceonly");
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-11 14:52:13 +00:00
|
|
|
OLR_SyncTags();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-11 14:52:13 +00:00
|
|
|
if (exitinfo.MailScan) {
|
|
|
|
IsDoing("New mail check");
|
|
|
|
CheckMail();
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-11 14:52:13 +00:00
|
|
|
/*
|
|
|
|
* We don't show new files to new users.
|
|
|
|
*/
|
|
|
|
if (exitinfo.ieFILE && (!IsNew)) {
|
|
|
|
IsDoing("New files check");
|
|
|
|
NewfileScan(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copy last file Area in to current Area
|
|
|
|
*/
|
|
|
|
SetFileArea(exitinfo.iLastFileArea);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copy Last Message Area in to Current Msg Area
|
|
|
|
*/
|
|
|
|
SetMsgArea(usrconfig.iLastMsgArea);
|
|
|
|
SetEmailArea((char *)"mailbox");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set or Reset the DoNotDisturb flag, now is the time
|
|
|
|
* we may be interrupted.
|
|
|
|
*/
|
|
|
|
UserSilent(usrconfig.DoNotDisturb);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Start the menu.
|
|
|
|
*/
|
|
|
|
menu();
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|