rearranged NeonServ code to be modular
[NeonServV5.git] / src / cmd_neonserv_bans.c
diff --git a/src/cmd_neonserv_bans.c b/src/cmd_neonserv_bans.c
deleted file mode 100644 (file)
index 7ad47e1..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/* cmd_neonserv_bans.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
- * 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 <http://www.gnu.org/licenses/>. 
- */
-
-#include "cmd_neonserv.h"
-
-/*
-* argv[0]    (optional) mask
-*/
-CMD_BIND(neonserv_cmd_bans) {
-    MYSQL_RES *res;
-    MYSQL_ROW row;
-    //ban list
-    int i, with_expire = 0, cindex = 0;
-    char triggered_str[MAXLEN], expires_str[MAXLEN];
-    struct Table *table;
-    printf_mysql_query("SELECT `ban_mask`, `user_user`, `ban_triggered`, `ban_timeout`, `ban_reason` FROM `bans` LEFT JOIN `users` ON `ban_owner` = `user_id` WHERE `ban_channel` = '%d'", chan->channel_id);
-    res = mysql_use();
-    table = table_init(5, mysql_num_rows(res) + 1, 0);
-    char *content[5];
-    //add a NULL row (we add values later)
-    content[0] = NULL;
-    content[1] = NULL;
-    content[2] = NULL;
-    content[3] = NULL;
-    content[4] = NULL;
-    table_add(table, content);
-    while ((row = mysql_fetch_row(res)) != NULL) {
-        if(argc > 0 && match(argv[0], row[0])) continue;
-        content[0] = row[0];
-        content[1] = row[1];
-        content[2] = (strcmp(row[2], "0") ? timeToStr(user, (time(0) - atoi(row[2])), 2, triggered_str) : get_language_string(user, "NS_USERS_SEEN_NEVER"));
-        if(strcmp(row[3], "0")) {
-            if(!with_expire) {
-                //we're using expire times now...
-                for(i = 0; i < cindex; i++)
-                    table_change_field(table, i+1, 3, get_language_string(user, "NS_USERS_SEEN_NEVER"));
-                with_expire = 1;
-            }
-            content[3] = timeToStr(user, (atoi(row[3]) - time(0)), 2, expires_str);
-        } else
-            content[3] = (with_expire ? get_language_string(user, "NS_USERS_SEEN_NEVER") : NULL);
-        content[4] = row[4];
-        cindex++;
-        table_add(table, content);
-    }
-    //now we add the table header
-    content[0] = get_language_string(user, "NS_BANS_HEADER_MASK");
-    content[1] = get_language_string(user, "NS_BANS_HEADER_SETBY");
-    content[2] = get_language_string(user, "NS_BANS_HEADER_TRIGGERED");
-    content[3] = (with_expire ? get_language_string(user, "NS_BANS_HEADER_EXPIRES") : NULL);
-    content[4] = get_language_string(user, "NS_BANS_HEADER_REASON");
-    table_change(table, 0, content);
-    char **table_lines = table_end(table);
-    for(i = 0; i < table->entrys; i++) {
-        reply(getTextBot(), user, table_lines[i]);
-    }
-    if(!cindex)
-        reply(getTextBot(), user, "NS_TABLE_NONE");
-    reply(getTextBot(), user, "NS_TABLE_COUNT", cindex);
-    table_free(table);
-}