summaryrefslogtreecommitdiffstats
path: root/MCServer/Plugins/Core/web_permissions.lua
diff options
context:
space:
mode:
authornielsbreu@gmail.com <nielsbreu@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-03-24 16:44:44 +0100
committernielsbreu@gmail.com <nielsbreu@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-03-24 16:44:44 +0100
commit03e29802cdde309f3734ab7b6dd17ab60b9a359f (patch)
treebcc0712b29b55fa6ede3df3757f14e0c428b8af4 /MCServer/Plugins/Core/web_permissions.lua
parentFixed a problem in Linux handling of ListenThread. (diff)
downloadcuberite-03e29802cdde309f3734ab7b6dd17ab60b9a359f.tar
cuberite-03e29802cdde309f3734ab7b6dd17ab60b9a359f.tar.gz
cuberite-03e29802cdde309f3734ab7b6dd17ab60b9a359f.tar.bz2
cuberite-03e29802cdde309f3734ab7b6dd17ab60b9a359f.tar.lz
cuberite-03e29802cdde309f3734ab7b6dd17ab60b9a359f.tar.xz
cuberite-03e29802cdde309f3734ab7b6dd17ab60b9a359f.tar.zst
cuberite-03e29802cdde309f3734ab7b6dd17ab60b9a359f.zip
Diffstat (limited to 'MCServer/Plugins/Core/web_permissions.lua')
-rw-r--r--MCServer/Plugins/Core/web_permissions.lua56
1 files changed, 46 insertions, 10 deletions
diff --git a/MCServer/Plugins/Core/web_permissions.lua b/MCServer/Plugins/Core/web_permissions.lua
index 4fce502e1..962078bb2 100644
--- a/MCServer/Plugins/Core/web_permissions.lua
+++ b/MCServer/Plugins/Core/web_permissions.lua
@@ -1,11 +1,6 @@
local function ShowUsersTable()
local Content = "<h4>Users</h4>"
- local UsersIni = cIniFile("users.ini")
- if( UsersIni:ReadFile() == false ) then
- return "Could not read users.ini!"
- end
-
local NumUsers = UsersIni:GetNumKeys()
Content = Content .. "<table>"
@@ -36,11 +31,6 @@ end
local function ShowGroupsTable()
local Content = "<h4>Groups</h4>"
- local GroupsIni = cIniFile("groups.ini")
- if( GroupsIni:ReadFile() == false ) then
- return "Could not read groups.ini!"
- end
-
local NumGroups = GroupsIni:GetNumKeys()
Content = Content .. "<table>"
@@ -69,9 +59,55 @@ local function ShowGroupsTable()
return Content
end
+local function AddPlayers( Request )
+ local Content = "<h4>Add Players</h4>"
+ if( Request.PostParams["AddPlayerToGroup"] ~= nil ) then
+ if Request.PostParams["AddPlayer"] ~= "" then
+ if Request.PostParams["AddGroups"] ~= "" then
+ if GroupsIni:FindKey(Request.PostParams["AddGroup"]) == -1 then
+ return "Group does not exist"
+ end
+ UsersIni:DeleteKey(Request.PostParams["AddPlayer"])
+ UsersIni:GetValueSet(Request.PostParams["AddPlayer"], "Groups", Request.PostParams["AddGroup"])
+ UsersIni:WriteFile()
+ local loopPlayers = function( Player )
+ if Player:GetName() == Request.PostParams["AddPlayer"] then
+ Player:SendMessage( cChatColor.Green .. "You were moved to group " .. Request.PostParams["AddGroup"] )
+ Player:LoadPermissionsFromDisk()
+ end
+ end
+ local loopWorlds = function ( World )
+ World:ForEachPlayer( loopPlayers )
+ end
+ cRoot:Get():ForEachWorld( loopWorlds )
+ end
+ end
+ end
+ Content = Content .. [[
+ <form method="POST">
+ <table>
+ <tr><td style="width: 20%;">Player:</td>
+ <td><input type="text" name="AddPlayer" value=""></td></tr><br>
+ <tr><td style="width: 20%;">Group:</td>
+ <td><input type="text" name="AddGroup" value=""></td></tr>
+ </table>
+ <input type="submit" value="Add Player" name="AddPlayerToGroup">]]
+ return Content
+end
+
function HandleRequest_Permissions( Request )
+ GroupsIni = cIniFile("groups.ini")
+ if( GroupsIni:ReadFile() == false ) then
+ return "Could not read groups.ini!"
+ end
+ UsersIni = cIniFile("users.ini")
+ if( UsersIni:ReadFile() == false ) then
+ return "Could not read users.ini!"
+ end
+
local Content = ""
+ Content = Content .. AddPlayers( Request )
Content = Content .. ShowGroupsTable()
Content = Content .. ShowUsersTable()