Fixed society vulnerabilities

This commit is contained in:
ElPumpo
2019-04-02 22:36:25 +02:00
parent 7ac3744394
commit b3e7209f01
3 changed files with 71 additions and 73 deletions
+13 -33
View File
File diff suppressed because one or more lines are too long
+3 -3
View File
@@ -1,5 +1,5 @@
Config = {}
Config = {}
Config.Locale = 'fr'
Config.Locale = 'fr'
Config.EnableESXIdentity = false
Config.MaxSalary = 3500
Config.MaxSalary = 3500
+55 -37
View File
@@ -1,6 +1,6 @@
ESX = nil
Jobs = {}
RegisteredSocieties = {}
ESX = nil
local Jobs = {}
local RegisteredSocieties = {}
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
@@ -95,14 +95,12 @@ AddEventHandler('esx_society:depositMoney', function(society, amount)
end
if amount > 0 and xPlayer.getMoney() >= amount then
TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function(account)
xPlayer.removeMoney(amount)
account.addMoney(amount)
end)
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('have_deposited', ESX.Math.GroupDigits(amount)))
else
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('invalid_amount'))
end
@@ -246,50 +244,70 @@ end)
ESX.RegisterServerCallback('esx_society:setJob', function(source, cb, identifier, job, grade, type)
local xPlayer = ESX.GetPlayerFromId(source)
local xTarget = ESX.GetPlayerFromIdentifier(identifier)
local isBoss = xPlayer.job.grade_name == 'boss'
if xTarget then
xTarget.setJob(job, grade)
if isBoss then
local xTarget = ESX.GetPlayerFromIdentifier(identifier)
if type == 'hire' then
TriggerClientEvent('esx:showNotification', xTarget.source, _U('you_have_been_hired', job))
elseif type == 'promote' then
TriggerClientEvent('esx:showNotification', xTarget.source, _U('you_have_been_promoted'))
elseif type == 'fire' then
TriggerClientEvent('esx:showNotification', xTarget.source, _U('you_have_been_fired', xTarget.getJob().label))
end
if xTarget then
xTarget.setJob(job, grade)
if type == 'hire' then
TriggerClientEvent('esx:showNotification', xTarget.source, _U('you_have_been_hired', job))
elseif type == 'promote' then
TriggerClientEvent('esx:showNotification', xTarget.source, _U('you_have_been_promoted'))
elseif type == 'fire' then
TriggerClientEvent('esx:showNotification', xTarget.source, _U('you_have_been_fired', xTarget.getJob().label))
end
cb()
else
MySQL.Async.execute('UPDATE users SET job = @job, job_grade = @job_grade WHERE identifier = @identifier', {
['@job'] = job,
['@job_grade'] = grade,
['@identifier'] = identifier
}, function(rowsChanged)
cb()
end)
else
MySQL.Async.execute('UPDATE users SET job = @job, job_grade = @job_grade WHERE identifier = @identifier', {
['@job'] = job,
['@job_grade'] = grade,
['@identifier'] = identifier
}, function(rowsChanged)
cb()
end)
end
else
print(('esx_society: %s attempted to setJob'):format(xPlayer.identifier))
cb()
end
end)
ESX.RegisterServerCallback('esx_society:setJobSalary', function(source, cb, job, grade, salary)
MySQL.Async.execute('UPDATE job_grades SET salary = @salary WHERE job_name = @job_name AND grade = @grade', {
['@salary'] = salary,
['@job_name'] = job,
['@grade'] = grade
}, function(rowsChanged)
Jobs[job].grades[tostring(grade)].salary = salary
local xPlayers = ESX.GetPlayers()
local isBoss = isPlayerBoss(source, job)
local identifier = GetPlayerIdentifier(source, 0)
for i=1, #xPlayers, 1 do
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
if isBoss then
if salary <= Config.MaxSalary then
MySQL.Async.execute('UPDATE job_grades SET salary = @salary WHERE job_name = @job_name AND grade = @grade', {
['@salary'] = salary,
['@job_name'] = job,
['@grade'] = grade
}, function(rowsChanged)
Jobs[job].grades[tostring(grade)].salary = salary
local xPlayers = ESX.GetPlayers()
if xPlayer.job.name == job and xPlayer.job.grade == grade then
xPlayer.setJob(job, grade)
end
for i=1, #xPlayers, 1 do
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
if xPlayer.job.name == job and xPlayer.job.grade == grade then
xPlayer.setJob(job, grade)
end
end
cb()
end)
else
print(('esx_society: %s attempted to setJobSalary over config limit!'):format(identifier))
cb()
end
else
print(('esx_society: %s attempted to setJobSalary'):format(identifier))
cb()
end)
end
end)
ESX.RegisterServerCallback('esx_society:getOnlinePlayers', function(source, cb)