Add node messaging
This commit is contained in:
parent
db4431c22d
commit
f2cc401100
Binary file not shown.
2
bbs.h
2
bbs.h
@ -247,6 +247,8 @@ extern struct user_record *new_user();
|
||||
extern struct user_record *check_user_pass(char *loginname, char *password);
|
||||
extern void list_users(struct user_record *user);
|
||||
|
||||
extern void active_nodes();
|
||||
extern void send_node_msg();
|
||||
extern void display_bulletins();
|
||||
extern void display_textfiles();
|
||||
|
||||
|
@ -214,3 +214,8 @@ Sorry, this %s is unavailable over SSH\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
|
||||
Node %d. %s\r\n
|
||||
Select a node to message...\r\n\r\n
|
||||
\r\nInvalid Node!\r\n
|
||||
\r\nEnter your message (256 chars max)...\r\n
|
||||
%s on node %d says:\r\n %s\r\n\r\n
|
||||
|
57
main_menu.c
57
main_menu.c
@ -9,6 +9,8 @@
|
||||
#include "lua/lauxlib.h"
|
||||
|
||||
extern struct bbs_config conf;
|
||||
extern struct user_record *gUser;
|
||||
extern int mynode;
|
||||
|
||||
void display_bulletins() {
|
||||
int i;
|
||||
@ -28,6 +30,61 @@ void display_bulletins() {
|
||||
}
|
||||
}
|
||||
|
||||
void active_nodes() {
|
||||
int i;
|
||||
struct stat s;
|
||||
char buffer[PATH_MAX];
|
||||
FILE *fptr;
|
||||
|
||||
for (i=0;i<conf.nodes;i++) {
|
||||
snprintf(buffer, PATH_MAX, "%s/nodeinuse.%d", conf.bbs_path, i+1);
|
||||
if (stat(buffer, &s) == 0) {
|
||||
fptr = fopen(buffer, "r");
|
||||
if (fptr) {
|
||||
fgets(buffer, PATH_MAX, fptr);
|
||||
fclose(fptr);
|
||||
chomp(buffer);
|
||||
s_printf(get_string(216), i+1, buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void send_node_msg() {
|
||||
char buffer[PATH_MAX];
|
||||
char msg[257];
|
||||
int nodetomsg = 0;
|
||||
struct stat s;
|
||||
FILE *fptr;
|
||||
|
||||
s_printf(get_string(216));
|
||||
active_nodes();
|
||||
|
||||
s_readstring(buffer, 4);
|
||||
nodetomsg = atoi(buffer);
|
||||
|
||||
if (nodetomsg < 1 || nodetomsg > conf.nodes) {
|
||||
s_printf(get_string(218));
|
||||
return;
|
||||
}
|
||||
s_printf(get_string(219));
|
||||
|
||||
s_readstring(msg, 256);
|
||||
|
||||
snprintf(buffer, PATH_MAX, "%s/node%d", conf.bbs_path, nodetomsg);
|
||||
|
||||
if (stat(buffer, &s) != 0) {
|
||||
mkdir(buffer, 0755);
|
||||
}
|
||||
snprintf(buffer, PATH_MAX, "%s/node%d/nodemsg.txt", conf.bbs_path, nodetomsg);
|
||||
|
||||
fptr = fopen(buffer, "a");
|
||||
if (fptr) {
|
||||
fprintf(fptr, get_string(220), gUser->loginname, mynode, msg);
|
||||
fclose(fptr);
|
||||
}
|
||||
}
|
||||
|
||||
void display_textfiles() {
|
||||
int i;
|
||||
char buffer[5];
|
||||
|
8
menus.c
8
menus.c
@ -44,6 +44,7 @@
|
||||
#define MENU_PREVFILESUB 35
|
||||
#define MENU_LISTMESSAGES 36
|
||||
#define MENU_DOSCRIPT 37
|
||||
#define MENU_SENDNODEMSG 38
|
||||
|
||||
extern struct bbs_config conf;
|
||||
extern struct user_record *gUser;
|
||||
@ -181,6 +182,8 @@ int menu_system(char *menufile) {
|
||||
menu[menu_items-1]->command = MENU_LISTMESSAGES;
|
||||
} else if (strncasecmp(&buffer[8], "DOSCRIPT", 8) == 0) {
|
||||
menu[menu_items-1]->command = MENU_DOSCRIPT;
|
||||
} else if (strncasecmp(&buffer[8], "SENDNODEMSG", 11) == 0) {
|
||||
menu[menu_items-1]->command = MENU_SENDNODEMSG;
|
||||
}
|
||||
} else if (strncasecmp(buffer, "SECLEVEL", 8) == 0) {
|
||||
menu[menu_items-1]->seclevel = atoi(&buffer[9]);
|
||||
@ -451,7 +454,10 @@ int menu_system(char *menufile) {
|
||||
break;
|
||||
case MENU_DOSCRIPT:
|
||||
do_lua_script(menu[i]->data);
|
||||
break;
|
||||
break;
|
||||
case MENU_SENDNODEMSG:
|
||||
send_node_msg();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -37,6 +37,9 @@ DATA file
|
||||
HOTKEY S
|
||||
COMMAND SETTINGS
|
||||
|
||||
HOTKEY N
|
||||
COMMAND SENDNODEMSG
|
||||
|
||||
HOTKEY G
|
||||
COMMAND SUBMENU
|
||||
DATA logoff
|
||||
|
Reference in New Issue
Block a user