1 /* cmd_neonserv_info.c - NeonServ v5.6
2 * Copyright (C) 2011-2012 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);
32 table_set_bold(table, 0, 1);
34 reply(textclient, user, "NS_INFO_HEADER", chan->name);
35 content[0] = get_language_string(user, "NS_INFO_DEFAULTTOPIC");
37 table_add(table, content);
38 content[0] = get_language_string(user, "NS_INFO_MODELOCK");
40 table_add(table, content);
41 content[0] = get_language_string(user, "NS_INFO_RECORD");
43 table_add(table, content);
44 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);
46 char ownerstr[MAXLEN];
47 int ownerpos = 0, usercount = 0;
49 while((row2 = mysql_fetch_row(res))) {
50 if(!strcmp(row2[1], "500")) {
51 ownerpos += sprintf(ownerstr + ownerpos, (ownerpos ? ", %s" : "%s"), row2[0]);
52 if((user->flags & USERFLAG_ISAUTHED) && !stricmp(row2[0], user->auth))
57 content[0] = get_language_string(user, "NS_INFO_OWNER");
58 content[1] = ownerstr;
59 table_add(table, content);
60 sprintf(ownerstr, "%d", usercount);
61 content[0] = get_language_string(user, "NS_INFO_USERS");
62 content[1] = ownerstr;
63 table_add(table, content);
64 printf_mysql_query("SELECT COUNT(*) FROM `bans` WHERE `ban_channel` = '%d'", chan->channel_id);
66 row2 = mysql_fetch_row(res);
67 content[0] = get_language_string(user, "NS_INFO_BANS");
69 table_add(table, content);
70 content[0] = get_language_string(user, "NS_INFO_VISITED");
71 content[1] = timeToStr(user, time(0) - atoi(row[3]), 2, ownerstr);
72 table_add(table, content);
73 if(strcmp(row[4], "0")) {
74 content[0] = get_language_string(user, "NS_INFO_REGISTERED");
75 content[1] = timeToStr(user, time(0) - atoi(row[4]), 2, ownerstr);
76 table_add(table, content);
78 if(row[5] && isGodMode(user)) {
79 content[0] = get_language_string(user, "NS_INFO_REGISTRAR");
81 table_add(table, content);
83 char **table_lines = table_end(table);
85 for(i = 0; i < table->entrys; i++) {
86 reply(textclient, user, table_lines[i]);
89 if(userisowner || isGodMode(user)) {
90 printf_mysql_query("SELECT `owner_history_time`, a.`user_user`, b.`user_user` FROM `owner_history` LEFT JOIN `users` a ON `owner_history_from_uid` = a.`user_id` LEFT JOIN `users` b ON `owner_history_to_uid` = b.`user_id` WHERE `owner_history_cid` = '%d'", chan->channel_id);
92 if(mysql_num_rows(res)) {
93 reply(textclient, user, "NS_INFO_OWNERLOG", chan->name);
97 while((row = mysql_fetch_row(res))) {
98 rawtime = (time_t) atol(row[0]);
99 timeinfo = localtime(&rawtime);
100 strftime(timeBuf, 80, "%c", timeinfo);
101 reply(textclient, user, "NS_INFO_OWNERCHANGE", row[1], row[2], timeBuf);