Skip to content

Commit

Permalink
admin: Remove execute code functionality (PR #442)
Browse files Browse the repository at this point in the history
  • Loading branch information
srslyyyy committed Jul 24, 2023
1 parent bf3995a commit 507a049
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 56 deletions.
15 changes: 0 additions & 15 deletions [admin]/admin/client/admin_client.lua
Expand Up @@ -124,21 +124,6 @@ function getWeatherNameFromID ( weather )
return iif ( aWeathers[weather], aWeathers[weather], "Unknown" )
end
function aExecute ( action, echo )
local result = loadstring("return " .. action)()
if ( echo == true ) then
local restring
if ( type ( result ) == "table" ) then
restring = "Table ("..unpack ( result )..")"
elseif ( type ( result ) == "userdata" ) then
restring = "Element ("..getElementType ( result )..")"
else
restring = tostring ( result )
end
outputChatBox( "Command executed! Result: " ..restring, 0, 0, 255 )
end
end
function iif ( cond, arg1, arg2 )
if ( cond ) then
return arg1
Expand Down
17 changes: 2 additions & 15 deletions [admin]/admin/client/gui/admin_main.lua
Expand Up @@ -212,12 +212,7 @@ y=y+B aTab1.VehicleHealth = guiCreateLabel ( 0.26, y, 0.25, 0.04, "Vehicle Heal
aTab2.LogLine3 = guiCreateLabel ( 0.41, 0.87, 0.50, 0.03, "", true, aTab2.Tab )
aTab2.LogLine4 = guiCreateLabel ( 0.41, 0.90, 0.50, 0.03, "", true, aTab2.Tab )
aTab2.LogLine5 = guiCreateLabel ( 0.41, 0.93, 0.50, 0.03, "", true, aTab2.Tab )
guiCreateLabel ( 0.41, 0.65, 0.50, 0.04, "Execute Command:", true, aTab2.Tab )
aTab2.Command = guiCreateEdit ( 0.41, 0.70, 0.40, 0.055, "", true, aTab2.Tab )
aTab2.ExecuteClient = guiCreateButton ( 0.82, 0.70, 0.16, 0.035, "Client", true, aTab2.Tab, "execute" )
aTab2.ExecuteServer = guiCreateButton ( 0.82, 0.736, 0.16, 0.035, "Server", true, aTab2.Tab, "execute" )
aTab2.ExecuteAdvanced = guiCreateLabel ( 0.45, 0.71, 0.50, 0.04, "For advanced users only.", true, aTab2.Tab )
guiLabelSetColor ( aTab2.ExecuteAdvanced, 255, 0, 0 )
aLogLines = 1
createMapTab()
Expand Down Expand Up @@ -1075,16 +1070,8 @@ function aClientClick ( button )
elseif ( source == aTab2.ResourceRefresh or source == aTab2.ResourceInclMaps ) then
guiGridListClear ( aTab2.ResourceList )
triggerServerEvent ( "aSync", localPlayer, "resources" )
elseif ( source == aTab2.ExecuteClient ) then
if ( ( guiGetText ( aTab2.Command ) ) and ( guiGetText ( aTab2.Command ) ~= "" ) ) then aExecute ( guiGetText ( aTab2.Command ), true ) end
elseif ( source == aTab2.ExecuteServer ) then
if ( ( guiGetText ( aTab2.Command ) ) and ( guiGetText ( aTab2.Command ) ~= "" ) ) then triggerServerEvent ( "aExecute", localPlayer, guiGetText ( aTab2.Command ), true ) end
elseif ( source == aTab2.Command ) then
guiSetVisible ( aTab2.ExecuteAdvanced, false )
elseif ( source == aTab2.ExecuteAdvanced ) then
guiSetVisible ( aTab2.ExecuteAdvanced, false )
end
-- TAB 3, WORLD
elseif ( getElementParent ( source ) == aTab3.Tab ) then
if ( source == aTab3.SetGameType ) then aInputBox ( "Game Type", "Enter game type:", "", "setGameType" )
Expand Down
4 changes: 0 additions & 4 deletions [admin]/admin/conf/ACL.xml
Expand Up @@ -56,7 +56,6 @@
<right name="command.stopall" access="false" />
<right name="command.delete" access="true" />
<right name="command.restart" access="true" />
<right name="command.execute" access="true" />
<!--Server related-->
<right name="command.setpassword" access="true" />
<right name="command.setwelcome" access="true" />
Expand Down Expand Up @@ -138,7 +137,6 @@
<right name="command.stopall" access="false" />
<right name="command.delete" access="false" />
<right name="command.restart" access="true" />
<right name="command.execute" access="false" />
<!--Server related-->
<right name="command.setpassword" access="true" />
<right name="command.setwelcome" access="true" />
Expand Down Expand Up @@ -219,7 +217,6 @@
<right name="command.stopall" access="false" />
<right name="command.delete" access="false" />
<right name="command.restart" access="false" />
<right name="command.execute" access="false" />
<!--Server related-->
<right name="command.setpassword" access="false" />
<right name="command.setwelcome" access="false" />
Expand Down Expand Up @@ -300,7 +297,6 @@
<right name="command.stopall" access="false" />
<right name="command.delete" access="false" />
<right name="command.restart" access="false" />
<right name="command.execute" access="false" />
<!--Server related-->
<right name="command.setpassword" access="false" />
<right name="command.setwelcome" access="false" />
Expand Down
22 changes: 0 additions & 22 deletions [admin]/admin/server/admin_server.lua
Expand Up @@ -1607,28 +1607,6 @@ addEventHandler ( "aBans", root, function ( action, data, arg1, arg2, arg3 )
return false
end )
addEvent ( "aExecute", true )
addEventHandler ( "aExecute", root, function ( action, echo )
if checkClient( "command.execute", source, 'aExecute', action ) then return end
if ( hasObjectPermissionTo ( client or source, "command.execute" ) ) then
local result = loadstring("return " .. action)()
if ( echo == true ) then
local restring = ""
if ( type ( result ) == "table" ) then
for k,v in pairs ( result ) do restring = restring..tostring ( v )..", " end
restring = string.sub(restring,1,-3)
restring = "Table ("..restring..")"
elseif ( type ( result ) == "userdata" ) then
restring = "Element ("..getElementType ( result )..")"
else
restring = tostring ( result )
end
outputChatBox( "Command executed! Result: " ..restring, source, 0, 0, 255 )
end
outputServerLog ( "ADMIN: "..getAdminNameForLog ( source ).." executed command: "..action )
end
end )
addEvent ( "aAdminChat", true )
addEventHandler ( "aAdminChat", root, function ( chat )
if checkClient( true, source, 'aAdminChat' ) then return end
Expand Down

0 comments on commit 507a049

Please sign in to comment.