New - modified banlist
----------------------
(same infos are gonna be for allow list)

Pros:
1/ will be only one table for all kinds of bans
2/ one mysql query is enough
3/ extensible for all kinds of bans
4/ enabled/disabled switch will be on them and also who unbanned what (in a kind of way)

Contras:
1/ primary key must be independent of nick/ip or so.. therefore int auto increment,
	this makes more difficult to control for multiple bans, but it's still possible, let's be positive
???

Inofs in banlist:
-----------------
banned user's: nick, ip, host, and all bannable infos
flags what is banned
date of first appearance of this ban
first banner op nick (first , because any op can add bans to this later)
ban reason etc...
date of ban expiration


Description of table:
---------------------

+------------+------------------------------+------+-----+---------------------+-------+
| Field      | Type                         | Null | Key | Default             | Extra |
+------------+------------------------------+------+-----+---------------------+-------+
| ip         | varchar(15)                  | YES  |     | NULL                |       |
| nick       | varchar(60)                  | YES  |     | NULL                |       |
| enabled    | tinyint(1)                   |      |     | 1                   |       |
| host       | text                         | YES  |     | NULL                |       |
| share      | varchar(15)                  | YES  |     | NULL                |       |
| email      | varchar(128)                 | YES  |     | NULL                |       |
| range_fr   | varchar(15)                  | YES  |     | NULL                |       |
| range_to   | varchar(15)                  | YES  |     | NULL                |       |
| date_start | datetime                     | YES  |     | 0000-00-00 00:00:00 |       |
| date_limit | datetime                     | YES  |     | NULL                |       |
| flags      | set('I','N','H','S','E','R') |      |     |                     |       |
| nick_op    | varchar(60)                  | YES  |     | NULL                |       |
| reason     | text                         | YES  |     | NULL                |       |
+------------+------------------------------+------+-----+---------------------+-------+

Queries for bans unbans, rebans, tests etc..
--------------------------------------------
suppose all variables @blabla are given

****************************
** various predefined checks

<date_limit check>      = (date_limit IS NULL OR (date_limit >= NOW()))
<std check for bantest> = ( enabled and <date_limit check> )
<ip check>              = ( @the_ip=ip OR LEFT(@the_ip, LENGTH(ip)+1)=CONCAT(ip,'.') )
<host check>            = ( @the_host=host OR RIGHT(@the_host, LENGTH(host)+1)=CONCAT('.',host) )
<nick check>            = ( nick=@the_nick )

*******************
<range check>           = ( @the_ip > range_from AND @the_ip < range_from )

e.g:
1.2.3.0 - 1.2.4.255 / test with 11.blabla
1.2.3.0 - 11.2.4.255 / test with 111.blabla
* the simeple text ">" maybe works


**********************************
** delete or move all expired bans
... WHERE NOT <date_limit check>


*******************
** test for ip ban:

... WHERE <std check for bantest> and ip=@the_ip AND INSET('I',flags); // ip
... WHERE <std check for bantest> AND <ip check> AND INSET('I',flags) // ip range or ip
Note:
	* multiple records are possible, because if different nicks or null nick
	* if no record is found, ther is no ban and all is ok
	* otherwise ban is valid, and you can either list them, or not to list them
	* in case of allow list and multiple records: only the one with corresponding nick is usable or NULL


********************
** test for nick ban
... WHERE <std check for bantest> and <nick check> AND INSET('N',flags); // nick

you get the point ?

*************************************************************************
** test for existance of ban in case of control before trying to add ban:

suppose: you have the nick and ip (if you need ban only one of them, the other is null)

case 1/ there is same ip but different nick -> create new ban
case 2/ there is same ip and same nick -> update this one
case 3/ there is same nick different ip -> new ban
case 4/ nothing same -> new ban

... WHERE  <nick check> AND <ip check>


***********************************************
** how to ban other stuff then ip, nick or both

That seems to be problem with given primary key. If you wanna generally ban host let's say blbla.com
you can't figure out in general way any ip or nick corresponding to it...

Easy help, just make ip=NULL and e.g. nick="hostban_blabla.com" and you are ok ;o)
if you have ip, no problem, just use it ;o)


*************************************************************
** how to import the 0.9.2 version of banlist 2do(correction)

the approximative way, which should work fine
insert into banlist
	(ip,nick     ,reason,date_start,date_limit, nick_op, enabled, flags             ) select
	(ip, nick_ban,reason,date_ban  ,date_limit, nick_op, 1      , MAKE_SET('I','N') ) from ipbanlist;
insert into banlist
	(nick    , reason,date_start,date_limit, nick_op, enabled, flags        ) select
	(nick_ban, reason,date_ban  ,date_limit, nick_op, 1      , MAKE_SET('N')) from nickbanlist where ip is null;

update banlist set flags=unset('N',flasg) where nick is null;
