Commit def1556f authored by Jonah's avatar Jonah

added global helper functions

parent 185765a5
......@@ -121,3 +121,50 @@ end
ULib.ucl.registerAccess( "ulx unpropbanall", ULib.ACCESS_SUPERADMIN, "Ability to unban all propban entries", "Other" ) -- Permission for admins to unban players banned by other admins.
ULib.ucl.registerAccess( "ulx editpropbanall", ULib.ACCESS_SUPERADMIN, "Ability to edit all propban entries", "Other" ) -- Permission for admins to edit bans made by other admins.
--Global functions
function pb_doban(inip, steamid, name, length, reason, callingadmin)
local adminid = callingadmin.SteamID or 0
local ip = string.Explode(":", inip)[1]
local qTab = {}
qTab.wait = false
local time = os.time();
local query = "INSERT INTO "..db_prefix.."bans (ip, authid, name, created, ends, length, reason, aid) "
query = query.." VALUES ('"..propban_database:escape(ip).."', '"..propban_database:escape(steamid).."', '"..propban_database:escape(name).."',"..time..", "..(time + length)..", "..length..", '"..propban_database:escape(reason).."', "..adminid..");"
pbSQLQuery(query, qTab)
XGUIRefreshBans()
end
function pb_banplayer(ply, length, reason, callingadmin)
local ip = string.Explode(":",ply:IPAddress())[1]
local steamid = ply:SteamID()
local name = ply:Nick()
pb_doban(ip,steamid,name,length,reason,callingadmin)
end
function pb_unban(steamid,ply,unreason)
local adminID = ply.SteamID() or 0
local qTab = {}
qTab.wait = false
pbSQLQuery("UPDATE "..db_prefix.."bans SET RemovedOn = "..os.time()..", RemovedBy = "..adminID..", RemoveType = 'U', ureason = '"..propban_database:escape(ureason).."' WHERE authid = '"..propban_database:escape(steamid).."' and RemoveType is null", qTab)
XGUIRefreshBans()
end
function pb_canunban(steamid, ply)
local adminID = ply:SteamID() or 0
local query = "SELECT * FROM "..db_prefix.."bans WHERE authid = '"..propban_database:escape(steamid).."' and RemoveType is null"
if not ULib.ucl.query( ply, "ulx unpropbanall" ) then
query = query .. " and aid = "..adminID
end
local qTab = {}
qTab.wait = true
return #pbSQLQuery(query, qTab) > 0
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment