added new auth-check security feature
[NeonServV5.git] / src / cmd_global_unregister.c
index 99669afe62d22ee9e49f4f0b994542da050e15a6..43dab20796f171615c61b67c487001eb0d539b22 100644 (file)
@@ -1,5 +1,5 @@
-/* cmd_global_unregister.c - NeonServ v5.2
- * Copyright (C) 2011  Philipp Kreil (pk910)
+/* cmd_global_unregister.c - NeonServ v5.3
+ * Copyright (C) 2011-2012  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
 CMD_BIND(global_cmd_unregister) {
     MYSQL_RES *res;
     MYSQL_ROW row;
-    char *channel = argv[0];
+    char *channel;
+    if(argc)
+        channel = argv[0];
+    else
+        channel = (chan ? chan->name : "");
     if(!is_valid_chan(channel)) {
         reply(getTextBot(), user, "NS_INVALID_CHANNEL_NAME", argv[0]);
         return;
@@ -37,7 +41,10 @@ CMD_BIND(global_cmd_unregister) {
         reply(getTextBot(), user, "NS_UNREGISTER_NOT_REGISTERED", argv[0], client->user->nick);
         return;
     }
-    printf_mysql_query("SELECT `botid`, `bot_channels`.`id`, `suspended` FROM `bot_channels` LEFT JOIN `bots` ON `bot_channels`.`botid` = `bots`.`id` WHERE `chanid` = '%d' AND `botclass` = '%d'", chanid, client->botid);
+    if(client->botid == 0)
+        printf_mysql_query("SELECT `botid`, `bot_channels`.`id`, `suspended` FROM `bot_channels` LEFT JOIN `bots` ON `bot_channels`.`botid` = `bots`.`id` WHERE `chanid` = '%d' AND `botclass` = '0' AND `botid` = '%d'", chanid, client->clientid);
+    else
+        printf_mysql_query("SELECT `botid`, `bot_channels`.`id`, `suspended` FROM `bot_channels` LEFT JOIN `bots` ON `bot_channels`.`botid` = `bots`.`id` WHERE `chanid` = '%d' AND `botclass` = '%d'", chanid, client->botid);
     res = mysql_use();
     if ((row = mysql_fetch_row(res)) == NULL) {
         reply(getTextBot(), user, "NS_UNREGISTER_NOT_REGISTERED", argv[0], client->user->nick);