|
|
1.1 ! root 1: /* con_hi.cpp */ ! 2: ! 3: /* Synchronet hi-level console routines */ ! 4: ! 5: /* $Id: con_hi.cpp,v 1.12 2006/08/23 01:45:05 rswindell Exp $ */ ! 6: ! 7: /**************************************************************************** ! 8: * @format.tab-size 4 (Plain Text/Source Code File Header) * ! 9: * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * ! 10: * * ! 11: * Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html * ! 12: * * ! 13: * This program is free software; you can redistribute it and/or * ! 14: * modify it under the terms of the GNU General Public License * ! 15: * as published by the Free Software Foundation; either version 2 * ! 16: * of the License, or (at your option) any later version. * ! 17: * See the GNU General Public License for more details: gpl.txt or * ! 18: * http://www.fsf.org/copyleft/gpl.html * ! 19: * * ! 20: * Anonymous FTP access to the most recent released source is available at * ! 21: * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net * ! 22: * * ! 23: * Anonymous CVS access to the development source and modification history * ! 24: * is available at cvs.synchro.net:/cvsroot/sbbs, example: * ! 25: * cvs -d :pserver:[email protected]:/cvsroot/sbbs login * ! 26: * (just hit return, no password is necessary) * ! 27: * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src * ! 28: * * ! 29: * For Synchronet coding style and modification guidelines, see * ! 30: * http://www.synchro.net/source.html * ! 31: * * ! 32: * You are encouraged to submit any modifications (preferably in Unix diff * ! 33: * format) via e-mail to [email protected] * ! 34: * * ! 35: * Note: If this box doesn't appear square, then you need to fix your tabs. * ! 36: ****************************************************************************/ ! 37: ! 38: #include "sbbs.h" ! 39: ! 40: /****************************************************************************/ ! 41: /* Redraws str using i as current cursor position and l as length */ ! 42: /****************************************************************************/ ! 43: void sbbs_t::redrwstr(char *strin, int i, int l, long mode) ! 44: { ! 45: char str[256],c; ! 46: ! 47: sprintf(str,"%-*.*s",l,l,strin); ! 48: c=i; ! 49: while(c--) ! 50: outchar(BS); ! 51: if(mode&K_MSG) ! 52: bputs(str); ! 53: else ! 54: rputs(str); ! 55: if(term_supports(ANSI)) { ! 56: cleartoeol(); ! 57: if(i<l) ! 58: cursor_left(l-i); ! 59: } else { ! 60: while(c<cols-1) { /* clear to end of line */ ! 61: outchar(' '); ! 62: c++; ! 63: } ! 64: while(c>l) { /* back space to end of string */ ! 65: outchar(BS); ! 66: c--; ! 67: } ! 68: } ! 69: } ! 70: ! 71: ! 72: int sbbs_t::uselect(int add, uint n, char *title, char *item, uchar *ar) ! 73: { ! 74: char str[128]; ! 75: int i; ! 76: uint t,u; ! 77: ! 78: if(uselect_total>=sizeof(uselect_num)/sizeof(uselect_num[0])) /* out of bounds */ ! 79: uselect_total=0; ! 80: ! 81: if(add) { ! 82: if(ar && !chk_ar(ar,&useron)) ! 83: return(0); ! 84: if(!uselect_total) ! 85: bprintf(text[SelectItemHdr],title); ! 86: uselect_num[uselect_total++]=n; ! 87: bprintf(text[SelectItemFmt],uselect_total,item); ! 88: return(0); } ! 89: ! 90: if(!uselect_total) ! 91: return(-1); ! 92: ! 93: for(u=0;u<uselect_total;u++) ! 94: if(uselect_num[u]==n) ! 95: break; ! 96: if(u==uselect_total) ! 97: u=0; ! 98: sprintf(str,text[SelectItemWhich],u+1); ! 99: mnemonics(str); ! 100: i=getnum(uselect_total); ! 101: t=uselect_total; ! 102: uselect_total=0; ! 103: if(i<0) ! 104: return(-1); ! 105: if(!i) { /* User hit ENTER, use default */ ! 106: for(u=0;u<t;u++) ! 107: if(uselect_num[u]==n) ! 108: return(uselect_num[u]); ! 109: if(n<t) ! 110: return(uselect_num[n]); ! 111: return(-1); } ! 112: return(uselect_num[i-1]); ! 113: } ! 114: ! 115: /****************************************************************************/ ! 116: /* Prompts user for System Password. Returns 1 if user entered correct PW */ ! 117: /****************************************************************************/ ! 118: bool sbbs_t::chksyspass() ! 119: { ! 120: char str[256],str2[256]; ! 121: int orgcon=console; ! 122: ! 123: if(online==ON_REMOTE && !(cfg.sys_misc&SM_R_SYSOP)) { ! 124: logline("S!","Remote sysop access disabled"); ! 125: return(false); ! 126: } ! 127: #if 0 /* no local logins in v3 */ ! 128: if(online==ON_LOCAL) { ! 129: if(!(cfg.sys_misc&SM_L_SYSOP)) ! 130: return(false); ! 131: if(!(cfg.node_misc&NM_SYSPW) && !(cfg.sys_misc&SM_REQ_PW)) ! 132: return(false); ! 133: } ! 134: #endif ! 135: bputs(text[SystemPassword]); ! 136: console&=~(CON_R_ECHO|CON_L_ECHO); ! 137: getstr(str,40,K_UPPER); ! 138: console=orgcon; ! 139: CRLF; ! 140: if(strcmp(cfg.sys_pass,str)) { ! 141: if(cfg.sys_misc&SM_ECHO_PW) ! 142: sprintf(str2,"%s #%u System password attempt: '%s'" ! 143: ,useron.alias,useron.number,str); ! 144: else ! 145: sprintf(str2,"%s #%u System password verification failure" ! 146: ,useron.alias,useron.number); ! 147: logline("S!",str2); ! 148: return(false); ! 149: } ! 150: return(true); ! 151: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.