This commit is contained in:
lifestorm
2024-08-04 23:54:45 +03:00
parent 8064ba84d8
commit 6a58f406b1
7522 changed files with 4011896 additions and 15 deletions

View File

@@ -0,0 +1,574 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
eProtect = eProtect or {}
eProtect.queneData = eProtect.queneData or {}
eProtect.saveQueue = eProtect.saveQueue or {}
eProtect.data = eProtect.data or {}
eProtect.data.disabled = eProtect.data.disabled or {}
local ignoreSaving = {
["fakeNets"] = true,
["netLogging"] = true,
["exploitPatcher"] = true
}
util.AddNetworkString("eP:Handeler")
local function openMenu(ply)
net.Start("eP:Handeler")
net.WriteUInt(2, 3)
net.Send(ply)
end
local convertedTbl
convertedTbl = function(tbl)
local converted_tbl = {}
for k,v in pairs(tbl) do
if istable(v) then v = convertedTbl(v) end
local isSID = util.SteamIDFrom64(k) != "STEAM_0:0:0"
if isSID then
converted_tbl["sid64_"..k] = v
else
converted_tbl[k] = v
end
end
return converted_tbl
end
local function networkData(ply, data, specific)
if !data then return end
local data = util.TableToJSON(convertedTbl(data))
data = util.Compress(data)
net.Start("eP:Handeler")
net.WriteUInt(1, 3)
net.WriteUInt(#data, 32)
net.WriteData(data, #data)
if specific then
net.WriteString(specific)
end
net.Send(ply)
end
eProtect.hasPermission = function(ply, specific)
return eProtect.config["permission"][ply:GetUserGroup()]
end
local punished = {}
eProtect.getData = function(specific)
local data = file.Read("eprotect/data.json", "DATA")
if !data then return end
data = util.JSONToTable(data)
if specific then
data = data[specific]
end
for k,v in pairs(data) do
eProtect.data[k] = v
end
return table.Copy(data)
end
eProtect.dataVerification = function()
local data = eProtect.getData()
data = data or {}
data["general"] = data["general"] or {}
for k,v in pairs(eProtect.BaseConfig) do
if data["general"][k] then continue end
data["general"][k] = v[1]
end
for k,v in pairs(eProtect.data) do
if ignoreSaving[k] or k == "general" then continue end
data[k] = v
end
file.CreateDir("eprotect")
file.Write("eprotect/data.json", util.TableToJSON(data))
eProtect.getData()
eProtect.queueNetworking()
end
eProtect.saveData = function()
file.CreateDir("eprotect")
local data = table.Copy(eProtect.data)
for k, v in pairs(data) do
if ignoreSaving[k] then data[k] = nil end
end
file.Write("eprotect/data.json", util.TableToJSON(data))
end
eProtect.canNetwork = function(ply, netstring)
if !IsValid(ply) or !ply:IsPlayer() then return end
if (punished[ply:SteamID()] or eProtect.data.disabled[ply:SteamID()] or eProtect.data.general["disable-all-networking"]) and (netstring ~= "eP:Handeler") then return false end
return true
end
eProtect.punish = function(ply, type, msg, duration)
if eProtect.data.general["bypassgroup"][ply:GetUserGroup()] or eProtect.data.general["bypass_sids"][ply:SteamID()] or eProtect.data.general["bypass_sids"][ply:SteamID64()] then return end
msg = eProtect.config["prefix"]..msg
punished[ply:SteamID()] = true
slib.punish(ply, type, msg, duration)
end
eProtect.networkData = function(ply)
if eProtect.queneData[ply:SteamID()] then
for k,v in pairs(eProtect.queneData[ply:SteamID()]) do
networkData(ply, eProtect.data[k], k)
eProtect.queneData[ply:SteamID()][k] = nil
end
end
end
local function registerQuene(ply, specific)
if specific then
eProtect.queneData[ply:SteamID()] = eProtect.queneData[ply:SteamID()] and eProtect.queneData[ply:SteamID()] or {}
eProtect.queneData[ply:SteamID()][specific] = true
else
for k,v in pairs(eProtect.data) do
registerQuene(ply, k)
end
end
end
eProtect.queueNetworking = function(ply, specific)
if ply then
registerQuene(ply, specific)
else
for k,v in pairs(player.GetAll()) do
if !IsValid(v) then continue end
registerQuene(v, specific)
end
end
end
local screenshotRequested = {}
local idRequested = {}
local dataRequested = {}
local limitSC = {}
local function requestData(ply, target, type)
local data
if type == 1 then
local sid = target:SteamID()
if limitSC[sid] and CurTime() - limitSC[sid] < 10 then
slib.notify(eProtect.config["prefix"]..slib.getLang("eprotect", eProtect.config["language"], "sc-timeout", math.Round(10 - (CurTime() - limitSC[sid])), target:Nick()), ply)
return end
limitSC[sid] = CurTime()
data = screenshotRequested
elseif type == 2 then
data = idRequested
elseif type == 3 then
data = dataRequested
end
if data[target] then return end
data[target] = ply
net.Start("eP:Handeler")
net.WriteUInt(3, 3)
net.WriteUInt(type, 2)
net.WriteBool(false)
net.Send(target)
timer.Simple(10, function()
if !target or !ply then return end
if data[target] then
data[target] = nil
slib.notify(eProtect.config["prefix"]..slib.getLang("eprotect", eProtect.config["language"], "sc-failed", target:Nick()), ply)
end
end)
end
hook.Add("PlayerInitialSpawn", "eP:NetworkingQueuer", function(ply)
eProtect.queueNetworking(ply)
local sid = ply:SteamID()
if punished[sid] then punished[sid] = nil end
end)
local function verifyBannedAlt(ply, sid64, type)
sid64 = sid64 or ply:SteamID64()
local isBanned = slib.isBanned(sid64, function(banned, sid) if banned then if IsValid(ply) then slib.punish(ply, type, eProtect.config["prefix"]..slib.getLang("eprotect", eProtect.config["language"], "punished-alt")) end end end)
if isBanned then
slib.punish(ply, type, eProtect.config["prefix"]..slib.getLang("eprotect", eProtect.config["language"], "punished-alt"))
end
return isBanned
end
local settingConverter = { // Its reverted on clientside
[1] = 3,
[2] = 1,
[3] = 2
}
hook.Add("PlayerInitialSpawn", "eP:AutomaticChecks", function(ply)
local automatic_identifier = tonumber(eProtect.data.general["automatic-identifier"]) or 1
timer.Simple(1.5, function() -- Giving time to set usergroup.
if !IsValid(ply) or !ply:IsPlayer() or ply:IsBot() or eProtect.data.general["bypassgroup"][ply:GetUserGroup()] or eProtect.data.general["bypass_sids"][ply:SteamID64()] or eProtect.data.general["bypass_sids"][ply:SteamID()] then return end
if eProtect.data.general["block-vpn"] and !eProtect.data.general["bypass-vpn"][ply:GetUserGroup()] and !eProtect.data.general["bypass-vpn"][ply:SteamID64()] then
local ip = ""
for k,v in ipairs(string.ToTable(ply:IPAddress())) do
if v == ":" then break end
ip = ip..v
end
http.Fetch("https://proxycheck.io/v2/"..ip.."?vpn=1", function(result)
result = result and util.JSONToTable(result)
if result[ip] and result[ip].proxy == "yes" then
ply:Kick(eProtect.config["prefix"]..slib.getLang("eprotect", eProtect.config["language"], "vpn-blocked"))
end
end)
end
if automatic_identifier > 0 then
eProtect.correlateIP(ply, function(result)
local correlatedIPs = result
local plysid64, ownerplysid64 = ply:SteamID64(), ply:OwnerSteamID64()
local familyShare = ply:SteamID64() ~= ply:OwnerSteamID64()
local detections = !familyShare and !table.IsEmpty(correlatedIPs)
local altsDetected = {}
if detections then
local detect_type
detections = ""
if correlatedIPs and istable(correlatedIPs) and !table.IsEmpty(correlatedIPs) then
detect_type = "correlated-ip"
for k,v in ipairs(correlatedIPs) do
table.insert(altsDetected, v.sid64)
end
detections = slib.getLang("eprotect", eProtect.config["language"], "correlated-ip")
end
if familyShare then
detect_type = "family-share"
detections = detections == "" and slib.getLang("eprotect", eProtect.config["language"], "family-share") or detections.." "..slib.getLang("eprotect", eProtect.config["language"], "and").." "..slib.getLang("eprotect", eProtect.config["language"], "family-share")
table.insert(altsDetected, ownerplysid64)
end
if detections ~= "" then
local doneAction
if automatic_identifier == 1 then
for k, v in ipairs(player.GetAll()) do
if eProtect.data.general["notification-groups"][v:GetUserGroup()] then
slib.notify(eProtect.config["prefix"]..slib.getLang("eprotect", eProtect.config["language"], "auto-detected-alt", ply:Nick(), detections), v)
end
end
doneAction = true
elseif automatic_identifier == 2 then
for k,v in ipairs(altsDetected) do
doneAction = doneAction or verifyBannedAlt(ply, v, 1)
end
elseif automatic_identifier == 3 then
for k,v in ipairs(altsDetected) do
doneAction = doneAction or verifyBannedAlt(ply, v, 2)
end
end
if doneAction then
eProtect.logDetectionHandeler(ply, "alt-detection", slib.getLang("eprotect", eProtect.config["language"], detect_type), settingConverter[automatic_identifier], util.TableToJSON(altsDetected))
end
end
end
end)
end
end)
end)
hook.Add("PlayerSay", "eP:OpenMenu", function(ply, text, public)
if eProtect.config["command"] == string.lower(text) then
if !eProtect.hasPermission(ply) then
return text
end
eProtect.networkData(ply)
openMenu(ply)
return ""
end
end )
hook.Add("eP:PreNetworking", "eP:Restrictions", function(ply, netstring, len)
if !eProtect.canNetwork(ply, netstring) then return false end
if len >= 512000 then eProtect.logDetectionHandeler(ply, "net-overflow", netstring, 1) eProtect.punish(ply, 1, slib.getLang("eprotect", eProtect.config["language"], "kick-net-overflow")) return false end
end)
hook.Add("eP:PreHTTP", "eP:PreventBlockedHTTP", function(url)
if eProtect.data.general["httpfocusedurls"] then
return eProtect.data.general["httpfocusedurlsisblacklist"] == !tobool(eProtect.data.general["httpfocusedurls"][url])
end
end)
timer.Create("eP:SaveCache", eProtect.config["process-save-queue"], 0, function()
if !eProtect.saveQueue then return end
eProtect.saveData()
eProtect.saveQueue = nil
end)
net.Receive("eP:Handeler", function(len, ply)
local gateway = net.ReadBit()
local action = net.ReadUInt(2)
if tobool(gateway) then
if !eProtect.hasPermission(ply) then return end
if action == 0 then
local id = net.ReadUInt(1)
local page = net.ReadUInt(15)
local search = net.ReadString()
if id == 0 then
eProtect.requestHTTPLog(ply, page, search)
elseif id == 1 then
eProtect.requestDetectionLog(ply, page, search)
end
elseif action == 1 then
local specific = net.ReadUInt(3)
local strings = {}
for i=1,specific do
strings[i] = net.ReadString()
end
local statement = net.ReadUInt(2)
local data
if statement == 1 then
data = net.ReadBool()
elseif statement == 2 then
data = net.ReadInt(32)
elseif statement == 3 then
local chunk = net.ReadUInt(32)
data = net.ReadData(chunk)
data = util.Decompress(data)
data = util.JSONToTable(data)
local converted_tbl = {}
for k, v in pairs(data) do
if string.sub(k, 1, 6) == "sid64_" then
local sid64 = string.sub(k, 7, #k)
if util.SteamIDFrom64(sid64) != "STEAM_0:0:0" then
k = sid64
end
end
converted_tbl[k] = v
end
data = converted_tbl
end
local finaldestination = eProtect.data
for k,v in ipairs(strings) do
finaldestination = finaldestination[v]
if k >= (#strings - 1) then break end
end
finaldestination[strings[#strings]] = data
eProtect.saveQueue = true
eProtect.queueNetworking(nil, strings[1])
elseif action == 2 then
local subaction = net.ReadUInt(3)
local target = net.ReadUInt(14)
target = Entity(target)
if !IsValid(target) or !target:IsPlayer() then slib.notify(eProtect.config["prefix"]..slib.getLang("eprotect", eProtect.config["language"], "invalid-player"), ply) return end
local sid = target:SteamID()
if subaction == 1 then
eProtect.data.disabled[sid] = net.ReadBool()
eProtect.queueNetworking(nil, "disabled")
elseif subaction == 2 then
requestData(ply, target, net.ReadUInt(2))
elseif subaction == 3 then
local bit = net.ReadBit()
if tobool(bit) then
eProtect.correlateIP(target, function(result)
if !IsValid(target) or !IsValid(ply) then return end
if table.IsEmpty(result) then slib.notify(eProtect.config["prefix"]..slib.getLang("eprotect", eProtect.config["language"], "no-correlation", target:Nick()), ply) return end
result = util.TableToJSON(result)
result = util.Base64Encode(result)
net.Start("eP:Handeler")
net.WriteUInt(4,3)
net.WriteUInt(target:EntIndex(), 14)
net.WriteString(result)
net.WriteBit(1)
net.Send(ply)
end)
else
eProtect.showIPs(target, ply)
end
elseif subaction == 4 then
local sid64 = target:SteamID64()
local ownersid64 = target:OwnerSteamID64()
if sid64 == ownersid64 then
slib.notify(eProtect.config["prefix"]..slib.getLang("eprotect", eProtect.config["language"], "no-family-share", target:Nick()), ply)
else
slib.notify(eProtect.config["prefix"]..slib.getLang("eprotect", eProtect.config["language"], "has-family-share", target:Nick(), ownersid64), ply)
end
end
end
else
if action == 1 then
local subaction = net.ReadUInt(2)
local data
if subaction == 1 then
data = screenshotRequested
elseif subaction == 2 then
data = idRequested
elseif subaction == 3 then
data = dataRequested
end
if !data[ply] then if eProtect.config["punishMaliciousIntent"] then eProtect.punish(ply, 1, slib.getLang("eprotect", eProtect.config["language"], "kick-malicious-intent")) end return end
local target = data[ply]
data[ply] = nil
local id
if subaction == 3 then
local chunk = net.ReadUInt(32)
id = net.ReadData(chunk)
else
id = net.ReadString()
end
if !id or id == "" then
if eProtect.config["punishMaliciousIntent"] then
eProtect.punish(ply, 1, slib.getLang("eprotect", eProtect.config["language"], "kick-malicious-intent"))
end
return end
net.Start("eP:Handeler")
net.WriteUInt(3, 3)
net.WriteUInt(subaction, 2)
net.WriteUInt(ply:EntIndex(), 14)
net.WriteBool(true)
if subaction == 3 then
local chunk = #id
net.WriteUInt(chunk, 32)
net.WriteData(id, chunk)
else
net.WriteString(id)
end
net.Send(target)
elseif action == 2 then
local menu = net.ReadUInt(2)
local menus = {
[1] = "Loki",
[2] = "Exploit City"
}
eProtect.logDetectionHandeler(ply, "exploit-menu", menus[menu], 2)
eProtect.punish(ply, 2, slib.getLang("eprotect", eProtect.config["language"], "banned-exploit-menu"))
end
end
end)
hook.Add("eP:SQLConnected", "eP:TransferOldIPs", function()
local files = file.Find("eprotect/ips/*", "DATA")
for k,v in pairs(files) do
local sid64 = string.gsub(v, ".json", "")
local ips = file.Read("eprotect/ips/"..v, "DATA")
ips = util.JSONToTable(ips)
if !ips then continue end
for ip, data in pairs(ips) do
eProtect.registerIP(sid64, ip, data[1], data[2])
end
file.Delete("eprotect/ips/"..v)
end
file.Delete("eprotect/ips")
local save = false
if eProtect.data.httpLogging then
for url, v in pairs(eProtect.data.httpLogging) do
eProtect.logHTTP(url, v.type, v.called)
end
eProtect.data.httpLogging = nil
save = true
end
if eProtect.data.punishmentLogging then
for i = #eProtect.data.punishmentLogging, 1, -1 do
local data = eProtect.data.punishmentLogging[i]
eProtect.logDetection(data.ply, "", data.reason, data.info, data.type)
end
eProtect.data.punishmentLogging = nil
save = true
end
if save then
eProtect.saveData()
end
end)
eProtect.dataVerification()

View File

@@ -0,0 +1,67 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
eProtect = eProtect or {}
eProtect.overrides = eProtect.overrides or {}
if !eProtect.overrides["net.Incoming"] then
eProtect.overrides["net.Incoming"] = true
function net.Incoming( len, client )
local i = net.ReadHeader()
local strName = util.NetworkIDToString( i )
if ( !strName ) then return end
local func = net.Receivers[ strName:lower() ]
if ( !func ) then return end
len = len - 16
local pre = hook.Run("eP:PreNetworking", client, strName, len)
if pre == false then return end
func( len, client )
hook.Run("eP:PostNetworking", client, strName, len)
end
end
if !eProtect.config["disablehttplogging"] and ((!VC and !XEON and !mLib) or eProtect.config["ignoreDRM"]) then
if !eProtect.overrides["http.Fetch"] then
eProtect.overrides["http.Fetch"] = true
local oldFetch = http.Fetch
function http.Fetch(...)
local args = {...}
local result = hook.Run("eP:PreHTTP", args[1], "fetch")
if result == false then return end
oldFetch(...)
hook.Run("eP:PostHTTP", args[1], "fetch")
end
end
if !eProtect.overrides["http.Post"] then
eProtect.overrides["http.Post"] = true
local oldPost = http.Post
function http.Post(...)
local args = {...}
local result = hook.Run("eP:PreHTTP", args[1], "post")
if result == false then return end
oldPost(...)
hook.Run("eP:PostHTTP", args[1], "post")
end
end
end

View File

@@ -0,0 +1,250 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local query, db
local escape_str = function(str) return SQLStr(str, true) end
local create_queries = {
[1] = [[CREATE TABLE IF NOT EXISTS eprotect_ips(
id INTEGER PRIMARY KEY %s,
sid64 CHAR(17),
ip CHAR(15),
country CHAR(3),
logged_time INTEGER DEFAULT 0
)]],
[2] = [[CREATE TABLE IF NOT EXISTS eprotect_detections(
id INTEGER PRIMARY KEY %s,
name CHAR(32),
sid64 CHAR(17),
reason CHAR(32),
info CHAR(32),
type INTEGER DEFAULT 0,
logged_time INTEGER DEFAULT 0,
additional_info TEXT NULL
)]],
[3] = [[CREATE TABLE IF NOT EXISTS eprotect_http(
id INTEGER PRIMARY KEY %s,
link CHAR(64),
type CHAR(6),
called INTEGER DEFAULT 0
)]],
[4] = [[ALTER TABLE eprotect_detections
ADD additional_info TEXT NULL]]
}
local function makeTables()
for i = 1, #create_queries do
query(string.format(create_queries[i], eProtect.config["storage_type"] == "sql_local" and "AUTOINCREMENT" or "AUTO_INCREMENT"))
end
end
if eProtect.config["storage_type"] == "mysql" then
require("mysqloo")
query = function() end
local dbinfo = eProtect.config["mysql_info"]
db = mysqloo.connect(dbinfo.host, dbinfo.username, dbinfo.password, dbinfo.database, dbinfo.port)
function db:onConnected()
print(eProtect.config["prefix"]..slib.getLang("eprotect", eProtect.config["language"], "mysql_successfull"))
query = function(str, func)
local q = db:query(str)
q.onSuccess = function(_, data)
if func then
func(data)
end
end
q.onError = function(_, err) end
q:start()
end
escape_str = function(str) return db:escape(tostring(str)) end
makeTables()
hook.Run("eP:SQLConnected")
end
function db:onConnectionFailed(err)
print(eProtect.config["prefix"]..slib.getLang("eprotect", eProtect.config["language"], "mysql_failed"))
print( "Error:", err )
end
db:connect()
else
local oldFunc = sql.Query
query = function(str, func)
local result = oldFunc(str)
if func then
func(result)
end
end
makeTables()
end
local function handleCallbacksCorrelation(parent_tbl, correlated, callback)
for k,v in ipairs(parent_tbl) do
if !v then return end
end
if !callback then return end
callback(correlated or {})
end
eProtect.correlateIP = function(target, callback)
if !IsValid(target) then return end
local sid64, tbl = target:SteamID64(), {}
query("SELECT * FROM eprotect_ips WHERE sid64 = '"..sid64.."'", function(result)
if result and result[1] then
local parent_tbl = {}
for k, v in ipairs(result) do
parent_tbl[k] = false
end
for key, plydata in ipairs(result) do
query("SELECT * FROM eprotect_ips WHERE ip = '"..(plydata.ip).."'", function(result)
if result and result[1] then
for k,v in ipairs(result) do
if v.sid64 == sid64 then continue end
table.insert(tbl, {sid64 = v.sid64, ip = v.ip})
end
end
parent_tbl[key] = true
handleCallbacksCorrelation(parent_tbl, tbl, callback)
end)
end
end
end)
end
eProtect.showIPs = function(target, ply)
local sid64 = target:SteamID64()
query("SELECT * FROM eprotect_ips WHERE sid64 = '"..sid64.."'", function(result)
if !IsValid(target) or !IsValid(ply) or !result or !result[1] then return end
result = util.TableToJSON(result)
result = util.Base64Encode(result)
net.Start("eP:Handeler")
net.WriteUInt(4,3)
net.WriteUInt(target:EntIndex(), 14)
net.WriteString(result)
net.WriteBit(0)
net.Send(ply)
end)
end
eProtect.registerIP = function(sid64, ip, country, time)
query("SELECT * FROM eprotect_ips WHERE ip = '"..ip.."' AND sid64 = '"..sid64.."'", function(result)
if result and result[1] then return end
query(string.format("INSERT INTO eprotect_ips(ip, sid64, country, logged_time) VALUES('%s', %s, '%s', %s)", escape_str(ip), sid64, escape_str(country), time or os.time()))
end)
end
eProtect.logDetection = function(name, sid64, reason, info, type, additional_info)
additional_info = additional_info or ""
query(string.format("INSERT INTO eprotect_detections(name, sid64, reason, info, type, logged_time, additional_info) VALUES('%s', '%s', '%s', '%s', '%s', %s, '%s')", escape_str(name), escape_str(sid64), escape_str(reason), escape_str(info), escape_str(type), os.time(), escape_str(additional_info)))
end
eProtect.logHTTP = function(link, type, called)
link = escape_str(link)
query("SELECT * FROM eprotect_http WHERE link = '"..link.."'", function(result)
if result and result[1] then
query("UPDATE eprotect_http SET called = "..(result[1].called + 1).." WHERE link = '"..link.."'")
return end
query(string.format("INSERT INTO eprotect_http(link, type, called) VALUES('%s', '%s', "..(tonumber(called) or 1)..")", link, escape_str(type)))
end)
end
local function networkData(ply, data, id)
local compressed = util.Compress(util.TableToJSON(data))
net.Start("eP:Handeler")
net.WriteUInt(5, 3)
net.WriteUInt(id, 1)
net.WriteUInt(#compressed, 32)
net.WriteData(compressed, #compressed)
net.Send(ply)
end
local http_cd, detection_cd = {}, {}
eProtect.requestHTTPLog = function(ply, page, search)
if http_cd[ply] and http_cd[ply] > CurTime() then return end
http_cd[ply] = CurTime() + .1
search = search ~= "" and escape_str(search) or nil
local perpage, pageCount = 20, 1
local start = perpage * ((tonumber(page) or 1) - 1)
local data = {}
local search_str = search and " WHERE (link LIKE '%"..search.."%')" or ""
query("SELECT COUNT(id) FROM eprotect_http"..search_str, function(pageresult)
if pageresult and pageresult[1] and pageresult[1]["COUNT(id)"] then
data.pageCount = math.max(math.ceil((pageresult[1]["COUNT(id)"] or 0) / perpage), 1)
end
data.page = page
query("SELECT * FROM eprotect_http "..search_str.." LIMIT "..start..", "..perpage, function(result)
data.result = result
networkData(ply, data, 0)
end)
end)
end
eProtect.requestDetectionLog = function(ply, page, search)
if detection_cd[ply] and detection_cd[ply] > CurTime() then return end
detection_cd[ply] = CurTime() + .1
search = search ~= "" and escape_str(search) or nil
local perpage, pageCount = 20, 1
local start = perpage * ((tonumber(page) or 1) - 1)
local data = {}
local search_str = search and " WHERE (sid64 LIKE '%"..search.."%' OR name LIKE '%"..search.."%') " or ""
query("SELECT COUNT(id) FROM eprotect_detections"..search_str, function(pageresult)
if pageresult and pageresult[1] and pageresult[1]["COUNT(id)"] then
data.pageCount = math.max(math.ceil((pageresult[1]["COUNT(id)"] or 0) / perpage), 1)
end
data.page = page
query("SELECT * FROM eprotect_detections"..search_str.." ORDER BY id DESC LIMIT "..start..", "..perpage, function(result)
data.result = result
networkData(ply, data, 1)
end)
end)
end
if eProtect.config["storage_type"] == "sql_local" then
hook.Run("eP:SQLConnected")
end