2016-04-10 08:45:02 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include "bbs.h"
|
|
|
|
|
2016-12-08 06:32:05 +00:00
|
|
|
extern struct bbs_config conf;
|
|
|
|
|
2016-08-06 04:36:36 +00:00
|
|
|
void settings_menu(struct user_record *user) {
|
2016-04-10 08:45:02 +00:00
|
|
|
char buffer[256];
|
|
|
|
int dosettings = 0;
|
|
|
|
char c;
|
2016-08-04 21:43:11 +00:00
|
|
|
char *hash;
|
2016-12-08 06:32:05 +00:00
|
|
|
int new_arc;
|
|
|
|
int i;
|
2016-08-04 21:43:11 +00:00
|
|
|
|
2016-04-10 08:45:02 +00:00
|
|
|
while (!dosettings) {
|
2016-08-14 09:56:15 +00:00
|
|
|
s_printf(get_string(149));
|
|
|
|
s_printf(get_string(150));
|
|
|
|
s_printf(get_string(151));
|
|
|
|
s_printf(get_string(152), user->location);
|
2016-12-08 06:32:05 +00:00
|
|
|
s_printf(get_string(205), conf.archivers[user->defarchiver - 1]->name);
|
2016-08-14 09:56:15 +00:00
|
|
|
s_printf(get_string(153));
|
|
|
|
s_printf(get_string(154));
|
2016-08-04 21:43:11 +00:00
|
|
|
|
2016-08-06 04:36:36 +00:00
|
|
|
c = s_getc();
|
2016-08-04 21:43:11 +00:00
|
|
|
|
2016-04-10 08:45:02 +00:00
|
|
|
switch(tolower(c)) {
|
2016-12-02 05:31:29 +00:00
|
|
|
case 27:
|
|
|
|
{
|
|
|
|
c = s_getc();
|
|
|
|
if (c == 91) {
|
|
|
|
c = s_getc();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2016-04-10 08:45:02 +00:00
|
|
|
case 'p':
|
|
|
|
{
|
2016-08-14 09:56:15 +00:00
|
|
|
s_printf(get_string(155));
|
2016-08-06 04:36:36 +00:00
|
|
|
s_readpass(buffer, 16);
|
2016-08-04 21:43:11 +00:00
|
|
|
hash = hash_sha256(buffer, user->salt);
|
|
|
|
if (strcmp(hash, user->password) == 0) {
|
2016-08-14 09:56:15 +00:00
|
|
|
s_printf(get_string(156));
|
2016-08-06 04:36:36 +00:00
|
|
|
s_readstring(buffer, 16);
|
2016-04-10 08:45:02 +00:00
|
|
|
if (strlen(buffer) >= 8) {
|
|
|
|
free(user->password);
|
2016-08-04 21:43:11 +00:00
|
|
|
free(user->salt);
|
|
|
|
|
|
|
|
gen_salt(&user->salt);
|
|
|
|
user->password = hash_sha256(buffer, user->salt);
|
|
|
|
|
2016-04-10 08:45:02 +00:00
|
|
|
save_user(user);
|
2016-08-14 09:56:15 +00:00
|
|
|
s_printf(get_string(157));
|
2016-04-10 08:45:02 +00:00
|
|
|
} else {
|
2016-08-14 09:56:15 +00:00
|
|
|
s_printf(get_string(158));
|
2016-04-10 08:45:02 +00:00
|
|
|
}
|
|
|
|
} else {
|
2016-08-14 09:56:15 +00:00
|
|
|
s_printf(get_string(159));
|
2016-04-10 08:45:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'l':
|
|
|
|
{
|
2016-08-14 09:56:15 +00:00
|
|
|
s_printf(get_string(160));
|
2016-08-06 04:36:36 +00:00
|
|
|
s_readstring(buffer, 32);
|
2016-04-10 08:45:02 +00:00
|
|
|
free(user->location);
|
|
|
|
user->location = (char *)malloc(strlen(buffer) + 1);
|
|
|
|
strcpy(user->location, buffer);
|
|
|
|
save_user(user);
|
|
|
|
}
|
|
|
|
break;
|
2016-12-08 06:32:05 +00:00
|
|
|
case 'a':
|
|
|
|
{
|
|
|
|
s_printf(get_string(206));
|
|
|
|
|
|
|
|
for (i=0;i<conf.archiver_count;i++) {
|
|
|
|
s_printf(get_string(207), i + 1, conf.archivers[i]->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
s_printf(get_string(208));
|
|
|
|
s_readstring(buffer, 5);
|
|
|
|
new_arc = atoi(buffer);
|
|
|
|
|
|
|
|
if (new_arc - 1 < 0 || new_arc > conf.archiver_count) {
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
user->defarchiver = new_arc;
|
|
|
|
save_user(user);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2016-04-10 08:45:02 +00:00
|
|
|
case 'q':
|
|
|
|
dosettings = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|