static void m_help(struct Luser *lptr, struct NickInfo *nptr, int ac, char **av) { if (ac >= 2) { char str[MAXLINE]; struct Command *cptr; for (cptr = memocmds; cptr->cmd; cptr++) if (!irccmp(av[1], cptr->cmd)) break; if (cptr->cmd) if ((cptr->level == LVL_ADMIN) && !(IsValidAdmin(lptr))) { notice(n_MemoServ, lptr->nick, "No help available on \002%s\002", av[1]); return; } ircsprintf(str, "%s", av[1]); GiveHelp(n_MemoServ, lptr->nick, str, NODCC); } else GiveHelp(n_MemoServ, lptr->nick, NULL, NODCC); } /* m_help() */
/* * es_help() * * Give lptr help on command av[1] */ static void es_help(struct Luser *lptr, int ac, char **av) { if (ac >= 2) { char str[MAXLINE]; struct Command *sptr; for (sptr = seencmds; sptr->cmd; sptr++) if (!irccmp(av[1], sptr->cmd)) break; if (sptr->cmd) if ((sptr->level == LVL_ADMIN) && !(IsValidAdmin(lptr))) { notice(n_SeenServ, lptr->nick, "No help available on \002%s\002", av[1]); return ; } ircsprintf(str, "%s", av[1]); GiveHelp(n_SeenServ, lptr->nick, str, NODCC); } else GiveHelp(n_SeenServ, lptr->nick, NULL, NODCC); } /* es_help() */
void ss_process(char *nick, char *command) { int acnt; char **arv; struct Command *sptr; struct Luser *lptr; if (!command || !(lptr = FindClient(nick))) return; if (Network->flags & NET_OFF) { notice(n_StatServ, lptr->nick, "Services are currently \002disabled\002"); return; } acnt = SplitBuf(command, &arv); if (acnt == 0) { MyFree(arv); return; } sptr = GetCommand(statcmds, arv[0]); if (!sptr || (sptr == (struct Command *) -1)) { notice(n_StatServ, lptr->nick, "%s command [%s]", (sptr == (struct Command *) -1) ? "Ambiguous" : "Unknown", arv[0]); MyFree(arv); return; } /* * Check if the command is for admins only - if so, * check if they match an admin O: line. If they do, * check if they are registered with OperServ, * if so, allow the command */ if ((sptr->level == LVL_ADMIN) && !(IsValidAdmin(lptr))) { notice(n_StatServ, lptr->nick, "Unknown command [%s]", arv[0]); MyFree(arv); return; } /* call sptr->func to execute command */ (*sptr->func)(lptr, acnt, arv); MyFree(arv); return; } /* ss_process() */
/* * Show services adminstrators. Code from IrcBg, slightly modified. -kre */ static void ss_showadmins(struct Luser *lptr, int ac, char **av) { int iCnt = 0; struct Luser *tempuser; RecordCommand("%s: %s!%s@%s SHOWADMINS", n_StatServ, lptr->nick, lptr->username, lptr->hostname); notice(n_StatServ, lptr->nick, "Currently online services admins"); notice(n_StatServ, lptr->nick, "--------------------------------"); for (tempuser = ClientList; tempuser; tempuser = tempuser->next) { if (IsValidAdmin(tempuser)) notice(n_StatServ, lptr->nick , "[%d] %s", ++iCnt,tempuser->nick ); } notice(n_StatServ, lptr->nick, "--------------------------------"); notice(n_StatServ, lptr->nick, " %d admins online.", iCnt); }
void ms_process(char *nick, char *command) { int acnt; char **arv; struct Command *mptr; struct Luser *lptr; struct NickInfo *nptr, *master; if (!command || !(lptr = FindClient(nick))) return; if (Network->flags & NET_OFF) { notice(n_MemoServ, lptr->nick, "Services are currently \002disabled\002"); return; } acnt = SplitBuf(command, &arv); if (acnt == 0) { MyFree(arv); return; } mptr = GetCommand(memocmds, arv[0]); if (!mptr || (mptr == (struct Command *) -1)) { notice(n_MemoServ, lptr->nick, "%s command [%s]", (mptr == (struct Command *) -1) ? "Ambiguous" : "Unknown", arv[0]); MyFree(arv); return; } /* * Check if the command is for admins only - if so, * check if they match an admin O: line. If they do, * check if they are EITHER oper'd, or registered with OperServ, * if either of these is true, allow the command */ if ((mptr->level == LVL_ADMIN) && !(IsValidAdmin(lptr))) { notice(n_MemoServ, lptr->nick, "Unknown command [%s]", arv[0]); MyFree(arv); return; } nptr = FindNick(lptr->nick); master = GetMaster(nptr); if (!nptr && !master && (mptr->level != LVL_NONE)) { /* the command requires a registered nickname */ notice(n_MemoServ, lptr->nick, "Your nickname is not registered"); notice(n_MemoServ, lptr->nick, ERR_MORE_INFO, n_NickServ, "REGISTER"); MyFree(arv); return; } if (nptr) { if (nptr->flags & NS_FORBID) { notice(n_MemoServ, lptr->nick, "Cannot execute commands for forbidden nicknames"); MyFree(arv); return; } if (mptr->level != LVL_NONE) { if (!(nptr->flags & NS_IDENTIFIED)) { notice(n_MemoServ, lptr->nick, "Password identification is required for [\002%s\002]", mptr->cmd); notice(n_MemoServ, lptr->nick, "Type \002/msg %s IDENTIFY <password>\002 and retry", n_NickServ); MyFree(arv); return; } } } /* if (nptr) */ /* call mptr->func to execute command */ (*mptr->func)(lptr, master, acnt, arv); MyFree(arv); return; } /* ms_process() */
/* * es_seen() * * Give lptr seen info on av[1] wild matches (nick + userhost) * * XXX: THIS FUNCTION IS UTTER CRAP */ static void es_seen(struct Luser *lptr, int ac, char **av) { int i, count; aSeen *seen, *first = NULL, *saved = NULL, *sorted[5]; char nuhost[NICKLEN + USERLEN + HOSTLEN + 3], sendstr[256]; if (ac < 2) { notice(n_SeenServ, lptr->nick, "Syntax: SEEN <nick|hostmask>"); notice(n_SeenServ, lptr->nick, ERR_MORE_INFO, n_SeenServ, "SEEN"); return ; } if (strchr(av[1], '*') || strchr(av[1], '?')) { /* This stuff violates privacy like hell, restrict! -- jilles */ if (!IsValidAdmin(lptr)) { notice(n_SeenServ, lptr->nick, "Wildcard SEEN is restricted to admins."); return; } count = 0; for (seen = seenp; seen; seen = seen->prev) { memset(nuhost, 0, sizeof(nuhost)); strncpy(nuhost, seen->nick, NICKLEN); strcat(nuhost, "!"); strncat(nuhost, seen->userhost, USERLEN + HOSTLEN + 1); if (match(av[1], nuhost)) { seen->seen = saved; saved = seen; if (++count > MAXWILDSEEN) break; } } first = saved; if (count > MAXWILDSEEN) { notice(n_SeenServ, lptr->nick, "I found more than %d matches to your query; " "please refine it to see any output", MAXWILDSEEN); return ; } else if (count == 0) { notice(n_SeenServ, lptr->nick, "I found no matching seen records to your query"); return ; } else { for (i = 0; (i < 5) && (i < count); i++) { aSeen **pcandidate = &first; aSeen *tmp; /* pcandidate is the next candidate for the last * element. We iterate the list looking for a better * candidate (ie, a later element) */ /* We look to see if the *next* item is a candidate, * and if it is, we store the value of *our* pointer * to it. That lets us splice out the candidate at * the end. */ for (tmp = *pcandidate; tmp->seen; tmp = tmp->seen) { if (tmp->seen->time > (*pcandidate)->time) { pcandidate = &tmp->seen; } } sorted[i] = *pcandidate; /* Splice that element out of the list */ *pcandidate = (*pcandidate)->seen; } } ircsprintf(sendstr, "I found %d match(es), ", count); if (count > 5) strcat(sendstr, "here are the 5 most recent, "); strcat(sendstr, "sorted:"); count = i; for (i = 0; i < count; i++) { strcat(sendstr, " "); strcat(sendstr, sorted[i]->nick); } strcat(sendstr, ". "); if (sorted[0]->type == 1) { notice(n_SeenServ, lptr->nick, "%s %s (%s) was last seen %s ago, quiting: %s", sendstr, sorted[0]->nick, sorted[0]->userhost, timeago(sorted[0]->time, 0), sorted[0]->msg); } else if (sorted[0]->type == 2) { notice(n_SeenServ, lptr->nick, "%s %s (%s) was last seen %s ago, changing nicks", sendstr, sorted[0]->nick, sorted[0]->userhost, timeago(sorted[0]->time, 0)); } } else { es_seennick(lptr, ac, av); } } /* es_seen */