More work on utf8
This commit is contained in:
parent
6027021d4f
commit
8b611fc3fe
3
bbs.c
3
bbs.c
@ -210,6 +210,9 @@ void s_printf(char *fmt, ...) {
|
||||
}
|
||||
|
||||
int should_convert_utf8() {
|
||||
if (gUser != NULL) {
|
||||
return gUser->codepage;
|
||||
}
|
||||
return conf.codepage;
|
||||
}
|
||||
|
||||
|
1
bbs.h
1
bbs.h
@ -202,6 +202,7 @@ struct user_record {
|
||||
int defarchiver;
|
||||
int defprotocol;
|
||||
int nodemsgs;
|
||||
int codepage;
|
||||
};
|
||||
|
||||
struct jam_msg {
|
||||
|
4
files.c
4
files.c
@ -443,7 +443,7 @@ int do_download(struct user_record *user, char *file) {
|
||||
|
||||
free(arguments);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int do_upload(struct user_record *user, char *final_path) {
|
||||
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user