X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2Fcmd_neonserv_move.c;h=d8ae8069fb5487a959a27a30a45f6efb7a2b53d7;hb=c575e458c6257e75b97884847143b20965a5dfda;hp=804954faf45ff92be7a1f9798fdd11e200e92da4;hpb=0f1dc61921eef1db8e404a5a82372e2d1cd55daa;p=NeonServV5.git diff --git a/src/cmd_neonserv_move.c b/src/cmd_neonserv_move.c index 804954f..d8ae806 100644 --- a/src/cmd_neonserv_move.c +++ b/src/cmd_neonserv_move.c @@ -1,3 +1,19 @@ +/* cmd_neonserv_move.c - NeonServ v5.2 + * Copyright (C) 2011 Philipp Kreil (pk910) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #include "cmd_neonserv.h" @@ -53,18 +69,23 @@ CMD_BIND(neonserv_cmd_move) { putsock(bot, "PART %s :Channel moved to %s.", channel, new_channel); putsock(bot, "JOIN %s", new_channel); } - printf_mysql_query("DELETE FROM `channels` WHERE `channel_name` = '%s'", escape_string(new_channel)); - printf_mysql_query("UPDATE `channels` SET `channel_name` = '%s' WHERE `channel_id` = '%s'", escape_string(new_channel), row[1]); + printf_mysql_query("SELECT `channel_id` FROM `channels` WHERE `channel_name` = '%s'", escape_string(new_channel)); + res = mysql_use(); + if ((row = mysql_fetch_row(res)) != NULL) { + chanid = atoi(row[0]); + printf_mysql_query("DELETE FROM `chanusers` WHERE `chanuser_cid` = '%d'", chanid); + printf_mysql_query("DELETE FROM `bans` WHERE `ban_channel` = '%d'", chanid); + printf_mysql_query("DELETE FROM `events` WHERE `cid` = '%d'", chanid); + printf_mysql_query("DELETE FROM `noinvite` WHERE `cid` = '%d'", chanid); + printf_mysql_query("DELETE FROM `owner_history` WHERE `owner_history_cid` = '%d'", chanid); + printf_mysql_query("DELETE FROM `channels` WHERE `channel_id` = '%d'", chanid); + } + printf_mysql_query("UPDATE `channels` SET `channel_name` = '%s' WHERE `channel_name` = '%s'", escape_string(new_channel), escape_string(channel)); struct ChanNode *channode = getChanByName(channel); if(channode && channode->flags & CHANFLAG_REQUESTED_CHANINFO) { channode->flags &= ~CHANFLAG_CHAN_REGISTERED; channode->channel_id = 0; } - channode = getChanByName(new_channel); - if(channode && channode->flags & CHANFLAG_REQUESTED_CHANINFO) { - channode->flags |= CHANFLAG_CHAN_REGISTERED; - channode->channel_id = atoi(row[1]); - } reply(getTextBot(), user, "NS_MOVE_DONE", channel, new_channel); logEvent(event); }