8270e82a9621afff9610c306155c272e6f800836
[NeonServV5.git] / src / event_neonserv_part.c
1 /* event_neonserv_part.c - NeonServ v5.1
2  * Copyright (C) 2011  Philipp Kreil (pk910)
3  * 
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  * 
14  * You should have received a copy of the GNU General Public License 
15  * along with this program. If not, see <http://www.gnu.org/licenses/>. 
16  */
17
18 static void neonserv_event_part(struct ChanUser *chanuser, char *reason) {
19     struct ChanNode *chan = chanuser->chan;
20     struct UserNode *user = chanuser->user;
21     MYSQL_RES *res;
22     MYSQL_ROW chanuserrow;
23     loadChannelSettings(chan);
24     if(!(chan->flags & CHANFLAG_CHAN_REGISTERED)) return;
25     if((user->flags & USERFLAG_ISAUTHED)) {
26         printf_mysql_query("SELECT `chanuser_id` FROM `chanusers` LEFT JOIN `users` ON `chanuser_uid` = `user_id` WHERE `chanuser_cid` = '%d' AND `user_user` = '%s'", chan->channel_id, escape_string(user->auth));
27         res = mysql_use();
28         if((chanuserrow = mysql_fetch_row(res)) != NULL)
29             printf_mysql_query("UPDATE `chanusers` SET `chanuser_seen` = UNIX_TIMESTAMP() WHERE `chanuser_id` = '%s'", chanuserrow[0]);
30     }
31 }