Make showing node msgs optional
This commit is contained in:
parent
96a613d706
commit
71f9fe9b92
1
bbs.h
1
bbs.h
@ -198,6 +198,7 @@ struct user_record {
|
||||
int bwavepktno;
|
||||
int defarchiver;
|
||||
int defprotocol;
|
||||
int nodemsgs;
|
||||
};
|
||||
|
||||
struct jam_msg {
|
||||
|
@ -213,3 +213,4 @@ Sorry, this %s is unavailable over SSH\r\n
|
||||
\r\n\e[1;32mSelect a protocol...\e[0m\r\n\r\n
|
||||
\e[0;36mO. \e[1;37mDefault Protocol (\e[1;33m%s\e[1;37m)\r\n
|
||||
File exists!\r\n
|
||||
\e[0;36mM. \e[1;37mShow Node Msgs(\e[1;33m%s\e[1;37m)\r\n
|
||||
|
30
menus.c
30
menus.c
@ -233,23 +233,25 @@ int menu_system(char *menufile) {
|
||||
|
||||
|
||||
while (!doquit) {
|
||||
snprintf(buffer, PATH_MAX, "%s/node%d/nodemsg.txt", conf.bbs_path, mynode);
|
||||
if (gUser->nodemsgs) {
|
||||
snprintf(buffer, PATH_MAX, "%s/node%d/nodemsg.txt", conf.bbs_path, mynode);
|
||||
|
||||
if (stat(buffer, &s) == 0) {
|
||||
fptr = fopen(buffer, "r");
|
||||
if (fptr) {
|
||||
fgets(buffer, PATH_MAX, fptr);
|
||||
while (!feof(fptr)) {
|
||||
chomp(buffer);
|
||||
s_printf("\r\n%s\r\n", buffer);
|
||||
if (stat(buffer, &s) == 0) {
|
||||
fptr = fopen(buffer, "r");
|
||||
if (fptr) {
|
||||
fgets(buffer, PATH_MAX, fptr);
|
||||
}
|
||||
fclose(fptr);
|
||||
snprintf(buffer, PATH_MAX, "%s/node%d/nodemsg.txt", conf.bbs_path, mynode);
|
||||
unlink(buffer);
|
||||
while (!feof(fptr)) {
|
||||
chomp(buffer);
|
||||
s_printf("\r\n%s\r\n", buffer);
|
||||
fgets(buffer, PATH_MAX, fptr);
|
||||
}
|
||||
fclose(fptr);
|
||||
snprintf(buffer, PATH_MAX, "%s/node%d/nodemsg.txt", conf.bbs_path, mynode);
|
||||
unlink(buffer);
|
||||
|
||||
s_printf(get_string(6));
|
||||
c = s_getc();
|
||||
s_printf(get_string(6));
|
||||
c = s_getc();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (do_lua_menu == 0) {
|
||||
|
@ -21,6 +21,7 @@ void settings_menu(struct user_record *user) {
|
||||
s_printf(get_string(152), user->location);
|
||||
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(153));
|
||||
s_printf(get_string(154));
|
||||
|
||||
@ -111,6 +112,12 @@ void settings_menu(struct user_record *user) {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'm':
|
||||
{
|
||||
user->nodemsgs = !user->nodemsgs;
|
||||
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=? 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=? where loginname LIKE ?";
|
||||
|
||||
sprintf(buffer, "%s/users.sq3", conf.bbs_path);
|
||||
|
||||
@ -114,7 +114,8 @@ sqlite3_busy_timeout(db, 5000);
|
||||
sqlite3_bind_int(res, 15, user->bwavepktno);
|
||||
sqlite3_bind_int(res, 16, user->defarchiver);
|
||||
sqlite3_bind_int(res, 17, user->defprotocol);
|
||||
sqlite3_bind_text(res, 18, user->loginname, -1, 0);
|
||||
sqlite3_bind_int(res, 18, user->nodemsgs);
|
||||
sqlite3_bind_text(res, 19, user->loginname, -1, 0);
|
||||
} else {
|
||||
dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
|
||||
}
|
||||
@ -157,10 +158,11 @@ int inst_user(struct user_record *user) {
|
||||
"times_on INTEGER,"
|
||||
"bwavepktno INTEGER,"
|
||||
"archiver INTEGER,"
|
||||
"protocol INTEGER);";
|
||||
"protocol INTEGER,"
|
||||
"nodemsgs 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) 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) VALUES(?,?, ?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
char *err_msg = 0;
|
||||
|
||||
sprintf(buffer, "%s/users.sq3", conf.bbs_path);
|
||||
@ -206,6 +208,7 @@ sqlite3_busy_timeout(db, 5000);
|
||||
sqlite3_bind_int(res, 16, user->bwavepktno);
|
||||
sqlite3_bind_int(res, 17, user->defarchiver);
|
||||
sqlite3_bind_int(res, 18, user->defprotocol);
|
||||
sqlite3_bind_int(res, 19, user->nodemsgs);
|
||||
} else {
|
||||
dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
|
||||
}
|
||||
@ -233,7 +236,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 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 FROM users WHERE loginname LIKE ?";
|
||||
char *pass_hash;
|
||||
|
||||
sprintf(buffer, "%s/users.sq3", conf.bbs_path);
|
||||
@ -280,6 +283,7 @@ struct user_record *check_user_pass(char *loginname, char *password) {
|
||||
user->bwavepktno = sqlite3_column_int(res, 16);
|
||||
user->defarchiver = sqlite3_column_int(res, 17);
|
||||
user->defprotocol = sqlite3_column_int(res, 18);
|
||||
user->nodemsgs = sqlite3_column_int(res, 19);
|
||||
pass_hash = hash_sha256(password, user->salt);
|
||||
|
||||
if (strcmp(pass_hash, user->password) != 0) {
|
||||
@ -563,6 +567,7 @@ struct user_record *new_user() {
|
||||
user->timeson = 0;
|
||||
user->defprotocol = 1;
|
||||
user->defarchiver = 1;
|
||||
user->nodemsgs = 1;
|
||||
inst_user(user);
|
||||
|
||||
return user;
|
||||
|
@ -97,3 +97,22 @@ if (check_exists("bwavepktno") == 0) {
|
||||
$dbh->disconnect;
|
||||
}
|
||||
|
||||
if (check_exists("nodemsgs") == 0) {
|
||||
print "Column \"nodemsgs\" 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 nodemsgs INTEGER DEFAULT 1";
|
||||
$dbh->do($sql);
|
||||
$dbh->disconnect;
|
||||
}
|
||||
|
Reference in New Issue
Block a user