Made mbsebbs non setuid, added program mbnewusr

This commit is contained in:
Michiel Broek
2001-11-10 17:14:16 +00:00
parent 785fb988fb
commit e87e7c2ab6
57 changed files with 2677 additions and 2882 deletions

View File

@@ -11,21 +11,28 @@ SRCS = bank.c commonio.c filesub.c language.c mbfbgen.c mbtoberep.c \
mbuseradd.c newuser.c pinfo.c rad64.c timecheck.c change.c \
exitinfo.c funcs4.c mball.c mbsebbs.c menu.c nextuser.c pop3.c \
safe.c timeout.c chat.c file.c getdef.c mbchat.c mbstat.c misc.c \
offline.c putpwent.c salt.c user.c
offline.c putpwent.c salt.c user.c mbnewusr.c input.c whoson.c \
door.c dispfile.c
HDRS = bank.h commonio.h filesub.h language.h mbsebbs.h misc.h offline.h \
putpwent.h salt.h timeout.h bbslist.h email.h fsedit.h lineedit.h \
mbstat.h msgutil.h oneline.h pwcheck.h sgetpwent.h user.h bye.h \
encrypt.h funcs.h mail.h mbuser.h myname.h page.h pwio.h shadowio.h \
xmalloc.h change.h exitinfo.h funcs4.h mball.h mbuseradd.h newuser.h \
pinfo.h rad64.h statetbl.h chat.h file.h getdef.h mbpasswd.h menu.h \
nextuser.h pop3.h safe.h timecheck.h
nextuser.h pop3.h safe.h timecheck.h mbnewusr.h input.h whoson.h \
door.h dispfile.h
MBSEBBS_OBJS = bank.o bbslist.o chat.o file.o funcs.o funcs4.o mail.o menu.o \
misc.o pinfo.o nextuser.o oneline.o page.o pwcheck.o fsedit.o \
bye.o change.o mbsebbs.o safe.o timeout.o user.o timecheck.o \
exitinfo.o filesub.o lineedit.o offline.o language.o msgutil.o \
newuser.o pop3.o email.o
pop3.o email.o input.o whoson.o door.o dispfile.o
MBSEBBS_LIBS = ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/libmsgbase.a \
../lib/libdbase.a ../lib/libmbinet.a
MBNEWUSR_OBJS = mbnewusr.o newuser.o language.o bye.o timeout.o dispfile.o oneline.o \
timecheck.o exitinfo.o input.o misc.o funcs.o funcs4.o pwcheck.o change.o \
filesub.o mail.o email.o whoson.o msgutil.o pop3.o lineedit.o fsedit.o
MBNEWUSR_LIBS = ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/libmsgbase.a \
../lib/libdbase.a ../lib/libmbinet.a
MBALL_OBJS = mball.o
MBALL_LIBS = ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/libdbase.a
MBLANG_OBJS = mblang.o
@@ -44,7 +51,7 @@ MBUSERADD_OBJS = mbuseradd.o
MBPASSWD_OBJS = mbpasswd.o commonio.o pwio.o shadowio.o sgetpwent.o \
xmalloc.o myname.o rad64.o salt.o getdef.o encrypt.o putpwent.o
OTHER = Makefile
TARGET = mbsebbs mball mblang mbchat mbfbgen mbstat mbtoberep mbuser mbuseradd mbpasswd
TARGET = mbsebbs mbnewusr mball mblang mbchat mbfbgen mbstat mbtoberep mbuser mbuseradd mbpasswd
#############################################################################################################
@@ -60,6 +67,10 @@ mbsebbs: ${MBSEBBS_OBJS} ${MBSEBBS_LIBS}
${CC} -o mbsebbs ${MBSEBBS_OBJS} ${LIBS} ${MBSEBBS_LIBS}
strip mbsebbs
mbnewusr: ${MBNEWUSR_OBJS} ${MBNEWUSR_LIBS}
${CC} -o mbnewusr ${MBNEWUSR_OBJS} ${LIBS} ${MBNEWUSR_LIBS}
strip mbnewusr
mball: ${MBALL_OBJS} ${MBALL_LIBS}
${CC} -o mball ${MBALL_OBJS} ${LIBS} ${MBALL_LIBS}
strip mball
@@ -100,7 +111,8 @@ install: all
@if [ "`id -un`" != "root" ] ; then \
echo; echo " Must be root to install!"; echo; exit 3; \
fi
${INSTALL} -s -o ${OWNER} -g ${GROUP} -m 6711 mbsebbs ${BINDIR}
${INSTALL} -s -o ${OWNER} -g ${GROUP} -m 0751 mbsebbs ${BINDIR}
${INSTALL} -s -o ${OWNER} -g ${GROUP} -m 6711 mbnewusr ${BINDIR}
${INSTALL} -s -o ${OWNER} -g ${GROUP} -m 0711 mball ${BINDIR}
${INSTALL} -s -o ${OWNER} -g ${GROUP} -m 0711 mblang ${BINDIR}
${INSTALL} -s -o ${OWNER} -g ${GROUP} -m 0711 mbchat ${BINDIR}
@@ -140,55 +152,60 @@ depend:
# DO NOT DELETE THIS LINE - MAKE DEPEND RELIES ON IT
# Dependencies generated by make depend
bank.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/clcomm.h ../lib/common.h bank.h funcs4.h language.h funcs.h timeout.h timecheck.h exitinfo.h
bank.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/clcomm.h ../lib/common.h bank.h input.h language.h dispfile.h timeout.h timecheck.h whoson.h exitinfo.h
commonio.o: ../config.h commonio.h
filesub.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h filesub.h funcs.h language.h funcs4.h misc.h timeout.h exitinfo.h change.h
language.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h funcs4.h language.h
filesub.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h filesub.h funcs.h language.h funcs4.h input.h misc.h timeout.h exitinfo.h change.h
language.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h input.h language.h
mbfbgen.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h
mbtoberep.o: ../lib/libs.h ../lib/structs.h
msgutil.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msgtext.h ../lib/msg.h oneline.h msgutil.h
oneline.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h oneline.h funcs.h funcs4.h language.h
oneline.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h oneline.h funcs.h input.h language.h
pwcheck.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h pwcheck.h funcs4.h timeout.h
sgetpwent.o: ../config.h sgetpwent.h
xmalloc.o: ../config.h xmalloc.h
bbslist.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/clcomm.h ../lib/common.h bbslist.h funcs.h funcs4.h language.h
email.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/msgtext.h ../lib/msg.h ../lib/common.h ../lib/clcomm.h ../lib/mbinet.h exitinfo.h language.h mail.h timeout.h msgutil.h funcs4.h email.h
bbslist.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/clcomm.h ../lib/common.h bbslist.h funcs.h input.h language.h
email.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/msgtext.h ../lib/msg.h ../lib/common.h ../lib/clcomm.h ../lib/mbinet.h exitinfo.h language.h mail.h timeout.h msgutil.h input.h email.h whoson.h
fsedit.o: fsedit.h
lineedit.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h mail.h funcs4.h language.h timeout.h lineedit.h
lineedit.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h mail.h input.h language.h timeout.h lineedit.h
mblang.o: ../lib/libs.h ../lib/structs.h ../lib/records.h
mbuser.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbuser.h
myname.o: ../config.h
page.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h funcs.h funcs4.h chat.h page.h timeout.h mail.h language.h
page.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h dispfile.h input.h chat.h page.h timeout.h mail.h language.h
pwio.o: ../config.h sgetpwent.h commonio.h putpwent.h pwio.h
shadowio.o: ../config.h commonio.h shadowio.h
bye.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/clcomm.h ../lib/common.h funcs.h misc.h language.h bye.h
bye.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/clcomm.h ../lib/common.h dispfile.h misc.h language.h bye.h
encrypt.o: ../config.h encrypt.h
funcs.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/msgtext.h ../lib/msg.h ../lib/clcomm.h funcs.h language.h funcs4.h oneline.h misc.h bye.h timeout.h timecheck.h exitinfo.h mail.h email.h
mail.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/msgtext.h ../lib/clcomm.h ../lib/msg.h mail.h funcs.h funcs4.h language.h misc.h timeout.h oneline.h exitinfo.h lineedit.h fsedit.h filesub.h msgutil.h pop3.h email.h
funcs.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/msgtext.h ../lib/msg.h ../lib/clcomm.h funcs.h funcs4.h language.h input.h oneline.h misc.h bye.h timeout.h timecheck.h exitinfo.h mail.h email.h
mail.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/msgtext.h ../lib/clcomm.h ../lib/msg.h mail.h funcs.h input.h language.h misc.h timeout.h oneline.h exitinfo.h lineedit.h fsedit.h filesub.h msgutil.h pop3.h email.h whoson.h
mbpasswd.o: ../config.h encrypt.h rad64.h myname.h xmalloc.h pwio.h shadowio.h mbpasswd.h
mbuseradd.o: ../config.h mbuseradd.h
newuser.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/clcomm.h ../lib/common.h funcs4.h pwcheck.h newuser.h language.h timeout.h change.h bye.h
pinfo.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h funcs4.h
newuser.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/clcomm.h ../lib/common.h funcs4.h input.h pwcheck.h newuser.h language.h timeout.h change.h bye.h dispfile.h
pinfo.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h pinfo.h input.h
rad64.o: ../config.h rad64.h
timecheck.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/clcomm.h ../lib/common.h timecheck.h funcs.h funcs4.h misc.h bye.h exitinfo.h language.h
change.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h change.h funcs.h funcs4.h language.h misc.h pwcheck.h timeout.h exitinfo.h bye.h
exitinfo.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h funcs.h funcs4.h language.h oneline.h misc.h bye.h timeout.h timecheck.h exitinfo.h
funcs4.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/clcomm.h ../lib/common.h ../lib/msg.h funcs4.h misc.h timeout.h language.h
change.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h change.h dispfile.h funcs.h funcs4.h input.h language.h misc.h pwcheck.h timeout.h exitinfo.h bye.h
exitinfo.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h funcs.h input.h language.h oneline.h misc.h bye.h timeout.h timecheck.h exitinfo.h
funcs4.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/clcomm.h ../lib/common.h ../lib/msg.h funcs4.h input.h misc.h timeout.h language.h
mball.o: ../lib/libs.h ../lib/structs.h ../lib/mbse.h ../lib/records.h ../lib/common.h ../lib/dbcfg.h ../lib/clcomm.h mball.h
mbsebbs.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h mbsebbs.h user.h funcs.h funcs4.h language.h menu.h misc.h bye.h timeout.h
menu.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h oneline.h mail.h bbslist.h change.h bank.h chat.h file.h funcs.h funcs4.h misc.h nextuser.h safe.h timeout.h menu.h page.h pinfo.h bye.h timecheck.h exitinfo.h language.h offline.h email.h
nextuser.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/ansi.h ../lib/clcomm.h ../lib/common.h nextuser.h funcs.h funcs4.h language.h timeout.h
mbsebbs.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h mbsebbs.h user.h dispfile.h funcs4.h language.h menu.h misc.h bye.h timeout.h
menu.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h oneline.h mail.h bbslist.h change.h bank.h chat.h file.h funcs.h funcs4.h input.h misc.h nextuser.h safe.h timeout.h menu.h page.h pinfo.h bye.h timecheck.h whoson.h language.h offline.h email.h door.h dispfile.h
nextuser.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/ansi.h ../lib/clcomm.h ../lib/common.h nextuser.h funcs.h input.h language.h timeout.h
pop3.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/mbinet.h ../lib/msgtext.h ../lib/msg.h msgutil.h pop3.h
safe.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/clcomm.h ../lib/common.h exitinfo.h funcs.h funcs4.h misc.h safe.h timeout.h language.h
safe.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/clcomm.h ../lib/common.h whoson.h dispfile.h input.h misc.h safe.h timeout.h language.h
timeout.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h timeout.h funcs.h funcs4.h bye.h filesub.h language.h
chat.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h chat.h funcs.h funcs4.h language.h misc.h exitinfo.h
file.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h filesub.h file.h funcs.h funcs4.h language.h misc.h timeout.h exitinfo.h change.h
chat.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h chat.h funcs.h input.h language.h misc.h whoson.h
file.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h filesub.h file.h funcs.h input.h language.h misc.h timeout.h exitinfo.h whoson.h change.h
getdef.o: ../config.h getdef.h
mbchat.o: ../lib/libs.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h
mbstat.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbstat.h
misc.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/clcomm.h ../lib/common.h funcs.h funcs4.h language.h misc.h timeout.h exitinfo.h
offline.o: ../lib/libs.h ../lib/structs.h ../lib/mbse.h ../lib/records.h ../lib/bluewave.h ../lib/common.h ../lib/clcomm.h ../lib/msgtext.h ../lib/msg.h mail.h funcs.h funcs4.h language.h file.h filesub.h exitinfo.h timeout.h msgutil.h pop3.h offline.h
misc.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/clcomm.h ../lib/common.h funcs.h funcs4.h input.h language.h misc.h timeout.h exitinfo.h
offline.o: ../lib/libs.h ../lib/structs.h ../lib/mbse.h ../lib/records.h ../lib/bluewave.h ../lib/common.h ../lib/clcomm.h ../lib/msgtext.h ../lib/msg.h mail.h funcs.h funcs4.h input.h language.h file.h filesub.h exitinfo.h timeout.h msgutil.h pop3.h offline.h whoson.h
putpwent.o: ../config.h putpwent.h
salt.o: ../config.h rad64.h getdef.h
user.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h timeout.h user.h pwcheck.h funcs.h funcs4.h misc.h bye.h file.h mail.h change.h menu.h exitinfo.h language.h offline.h statetbl.h email.h newuser.h
user.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h timeout.h user.h pwcheck.h dispfile.h funcs4.h input.h misc.h bye.h file.h mail.h change.h menu.h exitinfo.h language.h offline.h statetbl.h email.h
mbnewusr.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h mbnewusr.h funcs.h funcs4.h input.h language.h misc.h bye.h timeout.h newuser.h
input.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/clcomm.h ../lib/common.h input.h timeout.h language.h
whoson.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h input.h language.h exitinfo.h whoson.h
door.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h input.h timeout.h exitinfo.h whoson.h door.h
dispfile.o: ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/msgtext.h ../lib/msg.h ../lib/clcomm.h funcs.h funcs4.h language.h oneline.h misc.h timeout.h timecheck.h exitinfo.h mail.h email.h dispfile.h
# End of generated dependencies

View File

@@ -1,8 +1,7 @@
/*****************************************************************************
*
* File ..................: bbs/bank.c
* $Id$
* Purpose ...............: Time/Bytes Bank
* Last modification date : 28-Jun-2001
*
*****************************************************************************
* Copyright (C) 1997-2001
@@ -36,11 +35,12 @@
#include "../lib/clcomm.h"
#include "../lib/common.h"
#include "bank.h"
#include "funcs4.h"
#include "input.h"
#include "language.h"
#include "funcs.h"
#include "dispfile.h"
#include "timeout.h"
#include "timecheck.h"
#include "whoson.h"
#include "exitinfo.h"

View File

@@ -1,8 +1,7 @@
/*****************************************************************************
*
* File ..................: bbs/bbslist.c
* $Id$
* Purpose ...............: Handle BBS lists
* Last modification date : 28-Jun-2001
* ToDo ..................: Add use of new fields
* Verify check at logon
* Intro New BBS at logon
@@ -40,7 +39,7 @@
#include "../lib/common.h"
#include "bbslist.h"
#include "funcs.h"
#include "funcs4.h"
#include "input.h"
#include "language.h"

View File

@@ -35,7 +35,7 @@
#include "../lib/records.h"
#include "../lib/clcomm.h"
#include "../lib/common.h"
#include "funcs.h"
#include "dispfile.h"
#include "misc.h"
#include "language.h"
#include "bye.h"

View File

@@ -1,8 +1,7 @@
/*****************************************************************************
*
* File ..................: bbs/change.c
* $Id$
* Purpose ...............: Change user settings
* Last modification date : 27-Oct-2001
*
*****************************************************************************
* Copyright (C) 1997-2001
@@ -36,8 +35,10 @@
#include "../lib/common.h"
#include "../lib/clcomm.h"
#include "change.h"
#include "dispfile.h"
#include "funcs.h"
#include "funcs4.h"
#include "input.h"
#include "language.h"
#include "misc.h"
#include "pwcheck.h"

View File

@@ -1,8 +1,7 @@
/*****************************************************************************
*
* File ..................: bbs/chat.c
* $Id$
* Purpose ...............: Sysop to user chat utility
* Last modification date : 08-Feb-1999
*
*****************************************************************************
* Copyright (C) 1997-1999
@@ -37,10 +36,10 @@
#include "../lib/clcomm.h"
#include "chat.h"
#include "funcs.h"
#include "funcs4.h"
#include "input.h"
#include "language.h"
#include "misc.h"
#include "exitinfo.h"
#include "whoson.h"

523
mbsebbs/dispfile.c Normal file
View File

@@ -0,0 +1,523 @@
/*****************************************************************************
*
* $Id$
* Purpose ...............: Display ANSI/ASCII textfiles
*
*****************************************************************************
* Copyright (C) 1997-2001
*
* 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
* Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*****************************************************************************/
#include "../lib/libs.h"
#include "../lib/mbse.h"
#include "../lib/structs.h"
#include "../lib/records.h"
#include "../lib/common.h"
#include "../lib/msgtext.h"
#include "../lib/msg.h"
#include "../lib/clcomm.h"
#include "funcs.h"
#include "funcs4.h"
#include "language.h"
#include "oneline.h"
#include "misc.h"
#include "timeout.h"
#include "timecheck.h"
#include "exitinfo.h"
#include "mail.h"
#include "email.h"
#include "dispfile.h"
/*
* Function returns total number of bbs users
*/
int TotalUsers(void);
int TotalUsers(void)
{
FILE *pUsrConfig;
int ch = 0;
char *temp;
struct userhdr uhdr;
struct userrec u;
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/etc/users.data", getenv("MBSE_ROOT"));
if(( pUsrConfig = fopen(temp,"rb")) == NULL)
WriteError("ControlCodeK: Can't open users file %s for reading", temp);
else {
fread(&uhdr, sizeof(uhdr), 1, pUsrConfig);
while (fread(&u, uhdr.recsize, 1, pUsrConfig) == 1)
if ((!u.Deleted) && (strlen(u.sUserName) > 0))
ch++;
fclose(pUsrConfig);
}
free(temp);
return ch;
}
/*
* Function will display textfile in either ansi or ascii and
* display control codes if they exist.
* Returns Success if it can display the requested file
*/
int DisplayFile(char *filename)
{
FILE *pFileName;
long iSec = 0;
char *sFileName, *tmp, *tmp1;
char newfile[PATH_MAX];
int i, x;
sFileName = calloc(16385, sizeof(char));
tmp = calloc(PATH_MAX, sizeof(char));
tmp1 = calloc(PATH_MAX, sizeof(char));
/*
* Open the file in the following search order:
* 1 - if GraphMode -> users language .ans
* 2 - if GraphMode -> default language .ans
* 3 - users language .asc
* 4 - default language .asc
* 5 - Abort, there is no file to show.
*/
pFileName = NULL;
if (exitinfo.GraphMode) {
sprintf(newfile, "%s/%s.ans", lang.TextPath, filename);
if ((pFileName = fopen(newfile, "rb")) == NULL) {
sprintf(newfile, "%s/%s.ans", CFG.bbs_txtfiles, filename);
pFileName = fopen(newfile, "rb");
}
}
if (pFileName == NULL) {
sprintf(newfile, "%s/%s.asc", lang.TextPath, filename);
if ((pFileName = fopen(newfile, "rb")) == NULL) {
sprintf(newfile, "%s/%s.asc", CFG.bbs_txtfiles, filename);
if ((pFileName = fopen(newfile, "rb")) == NULL) {
free(sFileName);
free(tmp);
free(tmp1);
return FALSE;
}
}
}
Syslog('B', "Displayfile %s", newfile);
while (!feof(pFileName)) {
i = fread(sFileName, sizeof(char), 16384, pFileName);
for(x = 0; x < i; x++) {
switch(*(sFileName + x)) {
case '':
ControlCodeU(sFileName[++x]);
break;
case '':
ControlCodeF(sFileName[++x]);
break;
case ' ':
ControlCodeK(sFileName[++x]);
break;
case '':
fflush(stdout);
fflush(stdin);
alarm_on();
Getone();
break;
case '':
/*
* This code will allow you to specify a security level
* in front of the text, ie ^B32000^Bthis is a test^B
* will print this is a test only if you have security
* above 32000. Only one set of control chars per line.
* You cannot have multiple securitys etc
*/
x++;
strcpy(tmp1, "");
while (*(sFileName + x) != '') {
sprintf(tmp, "%c", *(sFileName + x));
strcat(tmp1, tmp);
x++;
}
x++;
iSec = atoi(tmp1);
while ((x <= i) && (*(sFileName + x) != '')) {
if (exitinfo.Security.level >= iSec)
printf("%c", *(sFileName + x));
x++;
}
break;
case '':
fflush(stdout);
sleep(1);
break;
default:
printf("%c", *(sFileName + x));
} /* switch */
} /* for */
} /* while !eof */
fclose(pFileName);
free(sFileName);
free(tmp);
free(tmp1);
return TRUE;
}
int DisplayFileEnter(char *File)
{
int rc;
rc = DisplayFile(File);
Enter(1);
/* Press ENTER to continue */
language(13, 0, 436);
fflush(stdout);
fflush(stdin);
alarm_on();
Getone();
return rc;
}
void ControlCodeF(int ch)
{
/* Update user info */
ReadExitinfo();
switch (toupper(ch)) {
case '!':
printf(exitinfo.sProtocol);
break;
case 'A':
printf("%ld", exitinfo.Uploads);
break;
case 'B':
printf("%ld", exitinfo.Downloads);
break;
case 'C':
printf("%lu", exitinfo.DownloadK);
break;
case 'D':
printf("%lu", exitinfo.UploadK);
break;
case 'E':
printf("%lu", exitinfo.DownloadK + exitinfo.UploadK);
break;
case 'F':
printf("%lu", LIMIT.DownK);
break;
case 'G':
printf("%d", exitinfo.iTransferTime);
break;
case 'H':
printf("%d", iAreaNumber);
break;
case 'I':
printf(sAreaDesc);
break;
case 'J':
printf("%u", LIMIT.DownF);
break;
case 'K':
printf("%s", LIMIT.Description);
break;
default:
printf(" ");
}
}
void ControlCodeU(int ch)
{
/*
* Update user info
*/
TimeCheck();
ReadExitinfo();
switch (toupper(ch)) {
case 'A':
printf("%s", exitinfo.sUserName);
break;
case 'B':
printf(exitinfo.sLocation);
break;
case 'C':
printf(exitinfo.sVoicePhone);
break;
case 'D':
printf(exitinfo.sDataPhone);
break;
case 'E':
printf(LastLoginDate);
break;
case 'F':
printf("%s %s", StrDateDMY(exitinfo.tFirstLoginDate), StrTimeHMS(exitinfo.tFirstLoginDate));
break;
case 'G':
printf(LastLoginTime);
break;
case 'H':
printf("%d", exitinfo.Security.level);
break;
case 'I':
printf("%d", exitinfo.iTotalCalls);
break;
case 'J':
printf("%d", exitinfo.iTimeUsed);
break;
case 'K':
printf("%d", exitinfo.iConnectTime);
break;
case 'L':
printf("%d", exitinfo.iTimeLeft);
break;
case 'M':
printf("%d", exitinfo.iScreenLen);
break;
case 'N':
printf(FirstName);
break;
case 'O':
printf(LastName);
break;
case 'Q':
printf("%s", exitinfo.ieNEWS ? (char *) Language(147) : (char *) Language(148));
break;
case 'P':
printf("%s", exitinfo.GraphMode ? (char *) Language(147) : (char *) Language(148));
break;
case 'R':
printf("%s", exitinfo.HotKeys ? (char *) Language(147) : (char *) Language(148));
break;
case 'S':
printf("%d", exitinfo.iTimeUsed + exitinfo.iTimeLeft);
break;
case 'T':
printf(exitinfo.sDateOfBirth);
break;
case 'U':
printf("%d", exitinfo.iPosted);
break;
case 'X':
printf(lang.Name);
break;
case 'Y':
printf(exitinfo.sHandle);
break;
case 'Z':
printf("%s", exitinfo.DoNotDisturb ? (char *) Language(147) : (char *) Language(148));
break;
case '1':
printf("%s", exitinfo.MailScan ? (char *) Language(147) : (char *) Language(148));
break;
case '2':
printf("%s", exitinfo.ieFILE ? (char *) Language(147) : (char *) Language(148));
break;
case '3':
printf("%s", exitinfo.FsMsged ? (char *) Language(147) : (char *) Language(148));
break;
case '4':
printf("%s", exitinfo.FSemacs ? (char *) Language(147) : (char *) Language(148));
break;
case '5':
printf(exitinfo.address[0]);
break;
case '6':
printf(exitinfo.address[1]);
break;
case '7':
printf(exitinfo.address[2]);
break;
default:
printf(" ");
}
}
void ControlCodeK(int ch)
{
FILE *pCallerLog;
char sDataFile[PATH_MAX];
lastread LR;
switch (toupper(ch)) {
case 'A':
printf("%s", (char *) GetDateDMY());
break;
case 'B':
printf("%s", (char *) GetLocalHMS());
break;
case 'C':
printf("%s", (char *) GLCdate());
break;
case 'D':
printf("%s", (char *) GLCdateyy());
break;
case 'E':
printf("%d", Speed() );
break;
case 'F':
printf("%s", LastCaller);
break;
case 'G':
printf("%d", TotalUsers());
break;
case 'H':
sprintf(sDataFile, "%s/etc/sysinfo.data", getenv("MBSE_ROOT"));
if((pCallerLog = fopen(sDataFile, "rb")) != NULL) {
fread(&SYSINFO, sizeof(SYSINFO), 1, pCallerLog);
printf("%ld", SYSINFO.SystemCalls);
fclose(pCallerLog);
}
break;
case 'I':
printf("%d", iMsgAreaNumber + 1);
break;
case 'J':
printf(sMsgAreaDesc);
break;
case 'K':
printf("%s", Oneliner_Get());
break;
case 'L':
SetMsgArea(iMsgAreaNumber);
printf("%ld", MsgBase.Total);
break;
case 'M':
LR.UserID = grecno;
if (Msg_Open(sMsgAreaBase)) {
if (Msg_GetLastRead(&LR) == TRUE) {
if (LR.HighReadMsg > MsgBase.Highest)
LR.HighReadMsg = MsgBase.Highest;
printf("%ld", LR.HighReadMsg);
} else
printf("?");
Msg_Close();
}
break;
case 'N':
printf("%s", sMailbox);
break;
case 'O':
SetEmailArea(sMailbox);
printf("%ld", EmailBase.Total);
break;
case 'P':
sprintf(sDataFile, "%s/%s/%s", CFG.bbs_usersdir, exitinfo.Name, sMailbox);
LR.UserID = grecno;
if (Msg_Open(sDataFile)) {
if (Msg_GetLastRead(&LR) == TRUE) {
if (LR.HighReadMsg > EmailBase.Highest)
LR.HighReadMsg = EmailBase.Highest;
printf("%ld", LR.HighReadMsg);
} else
printf("?");
Msg_Close();
}
break;
default:
printf(" ");
}
}

13
mbsebbs/dispfile.h Normal file
View File

@@ -0,0 +1,13 @@
/* $Id$ */
#ifndef _DISPLAYFILE_H
#define _DISPLAYFILE_H
int DisplayFile(char *); /* Display .ans/.asc textfile */
int DisplayFileEnter(char *); /* Display .ans/.asc wait for Enter */
void ControlCodeF(int); /* Check Control Codes in File */
void ControlCodeU(int); /* Check Control Codes in File */
void ControlCodeK(int); /* Check Control Codes in File */
#endif

298
mbsebbs/door.c Normal file
View File

@@ -0,0 +1,298 @@
/*****************************************************************************
*
* $Id$
* Purpose ...............: Run external door
*
*****************************************************************************
* Copyright (C) 1997-2001
*
* 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
* Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*****************************************************************************/
#include "../lib/libs.h"
#include "../lib/mbse.h"
#include "../lib/structs.h"
#include "../lib/records.h"
#include "../lib/common.h"
//#include "../lib/msgtext.h"
//#include "../lib/msg.h"
#include "../lib/clcomm.h"
#include "input.h"
#include "timeout.h"
#include "exitinfo.h"
#include "whoson.h"
#include "door.h"
extern time_t t_start;
extern int e_pid;
extern char **environ;
char *Gdate(time_t, int);
char *Gdate(time_t tt, int Y2K)
{
static char GLC[15];
struct tm *tm;
tm = localtime(&tt);
if (Y2K)
sprintf(GLC, "%02d-%02d-%04d", tm->tm_mon +1, tm->tm_mday, tm->tm_year + 1900);
else
sprintf(GLC, "%02d-%02d-%02d", tm->tm_mon +1, tm->tm_mday, tm->tm_year % 100);
return (GLC);
}
char *Rdate(char *, int);
char *Rdate(char *ind, int Y2K)
{
static char GLC[15];
memset(&GLC, 0, sizeof(GLC));
GLC[0] = ind[3];
GLC[1] = ind[4];
GLC[2] = '-';
GLC[3] = ind[0];
GLC[4] = ind[1];
GLC[5] = '-';
if (Y2K) {
GLC[6] = ind[6];
GLC[7] = ind[7];
GLC[8] = ind[8];
GLC[9] = ind[9];
} else {
GLC[6] = ind[8];
GLC[7] = ind[9];
}
return GLC;
}
/*
* Function will run a external program or door
*/
void ExtDoor(char *Program, int NoDoorsys, int Y2Kdoorsys, int Comport, int NoSuid)
{
char *String, *String1;
int i, rc;
char *temp1;
FILE *fp;
temp1 = calloc(PATH_MAX, sizeof(char));
String = calloc(81, sizeof(char));
WhosDoingWhat(DOOR);
if ((strstr(Program, "/N")) != NULL) {
sprintf(temp1, "%d", iNode);
strreplace(Program, (char *)"/N", temp1);
}
if ((strstr(Program, "/A")) != NULL) {
colour(3, 0);
if ((String = strstr(Program, "/T=")) != NULL) {
String1 = String + 3;
printf("\n%s", String1);
} else
printf("\nPlease enter filename: ");
fflush(stdout);
colour(CFG.InputColourF, CFG.InputColourB);
GetstrC(temp1, 80);
strreplace(Program, (char *)"/A", temp1);
for(i = 0; i < strlen(Program); i++) {
if (*(Program + i) == '\0')
break;
if (*(Program + i) == '/')
*(Program + i) = '\0';
}
}
free(String);
Syslog('+', "Door: %s", Program);
ReadExitinfo();
alarm_set((exitinfo.iTimeLeft * 60) - 10);
Altime((exitinfo.iTimeLeft * 60));
/*
* Always remove the old door.sys first.
*/
sprintf(temp1, "%s/%s/door.sys", CFG.bbs_usersdir, exitinfo.Name);
unlink(temp1);
/*
* Write door.sys in users homedirectory
*/
if (!NoDoorsys) {
if ((fp = fopen(temp1, "w+")) == NULL) {
WriteError("$Can't create %s", temp1);
} else {
if (Comport) {
fprintf(fp, "COM1:\r\n"); /* COM port */
fprintf(fp, "19200\r\n");/* Effective baudrate */
} else {
fprintf(fp, "COM0:\r\n");/* COM port */
fprintf(fp, "0\r\n"); /* Effective baudrate */
}
fprintf(fp, "8\r\n"); /* Databits */
fprintf(fp, "%d\r\n", iNode); /* Node number */
if (Comport)
fprintf(fp, "19200\r\n");/* Locked baudrate */
else
fprintf(fp, "%ld\r\n", ttyinfo.portspeed); /* Locked baudrate */
fprintf(fp, "Y\r\n"); /* Screen display */
fprintf(fp, "N\r\n"); /* Printer on */
fprintf(fp, "Y\r\n"); /* Page bell */
fprintf(fp, "Y\r\n"); /* Caller alarm */
fprintf(fp, "%s\r\n", exitinfo.sUserName);
fprintf(fp, "%s\r\n", exitinfo.sLocation);
fprintf(fp, "%s\r\n", exitinfo.sVoicePhone);
fprintf(fp, "%s\r\n", exitinfo.sDataPhone);
fprintf(fp, "%s\r\n", exitinfo.Password);
fprintf(fp, "%d\r\n", exitinfo.Security.level);
fprintf(fp, "%d\r\n", exitinfo.iTotalCalls);
fprintf(fp, "%s\r\n", Gdate(exitinfo.tLastLoginDate, Y2Kdoorsys));
fprintf(fp, "%d\r\n", exitinfo.iTimeLeft * 60);
fprintf(fp, "%d\r\n", exitinfo.iTimeLeft);
fprintf(fp, "GR\r\n"); /* ANSI graphics */
fprintf(fp, "%d\r\n", exitinfo.iScreenLen);
fprintf(fp, "N\r\n"); /* User mode, always N */
fprintf(fp, "\r\n"); /* Always blank */
fprintf(fp, "\r\n"); /* Always blank */
fprintf(fp, "%s\r\n", Rdate(exitinfo.sExpiryDate, Y2Kdoorsys));
fprintf(fp, "%d\r\n", grecno); /* Users recordnumber */
fprintf(fp, "%s\r\n", exitinfo.sProtocol);
fprintf(fp, "%ld\r\n", exitinfo.Uploads);
fprintf(fp, "%ld\r\n", exitinfo.Downloads);
fprintf(fp, "%ld\r\n", LIMIT.DownK);
fprintf(fp, "%ld\r\n", LIMIT.DownK);
fprintf(fp, "%s\r\n", Rdate(exitinfo.sDateOfBirth, Y2Kdoorsys));
fprintf(fp, "\r\n"); /* Path to userbase */
fprintf(fp, "\r\n"); /* Path to messagebase */
fprintf(fp, "%s\r\n", CFG.sysop_name);
fprintf(fp, "%s\r\n", exitinfo.sHandle);
fprintf(fp, "none\r\n"); /* Next event time */
fprintf(fp, "Y\r\n"); /* Error free connect. */
fprintf(fp, "N\r\n"); /* Always N */
fprintf(fp, "Y\r\n"); /* Always Y */
fprintf(fp, "7\r\n"); /* Default textcolor */
fprintf(fp, "0\r\n"); /* Always 0 */
fprintf(fp, "%s\r\n", Gdate(exitinfo.tLastLoginDate, Y2Kdoorsys));
fprintf(fp, "%s\r\n", StrTimeHM(t_start));
fprintf(fp, "%s\r\n", LastLoginTime);
fprintf(fp, "32768\r\n"); /* Always 32768 */
fprintf(fp, "%d\r\n", exitinfo.DownloadsToday);
fprintf(fp, "%ld\r\n", exitinfo.UploadK);
fprintf(fp, "%ld\r\n", exitinfo.DownloadK);
fprintf(fp, "%s\r\n", exitinfo.sComment);
fprintf(fp, "0\r\n"); /* Always 0 */
fprintf(fp, "%d\r\n\032", exitinfo.iPosted);
fclose(fp);
}
}
clear();
printf("Loading ...\n\n");
if (NoSuid)
rc = exec_nosuid(Program);
else
rc = execute((char *)"/bin/sh", (char *)"-c", Program, NULL, NULL, NULL);
Altime(0);
alarm_off();
alarm_on();
Syslog('+', "Door end, rc=%d", rc);
free(temp1);
printf("\n\n");
Pause();
}
/*
* Execute a door as real user, not suid.
*/
int exec_nosuid(char *mandato)
{
int rc, status;
pid_t pid;
if (mandato == NULL)
return 1; /* Prevent running a shell */
Syslog('+', "Execve: /bin/sh -c %s", mandato);
pid = fork();
if (pid == -1)
return 1;
if (pid == 0) {
char *argv[4];
argv[0] = (char *)"sh";
argv[1] = (char *)"-c";
argv[2] = mandato;
argv[3] = 0;
execve("/bin/sh", argv, environ);
exit(127);
}
e_pid = pid;
do {
rc = waitpid(pid, &status, 0);
e_pid = 0;
} while (((rc > 0) && (rc != pid)) || ((rc == -1) && (errno == EINTR)));
switch(rc) {
case -1:
WriteError("$Waitpid returned %d, status %d,%d", rc,status>>8,status&0xff);
return -1;
case 0:
return 0;
default:
if (WIFEXITED(status)) {
rc = WEXITSTATUS(status);
if (rc) {
WriteError("Exec_nosuid: returned error %d", rc);
return rc;
}
}
if (WIFSIGNALED(status)) {
rc = WTERMSIG(status);
WriteError("Wait stopped on signal %d", rc);
return rc;
}
if (rc)
WriteError("Wait stopped unknown, rc=%d", rc);
return rc;
}
return 0;
}

9
mbsebbs/door.h Normal file
View File

@@ -0,0 +1,9 @@
/* $Id$ */
#ifndef _DOOR_H
#define _DOOR_H
void ExtDoor(char *, int, int, int, int); /* Run external door */
int exec_nosuid(char *); /* Execute as real user */
#endif

View File

@@ -1,8 +1,7 @@
/*****************************************************************************
*
* File ..................: bbs/email.c
* $Id$
* Purpose ...............: Internet email
* Last modification date : 26-Oct-2001
*
*****************************************************************************
* Copyright (C) 1997-2001
@@ -43,8 +42,9 @@
#include "mail.h"
#include "timeout.h"
#include "msgutil.h"
#include "funcs4.h"
#include "input.h"
#include "email.h"
#include "whoson.h"
extern unsigned long LastNum;

View File

@@ -1,8 +1,7 @@
/*****************************************************************************
*
* File ..................: bbs/exitinfo.c
* $Id$
* Purpose ...............: Exitinfo functions
* Last modification date : 26-Oct-2001
*
*****************************************************************************
* Copyright (C) 1997-2001
@@ -36,7 +35,7 @@
#include "../lib/common.h"
#include "../lib/clcomm.h"
#include "funcs.h"
#include "funcs4.h"
#include "input.h"
#include "language.h"
#include "oneline.h"
#include "misc.h"
@@ -46,7 +45,7 @@
#include "exitinfo.h"
extern int LC_Download, LC_Upload, LC_Read, LC_Chat, LC_Olr, LC_Door;
//extern int LC_Download, LC_Upload, LC_Read, LC_Chat, LC_Olr, LC_Door;
/*
@@ -139,276 +138,3 @@ void WriteExitinfo()
}
/*
* Function to display what users are currently On-Line and what they
* are busy doing
*/
void WhosOn(char *OpData)
{
FILE *pExitinfo;
DIR *Directory;
char *Heading, *Underline, *temp, *tmp, *device;
struct dirent *Dir;
int i, x;
Underline = calloc(81, sizeof(char));
Heading = calloc(81, sizeof(char));
temp = calloc(PATH_MAX, sizeof(char));
tmp = calloc(PATH_MAX, sizeof(char));
WhosDoingWhat(WHOSON);
clear();
Enter(1);
colour(15, 0);
sprintf(Heading, "%s%s", (char *) Language(414), CFG.bbs_name);
Center(Heading);
x = strlen(Heading);
for(i = 0; i < x; i++)
sprintf(Underline, "%s%c", Underline, exitinfo.GraphMode ? 196 : 45);
colour(12, 0);
Center(Underline);
printf("\n");
pout(10, 0, (char *) Language(415));
Enter(1);
colour(2, 0);
fLine(79);
sprintf(tmp, "%s/tmp", getenv("MBSE_ROOT"));
if ((Directory = opendir(tmp)) != NULL)
while ((Dir = readdir( Directory )) != NULL)
if((strstr(Dir->d_name, ".bbs-exitinfo.")) != NULL) {
sprintf(temp, "%s/%s", tmp, Dir->d_name);
if(( pExitinfo = fopen(temp, "rb")) != NULL) {
fread(&exitinfo, sizeof(exitinfo), 1, pExitinfo);
colour(11, 0);
if((strcmp(OpData, "/H")) == 0) {
if((strcmp(exitinfo.sHandle, "") != 0 && *(exitinfo.sHandle) != ' '))
printf("%-30s", exitinfo.sHandle);
else
printf("%-30s", exitinfo.sUserName);
} else
printf("%-30s", exitinfo.sUserName);
colour(9, 0);
if((device = strstr(Dir->d_name, "tty")) != NULL)
printf("%-9s", device);
else
printf("%-9s", "None");
colour(15, 0);
/* Browseng */
if(exitinfo.iStatus == BROWSING)
printf("%-15s", (char *) Language(418));
/* Downloading */
else if(exitinfo.iStatus == DOWNLOAD)
printf("%-15s", (char *) Language(419));
/* Uploading */
else if(exitinfo.iStatus == UPLOAD)
printf("%-15s", (char *) Language(420));
/* Msg Section */
else if(exitinfo.iStatus == READ_POST)
printf("%-15s", (char *) Language(421));
/* External Door */
else if(exitinfo.iStatus == DOOR)
printf("%-15s", (char *) Language(422));
/* Chatting */
else if(exitinfo.iStatus == SYSOPCHAT)
printf("%-15s", (char *) Language(423));
/* Listing Files */
else if(exitinfo.iStatus == FILELIST)
printf("%-15s", (char *) Language(424));
/* Banking Door */
else if(exitinfo.iStatus == TIMEBANK)
printf("%-15s", (char *) Language(426));
/* Safe Door */
else if(exitinfo.iStatus == SAFE)
printf("%-15s", (char *) Language(427));
/* WhosOn List */
else if(exitinfo.iStatus == WHOSON)
printf("%-15s", (char *) Language(428));
/* Idle */
else
printf("%s", (char *) Language(429));
colour(12, 0);
printf("%-25s\n", exitinfo.sLocation);
fclose(pExitinfo);
}
}
closedir(Directory);
ReadExitinfo();
colour(2, 0);
fLine(79);
free(tmp);
free(temp);
free(Underline);
free(Heading);
printf("\n");
}
/*
* Function will update users file and and update exitinfo.iStatus
*/
void WhosDoingWhat(int iStatus)
{
char *temp;
temp = calloc(PATH_MAX, sizeof(char));
ReadExitinfo();
exitinfo.iStatus = iStatus;
WriteExitinfo();
switch(iStatus) {
case BROWSING:
strcpy(temp, "Browsing Menus");
break;
case DOWNLOAD:
strcpy(temp, "Downloading");
LC_Download = TRUE;
break;
case UPLOAD:
strcpy(temp, "Uploading");
LC_Upload = TRUE;
break;
case READ_POST:
strcpy(temp, "Read/post Messages");
LC_Read = TRUE;
break;
case DOOR:
strcpy(temp, "External Door");
LC_Door = TRUE;
break;
case SYSOPCHAT:
strcpy(temp, "Sysop Chat");
LC_Chat = TRUE;
break;
case FILELIST:
strcpy(temp, "List Files");
break;
case TIMEBANK:
strcpy(temp, "Time Bank");
LC_Door = TRUE;
break;
case SAFE:
strcpy(temp, "Safe Cracker");
LC_Door = TRUE;
break;
case WHOSON:
strcpy(temp, "View Whoson List");
break;
case OLR:
strcpy(temp, "Offline Reader");
LC_Olr = TRUE;
break;
}
IsDoing(temp);
free(temp);
}
/*
* Function will allow a user to send a on-line message to another user
* It will prompt the user for the username. The message is sent thru
* mbsed, from the resonse message we can see if we succeeded.
*/
void SendOnlineMsg(char *OpData)
{
static char buf[128];
char *User, *String;
User = calloc(36, sizeof(char));
String = calloc(77, sizeof(char));
WhosOn(OpData);
/* Please enter username to send message to: */
pout(3, 0, (char *) Language(430));
colour(CFG.InputColourF, CFG.InputColourB);
fflush(stdout);
GetstrC(User, 35);
if (!strcmp(User, "")) {
free(User);
free(String);
return;
}
/* Please enter message to send (Max 76 Characters) */
pout(10, 0, (char *)Language(433));
pout(10, 0, (char *)"\n> ");
colour(CFG.InputColourF, CFG.InputColourB);
fflush(stdout);
GetstrC(String, 76);
if ((strcmp(String, "")) != 0) {
buf[0] = '\0';
sprintf(buf, "CSPM:3,%s,%s,%s;", strcmp(OpData, "/H") != 0 ? exitinfo.sUserName : \
strcmp(exitinfo.sHandle, "") == 0 ? exitinfo.sUserName : \
exitinfo.sHandle, User, String);
if (socket_send(buf) == 0) {
strcpy(buf, socket_receive());
if (strncmp(buf, "100:1,3;", 8) == 0) {
/* Sorry, there is no user on */
printf("\n%s %s\n\n", (char *) Language(431), User);
}
if (strncmp(buf, "100:1,2;", 8) == 0) {
printf("\nNo more room in users message buffer\n\n");
}
if (strncmp(buf, "100:1,1;", 8) == 0) {
colour(12, 0);
/* doesn't wish to be disturbed */
printf("\n%s %s\n", User, (char *) Language(432));
}
if (strncmp(buf, "100:0;", 6) == 0) {
printf("Message Sent!\n");
Syslog('+', "Online msg to %s: \"%s\"", User, String);
}
}
}
free(User);
free(String);
Pause();
}

View File

@@ -1,13 +1,10 @@
/* $Id$ */
#ifndef _EXITINFO_H
#define _EXITINFO_H
void InitExitinfo(void); /* Create exitinfo */
void ReadExitinfo(void); /* Read Users Config in Memory */
void WriteExitinfo(void); /* Write Users config from memory */
void WhosOn(char *); /* What users are currently online */
void WhosDoingWhat(int); /* Update what user is doing */
void SendOnlineMsg(char *); /* Send On-Line Message to User */
#endif

View File

@@ -1,8 +1,7 @@
/*****************************************************************************
*
* File ..................: bbs/file.c
* $Id$
* Purpose ...............: All the file functions.
* Last modification date : 30-Sep-2001
*
*****************************************************************************
* Copyright (C) 1997-2001
@@ -38,11 +37,12 @@
#include "filesub.h"
#include "file.h"
#include "funcs.h"
#include "funcs4.h"
#include "input.h"
#include "language.h"
#include "misc.h"
#include "timeout.h"
#include "exitinfo.h"
#include "whoson.h"
#include "change.h"

View File

@@ -1,8 +1,7 @@
/*****************************************************************************
*
* File ..................: bbs/filesub.c
* $Id$
* Purpose ...............: All the file sub functions.
* Last modification date : 30-Sep-2001
*
*****************************************************************************
* Copyright (C) 1997-2001
@@ -39,6 +38,7 @@
#include "funcs.h"
#include "language.h"
#include "funcs4.h"
#include "input.h"
#include "misc.h"
#include "timeout.h"
#include "exitinfo.h"

View File

@@ -1,8 +1,7 @@
/*****************************************************************************
*
* File ..................: bbs/funcs.c
* $Id$
* Purpose ...............: Misc functions
* Last modification date : 29-Oct-2001
*
*****************************************************************************
* Copyright (C) 1997-2001
@@ -38,22 +37,24 @@
#include "../lib/msg.h"
#include "../lib/clcomm.h"
#include "funcs.h"
#include "language.h"
#include "funcs4.h"
#include "language.h"
#include "input.h"
#include "oneline.h"
#include "misc.h"
#include "bye.h"
#include "timeout.h"
#include "timecheck.h"
#include "exitinfo.h"
//#include "whoson.h"
#include "mail.h"
#include "email.h"
extern long ActiveMsgs;
extern time_t t_start;
extern int e_pid;
extern char **environ;
//extern time_t t_start;
//extern int e_pid;
//extern char **environ;
/*
@@ -231,388 +232,6 @@ void TimeStats()
char *Gdate(time_t, int);
char *Gdate(time_t tt, int Y2K)
{
static char GLC[15];
struct tm *tm;
tm = localtime(&tt);
if (Y2K)
sprintf(GLC, "%02d-%02d-%04d", tm->tm_mon +1, tm->tm_mday, tm->tm_year + 1900);
else
sprintf(GLC, "%02d-%02d-%02d", tm->tm_mon +1, tm->tm_mday, tm->tm_year % 100);
return (GLC);
}
char *Rdate(char *, int);
char *Rdate(char *ind, int Y2K)
{
static char GLC[15];
memset(&GLC, 0, sizeof(GLC));
GLC[0] = ind[3];
GLC[1] = ind[4];
GLC[2] = '-';
GLC[3] = ind[0];
GLC[4] = ind[1];
GLC[5] = '-';
if (Y2K) {
GLC[6] = ind[6];
GLC[7] = ind[7];
GLC[8] = ind[8];
GLC[9] = ind[9];
} else {
GLC[6] = ind[8];
GLC[7] = ind[9];
}
return GLC;
}
/*
* Function will run a external program or door
*/
void ExtDoor(char *Program, int NoDoorsys, int Y2Kdoorsys, int Comport, int NoSuid)
{
char *String, *String1;
int i, rc;
char *temp1;
FILE *fp;
temp1 = calloc(PATH_MAX, sizeof(char));
String = calloc(81, sizeof(char));
WhosDoingWhat(DOOR);
if ((strstr(Program, "/N")) != NULL) {
sprintf(temp1, "%d", iNode);
strreplace(Program, (char *)"/N", temp1);
}
if ((strstr(Program, "/A")) != NULL) {
colour(3, 0);
if ((String = strstr(Program, "/T=")) != NULL) {
String1 = String + 3;
printf("\n%s", String1);
} else
printf("\nPlease enter filename: ");
fflush(stdout);
colour(CFG.InputColourF, CFG.InputColourB);
GetstrC(temp1, 80);
strreplace(Program, (char *)"/A", temp1);
for(i = 0; i < strlen(Program); i++) {
if (*(Program + i) == '\0')
break;
if (*(Program + i) == '/')
*(Program + i) = '\0';
}
}
free(String);
Syslog('+', "Door: %s", Program);
ReadExitinfo();
alarm_set((exitinfo.iTimeLeft * 60) - 10);
Altime((exitinfo.iTimeLeft * 60));
/*
* Always remove the old door.sys first.
*/
sprintf(temp1, "%s/%s/door.sys", CFG.bbs_usersdir, exitinfo.Name);
unlink(temp1);
/*
* Write door.sys in users homedirectory
*/
if (!NoDoorsys) {
if ((fp = fopen(temp1, "w+")) == NULL) {
WriteError("$Can't create %s", temp1);
} else {
if (Comport) {
fprintf(fp, "COM1:\r\n"); /* COM port */
fprintf(fp, "19200\r\n");/* Effective baudrate */
} else {
fprintf(fp, "COM0:\r\n");/* COM port */
fprintf(fp, "0\r\n"); /* Effective baudrate */
}
fprintf(fp, "8\r\n"); /* Databits */
fprintf(fp, "%d\r\n", iNode); /* Node number */
if (Comport)
fprintf(fp, "19200\r\n");/* Locked baudrate */
else
fprintf(fp, "%ld\r\n", ttyinfo.portspeed); /* Locked baudrate */
fprintf(fp, "Y\r\n"); /* Screen display */
fprintf(fp, "N\r\n"); /* Printer on */
fprintf(fp, "Y\r\n"); /* Page bell */
fprintf(fp, "Y\r\n"); /* Caller alarm */
fprintf(fp, "%s\r\n", exitinfo.sUserName);
fprintf(fp, "%s\r\n", exitinfo.sLocation);
fprintf(fp, "%s\r\n", exitinfo.sVoicePhone);
fprintf(fp, "%s\r\n", exitinfo.sDataPhone);
fprintf(fp, "%s\r\n", exitinfo.Password);
fprintf(fp, "%d\r\n", exitinfo.Security.level);
fprintf(fp, "%d\r\n", exitinfo.iTotalCalls);
fprintf(fp, "%s\r\n", Gdate(exitinfo.tLastLoginDate, Y2Kdoorsys));
fprintf(fp, "%d\r\n", exitinfo.iTimeLeft * 60);
fprintf(fp, "%d\r\n", exitinfo.iTimeLeft);
fprintf(fp, "GR\r\n"); /* ANSI graphics */
fprintf(fp, "%d\r\n", exitinfo.iScreenLen);
fprintf(fp, "N\r\n"); /* User mode, always N */
fprintf(fp, "\r\n"); /* Always blank */
fprintf(fp, "\r\n"); /* Always blank */
fprintf(fp, "%s\r\n", Rdate(exitinfo.sExpiryDate, Y2Kdoorsys));
fprintf(fp, "%d\r\n", grecno); /* Users recordnumber */
fprintf(fp, "%s\r\n", exitinfo.sProtocol);
fprintf(fp, "%ld\r\n", exitinfo.Uploads);
fprintf(fp, "%ld\r\n", exitinfo.Downloads);
fprintf(fp, "%ld\r\n", LIMIT.DownK);
fprintf(fp, "%ld\r\n", LIMIT.DownK);
fprintf(fp, "%s\r\n", Rdate(exitinfo.sDateOfBirth, Y2Kdoorsys));
fprintf(fp, "\r\n"); /* Path to userbase */
fprintf(fp, "\r\n"); /* Path to messagebase */
fprintf(fp, "%s\r\n", CFG.sysop_name);
fprintf(fp, "%s\r\n", exitinfo.sHandle);
fprintf(fp, "none\r\n"); /* Next event time */
fprintf(fp, "Y\r\n"); /* Error free connect. */
fprintf(fp, "N\r\n"); /* Always N */
fprintf(fp, "Y\r\n"); /* Always Y */
fprintf(fp, "7\r\n"); /* Default textcolor */
fprintf(fp, "0\r\n"); /* Always 0 */
fprintf(fp, "%s\r\n", Gdate(exitinfo.tLastLoginDate, Y2Kdoorsys));
fprintf(fp, "%s\r\n", StrTimeHM(t_start));
fprintf(fp, "%s\r\n", LastLoginTime);
fprintf(fp, "32768\r\n"); /* Always 32768 */
fprintf(fp, "%d\r\n", exitinfo.DownloadsToday);
fprintf(fp, "%ld\r\n", exitinfo.UploadK);
fprintf(fp, "%ld\r\n", exitinfo.DownloadK);
fprintf(fp, "%s\r\n", exitinfo.sComment);
fprintf(fp, "0\r\n"); /* Always 0 */
fprintf(fp, "%d\r\n\032", exitinfo.iPosted);
fclose(fp);
}
}
clear();
printf("Loading ...\n\n");
if (NoSuid)
rc = exec_nosuid(Program);
else
rc = execute((char *)"/bin/sh", (char *)"-c", Program, NULL, NULL, NULL);
Altime(0);
alarm_off();
alarm_on();
Syslog('+', "Door end, rc=%d", rc);
free(temp1);
printf("\n\n");
Pause();
}
/*
* Execute a door as real user, not suid.
*/
int exec_nosuid(char *mandato)
{
int rc, status;
pid_t pid;
if (mandato == NULL)
return 1; /* Prevent running a shell */
Syslog('+', "Execve: /bin/sh -c %s", mandato);
pid = fork();
if (pid == -1)
return 1;
if (pid == 0) {
char *argv[4];
argv[0] = (char *)"sh";
argv[1] = (char *)"-c";
argv[2] = mandato;
argv[3] = 0;
execve("/bin/sh", argv, environ);
exit(127);
}
e_pid = pid;
do {
rc = waitpid(pid, &status, 0);
e_pid = 0;
} while (((rc > 0) && (rc != pid)) || ((rc == -1) && (errno == EINTR)));
switch(rc) {
case -1:
WriteError("$Waitpid returned %d, status %d,%d", rc,status>>8,status&0xff);
return -1;
case 0:
return 0;
default:
if (WIFEXITED(status)) {
rc = WEXITSTATUS(status);
if (rc) {
WriteError("Exec_nosuid: returned error %d", rc);
return rc;
}
}
if (WIFSIGNALED(status)) {
rc = WTERMSIG(status);
WriteError("Wait stopped on signal %d", rc);
return rc;
}
if (rc)
WriteError("Wait stopped unknown, rc=%d", rc);
return rc;
}
return 0;
}
/*
* Function will display textfile in either ansi or ascii and
* display control codes if they exist.
* Returns Success if it can display the requested file
*/
int DisplayFile(char *filename)
{
FILE *pFileName;
long iSec = 0;
char *sFileName, *tmp, *tmp1;
char newfile[PATH_MAX];
int i, x;
sFileName = calloc(16385, sizeof(char));
tmp = calloc(PATH_MAX, sizeof(char));
tmp1 = calloc(PATH_MAX, sizeof(char));
/*
* Open the file in the following search order:
* 1 - if GraphMode -> users language .ans
* 2 - if GraphMode -> default language .ans
* 3 - users language .asc
* 4 - default language .asc
* 5 - Abort, there is no file to show.
*/
pFileName = NULL;
if (exitinfo.GraphMode) {
sprintf(newfile, "%s/%s.ans", lang.TextPath, filename);
if ((pFileName = fopen(newfile, "rb")) == NULL) {
sprintf(newfile, "%s/%s.ans", CFG.bbs_txtfiles, filename);
pFileName = fopen(newfile, "rb");
}
}
if (pFileName == NULL) {
sprintf(newfile, "%s/%s.asc", lang.TextPath, filename);
if ((pFileName = fopen(newfile, "rb")) == NULL) {
sprintf(newfile, "%s/%s.asc", CFG.bbs_txtfiles, filename);
if ((pFileName = fopen(newfile, "rb")) == NULL) {
free(sFileName);
free(tmp);
free(tmp1);
return FALSE;
}
}
}
Syslog('B', "Displayfile %s", newfile);
while (!feof(pFileName)) {
i = fread(sFileName, sizeof(char), 16384, pFileName);
for(x = 0; x < i; x++) {
switch(*(sFileName + x)) {
case '':
ControlCodeU(sFileName[++x]);
break;
case '':
ControlCodeF(sFileName[++x]);
break;
case ' ':
ControlCodeK(sFileName[++x]);
break;
case '':
fflush(stdout);
fflush(stdin);
alarm_on();
Getone();
break;
case '':
/*
* This code will allow you to specify a security level
* in front of the text, ie ^B32000^Bthis is a test^B
* will print this is a test only if you have security
* above 32000. Only one set of control chars per line.
* You cannot have multiple securitys etc
*/
x++;
strcpy(tmp1, "");
while (*(sFileName + x) != '') {
sprintf(tmp, "%c", *(sFileName + x));
strcat(tmp1, tmp);
x++;
}
x++;
iSec = atoi(tmp1);
while ((x <= i) && (*(sFileName + x) != '')) {
if (exitinfo.Security.level >= iSec)
printf("%c", *(sFileName + x));
x++;
}
break;
case '':
fflush(stdout);
sleep(1);
break;
default:
printf("%c", *(sFileName + x));
} /* switch */
} /* for */
} /* while !eof */
fclose(pFileName);
free(sFileName);
free(tmp);
free(tmp1);
return TRUE;
}
int DisplayFileEnter(char *File)
{
int rc;
rc = DisplayFile(File);
Enter(1);
/* Press ENTER to continue */
language(13, 0, 436);
fflush(stdout);
fflush(stdin);
alarm_on();
Getone();
return rc;
}
int CheckFile(char *File, int iArea)
{
FILE *pFileB;
@@ -646,311 +265,6 @@ int CheckFile(char *File, int iArea)
void ControlCodeF(int ch)
{
/* Update user info */
ReadExitinfo();
switch (toupper(ch)) {
case '!':
printf(exitinfo.sProtocol);
break;
case 'A':
printf("%ld", exitinfo.Uploads);
break;
case 'B':
printf("%ld", exitinfo.Downloads);
break;
case 'C':
printf("%lu", exitinfo.DownloadK);
break;
case 'D':
printf("%lu", exitinfo.UploadK);
break;
case 'E':
printf("%lu", exitinfo.DownloadK + exitinfo.UploadK);
break;
case 'F':
printf("%lu", LIMIT.DownK);
break;
case 'G':
printf("%d", exitinfo.iTransferTime);
break;
case 'H':
printf("%d", iAreaNumber);
break;
case 'I':
printf(sAreaDesc);
break;
case 'J':
printf("%u", LIMIT.DownF);
break;
case 'K':
printf("%s", LIMIT.Description);
break;
default:
printf(" ");
}
}
void ControlCodeU(int ch)
{
/*
* Update user info
*/
TimeCheck();
ReadExitinfo();
switch (toupper(ch)) {
case 'A':
printf("%s", exitinfo.sUserName);
break;
case 'B':
printf(exitinfo.sLocation);
break;
case 'C':
printf(exitinfo.sVoicePhone);
break;
case 'D':
printf(exitinfo.sDataPhone);
break;
case 'E':
printf(LastLoginDate);
break;
case 'F':
printf("%s %s", StrDateDMY(exitinfo.tFirstLoginDate), StrTimeHMS(exitinfo.tFirstLoginDate));
break;
case 'G':
printf(LastLoginTime);
break;
case 'H':
printf("%d", exitinfo.Security.level);
break;
case 'I':
printf("%d", exitinfo.iTotalCalls);
break;
case 'J':
printf("%d", exitinfo.iTimeUsed);
break;
case 'K':
printf("%d", exitinfo.iConnectTime);
break;
case 'L':
printf("%d", exitinfo.iTimeLeft);
break;
case 'M':
printf("%d", exitinfo.iScreenLen);
break;
case 'N':
printf(FirstName);
break;
case 'O':
printf(LastName);
break;
case 'Q':
printf("%s", exitinfo.ieNEWS ? (char *) Language(147) : (char *) Language(148));
break;
case 'P':
printf("%s", exitinfo.GraphMode ? (char *) Language(147) : (char *) Language(148));
break;
case 'R':
printf("%s", exitinfo.HotKeys ? (char *) Language(147) : (char *) Language(148));
break;
case 'S':
printf("%d", exitinfo.iTimeUsed + exitinfo.iTimeLeft);
break;
case 'T':
printf(exitinfo.sDateOfBirth);
break;
case 'U':
printf("%d", exitinfo.iPosted);
break;
case 'X':
printf(lang.Name);
break;
case 'Y':
printf(exitinfo.sHandle);
break;
case 'Z':
printf("%s", exitinfo.DoNotDisturb ? (char *) Language(147) : (char *) Language(148));
break;
case '1':
printf("%s", exitinfo.MailScan ? (char *) Language(147) : (char *) Language(148));
break;
case '2':
printf("%s", exitinfo.ieFILE ? (char *) Language(147) : (char *) Language(148));
break;
case '3':
printf("%s", exitinfo.FsMsged ? (char *) Language(147) : (char *) Language(148));
break;
case '4':
printf("%s", exitinfo.FSemacs ? (char *) Language(147) : (char *) Language(148));
break;
case '5':
printf(exitinfo.address[0]);
break;
case '6':
printf(exitinfo.address[1]);
break;
case '7':
printf(exitinfo.address[2]);
break;
default:
printf(" ");
}
}
void ControlCodeK(int ch)
{
FILE *pCallerLog;
char sDataFile[PATH_MAX];
lastread LR;
switch (toupper(ch)) {
case 'A':
printf("%s", (char *) GetDateDMY());
break;
case 'B':
printf("%s", (char *) GetLocalHMS());
break;
case 'C':
printf("%s", (char *) GLCdate());
break;
case 'D':
printf("%s", (char *) GLCdateyy());
break;
case 'E':
printf("%d", Speed() );
break;
case 'F':
printf("%s", LastCaller);
break;
case 'G':
printf("%d", TotalUsers());
break;
case 'H':
sprintf(sDataFile, "%s/etc/sysinfo.data", getenv("MBSE_ROOT"));
if((pCallerLog = fopen(sDataFile, "rb")) != NULL) {
fread(&SYSINFO, sizeof(SYSINFO), 1, pCallerLog);
printf("%ld", SYSINFO.SystemCalls);
fclose(pCallerLog);
}
break;
case 'I':
printf("%d", iMsgAreaNumber + 1);
break;
case 'J':
printf(sMsgAreaDesc);
break;
case 'K':
printf("%s", Oneliner_Get());
break;
case 'L':
SetMsgArea(iMsgAreaNumber);
printf("%ld", MsgBase.Total);
break;
case 'M':
LR.UserID = grecno;
if (Msg_Open(sMsgAreaBase)) {
if (Msg_GetLastRead(&LR) == TRUE) {
if (LR.HighReadMsg > MsgBase.Highest)
LR.HighReadMsg = MsgBase.Highest;
printf("%ld", LR.HighReadMsg);
} else
printf("?");
Msg_Close();
}
break;
case 'N':
printf("%s", sMailbox);
break;
case 'O':
SetEmailArea(sMailbox);
printf("%ld", EmailBase.Total);
break;
case 'P':
sprintf(sDataFile, "%s/%s/%s", CFG.bbs_usersdir, exitinfo.Name, sMailbox);
LR.UserID = grecno;
if (Msg_Open(sDataFile)) {
if (Msg_GetLastRead(&LR) == TRUE) {
if (LR.HighReadMsg > EmailBase.Highest)
LR.HighReadMsg = EmailBase.Highest;
printf("%ld", LR.HighReadMsg);
} else
printf("?");
Msg_Close();
}
break;
default:
printf(" ");
}
}
/*
* View a textfile.
*/
@@ -1037,79 +351,4 @@ void LogEntry(char *Log)
/*
* 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).
*/
void SwapDate(char *Date3, char *Date4)
{
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);
}
/*
* Function returns total number of bbs users
*/
int TotalUsers()
{
FILE *pUsrConfig;
int ch = 0;
char *temp;
struct userhdr uhdr;
struct userrec u;
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/etc/users.data", getenv("MBSE_ROOT"));
if(( pUsrConfig = fopen(temp,"rb")) == NULL)
WriteError("ControlCodeK: Can't open users file %s for reading", temp);
else {
fread(&uhdr, sizeof(uhdr), 1, pUsrConfig);
while (fread(&u, uhdr.recsize, 1, pUsrConfig) == 1)
if ((!u.Deleted) && (strlen(u.sUserName) > 0))
ch++;
fclose(pUsrConfig);
}
free(temp);
return ch;
}

View File

@@ -1,4 +1,4 @@
/* funcs.h */
/* $Id$ */
#ifndef _FUNCS_H
#define _FUNCS_H
@@ -6,19 +6,9 @@
int Access(securityrec, securityrec); /* Check security access */
void UserList(char *); /* Get complete users list */
void TimeStats(void); /* Get users Time Statistics */
void ExtDoor(char *, int, int, int, int); /* Run external door */
int exec_nosuid(char *); /* Execute as real user */
int DisplayFile(char *); /* Display .ans/.asc textfile */
int DisplayFileEnter(char *); /* Display .ans/.asc wait for Enter */
int CheckFile(char *, int); /* Check for Dupe file in Database */
void ControlCodeF(int); /* Check Control Codes in File */
void ControlCodeU(int); /* Check Control Codes in File */
void ControlCodeK(int); /* Check Control Codes in File */
void ViewTextFile(char *); /* View text file */
void LogEntry(char *); /* Create log entry in logfile */
void SwapDate(char *, char *); /* Swap two Date strings around */
int TotalUsers(void); /* Returns total numbers of users */
#endif

View File

@@ -36,6 +36,7 @@
#include "../lib/common.h"
#include "../lib/msg.h"
#include "funcs4.h"
#include "input.h"
#include "misc.h"
#include "timeout.h"
#include "language.h"
@@ -76,441 +77,6 @@ int CheckStatus()
/*
* Get a character string with cursor position
*/
void GetstrP(char *sStr, int iMaxLen, int Position)
{
unsigned char ch = 0;
int iPos = Position;
if ((ttyfd = open("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
perror("open 1");
return;
}
Setraw();
alarm_on();
while (ch != KEY_ENTER) {
fflush(stdout);
ch = Readkey();
if ((ch == KEY_BACKSPACE) || (ch == KEY_DEL) || (ch == KEY_RUBOUT)) {
if (iPos > 0) {
printf("\b \b");
sStr[--iPos] = '\0';
} else
putchar('\007');
}
if (ch > 31 && ch < 127) {
if (iPos <= iMaxLen) {
iPos++;
sprintf(sStr, "%s%c", sStr, ch);
printf("%c", ch);
} else
putchar('\007');
}
}
Unsetraw();
close(ttyfd);
printf("\n");
}
/*
* Get a character string
*/
void GetstrC(char *sStr, int iMaxlen)
{
unsigned char ch = 0;
int iPos = 0;
fflush(stdout);
if ((ttyfd = open ("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
perror("open 6");
return;
}
Setraw();
strcpy(sStr, "");
alarm_on();
while (ch != 13) {
fflush(stdout);
ch = Readkey();
if ((ch == 8) || (ch == KEY_DEL) || (ch == 127)) {
if (iPos > 0) {
printf("\b \b");
sStr[--iPos] = '\0';
} else
putchar('\007');
}
if (ch > 31 && ch < 127) {
if (iPos <= iMaxlen) {
iPos++;
sprintf(sStr, "%s%c", sStr, ch);
printf("%c", ch);
} else
putchar('\007');
}
}
Unsetraw();
close(ttyfd);
printf("\n");
}
/*
* get a string, don't allow spaces (for Unix accounts)
*/
void GetstrU(char *sStr, int iMaxlen)
{
unsigned char ch = 0;
int iPos = 0;
fflush(stdout);
if ((ttyfd = open ("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
perror("open 6");
return;
}
Setraw();
strcpy(sStr, "");
alarm_on();
while (ch != 13) {
fflush(stdout);
ch = Readkey();
if ((ch == 8) || (ch == KEY_DEL) || (ch == 127)) {
if (iPos > 0) {
printf("\b \b");
sStr[--iPos] = '\0';
} else
putchar('\007');
}
if (isalnum(ch) || (ch == '@') || (ch == '.')) {
if (iPos <= iMaxlen) {
iPos++;
sprintf(sStr, "%s%c", sStr, ch);
printf("%c", ch);
} else
putchar('\007');
}
}
Unsetraw();
close(ttyfd);
printf("\n");
}
/*
* Get a phone number, only allow digits, + and - characters.
*/
void GetPhone(char *sStr, int iMaxlen)
{
unsigned char ch = 0;
int iPos = 0;
fflush(stdout);
if ((ttyfd = open ("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
perror("open 5");
return;
}
Setraw();
strcpy(sStr, "");
alarm_on();
while (ch != 13) {
fflush(stdout);
ch = Readkey();
if ((ch == 8) || (ch == KEY_DEL) || (ch == 127)) {
if (iPos > 0) {
printf("\b \b");
sStr[--iPos]='\0';
} else
putchar('\007');
}
if ((ch >= '0' && ch <= '9') || (ch == '-') || (ch == '+')) {
if (iPos <= iMaxlen) {
iPos++;
sprintf(sStr, "%s%c", sStr, ch);
printf("%c", ch);
} else
putchar('\007');
}
}
Unsetraw();
close(ttyfd);
printf("\n");
}
/*
* Get a number, allow digits, spaces, minus sign, points and comma's
*/
void Getnum(char *sStr, int iMaxlen)
{
unsigned char ch = 0;
int iPos = 0;
fflush(stdout);
if ((ttyfd = open ("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
perror("open 5");
return;
}
Setraw();
strcpy(sStr, "");
alarm_on();
while (ch != 13) {
fflush(stdout);
ch = Readkey();
if ((ch == 8) || (ch == KEY_DEL) || (ch == 127)) {
if (iPos > 0) {
printf("\b \b");
sStr[--iPos]='\0';
} else
putchar('\007');
}
if ((ch >= '0' && ch <= '9') || (ch == '-') || (ch == ' ') \
|| (ch == ',') || (ch == '.')) {
if (iPos <= iMaxlen) {
iPos++;
sprintf(sStr, "%s%c", sStr, ch);
printf("%c", ch);
} else
putchar('\007');
}
}
Unsetraw();
close(ttyfd);
printf("\n");
}
/*
* This function gets the date from the user checking the length and
* putting two minus signs in the right places
*/
void GetDate(char *sStr, int iMaxlen)
{
unsigned char ch = 0;
int iPos = 0;
fflush(stdout);
strcpy(sStr, "");
if ((ttyfd = open ("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
perror("open 4");
return;
}
Setraw();
alarm_on();
while (ch != 13) {
fflush(stdout);
ch = Readkey();
if ((ch == 8) || (ch == KEY_DEL) || (ch == 127)) {
if (iPos > 0)
printf("\b \b");
else
putchar('\007');
if (iPos == 3 || iPos == 6) {
printf("\b \b");
--iPos;
}
sStr[--iPos]='\0';
}
if (ch >= '0' && ch <= '9') {
if (iPos < iMaxlen) {
iPos++;
sprintf(sStr, "%s%c", sStr, ch);
printf("%c", ch);
if (iPos == 2 || iPos == 5) {
printf("-");
sprintf(sStr, "%s-", sStr);
iPos++;
}
} else
putchar('\007');
}
}
Unsetraw();
close(ttyfd);
printf("\n");
}
/*
* Get a string, capitalize only if set in config.
*/
void Getname(char *sStr, int iMaxlen)
{
unsigned char ch = 0;
int iPos = 0, iNewPos = 0;
fflush(stdout);
strcpy(sStr, "");
if ((ttyfd = open ("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
perror("open 2");
return;
}
Setraw();
alarm_on();
while (ch != 13) {
fflush(stdout);
ch = Readkey();
if ((ch == 8) || (ch == KEY_DEL) || (ch == 127)) {
if (iPos > 0) {
printf("\b \b");
sStr[--iPos]='\0';
} else
putchar('\007');
}
if (ch > 31 && (ch < 127)) {
if (iPos < iMaxlen) {
iPos++;
if (iPos == 1 && CFG.iCapUserName)
ch = toupper(ch);
if (ch == 32) {
iNewPos = iPos;
iNewPos++;
}
if (iNewPos == iPos && CFG.iCapUserName)
ch = toupper(ch);
else
if (CFG.iCapUserName)
ch = tolower(ch);
if (iPos == 1 && CFG.iCapUserName)
ch = toupper(ch);
sprintf(sStr, "%s%c", sStr, ch);
printf("%c", ch);
} else
putchar('\007');
}
}
Unsetraw();
close(ttyfd);
printf("\n");
}
/*
* Get a Fidonet style username, always capitalize.
*/
void GetnameNE(char *sStr, int iMaxlen)
{
unsigned char ch = 0;
int iPos = 0, iNewPos = 0;
fflush(stdout);
strcpy(sStr, "");
if ((ttyfd = open ("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
perror("open 2");
return;
}
Setraw();
alarm_on();
while (ch != 13) {
fflush(stdout);
ch = Readkey();
if ((ch == 8) || (ch == KEY_DEL) || (ch == 127)) {
if (iPos > 0) {
printf("\b \b");
sStr[--iPos]='\0';
} else
putchar('\007');
}
if (ch > 31 && ch < 127) {
if (iPos < iMaxlen) {
iPos++;
if (iPos == 1)
ch = toupper(ch);
if (ch == 32) {
iNewPos = iPos;
iNewPos++;
}
if (iNewPos == iPos)
ch = toupper(ch);
else
ch = tolower(ch);
if (iPos == 1)
ch = toupper(ch);
sprintf(sStr, "%s%c", sStr, ch);
printf("%c", ch);
} else
putchar('\007');
}
}
Unsetraw();
close(ttyfd);
printf("\n");
}
/*
* Function will Scan Users Database for existing phone numbers. If
* found, it will write a log entry to the logfile. The user WILL NOT
@@ -549,39 +115,6 @@ int TelephoneScan(char *Number, char *Name)
void Pause()
{
int i, x;
char *string;
string = malloc(81);
/* Press (Enter) to continue: */
sprintf(string, "\r%s", (char *) Language(375));
colour(CFG.CRColourF, CFG.CRColourB);
printf(string);
do {
fflush(stdout);
fflush(stdin);
alarm_on();
i = Getone();
} while ((i != '\r') && (i != '\n'));
x = strlen(string);
for(i = 0; i < x; i++)
printf("\b");
for(i = 0; i < x; i++)
printf(" ");
for(i = 0; i < x; i++)
printf("\b");
fflush(stdout);
free(string);
}
/*
* Function to check if UserName exists and returns a 0 or 1
*/

View File

@@ -1,19 +1,12 @@
/* $Id$ */
#ifndef _FUNCS4_H
#define _FUNCS4_H
void UserSilent(int); /* Update users silent flag info */
int CheckStatus(void); /* Check BBS open status */
void GetstrU(char *, int); /* Get string, forbid spaces */
void GetstrP(char *, int, int); /* Get string with cursor position */
void GetstrC(char *, int); /* Get string, length, clear string */
void Getnum(char *, int); /* Get only numbers from user */
void Getname(char *, int); /* Get name & convert every 1st char to U/C */
void GetnameNE(char *, int); /* Get name & convert every 1st char to U/C */
void GetDate(char *, int); /* Get users birth date and check */
void GetPhone(char *, int); /* Get telephone number */
int TelephoneScan(char *, char *);/* Scans for Duplicate User Phone Numbers */
void Pause(void); /* Puts Pause on Screen and halts screen */
int CheckName(char *); /* Check if user name exists */
char *logdate(void); /* Returns DD-Mon HH:MM:SS */
char *NameGen(char *); /* Get and test for unix login */
@@ -29,4 +22,3 @@ char *GetMonth(int); /* Returns Mmm */
#endif

510
mbsebbs/input.c Normal file
View File

@@ -0,0 +1,510 @@
/*****************************************************************************
*
* $Id$
* Purpose ...............: Input functions, also for some utils.
*
*****************************************************************************
* Copyright (C) 1997-2001
*
* 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
* Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*****************************************************************************/
#include "../lib/libs.h"
#include "../lib/mbse.h"
#include "../lib/structs.h"
#include "../lib/records.h"
#include "../lib/clcomm.h"
#include "../lib/common.h"
#include "input.h"
#include "timeout.h"
#include "language.h"
/*
* Get a character string with cursor position
*/
void GetstrP(char *sStr, int iMaxLen, int Position)
{
unsigned char ch = 0;
int iPos = Position;
if ((ttyfd = open("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
perror("open 1");
return;
}
Setraw();
alarm_on();
while (ch != KEY_ENTER) {
fflush(stdout);
ch = Readkey();
if ((ch == KEY_BACKSPACE) || (ch == KEY_DEL) || (ch == KEY_RUBOUT)) {
if (iPos > 0) {
printf("\b \b");
sStr[--iPos] = '\0';
} else
putchar('\007');
}
if (ch > 31 && ch < 127) {
if (iPos <= iMaxLen) {
iPos++;
sprintf(sStr, "%s%c", sStr, ch);
printf("%c", ch);
} else
putchar('\007');
}
}
Unsetraw();
close(ttyfd);
printf("\n");
}
/*
* Get a character string
*/
void GetstrC(char *sStr, int iMaxlen)
{
unsigned char ch = 0;
int iPos = 0;
fflush(stdout);
if ((ttyfd = open ("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
perror("open 6");
return;
}
Setraw();
strcpy(sStr, "");
alarm_on();
while (ch != 13) {
fflush(stdout);
ch = Readkey();
if ((ch == 8) || (ch == KEY_DEL) || (ch == 127)) {
if (iPos > 0) {
printf("\b \b");
sStr[--iPos] = '\0';
} else
putchar('\007');
}
if (ch > 31 && ch < 127) {
if (iPos <= iMaxlen) {
iPos++;
sprintf(sStr, "%s%c", sStr, ch);
printf("%c", ch);
} else
putchar('\007');
}
}
Unsetraw();
close(ttyfd);
printf("\n");
}
/*
* get a string, don't allow spaces (for Unix accounts)
*/
void GetstrU(char *sStr, int iMaxlen)
{
unsigned char ch = 0;
int iPos = 0;
fflush(stdout);
if ((ttyfd = open ("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
perror("open 6");
return;
}
Setraw();
strcpy(sStr, "");
alarm_on();
while (ch != 13) {
fflush(stdout);
ch = Readkey();
if ((ch == 8) || (ch == KEY_DEL) || (ch == 127)) {
if (iPos > 0) {
printf("\b \b");
sStr[--iPos] = '\0';
} else
putchar('\007');
}
if (isalnum(ch) || (ch == '@') || (ch == '.')) {
if (iPos <= iMaxlen) {
iPos++;
sprintf(sStr, "%s%c", sStr, ch);
printf("%c", ch);
} else
putchar('\007');
}
}
Unsetraw();
close(ttyfd);
printf("\n");
}
/*
* Get a phone number, only allow digits, + and - characters.
*/
void GetPhone(char *sStr, int iMaxlen)
{
unsigned char ch = 0;
int iPos = 0;
fflush(stdout);
if ((ttyfd = open ("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
perror("open 5");
return;
}
Setraw();
strcpy(sStr, "");
alarm_on();
while (ch != 13) {
fflush(stdout);
ch = Readkey();
if ((ch == 8) || (ch == KEY_DEL) || (ch == 127)) {
if (iPos > 0) {
printf("\b \b");
sStr[--iPos]='\0';
} else
putchar('\007');
}
if ((ch >= '0' && ch <= '9') || (ch == '-') || (ch == '+')) {
if (iPos <= iMaxlen) {
iPos++;
sprintf(sStr, "%s%c", sStr, ch);
printf("%c", ch);
} else
putchar('\007');
}
}
Unsetraw();
close(ttyfd);
printf("\n");
}
/*
* Get a number, allow digits, spaces, minus sign, points and comma's
*/
void Getnum(char *sStr, int iMaxlen)
{
unsigned char ch = 0;
int iPos = 0;
fflush(stdout);
if ((ttyfd = open ("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
perror("open 5");
return;
}
Setraw();
strcpy(sStr, "");
alarm_on();
while (ch != 13) {
fflush(stdout);
ch = Readkey();
if ((ch == 8) || (ch == KEY_DEL) || (ch == 127)) {
if (iPos > 0) {
printf("\b \b");
sStr[--iPos]='\0';
} else
putchar('\007');
}
if ((ch >= '0' && ch <= '9') || (ch == '-') || (ch == ' ') \
|| (ch == ',') || (ch == '.')) {
if (iPos <= iMaxlen) {
iPos++;
sprintf(sStr, "%s%c", sStr, ch);
printf("%c", ch);
} else
putchar('\007');
}
}
Unsetraw();
close(ttyfd);
printf("\n");
}
/*
* This function gets the date from the user checking the length and
* putting two minus signs in the right places
*/
void GetDate(char *sStr, int iMaxlen)
{
unsigned char ch = 0;
int iPos = 0;
fflush(stdout);
strcpy(sStr, "");
if ((ttyfd = open ("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
perror("open 4");
return;
}
Setraw();
alarm_on();
while (ch != 13) {
fflush(stdout);
ch = Readkey();
if ((ch == 8) || (ch == KEY_DEL) || (ch == 127)) {
if (iPos > 0)
printf("\b \b");
else
putchar('\007');
if (iPos == 3 || iPos == 6) {
printf("\b \b");
--iPos;
}
sStr[--iPos]='\0';
}
if (ch >= '0' && ch <= '9') {
if (iPos < iMaxlen) {
iPos++;
sprintf(sStr, "%s%c", sStr, ch);
printf("%c", ch);
if (iPos == 2 || iPos == 5) {
printf("-");
sprintf(sStr, "%s-", sStr);
iPos++;
}
} else
putchar('\007');
}
}
Unsetraw();
close(ttyfd);
printf("\n");
}
/*
* Get a string, capitalize only if set in config.
*/
void Getname(char *sStr, int iMaxlen)
{
unsigned char ch = 0;
int iPos = 0, iNewPos = 0;
fflush(stdout);
strcpy(sStr, "");
if ((ttyfd = open ("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
perror("open 2");
return;
}
Setraw();
alarm_on();
while (ch != 13) {
fflush(stdout);
ch = Readkey();
if ((ch == 8) || (ch == KEY_DEL) || (ch == 127)) {
if (iPos > 0) {
printf("\b \b");
sStr[--iPos]='\0';
} else
putchar('\007');
}
if (ch > 31 && (ch < 127)) {
if (iPos < iMaxlen) {
iPos++;
if (iPos == 1 && CFG.iCapUserName)
ch = toupper(ch);
if (ch == 32) {
iNewPos = iPos;
iNewPos++;
}
if (iNewPos == iPos && CFG.iCapUserName)
ch = toupper(ch);
else
if (CFG.iCapUserName)
ch = tolower(ch);
if (iPos == 1 && CFG.iCapUserName)
ch = toupper(ch);
sprintf(sStr, "%s%c", sStr, ch);
printf("%c", ch);
} else
putchar('\007');
}
}
Unsetraw();
close(ttyfd);
printf("\n");
}
/*
* Get a Fidonet style username, always capitalize.
*/
void GetnameNE(char *sStr, int iMaxlen)
{
unsigned char ch = 0;
int iPos = 0, iNewPos = 0;
fflush(stdout);
strcpy(sStr, "");
if ((ttyfd = open ("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
perror("open 2");
return;
}
Setraw();
alarm_on();
while (ch != 13) {
fflush(stdout);
ch = Readkey();
if ((ch == 8) || (ch == KEY_DEL) || (ch == 127)) {
if (iPos > 0) {
printf("\b \b");
sStr[--iPos]='\0';
} else
putchar('\007');
}
if (ch > 31 && ch < 127) {
if (iPos < iMaxlen) {
iPos++;
if (iPos == 1)
ch = toupper(ch);
if (ch == 32) {
iNewPos = iPos;
iNewPos++;
}
if (iNewPos == iPos)
ch = toupper(ch);
else
ch = tolower(ch);
if (iPos == 1)
ch = toupper(ch);
sprintf(sStr, "%s%c", sStr, ch);
printf("%c", ch);
} else
putchar('\007');
}
}
Unsetraw();
close(ttyfd);
printf("\n");
}
void Pause()
{
int i, x;
char *string;
string = malloc(81);
/* Press (Enter) to continue: */
sprintf(string, "\r%s", (char *) Language(375));
colour(CFG.CRColourF, CFG.CRColourB);
printf(string);
do {
fflush(stdout);
fflush(stdin);
alarm_on();
i = Getone();
} while ((i != '\r') && (i != '\n'));
x = strlen(string);
for(i = 0; i < x; i++)
printf("\b");
for(i = 0; i < x; i++)
printf(" ");
for(i = 0; i < x; i++)
printf("\b");
fflush(stdout);
free(string);
}

18
mbsebbs/input.h Normal file
View File

@@ -0,0 +1,18 @@
/* $Id$ */
#ifndef _INPUT_H
#define _INPUT_H
void GetstrU(char *, int); /* Get string, forbid spaces */
void GetstrP(char *, int, int); /* Get string with cursor position */
void GetstrC(char *, int); /* Get string, length, clear string */
void Getnum(char *, int); /* Get only numbers from user */
void Getname(char *, int); /* Get name & convert every 1st char to U/C */
void GetnameNE(char *, int); /* Get name & convert every 1st char to U/C */
void GetDate(char *, int); /* Get users birth date and check */
void GetPhone(char *, int); /* Get telephone number */
void Pause(void); /* Puts Pause on Screen and halts screen */
#endif

View File

@@ -1,8 +1,7 @@
/*****************************************************************************
*
* File ..................: bbs/language.c
* $Id$
* Purpose ...............: Language functions.
* Last modification date : 28-Jun-2001
*
*****************************************************************************
* Copyright (C) 1997-2001
@@ -35,7 +34,7 @@
#include "../lib/records.h"
#include "../lib/common.h"
#include "../lib/clcomm.h"
#include "funcs4.h"
#include "input.h"
#include "language.h"

View File

@@ -1,14 +1,13 @@
/*****************************************************************************
*
* File ..................: bbs/lineedit.c
* $Id$
* Purpose ...............: Message line editor.
* Last modification date : 06-Jul-1999
*
*****************************************************************************
* Copyright (C) 1997-1999
* Copyright (C) 1997-2001
*
* Michiel Broek FIDO: 2:2801/16
* Beekmansbos 10 Internet: mbroek@ux123.pttnwb.nl
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
* 1971 BV IJmuiden
* the Netherlands
*
@@ -36,7 +35,7 @@
#include "../lib/common.h"
#include "../lib/clcomm.h"
#include "mail.h"
#include "funcs4.h"
#include "input.h"
#include "language.h"
#include "timeout.h"
#include "lineedit.h"

View File

@@ -45,7 +45,7 @@
#include "../lib/msg.h"
#include "mail.h"
#include "funcs.h"
#include "funcs4.h"
#include "input.h"
#include "language.h"
#include "misc.h"
#include "timeout.h"
@@ -57,6 +57,7 @@
#include "msgutil.h"
#include "pop3.h"
#include "email.h"
#include "whoson.h"

227
mbsebbs/mbnewusr.c Normal file
View File

@@ -0,0 +1,227 @@
/*****************************************************************************
*
* $Id$
* Purpose ...............: New user registration
*
*****************************************************************************
* Copyright (C) 1997-2001
*
* 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
* Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*****************************************************************************/
#include "../lib/libs.h"
#include "../lib/mbse.h"
#include "../lib/structs.h"
#include "../lib/records.h"
#include "../lib/common.h"
#include "../lib/clcomm.h"
#include "mbnewusr.h"
#include "funcs.h"
#include "funcs4.h"
#include "input.h"
#include "language.h"
#include "misc.h"
#include "bye.h"
#include "timeout.h"
#include "newuser.h"
extern int do_quiet; /* Logging quiet flag */
time_t t_start;
char *StartTime;
int main(int argc, char **argv)
{
char *p, *tty;
FILE *pTty;
int i;
char temp[PATH_MAX];
struct passwd *pw;
#ifdef MEMWATCH
mwInit();
#endif
printf("Loading MBSE BBS New User Registration ...\n");
pTTY = calloc(15, sizeof(char));
tty = ttyname(1);
/*
* Get MBSE_ROOT Path and load Config into Memory
*/
FindMBSE();
if (!strlen(CFG.startname)) {
printf("FATAL: No bbs startname, edit mbsetup 1.2.10\n");
#ifdef MEMWATCH
mwTerm();
#endif
exit(1);
}
/*
* Set uid and gid to the "mbse" user.
*/
if ((pw = getpwnam((char *)"mbse")) == NULL) {
perror("Can't find user \"mbse\" in /etc/passwd");
#ifdef MEMWATCH
mwTerm();
#endif
exit(1);
}
if ((setuid(pw->pw_uid) == -1) || (setgid(pw->pw_gid) == -1)) {
perror("Can't setuid() or setgid() to \"mbse\" user");
#ifdef MEMWATCH
mwTerm();
#endif
exit(1);
}
/*
* Set local time and statistic indexes.
*/
time(&Time_Now);
time(&t_start);
l_date = localtime(&Time_Now);
Diw = l_date->tm_wday;
Miy = l_date->tm_mon;
time(&ltime);
/*
* Initialize this client with the server. We don't know
* who is at the other end of the line, so that's what we tell.
*/
do_quiet = TRUE;
InitClient((char *)"Unknown", (char *)"mbnewusr", (char *)"Unknown", CFG.logfile, CFG.bbs_loglevel, CFG.error_log);
IsDoing("Loging in");
Syslog(' ', " ");
Syslog(' ', "MBNEWUSR v%s", VERSION);
if ((p = getenv("CONNECT")) != NULL)
Syslog('+', "CONNECT %s", p);
if ((p = getenv("CALLER_ID")) != NULL)
if (!strncmp(p, "none", 4))
Syslog('+', "CALLER %s", p);
sUnixName[0] = '\0';
/*
* Initialize
*/
InitLanguage();
if ((tty = ttyname(0)) == NULL) {
WriteError("Not at a tty");
Quick_Bye(0);
}
if (strncmp("/dev/", tty, 5) == 0)
sprintf(pTTY, "%s", tty+5);
else if (*tty == '/') {
tty = strrchr(ttyname(0), '/');
++tty;
sprintf(pTTY, "%s", tty);
}
umask(007);
/*
* Trap signals
*/
for(i = 0; i < NSIG; i++) {
if ((i == SIGHUP) || (i == SIGBUS) || (i == SIGILL) ||
(i == SIGSEGV) || (i == SIGTERM) || (i == SIGKILL))
signal(i, (void (*))die);
else
signal(i, SIG_IGN);
}
/*
* Default set the terminal to ANSI mode. If your logo
* is in color, the user will see color no mather what.
*/
TermInit(1);
/*
* Now it's time to check if the bbs is open. If not, we
* log the user off.
*/
if (CheckStatus() == FALSE) {
Syslog('+', "Kicking user out, the BBS is closed");
Quick_Bye(0);
}
clear();
DisplayLogo();
colour(YELLOW, BLACK);
printf("MBSE BBS v%s (Release: %s)\n", VERSION, ReleaseDate);
colour(WHITE, BLACK);
printf("%s\n\n", COPYRIGHT);
/*
* Check if this port is available.
*/
sprintf(temp, "%s/etc/ttyinfo.data", getenv("MBSE_ROOT"));
iNode = 0;
if ((pTty = fopen(temp, "r")) == NULL) {
WriteError("Can't read %s", temp);
} else {
fread(&ttyinfohdr, sizeof(ttyinfohdr), 1, pTty);
while (fread(&ttyinfo, ttyinfohdr.recsize, 1, pTty) == 1) {
iNode++;
if (strcmp(ttyinfo.tty, pTTY) == 0)
break;
}
fclose(pTty);
if ((strcmp(ttyinfo.tty, pTTY) != 0) || (!ttyinfo.available)) {
Syslog('+', "No BBS allowed on port \"%s\"", pTTY);
printf("No BBS on this port allowed!\n\n");
Quick_Bye(0);
}
Syslog('b', "Node number %d", iNode);
/*
* Ask whether to display Connect String
*/
if (CFG.iConnectString) {
/* Connected on port */
colour(CYAN, BLACK);
printf("%s\"%s\" ", (char *) Language(348), ttyinfo.comment);
/* on */
printf("%s %s\n", (char *) Language(135), ctime(&ltime));
}
}
alarm_on();
Pause();
newuser();
Quick_Bye(0);
return 0;
}

10
mbsebbs/mbnewusr.h Normal file
View File

@@ -0,0 +1,10 @@
/* $Id$ */
#ifndef _MBNEWUSR_H
#define _MBNEWUSR_H
#define ReleaseDate __DATE__
#endif

View File

@@ -37,7 +37,7 @@
#include "../lib/msg.h"
#include "mbsebbs.h"
#include "user.h"
#include "funcs.h"
#include "dispfile.h"
#include "funcs4.h"
#include "language.h"
#include "menu.h"
@@ -57,7 +57,6 @@ int main(int argc, char **argv)
char *p, *tty;
int i;
char temp[PATH_MAX];
struct passwd *pw;
#ifdef MEMWATCH
mwInit();
@@ -76,31 +75,6 @@ int main(int argc, char **argv)
* Get MBSE_ROOT Path and load Config into Memory
*/
FindMBSE();
if (!strlen(CFG.startname)) {
printf("FATAL: No bbs startname, edit mbsetup 1.1.10\n");
#ifdef MEMWATCH
mwTerm();
#endif
exit(1);
}
/*
* Set uid and gid to the "mbse" user.
*/
if ((pw = getpwnam((char *)"mbse")) == NULL) {
perror("Can't find user \"mbse\" in /etc/passwd");
#ifdef MEMWATCH
mwTerm();
#endif
exit(1);
}
if ((setuid(pw->pw_uid) == -1) || (setgid(pw->pw_gid) == -1)) {
perror("Can't setuid() or setgid() to \"mbse\" user");
#ifdef MEMWATCH
mwTerm();
#endif
exit(1);
}
/*
* Set local time and statistic indexes.
@@ -113,11 +87,10 @@ int main(int argc, char **argv)
time(&ltime);
/*
* Initialize this client with the server. We don't know
* who is at the other end of the line, so that's what we tell.
* Initialize this client with the server.
*/
do_quiet = TRUE;
InitClient((char *)"Unknown", (char *)"mbsebbs", (char *)"Unknown", CFG.logfile, CFG.bbs_loglevel, CFG.error_log);
InitClient(getenv("LOGNAME"), (char *)"mbsebbs", (char *)"Unknown", CFG.logfile, CFG.bbs_loglevel, CFG.error_log);
IsDoing("Loging in");
Syslog(' ', " ");
@@ -130,13 +103,11 @@ int main(int argc, char **argv)
Syslog('+', "CALLER %s", p);
sUnixName[0] = '\0';
if (argc == 3) {
iUnixMode = TRUE;
strcpy(sUnixName, argv[2]);
} else if ((getenv("LOGNAME") != NULL) && (strcmp(getenv("LOGNAME"), CFG.startname))) {
iUnixMode = TRUE;
if (getenv("LOGNAME") != NULL) {
strcpy(sUnixName, getenv("LOGNAME"));
} else {
WriteError("No username in environment");
Quick_Bye(0);
}
/*
@@ -161,7 +132,7 @@ int main(int argc, char **argv)
sprintf(pTTY, "%s", tty);
}
umask(000);
umask(007);
/*
* Trap signals

View File

@@ -43,6 +43,7 @@
#include "file.h"
#include "funcs.h"
#include "funcs4.h"
#include "input.h"
#include "misc.h"
#include "nextuser.h"
#include "safe.h"
@@ -52,10 +53,13 @@
#include "pinfo.h"
#include "bye.h"
#include "timecheck.h"
#include "exitinfo.h"
#include "whoson.h"
#include "language.h"
#include "offline.h"
#include "email.h"
#include "door.h"
#include "dispfile.h"
/*

View File

@@ -36,6 +36,7 @@
#include "../lib/common.h"
#include "funcs.h"
#include "funcs4.h"
#include "input.h"
#include "language.h"
#include "misc.h"
#include "timeout.h"

View File

@@ -1,9 +1,8 @@
/*****************************************************************************
*
* File ..................: mbsebbs/newuser.c
* $Id$
* Purpose ...............: New User login under Unix, creates both
* BBS and unix accounts.
* Last modification date : 27-Oct-2001
*
*****************************************************************************
* Copyright (C) 1997-2001
@@ -36,40 +35,42 @@
#include "../lib/records.h"
#include "../lib/clcomm.h"
#include "../lib/common.h"
//#include "funcs.h"
#include "funcs4.h"
#include "input.h"
#include "pwcheck.h"
#include "newuser.h"
#include "language.h"
#include "timeout.h"
#include "change.h"
#include "bye.h"
#include "dispfile.h"
extern int do_quiet; /* No logging to the screen */
extern pid_t mypid; /* Pid of this program */
char UnixName[9]; /* Unix Name */
extern int ieLogin; /* IEMSI Login Successfull */
extern int ieRows; /* Rows on screen */
extern int ieHOT; /* Use Hotkeys */
extern char *ieHandle; /* Users Handle */
extern char *ieLocation; /* Users Location */
extern char *Passwd; /* Plain password */
int newuser(char *FullName)
int newuser()
{
FILE *pUsrConfig;
int i, x, Found, iLang, recno = 0;
int i, x, Found, iLang, recno = 0, Count = 0;
unsigned long crc;
char temp[PATH_MAX];
char temp[PATH_MAX], *FullName;
char *temp1, *temp2;
char *Phone1, *Phone2;
long offset;
struct userrec us;
int badname;
IsDoing("New user login");
Syslog('+', "Newuser registration");
clear();
DisplayFile((char *)"newuser");
iLang = Chg_Language(TRUE);
Enter(1);
@@ -77,8 +78,6 @@ int newuser(char *FullName)
language(CYAN, BLACK, 37);
Enter(2);
Syslog('+', "Name entered: %s", FullName);
memset(&usrconfig, 0, sizeof(usrconfig));
memset(&exitinfo, 0, sizeof(exitinfo));
@@ -86,92 +85,94 @@ int newuser(char *FullName)
temp2 = calloc(81, sizeof(char));
Phone1 = calloc(81, sizeof(char));
Phone2 = calloc(81, sizeof(char));
FullName = calloc(81, sizeof(char));
usrconfig.iLanguage = iLang;
usrconfig.FsMsged = TRUE;
do {
/* Please enter your First and Last name: */
language(CYAN, BLACK, 0);
fflush(stdout);
alarm_on();
Getname(temp, 35);
strcpy(FullName, tlcap(temp));
Syslog('+', "Name entered: %s", FullName);
/*
* Secret escape name
*/
if ((strcasecmp(temp, "off")) == 0) {
Syslog('+', "Quick \"off\" logout");
Quick_Bye(0);
}
Count++;
if (Count >= CFG.iCRLoginCount) {
Enter(1);
/* Disconnecting user ... */
language(CFG.HiliteF, CFG.HiliteB, 2);
Enter(2);
Syslog('!', "Exceeded maximum login attempts");
Quick_Bye(0);
}
/*
* Check name, duplicate names, unwanted names, single names, they all get
* the same errormessage.
*/
badname = (BadNames(temp) || (CheckName(temp) || (strchr(temp, ' ') == NULL)));
if (badname) {
language(LIGHTRED, BLACK, 386);
Enter(1);
}
} while (badname);
strcpy(FullName, tlcap(temp));
UserCity(mypid, FullName, (char *)"Unknown");
while (TRUE) {
do {
alarm_on();
Enter(1);
/* Use this name: */
language(YELLOW, BLACK, 38);
printf("%s [Y/n]? ", FullName);
fflush(stdout);
fflush(stdin);
GetstrC(temp, 80);
if ((strcasecmp(temp, "y") == 0) || (strcmp(temp, "") == 0))
sprintf(temp, "%s", FullName);
else {
do {
Syslog('+', "User chose to use a different name");
Enter(1);
/* Please enter your First and Last name: */
language(CYAN, BLACK, 0);
fflush(stdout);
alarm_on();
Getname(temp, 35);
if (CheckName(temp))
printf("\n%s\n", (char *) Language(149));
/*
* Do a check to see if name exists
*/
} while ((CheckName(temp) || strchr(temp, ' ') == NULL));
}
} while (BadNames(temp) || *(temp) == '\n');
/*
* Used to get users full name for other functions
*/
strcpy(FullName, tlcap(temp));
UserCity(mypid, FullName, (char *)"Unknown");
while (1) {
Enter(1);
/* Please enter your BBS password, this can be the same as the unix password */
printf("%s\n\n", (char *) Language(388));
/* Please enter new password : */
language(LIGHTCYAN, BLACK, 39);
fflush(stdout);
alarm_on();
Getpass(temp1);
if((x = strlen(temp1)) >= CFG.password_length) {
Enter(1);
/* Please enter password again : */
language(LIGHTCYAN, BLACK, 40);
fflush(stdout);
alarm_on();
Getpass(temp2);
if((i = strcmp(temp1,temp2)) != 0) {
Enter(2);
/* Your passwords do not match! Try again. */
language(LIGHTRED, BLACK, 41);
Enter(1);
} else {
crc = StringCRC32(tu(temp1));
break;
}
} else {
Enter(2);
/* Your password must contain at least */
language(LIGHTRED, BLACK, 42);
printf("%d ", CFG.password_length);
/* characters! Try again. */
language(WHITE, BLACK, 43);
Enter(1);
}
}
memset(Passwd, 0, 16);
sprintf(Passwd, "%s", temp2);
memset(&usrconfig.Password, 0, sizeof(usrconfig.Password));
sprintf(usrconfig.Password, "%s", temp2);
usrconfig.iPassword = crc;
Enter(1);
/* Please enter new password : */
language(LIGHTCYAN, BLACK, 39);
fflush(stdout);
alarm_on();
sprintf(UnixName, "%s", (char *) NameCreate(NameGen(FullName), FullName, temp2));
break;
Getpass(temp1);
if((x = strlen(temp1)) >= CFG.password_length) {
Enter(1);
/* Please enter password again : */
language(LIGHTCYAN, BLACK, 40);
fflush(stdout);
alarm_on();
Getpass(temp2);
if((i = strcmp(temp1,temp2)) != 0) {
Enter(2);
/* Your passwords do not match! Try again. */
language(LIGHTRED, BLACK, 41);
Enter(1);
} else {
crc = StringCRC32(tu(temp1));
break;
}
} else {
Enter(2);
/* Your password must contain at least */
language(LIGHTRED, BLACK, 42);
printf("%d ", CFG.password_length);
/* characters! Try again. */
language(WHITE, BLACK, 43);
Enter(1);
}
}
memset(&usrconfig.Password, 0, sizeof(usrconfig.Password));
sprintf(usrconfig.Password, "%s", temp2);
usrconfig.iPassword = crc;
alarm_on();
sprintf(UnixName, "%s", (char *) NameCreate(NameGen(FullName), FullName, temp2));
strcpy(usrconfig.sUserName, FullName);
strcpy(usrconfig.Name, UnixName);
Time_Now = time(NULL);
@@ -259,14 +260,11 @@ int newuser(char *FullName)
if(!CFG.iDataPhone)
printf("\n");
if (ieLogin && (strlen(ieLocation) >= CFG.CityLen) && (strlen(ieLocation) < 24)) {
strcpy(usrconfig.sLocation, ieLocation);
} else {
if (CFG.iLocation) {
if (CFG.iLocation) {
while (TRUE) {
Enter(1);
/* Enter your location */
pout(YELLOW, BLACK, (char *) Language(49));
language(YELLOW, BLACK, 49);
colour(CFG.InputColourF, CFG.InputColourB);
alarm_on();
if (CFG.iCapLocation) { /* Cap Location is turn on, Capitalise first letter */
@@ -288,14 +286,13 @@ int newuser(char *FullName)
break;
}
}
}
}
if (CFG.AskAddress) {
while (TRUE) {
Enter(1);
/* Your address, maximum 3 lines (only visible for the sysop): */
pout(LIGHTMAGENTA, BLACK, (char *)Language(474));
language(LIGHTMAGENTA, BLACK, 474);
Enter(1);
for (i = 0; i < 3; i++) {
colour(YELLOW, BLACK);
@@ -309,7 +306,7 @@ int newuser(char *FullName)
break;
Enter(1);
/* You need to enter your address here */
pout(LIGHTRED, BLACK, (char *)Language(475));
language(LIGHTRED, BLACK, 475);
Enter(1);
}
}
@@ -317,7 +314,7 @@ int newuser(char *FullName)
if (CFG.iHandle) {
Enter(1);
/* Enter a handle (Enter to Quit): */
pout(LIGHTRED, BLACK, (char *) Language(412));
language(LIGHTRED, BLACK, 412);
colour(CFG.InputColourF, CFG.InputColourB);
fflush(stdout);
alarm_on();
@@ -405,53 +402,44 @@ int newuser(char *FullName)
usrconfig.Security = CFG.newuser_access;
usrconfig.Email = CFG.GiveEmail;
if (ieLogin)
usrconfig.HotKeys = ieHOT;
else {
if (CFG.iHotkeys) {
while (TRUE) {
Enter(1);
/* Would you like hot-keyed menus [Y/n]: */
pout(LIGHTRED, BLACK, (char *) Language(62));
colour(CFG.InputColourF, CFG.InputColourB);
alarm_on();
GetstrC(temp, 8);
if (CFG.iHotkeys) {
while (TRUE) {
Enter(1);
/* Would you like hot-keyed menus [Y/n]: */
pout(LIGHTRED, BLACK, (char *) Language(62));
colour(CFG.InputColourF, CFG.InputColourB);
alarm_on();
GetstrC(temp, 8);
if ((toupper(temp[0]) == Keystroke(62, 0)) || (strcmp(temp,"") == 0)) {
usrconfig.HotKeys = TRUE;
break;
}
if (toupper(temp[0]) == Keystroke(62, 1)) {
usrconfig.HotKeys = FALSE;
break;
} else {
/* Please answer Y or N */
pout(WHITE, BLACK, (char *) Language(63));
}
if ((toupper(temp[0]) == Keystroke(62, 0)) || (strcmp(temp,"") == 0)) {
usrconfig.HotKeys = TRUE;
break;
}
} /* End of if Statement */
else
usrconfig.HotKeys = TRUE; /* Default set it to Hotkeys */
}
if (toupper(temp[0]) == Keystroke(62, 1)) {
usrconfig.HotKeys = FALSE;
break;
} else {
/* Please answer Y or N */
pout(WHITE, BLACK, (char *) Language(63));
}
}
} else
usrconfig.HotKeys = TRUE; /* Default set it to Hotkeys */
usrconfig.iTimeLeft = 20; /* Set Timeleft in users file to 20 */
Enter(1);
if (ieLogin)
usrconfig.iScreenLen = ieRows;
else {
/* Please enter your Screen Length [24]: */
pout(LIGHTMAGENTA, BLACK, (char *) Language(64));
colour(CFG.InputColourF, CFG.InputColourB);
fflush(stdout);
alarm_on();
Getnum(temp, 3);
/* Please enter your Screen Length [24]: */
pout(LIGHTMAGENTA, BLACK, (char *) Language(64));
colour(CFG.InputColourF, CFG.InputColourB);
fflush(stdout);
alarm_on();
Getnum(temp, 3);
if(strlen(temp) == 0)
usrconfig.iScreenLen = 24;
else
usrconfig.iScreenLen = atoi(temp);
}
if(strlen(temp) == 0)
usrconfig.iScreenLen = 24;
else
usrconfig.iScreenLen = atoi(temp);
alarm_on();
@@ -505,7 +493,7 @@ int newuser(char *FullName)
/* Login Name : */
pout(LIGHTBLUE, BLACK, (char *) Language(68));
colour(CYAN, BLACK);
printf("%s (%s)\n", FullName, UnixName);
printf("%s (%s)\n", UnixName, FullName);
/* Password : */
pout(LIGHTBLUE, BLACK, (char *) Language(69));
pout(CYAN, BLACK, (char *)"<");
@@ -530,15 +518,21 @@ int newuser(char *FullName)
free(Phone1);
free(Phone2);
DisplayFile((char *)"registered");
Syslog('+', "Completed new-user procedure");
/* New user registration completed. */
pout(LIGHTGREEN, BLACK, (char *) Language(71));
Enter(1);
/* You need to login again with the name: */
pout(LIGHTRED, BLACK, (char *) Language(5));
pout(YELLOW, BLACK, UnixName);
Enter(2);
alarm_on();
Pause();
alarm_off();
printf("\n");
return recno;
return 0;
}

View File

@@ -2,7 +2,7 @@
#define _NEWUSER_H
int newuser(char *); /* Newuser function */
int newuser(void); /* Newuser function */
#endif

View File

@@ -1,8 +1,7 @@
/*****************************************************************************
*
* File ..................: bbs/nextuser.c
* $Id$
* Purpose ...............: Message to next User door
* Last modification date : 28-Jun-2001
*
*****************************************************************************
* Copyright (C) 1997-2001
@@ -38,7 +37,7 @@
#include "../lib/common.h"
#include "nextuser.h"
#include "funcs.h"
#include "funcs4.h"
#include "input.h"
#include "language.h"
#include "timeout.h"

View File

@@ -1,8 +1,7 @@
/*****************************************************************************
*
* File ..................: bbs/offline.c
* $Id$
* Purpose ...............: Offline Reader
* Last modification date : 28-Jun-2001
*
*****************************************************************************
* Copyright (C) 1997-2001
@@ -44,6 +43,7 @@
#include "mail.h"
#include "funcs.h"
#include "funcs4.h"
#include "input.h"
#include "language.h"
#include "file.h"
#include "filesub.h"
@@ -52,6 +52,7 @@
#include "msgutil.h"
#include "pop3.h"
#include "offline.h"
#include "whoson.h"

View File

@@ -1,8 +1,7 @@
/*****************************************************************************
*
* File ..................: mbsebbs/oneline.c
* $Id$
* Purpose ...............: Oneliner functions.
* Last modification date : 28-jun-2001
*
*****************************************************************************
* Copyright (C) 1997-2001
@@ -37,7 +36,7 @@
#include "../lib/clcomm.h"
#include "oneline.h"
#include "funcs.h"
#include "funcs4.h"
#include "input.h"
#include "language.h"

View File

@@ -1,8 +1,7 @@
/*****************************************************************************
*
* File ..................: bbs/page.c
* $Id$
* Purpose ...............: Sysop Paging
* Last modification date : 28-Jun-2001
* Todo ..................: Implement new config settings.
*
*****************************************************************************
@@ -36,8 +35,8 @@
#include "../lib/records.h"
#include "../lib/common.h"
#include "../lib/clcomm.h"
#include "funcs.h"
#include "funcs4.h"
#include "dispfile.h"
#include "input.h"
#include "chat.h"
#include "page.h"
#include "timeout.h"

View File

@@ -34,7 +34,8 @@
#include "../lib/records.h"
#include "../lib/common.h"
#include "../lib/clcomm.h"
#include "funcs4.h"
#include "pinfo.h"
#include "input.h"

View File

@@ -1,8 +1,7 @@
/*****************************************************************************
*
* File ..................: bbs/safe.c
* $Id$
* Purpose ...............: Safe Door
* Last modification date : 26-Sep-2001
*
*****************************************************************************
* Copyright (C) 1997-2001
@@ -35,9 +34,9 @@
#include "../lib/records.h"
#include "../lib/clcomm.h"
#include "../lib/common.h"
#include "exitinfo.h"
#include "funcs.h"
#include "funcs4.h"
#include "whoson.h"
#include "dispfile.h"
#include "input.h"
#include "misc.h"
#include "safe.h"
#include "timeout.h"

View File

@@ -1,8 +1,7 @@
/*****************************************************************************
*
* File ..................: bbs/timeout.c
* $Id$
* Purpose ...............: Inactivity timeout functions
* Last modification date : 26-Sep-2001
*
*****************************************************************************
* Copyright (C) 1997-2001
@@ -94,11 +93,7 @@ void die(int onsig)
Syslog('+', "Last msg area %s", msgs.Name);
}
if (LoginPrompt) {
Unsetraw();
Quick_Bye(onsig);
} else
Good_Bye(onsig);
Good_Bye(onsig);
}
@@ -109,11 +104,7 @@ void alarm_sig()
/* Autologout: idletime reached.*/
printf("\r\n%s\r\n", (char *) Language(410));
if (LoginPrompt)
Syslog('!', "Autologout: idletime reached at login prompt");
else
Syslog('!', "Autologout: idletime reached");
Syslog('!', "Autologout: idletime reached");
die(SIGALRM);
}

File diff suppressed because it is too large Load Diff

324
mbsebbs/whoson.c Normal file
View File

@@ -0,0 +1,324 @@
/*****************************************************************************
*
* $Id$
* Purpose ...............: Who's online functions
*
*****************************************************************************
* Copyright (C) 1997-2001
*
* 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
* Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*****************************************************************************/
#include "../lib/libs.h"
#include "../lib/mbse.h"
#include "../lib/structs.h"
#include "../lib/records.h"
#include "../lib/common.h"
#include "../lib/clcomm.h"
//#include "funcs.h"
#include "input.h"
#include "language.h"
//#include "oneline.h"
//#include "misc.h"
//#include "bye.h"
//#include "timeout.h"
//#include "timecheck.h"
#include "exitinfo.h"
#include "whoson.h"
extern int LC_Download, LC_Upload, LC_Read, LC_Chat, LC_Olr, LC_Door;
/*
* Function to display what users are currently On-Line and what they
* are busy doing
*/
void WhosOn(char *OpData)
{
FILE *pExitinfo;
DIR *Directory;
char *Heading, *Underline, *temp, *tmp, *device;
struct dirent *Dir;
int i, x;
Underline = calloc(81, sizeof(char));
Heading = calloc(81, sizeof(char));
temp = calloc(PATH_MAX, sizeof(char));
tmp = calloc(PATH_MAX, sizeof(char));
WhosDoingWhat(WHOSON);
clear();
Enter(1);
colour(15, 0);
sprintf(Heading, "%s%s", (char *) Language(414), CFG.bbs_name);
Center(Heading);
x = strlen(Heading);
for(i = 0; i < x; i++)
sprintf(Underline, "%s%c", Underline, exitinfo.GraphMode ? 196 : 45);
colour(12, 0);
Center(Underline);
printf("\n");
pout(10, 0, (char *) Language(415));
Enter(1);
colour(2, 0);
fLine(79);
sprintf(tmp, "%s/tmp", getenv("MBSE_ROOT"));
if ((Directory = opendir(tmp)) != NULL)
while ((Dir = readdir( Directory )) != NULL)
if((strstr(Dir->d_name, ".bbs-exitinfo.")) != NULL) {
sprintf(temp, "%s/%s", tmp, Dir->d_name);
if(( pExitinfo = fopen(temp, "rb")) != NULL) {
fread(&exitinfo, sizeof(exitinfo), 1, pExitinfo);
colour(11, 0);
if((strcmp(OpData, "/H")) == 0) {
if((strcmp(exitinfo.sHandle, "") != 0 && *(exitinfo.sHandle) != ' '))
printf("%-30s", exitinfo.sHandle);
else
printf("%-30s", exitinfo.sUserName);
} else
printf("%-30s", exitinfo.sUserName);
colour(9, 0);
if((device = strstr(Dir->d_name, "tty")) != NULL)
printf("%-9s", device);
else
printf("%-9s", "None");
colour(15, 0);
/* Browseng */
if(exitinfo.iStatus == BROWSING)
printf("%-15s", (char *) Language(418));
/* Downloading */
else if(exitinfo.iStatus == DOWNLOAD)
printf("%-15s", (char *) Language(419));
/* Uploading */
else if(exitinfo.iStatus == UPLOAD)
printf("%-15s", (char *) Language(420));
/* Msg Section */
else if(exitinfo.iStatus == READ_POST)
printf("%-15s", (char *) Language(421));
/* External Door */
else if(exitinfo.iStatus == DOOR)
printf("%-15s", (char *) Language(422));
/* Chatting */
else if(exitinfo.iStatus == SYSOPCHAT)
printf("%-15s", (char *) Language(423));
/* Listing Files */
else if(exitinfo.iStatus == FILELIST)
printf("%-15s", (char *) Language(424));
/* Banking Door */
else if(exitinfo.iStatus == TIMEBANK)
printf("%-15s", (char *) Language(426));
/* Safe Door */
else if(exitinfo.iStatus == SAFE)
printf("%-15s", (char *) Language(427));
/* WhosOn List */
else if(exitinfo.iStatus == WHOSON)
printf("%-15s", (char *) Language(428));
/* Idle */
else
printf("%s", (char *) Language(429));
colour(12, 0);
printf("%-25s\n", exitinfo.sLocation);
fclose(pExitinfo);
}
}
closedir(Directory);
ReadExitinfo();
colour(2, 0);
fLine(79);
free(tmp);
free(temp);
free(Underline);
free(Heading);
printf("\n");
}
/*
* Function will update users file and and update exitinfo.iStatus
*/
void WhosDoingWhat(int iStatus)
{
char *temp;
temp = calloc(PATH_MAX, sizeof(char));
ReadExitinfo();
exitinfo.iStatus = iStatus;
WriteExitinfo();
switch(iStatus) {
case BROWSING:
strcpy(temp, "Browsing Menus");
break;
case DOWNLOAD:
strcpy(temp, "Downloading");
LC_Download = TRUE;
break;
case UPLOAD:
strcpy(temp, "Uploading");
LC_Upload = TRUE;
break;
case READ_POST:
strcpy(temp, "Read/post Messages");
LC_Read = TRUE;
break;
case DOOR:
strcpy(temp, "External Door");
LC_Door = TRUE;
break;
case SYSOPCHAT:
strcpy(temp, "Sysop Chat");
LC_Chat = TRUE;
break;
case FILELIST:
strcpy(temp, "List Files");
break;
case TIMEBANK:
strcpy(temp, "Time Bank");
LC_Door = TRUE;
break;
case SAFE:
strcpy(temp, "Safe Cracker");
LC_Door = TRUE;
break;
case WHOSON:
strcpy(temp, "View Whoson List");
break;
case OLR:
strcpy(temp, "Offline Reader");
LC_Olr = TRUE;
break;
}
IsDoing(temp);
free(temp);
}
/*
* Function will allow a user to send a on-line message to another user
* It will prompt the user for the username. The message is sent thru
* mbsed, from the resonse message we can see if we succeeded.
*/
void SendOnlineMsg(char *OpData)
{
static char buf[128];
char *User, *String;
User = calloc(36, sizeof(char));
String = calloc(77, sizeof(char));
WhosOn(OpData);
/* Please enter username to send message to: */
pout(3, 0, (char *) Language(430));
colour(CFG.InputColourF, CFG.InputColourB);
fflush(stdout);
GetstrC(User, 35);
if (!strcmp(User, "")) {
free(User);
free(String);
return;
}
/* Please enter message to send (Max 76 Characters) */
pout(10, 0, (char *)Language(433));
pout(10, 0, (char *)"\n> ");
colour(CFG.InputColourF, CFG.InputColourB);
fflush(stdout);
GetstrC(String, 76);
if ((strcmp(String, "")) != 0) {
buf[0] = '\0';
sprintf(buf, "CSPM:3,%s,%s,%s;", strcmp(OpData, "/H") != 0 ? exitinfo.sUserName : \
strcmp(exitinfo.sHandle, "") == 0 ? exitinfo.sUserName : \
exitinfo.sHandle, User, String);
if (socket_send(buf) == 0) {
strcpy(buf, socket_receive());
if (strncmp(buf, "100:1,3;", 8) == 0) {
/* Sorry, there is no user on */
printf("\n%s %s\n\n", (char *) Language(431), User);
}
if (strncmp(buf, "100:1,2;", 8) == 0) {
printf("\nNo more room in users message buffer\n\n");
}
if (strncmp(buf, "100:1,1;", 8) == 0) {
colour(12, 0);
/* doesn't wish to be disturbed */
printf("\n%s %s\n", User, (char *) Language(432));
}
if (strncmp(buf, "100:0;", 6) == 0) {
printf("Message Sent!\n");
Syslog('+', "Online msg to %s: \"%s\"", User, String);
}
}
}
free(User);
free(String);
Pause();
}

10
mbsebbs/whoson.h Normal file
View File

@@ -0,0 +1,10 @@
/* $Id$ */
#ifndef _WHOSON_H
#define _WHOSON_H
void WhosOn(char *); /* What users are currently online */
void WhosDoingWhat(int); /* Update what user is doing */
void SendOnlineMsg(char *); /* Send On-Line Message to User */
#endif