Move Strings into a String file so they can be customized

This commit is contained in:
Andrew Pamment 2016-08-14 19:56:15 +10:00
parent 89ba901b18
commit 86e39b7522
19 changed files with 837 additions and 560 deletions

View File

@ -5,7 +5,7 @@ JAMLIB = jamlib/jamlib.a
ZMODEM = Xmodem/libzmodem.a ZMODEM = Xmodem/libzmodem.a
LUA = lua/liblua.a LUA = lua/liblua.a
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o
%.o: %.c $(DEPS) %.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) $(CC) -c -o $@ $< $(CFLAGS)

View File

@ -5,7 +5,7 @@ JAMLIB = jamlib/jamlib.a
ZMODEM = Xmodem/libzmodem.a ZMODEM = Xmodem/libzmodem.a
LUA = lua/liblua.a LUA = lua/liblua.a
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o
%.o: %.c $(DEPS) %.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) $(CC) -c -o $@ $< $(CFLAGS)

View File

@ -5,7 +5,7 @@ JAMLIB = jamlib/jamlib.a
ZMODEM = Xmodem/libzmodem.a ZMODEM = Xmodem/libzmodem.a
LUA = lua/liblua.a LUA = lua/liblua.a
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o
%.o: %.c $(DEPS) %.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) $(CC) -c -o $@ $< $(CFLAGS)

View File

@ -5,7 +5,7 @@ JAMLIB = jamlib/jamlib.a
ZMODEM = Xmodem/libzmodem.a ZMODEM = Xmodem/libzmodem.a
LUA = lua/liblua.a LUA = lua/liblua.a
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o
%.o: %.c $(DEPS) %.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) $(CC) -c -o $@ $< $(CFLAGS)

64
bbs.c
View File

@ -132,7 +132,7 @@ void timer_handler(int signum) {
gUser->timeleft--; gUser->timeleft--;
if (gUser->timeleft <= 0) { if (gUser->timeleft <= 0) {
s_printf("\r\n\r\nSorry, you're out of time today..\r\n"); s_printf(get_string(0));
disconnect("Out of Time"); disconnect("Out of Time");
} }
@ -142,7 +142,7 @@ void timer_handler(int signum) {
usertimeout--; usertimeout--;
} }
if (usertimeout <= 0) { if (usertimeout <= 0) {
s_printf("\r\n\r\nTimeout waiting for input..\r\n"); s_printf(get_string(1));
disconnect("Timeout"); disconnect("Timeout");
} }
} }
@ -372,8 +372,8 @@ void display_last10_callers(struct user_record *user) {
struct tm l10_time; struct tm l10_time;
FILE *fptr = fopen("last10.dat", "rb"); FILE *fptr = fopen("last10.dat", "rb");
s_printf("\r\n\e[1;37mLast 10 callers:\r\n"); s_printf(get_string(2));
s_printf("\e[1;30m-------------------------------------------------------------------------------\r\n"); s_printf(get_string(3));
if (fptr != NULL) { if (fptr != NULL) {
@ -390,10 +390,10 @@ void display_last10_callers(struct user_record *user) {
for (z=0;z<i;z++) { for (z=0;z<i;z++) {
localtime_r(&callers[z].time, &l10_time); localtime_r(&callers[z].time, &l10_time);
s_printf("\e[1;37m%-16s \e[1;36m%-32s \e[1;32m%02d:%02d %02d-%02d-%02d\e[0m\r\n", callers[z].name, callers[z].location, l10_time.tm_hour, l10_time.tm_min, l10_time.tm_mday, l10_time.tm_mon + 1, l10_time.tm_year - 100); s_printf(get_string(4), callers[z].name, callers[z].location, l10_time.tm_hour, l10_time.tm_min, l10_time.tm_mday, l10_time.tm_mon + 1, l10_time.tm_year - 100);
} }
s_printf("\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n"); s_printf(get_string(5));
s_printf("Press any key to continue...\r\n"); s_printf(get_string(6));
s_getc(); s_getc();
} }
@ -402,16 +402,16 @@ void display_info() {
uname(&name); uname(&name);
s_printf("\r\n\r\n\e[1;37mSystem Information\r\n"); s_printf(get_string(7));
s_printf("\e[1;30m----------------------------------------------\r\n"); s_printf(get_string(8));
s_printf("\e[1;32mBBS Name : \e[1;37m%s\r\n", conf.bbs_name); s_printf(get_string(9), conf.bbs_name);
s_printf("\e[1;32mSysOp Name : \e[1;37m%s\r\n", conf.sysop_name); s_printf(get_string(10), conf.sysop_name);
s_printf("\e[1;32mNode : \e[1;37m%d\r\n", mynode); s_printf(get_string(11), mynode);
s_printf("\e[1;32mBBS Version : \e[1;37mMagicka %d.%d (%s)\r\n", VERSION_MAJOR, VERSION_MINOR, VERSION_STR); s_printf(get_string(12), VERSION_MAJOR, VERSION_MINOR, VERSION_STR);
s_printf("\e[1;32mSystem : \e[1;37m%s (%s)\r\n", name.sysname, name.machine); s_printf(get_string(13), name.sysname, name.machine);
s_printf("\e[1;30m----------------------------------------------\e[0m\r\n"); s_printf(get_string(14));
s_printf("Press any key to continue...\r\n"); s_printf(get_string(6));
s_getc(); s_getc();
} }
@ -430,11 +430,11 @@ void automessage_write(struct user_record *user) {
timen = time(NULL); timen = time(NULL);
localtime_r(&timen, &timenow); localtime_r(&timen, &timenow);
sprintf(automsg, "Automessage Posted by %s @ %s", user->loginname, asctime(&timenow)); sprintf(automsg, get_string(15), user->loginname, asctime(&timenow));
automsg[strlen(automsg) - 1] = '\r'; automsg[strlen(automsg) - 1] = '\r';
automsg[strlen(automsg)] = '\n'; automsg[strlen(automsg)] = '\n';
s_printf("\r\nEnter your message (4 lines):\r\n"); s_printf(get_string(16));
for (i=0;i<4;i++) { for (i=0;i<4;i++) {
s_printf("\r\n%d: ", i); s_printf("\r\n%d: ", i);
s_readstring(buffer, 75); s_readstring(buffer, 75);
@ -474,9 +474,9 @@ void automessage_display() {
dolog("Error opening automessage.txt"); dolog("Error opening automessage.txt");
} }
} else { } else {
s_printf("No automessage!\r\n"); s_printf(get_string(17));
} }
s_printf("\e[0mPress any key to continue...\r\n"); s_printf(get_string(6));
s_getc(); s_getc();
} }
@ -541,7 +541,7 @@ void runbbs_real(int socket, char *ip, int ssh) {
} }
if (mynode == 0) { if (mynode == 0) {
s_printf("Sorry, all nodes are in use. Please try later\r\n"); s_printf(get_string(18));
if (!ssh) { if (!ssh) {
close(socket); close(socket);
} }
@ -566,8 +566,8 @@ void runbbs_real(int socket, char *ip, int ssh) {
s_displayansi("issue"); s_displayansi("issue");
if (!ssh) { if (!ssh) {
s_printf("\e[0mEnter your Login Name or NEW to create an account\r\n"); s_printf(get_string(19));
s_printf("Login:> "); s_printf(get_string(20));
s_readstring(buffer, 25); s_readstring(buffer, 25);
@ -575,11 +575,11 @@ void runbbs_real(int socket, char *ip, int ssh) {
user = new_user(); user = new_user();
gUser = user; gUser = user;
} else { } else {
s_printf("\r\nPassword:> "); s_printf(get_string(21));
s_readpass(password, 16); s_readpass(password, 16);
user = check_user_pass(buffer, password); user = check_user_pass(buffer, password);
if (user == NULL) { if (user == NULL) {
s_printf("\r\nIncorrect Login.\r\n"); s_printf(get_string(22));
disconnect("Incorrect Login"); disconnect("Incorrect Login");
} }
@ -597,7 +597,7 @@ void runbbs_real(int socket, char *ip, int ssh) {
if (strcasecmp(user->loginname, buffer) == 0) { if (strcasecmp(user->loginname, buffer) == 0) {
fclose(nodefile); fclose(nodefile);
s_printf("\r\nYou are already logged in.\r\n"); s_printf(get_string(23));
disconnect("Already Logged in"); disconnect("Already Logged in");
} }
fclose(nodefile); fclose(nodefile);
@ -607,7 +607,7 @@ void runbbs_real(int socket, char *ip, int ssh) {
} else { } else {
if (gUser != NULL) { if (gUser != NULL) {
user = gUser; user = gUser;
s_printf("\e[0mWelcome back %s. Press enter to log in...\r\n", gUser->loginname); s_printf(get_string(24), gUser->loginname);
s_getc(); s_getc();
for (i=1;i<=conf.nodes;i++) { for (i=1;i<=conf.nodes;i++) {
sprintf(buffer, "%s/nodeinuse.%d", conf.bbs_path, i); sprintf(buffer, "%s/nodeinuse.%d", conf.bbs_path, i);
@ -621,14 +621,14 @@ void runbbs_real(int socket, char *ip, int ssh) {
if (strcasecmp(user->loginname, buffer) == 0) { if (strcasecmp(user->loginname, buffer) == 0) {
fclose(nodefile); fclose(nodefile);
s_printf("\r\nYou are already logged in.\r\n"); s_printf(get_string(23));
disconnect("Already Logged in"); disconnect("Already Logged in");
} }
fclose(nodefile); fclose(nodefile);
} }
} }
} else { } else {
s_printf("\e[0mWelcome to %s! Press enter to create an account...\r\n", conf.bbs_name); s_printf(get_string(25), conf.bbs_name);
s_getc(); s_getc();
gUser = new_user(); gUser = new_user();
user = gUser; user = gUser;
@ -687,7 +687,7 @@ void runbbs_real(int socket, char *ip, int ssh) {
while (stat(buffer, &s) == 0) { while (stat(buffer, &s) == 0) {
sprintf(buffer, "bulletin%d", i); sprintf(buffer, "bulletin%d", i);
s_displayansi(buffer); s_displayansi(buffer);
s_printf("\e[0mPress any key to continue...\r\n"); s_printf(get_string(6));
s_getc(); s_getc();
i++; i++;
sprintf(buffer, "%s/bulletin%d.ans", conf.ansi_path, i); sprintf(buffer, "%s/bulletin%d.ans", conf.ansi_path, i);
@ -703,9 +703,9 @@ void runbbs_real(int socket, char *ip, int ssh) {
// check email // check email
i = mail_getemailcount(user); i = mail_getemailcount(user);
if (i > 0) { if (i > 0) {
s_printf("\r\nYou have %d e-mail(s) in your inbox.\r\n", i); s_printf(get_string(26), i);
} else { } else {
s_printf("\r\nYou have no e-mail.\r\n"); s_printf(get_string(27));
} }
mail_scan(user); mail_scan(user);

5
bbs.h
View File

@ -96,7 +96,7 @@ struct bbs_config {
int ssh_port; int ssh_port;
char *ssh_dsa_key; char *ssh_dsa_key;
char *ssh_rsa_key; char *ssh_rsa_key;
char *string_file;
char *irc_server; char *irc_server;
int irc_port; int irc_port;
char *irc_channel; char *irc_channel;
@ -192,4 +192,7 @@ extern int file_menu(struct user_record *user);
extern void settings_menu(struct user_record *user); extern void settings_menu(struct user_record *user);
extern void lua_push_cfunctions(lua_State *L); extern void lua_push_cfunctions(lua_State *L);
extern void load_strings();
extern char *get_string(int offset);
#endif #endif

View File

@ -28,22 +28,22 @@ void add_bbs(struct user_record *user) {
sqlite3_stmt *res; sqlite3_stmt *res;
int rc; int rc;
s_printf("\r\n\e[1;37mEnter the BBS Name: \e[0m"); s_printf(get_string(28));
s_readstring(bbsname, 18); s_readstring(bbsname, 18);
s_printf("\r\n\e[1;37mEnter the Sysop's Name: \e[0m"); s_printf(get_string(29));
s_readstring(sysop, 16); s_readstring(sysop, 16);
s_printf("\r\n\e[1;37mEnter the Telnet URL: \e[0m"); s_printf(get_string(30));
s_readstring(telnet, 38); s_readstring(telnet, 38);
s_printf("\r\nYou entered:\r\n"); s_printf(get_string(31));
s_printf("\e[1;30m----------------------------------------------\e[0m\r\n"); s_printf(get_string(32));
s_printf("\e[1;37mBBS Name: \e[1;32m%s\r\n", bbsname); s_printf(get_string(33), bbsname);
s_printf("\e[1;37mSysop: \e[1;32m%s\r\n", sysop); s_printf(get_string(34), sysop);
s_printf("\e[1;37mTelnet URL: \e[1;32m%s\r\n", telnet); s_printf(get_string(35), telnet);
s_printf("\e[1;30m----------------------------------------------\e[0m\r\n"); s_printf(get_string(36));
s_printf("Is this correct? (Y/N) :"); s_printf(get_string(37));
c = s_getc(); c = s_getc();
if (tolower(c) == 'y') { if (tolower(c) == 'y') {
@ -93,9 +93,9 @@ void add_bbs(struct user_record *user) {
} }
sqlite3_finalize(res); sqlite3_finalize(res);
sqlite3_close(db); sqlite3_close(db);
s_printf("\r\n\e[1;32mAdded!\e[0m\r\n"); s_printf(get_string(38));
} else { } else {
s_printf("\r\n\e[1;31mAborted!\e[0m\r\n"); s_printf(get_string(39));
} }
} }
@ -109,7 +109,7 @@ void delete_bbs(struct user_record *user) {
int i; int i;
char c; char c;
s_printf("\r\nPlease enter the id of the BBS you want to delete: "); s_printf(get_string(40));
s_readstring(buffer, 5); s_readstring(buffer, 5);
i = atoi(buffer); i = atoi(buffer);
@ -125,11 +125,11 @@ void delete_bbs(struct user_record *user) {
sqlite3_bind_int(res, 2, user->id); sqlite3_bind_int(res, 2, user->id);
} else { } else {
sqlite3_close(db); sqlite3_close(db);
s_printf("\r\nThere are no BBSes in the list yet!\r\n"); s_printf(get_string(41));
return; return;
} }
if (sqlite3_step(res) == SQLITE_ROW) { if (sqlite3_step(res) == SQLITE_ROW) {
s_printf("\r\nAre you sure you want to delete %s?\r\n", sqlite3_column_text(res, 0)); s_printf(get_string(42), sqlite3_column_text(res, 0));
sqlite3_finalize(res); sqlite3_finalize(res);
c = s_getc(); c = s_getc();
if (tolower(c) == 'y') { if (tolower(c) == 'y') {
@ -138,18 +138,18 @@ void delete_bbs(struct user_record *user) {
sqlite3_bind_int(res, 1, i); sqlite3_bind_int(res, 1, i);
} else { } else {
sqlite3_close(db); sqlite3_close(db);
s_printf("\r\nThere are no BBSes in the list yet!\r\n"); s_printf(get_string(41));
return; return;
} }
sqlite3_step(res); sqlite3_step(res);
s_printf("\r\n\e[1;32mDeleted!\e[0m\r\n"); s_printf(get_string(43));
sqlite3_finalize(res); sqlite3_finalize(res);
} else { } else {
s_printf("\r\n\e[1;32mAborted!\e[0m\r\n"); s_printf(get_string(39));
} }
} else { } else {
sqlite3_finalize(res); sqlite3_finalize(res);
s_printf("\r\nThat BBS entry either doesn't exist or wasn't created by you.\r\n"); s_printf(get_string(44));
} }
sqlite3_close(db); sqlite3_close(db);
} }
@ -173,27 +173,27 @@ void list_bbses() {
rc = sqlite3_prepare_v2(db, sql, -1, &res, 0); rc = sqlite3_prepare_v2(db, sql, -1, &res, 0);
if (rc != SQLITE_OK) { if (rc != SQLITE_OK) {
sqlite3_close(db); sqlite3_close(db);
s_printf("\r\nThere are no BBSes in the list yet!\r\n"); s_printf(get_string(41));
return; return;
} }
i = 0; i = 0;
s_printf("\r\n\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n"); s_printf(get_string(45));
while (sqlite3_step(res) == SQLITE_ROW) { while (sqlite3_step(res) == SQLITE_ROW) {
s_printf("\e[1;30m[\e[1;34m%3d\e[1;30m] \e[1;37m%-18s \e[1;33m%-16s \e[1;32m%-37s\e[0m\r\n", sqlite3_column_int(res, 0), sqlite3_column_text(res, 1), sqlite3_column_text(res, 2), sqlite3_column_text(res, 3)); s_printf(get_string(46), sqlite3_column_int(res, 0), sqlite3_column_text(res, 1), sqlite3_column_text(res, 2), sqlite3_column_text(res, 3));
i++; i++;
if (i == 20) { if (i == 20) {
s_printf("Press any key to continue...\r\n"); s_printf(get_string(6));
s_getc(); s_getc();
i = 0; i = 0;
} }
} }
s_printf("\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n"); s_printf(get_string(47));
sqlite3_finalize(res); sqlite3_finalize(res);
sqlite3_close(db); sqlite3_close(db);
s_printf("Press any key to continue...\r\n"); s_printf(get_string(6));
s_getc(); s_getc();
} }
@ -202,7 +202,7 @@ void bbs_list(struct user_record *user) {
char c; char c;
while(!doquit) { while(!doquit) {
s_printf("\r\n\e[1;32mBBS Listings: \e[1;37m(\e[1;33mL\e[1;37m) \e[1;32mList, \e[1;37m(\e[1;33mA\e[1;37m) \e[1;32mAdd \e[1;37m(\e[1;33mD\e[1;37m) \e[1;32mDelete \e[1;37m(\e[1;33mQ\e[1;37m) \e[1;32mQuit\e[0m\r\n"); s_printf(get_string(48));
c = s_getc(); c = s_getc();

View File

@ -121,7 +121,7 @@ void chat_system(struct user_record *user) {
memset(inputbuffer, 0, 80); memset(inputbuffer, 0, 80);
if (conf.irc_server == NULL) { if (conf.irc_server == NULL) {
s_putstring("\r\nSorry, Chat is not supported on this system.\r\n"); s_putstring(get_string(49));
return; return;
} }
row_at = 0; row_at = 0;
@ -282,7 +282,7 @@ void chat_system(struct user_record *user) {
for (i=line_at+1;i<22;i++) { for (i=line_at+1;i<22;i++) {
s_putstring("\r\n"); s_putstring("\r\n");
} }
s_putstring("\e[1;45;37m Type /Quit to Exit\e[K\e[0m\r\n"); s_putstring(get_string(50));
if (inputbuffer_at > 0) { if (inputbuffer_at > 0) {
s_putstring(inputbuffer); s_putstring(inputbuffer);
} }

View File

@ -18,6 +18,7 @@ SSH DSA Key = /home/andrew/MagickaBBS/keys/ssh_host_dsa_key
SSH RSA Key = /home/andrew/MagickaBBS/keys/ssh_host_rsa_key SSH RSA Key = /home/andrew/MagickaBBS/keys/ssh_host_rsa_key
[paths] [paths]
String File = /home/andrew/MagickaBBS/magicka.strings
PID File = /home/andrew/MagickaBBS/magicka.pid PID File = /home/andrew/MagickaBBS/magicka.pid
ANSI Path = /home/andrew/MagickaBBS/ansis ANSI Path = /home/andrew/MagickaBBS/ansis
BBS Path = /home/andrew/MagickaBBS BBS Path = /home/andrew/MagickaBBS

View File

@ -241,7 +241,7 @@ void rundoor(struct user_record *user, char *cmd, int stdio) {
sprintf(buffer, "%s %d %d", cmd, mynode, gSocket); sprintf(buffer, "%s %d %d", cmd, mynode, gSocket);
system(buffer); system(buffer);
} else { } else {
s_printf("Non-STDIO door support on SSH is currently broken...\r\n"); s_printf(get_string(51));
} }
} }
timeoutpaused = 0; timeoutpaused = 0;
@ -283,7 +283,7 @@ int door_menu(struct user_record *user) {
if (do_internal_menu == 1) { if (do_internal_menu == 1) {
s_displayansi("doors"); s_displayansi("doors");
s_printf("\e[0m\r\nTL: %dm :> ", user->timeleft); s_printf(get_string(52), user->timeleft);
c = s_getc(); c = s_getc();
} else { } else {
@ -305,7 +305,7 @@ int door_menu(struct user_record *user) {
break; break;
case 'g': case 'g':
{ {
s_printf("\r\nAre you sure you want to log off? (Y/N)"); s_printf(get_string(53));
c = s_getc(); c = s_getc();
if (tolower(c) == 'y') { if (tolower(c) == 'y') {
doquit = 1; doquit = 1;

41
email.c
View File

@ -27,24 +27,24 @@ void send_email(struct user_record *user) {
char *isql = "INSERT INTO email (sender, recipient, subject, body, date, seen) VALUES(?, ?, ?, ?, ?, 0)"; char *isql = "INSERT INTO email (sender, recipient, subject, body, date, seen) VALUES(?, ?, ?, ?, ?, 0)";
char *err_msg = 0; char *err_msg = 0;
s_printf("\r\nTO: "); s_printf(get_string(54));
s_readstring(buffer, 16); s_readstring(buffer, 16);
if (strlen(buffer) == 0) { if (strlen(buffer) == 0) {
s_printf("\r\nAborted\r\n"); s_printf(get_string(39));
return; return;
} }
if (check_user(buffer)) { if (check_user(buffer)) {
s_printf("\r\n\r\nInvalid Username\r\n"); s_printf(get_string(55));
return; return;
} }
recipient = strdup(buffer); recipient = strdup(buffer);
s_printf("\r\nSUBJECT: "); s_printf(get_string(56));
s_readstring(buffer, 25); s_readstring(buffer, 25);
if (strlen(buffer) == 0) { if (strlen(buffer) == 0) {
free(recipient); free(recipient);
s_printf("\r\nAborted\r\n"); s_printf(get_string(39));
return; return;
} }
subject = strdup(buffer); subject = strdup(buffer);
@ -150,14 +150,13 @@ void show_email(struct user_record *user, int msgno) {
date = (time_t)sqlite3_column_int(res, 4); date = (time_t)sqlite3_column_int(res, 4);
s_printf("\e[2J\e[1;32mFrom : \e[1;37m%s\r\n", sender); s_printf(get_string(57), sender);
s_printf("\e[1;32mSubject : \e[1;37m%s\r\n", subject); s_printf(get_string(58), subject);
localtime_r(&date, &msg_date); localtime_r(&date, &msg_date);
sprintf(buffer, "\e[1;32mDate : \e[1;37m%s", asctime(&msg_date)); sprintf(buffer, "%s", asctime(&msg_date));
buffer[strlen(buffer) - 1] = '\0'; buffer[strlen(buffer) - 1] = '\0';
strcat(buffer, "\r\n"); s_printf(get_string(59), buffer);
s_printf(buffer); s_printf(get_string(60));
s_printf("\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n");
lines = 0; lines = 0;
chars = 0; chars = 0;
@ -168,7 +167,7 @@ void show_email(struct user_record *user, int msgno) {
s_printf("\r\n"); s_printf("\r\n");
lines++; lines++;
if (lines == 19) { if (lines == 19) {
s_printf("\e[1;37mPress a key to continue...\e[0m"); s_printf(get_string(6));
s_getc(); s_getc();
lines = 0; lines = 0;
s_printf("\e[5;1H\e[0J"); s_printf("\e[5;1H\e[0J");
@ -193,7 +192,7 @@ void show_email(struct user_record *user, int msgno) {
} }
sqlite3_step(res); sqlite3_step(res);
s_printf("\e[1;37mPress \e[1;36mR\e[1;37m to reply, \e[1;36mD\e[1;37m to delete \e[1;36mEnter\e[1;37m to quit...\e[0m\r\n"); s_printf(get_string(61));
c = s_getc(); c = s_getc();
if (tolower(c) == 'r') { if (tolower(c) == 'r') {
if (subject != NULL) { if (subject != NULL) {
@ -293,12 +292,12 @@ void list_emails(struct user_record *user) {
dolog("Failed to execute statement: %s", sqlite3_errmsg(db)); dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
sqlite3_finalize(res); sqlite3_finalize(res);
sqlite3_close(db); sqlite3_close(db);
s_printf("\r\nYou have no email\r\n"); s_printf(get_string(62));
return; return;
} }
msgid = 0; msgid = 0;
s_printf("\e[2J\e[1;37;44m[MSG#] Subject From Date \r\n\e[0m"); s_printf(get_string(63));
while (sqlite3_step(res) == SQLITE_ROW) { while (sqlite3_step(res) == SQLITE_ROW) {
from = strdup((char *)sqlite3_column_text(res, 0)); from = strdup((char *)sqlite3_column_text(res, 0));
subject = strdup((char *)sqlite3_column_text(res, 1)); subject = strdup((char *)sqlite3_column_text(res, 1));
@ -306,15 +305,15 @@ void list_emails(struct user_record *user) {
date = (time_t)sqlite3_column_int(res, 3); date = (time_t)sqlite3_column_int(res, 3);
localtime_r(&date, &msg_date); localtime_r(&date, &msg_date);
if (seen == 0) { if (seen == 0) {
s_printf("\e[1;30m[\e[1;34m%4d\e[1;30m]\e[1;32m*\e[1;37m%-39.39s \e[1;32m%-16.16s \e[1;35m%02d:%02d %02d-%02d-%02d\e[0m\r\n", msgid + 1, subject, from, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100); s_printf(get_string(64), msgid + 1, subject, from, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
} else { } else {
s_printf("\e[1;30m[\e[1;34m%4d\e[1;30m] \e[1;37m%-39.39s \e[1;32m%-16.16s \e[1;35m%02d:%02d %02d-%02d-%02d\e[0m\r\n", msgid + 1, subject, from, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100); s_printf(get_string(65), msgid + 1, subject, from, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
} }
free(from); free(from);
free(subject); free(subject);
if (msgid % 22 == 0 && msgid != 0) { if (msgid % 22 == 0 && msgid != 0) {
s_printf("\e[1;37mEnter \e[1;36m# \e[1;37mto read, \e[1;36mQ \e[1;37mto quit or \e[1;36mEnter\e[1;37m to continue\e[0m\r\n"); s_printf(get_string(66));
s_readstring(buffer, 5); s_readstring(buffer, 5);
if (strlen(buffer) > 0) { if (strlen(buffer) > 0) {
if (tolower(buffer[0]) == 'q') { if (tolower(buffer[0]) == 'q') {
@ -329,14 +328,14 @@ void list_emails(struct user_record *user) {
return; return;
} }
} }
s_printf("\e[2J\e[1;37;44m[MSG#] Subject From Date \r\n\e[0m"); s_printf(get_string(63));
} }
msgid++; msgid++;
} }
if (msgid == 0) { if (msgid == 0) {
s_printf( "\r\nYou have no email\r\n"); s_printf(get_string(62));
} else { } else {
s_printf("\e[1;37mEnter \e[1;36m# \e[1;37mto read, or \e[1;36mEnter\e[1;37m to quit\e[0m\r\n"); s_printf(get_string(67));
s_readstring(buffer, 5); s_readstring(buffer, 5);
if (strlen(buffer) > 0) { if (strlen(buffer) > 0) {
msgtoread = atoi(buffer) - 1; msgtoread = atoi(buffer) - 1;

48
files.c
View File

@ -467,7 +467,7 @@ void list_files(struct user_record *user) {
if (rc != SQLITE_OK) { if (rc != SQLITE_OK) {
sqlite3_finalize(res); sqlite3_finalize(res);
sqlite3_close(db); sqlite3_close(db);
s_printf("\r\nNo files in this area!\r\n"); s_printf(get_string(68));
return; return;
} }
@ -492,7 +492,7 @@ void list_files(struct user_record *user) {
sqlite3_close(db); sqlite3_close(db);
if (files_c == 0) { if (files_c == 0) {
s_printf("\r\nNo files in this area!\r\n"); s_printf(get_string(68));
return; return;
} }
s_printf("\r\n"); s_printf("\r\n");
@ -510,7 +510,7 @@ void list_files(struct user_record *user) {
} else { } else {
file_unit = 'b'; file_unit = 'b';
} }
s_printf("\r\n\r\n\e[1;30m[\e[1;34m%3d\e[1;30m] \e[1;33m%3ddloads \e[1;36m%4d%c \e[1;37m%-56s\r\n \e[0;32m", i, files_e[i]->dlcount, file_size, file_unit, basename(files_e[i]->filename)); s_printf(get_string(69), i, files_e[i]->dlcount, file_size, file_unit, basename(files_e[i]->filename));
lines+=3; lines+=3;
for (j=0;j<strlen(files_e[i]->description);j++) { for (j=0;j<strlen(files_e[i]->description);j++) {
if (files_e[i]->description[j] == '\n') { if (files_e[i]->description[j] == '\n') {
@ -519,7 +519,7 @@ void list_files(struct user_record *user) {
if (lines >= 18) { if (lines >= 18) {
lines = 0; lines = 0;
while (1) { while (1) {
s_printf("\r\n\e[0mEnter # to tag, Q to quit, Enter to continue: "); s_printf(get_string(70));
s_readstring(buffer, 5); s_readstring(buffer, 5);
if (strlen(buffer) == 0) { if (strlen(buffer) == 0) {
s_printf("\r\n"); s_printf("\r\n");
@ -552,18 +552,18 @@ void list_files(struct user_record *user) {
} }
tagged_files[tagged_count] = strdup(files_e[z]->filename); tagged_files[tagged_count] = strdup(files_e[z]->filename);
tagged_count++; tagged_count++;
s_printf("\r\nTagged %s\r\n", basename(files_e[z]->filename)); s_printf(get_string(71), basename(files_e[z]->filename));
} else { } else {
s_printf("\r\nAlready Tagged\r\n"); s_printf(get_string(72));
} }
} else { } else {
s_printf("\r\nSorry, you don't have permission to download from this area\r\n"); s_printf(get_string(73));
} }
} }
} }
} }
} else { } else {
s_printf(" \e[0;32m"); s_printf(get_string(74));
} }
} else { } else {
s_putchar(files_e[i]->description[j]); s_putchar(files_e[i]->description[j]);
@ -571,7 +571,7 @@ void list_files(struct user_record *user) {
} }
} }
while (1) { while (1) {
s_printf("\r\n\e[0mEnter # to tag, Enter to quit: "); s_printf(get_string(75));
s_readstring(buffer, 5); s_readstring(buffer, 5);
if (strlen(buffer) == 0) { if (strlen(buffer) == 0) {
for (z=0;z<files_c;z++) { for (z=0;z<files_c;z++) {
@ -601,12 +601,12 @@ void list_files(struct user_record *user) {
} }
tagged_files[tagged_count] = strdup(files_e[z]->filename); tagged_files[tagged_count] = strdup(files_e[z]->filename);
tagged_count++; tagged_count++;
s_printf("\r\nTagged %s\r\n", basename(files_e[z]->filename)); s_printf(get_string(71), basename(files_e[z]->filename));
} else { } else {
s_printf("\r\nAlready Tagged\r\n"); s_printf(get_string(72));
} }
} else { } else {
s_printf("\r\nSorry, you don't have permission to download from this area\r\n"); s_printf(get_string(73));
} }
} }
} }
@ -650,7 +650,7 @@ int file_menu(struct user_record *user) {
if (do_internal_menu == 1) { if (do_internal_menu == 1) {
s_displayansi("filemenu"); s_displayansi("filemenu");
s_printf("\e[0m\r\nDir: (%d) %s\r\nSub: (%d) %s\r\nTL: %dm :> ", user->cur_file_dir, conf.file_directories[user->cur_file_dir]->name, user->cur_file_sub, conf.file_directories[user->cur_file_dir]->file_subs[user->cur_file_sub]->name, user->timeleft); s_printf(get_string(76), user->cur_file_dir, conf.file_directories[user->cur_file_dir]->name, user->cur_file_sub, conf.file_directories[user->cur_file_dir]->file_subs[user->cur_file_sub]->name, user->timeleft);
c = s_getc(); c = s_getc();
} else { } else {
@ -669,22 +669,22 @@ int file_menu(struct user_record *user) {
switch(tolower(c)) { switch(tolower(c)) {
case 'i': case 'i':
{ {
s_printf("\r\n\r\nFile Directories:\r\n\r\n"); s_printf(get_string(77));
for (i=0;i<conf.file_directory_count;i++) { for (i=0;i<conf.file_directory_count;i++) {
if (conf.file_directories[i]->sec_level <= user->sec_level) { if (conf.file_directories[i]->sec_level <= user->sec_level) {
s_printf(" %d. %s\r\n", i, conf.file_directories[i]->name); s_printf(get_string(78), i, conf.file_directories[i]->name);
} }
if (i != 0 && i % 20 == 0) { if (i != 0 && i % 20 == 0) {
s_printf("Press any key to continue...\r\n"); s_printf(get_string(6));
c = s_getc(); c = s_getc();
} }
} }
s_printf("Enter the directory number: "); s_printf(get_string(79));
s_readstring(prompt, 5); s_readstring(prompt, 5);
if (tolower(prompt[0]) != 'q') { if (tolower(prompt[0]) != 'q') {
j = atoi(prompt); j = atoi(prompt);
if (j < 0 || j >= conf.file_directory_count || conf.file_directories[j]->sec_level > user->sec_level) { if (j < 0 || j >= conf.file_directory_count || conf.file_directories[j]->sec_level > user->sec_level) {
s_printf("\r\nInvalid directory number!\r\n"); s_printf(get_string(80));
} else { } else {
s_printf("\r\n"); s_printf("\r\n");
user->cur_file_dir = j; user->cur_file_dir = j;
@ -695,21 +695,21 @@ int file_menu(struct user_record *user) {
break; break;
case 's': case 's':
{ {
s_printf("\r\n\r\nFile Subdirectories:\r\n\r\n"); s_printf(get_string(81));
for (i=0;i<conf.file_directories[user->cur_file_dir]->file_sub_count;i++) { for (i=0;i<conf.file_directories[user->cur_file_dir]->file_sub_count;i++) {
s_printf(" %d. %s\r\n", i, conf.file_directories[user->cur_file_dir]->file_subs[i]->name); s_printf(" %d. %s\r\n", i, conf.file_directories[user->cur_file_dir]->file_subs[i]->name);
if (i != 0 && i % 20 == 0) { if (i != 0 && i % 20 == 0) {
s_printf("Press any key to continue...\r\n"); s_printf(get_string(6));
c = s_getc(); c = s_getc();
} }
} }
s_printf("Enter the sub directory number: "); s_printf(get_string(82));
s_readstring(prompt, 5); s_readstring(prompt, 5);
if (tolower(prompt[0]) != 'q') { if (tolower(prompt[0]) != 'q') {
j = atoi(prompt); j = atoi(prompt);
if (j < 0 || j >= conf.file_directories[user->cur_file_dir]->file_sub_count) { if (j < 0 || j >= conf.file_directories[user->cur_file_dir]->file_sub_count) {
s_printf("\r\nInvalid sub directiry number!\r\n"); s_printf(get_string(83));
} else { } else {
s_printf("\r\n"); s_printf("\r\n");
user->cur_file_sub = j; user->cur_file_sub = j;
@ -725,7 +725,7 @@ int file_menu(struct user_record *user) {
if (user->sec_level >= conf.file_directories[user->cur_file_dir]->file_subs[user->cur_file_sub]->upload_sec_level) { if (user->sec_level >= conf.file_directories[user->cur_file_dir]->file_subs[user->cur_file_sub]->upload_sec_level) {
upload(user); upload(user);
} else { } else {
s_printf("Sorry, you don't have permission to upload in this Sub\r\n"); s_printf(get_string(84));
} }
} }
break; break;
@ -796,7 +796,7 @@ int file_menu(struct user_record *user) {
break; break;
case 'g': case 'g':
{ {
s_printf("\r\nAre you sure you want to log off? (Y/N)"); s_printf(get_string(53));
c = s_getc(); c = s_getc();
if (tolower(c) == 'y') { if (tolower(c) == 'y') {
dofiles = 1; dofiles = 1;

186
magicka.strings Normal file
View File

@ -0,0 +1,186 @@
\r\n\r\nSorry, you're out of time today..\r\n
\r\n\r\nTimeout waiting for input..\r\n
\r\n\e[1;37mLast 10 callers:\r\n
\e[1;30m-------------------------------------------------------------------------------\r\n
\e[1;37m%-16s \e[1;36m%-32s \e[1;32m%02d:%02d %02d-%02d-%02d\e[0m\r\n
\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n
\e[1;37mPress any key to continue...\e[0m\r\n
\r\n\r\n\e[1;37mSystem Information\r\n
\e[1;30m----------------------------------------------\r\n
\e[1;32mBBS Name : \e[1;37m%s\r\n
\e[1;32mSysOp Name : \e[1;37m%s\r\n
\e[1;32mNode : \e[1;37m%d\r\n
\e[1;32mBBS Version : \e[1;37mMagicka %d.%d (%s)\r\n
\e[1;32mSystem : \e[1;37m%s (%s)\r\n
\e[1;30m----------------------------------------------\e[0m\r\n
Automessage Posted by %s @ %s
\r\nEnter your message (4 lines):\r\n
No automessage!\r\n
Sorry, all nodes are in use. Please try later\r\n
\e[0mEnter your Login Name or NEW to create an account\r\n
Login:>
\r\nPassword:>
\r\nIncorrect Login.\r\n
\r\nYou are already logged in.\r\n
\e[0mWelcome back %s. Press enter to log in...\r\n
\e[0mWelcome to %s! Press enter to create an account...\r\n
\r\nYou have %d e-mail(s) in your inbox.\r\n
\r\nYou have no e-mail.\r\n
\r\n\e[1;37mEnter the BBS Name: \e[0m
\r\n\e[1;37mEnter the Sysop's Name: \e[0m
\r\n\e[1;37mEnter the Telnet URL: \e[0m
\r\nYou entered:\r\n
\e[1;30m----------------------------------------------\e[0m\r\n
\e[1;37mBBS Name: \e[1;32m%s\r\n
\e[1;37mSysop: \e[1;32m%s\r\n
\e[1;37mTelnet URL: \e[1;32m%s\r\n
\e[1;30m----------------------------------------------\e[0m\r\n
Is this correct? (Y/N) :
\r\n\e[1;32mAdded!\e[0m\r\n
\r\n\e[1;31mAborted!\e[0m\r\n
\r\nPlease enter the id of the BBS you want to delete:
\r\nThere are no BBSes in the list yet!\r\n
\r\nAre you sure you want to delete %s?\r\n
\r\n\e[1;32mDeleted!\e[0m\r\n
\r\nThat BBS entry either doesn't exist or wasn't created by you.\r\n
\r\n\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n
\e[1;30m[\e[1;34m%3d\e[1;30m] \e[1;37m%-18s \e[1;33m%-16s \e[1;32m%-37s\e[0m\r\n
\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n
\r\n\e[1;32mBBS Listings: \e[1;37m(\e[1;33mL\e[1;37m) \e[1;32mList, \e[1;37m(\e[1;33mA\e[1;37m) \e[1;32mAdd \e[1;37m(\e[1;33mD\e[1;37m) \e[1;32mDelete \e[1;37m(\e[1;33mQ\e[1;37m) \e[1;32mQuit\e[0m\r\n
\r\nSorry, Chat is not supported on this system.\r\n
\e[1;45;37m Type /Quit to Exit\e[K\e[0m\r\n
Non-STDIO door support on SSH is currently broken...\r\n
\e[0m\r\nTL: %dm :>
\r\nAre you sure you want to log off? (Y/N)
\r\nTO:
\r\n\r\nInvalid Username\r\n
\r\nSUBJECT:
\e[2J\e[1;32mFrom : \e[1;37m%s\r\n
\e[1;32mSubject : \e[1;37m%s\r\n
\e[1;32mDate : \e[1;37m%s\r\n
\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n
\e[1;37mPress \e[1;36mR\e[1;37m to reply, \e[1;36mD\e[1;37m to delete \e[1;36mEnter\e[1;37m to quit...\e[0m\r\n
\r\nYou have no email\r\n
\e[2J\e[1;37;44m[MSG#] Subject From Date \r\n\e[0m
\e[1;30m[\e[1;34m%4d\e[1;30m]\e[1;32m*\e[1;37m%-39.39s \e[1;32m%-16.16s \e[1;35m%02d:%02d %02d-%02d-%02d\e[0m\r\n
\e[1;30m[\e[1;34m%4d\e[1;30m] \e[1;37m%-39.39s \e[1;32m%-16.16s \e[1;35m%02d:%02d %02d-%02d-%02d\e[0m\r\n
\e[1;37mEnter \e[1;36m# \e[1;37mto read, \e[1;36mQ \e[1;37mto quit or \e[1;36mEnter\e[1;37m to continue\e[0m\r\n
\e[1;37mEnter \e[1;36m# \e[1;37mto read, or \e[1;36mEnter\e[1;37m to quit\e[0m\r\n
\r\nNo files in this area!\r\n
\r\n\r\n\e[1;30m[\e[1;34m%3d\e[1;30m] \e[1;33m%3ddloads \e[1;36m%4d%c \e[1;37m%-56s\r\n \e[0;32m
\r\n\e[0mEnter # to tag, Q to quit, Enter to continue:
\r\nTagged %s\r\n
\r\nAlready Tagged\r\n
\r\nSorry, you don't have permission to download from this area\r\n
\e[0;32m
\r\n\e[0mEnter # to tag, Enter to quit:
\e[0m\r\nDir: (%d) %s\r\nSub: (%d) %s\r\nTL: %dm :>
\r\n\r\nFile Directories:\r\n\r\n
%d. %s\r\n
Enter the directory number:
\r\nInvalid directory number!\r\n
\r\n\r\nFile Subdirectories:\r\n\r\n
Enter the sub directory number:
\r\nInvalid sub directory number!\r\n
Sorry, you don't have permission to upload in this Sub\r\n
\r\nUse external editor? (Y/N)
\r\n\e[1;32mMagicka Internal Editor, Type \e[1;37m/S \e[1;32mto save, \e[1;37m/A \e[1;32mto abort and \e[1;37m/? \e[1;32mfor help\r\n
\e[1;30m-------------------------------------------------------------------------------\e[0m
\r\n\e[1;30m[\e[1;34m%3d\e[1;30m]: \e[0m%s
\r\nNo message to quote!\r\n
\r\nQuote from Line:
\r\nQuote to Line:
Quoting Cancelled\r\n
\e[1;33m\r\nHELP\r\n
/S - Save Message\r\n
/A - Abort Message\r\n
/Q - Quote Message\r\n
/E - Edit (Rewrite) Line\r\n
/D - Delete Line\r\n
/I - Insert Line\r\n
/L - Relist Message\r\n\e[0m
\r\nWhich line do you want to delete?
\r\nWhich line do you want to edit?
\r\n\e[1;30m[\e[1;34m%3d\e[1;30m]: \e[0m
\r\nInsert before which line?
\e[2J\e[1;32mFrom : \e[1;37m%s (%d:%d/%d.%d)\r\n
\e[2J\e[1;32mFrom : \e[1;37m%s\r\n
\e[1;32mTo : \e[1;37m%-27.27s \e[1;32mConf : \e[1;37m%-27.27s\r\n
\e[1;32mSubject : \e[1;37m%-27.27s \e[1;32mArea : \e[1;37m%-27.27s\r\n
\e[1;32mDate : \e[1;37m%s \e[1;32mMsgNo : \e[1;37m%4d of %4d\r\n
\e[1;32mAttribs : \e[1;37m%s\r\n
\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n
\r\n\e[1;37mPress \e[1;36mR \e[1;37mto reply, \e[1;36mQ \e[1;37mto quit, \e[1;36mB \e[1;37mto go Back, \e[1;36mSPACE \e[1;37mfor Next Mesage...
\r\nSorry, you are not allowed to post in this area\r\n
\r\n\r\nReplying to: %s\r\n
Change Subject? (Y/N)
\r\nNew subject:
\r\nOk, not changing the subject line...
\r\n\r\nNo more messages\r\n
\e[0m\r\nConf: (%d) %s\r\nArea: (%d) %s\r\nTL: %dm :>
Read message [1-%d] or N for New:
\r\nADDR:
\r\n\r\nInvalid Address\r\n
\r\nMailing to %d:%d/%d.%d\r\n
\r\nMailing to @%d\r\n
Start at message [1-%d] or N for New?
\e[2J\e[1;37;44m[MSG#] Subject From To Date \r\n\e[0m
\e[1;30m[\e[1;34m%4d\e[1;30m]\e[1;32m*\e[1;37m%-25.25s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[0m\r\n
\e[1;30m[\e[1;34m%4d\e[1;30m] \e[1;37m%-25.25s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[0m\r\n
(#) Read Message # (Q) Quit (ENTER) Continue\r\n
\r\nThere is no mail in this area\r\n
\r\n\r\nMail Conferences:\r\n\r\n
%d. %s\r\n
Enter the conference number:
\r\nInvalid conference number!\r\n
\r\n\r\nMail Areas:\r\n\r\n
%d. %s\r\n
Enter the area number:
\r\nInvalid area number!\r\n
\r\nScan for new mail? (Y/N) :
\r\n\e[1;32m%d. %s\e[0m\r\n
\e[1;37m --> %d. %s (%d new)\e[0m\r\n
\r\n\e[0mTL: %dm :>
\r\n\e[1;32mText Files Collection\r\n
\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n
\e[1;30m[\e[1;34m%3d\e[1;30m] \e[1;37m%s\r\n
\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n
Enter the number of a text file to display or Q to quit:
\r\nSorry, there are no text files to display\r\n
\e[2J\e[1;32mYour Settings\r\n
\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n
\e[0;36mP. \e[1;37mPassword (\e[1;33mNot Shown\e[1;37m)\r\n
\e[0;36mL. \e[1;37mLocation (\e[1;33m%s\e[1;37m)\r\n
\e[0;36mQ. \e[1;37mQuit to Main Menu\r\n
\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n
\r\nEnter your current password:
\r\nEnter your new password (8 chars min):
\r\nPassword Changed!\r\n
\r\nPassword too short!\r\n
\r\nPassword Incorrect!\r\n
\r\nEnter your new location:
\e[2J\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n
User Name Location Times On\r\n
\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n
\e[1;37m%-16s \e[1;36m%-32s \e[1;32m%5d\r\n
\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n
\r\nWhat is your login name:
Sorry, that name is too short.\r\n
Sorry, invalid character, can only use alpha characters.\r\n
Sorry, that name is reserved.\r\n
Sorry, that name is in use.\r\n
What is your first name:
What is your last name:
What is your e-mail address:
Where are you located:
What password would you like (at least 8 characters):
You Entered:\r\n
-------------------------------------\r\n
Login Name:
\r\nFirst Name:
\r\nLast Name:
\r\nE-mail:
\r\nLocation:
\r\n-------------------------------------\r\n
Is this Correct? (Y/N)
\e[1;37mPress any key to continue...\e[0m

File diff suppressed because it is too large Load Diff

5
main.c
View File

@ -311,6 +311,8 @@ static int handler(void* user, const char* section, const char* name,
conf->netmail_sem = strdup(value); conf->netmail_sem = strdup(value);
} else if (strcasecmp(name, "pid file") == 0) { } else if (strcasecmp(name, "pid file") == 0) {
conf->pid_file = strdup(value); conf->pid_file = strdup(value);
} else if (strcasecmp(name, "string file") == 0) {
conf->string_file = strdup(value);
} }
} else if (strcasecmp(section, "mail conferences") == 0) { } else if (strcasecmp(section, "mail conferences") == 0) {
if (conf->mail_conference_count == 0) { if (conf->mail_conference_count == 0) {
@ -738,6 +740,7 @@ int main(int argc, char **argv) {
conf.echomail_sem = NULL; conf.echomail_sem = NULL;
conf.netmail_sem = NULL; conf.netmail_sem = NULL;
conf.telnet_port = 0; conf.telnet_port = 0;
conf.string_file = NULL;
// Load BBS data // Load BBS data
if (ini_parse(argv[1], handler, &conf) <0) { if (ini_parse(argv[1], handler, &conf) <0) {
@ -764,6 +767,8 @@ int main(int argc, char **argv) {
exit(-1); exit(-1);
} }
load_strings();
if (conf.fork) { if (conf.fork) {
if (stat(conf.pid_file, &s) == 0) { if (stat(conf.pid_file, &s) == 0) {
fprintf(stderr, "Magicka already running or stale pid file at: %s\n", conf.pid_file); fprintf(stderr, "Magicka already running or stale pid file at: %s\n", conf.pid_file);

View File

@ -47,7 +47,7 @@ void main_menu(struct user_record *user) {
s_displayansi("mainmenu"); s_displayansi("mainmenu");
s_printf("\r\n\e[0mTL: %dm :> ", user->timeleft); s_printf(get_string(142), user->timeleft);
c = s_getc(); c = s_getc();
} else { } else {
@ -75,21 +75,21 @@ void main_menu(struct user_record *user) {
if (conf.text_file_count > 0) { if (conf.text_file_count > 0) {
while(1) { while(1) {
s_printf("\r\n\e[1;32mText Files Collection\r\n"); s_printf(get_string(143));
s_printf("\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n"); s_printf(get_string(144));
for (i=0;i<conf.text_file_count;i++) { for (i=0;i<conf.text_file_count;i++) {
s_printf("\e[1;30m[\e[1;34m%3d\e[1;30m] \e[1;37m%s\r\n", i, conf.text_files[i]->name); s_printf(get_string(145), i, conf.text_files[i]->name);
} }
s_printf("\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n"); s_printf(get_string(146));
s_printf("Enter the number of a text file to display or Q to quit: "); s_printf(get_string(147));
s_readstring(buffer, 4); s_readstring(buffer, 4);
if (tolower(buffer[0]) != 'q') { if (tolower(buffer[0]) != 'q') {
i = atoi(buffer); i = atoi(buffer);
if (i >= 0 && i < conf.text_file_count) { if (i >= 0 && i < conf.text_file_count) {
s_printf("\r\n"); s_printf("\r\n");
s_displayansi_p(conf.text_files[i]->path); s_displayansi_p(conf.text_files[i]->path);
s_printf("Press any key to continue..."); s_printf(get_string(6));
s_getc(); s_getc();
s_printf("\r\n"); s_printf("\r\n");
} }
@ -98,8 +98,8 @@ void main_menu(struct user_record *user) {
} }
} }
} else { } else {
s_printf("\r\nSorry, there are no text files to display\r\n"); s_printf(get_string(148));
s_printf("Press any key to continue...\r\n"); s_printf(get_string(6));
s_getc(); s_getc();
} }
} }
@ -127,7 +127,7 @@ void main_menu(struct user_record *user) {
while (stat(buffer, &s) == 0) { while (stat(buffer, &s) == 0) {
sprintf(buffer, "bulletin%d", i); sprintf(buffer, "bulletin%d", i);
s_displayansi(buffer); s_displayansi(buffer);
s_printf("\e[0mPress any key to continue...\r\n"); s_printf(get_string(6));
s_getc(); s_getc();
i++; i++;
sprintf(buffer, "%s/bulletin%d.ans", conf.ansi_path, i); sprintf(buffer, "%s/bulletin%d.ans", conf.ansi_path, i);
@ -151,7 +151,7 @@ void main_menu(struct user_record *user) {
break; break;
case 'g': case 'g':
{ {
s_printf("\r\nAre you sure you want to log off? (Y/N)"); s_printf(get_string(53));
c = s_getc(); c = s_getc();
if (tolower(c) == 'y') { if (tolower(c) == 'y') {
doquit = 1; doquit = 1;

View File

@ -11,23 +11,23 @@ void settings_menu(struct user_record *user) {
char *hash; char *hash;
while (!dosettings) { while (!dosettings) {
s_printf("\e[2J\e[1;32mYour Settings\r\n"); s_printf(get_string(149));
s_printf("\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n"); s_printf(get_string(150));
s_printf("\e[0;36mP. \e[1;37mPassword (\e[1;33mNot Shown\e[1;37m)\r\n"); s_printf(get_string(151));
s_printf("\e[0;36mL. \e[1;37mLocation (\e[1;33m%s\e[1;37m)\r\n", user->location); s_printf(get_string(152), user->location);
s_printf("\e[0;36mQ. \e[1;37mQuit to Main Menu\r\n"); s_printf(get_string(153));
s_printf("\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n"); s_printf(get_string(154));
c = s_getc(); c = s_getc();
switch(tolower(c)) { switch(tolower(c)) {
case 'p': case 'p':
{ {
s_printf("\r\nEnter your current password: "); s_printf(get_string(155));
s_readpass(buffer, 16); s_readpass(buffer, 16);
hash = hash_sha256(buffer, user->salt); hash = hash_sha256(buffer, user->salt);
if (strcmp(hash, user->password) == 0) { if (strcmp(hash, user->password) == 0) {
s_printf("\r\nEnter your new password (8 chars min): "); s_printf(get_string(156));
s_readstring(buffer, 16); s_readstring(buffer, 16);
if (strlen(buffer) >= 8) { if (strlen(buffer) >= 8) {
free(user->password); free(user->password);
@ -37,18 +37,18 @@ void settings_menu(struct user_record *user) {
user->password = hash_sha256(buffer, user->salt); user->password = hash_sha256(buffer, user->salt);
save_user(user); save_user(user);
s_printf("\r\nPassword Changed!\r\n"); s_printf(get_string(157));
} else { } else {
s_printf("\r\nPassword too short!\r\n"); s_printf(get_string(158));
} }
} else { } else {
s_printf("\r\nPassword Incorrect!\r\n"); s_printf(get_string(159));
} }
} }
break; break;
case 'l': case 'l':
{ {
s_printf("\r\nEnter your new location: "); s_printf(get_string(160));
s_readstring(buffer, 32); s_readstring(buffer, 32);
free(user->location); free(user->location);
user->location = (char *)malloc(strlen(buffer) + 1); user->location = (char *)malloc(strlen(buffer) + 1);

83
strings.c Normal file
View File

@ -0,0 +1,83 @@
#include "bbs.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
extern struct bbs_config conf;
char *undefined = "Undefined String";
char **strings;
int string_count;
void chomp(char *string) {
while ((string[strlen(string)-1] == '\r' || string[strlen(string)-1] == '\n') && strlen(string)) {
string[strlen(string)-1] = '\0';
}
}
char *parse_newlines(char *string) {
char *newstring = (char *)malloc(strlen(string) + 1);
int pos = 0;
int i;
for (i=0;i<strlen(string);i++) {
if (string[i] == '\\') {
if (i < strlen(string) - 1) {
i++;
if (string[i] == 'n') {
newstring[pos++] = '\n';
} else if (string[i] == 'r') {
newstring[pos++] = '\r';
} else if (string[i] == '\\') {
newstring[pos++] = '\\';
} else if (string[i] == 'e') {
newstring[pos++] = '\e';
}
newstring[pos] = '\0';
}
} else {
newstring[pos++] = string[i];
newstring[pos] = '\0';
}
}
return newstring;
}
char *get_string(int offset) {
if (offset >= string_count) {
return undefined;
}
return strings[offset];
}
void load_strings() {
FILE *fptr;
char buffer[1024];
if (conf.string_file == NULL) {
fprintf(stderr, "Strings file can not be undefined!\n");
exit(-1);
}
fptr = fopen(conf.string_file, "r");
if (!fptr) {
fprintf(stderr, "Unable to open strings file!\n");
exit(-1);
}
string_count = 0;
fgets(buffer, 1024, fptr);
while (!feof(fptr)) {
chomp(buffer);
if (string_count == 0) {
strings = (char **)malloc(sizeof(char *));
} else {
strings = (char **)realloc(strings, sizeof(char *) * (string_count + 1));
}
strings[string_count] = parse_newlines(buffer);
string_count++;
fgets(buffer, 1024, fptr);
}
fclose(fptr);
}

58
users.c
View File

@ -345,25 +345,25 @@ void list_users(struct user_record *user) {
sqlite3_close(db); sqlite3_close(db);
exit(1); exit(1);
} }
s_printf("\e[2J\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n"); s_printf(get_string(161));
s_printf("User Name Location Times On\r\n"); s_printf(get_string(162));
s_printf("\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n"); s_printf(get_string(163));
i = 0; i = 0;
while (sqlite3_step(res) == SQLITE_ROW) { while (sqlite3_step(res) == SQLITE_ROW) {
s_printf("\e[1;37m%-16s \e[1;36m%-32s \e[1;32m%5d\r\n", sqlite3_column_text(res, 0), sqlite3_column_text(res, 1), sqlite3_column_int(res, 2)); s_printf(get_string(164), sqlite3_column_text(res, 0), sqlite3_column_text(res, 1), sqlite3_column_int(res, 2));
i++; i++;
if (i == 20) { if (i == 20) {
s_printf("Press any key to continue...\r\n"); s_printf(get_string(6));
s_getc(); s_getc();
i = 0; i = 0;
} }
} }
s_printf("\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n"); s_printf(get_string(165));
sqlite3_finalize(res); sqlite3_finalize(res);
sqlite3_close(db); sqlite3_close(db);
s_printf("Press any key to continue...\r\n"); s_printf(get_string(6));
s_getc(); s_getc();
} }
@ -422,17 +422,17 @@ struct user_record *new_user() {
passok = 0; passok = 0;
nameok = 0; nameok = 0;
do { do {
s_printf("\r\nWhat is your login name: "); s_printf(get_string(166));
s_readstring(buffer, 16); s_readstring(buffer, 16);
s_printf("\r\n"); s_printf("\r\n");
if (strlen(buffer) < 3) { if (strlen(buffer) < 3) {
s_printf("Sorry, that name is too short.\r\n"); s_printf(get_string(167));
continue; continue;
} }
for (i=0;i<strlen(buffer);i++) { for (i=0;i<strlen(buffer);i++) {
if (!(tolower(buffer[i]) >= 97 && tolower(buffer[i]) <= 122)) { if (!(tolower(buffer[i]) >= 97 && tolower(buffer[i]) <= 122)) {
s_printf("Sorry, invalid character, can only use alpha characters.\r\n"); s_printf(get_string(168));
nameok = 1; nameok = 1;
break; break;
} }
@ -442,77 +442,77 @@ struct user_record *new_user() {
continue; continue;
} }
if (strcasecmp(buffer, "unknown") == 0) { if (strcasecmp(buffer, "unknown") == 0) {
s_printf("Sorry, that name is reserved.\r\n"); s_printf(get_string(169));
continue; continue;
} }
if (strcasecmp(buffer, "all") == 0) { if (strcasecmp(buffer, "all") == 0) {
s_printf("Sorry, that name is reserved.\r\n"); s_printf(get_string(169));
continue; continue;
} }
if (strcasecmp(buffer, "new") == 0) { if (strcasecmp(buffer, "new") == 0) {
s_printf("Sorry, that name is reserved.\r\n"); s_printf(get_string(169));
continue; continue;
} }
user->loginname = strdup(buffer); user->loginname = strdup(buffer);
nameok = check_user(user->loginname); nameok = check_user(user->loginname);
if (!nameok) { if (!nameok) {
s_printf("Sorry, that name is in use.\r\n"); s_printf(get_string(170));
free(user->loginname); free(user->loginname);
memset(buffer, 0, 256); memset(buffer, 0, 256);
} }
} while (!nameok); } while (!nameok);
s_printf("What is your first name: "); s_printf(get_string(171));
memset(buffer, 0, 256); memset(buffer, 0, 256);
s_readstring(buffer, 32); s_readstring(buffer, 32);
s_printf("\r\n"); s_printf("\r\n");
user->firstname = strdup(buffer); user->firstname = strdup(buffer);
s_printf("What is your last name: "); s_printf(get_string(172));
memset(buffer, 0, 256); memset(buffer, 0, 256);
s_readstring(buffer, 32); s_readstring(buffer, 32);
s_printf("\r\n"); s_printf("\r\n");
user->lastname = strdup(buffer); user->lastname = strdup(buffer);
s_printf("What is your e-mail address: "); s_printf(get_string(173));
memset(buffer, 0, 256); memset(buffer, 0, 256);
s_readstring(buffer, 64); s_readstring(buffer, 64);
s_printf("\r\n"); s_printf("\r\n");
user->email = strdup(buffer); user->email = strdup(buffer);
s_printf("Where are you located: "); s_printf(get_string(174));
memset(buffer, 0, 256); memset(buffer, 0, 256);
s_readstring(buffer, 32); s_readstring(buffer, 32);
s_printf("\r\n"); s_printf("\r\n");
user->location = strdup(buffer); user->location = strdup(buffer);
do { do {
s_printf("What password would you like (at least 8 characters): "); s_printf(get_string(175));
memset(buffer, 0, 256); memset(buffer, 0, 256);
s_readstring(buffer, 16); s_readstring(buffer, 16);
s_printf("\r\n"); s_printf("\r\n");
if (strlen(buffer) >= 8) { if (strlen(buffer) >= 8) {
passok = 1; passok = 1;
} else { } else {
s_printf("Password too short!\r\n"); s_printf(get_string(158));
} }
} while (!passok); } while (!passok);
gen_salt(&user->salt); gen_salt(&user->salt);
user->password = hash_sha256(buffer, user->salt); user->password = hash_sha256(buffer, user->salt);
s_printf("You Entered:\r\n"); s_printf(get_string(176));
s_printf("-------------------------------------\r\n"); s_printf(get_string(177));
s_printf("Login Name: "); s_printf(get_string(178));
s_printf(user->loginname); s_printf(user->loginname);
s_printf("\r\nFirst Name: "); s_printf(get_string(179));
s_printf(user->firstname); s_printf(user->firstname);
s_printf("\r\nLast Name: "); s_printf(get_string(180));
s_printf(user->lastname); s_printf(user->lastname);
s_printf("\r\nE-mail: "); s_printf(get_string(181));
s_printf(user->email); s_printf(user->email);
s_printf("\r\nLocation: "); s_printf(get_string(182));
s_printf(user->location); s_printf(user->location);
s_printf("\r\n-------------------------------------\r\n"); s_printf(get_string(183));
s_printf("Is this Correct? (Y/N)"); s_printf(get_string(184));
c = s_getchar(); c = s_getchar();
while (tolower(c) != 'y' && tolower(c) != 'n') { while (tolower(c) != 'y' && tolower(c) != 'n') {
c = s_getchar(); c = s_getchar();