X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2Fmodules%2FNeonServ.mod%2Fevent_neonserv_join.c;h=5f77f4259d13db411edf02171f7581243916e61d;hb=139ae91def764e66b5d2024723700101cc2a379e;hp=77d5de7519a200df297dbe939b3b691b405e8c03;hpb=706e48b1e666054030c491d864f740071e390038;p=NeonServV5.git diff --git a/src/modules/NeonServ.mod/event_neonserv_join.c b/src/modules/NeonServ.mod/event_neonserv_join.c index 77d5de7..5f77f42 100644 --- a/src/modules/NeonServ.mod/event_neonserv_join.c +++ b/src/modules/NeonServ.mod/event_neonserv_join.c @@ -1,4 +1,4 @@ -/* event_neonserv_join.c - NeonServ v5.3 +/* event_neonserv_join.c - NeonServ v5.6 * Copyright (C) 2011-2012 Philipp Kreil (pk910) * * This program is free software: you can redistribute it and/or modify @@ -18,11 +18,10 @@ struct neonserv_event_join_cache { struct ClientSocket *client; struct ChanUser *chanuser; - int was_registering; }; static USERAUTH_CALLBACK(neonserv_event_join_nick_lookup); -static void neonserv_event_join_async1(struct ClientSocket *client, struct ChanUser *chanuser, int was_registering); +static void neonserv_event_join_async1(struct ClientSocket *client, struct ChanUser *chanuser); static TIMEQ_CALLBACK(neonserv_event_join_dynlimit); static void neonserv_event_join(struct ChanUser *chanuser) { @@ -31,6 +30,7 @@ static void neonserv_event_join(struct ChanUser *chanuser) { if(!client) return; //we can't "see" this event if(chanuser->user == client->user) { requestOp(client->user, chanuser->chan); + module_neonbackup_recover_chan(chanuser->chan); return; } if(chanuser->user->flags & USERFLAG_ISBOT) return; @@ -53,32 +53,30 @@ static void neonserv_event_join(struct ChanUser *chanuser) { if(!(user->flags & USERFLAG_ISAUTHED)) { struct neonserv_event_join_cache *cache = malloc(sizeof(*cache)); if (!cache) { - perror("malloc() failed"); + printf_log("neonserv", LOG_ERROR, "%s:%d malloc() failed", __FILE__, __LINE__); return; } cache->client = client; cache->chanuser = chanuser; - cache->was_registering = (user->flags & USERFLAG_WAS_REGISTRING); - get_userauth(user, neonserv_event_join_nick_lookup, cache); + get_userauth(user, module_id, neonserv_event_join_nick_lookup, cache); } else - neonserv_event_join_async1(client, chanuser, (user->flags & USERFLAG_WAS_REGISTRING)); + neonserv_event_join_async1(client, chanuser); } static USERAUTH_CALLBACK(neonserv_event_join_nick_lookup) { struct neonserv_event_join_cache *cache = data; - if(user) { - neonserv_event_join_async1(cache->client, cache->chanuser, cache->was_registering); - } + if(user) + neonserv_event_join_async1(cache->client, cache->chanuser); free(cache); } -static void neonserv_event_join_async1(struct ClientSocket *client, struct ChanUser *chanuser, int was_registering) { +static void neonserv_event_join_async1(struct ClientSocket *client, struct ChanUser *chanuser) { struct ClientSocket *textclient = ((client->flags & SOCKET_FLAG_PREFERRED) ? client : get_prefered_bot(client->botid)); struct ChanNode *chan = chanuser->chan; struct UserNode *user = chanuser->user; struct ModeBuffer *modeBuf; int with_halfops = get_int_field("General.have_halfop"); - MYSQL_RES *res; + MYSQL_RES *res, *res2; MYSQL_ROW row, chanuserrow, defaultrow = NULL; printf_mysql_query("SELECT `channel_maxusers`, `channel_greeting`, `channel_usergreeting`, `channel_getop`, `channel_getvoice`, `channel_userinfo`, `channel_dynlimit`, `channel_gethalfop` FROM `channels` WHERE `channel_id` = '%d'", chan->channel_id); res = mysql_use(); @@ -139,7 +137,7 @@ static void neonserv_event_join_async1(struct ClientSocket *client, struct ChanU if(a) b = a+2; } while(a); - if(greetingPos && (!was_registering || *row[2])) + if(greetingPos && *row[2]) reply(textclient, user, "[%s] %s", chan->name, greeting); //USER RIGHTS if(!(userflags & DB_CHANUSER_NOAUTOOP)) { @@ -173,7 +171,7 @@ static void neonserv_event_join_async1(struct ClientSocket *client, struct ChanU sprintf(nameBuf, "dynlimit_%s", chan->name); if(!timeq_name_exists(nameBuf)) { //neonserv_event_join_dynlimit - timeq_add_name(nameBuf, 30, neonserv_event_join_dynlimit, strdup(chan->name)); + timeq_add_name(nameBuf, 30, module_id, neonserv_event_join_dynlimit, strdup(chan->name)); } } //AUTOINVITE @@ -221,8 +219,8 @@ static void neonserv_event_join_async1(struct ClientSocket *client, struct ChanU } if(chanuserrow[3] == NULL && defaultrow == NULL) { printf_mysql_query("SELECT `channel_getinvite` FROM `channels` WHERE `channel_name` = 'defaults'"); - res = mysql_use(); - defaultrow = mysql_fetch_row(res); + res2 = mysql_use(); + defaultrow = mysql_fetch_row(res2); } getinvite = atoi((chanuserrow[3] ? chanuserrow[3] : defaultrow[0])); if(atoi(chanuserrow[0]) >= getinvite) { @@ -237,6 +235,7 @@ static TIMEQ_CALLBACK(neonserv_event_join_dynlimit) { char *chanName = data; struct ChanNode *chan = getChanByName(chanName); free(chanName); + if(!chan) return; struct ClientSocket *client = getBotForChannel(chan); if(!client) return; loadChannelSettings(chan);