ULX

Author Topic: UBan -- Global ban system. Ban users from all servers connected to a single DB!  (Read 99426 times)

0 Members and 5 Guests are viewing this topic.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Current version: 1.1

Do you run multiple servers or have close friends that you run servers with? Have you ever wanted to instantaneously ban someone from all these servers at once? Then look no farther, UBan is for you!

Please note that you'll be setting up your own database to store your global bans. There is not a global ban list that all users of this script get, you set up a list on your own for a ring of trusted servers.

Installation:
Extract the uban folder to garrysmod/addons
YOU ABSOLUTELY MUST HAVE THE GM_MYSQL MODULE (http://forums.facepunchstudios.com/showthread.php?t=241247)

Unless you plan on using the lua functions directly, you must also have ULX.

You'll also need to set up the database. The MySQL code to do this is inside the uban.lua file, or you can get it from the bottom of this post. You'll need to use this code in your MySQL client of choice while connected to your database (SSH, PHPMyAdmin, etc)

Last, change the config at the top of uban.lua to your DB details.

Usage:
ulx gban (user) (time) (comment) -- Ban a user by name in the server. Time is in minutes, use 0 for perma.
ie: ulx gban Megiddo 0 "Dirty spammer"

ulx gbanid (steamid) (time) (comment)
ulx gunbanid (steamid)

FAQs:
Q: Can I still keep my local bans?
A: Yes, UBan compliments the existing ban system. It will leave local bans untouched, and you can continue to locally ban users if you wish.

Q: Can I get access to _your_ database?
A: No. Maybe read-only access down the road.

Q: How do I set up the MySQL table?
A: Get someone who can help you.

Q: Can you help me set up MySQL?
A: No.

Q: What's up with this extra information in the DB that's not used by UBan?
A: Future use. Another community server admin ([WCA]PHPirate) has sponsored this project and is making a PHP viewer script. You can see an initial demo of this script here: http://forums.planetwca.com/banned.html

Table structure (Use this code in your SQL client)
Quote
CREATE TABLE gbans (
id INT UNSIGNED PRIMARY KEY NOT NULL UNIQUE AUTO_INCREMENT,
steamid CHAR( 12 ) NOT NULL,
name CHAR( 31 ),
time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
unban_time TIMESTAMP NOT NULL DEFAULT 0,
comment CHAR( 128 ),
serverip INT UNSIGNED,
serverport SMALLINT UNSIGNED NOT NULL DEFAULT 27015,
adminname CHAR( 31 ),
adminsteamid CHAR( 12 )
);

Download: http://ulyssesmod.net/archive/UBan-v1_1.zip
« Last Edit: July 25, 2011, 01:06:43 PM by Megiddo »
Experiencing God's grace one day at a time.

Offline LoC

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
This is a great script and the most of it works fine for me, but the IP wasn't saved all right ("1049437792" instead of "62.141.38.96")

And could you tell me how I can overwrite the normal ULX ban-functions the gban-functions?
(So if someones uses the admin-menu to ban someone, this guy will glob-baned)

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
They are saved right silly. :)

You can remove the original functions and just rename the gban ones. Or even better, add the gban functions to the menu.
Experiencing God's grace one day at a time.

Offline p1cwh0r3

  • Newbie
  • *
  • Posts: 12
  • Karma: 1
Well, going to give this a run. I'm assuming all would be fine with the new GMod?

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Experiencing God's grace one day at a time.

Offline p1cwh0r3

  • Newbie
  • *
  • Posts: 12
  • Karma: 1
Long story short: UBan failure. Error is: autorun/server/uban.lua:140: Column 'serverip' cannot be null

Config has all the information in it and yet it is still giving this error. I myself am starting off with MySQL I'm not asking for help with that.. just an idea as to why it is producing this error? Configs are set as required.
Taken everything step by step... ???

More than likely though I've tripped while taking a step I suppose...

« Last Edit: January 29, 2008, 09:01:44 AM by p1cwh0r3 »

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
You're probably using UBan and the DB on the same server (local), which errors out. I fixed this a while ago and pushed it to a beta tester for "quick verification" that it was bug free... but he's been beta testing it for about a year now so I guess it's about time I just go ahead and release it... I'll try to release the new one the end of this week.
Experiencing God's grace one day at a time.

Offline trab

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
    • ICannt.org
Actually the SQL database is on another machine with a different IP to all the game servers.

I am a SQL newbie, but a few things that I have noticed in the database setup that (while making a mockup on my own machine) you noted in the first post:

1. If you have not specified NOT NULL I assume NULL?

2. When using phpMyAdmin and specifying an INT the length defaults to 10 this should be longer right? as an IP could potentially have 15 digits inclusive (decimal).

3. the 'id' has been specified with PRIMARY KEY and UNIQUE which are basically the same thing right?
phpMYAdmin message: The following indexes appear to be equal and one of them should be removed: PRIMARY, id
or am I just doing something wrong there?

Thanks for your time,

trab - ICannt.org Senior Admin
|IC| Sub-Zero - ICannt.org Senior Admin

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
2. When using phpMyAdmin and specifying an INT the length defaults to 10 this should be longer right? as an IP could potentially have 15 digits inclusive (decimal).

It's not an IP, its a 10 digit number representing the IP or steamid.
http://garrysmod.com/wiki/?title=Player.UniqueID (I think)

As for other questions, well, I don't know (though I should learn) SQL.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Actually the SQL database is on another machine with a different IP to all the game servers.

I am a SQL newbie, but a few things that I have noticed in the database setup that (while making a mockup on my own machine) you noted in the first post:

1. If you have not specified NOT NULL I assume NULL?

If NOT NULL isn't there it means the value *could* be null.

2. When using phpMyAdmin and specifying an INT the length defaults to 10 this should be longer right? as an IP could potentially have 15 digits inclusive (decimal).

NO! No one seems to understand that xxx.xxx.xxx.xxx is NOT how a computer sees an IP. An integer is the correct representation and takes up 4 bytes instead of 15.

3. the 'id' has been specified with PRIMARY KEY and UNIQUE which are basically the same thing right?
phpMYAdmin message: The following indexes appear to be equal and one of them should be removed: PRIMARY, id
or am I just doing something wrong there?

Primary key implies unique but there's no harm in specifying it anyways.
Experiencing God's grace one day at a time.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Long story short: UBan failure. Error is: autorun/server/uban.lua:140: Column 'serverip' cannot be null

Config has all the information in it and yet it is still giving this error. I myself am starting off with MySQL I'm not asking for help with that.. just an idea as to why it is producing this error? Configs are set as required.
Taken everything step by step... ???

More than likely though I've tripped while taking a step I suppose...



I was getting this error too.. I just went into my database(PhPMyAdmin) and set the NULL on serverip and serverport from NO to YES.. This allows for the script to pass null to these rows on the table withouth erroring..
Tested it and it works perfectly.

Offline p1cwh0r3

  • Newbie
  • *
  • Posts: 12
  • Karma: 1
Sorry for the late reply. This i can confirm works also; We've had our UBan running for a while now and no other issues.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Need to release my update...
* Megiddo puts on todo list
Experiencing God's grace one day at a time.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
No worries Meg, it works.. just with a little tinkering... Get all the important things done first =)

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given