X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=cmd_neonserv_deluser.c;h=b6ff2830039d0c1ed42cdc3e52454280c1c4172c;hb=795115bf680185ae01043bd1222b78bfed8c1d87;hp=b98e7f32dc2b8bca25c10d2eb72eb76aedcae1d5;hpb=95b8a45a27830cd378e415c675e3838eb88d769b;p=NeonServV5.git diff --git a/cmd_neonserv_deluser.c b/cmd_neonserv_deluser.c index b98e7f3..b6ff283 100644 --- a/cmd_neonserv_deluser.c +++ b/cmd_neonserv_deluser.c @@ -1,45 +1,25 @@ +#include "cmd_neonserv.h" + /* * argv[0] - nick / *auth */ -static AUTHLOOKUP_CALLBACK(neonserv_cmd_deluser_auth_lookup); static USERAUTH_CALLBACK(neonserv_cmd_deluser_nick_lookup); -static void neonserv_cmd_deluser_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, char *nick, char *auth); +static void neonserv_cmd_deluser_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, char *nick, char *auth); struct neonserv_cmd_deluser_cache { struct ClientSocket *client, *textclient; struct UserNode *user; struct ChanNode *chan; + struct Event *event; char *nick; }; -static CMD_BIND(neonserv_cmd_deluser) { - int caccess; - MYSQL_RES *res; - MYSQL_ROW row; - check_mysql(); +CMD_BIND(neonserv_cmd_deluser) { if(argv[0][0] == '*') { //we've got an auth argv[0]++; - printf_mysql_query("SELECT `user_user` FROM `users` WHERE `user_user` = '%s'", escape_string(argv[0])); - res = mysql_use(); - if ((row = mysql_fetch_row(res)) != NULL) { - neonserv_cmd_deluser_async1(client, getTextBot(), user, chan, argv[0], row[0]); - } else { - //we need to create a new user... - //but first lookup the auth to check if it really exists - struct neonserv_cmd_deluser_cache *cache = malloc(sizeof(*cache)); - if (!cache) { - perror("malloc() failed"); - return; - } - cache->client = client; - cache->textclient = getTextBot(); - cache->user = user; - cache->chan = chan; - cache->nick = strdup(argv[0]); - lookup_authname(argv[0], neonserv_cmd_deluser_auth_lookup, cache); - } + neonserv_cmd_deluser_async1(client, getTextBot(), user, chan, event, argv[0], argv[0]); } else { struct UserNode *cuser = getUserByNick(argv[0]); if(!cuser) { @@ -47,7 +27,7 @@ static CMD_BIND(neonserv_cmd_deluser) { cuser->flags |= USERFLAG_ISTMPUSER; } if(cuser->flags & USERFLAG_ISAUTHED) { - neonserv_cmd_deluser_async1(client, getTextBot(), user, chan, argv[0], cuser->auth); + neonserv_cmd_deluser_async1(client, getTextBot(), user, chan, event, argv[0], cuser->auth); } else { struct neonserv_cmd_deluser_cache *cache = malloc(sizeof(*cache)); if (!cache) { @@ -58,23 +38,13 @@ static CMD_BIND(neonserv_cmd_deluser) { cache->textclient = getTextBot(); cache->user = user; cache->chan = chan; + cache->event = event; cache->nick = strdup(argv[0]); get_userauth(cuser, neonserv_cmd_deluser_nick_lookup, cache); } } } -static AUTHLOOKUP_CALLBACK(neonserv_cmd_deluser_auth_lookup) { - struct neonserv_cmd_deluser_cache *cache = data; - if(!exists) { - //AUTH_DOES_NOT_EXIST - reply(cache->textclient, cache->user, "NS_AUTH_UNKNOWN", cache->nick); - } else - neonserv_cmd_deluser_async1(cache->client, cache->textclient, cache->user, cache->chan, cache->nick, auth); - free(cache->nick); - free(cache); -} - static USERAUTH_CALLBACK(neonserv_cmd_deluser_nick_lookup) { struct neonserv_cmd_deluser_cache *cache = data; if(!user) { @@ -86,12 +56,12 @@ static USERAUTH_CALLBACK(neonserv_cmd_deluser_nick_lookup) { reply(cache->textclient, cache->user, "NS_USER_NEED_AUTH", cache->nick); } else - neonserv_cmd_deluser_async1(cache->client, cache->textclient, cache->user, cache->chan, user->nick, user->auth); + neonserv_cmd_deluser_async1(cache->client, cache->textclient, cache->user, cache->chan, cache->event, user->nick, user->auth); free(cache->nick); free(cache); } -static void neonserv_cmd_deluser_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, char *nick, char *auth) { +static void neonserv_cmd_deluser_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, char *nick, char *auth) { //we've got a valid auth now... MYSQL_RES *res; MYSQL_ROW row; @@ -104,9 +74,18 @@ static void neonserv_cmd_deluser_async1(struct ClientSocket *client, struct Clie printf_mysql_query("SELECT `chanuser_access`, `chanuser_id` FROM `chanusers` WHERE `chanuser_cid` = '%d' AND `chanuser_uid` = '%d'", chan->channel_id, userid); res = mysql_use(); if ((row = mysql_fetch_row(res)) != NULL) { + if(atoi(row[0]) >= getChannelAccess(user, chan, 0)) { + if(isGodMode(user)) { + event->flags |= CMDFLAG_OPLOG; + } else { + reply(textclient, user, "NS_USER_OUTRANKED", nick); + return; + } + } //delete printf_mysql_query("DELETE FROM `chanusers` WHERE `chanuser_id` = '%s'", row[1]); reply(textclient, user, "NS_DELUSER_DONE", nick, atoi(row[0]), chan->name); + logEvent(event); return; } }