local function HTML_Option( value, text, selected ) if( selected == true ) then return [[]] else return [["]] end end local function ShowUsersTable() local Content = "

Users

" 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 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 local function HTML_Select_Group( name, defaultValue ) Groups = "" for I=0, GroupsIni:GetNumKeys() - 1 do Groups = Groups .. HTML_Option(GroupsIni:KeyName(I), GroupsIni:KeyName(I), defaultValue == GroupsIni:KeyName(I) ) end return [[]] end local function AddPlayers( Request ) local Content = "

Add or change Players

" 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 SendMessageSuccess( Player, "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 .. [[

Player:
Group: ]] .. HTML_Select_Group("AddGroup", GroupsIni:KeyName(0) ) .. [[
]] 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() return Content end