diff --git a/ansis/doors.ans b/ansis/doors.ans new file mode 100644 index 0000000..bb8c045 --- /dev/null +++ b/ansis/doors.ans @@ -0,0 +1,15 @@ +[?7h + ÜÜÜÜÜÜ ÜÜÜÜÜÜÜ ÜÜÜÜÜÜÜ ÜÜÜÜÜÜ ÜÜÜÜÜÜÜ ÜÜÜÜÜÜ ÜÜÜÜÜÜÜÜÜÜÜ ÜÜÜÜÜÜÜ ÜÜÜÜÜÜÜ + ²ßÜ ²Û²ßÜ Û²²ßÜ Û²ÛÛ°Ü ²Û²ßÜÜÜÜ ²ß° ²Û²ß°Ü ²ß°Ü ²Û²ßÜÜ ßß ²ÛÜÜÜÜÜ + ±Û ßÜ±Û °²Üß ² °²Üß ² ²² ² °ß±ÛÜ ±ß°²ßß߱߰² ² °² ² ±ß±²Ü° ²ßÜÜ ²ß + ßßßßßß° ßßßßßß ßßßßßß ßß°°ßßßßßß ßß ß °Û ßß ß ßß ß °Û ßßßßßß ßßßßßß° + ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + ³ 0. Example Door³³ + ³³³ + ³³³ + ³³³ + ³³³ + ³³ Q. Quit to Main Menu³ + ³³ G. Goodbye (Log Off)³ + ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + diff --git a/ansis/mainmenu.ans b/ansis/mainmenu.ans index 9f57caa..bda94ef 100644 --- a/ansis/mainmenu.ans +++ b/ansis/mainmenu.ans @@ -4,10 +4,10 @@ °² ² °² ² ±ß°²ßß߲߱² °² ² ±ß°² ² °² ² ±ß±²Ü° ²ß°² ² ±ß°²Üß ²  ßß ß ßß ß °Û ßß ß °Û ßß ßß ß °Û ßß ß ßß ß °Û ßßßßßß ßß ß °Û ßßßßßß ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - ³ M. Message Areas³ L. BBS List³ - ³ T. File Areas³ C. Chat System³ + ³ M. Message Areas³ L. BBS List³ + ³ T. File Areas³ C. Chat System³ ³ B. Bulletins³ U. User List³ - ³ O. Online Games³ 1. Last 10 Callers³ + ³ D. Online Games³ 1. Last 10 Callers³ ³³³ ³³³ ³³ G. Goodbye (Log Off)³ diff --git a/bbs.c b/bbs.c index 7748dc6..18e5190 100644 --- a/bbs.c +++ b/bbs.c @@ -551,7 +551,7 @@ void runbbs(int socket, char *config_path) { save_user(user); } gUser = user; - + user->timeson++; // bulletins i = 0; sprintf(buffer, "%s/bulletin%d.ans", conf.ansi_path, i); diff --git a/bbs.h b/bbs.h index 4ee6e5f..359922d 100644 --- a/bbs.h +++ b/bbs.h @@ -73,6 +73,7 @@ struct user_record { int cur_mail_area; int cur_file_dir; int cur_file_sub; + int timeson; }; @@ -92,7 +93,7 @@ extern int save_user(struct user_record *user); extern int check_user(char *loginname); extern struct user_record *new_user(int socket); extern struct user_record *check_user_pass(int socket, char *loginname, char *password); - +extern void list_users(int socket, struct user_record *user); extern void main_menu(int socket, struct user_record *user); diff --git a/main_menu.c b/main_menu.c index a433ce3..98ad084 100644 --- a/main_menu.c +++ b/main_menu.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "bbs.h" extern struct bbs_config conf; @@ -9,7 +10,9 @@ void main_menu(int socket, struct user_record *user) { int doquit = 0; char c; char prompt[128]; - + char buffer[256]; + int i; + struct stat s; while (!doquit) { s_displayansi(socket, "mainmenu"); @@ -20,6 +23,27 @@ void main_menu(int socket, struct user_record *user) { c = s_getc(socket); switch(tolower(c)) { + case 'u': + { + list_users(socket, user); + } + break; + case 'b': + { + i = 0; + sprintf(buffer, "%s/bulletin%d.ans", conf.ansi_path, i); + + while (stat(buffer, &s) == 0) { + sprintf(buffer, "bulletin%d", i); + s_displayansi(socket, buffer); + sprintf(buffer, "Press any key to continue...\r\n"); + s_putstring(socket, buffer); + s_getc(socket); + i++; + sprintf(buffer, "%s/bulletin%d.ans", conf.ansi_path, i); + } + } + break; case '1': { display_last10_callers(socket, user, 0); diff --git a/users.c b/users.c index edb4937..82b873a 100644 --- a/users.c +++ b/users.c @@ -28,7 +28,7 @@ int save_user(struct user_record *user) { int rc; char *update_sql = "UPDATE users SET password=?, firstname=?," - "lastname=?, email=?, location=?, sec_level=?, last_on=?, time_left=?, cur_mail_conf=?, cur_mail_area=?, cur_file_dir=?, cur_file_sub=? 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=? where loginname LIKE ?"; char *err_msg = 0; sprintf(buffer, "%s/users.sq3", conf.bbs_path); @@ -57,7 +57,8 @@ int save_user(struct user_record *user) { sqlite3_bind_int(res, 10, user->cur_mail_area); sqlite3_bind_int(res, 11, user->cur_file_dir); sqlite3_bind_int(res, 12, user->cur_file_sub); - sqlite3_bind_text(res, 13, user->loginname, -1, 0); + sqlite3_bind_int(res, 13, user->timeson); + sqlite3_bind_text(res, 14, user->loginname, -1, 0); } else { fprintf(stderr, "Failed to execute statement: %s\n", sqlite3_errmsg(db)); } @@ -95,10 +96,11 @@ int inst_user(struct user_record *user) { "cur_mail_conf INTEGER," "cur_mail_area INTEGER," "cur_file_sub INTEGER," - "cur_file_dir INTEGER);"; + "cur_file_dir INTEGER," + "times_on INTEGER);"; char *insert_sql = "INSERT INTO users (loginname, password, firstname," - "lastname, email, location, sec_level, last_on, time_left, cur_mail_conf, cur_mail_area, cur_file_dir, cur_file_sub) VALUES(?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + "lastname, email, location, sec_level, last_on, time_left, cur_mail_conf, cur_mail_area, cur_file_dir, cur_file_sub, times_on) VALUES(?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; char *err_msg = 0; sprintf(buffer, "%s/users.sq3", conf.bbs_path); @@ -139,6 +141,7 @@ int inst_user(struct user_record *user) { sqlite3_bind_int(res, 11, user->cur_mail_area); sqlite3_bind_int(res, 12, user->cur_file_dir); sqlite3_bind_int(res, 13, user->cur_file_sub); + sqlite3_bind_int(res, 14, user->timeson); } else { fprintf(stderr, "Failed to execute statement: %s\n", sqlite3_errmsg(db)); @@ -206,6 +209,7 @@ struct user_record *check_user_pass(int socket, char *loginname, char *password) user->cur_mail_area = sqlite3_column_int(res, 11); user->cur_file_dir = sqlite3_column_int(res, 12); user->cur_file_sub = sqlite3_column_int(res, 13); + user->timeson = sqlite3_column_int(res, 14); if (strcmp(password, user->password) != 0) { free(user); @@ -233,6 +237,55 @@ struct user_record *check_user_pass(int socket, char *loginname, char *password) return user; } +void list_users(int socket, struct user_record *user) { + char buffer[256]; + sqlite3 *db; + sqlite3_stmt *res; + int rc; + int i; + + char *sql = "SELECT loginname,location,times_on FROM users"; + + sprintf(buffer, "%s/users.sq3", conf.bbs_path); + + rc = sqlite3_open(buffer, &db); + + if (rc != SQLITE_OK) { + fprintf(stderr, "Cannot open database: %s\n", sqlite3_errmsg(db)); + sqlite3_close(db); + exit(1); + } + rc = sqlite3_prepare_v2(db, sql, -1, &res, 0); + if (rc != SQLITE_OK) { + fprintf(stderr, "Cannot prepare statement: %s\n", sqlite3_errmsg(db)); + sqlite3_close(db); + exit(1); + } + s_putstring(socket, "\r\n\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n"); + s_putstring(socket, "User Name Location Times On\r\n"); + s_putstring(socket, "\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n"); + i = 0; + while (sqlite3_step(res) == SQLITE_ROW) { + sprintf(buffer, "\e[1;37m%-16s \e[1;36m%-32s \e[1;32m%5d\r\n", sqlite3_column_text(res, 0), sqlite3_column_text(res, 1), sqlite3_column_int(res, 2)); + s_putstring(socket, buffer); + + i++; + if (i == 20) { + sprintf(buffer, "Press any key to continue...\r\n"); + s_putstring(socket, buffer); + s_getc(socket); + i = 0; + } + } + s_putstring(socket, "\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n"); + sqlite3_finalize(res); + sqlite3_close(db); + + sprintf(buffer, "Press any key to continue...\r\n"); + s_putstring(socket, buffer); + s_getc(socket); +} + int check_user(char *loginname) { char buffer[256]; sqlite3 *db; @@ -392,6 +445,7 @@ struct user_record *new_user(int socket) { user->cur_file_sub = 0; user->cur_mail_area = 0; user->cur_mail_conf = 0; + user->timeson = 0; inst_user(user); return user;