From 9dfa0f1f15c413540e932a04e94419a8a3b37dcf Mon Sep 17 00:00:00 2001 From: faketruth Date: Mon, 30 Jan 2012 16:47:26 +0000 Subject: Added a WebAdmin interface to view users their groups, and the permissions of groups. cChunk::Tick did an assertion in cCSLock, I used a cCSUnlock to fix it, but not sure if this is correct. git-svn-id: http://mc-server.googlecode.com/svn/trunk@194 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- Plugins/Core/main.lua | 3 +- Plugins/Core/web_permissions.lua | 79 ++++++++++++++++++++++++++++++++++++++++ Plugins/Core/web_playerlist.lua | 17 +++++---- 3 files changed, 91 insertions(+), 8 deletions(-) create mode 100644 Plugins/Core/web_permissions.lua (limited to 'Plugins') diff --git a/Plugins/Core/main.lua b/Plugins/Core/main.lua index 90f86938f..d8fadaad9 100644 --- a/Plugins/Core/main.lua +++ b/Plugins/Core/main.lua @@ -129,9 +129,10 @@ function Initialize( Plugin ) local WebPlugin = Plugin:CreateWebPlugin() WebPlugin:SetName( Plugin:GetName() ) + WebPlugin:AddTab( "Playerlist", HandleRequest_PlayerList ) WebPlugin:AddTab( "Whitelist", HandleRequest_WhiteList ) WebPlugin:AddTab( "Reload", HandleRequest_Reload ) - WebPlugin:AddTab( "Playerlist", HandleRequest_PlayerList ) + WebPlugin:AddTab( "Permissions", HandleRequest_Permissions ) LOG( "Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion() ) return true diff --git a/Plugins/Core/web_permissions.lua b/Plugins/Core/web_permissions.lua new file mode 100644 index 000000000..5c7527056 --- /dev/null +++ b/Plugins/Core/web_permissions.lua @@ -0,0 +1,79 @@ +local function ShowUsersTable() + local Content = "

Users

" + + local UsersIni = cIniFile("users.ini") + if( UsersIni:ReadFile() == false ) then + return "Could not read users.ini!" + end + + local NumUsers = UsersIni:GetNumKeys() + + Content = Content .. "" + + if( NumUsers > 0 ) then + Content = Content .. "" + + for i=0, NumUsers-1 do + local UserName = UsersIni:GetKeyName( i ) + + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + end + else + Content = Content .. "" + end + Content = Content .. "
UserGroups
" .. i .. "." .. UserName .. "" + Content = Content .. UsersIni:GetValue( UserName, "Groups", "-" ) + Content = Content .. "
None
" + + + return Content +end + +local function ShowGroupsTable() + local Content = "

Groups

" + + local GroupsIni = cIniFile("groups.ini") + if( GroupsIni:ReadFile() == false ) then + return "Could not read groups.ini!" + end + + local NumGroups = GroupsIni:GetNumKeys() + + Content = Content .. "" + if( NumGroups > 0 ) then + Content = Content .. "" + + for i=0, NumGroups-1 do + local GroupName = GroupsIni:GetKeyName( i ) + + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + end + else + Content = Content .. "" + end + Content = Content .. "
NamePermissionsColor
" .. i .. "." .. GroupName .. "" + Content = Content .. GroupsIni:GetValue( GroupName, "Permissions", "-" ) + Content = Content .. "" + Content = Content .. GroupsIni:GetValue( GroupName, "Color", "-" ) + Content = Content .. "
None
" + + return Content +end + +function HandleRequest_Permissions( Request ) + local Content = "" + + Content = Content .. ShowGroupsTable() + Content = Content .. ShowUsersTable() + + return Content +end \ No newline at end of file diff --git a/Plugins/Core/web_playerlist.lua b/Plugins/Core/web_playerlist.lua index eeb9369c1..205306ba8 100644 --- a/Plugins/Core/web_playerlist.lua +++ b/Plugins/Core/web_playerlist.lua @@ -18,14 +18,17 @@ function HandleRequest_PlayerList( Request ) local PlayerList = World:GetAllPlayers() - for i, Player in ipairs( PlayerList ) do - Content = Content .. "" - Content = Content .. "" .. i .. "." - Content = Content .. "" .. Player:GetName() .. "" - Content = Content .. "Kick" - Content = Content .. "" + if( #PlayerList > 0 ) then + for i, Player in ipairs( PlayerList ) do + Content = Content .. "" + Content = Content .. "" .. i .. "." + Content = Content .. "" .. Player:GetName() .. "" + Content = Content .. "Kick" + Content = Content .. "" + end + else + Content = Content .. "None" end - Content = Content .. "" Content = Content .. "
" return Content -- cgit v1.2.3