⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 m_svsmode.c

📁 Unreal irc 服务器源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
			}			break;			case 'e': {				Extban *extban;				Ban *ban, *bnext;				if (parc >= i) {					if (!(acptr = find_person(parv[i-1], NULL))) {						i++;						break;					}					if (ts && ts != acptr->since) {						i++;						break;					}					i++;					unban_user(sptr, chptr, acptr, 'e');				}				else {					clear_bans(sptr, chptr, 'e');				}			}			break;			case 'I': {				Ban *ban, *bnext;				if (parc >= i) {					if (!(acptr = find_person(parv[i-1], NULL))) {						i++;						break;					}					if (ts && ts != acptr->since) {						i++;						break;					}					i++;					unban_user(sptr, chptr, acptr, 'I');				}				else {					clear_bans(sptr, chptr, 'I');				}			}			break;		}	}	if (*parabuf) {		sendto_channel_butserv(chptr, sptr, ":%s MODE %s %s %s", sptr->name, chptr->chname, 			modebuf, parabuf);		sendto_serv_butone(NULL, ":%s MODE %s %s %s", sptr->name, chptr->chname, modebuf, parabuf);		*parabuf = 0;	}	return 0;}/* * do_svsmode() [merge from svsmode/svs2mode] * parv[0] - sender * parv[1] - username to change mode for * parv[2] - modes to change * parv[3] - Service Stamp (if mode == d) * * show_change can be 0 (for svsmode) or 1 (for svs2mode). */int  do_svsmode(aClient *cptr, aClient *sptr, int parc, char *parv[], int show_change){int i;char *m;aClient *acptr;int  what, setflags;char *xmsg = show_change ? MSG_SVS2MODE : MSG_SVSMODE;char *xtok = show_change ? TOK_SVS2MODE : TOK_SVSMODE;	if (!IsULine(sptr))		return 0;	what = MODE_ADD;	if (parc < 3)		return 0;	if (parv[1][0] == '#') 		return channel_svsmode(cptr, sptr, parc, parv);	if (!(acptr = find_person(parv[1], NULL)))		return 0;	setflags = 0;	if (show_change) /* only used if show_change is set */	{		for (i = 0; i <= Usermode_highest; i++)		if (Usermode_Table[i].flag && (acptr->umodes & Usermode_Table[i].mode))			setflags |= Usermode_Table[i].mode;	}	/* parse mode change string(s) */	for (m = parv[2]; *m; m++)		switch (*m)		{			case '+':				what = MODE_ADD;				break;			case '-':				what = MODE_DEL;				break;			/* we may not get these, but they shouldnt be in default */			case ' ':			case '\n':			case '\r':			case '\t':				break;			case 'i':				if ((what == MODE_ADD) && !(acptr->umodes & UMODE_INVISIBLE))					IRCstats.invisible++;				if ((what == MODE_DEL) && (acptr->umodes & UMODE_INVISIBLE))					IRCstats.invisible--;				goto setmodex;			case 'O': /* Locops are opers too! */				if (what == MODE_ADD)				{#ifndef NO_FDLIST					if (!IsAnOper(acptr) && MyClient(acptr))						addto_fdlist(acptr->slot, &oper_fdlist);#endif					acptr->umodes &= ~UMODE_OPER;				}#ifndef NO_FDLIST				if (what == MODE_DEL && (acptr->umodes & UMODE_LOCOP) && MyClient(acptr))					delfrom_fdlist(acptr->slot, &oper_fdlist);#endif				goto setmodex;								case 'o':				if ((what == MODE_ADD) && !(acptr->umodes & UMODE_OPER))				{#ifndef NO_FDLIST					if (MyClient(acptr) && !IsLocOp(acptr))						addto_fdlist(acptr->slot, &oper_fdlist);#endif					acptr->umodes &= ~UMODE_LOCOP; /* can't be both local and global */					IRCstats.operators++;				}				if ((what == MODE_DEL) && (acptr->umodes & UMODE_OPER))				{					if (acptr->umodes & UMODE_HIDEOPER)					{						/* clear 'H' too, and opercount stays the same.. */						acptr->umodes &= ~UMODE_HIDEOPER;					} else {						IRCstats.operators--;					}#ifndef NO_FDLIST					if (MyClient(acptr))						delfrom_fdlist(acptr->slot, &oper_fdlist);#endif				}				goto setmodex;			case 'H':				if (what == MODE_ADD && !(acptr->umodes & UMODE_HIDEOPER))				{					if (!IsAnOper(acptr) && !strchr(parv[2], 'o')) /* (ofcoz this strchr() is flawed) */					{						/* isn't an oper, and would not become one either.. abort! */						sendto_realops(							"[BUG] server %s tried to set +H while user not an oper, para=%s/%s, "							"umodes=%ld, please fix your services or if you think it's our fault, "							"report at http://bugs.unrealircd.org/", sptr->name, parv[1], parv[2], acptr->umodes);						break; /* abort! */					}					if (!IsLocOp(acptr))						IRCstats.operators--;				}				if (what == MODE_DEL && (acptr->umodes & UMODE_HIDEOPER) && !IsLocOp(acptr))					IRCstats.operators++;				goto setmodex;			case 'd':				if (parv[3] && isdigit(*parv[3]))				{					acptr->user->servicestamp = strtoul(parv[3], NULL, 10);					break;				}			case 'x':				if (what == MODE_DEL)				{					/* -x */					if (acptr->user->virthost)					{						/* Removing mode +x and virthost set... recalculate host then (but don't activate it!) */						MyFree(acptr->user->virthost);						acptr->user->virthost = strdup(acptr->user->cloakedhost);					}				} else				{					/* +x */					if (!acptr->user->virthost)					{						/* Hmm... +x but no virthost set, that's bad... use cloakedhost.						 * Not sure if this could ever happen, but just in case... -- Syzop						 */						acptr->user->virthost = strdup(acptr->user->cloakedhost);					}					/* Announce the new host to VHP servers if we're setting the virthost to the cloakedhost.					 * In other cases, we can assume that the host has been broadcasted already (after all,					 * how else could it have been changed...?).					 * NOTES: we're doing a strcasecmp here instead of simply checking if it's a "+x but					 * not -t"-case. The reason for this is that the 't' might follow ("+xt" instead of "+tx"),					 * in which case we would have needlessly announced it. Ok I didn't test it but that's					 * the idea behind it :P. -- Syzop					 */					if (MyClient(acptr) && !strcasecmp(acptr->user->virthost, acptr->user->cloakedhost))						sendto_serv_butone_token_opt(NULL, OPT_VHP, acptr->name,							MSG_SETHOST, TOK_SETHOST, "%s", acptr->user->virthost);				}			default:				setmodex:				for (i = 0; i <= Usermode_highest; i++)				{					if (!Usermode_Table[i].flag)						continue;					if (*m == Usermode_Table[i].flag)					{						if (what == MODE_ADD)							acptr->umodes |= Usermode_Table[i].mode;						else							acptr->umodes &= ~Usermode_Table[i].mode;						break;					}				}				break;		} /*switch*/	if (parc > 3)		sendto_serv_butone_token(cptr, parv[0], xmsg, xtok,			"%s %s %s", parv[1], parv[2], parv[3]);	else		sendto_serv_butone_token(cptr, parv[0], xmsg, xtok,			"%s %s", parv[1], parv[2]);	if (show_change)	{		char buf[BUFSIZE];		send_umode(NULL, acptr, setflags, ALL_UMODES, buf);		if (MyClient(acptr) && buf[0] && buf[1])			sendto_one(acptr, ":%s MODE %s :%s", parv[0], parv[1], buf);	}	VERIFY_OPERCOUNT(acptr, "svsmodeX");	return 0;}/* * m_svsmode() added by taz * parv[0] - sender * parv[1] - username to change mode for * parv[2] - modes to change * parv[3] - Service Stamp (if mode == d) */int  m_svsmode(aClient *cptr, aClient *sptr, int parc, char *parv[]){	return do_svsmode(cptr, sptr, parc, parv, 0);}/* * m_svs2mode() added by Potvin * parv[0] - sender * parv[1] - username to change mode for * parv[2] - modes to change * parv[3] - Service Stamp (if mode == d) */int  m_svs2mode(aClient *cptr, aClient *sptr, int parc, char *parv[]){	return do_svsmode(cptr, sptr, parc, parv, 1);}void add_send_mode_param(aChannel *chptr, aClient *from, char what, char mode, char *param) {	static char *modes = NULL, lastwhat;	static short count = 0;	short send = 0;		if (!modes) modes = modebuf;		if (!modebuf[0]) {		modes = modebuf;		*modes++ = what;		*modes = 0;		lastwhat = what;		*parabuf = 0;		count = 0;	}	if (lastwhat != what) {		*modes++ = what;		*modes = 0;		lastwhat = what;	}	if (strlen(parabuf) + strlen(param) + 11 < MODEBUFLEN) {		if (*parabuf) 			strcat(parabuf, " ");		strcat(parabuf, param);		*modes++ = mode;		*modes = 0;		count++;	}	else if (*parabuf) 		send = 1;	if (count == MAXMODEPARAMS)		send = 1;	if (send) {		sendto_channel_butserv(chptr, from, ":%s MODE %s %s %s",			from->name, chptr->chname, modebuf, parabuf);		sendto_serv_butone(NULL, ":%s MODE %s %s %s", from->name, chptr->chname, modebuf, parabuf);		send = 0;		*parabuf = 0;		modes = modebuf;		*modes++ = what;		lastwhat = what;		if (count != MAXMODEPARAMS) {			strcpy(parabuf, param);			*modes++ = mode;			count = 1;		}		else 			count = 0;		*modes = 0;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -