|
| 1 | +// logon.js |
| 2 | + |
| 3 | +// Synchronet v3.1 Default Logon Module |
| 4 | + |
| 5 | +// $Id: logon.js,v 1.22 2013/10/15 13:16:04 deuce Exp $ |
| 6 | + |
| 7 | +// @format.tab-size 4, @format.use-tabs true |
| 8 | + |
| 9 | +load("sbbsdefs.js"); |
| 10 | +load("text.js"); |
| 11 | +load("asc2htmlterm.js"); |
| 12 | +var options = load("modopts.js", "logon"); |
| 13 | + |
| 14 | +// Check if we're being asked to auto-run an external (web interface external programs section uses this) |
| 15 | +if (options && (options.rlogin_auto_xtrn) && (bbs.sys_status & SS_RLOGIN) && (console.terminal.indexOf("xtrn=") === 0)) { |
| 16 | + var external_code = console.terminal.substring(5); |
| 17 | + if (!bbs.exec_xtrn(external_code)) { |
| 18 | + alert(log(LOG_ERR,"!ERROR Unable to launch external: '" + external_code + "'")); |
| 19 | + } |
| 20 | + bbs.hangup(); |
| 21 | + exit(); |
| 22 | +} |
| 23 | + |
| 24 | +//Disable spinning cursor at pause prompts |
| 25 | +bbs.node_settings|=NM_NOPAUSESPIN |
| 26 | + |
| 27 | +if(user.security.restrictions&UFLAG_G) { |
| 28 | + while(bbs.online) { |
| 29 | + printf("\1y\1hFor our records, please enter your full name: \1w"); |
| 30 | + name=console.getstr(LEN_NAME,K_UPRLWR); |
| 31 | + if(!name || !name.length) |
| 32 | + continue; |
| 33 | + bbs.log_str("Guest: " + name); |
| 34 | + user.name = name; |
| 35 | + break; |
| 36 | + } |
| 37 | + |
| 38 | + while(bbs.online) { |
| 39 | + printf("\1y\1hPlease enter your e-mail address: \1w"); |
| 40 | + email=console.getstr(LEN_NETMAIL); |
| 41 | + if(!email || !email.length) |
| 42 | + continue; |
| 43 | + bbs.log_str(" " + email); |
| 44 | + user.netmail=email; |
| 45 | + user.settings|=USER_NETMAIL; |
| 46 | + break; |
| 47 | + } |
| 48 | + |
| 49 | + while(bbs.online) { |
| 50 | + printf("\1y\1hPlease enter your location (City, State): \1w"); |
| 51 | + location=console.getstr(LEN_LOCATION,K_UPRLWR); |
| 52 | + if(!location || !location.length) |
| 53 | + continue; |
| 54 | + bbs.log_str(" " + location); |
| 55 | + user.location=location; |
| 56 | + break; |
| 57 | + } |
| 58 | + |
| 59 | + if(bbs.online) |
| 60 | + bbs.log_str("\r\n"); |
| 61 | + while(bbs.online) { |
| 62 | + printf("\1y\1hWhere did you hear about this BBS?\r\n: \1w"); |
| 63 | + ref=console.getstr(70); |
| 64 | + if(!ref || !ref.length) |
| 65 | + continue; |
| 66 | + bbs.log_str(ref + "\r\n"); |
| 67 | + break; |
| 68 | + } |
| 69 | + |
| 70 | +// print("name: " + user.name); |
| 71 | +// print("email: " + user.netmail); |
| 72 | +// print("location: " + user.location); |
| 73 | +} |
| 74 | + |
| 75 | + |
| 76 | +// Force split-screen chat on ANSI users |
| 77 | +if(user.settings&USER_ANSI) |
| 78 | + user.chat_settings|=CHAT_SPLITP; |
| 79 | + |
| 80 | +// Inactivity exemption |
| 81 | +if(user.security.exemptions&UFLAG_H) |
| 82 | + console.status|=CON_NO_INACT; |
| 83 | + |
| 84 | +/****************************** |
| 85 | +* Replaces the 2.1 Logon stuff |
| 86 | +******************************/ |
| 87 | + |
| 88 | +var ouah = console.noyes("Quick login? (straight to shell/no ANSI)"); |
| 89 | +if (ouah) { |
| 90 | + // Logon screens |
| 91 | + |
| 92 | + // Print logon screens based on security level |
| 93 | + if(file_exists(system.text_dir + "menu/logon" + user.security.level + ".*")) |
| 94 | + bbs.menu("logon" + user.security.level); |
| 95 | + |
| 96 | + // Print successively numbered logon screens (logon, logon1, logon2, etc.) |
| 97 | + for(var i=0;;i++) { |
| 98 | + var fname="logon"; |
| 99 | + if(i) |
| 100 | + fname+=i; |
| 101 | + if(!file_exists(system.text_dir + "menu/" + fname + ".*")) { |
| 102 | + if(i>1) |
| 103 | + break; |
| 104 | + continue; |
| 105 | + } |
| 106 | + bbs.menu(fname); |
| 107 | + } |
| 108 | + |
| 109 | + // Print one of text/menu/random*.*, picked at random |
| 110 | + // e.g. random1.asc, random2.asc, random3.asc, etc. |
| 111 | + var random_list = directory(system.text_dir + "menu/random*.*"); |
| 112 | + if(random_list.length) |
| 113 | + bbs.menu(file_getname(random_list[random(random_list.length)]).slice(0,-4)); |
| 114 | +} |
| 115 | + |
| 116 | +console.clear(); |
| 117 | +bbs.user_event(EVENT_LOGON); |
| 118 | + |
| 119 | +/* |
| 120 | + * Disable HTML mode if not using an HTML shell |
| 121 | + * If you don't do this, you'll get HTML menus that flash on |
| 122 | + * screen then disappear when the ANSI prompt is displayed |
| 123 | + * |
| 124 | + * It's still in the autoterm variable, so you CAN switch |
| 125 | + */ |
| 126 | +if(user.settings&USER_HTML) { |
| 127 | + if(user.command_shell.search(/html/i)==-1) |
| 128 | + user.settings&=~USER_HTML; |
| 129 | +} |
| 130 | + |
| 131 | +if(user.settings&USER_HTML) { |
| 132 | + var buf="\2\2<html><head><title>Welcome status screen</title></head><body bgcolor=\"black\" text=\"#a8a8a8\">"; |
| 133 | + |
| 134 | + // Last few callers |
| 135 | + logonlst=system.data_dir + "logon.lst" |
| 136 | + if(file_size(logonlst)<1) |
| 137 | + buf += asc2htmlterm("\1n\1g\1hYou are the first caller of the day!\r\n",false,true).replace(/(?: )*<br>/g,'<br>'); |
| 138 | + else { |
| 139 | + f=new File(logonlst); |
| 140 | + if(f.open("rb",true,f.length)) { |
| 141 | + var lastbuf=f.read(f.length); |
| 142 | + f.close(); |
| 143 | + lastbuf = lastbuf.replace(/^.*((?:[\x00\x09\x0b-\xff]*[\n]){1,4})$/,'$1'); |
| 144 | + buf += asc2htmlterm("\1n\1g\1hLast few callers:\1n\r\n",false,true).replace(/(?: )*<br>/g,'<br>'); |
| 145 | + buf += asc2htmlterm(lastbuf, false, true).replace(/(?: )*<br>/g,'<br>'); |
| 146 | + } |
| 147 | + } |
| 148 | + buf += ' <br>'; |
| 149 | + |
| 150 | + // Auto-message |
| 151 | + auto_msg=system.data_dir + "msgs/auto.msg" |
| 152 | + if(file_size(auto_msg)>0) { |
| 153 | + f=new File(auto_msg); |
| 154 | + if(f.open("rb",true,f.length)) { |
| 155 | + buf += asc2htmlterm(f.read(f.length), false, true, P_NOATCODES).replace(/(?: )*<br>/g,'<br>'); |
| 156 | + f.close(); |
| 157 | + } |
| 158 | + |
| 159 | + buf += ' <br>'; |
| 160 | + } |
| 161 | + |
| 162 | + if(!(system.settings&SYS_NOSYSINFO)) { |
| 163 | + buf += asc2htmlterm(format(bbs.text(SiSysName),system.name) |
| 164 | + + format(bbs.text(LiUserNumberName),user.number,user.alias) |
| 165 | + + format(bbs.text(LiLogonsToday),user.stats.logonstoday |
| 166 | + ,user.limits.logons_per_day) |
| 167 | + + format(bbs.text(LiTimeonToday),user.stats.timeon_today |
| 168 | + ,user.limits.time_per_day+user.security.minutes) |
| 169 | + + format(bbs.text(LiMailWaiting),user.mail_waiting) |
| 170 | + , false, true).replace(/(?: )*<br>/g,'<br>'); |
| 171 | + /* |
| 172 | + * Notes: |
| 173 | + * 1) We cannot access cfg.sys_char_ar |
| 174 | + * 2) logon.cpp and chat.cpp differ... chat.cpp adds useron.exempt&FLAG('C') |
| 175 | + */ |
| 176 | + /* |
| 177 | + strcpy(str,bbs.text[LiSysopIs]); |
| 178 | + if(bbs.startup_options&BBS_OPT_SYSOP_AVAILABLE |
| 179 | + || (cfg.sys_chat_ar[0] && chk_ar(cfg.sys_chat_ar,&useron))) |
| 180 | + strcat(str,bbs.text[LiSysopAvailable]); |
| 181 | + else |
| 182 | + strcat(str,bbs.text[LiSysopNotAvailable]); |
| 183 | + format("%s\r\n\r\n",str); |
| 184 | + */ |
| 185 | + } |
| 186 | + |
| 187 | + buf += "<br><a href=\" \">Click here to continue...</a></body>\n\2"; |
| 188 | + /* Disable autopause */ |
| 189 | + var os = bbs.sys_status; |
| 190 | + bbs.sys_status |= SS_PAUSEOFF; |
| 191 | + bbs.sys_status &= ~SS_PAUSEON; |
| 192 | + console.write(buf); |
| 193 | + bbs.sys_status=os; |
| 194 | + console.getkey(); |
| 195 | +} |
| 196 | +else { |
| 197 | + if (ouah) { |
| 198 | + // Last few callers |
| 199 | + console.aborted=false; |
| 200 | + console.clear(); |
| 201 | + logonlst=system.data_dir + "logon.lst" |
| 202 | + if(file_size(logonlst)<1) |
| 203 | + printf("\1n\1g\1hYou are the first caller of the day!\r\n"); |
| 204 | + else { |
| 205 | + printf("\1n\1g\1hLast few callers:\1n\r\n"); |
| 206 | + console.printtail(logonlst,4,P_NOATCODES); // args: filename, lines, mode |
| 207 | + } |
| 208 | + console.crlf(); |
| 209 | + |
| 210 | + // Auto-message |
| 211 | + auto_msg=system.data_dir + "msgs/auto.msg" |
| 212 | + if(file_size(auto_msg)>0) { |
| 213 | + console.printfile(auto_msg,P_NOATCODES); |
| 214 | + console.crlf(); |
| 215 | + } |
| 216 | + } |
| 217 | +} |
| 218 | + |
| 219 | +// Automatically set shell to WIPSHELL |
| 220 | +if(user.settings&USER_WIP) |
| 221 | + user.command_shell="WIPSHELL"; |
| 222 | + |
| 223 | +if(user.security.level==99 /* Sysop logging on */ |
| 224 | + && !system.matchuser("guest") /* Guest account does not yet exist */ |
| 225 | + && user.security.flags4&UFLAG_G /* Sysop has not asked to stop this question */ |
| 226 | + ) { |
| 227 | + if(console.yesno("Create Guest/Anonymous user account (highly recommended)")) |
| 228 | + load("makeguest.js"); |
| 229 | + else if(!console.yesno("Ask again later")) |
| 230 | + user.security.flags4&=~UFLAG_G; /* Turn off flag 4G to not ask again */ |
| 231 | + console.crlf(); |
| 232 | +} |
| 233 | + |
| 234 | +// Set rlogin_xtrn_menu=true in [logon] section of ctrl/modopts.ini |
| 235 | +// if you want your RLogin server to act as a door game server only |
| 236 | +if(options |
| 237 | + && options.rlogin_xtrn_menu |
| 238 | + && bbs.sys_status&SS_RLOGIN) { |
| 239 | + bbs.xtrn_sec(); |
| 240 | + bbs.hangup(); |
| 241 | +} |
0 commit comments