int main( int argc, char *argv[] ) { struct quickroom allquick[MAXROOMS]; struct userinfo *start; /* to mark beginning of malloc'ed RAM */ long ucount = 0; chdir(BBSDIR); char name[L_USERNAME + 1]; int i; struct userinfo *current, *uinfo; user_type *tmpuser; long unbr; DIR *userdir; struct dirent *tmpdirent; printf("1. Reading the users.\n"); userdir = opendir(USERDIR); if (userdir == NULL) { printf("opendir() problems!\n"); exit(0); } while ((tmpdirent = readdir(userdir)) != NULL) { if (tmpdirent->d_name[0] != '.') { user = readuser(tmpdirent->d_name[0]); /* make userlist */ } } closedir(USERDIR); return 0; }
unsigned long get_new_mail_number(const char *name) { long a; user_t *user; user = readuser(name); if (!user) { mono_errno = E_NOUSER; return -1; } user->mailnum++; a = user->mailnum; if (writeuser(user, 0) == -1) { xfree(user); return -1; } xfree(user); if (mono_return_pid(name) != -1) { if ((kill(mono_return_pid(name), SIGUSR2)) == -1) { return -1; } } return a; }
int change_QL(unsigned int quad_num, const char *QLname, int how) { user_t *QL; int i, has_ql_flag; if ( quad_num > MAXQUADS) { mono_errno = E_NOQUAD; return -1; } if (mono_sql_u_check_user(QLname) == FALSE && how == 1) { mono_errno = E_NOUSER; return -1; } if ((QL = readuser(QLname)) == NULL) return -1; if (how > 0) { for (i = 0; i < 5; i++) { /* if we're already marked */ if (QL->RA_rooms[i] == quad_num) break; mono_sql_uf_add_host(QL->usernum, quad_num); if (QL->RA_rooms[i] < 0) { QL->RA_rooms[i] = quad_num; break; } } QL->flags |= US_ROOMAIDE; } else { has_ql_flag = 0; mono_sql_uf_remove_host(QL->usernum, quad_num); for (i = 0; i < 5; i++) { if (QL->RA_rooms[i] == quad_num) QL->RA_rooms[i] = -1; if (QL->RA_rooms[i] > 0) has_ql_flag++; } if (has_ql_flag == 0) QL->flags &= ~US_ROOMAIDE; else QL->flags |= US_ROOMAIDE; } if (writeuser(QL, 0) != 0) { xfree(QL); return -1; } xfree(QL); if (mono_return_pid(QLname) != -1) (void) kill(mono_return_pid(QLname), SIGUSR2); return 0; }
void do_kickout() { char *the_user = NULL; user_t *userP; /* changed varname: PR */ room_t scratch; unsigned int user_id; int not_done; read_forum(curr_rm, &scratch); cprintf("\n"); if (!(scratch.flags & QR_PRIVATE)) cprintf("\1f\1rRemember that this is a \1gPublic \1r%s!\n\n", config.forum); cprintf("\1f\1rAlien to kickout from \1g%s\1w>: \1c", scratch.name); nox = 1; the_user = get_name(2); if (the_user[0] == 0) return; if (mono_sql_u_check_user(the_user) == FALSE) { cprintf("\n\1f\1rNo such user.\1a\n"); return; } userP = readuser(the_user); if (userP->priv & PRIV_WIZARD) { cprintf("\n\1f\1rYou can't kickout " WIZARDTITLE "s\1r!!!\1a\n\n"); log_sysop_action("tried to kick %s out of %s>", userP->username, scratch.name); xfree(userP); return; } if (kickout(the_user, curr_rm) == -1) { cprintf("\n\1f\1rSomething went wrong kicking that user.\n\1a"); return; } mono_cached_sql_u_name2id(the_user, &user_id); mono_sql_uf_add_kicked(user_id, curr_rm); log_sysop_action("kicked %s out of %s>.", the_user, quickroom.name); cprintf("\n\1f\1rYou now have to write a %s \1w(\1ryell\1w)\1r to the %s%s\1a\n", config.message, ADMINCOL, config.admin); cprintf("\1f\1rabout the kickout: who, why, where, for how long.%s", "\n\n(Kickout Notification)\1a\n"); not_done = enter_message(YELL_FORUM, EDIT_NORMAL, FORCED_BANNER, NULL); while (not_done) { cprintf("\n\1rYou're required to enter this yell.\1a\n"); not_done = enter_message(YELL_FORUM, EDIT_NORMAL, FORCED_BANNER, NULL); } xfree(userP); return; }
/************************************************* * kickout() * returns 1 on successfull kickout *************************************************/ int kickout(const char *user, unsigned int room) { user_t *userP; room_t scratch; if (mono_sql_u_check_user(user) == FALSE) { mono_errno = E_NOUSER; return -1; } if ( room > MAXQUADS ) { mono_errno = E_NOQUAD; return -1; } read_forum( room, &scratch ); userP = readuser(user); if (!userP) { mono_errno = E_NOUSER; return -1; } if (userP->priv & PRIV_WIZARD) { xfree(userP); return -1; } if (userP->generation[room] == (-5)) { xfree(userP); return -1; } userP->generation[room] = (-5); userP->forget[room] = scratch.generation; mono_sql_uf_add_kicked( room, userP->usernum ); if (writeuser(userP, 0) != 0) { xfree(userP); return -1; } if (mono_return_pid(user) != -1) (void) kill(mono_return_pid(user), SIGUSR2); /* READSELF-signal */ (void) log_it("rooms", "kicked %s out of %s>", userP->username, scratch.name); xfree(userP); return 1; }
void initpersheader(void) { long tid,lappnr,length,x; struct tm *ts; struct User usr; char filnamn[40]; Servermem->action[nodnr] = SKRIVER; Servermem->varmote[nodnr] = -1; memset(&brevspar,0,sizeof(struct ReadLetter)); sprintf(brevspar.to,"%d",readhead.person); sprintf(brevspar.from,"%d",inloggad); readuser(readhead.person,&usr); if(usr.flaggor & LAPPBREV) { puttekn("\r\n\n",-1); lappnr=atoi(brevspar.to); sprintf(filnamn,"NiKom:Users/%d/%d/Lapp",lappnr/100,lappnr); if(!access(filnamn,0)) sendfile(filnamn); puttekn("\r\n",-1); } time(&tid); ts=localtime(&tid); sprintf(brevspar.date,"%2d%02d%02d %02d:%02d",ts->tm_year,ts->tm_mon+1,ts->tm_mday,ts->tm_hour,ts->tm_min); strcpy(brevspar.systemid,"NiKom"); sprintf(outbuffer,"\r\n\nMöte: %s\r\n",Servermem->cfg.brevnamn); puttekn(outbuffer,-1); sprintf(outbuffer,"Lokalt brev, %s\n\r",brevspar.date); puttekn(outbuffer,-1); sprintf(outbuffer,"Avsändare: %s\r\n",getusername(inloggad)); puttekn(outbuffer,-1); sprintf(outbuffer,"Mottagare: %s\n\r",getusername(readhead.person)); puttekn(outbuffer,-1); puttekn("Ärende: ",-1); strcpy(brevspar.subject,readhead.arende); puttekn(brevspar.subject,-1); puttekn("\n\r",-1); if(Servermem->inne[nodnr].flaggor & STRECKRAD) { length=strlen(brevspar.subject); for(x=0;x<length+8;x++) outbuffer[x]='-'; outbuffer[x]=0; puttekn(outbuffer,-1); puttekn("\r\n\n",-1); } else eka('\n'); }
int invite(const char *name, unsigned int room) { user_t *user; room_t scratch; if (mono_sql_u_check_user(name) == FALSE) return -1; if ( (room > MAXQUADS) ) return -1; user = readuser(name); if (user == NULL) return -1; read_forum( room, &scratch ); if (user->generation[room] == scratch.generation) { xfree(user); return -1; } user->generation[room] = scratch.generation; user->forget[room] = -1; mono_sql_uf_add_invited( room, user->usernum ); (void) writeuser(user, 0); if (mono_return_pid(name) != -1) (void) kill(mono_return_pid(name), SIGUSR2); (void) log_it("rooms", "someone invited %s to %s>", user->username, scratch.name); xfree(user); return 0; }
int initbrevheader(int tillpers) { int length=0,x=0,lappnr; long tid,tempmott; struct tm *ts; struct User usr; char filnamn[40],*mottagare,tempbuf[10],*vemskrev; Servermem->action[nodnr] = SKRIVER; Servermem->varmote[nodnr] = -1; memset(&brevspar,0,sizeof(struct ReadLetter)); if(tillpers==-1) { strcpy(brevspar.to,brevread.from); mottagare=brevread.to; while(mottagare[0]) { tempmott=atoi(mottagare); if(tempmott==inloggad || recisthere(brevspar.to,tempmott)) { mottagare=hittaefter(mottagare); continue; } sprintf(tempbuf," %d",tempmott); strcat(brevspar.to,tempbuf); mottagare=hittaefter(mottagare); } sprintf(brevspar.reply,"%d %d %s",senast_brev_anv,senast_brev_nr,brevread.from); } else { sprintf(brevspar.to,"%d",tillpers); } sprintf(brevspar.from,"%d",inloggad); readuser(atoi(brevspar.to),&usr); if(usr.flaggor & LAPPBREV) { puttekn("\r\n\n",-1); lappnr=atoi(brevspar.to); sprintf(filnamn,"NiKom:Users/%d/%d/Lapp",lappnr/100,lappnr); if(!access(filnamn,0)) sendfile(filnamn); puttekn("\r\n",-1); } time(&tid); ts=localtime(&tid); sprintf(brevspar.date,"%2d%02d%02d %02d:%02d",ts->tm_year,ts->tm_mon+1,ts->tm_mday,ts->tm_hour,ts->tm_min); strcpy(brevspar.systemid,"NiKom"); sprintf(outbuffer,"\r\n\nMöte: %s\r\n",Servermem->cfg.brevnamn); puttekn(outbuffer,-1); sprintf(outbuffer,"Lokalt brev, %s\n\r",brevspar.date); puttekn(outbuffer,-1); sprintf(outbuffer,"Avsändare: %s\r\n",getusername(inloggad)); puttekn(outbuffer,-1); if(brevspar.reply[0]) { vemskrev=hittaefter(hittaefter(brevspar.reply)); sprintf(outbuffer,"Kommentar till en text av %s\r\n",getusername(atoi(vemskrev))); puttekn(outbuffer,-1); } mottagare=brevspar.to; while(mottagare[0]) { sprintf(outbuffer,"Mottagare: %s\n\r",getusername(atoi(mottagare))); puttekn(outbuffer,-1); mottagare=hittaefter(mottagare); } puttekn("Ärende: ",-1); if(tillpers==-1) { strcpy(brevspar.subject,brevread.subject); puttekn(brevspar.subject,-1); } else { if(getstring(EKO,40,NULL)) return(1); if(!inmat[0]) { eka('\n'); return(2); } strcpy(brevspar.subject,inmat); } puttekn("\r\n",-1); if(Servermem->inne[nodnr].flaggor & STRECKRAD) { length=strlen(brevspar.subject); for(x=0;x<length+8;x++) outbuffer[x]='-'; outbuffer[x]=0; puttekn(outbuffer,-1); puttekn("\r\n\n",-1); } else puttekn("\n",-1); return(0); }
void main(int argc,char *argv[]) { int going=TRUE,forsok=2,car=1,x,connectbps, i, tmp; struct NodeType *nt; char *tmppscreen,commandstring[100], configname[50] = "NiKom:DatoCfg/SerNode.cfg"; FILE *fil; if(argc>1) for(x=1; x<argc; x++) { if(argv[x][0]=='-') { if(argv[x][1]=='G') getty=TRUE; else if(argv[x][1]=='B') gettybps=atoi(&argv[x][2]); else if(argv[x][1]=='C') connectbps = atoi(&argv[x][2]); } else strcpy(configname,argv[x]); } if(!(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0))) cleanup(ERROR,"Kunde inte öppna intuition.library\n"); if(!(UtilityBase=OpenLibrary("utility.library",37L))) cleanup(ERROR,"Kunde inte öppna utility.library\n"); if(!(NiKomBase=OpenLibrary("nikom.library",0L))) cleanup(ERROR,"Kunde inte öppna nikom.library\n"); if(!initnode(NODSER)) cleanup(ERROR,"Kunde inte registrera noden i Servern\n"); if(!(nikomnodeport = CreateMsgPort())) cleanup(ERROR,"Kunde inte skapa NiKomNode-porten"); sprintf(nikomnodeportnamn,"NiKomNode%d",nodnr); nikomnodeport->mp_Node.ln_Name = nikomnodeportnamn; nikomnodeport->mp_Node.ln_Pri = 1; AddPort(nikomnodeport); sprintf(rexxportnamn,"NiKomPreRexx%d",nodnr); if(!(rexxport=(struct MsgPort *)CreateMsgPort())) cleanup(ERROR,"Kunde inte öppna RexxPort\n"); rexxport->mp_Node.ln_Name=rexxportnamn; rexxport->mp_Node.ln_Pri=50; AddPort(rexxport); if(!(RexxSysBase=(struct RsxLib *)OpenLibrary("rexxsyslib.library",0L))) cleanup(ERROR,"Kunde inte öppna rexxsyslib.library\n"); getnodeconfig(configname); if(pubscreen[0]=='-') tmppscreen=NULL; else tmppscreen=pubscreen; if(!(NiKwind=openmywindow(tmppscreen))) cleanup(ERROR,"Kunde inte öppna fönstret\n"); if(getty) dtespeed = gettybps; else dtespeed = highbaud; if(!OpenIO(NiKwind)) cleanup(ERROR,"Couldn't setup IO"); strcpy(Servermem->nodid[nodnr],nodid); conreqtkn(); serreqtkn(); Delay(50); for(;;) { inloggad=-1; Servermem->idletime[nodnr] = time(NULL); Servermem->inloggad[nodnr]=-1; if(getty) Servermem->connectbps[nodnr] = connectbps; else waitconnect(); Servermem->idletime[nodnr] = time(NULL); Servermem->inloggad[nodnr]=-2; /* Sätt till <Uppringd> för att även hantera -getty-fallet */ reloginspec: updateinactive(); Servermem->inne[nodnr].flaggor = Servermem->cfg.defaultflags; if(!getty) Delay(100); Servermem->inne[nodnr].rader=0; Servermem->inne[nodnr].chrset = CHRS_LATIN1; sendfile("NiKom:Texter/Inlogg.txt"); if(Servermem->cfg.ar.preinlogg) sendrexx(Servermem->cfg.ar.preinlogg); car=TRUE; Servermem->inne[nodnr].chrset = 0; memset(commandhistory,0,1000); going=1; while(going && going<=Servermem->cfg.logintries) { putstring("\r\nNamn: ",-1,0); if(getstring(EKO,40,NULL)) { car=FALSE; break; } if(!stricmp(inmat,Servermem->cfg.ny) && !(Servermem->cfg.cfgflags & NICFG_CLOSEDBBS)) { tmp = RegisterNewUser(); if(tmp == 2) { goto panik; } car = tmp ? 0 : 1; going=FALSE; } else if((inloggad=parsenamn(inmat))>=0) { if(readuser(inloggad,&Servermem->inne[nodnr])) { puttekn("Error reading user data.\r\n", -1); goto panik; } // TODO: Extract password loop. Should be identical to in NiKomCon.c forsok=2; while(forsok) { puttekn("\r\nLösen: ",-1); if(Servermem->inne[nodnr].flaggor & STAREKOFLAG) { if(getstring(STAREKO,15,NULL)) { car=FALSE; break; } } else { if(getstring(EJEKO,15,NULL)) { car=FALSE; break; } } if(CheckPassword(inmat, Servermem->inne[nodnr].losen)) { forsok=FALSE; going=FALSE; } else forsok--; } if(going && (Servermem->cfg.logmask & LOG_FAILINLOGG)) { LogEvent(USAGE_LOG, WARN, "Nod %d, %s angivet som namn, fel lösen.", nodnr, getusername(inloggad)); } if(going) going++; } else if(inloggad==-1) puttekn("\r\nHittar ej namnet\r\n",-1); } if(!car) { if(getty) cleanup(OK,""); disconnect(); continue; } if(going) { putstring("\n\n\rTyvärr. Du har försökt maximalt antal gånger att logga in. Kopplar ned.\n\r",-1,0); goto panik; /* Urrk vad fult. :-) */ } Servermem->inloggad[nodnr]=inloggad; Servermem->idletime[nodnr] = time(NULL); if((nt = selectNodeType()) == NULL) { goto panik; } abortinactive(); abortserial(); sprintf(commandstring,"%s -N%d -B%d %s",nt->path,nodnr,dtespeed,configname); CloseConsole(); CloseWindow(NiKwind); NiKwind = NULL; RemPort(nikomnodeport); i = 0; if(Servermem->connectbps[nodnr] > 0) { while(Servermem->info.bps[i] != Servermem->connectbps[nodnr] && Servermem->info.bps[i] > 0 && i<49) i++; if(i<49) { if(Servermem->info.bps[i] == Servermem->connectbps[nodnr]) Servermem->info.antbps[i]++; else { Servermem->info.bps[i] = Servermem->connectbps[nodnr]; Servermem->info.antbps[i]++; } } if(!(fil = fopen("NiKom:datocfg/sysinfo.dat","w"))) { /* putstring("Kunde inte spara nya sysinfo.dat..\n",-1,0); */ } if(fwrite((void *)&Servermem->info,sizeof(Servermem->info),1,fil) != 1) { /* putstring("Kunde inte skriva till nya sysinfo.dat....\n",-1,0); */ } fclose(fil); } nodestate = SystemTags(commandstring, SYS_UserShell, TRUE, TAG_DONE); AddPort(nikomnodeport); if(!getty || (nodestate & NIKSTATE_RELOGIN)) { if(!(NiKwind = openmywindow(tmppscreen))) cleanup(ERROR,"Kunde inte öppna fönstret\n"); OpenConsole(NiKwind); } serreqtkn(); if(nodestate & NIKSTATE_RELOGIN) goto reloginspec; panik: Delay(hangupdelay); if(getty) cleanup(OK,""); disconnect(); } }
checkvalidbatch() { char s[90], bytes[10], code[10], baud[10], bps[10], numcps[10], cps[10], numerror[10], error[10], stops[10], paksize[10], regnum[10],k[80]; char drive[MAXDRIVE],dir[MAXDIR],filename[MAXFILE],ext[MAXEXT]; FILE *bu; int i,totalcps, totalerror,o,totalfiles,oldfps,totalfps; struct userfile tempu; totalcps=totalerror=totalfiles=totalfps=0; bu=fopen("TRANSFER.LOG","r"); if(bu==NULL) { nl(); pl("4Can't find log file!!"); fclose(bu); return; } oldfps=user.filepoints; for(i=0;i < que.files || (feof(bu)==0);i++) { fscanf(bu,"%s %s %s %s %s %s %s %s %s %s %s %s",code,bytes,baud,bps,numcps,cps,numerror,error,stops,paksize,s,regnum); strupr(code); if(code[0] != 'L' && code[0] != 'E' && code[0] != 'Q') { user.filepoints -= fstruct.filepoints; user.num_dl++; user.k_dl+=fstruct.bytes; fstruct.timesdl++; writeuser(); fnsplit(s,drive,dir,filename,ext); strcpy(s,filename); strcat(s,ext); o=read_file(s); writefiles(o); readuser(fstruct.uploader,&tempu); tempu.filepoints=+fstruct.filepoints; writeu(&tempu); totalfiles++; totalcps+=atoi(numcps); totalerror+=atoi(numerror); totalfps+=fstruct.filepoints; } } fclose(bu); put_char(12); title("Transfer Stats"); print("4Average CPS :3 %d",totalcps/totalfiles); nl(); print("4Baud :3 %s",baud); nl(); print("4Total Errors:3 %d",totalerror); nl(); print("4Total Files :3 %d",totalfiles); nl(); nl(); print("4Old FPS: 3%d",oldfps); nl(); print("4Cost : 3%d",totalfps); nl(); print("4 ÄÄÄÄÄÄ"); nl(); print("4New FPS: 3%d",(oldfps-totalfps)); nl(); nl(); }
void *__saveds __asm LIBReadUser(register __d0 LONG usernumber, register __d1 LONG tag, register __a6 struct NiKomBase *NiKomBase) { int i; struct User user; for(i=0;i<MAXNOD;i++) if(usernumber==NiKomBase->Servermem->inloggad[i]) break; if(i<MAXNOD) { memcpy(&user,&NiKomBase->Servermem->inne[i],sizeof(struct User)); } else { if(readuser(usernumber,&user)) return (void *) -2; } switch(tag) { case US_Name : return (void *) user.namn; case US_Street : return (void *) user.gata; case US_Address : return (void *) user.postadress; case US_Country : return (void *) user.land; case US_Phonenumber : return (void *) user.telefon; case US_OtherInfo : return (void *) user.annan_info; case US_Password : return (void *) user.losen; case US_Status : return (void *) user.status; case US_Prompt : return (void *) user.prompt; case US_Rader : return (void *) user.rader; case US_Protocol : return (void *) user.protokoll; case US_Tottid : return (void *) user.tot_tid; case US_FirstLogin : return (void *) user.forst_in; case US_LastLogin : return (void *) user.senast_in; case US_Read : return (void *) user.read; case US_Written : return (void *) user.skrivit; /* case US_Flags : return (void *) user.flaggor; */ case US_Defarea : return (void *) user.defarea; case US_Charset : return (void *) user.chrset; case US_Uploads : return (void *) user.upload; case US_Downloads : return (void *) user.download; case US_Loggin : return (void *) user.loggin; case US_Shell : return (void *) user.shell; } return (void *) -1; }
int __saveds __asm LIBEditUser(register __d0 LONG usernumber, register __a0 struct TagItem *taglist, register __a6 struct NiKomBase *NiKomBase) { int i, userloggedin = -1, cacheduser = -1; ULONG tmp; struct User user; for(i=0;i<MAXNOD;i++) if(usernumber==NiKomBase->Servermem->inloggad[i]) break; if(i<MAXNOD) { memcpy(&user,&NiKomBase->Servermem->inne[i],sizeof(struct User)); userloggedin = i; } else { /* for(i=0;i<MAXUSERSCACHED;i++) if(NiKomBase->Servermem->UserCache[i].usernumber != -1) break; if(i<MAXUSERSCACHED) { memcpy(&user,&NiKomBase->Servermem->UserCache[i].Usercached,sizeof(struct User)); userloggedin = i; } else */ if(readuser(usernumber,&user)) return(-2); } if(GetTagData(US_Name,NULL,taglist)) if(parsenamn((char *)GetTagData(US_Name,NULL,taglist),NiKomBase) == -1) strcpy(user.namn,(char *)GetTagData(US_Name,NULL,taglist)); if(GetTagData(US_Street,NULL,taglist)) strcpy(user.gata,(char *)GetTagData(US_Street,NULL,taglist)); if(GetTagData(US_Address,NULL,taglist)) strcpy(user.postadress,(char *)GetTagData(US_Address,NULL,taglist)); if(GetTagData(US_Country,NULL,taglist)) strcpy(user.land,(char *)GetTagData(US_Country,NULL,taglist)); if(GetTagData(US_Phonenumber,NULL,taglist)) strcpy(user.telefon,(char *)GetTagData(US_Phonenumber,NULL,taglist)); if(GetTagData(US_OtherInfo,NULL,taglist)) strcpy(user.annan_info,(char *)GetTagData(US_OtherInfo,NULL,taglist)); if(GetTagData(US_Password,NULL,taglist)) strcpy(user.losen,(char *)GetTagData(US_Password,NULL,taglist)); if(GetTagData(US_Prompt,NULL,taglist)) strcpy(user.prompt,(char *)GetTagData(US_Prompt,NULL,taglist)); tmp = GetTagData(US_Status,-1L,taglist); if(tmp != -1L) user.status = tmp; tmp = GetTagData(US_Rader,-1L,taglist); if(tmp != -1L) user.rader = tmp; tmp = GetTagData(US_Protocol,-1L,taglist); if(tmp != -1L) user.protokoll = tmp; tmp = GetTagData(US_Tottid,-1L,taglist); if(tmp != -1L) user.tot_tid = tmp; tmp = GetTagData(US_FirstLogin,-1L,taglist); if(tmp != -1L) user.forst_in = tmp; tmp = GetTagData(US_LastLogin,-1L,taglist); if(tmp != -1L) user.senast_in = tmp; tmp = GetTagData(US_Read,-1L,taglist); if(tmp != -1L) user.read = tmp; GetTagData(US_Written,-1L,taglist); if(tmp != -1L) user.skrivit = tmp; tmp = GetTagData(US_Flags,-1L,taglist); if(tmp != -1L) user.flaggor = tmp; tmp = GetTagData(US_Defarea,-1L,taglist); if(tmp != -1L) user.defarea = tmp; tmp = GetTagData(US_Charset,-1L,taglist); if(tmp != -1L) user.chrset = tmp; tmp = GetTagData(US_Uploads,-1L,taglist); if(tmp != -1L) user.upload = tmp; tmp = GetTagData(US_Downloads,-1L,taglist); if(tmp != -1L) user.download = tmp; tmp = GetTagData(US_Loggin,-1L,taglist); if(tmp != -1L) user.loggin = tmp; tmp = GetTagData(US_Shell,-1L,taglist); if(tmp != -1L) user.shell = tmp; /* struct User { long tot_tid,forst_in,senast_in,read,skrivit,flaggor,textpek,brevpek, grupper,defarea,reserv2,chrset,reserv4,reserv5,upload,download, loggin,shell; char namn[41],gata[41],postadress[41],land[41],telefon[21], annan_info[61],losen[16],status,rader,protokoll, prompt[6],motratt[MAXMOTE/8],motmed[MAXMOTE/8],vote[MAXVOTE]; }; */ if(i<MAXNOD) memcpy(&NiKomBase->Servermem->inne[i],&user,sizeof(struct User)); else { if(writeuser(usernumber,&user)) return(-3); } return(usernumber); }
int andmot(void) { int motnr,going=TRUE,tillf,chng=FALSE,y,mad,clearmed,setratt,changed,x; struct ShortUser *userletpek; struct FidoDomain *domain; struct User skuser; struct Mote tempmote,*motpek; char tkn; if((motnr=parsemot(argument))==-1) { puttekn("\r\n\nFinns inget möte som heter så!\r\n\n",-1); return(0); } else if(motnr==-3) { puttekn("\r\n\nSkriv: Ändra Möte <mötesnamn>\r\n\n",-1); return(0); } motpek=getmotpek(motnr); if(!MayAdminConf(motnr, inloggad, &Servermem->inne[nodnr])) { puttekn("\r\n\nDu har ingen rätt att ändra på det mötet!\r\n\n",-1); return(0); } memcpy(&tempmote,motpek,sizeof(struct Mote)); while(going) { sprintf(outbuffer,"\r\nNamn : (%s) ",tempmote.namn); puttekn(outbuffer,-1); if(getstring(EKO,40,NULL)) return(1); if(inmat[0]) { if((tillf=parsemot(inmat))!=-1 && tillf!=motnr) puttekn("\r\n\nMötet finns redan!\r\n",-1); else { strncpy(tempmote.namn,inmat,40); tempmote.namn[40] = 0; going=FALSE; } } else going=FALSE; } sprintf(outbuffer,"\r\nMAD (%s) ",getusername(tempmote.mad)); puttekn(outbuffer,-1); if(getstring(EKO,40,NULL)) return(1); if(inmat[0]) { if((mad=parsenamn(inmat))==-1) puttekn("\r\nFinns ingen sådan användare!",-1); else tempmote.mad=mad; } sprintf(outbuffer,"\r\nSorteringsvärde : (%d) ",tempmote.sortpri); puttekn(outbuffer,-1); if(getstring(EKO,10,NULL)) return(1); if(inmat[0]) { tillf=atoi(inmat); if(tillf<0 || tillf>LONG_MAX) { sprintf(outbuffer,"\n\rVärdet måste ligga mellan 0 och %d",LONG_MAX); puttekn(outbuffer,-1); } else tempmote.sortpri=tillf; } puttekn("\r\nSka mötet vara slutet? ",-1); if(!jaellernej('j','n',tempmote.status & SLUTET ? 1 : 2)) { puttekn("Öppet",-1); if(tempmote.status & SLUTET) { chng=TRUE; tempmote.status &= ~SLUTET; } } else { puttekn("Slutet",-1); if(!(tempmote.status & SLUTET)) { chng=TRUE; tempmote.status |= SLUTET; } puttekn("\r\nVilka grupper ska ha tillgång till mötet? (? för lista)\r\n",-1); if(editgrupp((char *)&tempmote.grupper)) return(1); } puttekn("\r\nSka mötet vara skrivskyddat? ",-1); if(!jaellernej('j','n',tempmote.status & SKRIVSKYDD ? 1 : 2)) { puttekn("Oskyddat",-1); tempmote.status &= ~SKRIVSKYDD; } else { tempmote.status |= SKRIVSKYDD; puttekn("Skyddat",-1); } puttekn("\r\nSka mötet vara kommentarsskyddat? ",-1); if(!jaellernej('j','n',tempmote.status & KOMSKYDD ? 1 : 2)) { puttekn("Oskyddat",-1); tempmote.status &= ~KOMSKYDD; } else { tempmote.status |= KOMSKYDD; puttekn("Skyddat",-1); } puttekn("\r\nSka mötet vara hemligt? ",-1); if(!jaellernej('j','n',tempmote.status & HEMLIGT ? 1 : 2)) { puttekn("Ej hemligt",-1); tempmote.status &= ~HEMLIGT; } else { tempmote.status |= HEMLIGT; puttekn("Hemligt",-1); } if(!(tempmote.status & SLUTET)) { puttekn("\n\rSka alla användare bli medlemmar automagiskt? ",-1); if(!jaellernej('j','n',tempmote.status & AUTOMEDLEM ? 1 : 2)) { puttekn("Nej",-1); if(tempmote.status & AUTOMEDLEM) { chng=TRUE; tempmote.status &= ~AUTOMEDLEM; } } else { puttekn("Ja",-1); tempmote.status |= AUTOMEDLEM; } puttekn("\r\nSka rättigheterna styra skrivmöjlighet? ",-1); if(!jaellernej('j','n',tempmote.status & SKRIVSTYRT ? 1 : 2)) { puttekn("Nej",-1); if(tempmote.status & SKRIVSTYRT) chng=TRUE; tempmote.status &= ~SKRIVSTYRT; } else { puttekn("Ja",-1); if(!(tempmote.status & SKRIVSTYRT)) chng=TRUE; tempmote.status |= SKRIVSTYRT; puttekn("\r\nVilka grupper ska ha tillgång till mötet? (? för lista)\r\n",-1); if(editgrupp((char *)&tempmote.grupper)) return(1); } } else tempmote.status &= ~(AUTOMEDLEM | SKRIVSTYRT); puttekn("\r\nSka mötet bara vara åtkomligt från ARexx? ",-1); if(!jaellernej('j','n',tempmote.status & SUPERHEMLIGT ? 1 : 2)) { puttekn("Nej",-1); tempmote.status &= ~SUPERHEMLIGT; } else { tempmote.status |= SUPERHEMLIGT; puttekn("Ja",-1); } if(tempmote.type == MOTE_FIDO) { sprintf(outbuffer,"\n\rKatalog: (%s) ",tempmote.dir); puttekn(outbuffer,-1); getstring(EKO,79,NULL); if(inmat[0]) strcpy(tempmote.dir,inmat); sprintf(outbuffer,"\n\rTag-namn: (%s) ",tempmote.tagnamn); puttekn(outbuffer,-1); getstring(EKO,49,NULL); if(inmat[0]) strcpy(tempmote.tagnamn,inmat); sprintf(outbuffer,"\n\rOrigin: (%s) ",tempmote.origin); puttekn(outbuffer,-1); getstring(EKO,69,NULL); if(inmat[0]) strcpy(tempmote.origin,inmat); sprintf(outbuffer,"\n\n\r%c1: ISO Latin 1 (ISO 8859-1)\n\r",tempmote.charset==CHRS_LATIN1 ? '*' : ' '); puttekn(outbuffer,-1); sprintf(outbuffer,"%c2: SIS-7 (SF7, 'Måsvingar')\n\r",tempmote.charset==CHRS_SIS7 ? '*' : ' '); puttekn(outbuffer,-1); sprintf(outbuffer,"%c3: IBM CodePage\n\r",tempmote.charset==CHRS_CP437 ? '*' : ' '); puttekn(outbuffer,-1); sprintf(outbuffer,"%c4: Mac\n\n\r",tempmote.charset==CHRS_MAC ? '*' : ' '); puttekn(outbuffer,-1); puttekn("Val: ",-1); for(;;) { tkn=gettekn(); if(tkn=='1' || tkn=='2' || tkn=='3' || tkn=='4' || tkn=='\r') break; } switch(tkn) { case '1' : tempmote.charset = CHRS_LATIN1; break; case '2' : tempmote.charset = CHRS_SIS7; break; case '3' : tempmote.charset = CHRS_CP437; break; case '4' : tempmote.charset = CHRS_MAC; break; default: break; } puttekn("\n\n\r",-1); for(x=0;x<10;x++) { if(!Servermem->fidodata.fd[x].domain[0]) break; sprintf(outbuffer,"%c%3d: %s (%d:%d/%d.%d)\n\r",tempmote.domain == Servermem->fidodata.fd[x].nummer ? '*' : ' ', Servermem->fidodata.fd[x].nummer, Servermem->fidodata.fd[x].domain, Servermem->fidodata.fd[x].zone, Servermem->fidodata.fd[x].net, Servermem->fidodata.fd[x].node, Servermem->fidodata.fd[x].point); puttekn(outbuffer,-1); } if(!x) { puttekn("\n\rDu måste definiera en domän i NiKomFido.cfg först!\n\r",-1); return(0); } for(;;) { if(getstring(EKO,10,NULL)) return(1); if(!inmat[0]) break; if(domain=getfidodomain(atoi(inmat),0)) { tempmote.domain=domain->nummer; break; } else puttekn("\n\rFinns ingen sådan domän.\n\r",-1); } } puttekn("\r\n\nÄr allt korrekt? ",-1); if(jaellernej('j','n',1)) puttekn("Ja\n\n\r",-1); else { puttekn("Nej\r\n\n",-1); return(0); } if(chng) { puttekn("Users.dat kommer nu att gås igenom för att nollställa medlemskap\n\r",-1); puttekn("och rättigheter som om mötet var nyskapat.\n\n\r",-1); puttekn("Är ändringarna fortfarande korrekta? ",-1); if(!jaellernej('j','n',1)) { puttekn("Nej\n\r",-1); return(0); } puttekn("Ja\n\r",-1); } memcpy(motpek,&tempmote,sizeof(struct Mote)); writemeet(motpek); if(!chng) return(0); if((tempmote.status & AUTOMEDLEM) && !(tempmote.status & SKRIVSTYRT)) return(0); if(tempmote.status & SUPERHEMLIGT) return(0); if(tempmote.status & AUTOMEDLEM) clearmed=FALSE; else clearmed=TRUE; if(tempmote.status & (SLUTET | SKRIVSTYRT)) setratt=FALSE; else setratt=TRUE; for(y=0;y<MAXNOD;y++) { BAMCLEAR(Servermem->inne[y].motmed,tempmote.nummer); if(setratt) BAMSET(Servermem->inne[y].motratt,tempmote.nummer); else BAMCLEAR(Servermem->inne[y].motratt,tempmote.nummer); } puttekn("\r\nÄndrar i Users.dat..\r\n",-1); for(userletpek=(struct ShortUser *)Servermem->user_list.mlh_Head;userletpek->user_node.mln_Succ;userletpek=(struct ShortUser *)userletpek->user_node.mln_Succ) { if(!(userletpek->nummer%10)) { sprintf(outbuffer,"\r%d",userletpek->nummer); puttekn(outbuffer,-1); } if(readuser(userletpek->nummer,&skuser)) return(0); changed=FALSE; if(setratt!=BAMTEST(skuser.motratt,tempmote.nummer)) { if(setratt) BAMSET(skuser.motratt,tempmote.nummer); else BAMCLEAR(skuser.motratt,tempmote.nummer); changed=TRUE; } if(clearmed && BAMTEST(skuser.motmed,tempmote.nummer)) { BAMCLEAR(skuser.motmed,tempmote.nummer); changed=TRUE; } if(changed && writeuser(userletpek->nummer,&skuser)) return(0); } for(y=0;y<MAXNOD;y++) { BAMCLEAR(Servermem->inne[y].motmed,tempmote.nummer); if(setratt) BAMSET(Servermem->inne[y].motratt,tempmote.nummer); else BAMCLEAR(Servermem->inne[y].motratt,tempmote.nummer); } BAMSET(Servermem->inne[nodnr].motratt,tempmote.nummer); BAMSET(Servermem->inne[nodnr].motmed,tempmote.nummer); return(0); }
void main(int argc, char **argv) { int going = TRUE, forsok = 2,car = 1, tmp, ch; long tid; char tellstr[100],*tmppscreen, titel[80]; NewList((struct List *)&aliaslist); NewList((struct List *)&edit_list); if(!(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0))) cleanup(EXIT_ERROR,"Kunde inte öppna intuition.library\n"); if(!(UtilityBase=OpenLibrary("utility.library",37L))) cleanup(EXIT_ERROR,"Kunde inte öppna utility.library\n"); if(!(LocaleBase=OpenLibrary("locale.library",38L))) cleanup(EXIT_ERROR,"Kunde inte öppna locale.library\n"); if(!(NiKomBase=OpenLibrary("nikom.library",0L))) cleanup(EXIT_ERROR,"Kunde inte öppna nikom.linbrary"); getnodeconfig("NiKom:Datocfg/ConNode.cfg"); if(!(initnode(NODCON))) cleanup(EXIT_ERROR,"Kunde inte registrera noden i Servern\n"); if(!(nikomnodeport = CreateMsgPort())) cleanup(EXIT_ERROR,"Kunde inte skapa NiKomNode-porten"); sprintf(nikomnodeportnamn,"NiKomNode%d",nodnr); nikomnodeport->mp_Node.ln_Name = nikomnodeportnamn; nikomnodeport->mp_Node.ln_Pri = 1; AddPort(nikomnodeport); sprintf(rexxportnamn,"NiKomRexx%d",nodnr); if(!(rexxport=(struct MsgPort *)CreateMsgPort())) cleanup(EXIT_ERROR,"Kunde inte öppna RexxPort\n"); rexxport->mp_Node.ln_Name=rexxportnamn; rexxport->mp_Node.ln_Pri=50; AddPort(rexxport); if(!(RexxSysBase=(struct RsxLib *)OpenLibrary("rexxsyslib.library",0L))) cleanup(EXIT_ERROR,"Kunde inte öppna rexxsyslib.library\n"); if(pubscreen[0]=='-') tmppscreen=NULL; else tmppscreen=pubscreen; if(!(NiKwind=(struct Window *)OpenWindowTags(NULL,WA_Left,xpos, WA_Top,ypos, WA_Width,xsize, WA_Height,ysize, WA_IDCMP,IDCMP_CLOSEWINDOW, WA_MinWidth,50, WA_MinHeight,10, WA_MaxWidth,~0, WA_MaxHeight,~0, WA_SizeGadget,TRUE, WA_SizeBBottom, TRUE, WA_DragBar,TRUE, WA_DepthGadget,TRUE, WA_CloseGadget,TRUE, WA_SimpleRefresh,TRUE, WA_ScreenTitle,"NiKomCon", WA_AutoAdjust,TRUE, WA_PubScreenName,tmppscreen, TAG_DONE))) cleanup(EXIT_ERROR,"Kunde inte öppna fönstret\n"); if(!OpenIO(NiKwind)) cleanup(EXIT_ERROR,"Kunde inte öppna IO\n"); strcpy(Servermem->nodid[nodnr],nodid); sprintf(titel,"Nod #%d CON: <Ingen inloggad>",nodnr); SetWindowTitles(NiKwind,titel,(UBYTE *)-1L); Servermem->connectbps[nodnr] = -1; conreqtkn(); do { Servermem->idletime[nodnr] = time(NULL); memset(commandhistory,0,1024); Servermem->inne[nodnr].rader=0; sendfile("NiKom:Texter/Inlogg.txt"); if(Servermem->cfg.ar.preinlogg) sendautorexx(Servermem->cfg.ar.preinlogg); going=TRUE; while(going) { Servermem->idletime[nodnr] = time(NULL); puttekn("\r\nNamn: ",-1); getstring(EKO,40,NULL); if(!stricmp(inmat,Servermem->cfg.ny)) { tmp = RegisterNewUser(); if(tmp == 2) { goto panik; } car = tmp ? 0 : 1; going=FALSE; } else if((inloggad=parsenamn(inmat))>=0) { if(readuser(inloggad,&Servermem->inne[nodnr])) { puttekn("Error reading user data.\r\n", -1); goto panik; } // TODO: Extract password loop. Should be identical to in PreNode/Ser.c forsok=2; while(forsok) { puttekn("\r\nLösen: ",-1); if(Servermem->inne[nodnr].flaggor & STAREKOFLAG) getstring(STAREKO,15,NULL); else getstring(EJEKO,15,NULL); if(CheckPassword(inmat, Servermem->inne[nodnr].losen)) { forsok=FALSE; going=FALSE; } else { forsok--; } } } else if(inloggad==-1) puttekn("\r\nHittar ej namnet\r\n",-1); } sprintf(titel,"Nod #%d CON: %s #%d",nodnr,Servermem->inne[nodnr].namn,inloggad); SetWindowTitles(NiKwind,titel,(UBYTE *)-1L); if(!ReadUnreadTexts(&Servermem->unreadTexts[nodnr], inloggad)) { puttekn("Error reading unread text info.\r\n", -1); LogEvent(SYSTEM_LOG, ERROR, "Can't read unread text info for user %d", inloggad); goto panik; } Servermem->inloggad[nodnr]=inloggad; Servermem->idletime[nodnr] = time(NULL); if(getft("NiKom:Texter/Bulletin.txt")>Servermem->inne[nodnr].senast_in) sendfile("NiKom:Texter/Bulletin.txt"); connection(); if(Servermem->cfg.logmask & LOG_UTLOGG) { LogEvent(USAGE_LOG, INFO, "%s loggar ut från nod %d", getusername(inloggad), nodnr); } if(Servermem->say[nodnr]) displaysay(); if(Servermem->cfg.ar.utlogg) sendautorexx(Servermem->cfg.ar.utlogg); sendfile("NiKom:Texter/Utlogg.txt"); sprintf(titel,"Nod #%d CON: <Ingen inloggad>",nodnr); SetWindowTitles(NiKwind,titel,(UBYTE *)-1L); Servermem->inloggad[nodnr]=-1; Servermem->action[nodnr]=0; time(&tid); Servermem->inne[nodnr].senast_in=tid; Servermem->inne[nodnr].tot_tid+=(tid-logintime); Servermem->inne[nodnr].loggin++; Servermem->info.inloggningar++; Servermem->inne[nodnr].defarea=area2; writeuser(inloggad,&Servermem->inne[nodnr]); WriteUnreadTexts(&Servermem->unreadTexts[nodnr], inloggad); writesenaste(); freealiasmem(); sprintf(tellstr,"loggade just ut från nod %d",nodnr); tellallnodes(tellstr); panik: nodestate = 0; puttekn("\r\n\nEn inloggning till? (J/n)",-1); } while((ch = GetChar()) != 'n' && ch != 'N'); cleanup(EXIT_OK,""); }
int skapmot(void) { struct ShortUser *shortUser; int mad, setPermission, changed, ch, i, fidoDomainId, highestId; struct FidoDomain *fidoDomain; BPTR lock; struct User user; struct Mote tmpConf,*searchConf,*newConf; memset(&tmpConf, 0, sizeof(struct Mote)); if(argument[0] == '\0') { SendString("\r\n\nNamn på mötet: "); if(GetString(40,NULL)) { return 1; } strcpy(tmpConf.namn, inmat); } else { strcpy(tmpConf.namn, argument); } if(parsemot(tmpConf.namn) != -1) { SendString("\r\n\nFinns redan ett sådant möte!\r\n"); return 0; } tmpConf.skapat_tid = time(NULL);; tmpConf.skapat_av = inloggad; for(;;) { SendString("\r\nMötesAdministratör (MAD) : "); if(GetString(5,NULL)) { return 1; } if(inmat[0]) { if((mad = parsenamn(inmat)) == -1) { SendString("\r\nFinns ingen sådan användare!"); } else { tmpConf.mad = mad; break; } } } SendString("\n\rSorteringsvärde: "); tmpConf.sortpri = GetNumber(0, LONG_MAX, NULL); if(EditBitFlagShort("\r\nSka mötet vara slutet?", 'j', 'n', "Slutet", "Öppet", &tmpConf.status, SLUTET)) { return 1; } if(tmpConf.status & SLUTET) { SendString("\r\nVilka grupper ska ha tillgång till mötet? (? för lista)\r\n"); if(editgrupp((char *)&tmpConf.grupper)) { return 1; } } if(EditBitFlagShort("\r\nSka mötet vara skrivskyddat?", 'j', 'n', "Skyddat", "Oskyddat", &tmpConf.status, SKRIVSKYDD)) { return 1; } if(EditBitFlagShort("\r\nSka mötet vara kommentarsskyddat?", 'j', 'n', "Skyddat", "Oskyddat", &tmpConf.status, KOMSKYDD)) { return 1; } if(EditBitFlagShort("\r\nSka mötet vara hemligt?", 'j', 'n', "Hemligt", "Ej hemligt", &tmpConf.status, HEMLIGT)) { return 1; } if(!(tmpConf.status & SLUTET)) { if(EditBitFlagShort("\r\nSka alla användare bli medlemmar automagiskt?", 'j', 'n', "Ja", "Nej", &tmpConf.status, AUTOMEDLEM)) { return 1; } if(EditBitFlagShort("\r\nSka rättigheterna styra skrivmöjlighet?", 'j', 'n', "Ja", "Nej", &tmpConf.status, SKRIVSTYRT)) { return 1; } if(tmpConf.status & SKRIVSTYRT) { SendString("\r\nVilka grupper ska ha tillgång till mötet? (? för lista)\r\n"); if(editgrupp((char *)&tmpConf.grupper)) { return 1; } } } if(EditBitFlagShort("\r\nSka mötet enbart kommas åt från ARexx?", 'j', 'n', "Ja", "Nej", &tmpConf.status, SUPERHEMLIGT)) { return 1; } SendString("\n\n\rVilken typ av möte ska det vara?\n\r"); SendString("1: Lokalt möte\n\r"); SendString("2: Fido-möte\n\n\r"); SendString("Val: "); for(;;) { ch = GetChar(); if(ch == GETCHAR_LOGOUT) { return 1; } if(ch == '1' || ch == '2') { break; } } if(ch == '1') { SendString("Lokalt möte\n\n\r"); tmpConf.type = MOTE_ORGINAL; } else { SendString("Fido-möte\n\n\r"); tmpConf.type = MOTE_FIDO; if(EditString("Katalog for .msg-filerna", tmpConf.dir, 79, TRUE)) { return 1; } if(!(lock = Lock(tmpConf.dir, SHARED_LOCK))) { if(!(lock = CreateDir(tmpConf.dir))) SendString("\n\rKunde inte skapa katalogen\n\r"); } if(lock) { UnLock(lock); } if(EditString("FidoNet tag-namn", tmpConf.tagnamn, 49, TRUE)) { return 1; } strcpy(tmpConf.origin, Servermem->fidodata.defaultorigin); if(MaybeEditString("Origin-rad", tmpConf.origin, 69)) { return 1; } SendString("\n\n\rVilken teckenuppsättning ska användas för utgående texter?\n\r"); SendString("1: ISO Latin 1 (ISO 8859-1)\n\r"); SendString("2: SIS-7 (SF7, 'Måsvingar')\n\r"); SendString("3: IBM CodePage\n\r"); SendString("4: Mac\n\n\r"); SendString("Val: "); for(;;) { ch = GetChar(); if(ch == GETCHAR_LOGOUT) { return 1; } if(ch == '1' || ch == '2' || ch == '3' || ch == '4') { break; } } switch(ch) { case '1': SendString("ISO Latin 1\n\n\r"); tmpConf.charset = CHRS_LATIN1; break; case '2': SendString("SIS-7\n\n\r"); tmpConf.charset = CHRS_SIS7; break; case '3': SendString("IBM CodePage\n\n\r"); tmpConf.charset = CHRS_CP437; break; case '4': SendString("Mac\n\n\r"); tmpConf.charset = CHRS_MAC; break; } SendString("Vilken domän är mötet i?\n\r"); highestId = 0; for(i = 0; i < 10; i++) { if(!Servermem->fidodata.fd[i].domain[0]) { break; } highestId = max(highestId, Servermem->fidodata.fd[i].nummer); SendString("%3d: %s (%d:%d/%d.%d)\n\r", Servermem->fidodata.fd[i].nummer, Servermem->fidodata.fd[i].domain, Servermem->fidodata.fd[i].zone, Servermem->fidodata.fd[i].net, Servermem->fidodata.fd[i].node, Servermem->fidodata.fd[i].point); } if(i == 0) { SendString("\n\rDu måste definiera en domän i NiKomFido.cfg först!\n\r"); return 0; } for(;;) { SendString("\r\nDomän: "); if(GetString(5, NULL)) { return 1; } fidoDomainId = atoi(inmat); if(fidoDomain = getfidodomain(fidoDomainId, 0)) { break; } else { SendString("\n\rFinns ingen sådan domän.\n\r"); } } tmpConf.domain = fidoDomain->nummer; SendString("%s\n\n\r", fidoDomain->domain); } for(i = 0; i < MAXMOTE; i++) { if(getmotpek(i) == NULL) { break; } } if(i >= MAXMOTE) { SendString("\n\n\rDet finns inte plats för fler möten.\n\r"); return 0; } tmpConf.nummer = i; if(!(newConf = (struct Mote *)AllocMem(sizeof(struct Mote), MEMF_CLEAR | MEMF_PUBLIC))) { LogEvent(SYSTEM_LOG, ERROR, "Could not allocate %d bytes.", sizeof(struct Mote)); DisplayInternalError(); return 0; } memcpy(newConf, &tmpConf, sizeof(struct Mote)); ITER_EL(searchConf, Servermem->mot_list, mot_node, struct Mote *) { if(searchConf->sortpri > newConf->sortpri) { break; } } searchConf = (struct Mote *)searchConf->mot_node.mln_Pred; Insert((struct List *)&Servermem->mot_list, (struct Node *)newConf, (struct Node *)searchConf); writemeet(newConf); if((newConf->status & AUTOMEDLEM) && !(newConf->status & SKRIVSTYRT)) { return 0; } if(newConf->status & SUPERHEMLIGT) { return 0; } setPermission = (newConf->status & (SLUTET | SKRIVSTYRT)) ? FALSE : TRUE; for(i = 0; i < MAXNOD; i++) { BAMCLEAR(Servermem->inne[i].motmed, newConf->nummer); if(setPermission) { BAMSET(Servermem->inne[i].motratt, newConf->nummer); } else { BAMCLEAR(Servermem->inne[i].motratt, newConf->nummer); } } SendString("\r\nÄndrar i användardata..\r\n"); ITER_EL(shortUser, Servermem->user_list, user_node, struct ShortUser *) { if(!(shortUser->nummer % 10)) { SendString("\r%d", shortUser->nummer); } if(readuser(shortUser->nummer, &user)) { LogEvent(SYSTEM_LOG, ERROR, "Could not read user %d to set " "membership/permissions for new conference.", shortUser->nummer); DisplayInternalError(); return 0; } changed = FALSE; if(setPermission != BAMTEST(user.motratt, newConf->nummer)) { if(setPermission) { BAMSET(user.motratt, newConf->nummer); } else { BAMCLEAR(user.motratt, newConf->nummer); } changed = TRUE; } if(!(newConf->status & AUTOMEDLEM) && BAMTEST(user.motmed, newConf->nummer)) { BAMCLEAR(user.motmed, newConf->nummer); changed = TRUE; } if(changed && writeuser(shortUser->nummer, &user)) { LogEvent(SYSTEM_LOG, ERROR, "Could not write user %d to set " "membership/permissions for new conference.", shortUser->nummer); DisplayInternalError(); return 0; } } for(i = 0; i < MAXNOD; i++) { BAMCLEAR(Servermem->inne[i].motmed, newConf->nummer); if(setPermission) { BAMSET(Servermem->inne[i].motratt, newConf->nummer); } else { BAMCLEAR(Servermem->inne[i].motratt, newConf->nummer); } } BAMSET(Servermem->inne[nodnr].motratt, newConf->nummer); BAMSET(Servermem->inne[nodnr].motmed, newConf->nummer); if(newConf->type == MOTE_FIDO) { ReScanFidoConf(newConf, 0); } return 0; }
void main(int argc, char **argv) { int going=TRUE,forsok=2,car=1; long tid; char tellstr[100],*tmppscreen, titel[80]; UBYTE tillftkn; NewList((struct List *)&aliaslist); NewList((struct List *)&edit_list); if(!(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0))) cleanup(ERROR,"Kunde inte öppna intuition.library\n"); if(!(UtilityBase=OpenLibrary("utility.library",37L))) cleanup(ERROR,"Kunde inte öppna utility.library\n"); if(!(NiKomBase=OpenLibrary("nikom.library",0L))) cleanup(ERROR,"Kunde inte öppna nikom.linbrary"); getnodeconfig("NiKom:Datocfg/ConNode.cfg"); if(!(initnode(NODCON))) cleanup(ERROR,"Kunde inte registrera noden i Servern\n"); if(!(nikomnodeport = CreateMsgPort())) cleanup(ERROR,"Kunde inte skapa NiKomNode-porten"); sprintf(nikomnodeportnamn,"NiKomNode%d",nodnr); nikomnodeport->mp_Node.ln_Name = nikomnodeportnamn; nikomnodeport->mp_Node.ln_Pri = 1; AddPort(nikomnodeport); sprintf(rexxportnamn,"NiKomRexx%d",nodnr); if(!(rexxport=(struct MsgPort *)CreateMsgPort())) cleanup(ERROR,"Kunde inte öppna RexxPort\n"); rexxport->mp_Node.ln_Name=rexxportnamn; rexxport->mp_Node.ln_Pri=50; AddPort(rexxport); if(!(RexxSysBase=(struct RsxLib *)OpenLibrary("rexxsyslib.library",0L))) cleanup(ERROR,"Kunde inte öppna rexxsyslib.library\n"); if(pubscreen[0]=='-') tmppscreen=NULL; else tmppscreen=pubscreen; if(!(NiKwind=(struct Window *)OpenWindowTags(NULL,WA_Left,xpos, WA_Top,ypos, WA_Width,xsize, WA_Height,ysize, WA_IDCMP,IDCMP_CLOSEWINDOW, WA_MinWidth,50, WA_MinHeight,10, WA_MaxWidth,~0, WA_MaxHeight,~0, WA_SizeGadget,TRUE, WA_SizeBBottom, TRUE, WA_DragBar,TRUE, WA_DepthGadget,TRUE, WA_CloseGadget,TRUE, WA_SimpleRefresh,TRUE, WA_ScreenTitle,"NiKom © Tomas Kärki 1996-1998", WA_AutoAdjust,TRUE, WA_PubScreenName,tmppscreen, TAG_DONE))) cleanup(ERROR,"Kunde inte öppna fönstret\n"); if(!OpenIO(NiKwind)) cleanup(ERROR,"Kunde inte öppna IO\n"); if(!getkeyfile()) cleanup(ERROR,"Korrupt nyckelfil\n"); strcpy(Servermem->nodid[nodnr],nodid); sprintf(titel,"Nod #%d CON: <Ingen inloggad>",nodnr); SetWindowTitles(NiKwind,titel,(UBYTE *)-1L); Servermem->connectbps[nodnr] = -1; conreqtkn(); do { memset(commandhistory,0,1024); Servermem->inne[nodnr].rader=0; sendfile("NiKom:Texter/Inlogg.txt"); if(Servermem->cfg.ar.preinlogg) sendrexx(Servermem->cfg.ar.preinlogg); going=TRUE; while(going) { puttekn("\r\nNamn: ",-1); getstring(EKO,40,NULL); if(!stricmp(inmat,Servermem->cfg.ny)) { /* if(!reggadnamn[0] && ((struct ShortUser *)Servermem->user_list.mlh_TailPred)->nummer >= 4) puttekn("\n\n\rDenna demoversion av NiKom kan hantera maximalt 5 användare.\n\r",-1); else { Versionen är nu obegränsad 970930! */ if((car=nyanv())==2) goto panik; going=FALSE; /* } */ } else if((inloggad=parsenamn(inmat))>=0) { readuser(inloggad,&Servermem->inne[nodnr]); forsok=2; while(forsok) { puttekn("\r\nLösen: ",-1); if(Servermem->inne[nodnr].flaggor & STAREKOFLAG) getstring(STAREKO,15,NULL); else getstring(EJEKO,15,NULL); if(CheckPassword(inloggad, inmat)) { forsok=FALSE; going=FALSE; } else forsok--; } } else if(inloggad==-1) puttekn("\r\nHittar ej namnet\r\n",-1); } sprintf(titel,"Nod #%d CON: %s #%d",nodnr,Servermem->inne[nodnr].namn,inloggad); SetWindowTitles(NiKwind,titel,(UBYTE *)-1L); readuserbitmap(inloggad,Servermem->bitmaps[nodnr],0,temppek); Servermem->inloggad[nodnr]=inloggad; Servermem->idletime[nodnr] = time(NULL); if(getft("NiKom:Texter/Bulletin.txt")>Servermem->inne[nodnr].senast_in) sendfile("NiKom:Texter/Bulletin.txt"); connection(); if(Servermem->cfg.logmask & LOG_UTLOGG) { sprintf(outbuffer,"%s loggar ut från nod %d",getusername(inloggad),nodnr); logevent(outbuffer); } if(Servermem->say[nodnr]) displaysay(); if(Servermem->cfg.ar.utlogg) sendrexx(Servermem->cfg.ar.utlogg); sendfile("NiKom:Texter/Utlogg.txt"); sprintf(titel,"Nod #%d CON: <Ingen inloggad>",nodnr); SetWindowTitles(NiKwind,titel,(UBYTE *)-1L); SaveProgramCategory(inloggad); Servermem->inloggad[nodnr]=-1; Servermem->action[nodnr]=0; Servermem->inne[nodnr].textpek=textpek; time(&tid); Servermem->inne[nodnr].senast_in=tid; Servermem->inne[nodnr].tot_tid+=(tid-logintime); Servermem->inne[nodnr].loggin++; Servermem->info.inloggningar++; Servermem->inne[nodnr].defarea=area2; writeuser(inloggad,&Servermem->inne[nodnr]); writeuserbitmap(inloggad,Servermem->bitmaps[nodnr],0,temppek); writesenaste(); freealiasmem(); sprintf(tellstr,"loggade just ut från nod %d",nodnr); tellallnodes(tellstr); panik: puttekn("\r\n\nEn inloggning till? (J/n)",-1); } while((tillftkn=gettekn())!='n' && tillftkn!='N'); cleanup(OK,""); }
void purge_users() { DIR *userdir; struct dirent *tmpdirent; long now, absenttime; user_type *tmpuser; FILE *fp; char name[L_USERNAME + 1], work[100]; sprintf(work, "%s/%s", LOGDIR, "purgelog"); if ((fp = fopen(work, "a")) == NULL) { fprintf(stderr, "Could not open the purgelog: %s.\n", work); exit(1); } fprintf(fp, "Monolith User Purge: %s\n", date()); userdir = opendir(USERDIR); if (userdir == NULL) { printf("opendir() problems!\n"); exit(0); } while ((tmpdirent = readdir(userdir)) != NULL) { if (tmpdirent->d_name[0] == '.') /* ignore . files */ continue; strcpy(name, tmpdirent->d_name); name2file(name); tmpuser = readuser(name); if (tmpuser == NULL || strcasecmp(name, name2file(tmpuser->username)) != 0) { fprintf(stderr, "purge: problems with %s!\n", name); fprintf(fp, "purge: problems with %s!\n", name); if (tmpuser != NULL) free(tmpuser); continue; } time(&now); absenttime = now - tmpuser->laston_to; if (tmpuser->priv & PRIV_DELETED) { del_user(tmpuser->username); printf("deleted %s\n", tmpuser->username); fprintf(fp, "deleted %s\n", tmpuser->username); } if ( (((absenttime >= 30 * 24 * 60 * 60) && /* 30 days & < 10logins */ (tmpuser->timescalled < 5)) || (tmpuser->priv & PRIV_DELETED) /* or delmarked */ || (absenttime >= 120 * 24 * 60 * 60)) /* 90 days */ && ((tmpuser->flags & US_PERM) == 0) /* not US_PERM */ ) { del_user(tmpuser->username); printf("deleted %s\n", tmpuser->username); fprintf(fp, "deleted %s\n", tmpuser->username); } free(tmpuser); } fclose(fp); closedir(userdir); return; }
void look_into_quickroom(int degree) { int round, total = 0, blank, a, ret; userlist_t *p, *q; room_t scratch; user_t *tmpuser; time_t curtime; time(&curtime); curr_line = 5; line_count = 0; line_total = MAXQUADS; cprintf("\n\1f\1w Types: [\1pA\1w]nonymous, anonymous[\1pO\1w]ption, [\1rI\1w]nviteonly, [\1rP\1w]assworded,\n [\1rG\1w]uessname, [\1bR\1w]eadonly, [\1cS\1w]ubjectline, [\1bN\1w]o roominfo.\n\n\1w\1f## \1yRoomName \1rPosts \1gType \1cRoomAide "); if (degree == 1) cprintf("\1gAbsence"); cprintf("\n\1w----------------------------------------------------------------------------\n"); for (round = 0; round < MAXQUADS; round++) { scratch = readquad(round); if ((scratch.highest >= 0) && (scratch.flags & QR_INUSE) && (i_may_read_forum(round) || degree == 1)) { blank = 0; cprintf("\1w%3d \1y%-30.30s \1r%6ld ", round, scratch.name, scratch.highest); total = total + scratch.highest; if (scratch.flags & QR_PRIVATE) cprintf("\1rI"); else blank++; if (scratch.flags & QR_READONLY) cprintf("\1bR"); else blank++; if (scratch.flags & QR_SUBJECTLINE) cprintf("\1cS"); else blank++; if ((scratch.flags & QR_DESCRIBED) == 0) cprintf("\1bN"); else blank++; if (scratch.flags & QR_ANONONLY) cprintf("\1pA"); else if (scratch.flags & QR_ANON2) cprintf("\1pO"); else blank++; for (a = 0; a < blank; a++) putchar(' '); ret = mono_sql_uf_list_hosts_by_forum(round, &p); if (ret == -1) { cprintf("\1f\1r\nError getting hosts.\n"); } else { q = p; while (q) { cprintf("\1c %-20s \1g", q->name); if (degree == 1) { tmpuser = readuser(q->name); if (tmpuser == NULL) { cprintf("[Error]"); break; } cprintf("%2ld days", ((curtime - tmpuser->laston_to) / 60 / 60 / 24)); xfree(tmpuser); } q = q->next; } dest_userlist(p); } cprintf("\n"); if (increment(0) == 1) break; } } if (degree == 1) cprintf("\nA total number of %d messages have been posted to %s.\n", total, config.bbsname); }