commit
aee93039a3
@ -34,7 +34,7 @@ OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
magicka: $(OBJ) ${LUA} ${JAMLIB} ${ZMODEM} ${JSMN}
|
||||
$(CC) -o magicka -o $@ $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh
|
||||
$(CC) -o magicka -o $@ $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv
|
||||
|
||||
magimail: $(JAMLIB)
|
||||
cd utils/magimail && $(MAKE) freebsd
|
||||
|
@ -39,7 +39,7 @@ OBJ = deps/aha/aha.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o do
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${B64} ${JSMN}
|
||||
$(CC) -o magicka -o $@ $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh $(MICROHTTPD)
|
||||
$(CC) -o magicka -o $@ $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv $(MICROHTTPD)
|
||||
|
||||
magimail: $(JAMLIB)
|
||||
cd utils/magimail && $(MAKE) freebsd
|
||||
|
@ -35,7 +35,7 @@ OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${JSMN}
|
||||
$(CC) -o magicka -o $@ $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -ldl -lssl -lcrypto -lssh
|
||||
$(CC) -o magicka -o $@ $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -ldl -lssl -lcrypto -lssh
|
||||
|
||||
magimail: $(JAMLIB)
|
||||
cd utils/magimail && $(MAKE) linux
|
||||
|
@ -39,7 +39,7 @@ OBJ = deps/aha/aha.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o do
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
magicka: $(OBJ) ${LUA} ${JAMLIB} ${ZMODEM} ${B64} ${JSMN}
|
||||
$(CC) -o magicka -o $@ $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -ldl -lssl -lcrypto -lssh $(MICROHTTPD)
|
||||
$(CC) -o magicka -o $@ $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -ldl -lssl -lcrypto -lssh $(MICROHTTPD)
|
||||
|
||||
magimail: $(JAMLIB)
|
||||
cd utils/magimail && $(MAKE) linux
|
||||
|
@ -34,7 +34,7 @@ OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${JSMN}
|
||||
$(CC) -o magicka -o $@ $^ $(CFLAGS) -L/usr/pkg/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh
|
||||
$(CC) -o magicka -o $@ $^ $(CFLAGS) -L/usr/pkg/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv
|
||||
|
||||
magiedit: $(ODOORS)
|
||||
cd utils/magiedit && $(MAKE)
|
||||
|
@ -39,7 +39,7 @@ OBJ = deps/aha/aha.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o do
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${B64} ${JSMN}
|
||||
$(CC) -o magicka -o $@ $^ $(CFLAGS) -L/usr/pkg/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh $(MICROHTTPD)
|
||||
$(CC) -o magicka -o $@ $^ $(CFLAGS) -L/usr/pkg/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv $(MICROHTTPD)
|
||||
|
||||
magiedit: $(ODOORS)
|
||||
cd utils/magiedit && $(MAKE)
|
||||
|
@ -35,7 +35,7 @@ $(CDK):
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${JSMN}
|
||||
$(CC) -o magicka -o $@ $^ $(CFLAGS) -L/opt/local/lib -lsqlite3 -lutil -lm -ldl -lssl -lcrypto -lssh
|
||||
$(CC) -o magicka -o $@ $^ $(CFLAGS) -L/opt/local/lib -lsqlite3 -lutil -lm -ldl -lssl -lcrypto -lssh -liconv
|
||||
|
||||
magimail: $(JAMLIB)
|
||||
cd utils/magimail && $(MAKE) linux
|
||||
|
@ -39,7 +39,7 @@ OBJ = deps/aha/aha.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o do
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${B64} ${JSMN}
|
||||
$(CC) -o magicka -o $@ $^ $(CFLAGS) -L/opt/local/lib -lsqlite3 -lutil -lm -ldl -lssl -lcrypto -lssh $(MICROHTTPD)
|
||||
$(CC) -o magicka -o $@ $^ $(CFLAGS) -L/opt/local/lib -lsqlite3 -lutil -lm -ldl -lssl -lcrypto -lssh -liconv $(MICROHTTPD)
|
||||
|
||||
magimail: $(JAMLIB)
|
||||
cd utils/magimail && $(MAKE) linux
|
||||
|
86
bbs.c
86
bbs.c
@ -14,6 +14,7 @@
|
||||
#include <fts.h>
|
||||
#include <errno.h>
|
||||
#include <sys/socket.h>
|
||||
#include <iconv.h>
|
||||
#include "bbs.h"
|
||||
#include "lua/lua.h"
|
||||
#include "lua/lualib.h"
|
||||
@ -200,27 +201,92 @@ void timer_handler(int signum) {
|
||||
void s_printf(char *fmt, ...) {
|
||||
char buffer[512];
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(buffer, 512, fmt, ap);
|
||||
va_end(ap);
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(buffer, 512, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
s_putstring(buffer);
|
||||
}
|
||||
|
||||
int should_convert_utf8() {
|
||||
if (gUser != NULL) {
|
||||
return gUser->codepage;
|
||||
}
|
||||
return conf.codepage;
|
||||
}
|
||||
|
||||
void s_putchar(char c) {
|
||||
if (sshBBS) {
|
||||
putchar(c);
|
||||
iconv_t ic;
|
||||
char *inbuf;
|
||||
char *outbuf;
|
||||
char *ptr1;
|
||||
char *ptr2;
|
||||
size_t inc;
|
||||
size_t ouc;
|
||||
size_t sz;
|
||||
|
||||
if (!should_convert_utf8()) {
|
||||
if (sshBBS) {
|
||||
putchar(c);
|
||||
} else {
|
||||
write(gSocket, &c, 1);
|
||||
}
|
||||
} else {
|
||||
write(gSocket, &c, 1);
|
||||
ic = iconv_open("UTF-8", "CP437");
|
||||
inbuf = (char *)malloc(4);
|
||||
outbuf = (char *)malloc(4);
|
||||
memset(outbuf, 0, 4);
|
||||
sprintf(inbuf, "%c", c);
|
||||
inc = 1;
|
||||
ouc = 4;
|
||||
ptr1 = outbuf;
|
||||
ptr2 = inbuf;
|
||||
sz = iconv(ic, &inbuf, &inc, &outbuf, &ouc);
|
||||
if (sshBBS) {
|
||||
fprintf(stdout, "%s", ptr1);
|
||||
} else {
|
||||
write(gSocket, ptr1, outbuf - ptr1);
|
||||
}
|
||||
iconv_close(ic);
|
||||
free(ptr1);
|
||||
free(ptr2);
|
||||
}
|
||||
}
|
||||
|
||||
void s_putstring(char *c) {
|
||||
if (sshBBS) {
|
||||
printf("%s", c);
|
||||
iconv_t ic;
|
||||
char *inbuf;
|
||||
char *outbuf;
|
||||
size_t inc;
|
||||
size_t ouc;
|
||||
size_t sz;
|
||||
char *ptr1;
|
||||
char *ptr2;
|
||||
if (!should_convert_utf8()) {
|
||||
if (sshBBS) {
|
||||
puts(c);
|
||||
} else {
|
||||
write(gSocket, c, strlen(c));
|
||||
}
|
||||
} else {
|
||||
write(gSocket, c, strlen(c));
|
||||
ic = iconv_open("UTF-8", "CP437");
|
||||
inc = strlen(c);
|
||||
inbuf = strdup(c);
|
||||
outbuf = (char *)malloc(inc * 4);
|
||||
memset(outbuf, 0, inc * 4);
|
||||
ptr1 = outbuf;
|
||||
ptr2 = inbuf;
|
||||
ouc = inc * 4;
|
||||
sz = iconv(ic, &inbuf, &inc, &outbuf, &ouc);
|
||||
if (sshBBS) {
|
||||
fprintf(stdout, "%s", ptr1);
|
||||
} else {
|
||||
write(gSocket, ptr1, outbuf - ptr1);
|
||||
}
|
||||
iconv_close(ic);
|
||||
free(ptr1);
|
||||
free(ptr2);
|
||||
}
|
||||
}
|
||||
|
||||
|
8
bbs.h
8
bbs.h
@ -45,6 +45,7 @@ struct door_config {
|
||||
char *name;
|
||||
char *command;
|
||||
int stdio;
|
||||
char *codepage;
|
||||
};
|
||||
|
||||
struct mail_area {
|
||||
@ -113,6 +114,7 @@ struct ip_address_guard {
|
||||
};
|
||||
|
||||
struct bbs_config {
|
||||
int codepage;
|
||||
char *bbs_name;
|
||||
char *bwave_name;
|
||||
char *sysop_name;
|
||||
@ -143,6 +145,7 @@ struct bbs_config {
|
||||
char *menu_path;
|
||||
char *external_editor_cmd;
|
||||
int external_editor_stdio;
|
||||
char *external_editor_codepage;
|
||||
int fork;
|
||||
|
||||
int nodes;
|
||||
@ -199,6 +202,7 @@ struct user_record {
|
||||
int defarchiver;
|
||||
int defprotocol;
|
||||
int nodemsgs;
|
||||
int codepage;
|
||||
};
|
||||
|
||||
struct jam_msg {
|
||||
@ -272,8 +276,8 @@ extern void next_mail_area(struct user_record *user);
|
||||
extern void prev_mail_area(struct user_record *user);
|
||||
extern void post_message(struct user_record *user);
|
||||
|
||||
extern void rundoor(struct user_record *user, char *cmd, int stdio);
|
||||
extern void runexternal(struct user_record *user, char *cmd, int stdio, char **argv, char *cwd, int raw);
|
||||
extern void rundoor(struct user_record *user, char *cmd, int stdio, char *codepage);
|
||||
extern void runexternal(struct user_record *user, char *cmd, int stdio, char **argv, char *cwd, int raw, char *codepage);
|
||||
|
||||
extern void bbs_list(struct user_record *user);
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
[main]
|
||||
Codepage = CP437
|
||||
Telnet Port = 2023
|
||||
BBS Name = Magicka BBS
|
||||
Sysop Name = sysop
|
||||
@ -10,6 +11,7 @@ MagiChat BBSTag = Magicka
|
||||
Default Tagline = Brought to you by Another Magicka BBS!
|
||||
External Editor cmd = /home/andrew/MagickaBBS/utils/magiedit/magiedit.sh
|
||||
External Editor stdio = true
|
||||
External Editor Codepage = CP437
|
||||
Automessage Write Level = 10
|
||||
Fork = false
|
||||
Enable WWW = false
|
||||
|
64
doors.c
64
doors.c
@ -9,6 +9,7 @@
|
||||
#include <sys/wait.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <iconv.h>
|
||||
#if defined(linux)
|
||||
# include <pty.h>
|
||||
#elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__)
|
||||
@ -130,7 +131,7 @@ int write_door32sys(struct user_record *user) {
|
||||
|
||||
|
||||
|
||||
void rundoor(struct user_record *user, char *cmd, int stdio) {
|
||||
void rundoor(struct user_record *user, char *cmd, int stdio, char *codepage) {
|
||||
char *arguments[4];
|
||||
int door_out;
|
||||
char buffer[10];
|
||||
@ -147,14 +148,14 @@ void rundoor(struct user_record *user, char *cmd, int stdio) {
|
||||
arguments[2] = strdup(buffer);
|
||||
arguments[3] = NULL;
|
||||
|
||||
runexternal(user, cmd, stdio, arguments, NULL, 0);
|
||||
runexternal(user, cmd, stdio, arguments, NULL, 0, codepage);
|
||||
|
||||
free(arguments[0]);
|
||||
free(arguments[1]);
|
||||
free(arguments[2]);
|
||||
}
|
||||
|
||||
void runexternal(struct user_record *user, char *cmd, int stdio, char *argv[], char *cwd, int raw) {
|
||||
void runexternal(struct user_record *user, char *cmd, int stdio, char *argv[], char *cwd, int raw, char *codepage) {
|
||||
|
||||
char buffer[1024];
|
||||
int pid;
|
||||
@ -172,7 +173,8 @@ void runexternal(struct user_record *user, char *cmd, int stdio, char *argv[], c
|
||||
int i;
|
||||
int gotiac;
|
||||
int flush;
|
||||
|
||||
iconv_t ic;
|
||||
|
||||
struct timeval thetimeout;
|
||||
struct termios oldit;
|
||||
struct termios oldot;
|
||||
@ -182,6 +184,13 @@ void runexternal(struct user_record *user, char *cmd, int stdio, char *argv[], c
|
||||
char outbuf[512];
|
||||
int h;
|
||||
int g;
|
||||
char *ptr1;
|
||||
char *ptr2;
|
||||
char *ptr2p;
|
||||
size_t ouc;
|
||||
size_t inc;
|
||||
size_t sz;
|
||||
|
||||
timeoutpaused = 1;
|
||||
|
||||
if (write_door32sys(user) != 0) {
|
||||
@ -302,7 +311,27 @@ void runexternal(struct user_record *user, char *cmd, int stdio, char *argv[], c
|
||||
}
|
||||
}
|
||||
}
|
||||
write(master, outbuf, g);
|
||||
if (codepage == NULL || (strcmp(codepage, "CP437") == 0 && user->codepage == 0) || (strcmp(codepage, "UTF-8") == 0 && user->codepage == 1)) {
|
||||
write(master, outbuf, g);
|
||||
} else {
|
||||
if (user->codepage == 0) {
|
||||
ic = iconv_open(codepage, "CP437");
|
||||
} else {
|
||||
ic = iconv_open(codepage, "UTF-8");
|
||||
}
|
||||
ptr1 = outbuf;
|
||||
ptr2 = (char *)malloc((g + 1) * 4);
|
||||
ptr2p = ptr2;
|
||||
memset(ptr2, 0, (g + 1) * 4);
|
||||
inc = g;
|
||||
ouc = (g + 1) * 4;
|
||||
|
||||
iconv(ic, &ptr1, &inc, &ptr2, &ouc);
|
||||
write(master, ptr2p, ptr2 - ptr2p);
|
||||
|
||||
free(ptr2p);
|
||||
iconv_close(ic);
|
||||
}
|
||||
} else if (FD_ISSET(master, &fdset)) {
|
||||
len = read(master, inbuf, 256);
|
||||
if (len == 0) {
|
||||
@ -317,7 +346,30 @@ void runexternal(struct user_record *user, char *cmd, int stdio, char *argv[], c
|
||||
}
|
||||
outbuf[g++] = c;
|
||||
}
|
||||
write(door_out, outbuf, g);
|
||||
if (codepage == NULL || (strcmp(codepage, "CP437") == 0 && user->codepage == 0) || (strcmp(codepage, "UTF-8") == 0 && user->codepage == 1)) {
|
||||
write(door_out, outbuf, g);
|
||||
} else {
|
||||
if (user->codepage == 0) {
|
||||
ic = iconv_open("CP437", codepage);
|
||||
} else {
|
||||
ic = iconv_open("UTF-8", codepage);
|
||||
}
|
||||
ptr1 = outbuf;
|
||||
ptr2 = (char *)malloc((g + 1) * 4);
|
||||
ptr2p = ptr2;
|
||||
memset(ptr2, 0, (g + 1) * 4);
|
||||
inc = g;
|
||||
ouc = (g + 1) * 4;
|
||||
|
||||
sz = iconv(ic, &ptr1, &inc, &ptr2, &ouc);
|
||||
if (sz == -1) {
|
||||
perror("Iconv");
|
||||
}
|
||||
write(door_out, ptr2p, ptr2 - ptr2p);
|
||||
|
||||
free(ptr2p);
|
||||
iconv_close(ic);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!running_door) {
|
||||
|
8
files.c
8
files.c
@ -439,11 +439,11 @@ int do_download(struct user_record *user, char *file) {
|
||||
|
||||
arguments[0] = download_command;
|
||||
|
||||
runexternal(user, download_command, conf.protocols[user->defprotocol - 1]->stdio, arguments, conf.bbs_path, 1);
|
||||
runexternal(user, download_command, conf.protocols[user->defprotocol - 1]->stdio, arguments, conf.bbs_path, 1, NULL);
|
||||
|
||||
free(arguments);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int do_upload(struct user_record *user, char *final_path) {
|
||||
@ -540,7 +540,7 @@ int do_upload(struct user_record *user, char *final_path) {
|
||||
|
||||
mkdir(upload_path, 0755);
|
||||
|
||||
runexternal(user, upload_command, conf.protocols[user->defprotocol - 1]->stdio, arguments, upload_path, 1);
|
||||
runexternal(user, upload_command, conf.protocols[user->defprotocol - 1]->stdio, arguments, upload_path, 1, NULL);
|
||||
|
||||
free(arguments);
|
||||
|
||||
@ -571,7 +571,7 @@ int do_upload(struct user_record *user, char *final_path) {
|
||||
}
|
||||
while ((dent = readdir(inb)) != NULL) {
|
||||
if (dent->d_type == DT_REG) {
|
||||
snprintf(upload_command, 1-24, "%s%s", upload_path, dent->d_name);
|
||||
snprintf(upload_command, 1024, "%s%s", upload_path, dent->d_name);
|
||||
snprintf(upload_filename, 1024, "%s/%s", final_path, dent->d_name);
|
||||
|
||||
if (stat(upload_filename, &s) == 0) {
|
||||
|
@ -100,8 +100,8 @@ int l_bbsMailScan(lua_State *L) {
|
||||
int l_bbsRunDoor(lua_State *L) {
|
||||
char *cmd = (char *)lua_tostring(L, 1);
|
||||
int stdio = lua_toboolean(L, 2);
|
||||
|
||||
rundoor(gUser, cmd, stdio);
|
||||
char *codepage = (char *)lua_tostring(L, 3);
|
||||
rundoor(gUser, cmd, stdio, codepage);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -219,3 +219,4 @@ File exists!\r\n
|
||||
\r\n\e[1;31mInvalid Node!\e[0m\r\n
|
||||
\r\n\e[1;37mEnter your message (256 chars max)...\e[0m\r\n
|
||||
%s on node %d says:\r\n %s\r\n\r\n
|
||||
\e[0;36mC. \e[1;37mCodepage (\e[1;33m%s\e[1;37m)\r\n
|
||||
|
@ -423,7 +423,7 @@ char *external_editor(struct user_record *user, char *to, char *from, char *quot
|
||||
}
|
||||
fclose(fptr);
|
||||
|
||||
rundoor(user, conf.external_editor_cmd, conf.external_editor_stdio);
|
||||
rundoor(user, conf.external_editor_cmd, conf.external_editor_stdio, conf.external_editor_codepage);
|
||||
|
||||
// readin msgtmp
|
||||
sprintf(buffer, "%s/node%d/MSGTMP", conf.bbs_path, mynode);
|
||||
|
15
main.c
15
main.c
@ -210,6 +210,8 @@ static int door_config_handler(void* user, const char* section, const char* name
|
||||
} else {
|
||||
conf->doors[i]->stdio = 0;
|
||||
}
|
||||
} else if (strcasecmp(name, "codepage") == 0) {
|
||||
conf->doors[i]->codepage = strdup(value);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -224,6 +226,7 @@ static int door_config_handler(void* user, const char* section, const char* name
|
||||
conf->doors[conf->door_count] = (struct door_config *)malloc(sizeof(struct door_config));
|
||||
|
||||
conf->doors[conf->door_count]->name = strdup(section);
|
||||
conf->doors[conf->door_count]->codepage = NULL;
|
||||
|
||||
if (strcasecmp(name, "command") == 0) {
|
||||
conf->doors[conf->door_count]->command = strdup(value);
|
||||
@ -233,6 +236,8 @@ static int door_config_handler(void* user, const char* section, const char* name
|
||||
} else {
|
||||
conf->doors[conf->door_count]->stdio = 0;
|
||||
}
|
||||
} else if (strcasecmp(name, "codepage") == 0) {
|
||||
conf->doors[conf->door_count]->codepage = strdup(value);
|
||||
}
|
||||
conf->door_count++;
|
||||
|
||||
@ -434,6 +439,8 @@ static int handler(void* user, const char* section, const char* name,
|
||||
conf->default_tagline = strdup(value);
|
||||
} else if (strcasecmp(name, "external editor cmd") == 0) {
|
||||
conf->external_editor_cmd = strdup(value);
|
||||
} else if (strcasecmp(name, "external editor codepage") == 0) {
|
||||
conf->external_editor_codepage = strdup(value);
|
||||
} else if (strcasecmp(name, "external editor stdio") == 0) {
|
||||
if (strcasecmp(value, "true") == 0) {
|
||||
conf->external_editor_stdio = 1;
|
||||
@ -479,6 +486,12 @@ static int handler(void* user, const char* section, const char* name,
|
||||
conf->ipguard_tries = atoi(value);
|
||||
} else if (strcasecmp(name, "root menu") == 0) {
|
||||
conf->root_menu = strdup(value);
|
||||
} else if (strcasecmp(name, "codepage") == 0) {
|
||||
if (strcasecmp(value, "cp437") == 0) {
|
||||
conf->codepage = 0;
|
||||
} else if (strcasecmp(value, "utf-8") == 0) {
|
||||
conf->codepage = 1;
|
||||
}
|
||||
}
|
||||
} else if (strcasecmp(section, "paths") == 0){
|
||||
if (strcasecmp(name, "ansi path") == 0) {
|
||||
@ -1137,6 +1150,7 @@ int main(int argc, char **argv) {
|
||||
conf.mgchat_bbstag = NULL;
|
||||
conf.text_file_count = 0;
|
||||
conf.external_editor_cmd = NULL;
|
||||
conf.external_editor_codepage = NULL;
|
||||
conf.log_path = NULL;
|
||||
conf.script_path = NULL;
|
||||
conf.automsgwritelvl = 10;
|
||||
@ -1154,6 +1168,7 @@ int main(int argc, char **argv) {
|
||||
conf.ipguard_tries = 4;
|
||||
conf.ipguard_timeout = 120;
|
||||
conf.protocol_count = 0;
|
||||
conf.codepage = 0;
|
||||
|
||||
// Load BBS data
|
||||
if (ini_parse(argv[1], handler, &conf) <0) {
|
||||
|
3
menus.c
3
menus.c
@ -2,6 +2,7 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include "bbs.h"
|
||||
#include "lua/lua.h"
|
||||
#include "lua/lualib.h"
|
||||
@ -370,7 +371,7 @@ int menu_system(char *menufile) {
|
||||
for (j=0;j<conf.door_count;j++) {
|
||||
if (strcasecmp(menu[i]->data, conf.doors[j]->name) == 0) {
|
||||
dolog("%s launched door %s, on node %d", gUser->loginname, conf.doors[j]->name, mynode);
|
||||
rundoor(gUser, conf.doors[j]->command, conf.doors[j]->stdio);
|
||||
rundoor(gUser, conf.doors[j]->command, conf.doors[j]->stdio, conf.doors[j]->codepage);
|
||||
dolog("%s returned from door %s, on node %d", gUser->loginname, conf.doors[j]->name, mynode);
|
||||
break;
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ void settings_menu(struct user_record *user) {
|
||||
s_printf(get_string(205), conf.archivers[user->defarchiver - 1]->name);
|
||||
s_printf(get_string(213), conf.protocols[user->defprotocol - 1]->name);
|
||||
s_printf(get_string(215), (user->nodemsgs ? "TRUE" : "FALSE"));
|
||||
s_printf(get_string(221), (user->codepage ? "UTF-8" : "CP437"));
|
||||
s_printf(get_string(153));
|
||||
s_printf(get_string(154));
|
||||
|
||||
@ -118,6 +119,12 @@ void settings_menu(struct user_record *user) {
|
||||
save_user(user);
|
||||
}
|
||||
break;
|
||||
case 'c':
|
||||
{
|
||||
user->codepage = !user->codepage;
|
||||
save_user(user);
|
||||
}
|
||||
break;
|
||||
case 'q':
|
||||
dosettings = 1;
|
||||
break;
|
||||
|
15
users.c
15
users.c
@ -81,7 +81,7 @@ int save_user(struct user_record *user) {
|
||||
int rc;
|
||||
|
||||
char *update_sql = "UPDATE users SET password=?, salt=?, firstname=?,"
|
||||
"lastname=?, email=?, location=?, sec_level=?, last_on=?, time_left=?, cur_mail_conf=?, cur_mail_area=?, cur_file_dir=?, cur_file_sub=?, times_on=?, bwavepktno=?, archiver=?, protocol=?,nodemsgs=? where loginname LIKE ?";
|
||||
"lastname=?, email=?, location=?, sec_level=?, last_on=?, time_left=?, cur_mail_conf=?, cur_mail_area=?, cur_file_dir=?, cur_file_sub=?, times_on=?, bwavepktno=?, archiver=?, protocol=?,nodemsgs=?,codepage=? where loginname LIKE ?";
|
||||
|
||||
sprintf(buffer, "%s/users.sq3", conf.bbs_path);
|
||||
|
||||
@ -115,7 +115,8 @@ sqlite3_busy_timeout(db, 5000);
|
||||
sqlite3_bind_int(res, 16, user->defarchiver);
|
||||
sqlite3_bind_int(res, 17, user->defprotocol);
|
||||
sqlite3_bind_int(res, 18, user->nodemsgs);
|
||||
sqlite3_bind_text(res, 19, user->loginname, -1, 0);
|
||||
sqlite3_bind_int(res, 19, user->codepage);
|
||||
sqlite3_bind_text(res, 20, user->loginname, -1, 0);
|
||||
} else {
|
||||
dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
|
||||
}
|
||||
@ -159,10 +160,11 @@ int inst_user(struct user_record *user) {
|
||||
"bwavepktno INTEGER,"
|
||||
"archiver INTEGER,"
|
||||
"protocol INTEGER,"
|
||||
"nodemsgs INTEGER);";
|
||||
"nodemsgs INTEGER,"
|
||||
"codepage INTEGER);";
|
||||
|
||||
char *insert_sql = "INSERT INTO users (loginname, password, salt, firstname,"
|
||||
"lastname, email, location, sec_level, last_on, time_left, cur_mail_conf, cur_mail_area, cur_file_dir, cur_file_sub, times_on, bwavepktno, archiver, protocol, nodemsgs) VALUES(?,?, ?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
"lastname, email, location, sec_level, last_on, time_left, cur_mail_conf, cur_mail_area, cur_file_dir, cur_file_sub, times_on, bwavepktno, archiver, protocol, nodemsgs, codepage) VALUES(?,?, ?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
char *err_msg = 0;
|
||||
|
||||
sprintf(buffer, "%s/users.sq3", conf.bbs_path);
|
||||
@ -209,6 +211,7 @@ sqlite3_busy_timeout(db, 5000);
|
||||
sqlite3_bind_int(res, 17, user->defarchiver);
|
||||
sqlite3_bind_int(res, 18, user->defprotocol);
|
||||
sqlite3_bind_int(res, 19, user->nodemsgs);
|
||||
sqlite3_bind_int(res, 20, user->codepage);
|
||||
} else {
|
||||
dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
|
||||
}
|
||||
@ -236,7 +239,7 @@ struct user_record *check_user_pass(char *loginname, char *password) {
|
||||
sqlite3_stmt *res;
|
||||
int rc;
|
||||
char *sql = "SELECT Id, loginname, password, salt, firstname,"
|
||||
"lastname, email, location, sec_level, last_on, time_left, cur_mail_conf, cur_mail_area, cur_file_dir, cur_file_sub, times_on, bwavepktno, archiver, protocol,nodemsgs FROM users WHERE loginname LIKE ?";
|
||||
"lastname, email, location, sec_level, last_on, time_left, cur_mail_conf, cur_mail_area, cur_file_dir, cur_file_sub, times_on, bwavepktno, archiver, protocol,nodemsgs, codepage FROM users WHERE loginname LIKE ?";
|
||||
char *pass_hash;
|
||||
|
||||
sprintf(buffer, "%s/users.sq3", conf.bbs_path);
|
||||
@ -284,6 +287,7 @@ struct user_record *check_user_pass(char *loginname, char *password) {
|
||||
user->defarchiver = sqlite3_column_int(res, 17);
|
||||
user->defprotocol = sqlite3_column_int(res, 18);
|
||||
user->nodemsgs = sqlite3_column_int(res, 19);
|
||||
user->codepage = sqlite3_column_int(res, 20);
|
||||
pass_hash = hash_sha256(password, user->salt);
|
||||
|
||||
if (strcmp(pass_hash, user->password) != 0) {
|
||||
@ -568,6 +572,7 @@ struct user_record *new_user() {
|
||||
user->defprotocol = 1;
|
||||
user->defarchiver = 1;
|
||||
user->nodemsgs = 1;
|
||||
user->codepage = conf.codepage;
|
||||
inst_user(user);
|
||||
|
||||
return user;
|
||||
|
@ -116,3 +116,23 @@ if (check_exists("nodemsgs") == 0) {
|
||||
$dbh->do($sql);
|
||||
$dbh->disconnect;
|
||||
}
|
||||
|
||||
if (check_exists("codepage") == 0) {
|
||||
print "Column \"codepage\" doesn't exist... adding..\n";
|
||||
|
||||
my ($needed) = @_;
|
||||
|
||||
my $dsn = "dbi:SQLite:dbname=$dbfile";
|
||||
my $user = "";
|
||||
my $password = "";
|
||||
my $dbh = DBI->connect($dsn, $user, $password, {
|
||||
PrintError => 0,
|
||||
RaiseError => 1,
|
||||
AutoCommit => 1,
|
||||
FetchHashKeyName => 'NAME_lc',
|
||||
});
|
||||
|
||||
my $sql = "ALTER TABLE users ADD COLUMN codepage INTEGER DEFAULT 0";
|
||||
$dbh->do($sql);
|
||||
$dbh->disconnect;
|
||||
}
|
Reference in New Issue
Block a user