1 /* cmd_neonserv_info.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"
24 CMD_BIND(neonserv_cmd_info) {
28 printf_mysql_query("SELECT `channel_defaulttopic`, `channel_modes`, `channel_maxusers`, `channel_lastvisit`, `channel_registered`, `user_user` FROM `channels` LEFT JOIN `users` ON `channel_registrator` = `user_id` WHERE `channel_id` = '%d'", chan->channel_id);
30 row = mysql_fetch_row(res);
31 table = table_init(2, 9, 0);
33 reply(getTextBot(), user, "NS_INFO_HEADER", chan->name);
34 content[0] = get_language_string(user, "NS_INFO_DEFAULTTOPIC");
36 table_add(table, content);
37 content[0] = get_language_string(user, "NS_INFO_MODELOCK");
39 table_add(table, content);
40 content[0] = get_language_string(user, "NS_INFO_RECORD");
42 table_add(table, content);
43 printf_mysql_query("SELECT `user_user`, `chanuser_access` FROM `chanusers` LEFT JOIN `users` ON `user_id` = `chanuser_uid` WHERE `chanuser_cid` = '%d'", chan->channel_id);
45 char ownerstr[MAXLEN];
46 int ownerpos = 0, usercount = 0;
47 while((row2 = mysql_fetch_row(res))) {
48 if(!strcmp(row2[1], "500"))
49 ownerpos += sprintf(ownerstr + ownerpos, (ownerpos ? ", %s" : "%s"), row2[0]);
52 content[0] = get_language_string(user, "NS_INFO_OWNER");
53 content[1] = ownerstr;
54 table_add(table, content);
55 sprintf(ownerstr, "%d", usercount);
56 content[0] = get_language_string(user, "NS_INFO_USERS");
57 content[1] = ownerstr;
58 table_add(table, content);
59 printf_mysql_query("SELECT COUNT(*) FROM `bans` WHERE `ban_channel` = '%d'", chan->channel_id);
61 row2 = mysql_fetch_row(res);
62 content[0] = get_language_string(user, "NS_INFO_BANS");
64 table_add(table, content);
65 content[0] = get_language_string(user, "NS_INFO_VISITED");
66 content[1] = timeToStr(user, time(0) - atoi(row[3]), 2, ownerstr);
67 table_add(table, content);
68 if(strcmp(row[4], "0")) {
69 content[0] = get_language_string(user, "NS_INFO_REGISTERED");
70 content[1] = timeToStr(user, time(0) - atoi(row[4]), 2, ownerstr);
71 table_add(table, content);
74 content[0] = get_language_string(user, "NS_INFO_REGISTRAR");
76 table_add(table, content);
78 char **table_lines = table_end(table);
80 for(i = 0; i < table->entrys; i++) {
81 reply(getTextBot(), user, table_lines[i]);