/* * ================================================================= * Filename: m_userip.c * Description: Command /userip - Notifies IRC Operators on IP Query * Author: Raistlin * Version: Unreal3.2 * ================================================================= */ #include "config.h" #include "struct.h" #include "common.h" #include "sys.h" #include "numeric.h" #include "msg.h" #include "channel.h" #include #include #include #include "h.h" /* Prototype definitions */ extern void sendto_one(aClient *to, char *pattern, ...); static int m_userip(aClient *cptr, aClient *sptr, int parc, char *parv[]); static Command *CmdUserip = NULL; ModuleHeader MOD_HEADER(m_userip) = { "userip", "IRCops only", "Command /userip - Author: Raistlin - Notifies IRC Operators on IP Query", "3.2-b8-2", NULL }; DLLFUNC int MOD_INIT(m_userip)(ModuleInfo *modinfo) { CmdUserip = CommandAdd(modinfo->handle, "USERIP", NULL, m_userip, 1, 0); return MOD_SUCCESS; } DLLFUNC int MOD_LOAD(m_userip)(int module_load) { return MOD_SUCCESS; } DLLFUNC int MOD_UNLOAD(m_userip)(int module_unload) { if (CmdUserip) CommandDel(CmdUserip); return MOD_SUCCESS; } static int m_userip(aClient *cptr, aClient *sptr, int parc, char *parv[]) { char *p, *cn, *ip; struct Client *acptr; char response[5][NICKLEN * 2 + CHANNELLEN + USERLEN + HOSTLEN + 30]; int i; if (!IsAnOper(sptr)) { sendto_one(sptr, ":%s 481 %s :Permission Denied - You are not an IRC operator", me.name, sptr->name); return 0; } if (parc < 2) { sendto_one(sptr, ":%s 461 %s USERIP :Not enough parameters", me.name, sptr->name); return 0; } sendto_snomask_global(4, "*** [USERIP] %s is checking IP information for: %s", sptr->name, parv[1]); response[0][0] = response[1][0] = response[2][0] = response[3][0] = response[4][0] = '\0'; cn = parv[1]; for (i = 0; (i < 5) && cn; i++) { if ((p = strchr(cn, ' '))) *p = '\0'; if ((acptr = find_person(cn, NULL))) { ircsprintf(response[i], "%s%s=%c%s@%s", acptr->name, (IsAnOper(acptr) && (!IsHideOper(acptr) || sptr == acptr || IsAnOper(sptr))) ? "*" : "", (acptr->user->away) ? '-' : '+', acptr->user->username, (ip = GetIP(acptr)) ? ((acptr != sptr) && !IsOper(sptr) && IsHidden(acptr)) ? RCallbacks[CALLBACKTYPE_CLOAK]->func.pcharfunc(ip) : ip : ""); } if (p) p++; cn = p; } sendto_one(sptr, ":%s 340 %s :%s %s %s %s %s", me.name, sptr->name, response[0], response[1], response[2], response[3], response[4]); return 0; }