1 /* cmd_neonserv_delme.c - NeonServ v5.6
2 * Copyright (C) 2011-2012 Philipp Kreil (pk910)
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.
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.
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/>.
18 #include "cmd_neonserv.h"
24 CMD_BIND(neonserv_cmd_delme) {
28 printf_mysql_query("SELECT `user_id` FROM `users` WHERE `user_user` = '%s'", escape_string(user->auth));
30 if ((row = mysql_fetch_row(res)) != NULL) {
31 userid = atoi(row[0]);
32 //check if the user is added
33 printf_mysql_query("SELECT `chanuser_access`, `chanuser_id` FROM `chanusers` WHERE `chanuser_cid` = '%d' AND `chanuser_uid` = '%d'", chan->channel_id, userid);
35 if ((row = mysql_fetch_row(res)) != NULL) {
36 if(atoi(row[0]) == 500) {
37 reply(textclient, user, "NS_DELME_OWNER", chan->name);
43 static char unregkey[16];
44 for(tmp = user->auth; *tmp; tmp++)
45 seed = (seed * 0xEECE66DL ^ ((*tmp << 24) | (*tmp << 16) | (*tmp << 8) | *tmp));
46 for(tmp = chan->name; *tmp; tmp++)
47 seed = (seed * 0xEECE66DL ^ ((*tmp << 24) | (*tmp << 16) | (*tmp << 8) | *tmp));
48 sprintf(unregkey, "%08x", seed);
49 if(argc < 1 || strcmp(argv[0], unregkey)) {
50 reply(textclient, user, "NS_DELME_KEY", unregkey);
54 printf_mysql_query("DELETE FROM `chanusers` WHERE `chanuser_id` = '%s'", row[1]);
55 reply(textclient, user, "NS_DELME_DONE", atoi(row[0]), chan->name);
61 reply(textclient, user, "NS_NOT_ON_USERLIST_YOU", chan->name);