-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogon.js
205 lines (178 loc) · 5.75 KB
/
logon.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
// logon.js
// Synchronet v3.1 Default Logon Module
// $Id: logon.js,v 1.54 2020/04/03 15:27:54 rswindell Exp $
// @format.tab-size 4, @format.use-tabs true
require("sbbsdefs.js", 'SS_RLOGIN');
require("nodedefs.js", 'NODE_QUIET');
if(!bbs.mods.avatar_lib)
bbs.mods.avatar_lib = load({}, 'avatar_lib.js');
if(!bbs.mods.logonlist_lib)
bbs.mods.logonlist_lib = load({}, 'logonlist_lib.js');
load("fonts.js", "preload", "default");
if(!bbs.mods.userprops)
bbs.mods.userprops = load({}, "userprops.js");
var options = load("modopts.js", "logon");
if(!options)
options = {};
if(options.show_avatar === undefined)
options.show_avatar = true;
if(options.draw_avatar_right === undefined)
options.draw_avatar_right = true;
if(options.show_logon_list === undefined)
options.show_logon_list = true;
if(options.eval_first)
eval(options.eval_first);
if(user.settings & USER_ICE_COLOR) {
var cterm = load({}, "cterm_lib.js");
cterm.bright_background(true);
}
if(options.email_validation == true) {
load({}, "emailval.js");
if(!bbs.online)
exit();
}
// Check if we're being asked to auto-run an external (web interface external programs section uses this)
if ((options.rlogin_auto_xtrn) && (bbs.sys_status & SS_RLOGIN) && (console.terminal.indexOf("xtrn=") === 0)) {
var external_code = console.terminal.substring(5);
if (!bbs.exec_xtrn(external_code)) {
alert(log(LOG_ERR,"!ERROR Unable to launch external: '" + external_code + "'"));
}
bbs.hangup();
exit();
}
//Disable spinning cursor at pause prompts
//bbs.node_settings|=NM_NOPAUSESPIN
if(user.security.restrictions&UFLAG_G) {
while(bbs.online) {
printf("\1y\1hFor our records, please enter your full name: \1w");
name=console.getstr(LEN_NAME,K_UPRLWR);
if(!name || !name.length)
continue;
bbs.log_str("Guest: " + name);
user.name = name;
break;
}
while(bbs.online) {
printf("\1y\1hPlease enter your e-mail address: \1w");
email=console.getstr(LEN_NETMAIL);
if(!email || !email.length)
continue;
if(bbs.trashcan("email", email)) {
bbs.hangup();
exit();
}
bbs.log_str(" " + email);
user.netmail=email;
user.settings|=USER_NETMAIL;
break;
}
while(bbs.online) {
printf("\1y\1hPlease enter your location (City, State): \1w");
location=console.getstr(LEN_LOCATION,K_UPRLWR);
if(!location || !location.length)
continue;
if(bbs.trashcan("location", location)) {
bbs.hangup();
exit();
}
bbs.log_str(" " + location);
user.location=location;
break;
}
if(bbs.online)
bbs.log_str("\r\n");
while(bbs.online) {
printf("\1y\1hWhere did you hear about this BBS?\r\n: \1w");
ref=console.getstr(70);
if(!ref || !ref.length)
continue;
bbs.log_str(ref + "\r\n");
break;
}
}
// Force split-screen chat on ANSI users
if(console.term_supports(USER_ANSI))
user.chat_settings|=CHAT_SPLITP;
// Inactivity exemption
if(user.security.exemptions&UFLAG_H)
console.status|=CON_NO_INACT;
/******************************
* Replaces the 2.1 Logon stuff
******************************/
if(options.fast_logon !== true || !(bbs.sys_status&SS_FASTLOGON)
|| !user.compare_ars(options.fast_logon_requirements)) {
// Logon screens
// Print successively numbered logon screens (logon, logon1, logon2, etc.)
var highest_printed_logon_screen=-1;
for(var i=0;;i++) {
var fname="logon";
if(i)
fname+=i;
if(!bbs.menu_exists(fname)) {
if(i>1)
break;
continue;
}
bbs.menu(fname);
highest_printed_logon_screen = i;
}
// Print logon screens based on security level
if(user.security.level > highest_printed_logon_screen
&& bbs.menu_exists("logon" + user.security.level))
bbs.menu("logon" + user.security.level);
// Print one of text/menu/random*.*, picked at random
// e.g. random1.asc, random2.asc, random3.asc, etc.
var random_list = directory(system.text_dir + "menu/random*.*");
if(random_list.length)
bbs.menu(file_getname(random_list[random(random_list.length)]).slice(0,-4));
console.clear(LIGHTGRAY);
bbs.user_event(EVENT_LOGON);
}
if(user.security.level==99 /* Sysop logging on */
&& !system.matchuser("guest") /* Guest account does not yet exist */
&& bbs.mods.userprops.get("logon", "makeguest", true) /* Sysop has not asked to stop this question */
) {
if(console.yesno("Create Guest/Anonymous user account (highly recommended)"))
load("makeguest.js");
else if(!console.yesno("Ask again later"))
bbs.mods.userprops.set("logon", "makeguest", false);
console.crlf();
}
// Last few callers
console.aborted=false;
console.clear(LIGHTGRAY);
if(options.show_logon_list === true)
bbs.exec("?logonlist -l");
if(bbs.node_status != NODE_QUIET && ((system.settings&SYS_SYSSTAT) || !user.is_sysop))
bbs.mods.logonlist_lib.add();
// Auto-message
auto_msg=system.data_dir + "msgs/auto.msg"
if(file_size(auto_msg)>0) {
console.printfile(auto_msg,P_NOATCODES|P_WORDWRAP);
}
console.crlf();
if(options.show_avatar && console.term_supports(USER_ANSI)) {
if(options.draw_avatar_above || options.draw_avatar_right)
bbs.mods.avatar_lib.draw(user.number, /* name: */null, /* netaddr: */null, options.draw_avatar_above, options.draw_avatar_right);
else
bbs.mods.avatar_lib.show(user.number);
console.attributes = 7; // Clear the background attribute
}
// Set rlogin_xtrn_menu=true in [logon] section of ctrl/modopts.ini
// if you want your RLogin server to act as a door game server only
if(options.rlogin_xtrn_menu
&& bbs.sys_status&SS_RLOGIN) {
bbs.xtrn_sec();
bbs.hangup();
} else if(!(user.security.restrictions&UFLAG_G)
&& console.term_supports(USER_ANSI)
&& options.set_avatar == true) {
var avatar = bbs.mods.avatar_lib.read(user.number);
if(!avatar || (!avatar.data && !avatar.disabled)) {
alert("You have not selected an avatar.");
if(console.yesno("Select avatar now"))
load("avatar_chooser.js");
}
}
if(options.eval_last)
eval(options.eval_last);