Added User List, added times on stat
This commit is contained in:
15
ansis/doors.ans
Normal file
15
ansis/doors.ans
Normal file
@@ -0,0 +1,15 @@
|
||||
[?7h[255D[40m
|
||||
[0;1;30m [35m<35><6D><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[0;35m<35> [1m<31><6D><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
[45m<35><6D>[1C[30;40m<30> [35;45m<35><6D>[1C<31><43>[1C[30;40m<30> [35;45m۲[1C<31><43>[1C[30;40m<30> [35;45m۲[1C<31><43>[30;40m<30><6D> [35;45m<35><6D>[2C<32><43>[1C[0;35m<35>[1m<31><6D><EFBFBD> [45m<35><6D>[30;40m<30> [35;45m<35><6D>[1C<31><43>[30;40m<30><6D> [35;45m<35><6D>[30;40m<30><6D> [35;45m<35><6D>[1C<31><43>[0;35m<35><6D> [1m<31><6D> [45m<35>[40m<30><6D><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
[45m<35>[0;35m<35> [1;30m<30>[0;35m<35>[1;45m<35>[0;35m<35> [1;45m<35>[0;35m<35><6D>[1;30m<30> [35;45m<35> [1C<31>[0;35m<35><6D>[1;30m<30> [35;45m<35> [1C<31>[0;35m<35> [1;30m<30> [35;45m<35><6D>[2C<32>[0;35m<35><6D> [1;45m<35><6D>[1C<31>[0;35m<35>[1m<31><6D><EFBFBD>[45m<35><6D>[1C<31>[0;35m<35> [1;30m<30> [35;45m<35>[0;35m<35> [1;30m<30> [35;45m<35><6D>[1C<31>[0;35m<35><6D>[1;30m<30> [35;45m<35><6D>[1C[40m<30>[0;35m<35> [1;45m<35><6D>[40m
|
||||
[0;35m<35><6D><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[1;30m<30> [0;35m<35><6D><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>[1;30m<30>[6C<36>[0;35m<35><6D><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> [1;30m<30> [35;45m<35>[0;35m<35> <20><> [1;30m<30> [0;35m<35><6D> [1;30m<30> [35;45m<35>[0;35m<35> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[1;30m<30>
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<20> [0;36m0. [1;37mExample Door[17C[30m<30>[35C<35>
|
||||
<20>[34C<34>[35C<35>
|
||||
<20>[34C<34>[35C<35>
|
||||
<20>[34C<34>[35C<35>
|
||||
<20>[34C<34>[35C<35>
|
||||
<20>[34C<34> [0;36mQ. [1;37mQuit to Main Menu[13C[30m<30>
|
||||
<20>[34C<34> [0;36mG. [1;31mGoodbye [0;31m([1mLog Off[0;31m)[13C[1;30m<30>
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
[0m[255D
|
@@ -4,10 +4,10 @@
|
||||
[5C[42m<32>[0;32m<32> [1;30m<30> [32;42m<32>[0;32m<32> [1;30m<30> [32;42m<32><6D>[1C<31>[0;32m<32>[1m<31><6D><EFBFBD>[42m<32><6D>[1C<31>[0;32m<32> [1;42m<32>[0;32m<32> [1;30m<30> [32;42m<32><6D>[2C<32>[0;32m<32> [1;30m<30> [32;42m<32>[0;32m<32> [1;30m<30> [32;42m<32><6D>[1C<31>[0;32m<32><6D>[1;30m<30> [32;42m<32><6D>[1C<31>[0;32m<32> [1;30m<30> [32;42m<32><6D>[1C<31>[0;32m<32><6D>[1;30m<30> [32;42m<32> [40m
|
||||
[5C[0;32m<32><6D> [1;30m<30> [0;32m<32><6D> [1;30m<30> [32;42m<32>[0;32m<32> <20><> [1;30m<30> [32;42m<32>[0;32m<32> <20><> <20><> [1;30m<30> [32;42m<32>[0;32m<32> <20><> [1;30m<30> [0;32m<32><6D> [1;30m<30> [32;42m<32>[0;32m<32> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> [1;30m<30> [32;42m<32>[0;32m<32> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
[1;30m<30><6D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<20> [0;36mM. [1;37mMessage Areas[16C[30m<30> [0;36mL. [1;37mBBS List[22C[30m<EFBFBD>
|
||||
<20> [0;36mT. [1;37mFile Areas[19C[30m<30> [0;36mC. [1;37mChat System[19C[30m<EFBFBD>
|
||||
<20> [0;36mM. [1;37mMessage Areas[16C[30m<30> L. BBS List[22C<32>
|
||||
<20> T. File Areas[19C<39> C. Chat System[19C<39>
|
||||
<20> [0;36mB. [1;37mBulletins[20C[30m<30> [0;36mU. [1;37mUser List[21C[30m<30>
|
||||
<20> [0;36mO. [1;37mOnline Games[17C[30m<30> [0;36m1. [1;37mLast 10 Callers[15C[30m<30>
|
||||
<20> [0;36mD. [1;37mOnline Games[17C[30m<30> [0;36m1. [1;37mLast 10 Callers[15C[30m<30>
|
||||
<20>[34C<34>[35C<35>
|
||||
<20>[34C<34>[35C<35>
|
||||
<20>[34C<34> [0;36mG. [1;31mGoodbye [0;31m([1mLog Off[0;31m)[13C[1;30m<30>
|
||||
|
2
bbs.c
2
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);
|
||||
|
3
bbs.h
3
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);
|
||||
|
||||
|
26
main_menu.c
26
main_menu.c
@@ -1,6 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/stat.h>
|
||||
#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);
|
||||
|
62
users.c
62
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;
|
||||
|
Reference in New Issue
Block a user