added some code & compiler information to cmd_netinfo
[NeonServV5.git] / DBHelper.c
index 587158635b065e64283c71849adfb479d250cc06..5e9005d771e669d8bf55487a160943b84bd48322 100644 (file)
@@ -5,7 +5,7 @@
 #include "ChanUser.h"
 #include "mysqlConn.h"
 #include "lang.h"
-
+#include "tools.h"
 
 void _loadUserSettings(struct UserNode *user) {
     check_mysql();
@@ -118,13 +118,13 @@ int isUserProtected(struct ChanNode *chan, struct UserNode *victim, struct UserN
     char protection;
     loadChannelSettings(chan);
     if(!(chan->flags & CHANFLAG_CHAN_REGISTERED)) return 0;
-    printf_mysql_query("SELECT `channel_protect` FROM `channels` WHERE `channel_id` = '%d'");
+    printf_mysql_query("SELECT `channel_protect` FROM `channels` WHERE `channel_id` = '%d'", chan->channel_id);
     res = mysql_use();
     if(!(row = mysql_fetch_row(res))) return 0;
     if(row[0]) {
         protection = (char) atoi(row[0]);
     } else {
-         printf_mysql_query("SELECT `channel_protect` FROM `channels` WHERE `channel_name` = 'defaults'", chan->channel_id);
+         printf_mysql_query("SELECT `channel_protect` FROM `channels` WHERE `channel_name` = 'defaults'");
         res = mysql_use();
         row = mysql_fetch_row(res);
         protection = (char) atoi(row[0]);
@@ -154,4 +154,16 @@ int isUserProtected(struct ChanNode *chan, struct UserNode *victim, struct UserN
     return 0;
 }
 
-
+char *getBanAffectingMask(struct ChanNode *chan, char *mask) {
+    loadChannelSettings(chan);
+    if(!(chan->flags & CHANFLAG_CHAN_REGISTERED)) return 0;
+    MYSQL_RES *res;
+    MYSQL_ROW row;
+    printf_mysql_query("SELECT `ban_mask` FROM `bans` WHERE `ban_channel` = '%d'", chan->channel_id);
+    res = mysql_use();
+    while ((row = mysql_fetch_row(res)) != NULL) {
+        if(!match(row[0], mask))
+            return row[0];
+    }
+    return NULL;
+}