{NULL, NULL}
};
+static unsigned int convertNeonSpamSettingsToFlags(char *str);
static int loadNeonSpamSettings(struct ChanNode *chan);
static void createSpamNode(struct ChanUser *chanuser);
static void freeJoinNode(struct NeonSpamJoinNode *joinnode);
}
}
+char* convertNeonSpamSettingsToString(unsigned int flags, char *buffer) {
+ int pos = 0;
+ unsigned int i;
+ int j = 0;
+ char *chars = SPAMSETTINGS_CHARS;
+ for(i = 1; i <= SPAMSETTINGS_FLAGS; i = i << 1) {
+ if(flags & i)
+ buffer[pos++] = chars[j];
+ j++;
+ }
+ buffer[pos] = '\0';
+ return buffer;
+}
+
+static unsigned int convertNeonSpamSettingsToFlags(char *str) {
+ unsigned int i = 1, flags = 0;
+ int j = 0;
+ char *chars = SPAMSETTINGS_CHARS;
+ while(*str) {
+ for(; i <= SPAMSETTINGS_FLAGS; i = i << 1) {
+ if(*str == chars[j]) {
+ flags |= i;
+ j++;
+ break;
+ }
+ j++;
+ }
+ str++;
+ }
+ return flags;
+}
+
static int loadNeonSpamSettings(struct ChanNode *chan) {
if(chan->spam_settings) return 0;
struct NeonSpamSettings *settings = malloc(sizeof(*settings));
MYSQL_RES *res;
MYSQL_ROW row, defaults = NULL;
loadChannelSettings(chan);
- printf_mysql_query("SELECT `channel_scanstate`, `channel_maxrepeat`, `channel_maxflood`, `channel_floodtime`, `channel_maxjoin`, `channel_jointime`, `channel_scanexcept` FROM `channels` WHERE `channel_id` = '%d'", chan->channel_id);
+ printf_mysql_query("SELECT `channel_scanner`, `channel_spam_limit`, `channel_spam_except`, `channel_flood_limit`, `channel_flood_time`, `channel_flood_except`, `channel_join_limit`, `channel_join_time`, `channel_join_except`, `channel_caps_percent`, `channel_caps_except`, `channel_digit_percent`, `channel_digit_except` FROM `channels` WHERE `channel_id` = '%d'", chan->channel_id);
res = mysql_use();
row = mysql_fetch_row(res);
- if(!row[0] || !row[1] || !row[2] || !row[3] || !row[4] || !row[5]) {
- printf_mysql_query("SELECT `channel_scanstate`, `channel_maxrepeat`, `channel_maxflood`, `channel_floodtime`, `channel_maxjoin`, `channel_jointime`, `channel_scanexcept` FROM `channels` WHERE `channel_name` = 'defaults'");
+ if(!row[0] || !row[1] || !row[2] || !row[3] || !row[4] || !row[5] || !row[6] || !row[7] || !row[8] || !row[9] || !row[10] || !row[11] || !row[12]) {
+ printf_mysql_query("SELECT `channel_scanner`, `channel_spam_limit`, `channel_spam_except`, `channel_flood_limit`, `channel_flood_time`, `channel_flood_except`, `channel_join_limit`, `channel_join_time`, `channel_join_except`, `channel_caps_percent`, `channel_caps_except`, `channel_digit_percent`, `channel_digit_except` FROM `channels` WHERE `channel_name` = 'defaults'");
res = mysql_use();
defaults = mysql_fetch_row(res);
}
- settings->flags = atoi(row[0] ? row[0] : defaults[0]);
+ settings->flags = convertNeonSpamSettingsToFlags(row[0] ? row[0] : defaults[0]);
settings->spam_amount = atoi(row[1] ? row[1] : defaults[1]);
- settings->flood_amount = atoi(row[2] ? row[2] : defaults[2]);
- settings->flood_time = atoi(row[3] ? row[3] : defaults[3]);
- settings->join_amount = atoi(row[4] ? row[4] : defaults[4]);
- settings->join_time = atoi(row[5] ? row[5] : defaults[5]);
- settings->exceptlevel = atoi(row[6] ? row[6] : defaults[6]);
+ settings->exceptlevel[SPAMSETTINGS_SPAMEXCINDEX] = atoi(row[2] ? row[2] : defaults[2]);
+ settings->sensibility_amount[SPAMSETTINGS_FLOODSENINDEX] = atoi(row[3] ? row[3] : defaults[3]);
+ settings->sensibility_time[SPAMSETTINGS_FLOODSENINDEX] = atoi(row[4] ? row[4] : defaults[4]);
+ settings->exceptlevel[SPAMSETTINGS_FLOODEXCINDEX] = atoi(row[5] ? row[5] : defaults[5]);
+ settings->sensibility_amount[SPAMSETTINGS_JOINSENINDEX] = atoi(row[6] ? row[6] : defaults[6]);
+ settings->sensibility_time[SPAMSETTINGS_JOINSENINDEX] = atoi(row[7] ? row[7] : defaults[7]);
+ settings->exceptlevel[SPAMSETTINGS_JOINEXCINDEX] = atoi(row[8] ? row[8] : defaults[8]);
+ settings->percent[SPAMSETTINGS_CAPSPERCENTINDEX] = atoi(row[9] ? row[9] : defaults[9]);
+ settings->exceptlevel[SPAMSETTINGS_CAPSEXCINDEX] = atoi(row[10] ? row[10] : defaults[10]);
+ settings->percent[SPAMSETTINGS_DIGITPERCENTINDEX] = atoi(row[11] ? row[11] : defaults[11]);
+ settings->exceptlevel[SPAMSETTINGS_DIGITEXCINDEX] = atoi(row[12] ? row[12] : defaults[12]);
settings->join_nodes = NULL;
settings->lastmsg_time = 0;
int i;