Added User List, added times on stat
This commit is contained in:
parent
e7161ab489
commit
7d1b75c29a
15
ansis/doors.ans
Normal file
15
ansis/doors.ans
Normal file
@ -0,0 +1,15 @@
|
||||
[?7h[255D[40m
|
||||
[0;1;30m [35mワワワワワワ ワワワワワワワ ワワワワワワワ ワワワワワワ ワワワワワワ[0;35mワ [1mワワワワワワ ワワワワワワワワワワワ ワワワワワワワ ワワワワワワワ
|
||||
[45mイ゚[1C[30;40mワ [35;45mイロ[1Cイ゚[1C[30;40mワ [35;45mロイ[1Cイ゚[1C[30;40mワ [35;45mロイ[1Cロロ[30;40mーワ [35;45mイロ[2Cイ゚[1C[0;35mワ[1mワワワ [45mイ゚[30;40mー [35;45mイロ[1Cイ゚[30;40mーワ [35;45mイ゚[30;40mーワ [35;45mイロ[1Cイ゚[0;35mワワ [1m゚゚ [45mイ[40mロワワワワワ
|
||||
[45mア[0;35mロ [1;30m゚[0;35mワ[1;45mア[0;35mロ [1;45mー[0;35mイワ[1;30m゚ [35;45mイ [1Cー[0;35mイワ[1;30m゚ [35;45mイ [1Cイ[0;35mイ [1;30mイ [35;45mー゚[2Cア[0;35mロワ [1;45mア゚[1Cー[0;35mイ[1m゚゚゚[45mア゚[1Cー[0;35mイ [1;30mイ [35;45mー[0;35mイ [1;30mイ [35;45mア゚[1Cア[0;35mイワ[1;30mー [35;45mイ゚[1C[40mワ[0;35mワ [1;45mイ゚[40m
|
||||
[0;35m゚゚゚゚゚゚[1;30mー [0;35m゚゚゚゚゚゚ ゚゚゚゚゚゚ ゚゚[1;30mー[6Cー[0;35m゚゚゚゚゚゚ ゚゚ [1;30m゚ [35;45mー[0;35mロ ゚゚ [1;30m゚ [0;35m゚゚ [1;30m゚ [35;45mー[0;35mロ ゚゚゚゚゚゚ ゚゚゚゚゚゚[1;30mー
|
||||
トトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトト
|
||||
ウ [0;36m0. [1;37mExample Door[17C[30mウ[35Cウ
|
||||
ウ[34Cウ[35Cウ
|
||||
ウ[34Cウ[35Cウ
|
||||
ウ[34Cウ[35Cウ
|
||||
ウ[34Cウ[35Cウ
|
||||
ウ[34Cウ [0;36mQ. [1;37mQuit to Main Menu[13C[30mウ
|
||||
ウ[34Cウ [0;36mG. [1;31mGoodbye [0;31m([1mLog Off[0;31m)[13C[1;30mウ
|
||||
トトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトト
|
||||
[0m[255D
|
@ -4,10 +4,10 @@
|
||||
[5C[42mー[0;32mイ [1;30mイ [32;42mー[0;32mイ [1;30mイ [32;42mア゚[1Cー[0;32mイ[1m゚゚゚[42mア゚[1Cイ[0;32mイ [1;42mー[0;32mイ [1;30mイ [32;42mア゚[2Cー[0;32mイ [1;30mイ [32;42mー[0;32mイ [1;30mイ [32;42mア゚[1Cア[0;32mイワ[1;30mー [32;42mイ゚[1Cー[0;32mイ [1;30mイ [32;42mア゚[1Cー[0;32mイワ[1;30m゚ [32;42mイ [40m
|
||||
[5C[0;32m゚゚ [1;30m゚ [0;32m゚゚ [1;30m゚ [32;42mー[0;32mロ ゚゚ [1;30m゚ [32;42mー[0;32mロ ゚゚ ゚゚ [1;30m゚ [32;42mー[0;32mロ ゚゚ [1;30m゚ [0;32m゚゚ [1;30m゚ [32;42mー[0;32mロ ゚゚゚゚゚゚ ゚゚ [1;30m゚ [32;42mー[0;32mロ ゚゚゚゚゚゚
|
||||
[1;30mトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトト
|
||||
³ [0;36mM. [1;37mMessage Areas[16C[30m³ [0;36mL. [1;37mBBS List[22C[30m³
|
||||
³ [0;36mT. [1;37mFile Areas[19C[30m³ [0;36mC. [1;37mChat System[19C[30m³
|
||||
³ [0;36mM. [1;37mMessage Areas[16C[30m³ L. BBS List[22C³
|
||||
³ T. File Areas[19C³ C. Chat System[19C³
|
||||
ウ [0;36mB. [1;37mBulletins[20C[30mウ [0;36mU. [1;37mUser List[21C[30mウ
|
||||
³ [0;36mO. [1;37mOnline Games[17C[30m³ [0;36m1. [1;37mLast 10 Callers[15C[30m³
|
||||
³ [0;36mD. [1;37mOnline Games[17C[30m³ [0;36m1. [1;37mLast 10 Callers[15C[30m³
|
||||
ウ[34Cウ[35Cウ
|
||||
ウ[34Cウ[35Cウ
|
||||
ウ[34Cウ [0;36mG. [1;31mGoodbye [0;31m([1mLog Off[0;31m)[13C[1;30mウ
|
||||
|
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