Banning in MySQL
#1

Hi,

Can someone explain to me banning, unbanning, offline banning, temporatory banning? (banning contains ip ban for sure)

If possible, with MySQL.

Note: I am not asking you to script for me but to explain for me.
Reply
#2

First of all you need a table
Your table must have at least 5 columns: [Name] [IP] [BanIP] [BanUntil] [Permanent].
Name: varchar(24),
IP: varchar(16),
BanIP: bit,
BanUntil: timestamp,
Permanent: bit.

Saving data for bans
You should save data in standard format to prevent corruptions:
Name is the name of the player being banned using GetPlayerName(...)
IP is the player's IP using GetPlayerIP(...)
BanIP indicates if the IP is banned too, or not: 0 for no and 1 for yes.
BanUntil is a timestamp using MYSQL: ADDDATE(UTC_TIMESTAMP, %d) where %d is the count of days that ban should remain until.
Permanent indicated if the ban should ignore the BanUntil and deny player every time she requests.

Checking and loading ban data
You should just check bans on player connect:
You just need to check if (NAME EXISTS) or if (IP EXISTS and its BanIP EQUALS '1').
If your logical circuits returned TRUE, you should load ban data: BanUntil and Permanent.
Now if Permanent is 1, you should kick the player, if it's 0, next step. Now you should get current UTC time using MYSQL: UTC_TIMESTAMP and check if it's greater that BanUntil's given vaule or not, if it is, remove the ban row and allow the player in, otherwise, KICK!

Hope I helped ^^
Reply
#3

There are a lot of tutorials and filterscripts that covers both MYSQL and ban systems. Just search around on the forums. Here is an example tutorial to get you started.
Reply
#4

Quote:
Originally Posted by AnnaSB
Посмотреть сообщение
First of all you need a table
Your table must have at least 5 columns: [Name] [IP] [BanIP] [BanUntil] [Permanent].
Name: varchar(24),
IP: varchar(16),
BanIP: bit,
BanUntil: timestamp,
Permanent: bit.

Saving data for bans
You should save data in standard format to prevent corruptions:
Name is the name of the player being banned using GetPlayerName(...)
IP is the player's IP using GetPlayerIP(...)
BanIP indicates if the IP is banned too, or not: 0 for no and 1 for yes.
BanUntil is a timestamp using MYSQL: ADDDATE(UTC_TIMESTAMP, %d) where %d is the count of days that ban should remain until.
Permanent indicated if the ban should ignore the BanUntil and deny player every time she requests.

Checking and loading ban data
You should just check bans on player connect:
You just need to check if (NAME EXISTS) or if (IP EXISTS and its BanIP EQUALS '1').
If your logical circuits returned TRUE, you should load ban data: BanUntil and Permanent.
Now if Permanent is 1, you should kick the player, if it's 0, next step. Now you should get current UTC time using MYSQL: UTC_TIMESTAMP and check if it's greater that BanUntil's given vaule or not, if it is, remove the ban row and allow the player in, otherwise, KICK!

Hope I helped ^^
Thanks mate!
A reputation will be given in few seconds.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)