2016-04-10 18:45:02 +10:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include "bbs.h"
|
|
|
|
|
2016-12-08 16:32:05 +10:00
|
|
|
extern struct bbs_config conf;
|
|
|
|
|
2016-08-06 14:36:36 +10:00
|
|
|
void settings_menu(struct user_record *user) {
|
2016-04-10 18:45:02 +10:00
|
|
|
char buffer[256];
|
|
|
|
int dosettings = 0;
|
|
|
|
char c;
|
2016-08-05 07:43:11 +10:00
|
|
|
char *hash;
|
2016-12-08 16:32:05 +10:00
|
|
|
int new_arc;
|
|
|
|
int i;
|
2018-01-13 19:17:22 +10:00
|
|
|
char *sig;
|
2016-08-05 07:43:11 +10:00
|
|
|
|
2016-04-10 18:45:02 +10:00
|
|
|
while (!dosettings) {
|
2018-10-16 15:05:15 +00:00
|
|
|
struct archiver *arc = ptr_vector_get(&conf.archivers, user->defarchiver - 1);
|
|
|
|
struct protocol *proto = ptr_vector_get(&conf.protocols, user->defprotocol - 1);
|
2016-08-14 19:56:15 +10:00
|
|
|
s_printf(get_string(149));
|
|
|
|
s_printf(get_string(150));
|
|
|
|
s_printf(get_string(151));
|
|
|
|
s_printf(get_string(152), user->location);
|
2018-10-16 15:05:15 +00:00
|
|
|
s_printf(get_string(205), arc->name);
|
|
|
|
s_printf(get_string(213), proto->name);
|
2017-04-19 15:57:29 +10:00
|
|
|
s_printf(get_string(215), (user->nodemsgs ? "TRUE" : "FALSE"));
|
2017-04-23 12:28:01 +10:00
|
|
|
s_printf(get_string(221), (user->codepage ? "UTF-8" : "CP437"));
|
2017-09-11 16:10:38 +10:00
|
|
|
switch (user->exteditor) {
|
|
|
|
case 0:
|
2018-10-15 14:37:51 +00:00
|
|
|
strlcpy(buffer, "NO", sizeof buffer);
|
2017-09-11 16:10:38 +10:00
|
|
|
break;
|
|
|
|
case 1:
|
2018-10-15 14:37:51 +00:00
|
|
|
strlcpy(buffer, "YES", sizeof buffer);
|
2017-09-11 16:10:38 +10:00
|
|
|
break;
|
|
|
|
case 2:
|
2018-10-15 14:37:51 +00:00
|
|
|
strlcpy(buffer, "ASK", sizeof buffer);
|
2017-09-11 16:10:38 +10:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
s_printf(get_string(222), buffer);
|
2017-10-18 07:43:33 +10:00
|
|
|
s_printf(get_string(235), (user->bwavestyle ? "mo?,tu? ..." : "000-999"));
|
2018-01-13 19:17:22 +10:00
|
|
|
s_printf(get_string(245));
|
|
|
|
s_printf(get_string(246), (user->autosig ? "TRUE" : "FALSE"));
|
2016-08-14 19:56:15 +10:00
|
|
|
s_printf(get_string(153));
|
|
|
|
s_printf(get_string(154));
|
2016-08-05 07:43:11 +10:00
|
|
|
|
2016-08-06 14:36:36 +10:00
|
|
|
c = s_getc();
|
2016-08-05 07:43:11 +10:00
|
|
|
|
2018-10-08 14:13:11 +00:00
|
|
|
switch (tolower(c)) {
|
|
|
|
case 27: {
|
|
|
|
c = s_getc();
|
|
|
|
if (c == 91) {
|
2016-12-02 15:31:29 +10:00
|
|
|
c = s_getc();
|
|
|
|
}
|
2018-10-08 14:13:11 +00:00
|
|
|
} break;
|
|
|
|
case 'p': {
|
|
|
|
s_printf(get_string(155));
|
|
|
|
s_readpass(buffer, 16);
|
|
|
|
hash = hash_sha256(buffer, user->salt);
|
|
|
|
if (strcmp(hash, user->password) == 0) {
|
|
|
|
s_printf(get_string(156));
|
|
|
|
s_readstring(buffer, 16);
|
|
|
|
if (strlen(buffer) >= 8) {
|
|
|
|
free(user->password);
|
|
|
|
free(user->salt);
|
2016-08-05 07:43:11 +10:00
|
|
|
|
2018-10-08 14:13:11 +00:00
|
|
|
gen_salt(&user->salt);
|
|
|
|
user->password = hash_sha256(buffer, user->salt);
|
2016-08-05 07:43:11 +10:00
|
|
|
|
2016-12-08 16:32:05 +10:00
|
|
|
save_user(user);
|
2018-10-08 14:13:11 +00:00
|
|
|
s_printf(get_string(157));
|
2016-12-10 17:55:47 +10:00
|
|
|
} else {
|
2018-10-08 14:13:11 +00:00
|
|
|
s_printf(get_string(158));
|
2016-12-10 17:55:47 +10:00
|
|
|
}
|
2018-10-08 14:13:11 +00:00
|
|
|
} else {
|
|
|
|
s_printf(get_string(159));
|
2016-12-10 17:55:47 +10:00
|
|
|
}
|
2018-10-08 14:13:11 +00:00
|
|
|
} break;
|
|
|
|
case 'l': {
|
|
|
|
s_printf(get_string(160));
|
|
|
|
s_readstring(buffer, 32);
|
|
|
|
free(user->location);
|
2018-10-09 15:55:13 +00:00
|
|
|
user->location = strdup(buffer);
|
2018-10-08 14:13:11 +00:00
|
|
|
save_user(user);
|
|
|
|
} break;
|
|
|
|
case 'a': {
|
|
|
|
s_printf(get_string(206));
|
|
|
|
|
2018-10-16 15:05:15 +00:00
|
|
|
for (i = 0; i < ptr_vector_len(&conf.archivers); i++) {
|
|
|
|
struct archiver *arc = ptr_vector_get(&conf.archivers, i);
|
|
|
|
s_printf(get_string(207), i + 1, arc->name);
|
2017-04-19 15:57:29 +10:00
|
|
|
}
|
2018-10-08 14:13:11 +00:00
|
|
|
|
|
|
|
s_printf(get_string(208));
|
|
|
|
s_readstring(buffer, 5);
|
|
|
|
new_arc = atoi(buffer);
|
|
|
|
|
2018-10-16 15:05:15 +00:00
|
|
|
if (new_arc - 1 < 0 || new_arc > ptr_vector_len(&conf.archivers)) {
|
2018-10-08 14:13:11 +00:00
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
user->defarchiver = new_arc;
|
2017-04-23 12:28:01 +10:00
|
|
|
save_user(user);
|
|
|
|
}
|
2018-10-08 14:13:11 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case 'o': {
|
|
|
|
s_printf(get_string(212));
|
|
|
|
|
2018-10-16 15:05:15 +00:00
|
|
|
for (i = 0; i < ptr_vector_len(&conf.protocols); i++) {
|
|
|
|
struct protocol *proto = ptr_vector_get(&conf.protocols, i);
|
|
|
|
s_printf(get_string(207), i + 1, proto->name);
|
2017-09-11 16:10:38 +10:00
|
|
|
}
|
2018-10-08 14:13:11 +00:00
|
|
|
|
|
|
|
s_printf(get_string(208));
|
|
|
|
s_readstring(buffer, 5);
|
|
|
|
new_arc = atoi(buffer);
|
|
|
|
|
2018-10-16 15:05:15 +00:00
|
|
|
if (new_arc - 1 < 0 || new_arc > ptr_vector_len(&conf.protocols)) {
|
2018-10-08 14:13:11 +00:00
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
user->defprotocol = new_arc;
|
2017-10-18 07:36:58 +10:00
|
|
|
save_user(user);
|
|
|
|
}
|
2018-10-08 14:13:11 +00:00
|
|
|
} break;
|
|
|
|
case 'm': {
|
|
|
|
user->nodemsgs = !user->nodemsgs;
|
|
|
|
save_user(user);
|
|
|
|
} break;
|
|
|
|
case 'c': {
|
|
|
|
user->codepage = !user->codepage;
|
|
|
|
save_user(user);
|
|
|
|
} break;
|
|
|
|
case 'e': {
|
|
|
|
user->exteditor++;
|
|
|
|
if (user->exteditor == 3) {
|
|
|
|
user->exteditor = 0;
|
2018-01-13 19:17:22 +10:00
|
|
|
}
|
2018-10-08 14:13:11 +00:00
|
|
|
save_user(user);
|
|
|
|
} break;
|
|
|
|
case 'b': {
|
|
|
|
user->bwavepktno = 0;
|
|
|
|
user->bwavestyle = !user->bwavestyle;
|
|
|
|
save_user(user);
|
|
|
|
} break;
|
|
|
|
case 's': {
|
|
|
|
// set signature
|
|
|
|
if (user->signature != NULL) {
|
|
|
|
free(user->signature);
|
|
|
|
}
|
|
|
|
sig = external_editor(user, "No-One", "No-One", NULL, 0, "No-One", "Signature Editor", 0, 1);
|
|
|
|
if (sig != NULL) {
|
|
|
|
user->signature = sig;
|
2018-01-13 19:17:22 +10:00
|
|
|
save_user(user);
|
|
|
|
}
|
2018-10-08 14:13:11 +00:00
|
|
|
} break;
|
|
|
|
case 't': {
|
|
|
|
user->autosig = !user->autosig;
|
|
|
|
save_user(user);
|
|
|
|
} break;
|
2016-04-10 18:45:02 +10:00
|
|
|
case 'q':
|
|
|
|
dosettings = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|