added some code & compiler information to cmd_netinfo
[NeonServV5.git] / cmd_neonserv_upall.c
1
2 /*
3 * no arguments
4 */
5
6 static CMD_BIND(neonserv_cmd_upall) {
7     check_mysql();
8     MYSQL_RES *res, *default_res;
9     MYSQL_ROW row, default_row;
10     struct ChanUser *chanuser;
11     int userid, chan_getop, chan_getvoice, caccess;
12     printf_mysql_query("SELECT `user_id` FROM `users` WHERE `user_user` = '%s'", user->auth);
13     res = mysql_use();
14     if ((row = mysql_fetch_row(res)) == NULL)
15         return;
16     userid = atoi(row[0]);
17     printf_mysql_query("SELECT `chanuser_access`, `channel_getop`, `channel_getvoice`, `channel_name`, `channel_id` FROM `chanusers` LEFT JOIN `channels` ON `chanuser_cid` = `channel_id` WHERE `chanuser_uid` = '%d'", userid);
18     res = mysql_use();
19     while ((row = mysql_fetch_row(res)) != NULL) {
20         chan = getChanByName(row[3]);
21         if(!chan) continue;
22         printf_mysql_query("SELECT `botid` FROM `bot_channels` LEFT JOIN `bots` ON `bot_channels`.`botid` = `bots`.`id` WHERE `chanid` = '%s' AND `botclass` = '%d'", row[4], client->botid);
23         if (mysql_fetch_row(mysql_use()) == NULL) continue;
24         if(!(chanuser = getChanUser(user, chan))) continue;
25         if(!row[1] || !row[2]) {
26             printf_mysql_query("SELECT `channel_getop`, `channel_getvoice` FROM `channels` WHERE `channel_name` = 'defaults'");
27             default_res = mysql_use();
28             if ((default_row = mysql_fetch_row(default_res)) == NULL) return;
29             chan_getop = (row[1] ? atoi(row[1]) : atoi(default_row[0]));
30             chan_getvoice = (row[2] ? atoi(row[2]) : atoi(default_row[1]));
31         } else {
32             chan_getop = atoi(row[1]);
33             chan_getvoice = atoi(row[2]);
34         }
35         caccess = atoi(row[0]);
36         if(caccess >= chan_getop) {
37             if(!(chanuser->flags & CHANUSERFLAG_OPPED))
38                 putsock(client, "MODE %s +o %s", chan->name, user->nick);
39         } else if(caccess >= chan_getvoice) {
40             if(!(chanuser->flags & CHANUSERFLAG_VOICED))
41                 putsock(client, "MODE %s +v %s", chan->name, user->nick);
42         }
43     }
44 }