/** delete suggestions from the board **/ void delete_suggestions(UR_OBJECT user) { int cnt; set_crash(); if (word_count<2) { write_user(user,"Pouzitie: dsug all\n"); write_user(user," dsug <#>\n"); write_user(user," dsug to <#>\n"); write_user(user," dsug from <#> to <#>\n"); return; } if (get_wipe_parameters(user)==-1) return; if (!amsys->suggestion_count) { write_user(user,"There are no suggestions to delete.\n"); return; } if (user->wipe_from==-1) { unlink(SUGBOARD); write_user(user,"All suggestions deleted.\n"); write_syslog(SYSLOG,1,"%s wiped all suggestions from the suggestions board\n",user->name); amsys->suggestion_count=0; return; } if (user->wipe_from>amsys->suggestion_count) { vwrite_user(user,"There %s only %d suggestion%s on the board.\n",PLTEXT_IS(amsys->suggestion_count),amsys->suggestion_count,PLTEXT_S(amsys->suggestion_count)); return; } cnt=wipe_messages(SUGBOARD, user->wipe_from,user->wipe_to,0); if (cnt==amsys->suggestion_count) { unlink(SUGBOARD); vwrite_user(user,"There %s only %d suggestion%s on the board, all now deleted.\n",PLTEXT_WAS(cnt),cnt,PLTEXT_S(cnt)); write_syslog(SYSLOG,1,"%s wiped all suggestions from the suggestions board\n",user->name); amsys->suggestion_count=0; return; } amsys->suggestion_count-=cnt; vwrite_user(user,"%d suggestion%s deleted.\n",cnt,PLTEXT_S(cnt)); write_syslog(SYSLOG,1,"%s wiped %d suggestion%s from the suggestions board\n",user->name,cnt,PLTEXT_S(cnt)); }
/* Check if a normal user can remove a message */ int check_board_wipe(UR_OBJECT user) { FILE *fp; int valid,cnt,msg_number,yes,pt; char w1[ARR_SIZE],w2[ARR_SIZE],line[ARR_SIZE],line2[ARR_SIZE],fname[FNAME_LEN],id[ARR_SIZE],rmname[ROOM_NAME_LEN+1]; RM_OBJECT rm; set_crash(); if (word_count<2) { write_usage(user,"wipe <message #>"); return 0; } rm=user->room; if (!rm->mesg_cnt) { write_user(user, no_message_prompt); return 0; } msg_number=atoi(word[1]); if (!msg_number) { write_usage(user,"wipe <#>"); return 0; } if (msg_number>rm->mesg_cnt) { vwrite_user(user,"There %s only %d message%s on the board.\n", PLTEXT_IS(rm->mesg_cnt),rm->mesg_cnt,PLTEXT_S(rm->mesg_cnt)); return 0; } if (rm->access==PERSONAL_LOCKED || rm->access==PERSONAL_UNLOCKED) { midcpy(rm->name,rmname,1,strlen(rm->name)-2); rmname[0]=toupper(rmname[0]); sprintf(fname,"%s/%s.B", USERROOMS,rmname); } else sprintf(fname,"%s/%s.B", ROOMFILES, rm->name); if (!(fp=fopen(fname,"r"))) { write_user(user,"There was an error trying to read message board.\n"); write_syslog(ERRLOG,1,"Unable to open message board for %s in check_board_wipe().\n",rm->name); return 0; } valid=1; cnt=1; yes=0; id[0]='\0'; w1[0]='\0'; w2[0]='\0'; fgets(line,ARR_SIZE-1,fp); while(!feof(fp)) { if (*line=='\n') valid=1; sscanf(line,"%s %d",id,&pt); if (valid && !strcmp(id,"PT:")) { line2[0]='\0'; strcpy(line2,remove_first(remove_first(line))); sscanf(line2,"%s %s",w1,w2); if (msg_number==cnt) { /* lower case the name incase of recapping */ strtolower(w2); w2[0]=toupper(w2[0]); if (!strcmp(w2,user->name)) { yes=1; goto SKIP; /* found result, no need to go through rest of file */ } } valid=0; cnt++; if (cnt>msg_number) goto SKIP; /* no point carrying on if checked already */ } fgets(line,ARR_SIZE-1,fp); } SKIP: fclose(fp); if (!yes) { write_user(user,"You did not post that message. Use ~FTbfrom~RS to check the number again.\n"); return 0; } user->wipe_from=msg_number; user->wipe_to=msg_number; return 1; }
/* Allows a user to read a specific message number */ void read_board_specific(UR_OBJECT user, RM_OBJECT rm, int msg_number) { FILE *fp; int valid,cnt,pt; char id[ARR_SIZE],line[ARR_SIZE],fname[FNAME_LEN],*name,rmname[ROOM_NAME_LEN+1]; set_crash(); if (!rm->mesg_cnt) { vwrite_user(user, read_no_messages, rm->name); return; } if (!msg_number) { write_usage(user,"read [<room>] [<message #>]"); return; } if (msg_number>rm->mesg_cnt) { vwrite_user(user,"There %s only %d message%s posted on the %s board.\n",PLTEXT_IS(rm->mesg_cnt),rm->mesg_cnt,PLTEXT_S(rm->mesg_cnt),rm->name); return; } if (rm!=user->room && !has_room_access(user,rm)) { write_user(user,"That room is currently private, you cannot read the board.\n"); return; } if (rm->access==PERSONAL_LOCKED || rm->access==PERSONAL_UNLOCKED) { midcpy(rm->name,rmname,1,strlen(rm->name)-2); rmname[0]=toupper(rmname[0]); sprintf(fname,"%s/%s.B", USERROOMS,rmname); } else sprintf(fname,"%s/%s.B", ROOMFILES, rm->name); if (!(fp=fopen(fname,"r"))) { write_user(user,"There was an error trying to read the message board.\n"); write_syslog(ERRLOG,1,"Unable to open message board for %s in read_board_specific().\n",rm->name); return; } vwrite_user(user, message_board_header, rm->name); valid=1; cnt=1; id[0]='\0'; fgets(line,ARR_SIZE-1,fp); while (!feof(fp)) { if (*line=='\n') valid=1; sscanf(line,"%s %d",id,&pt); if (valid && !strcmp(id,"PT:")) { if (msg_number==cnt) { while(*line!='\n') { write_user(user,line); fgets(line,ARR_SIZE-1,fp); } } valid=0; cnt++; if (cnt>msg_number) goto SKIP; /* no point carrying on if read already */ } fgets(line,ARR_SIZE-1,fp); } SKIP: fclose(fp); vwrite_user(user,"\nMessage number ~FM~OL%d~RS out of ~FM~OL%d~RS.\n\n",msg_number,rm->mesg_cnt); if (user->vis) name=user->recap; else name=invisname; if (rm==user->room) if (user->level<GOD || user->vis) vwrite_room_except(user->room,user,"%s~RS reads the message board.\n",name); }
/*** Wipe some messages off the board ***/ void wipe_board(UR_OBJECT user) { int cnt; char fname[FNAME_LEN],*name,rmname[ROOM_NAME_LEN+1]; RM_OBJECT rm=user->room; set_crash(); if (word_count<2 && ((user->level>=WIZ && !is_personal_room(rm)) || (is_personal_room(rm) && (is_my_room(user,rm) || user->level>=GOD)))) { write_usage(user,"wipe all"); write_usage(user,"wipe <#>"); write_usage(user,"wipe to <#>"); write_usage(user,"wipe from <#> to <#>"); return; } else if (word_count<2 && ((user->level<WIZ && !is_personal_room(rm)) || (is_personal_room(rm) && !is_my_room(user,rm) && user->level<GOD ) ) ) { write_usage(user,"wipe <#>"); return; } switch (is_personal_room(rm)) { case 0: if (user->level<WIZ && !(check_board_wipe(user))) return; else if (get_wipe_parameters(user)==-1) return; break; case 1: if (!is_my_room(user,rm) && user->level<GOD && !check_board_wipe(user)) return; else if (get_wipe_parameters(user)==-1) return; break; } if (user->vis) name=user->recap; else name=invisname; if (rm->access==PERSONAL_LOCKED || rm->access==PERSONAL_UNLOCKED) { midcpy(rm->name,rmname,1,strlen(rm->name)-2); rmname[0]=toupper(rmname[0]); sprintf(fname,"%s/%s.B", USERROOMS, rmname); } else sprintf(fname,"%s/%s.B", ROOMFILES, rm->name); if (!rm->mesg_cnt) { write_user(user, wipe_empty_board); return; } if (user->wipe_from==-1) { unlink(fname); write_user(user, wipe_user_all_deleted); if (user->level<GOD || user->vis) vwrite_room_except(rm, user, wipe_room_all_deleted, name); write_syslog(SYSLOG,1,"%s wiped all messages from the board in the %s.\n",user->name,rm->name); rm->mesg_cnt=0; return; } if (user->wipe_from>rm->mesg_cnt) { vwrite_user(user,"There %s only %d message%s on the board.\n",PLTEXT_IS(rm->mesg_cnt),rm->mesg_cnt,PLTEXT_S(rm->mesg_cnt)); return; } cnt=wipe_messages(fname,user->wipe_from,user->wipe_to,0); if (cnt==rm->mesg_cnt) { unlink(fname); vwrite_user(user, wipe_too_many, rm->mesg_cnt, grm_num(8, rm->mesg_cnt)); if (user->level<GOD || user->vis) vwrite_room_except(rm,user,"%s maze nastenku.\n",name); write_syslog(SYSLOG,1,"%s wiped all messages from the board in the %s.\n",user->name,rm->name); rm->mesg_cnt=0; return; } rm->mesg_cnt-=cnt; vwrite_user(user, wipe_user_delete_range, cnt, grm_num(8, cnt), grm_num(9, cnt)); if (user->level<GOD || user->vis) vwrite_room_except(rm,user,"%s wipes some messages from the board.\n",name); write_syslog(SYSLOG,1,"%s wiped %d message%s from the board in the %s.\n",user->name,cnt,PLTEXT_S(cnt),rm->name); }
/* * Show talker rooms */ void rooms(UR_OBJECT user, int show_topics, int wrap) { RM_OBJECT rm; UR_OBJECT u; #ifdef NETLINKS NL_OBJECT nl; char serv[SERV_NAME_LEN + 1], nstat[9]; char rmaccess[9]; #endif int cnt, rm_cnt, rm_pub, rm_priv; if (word_count < 2) { if (!wrap) { user->wrap_room = room_first; } if (show_topics) { write_user(user, "\n+----------------------------------------------------------------------------+\n"); write_user(user, "~FC~OLpl u/m~RS | ~OL~FCname~RS - ~FC~OLtopic\n"); write_user(user, "+----------------------------------------------------------------------------+\n"); } else { write_user(user, "\n+----------------------------------------------------------------------------+\n"); write_user(user, "~FC~OLRoom name ~RS|~FC~OL Access Users Mesgs Inlink LStat Service\n"); write_user(user, "+----------------------------------------------------------------------------+\n"); } rm_cnt = 0; for (rm = user->wrap_room; rm; rm = rm->next) { if (is_personal_room(rm)) { continue; } if (rm_cnt == user->pager - 4) { switch (show_topics) { case 0: user->misc_op = 10; break; case 1: user->misc_op = 11; break; } write_user(user, "~BB~FG-=[*]=- PRESS <RETURN>, E TO EXIT:~RS "); return; } cnt = 0; for (u = user_first; u; u = u->next) if (u->type != CLONE_TYPE && u->room == rm) { ++cnt; } if (show_topics) { vwrite_user(user, "%c%c %2d/%-2d | %s%-20.20s~RS - %s\n", is_private_room(rm) ? 'P' : ' ', is_fixed_room(rm) ? '*' : ' ', cnt, rm->mesg_cnt, is_private_room(rm) ? "~FR~OL" : "", rm->name, rm->topic); } #ifdef NETLINKS else { if (is_private_room(rm)) { strcpy(rmaccess, " ~FRPRIV"); } else { strcpy(rmaccess, " ~FGPUB "); } if (is_fixed_room(rm)) { *rmaccess = '*'; } nl = rm->netlink; *serv = '\0'; if (!nl) { if (rm->inlink) { strcpy(nstat, " ~FRDOWN"); } else { strcpy(nstat, " -"); } } else { if (nl->type == UNCONNECTED) { strcpy(nstat, " ~FRDOWN"); } else if (nl->stage == UP) { strcpy(nstat, " ~FGUP"); } else { strcpy(nstat, " ~FYVER"); } } if (nl) { strcpy(serv, nl->service); } vwrite_user(user, "%-20s | %9s~RS %5d %5d %-6s %s~RS %s\n", rm->name, rmaccess, cnt, rm->mesg_cnt, noyes[rm->inlink], nstat, serv); } #endif ++rm_cnt; user->wrap_room = rm->next; } user->misc_op = 0; rm_pub = rm_priv = 0; for (rm = room_first; rm; rm = rm->next) { if (is_personal_room(rm)) { continue; } if (is_private_room(rm)) { ++rm_priv; } else { ++rm_pub; } } write_user(user, "+----------------------------------------------------------------------------+\n"); vwrite_user(user, "There is a total of ~OL%d~RS rooms. ~OL%d~RS %s public, and ~OL%d~RS %s private.\n", rm_priv + rm_pub, rm_pub, PLTEXT_IS(rm_pub), rm_priv, PLTEXT_IS(rm_priv)); write_user(user, "+----------------------------------------------------------------------------+\n\n"); return; } if (!strcasecmp(word[1], "-l")) { write_user(user, "The following rooms are default...\n\n"); vwrite_user(user, "Default main room : ~OL%s~RS\n", room_first->name); vwrite_user(user, "Default warp room : ~OL%s~RS\n", *amsys->default_warp ? amsys->default_warp : "<none>"); vwrite_user(user, "Default jail room : ~OL%s~RS\n", *amsys->default_jail ? amsys->default_jail : "<none>"); #ifdef GAMES vwrite_user(user, "Default bank room : ~OL%s~RS\n", *amsys->default_bank ? amsys->default_bank : "<none>"); vwrite_user(user, "Default shoot room : ~OL%s~RS\n", *amsys->default_shoot ? amsys->default_shoot : "<none>"); #endif if (!priv_room[0].name) { write_user(user, "\nThere are no level specific rooms currently availiable.\n\n"); return; } write_user(user, "\nThe following rooms are level specific...\n\n"); for (cnt = 0; priv_room[cnt].name; ++cnt) { vwrite_user(user, "~FC%s~RS is for users of level ~OL%s~RS and above.\n", priv_room[cnt].name, user_level[priv_room[cnt].level].name); } vwrite_user(user, "\nThere is a total of ~OL%d~RS level specific rooms.\n\n", cnt); return; } write_user(user, "Usage: rooms [-l]\n"); }