Added Settings Menu
This commit is contained in:
parent
fc970f3d25
commit
b94dbb4fa1
2
Makefile
2
Makefile
@ -4,7 +4,7 @@ DEPS = bbs.h
|
||||
JAMLIB = jamlib/jamlib.a
|
||||
ZMODEM = Xmodem/libzmodem.a
|
||||
|
||||
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o
|
||||
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
³ [0;36mT.[1;30m [37mFile Transfer Area[0m[11C[1;30m³ [0;36mC.[1;30m [37mChat System[0m[19C[1;30m³
|
||||
³ [0;36mB. [1;37mBulletins[0m[20C[1;30m³ [0;36mU. [1;37mUser List[0m[21C[1;30m³
|
||||
³ [0;36mD. [1;37mDoor Games & Utilites[0m[8C[1;30m³ [0;36m1. [1;37mLast 10 Callers[0m[15C[1;30m³
|
||||
³[0m [36mA. [1;37mText/ANSI File Collection[0m [1;30m³[0m[35C[1;30m³
|
||||
³[0m [36mA. [1;37mText/ANSI File Collection[0m [1;30m³[0m [36mS. [1;37mYour Settings[0m[17C[1;30m³
|
||||
³[0m[34C[1;30m³[0m[35C[1;30m³
|
||||
³[0m[34C[1;30m³ [0;36mG. [1;31mGoodbye [0;31m([1mLog Off[0;31m)[37m[13C[1;30m³
|
||||
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
|
||||
|
3
bbs.h
3
bbs.h
@ -137,6 +137,7 @@ extern void s_putstring(int socket, char *c);
|
||||
extern void s_displayansi_p(int socket, char *file);
|
||||
extern void s_displayansi(int socket, char *file);
|
||||
extern char s_getchar(int socket);
|
||||
extern void s_readpass(int socket, char *buffer, int max);
|
||||
extern void s_readstring(int socket, char *buffer, int max);
|
||||
extern char s_getc(int socket);
|
||||
extern void disconnect(int socket);
|
||||
@ -168,4 +169,6 @@ extern void send_email(int socket, struct user_record *user);
|
||||
extern void list_emails(int socket, struct user_record *user);
|
||||
|
||||
extern int file_menu(int socket, struct user_record *user);
|
||||
|
||||
extern void settings_menu(int sock, struct user_record *user);
|
||||
#endif
|
||||
|
@ -119,6 +119,11 @@ void main_menu(int socket, struct user_record *user) {
|
||||
doquit = file_menu(socket, user);
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
{
|
||||
settings_menu(socket, user);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
60
settings.c
Normal file
60
settings.c
Normal file
@ -0,0 +1,60 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include "bbs.h"
|
||||
|
||||
void settings_menu(int sock, struct user_record *user) {
|
||||
char buffer[256];
|
||||
int dosettings = 0;
|
||||
char c;
|
||||
|
||||
while (!dosettings) {
|
||||
s_putstring(sock, "\e[1;32mYour Settings\r\n");
|
||||
s_putstring(sock, "\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n");
|
||||
s_putstring(sock, "\e[0;36mP. \e[1;37mPassword (\e[1;33mNot Shown\e[1;37m)\r\n");
|
||||
sprintf(buffer, "\e[0;36mL. \e[1;37mLocation (\e[1;33m%s\e[1;37m)\r\n", user->location);
|
||||
s_putstring(sock, buffer);
|
||||
s_putstring(sock, "\e[0;36mQ. \e[1;37mQuit to Main Menu\r\n");
|
||||
s_putstring(sock, "\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n");
|
||||
|
||||
c = s_getc(sock);
|
||||
|
||||
switch(tolower(c)) {
|
||||
case 'p':
|
||||
{
|
||||
s_putstring(sock, "\r\nEnter your current password: ");
|
||||
s_readpass(sock, buffer, 16);
|
||||
if (strcmp(buffer, user->password) == 0) {
|
||||
s_putstring(sock, "\r\nEnter your new password (8 chars min): ");
|
||||
s_readstring(sock, buffer, 16);
|
||||
if (strlen(buffer) >= 8) {
|
||||
free(user->password);
|
||||
user->password = (char *)malloc(strlen(buffer) + 1);
|
||||
strcpy(user->password, buffer);
|
||||
save_user(user);
|
||||
s_putstring(sock, "\r\nPassword Changed!\r\n");
|
||||
} else {
|
||||
s_putstring(sock, "\r\nPassword too short!\r\n");
|
||||
}
|
||||
} else {
|
||||
s_putstring(sock, "\r\nPassword Incorrect!\r\n");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'l':
|
||||
{
|
||||
s_putstring(sock, "\r\nEnter your new location: ");
|
||||
s_readstring(sock, buffer, 32);
|
||||
free(user->location);
|
||||
user->location = (char *)malloc(strlen(buffer) + 1);
|
||||
strcpy(user->location, buffer);
|
||||
save_user(user);
|
||||
}
|
||||
break;
|
||||
case 'q':
|
||||
dosettings = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
5
users.c
5
users.c
@ -213,6 +213,11 @@ struct user_record *check_user_pass(int socket, char *loginname, char *password)
|
||||
user->timeson = sqlite3_column_int(res, 14);
|
||||
|
||||
if (strcmp(password, user->password) != 0) {
|
||||
free(user->loginname);
|
||||
free(user->firstname);
|
||||
free(user->lastname);
|
||||
free(user->email);
|
||||
free(user->location);
|
||||
free(user);
|
||||
sqlite3_finalize(res);
|
||||
sqlite3_close(db);
|
||||
|
Reference in New Issue
Block a user