1 /* cmd_neonserv_bans.c - NeonServ v5.0
2 * Copyright (C) 2011 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"
21 * argv[0] (optional) mask
23 CMD_BIND(neonserv_cmd_bans) {
27 int i, with_expire = 0, cindex = 0;
28 char triggered_str[MAXLEN], expires_str[MAXLEN];
30 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);
32 table = table_init(5, mysql_num_rows(res) + 1, 0);
34 //add a NULL row (we add values later)
40 table_add(table, content);
41 while ((row = mysql_fetch_row(res)) != NULL) {
42 if(argc > 0 && match(argv[0], row[0])) continue;
45 content[2] = (strcmp(row[2], "0") ? timeToStr(user, (time(0) - atoi(row[2])), 2, triggered_str) : get_language_string(user, "NS_USERS_SEEN_NEVER"));
46 if(strcmp(row[3], "0")) {
48 //we're using expire times now...
49 for(i = 0; i < cindex; i++)
50 table_change_field(table, i+1, 3, get_language_string(user, "NS_USERS_SEEN_NEVER"));
53 content[3] = timeToStr(user, (atoi(row[3]) - time(0)), 2, expires_str);
55 content[3] = (with_expire ? get_language_string(user, "NS_USERS_SEEN_NEVER") : NULL);
58 table_add(table, content);
60 //now we add the table header
61 content[0] = get_language_string(user, "NS_BANS_HEADER_MASK");
62 content[1] = get_language_string(user, "NS_BANS_HEADER_SETBY");
63 content[2] = get_language_string(user, "NS_BANS_HEADER_TRIGGERED");
64 content[3] = (with_expire ? get_language_string(user, "NS_BANS_HEADER_EXPIRES") : NULL);
65 content[4] = get_language_string(user, "NS_BANS_HEADER_REASON");
66 table_change(table, 0, content);
67 char **table_lines = table_end(table);
68 for(i = 0; i < table->entrys; i++) {
69 reply(getTextBot(), user, table_lines[i]);
72 reply(getTextBot(), user, "NS_TABLE_NONE");
73 reply(getTextBot(), user, "NS_TABLE_COUNT", cindex);