From 12906c026d414c752d3c0ba9481f425b24b29c67 Mon Sep 17 00:00:00 2001 From: faketruth Date: Mon, 20 Aug 2012 12:20:20 +0000 Subject: Moved files used by MCServer to a special MCServer folder git-svn-id: http://mc-server.googlecode.com/svn/trunk@763 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- MCServer/Plugins/Core/web_whitelist.lua | 79 +++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 MCServer/Plugins/Core/web_whitelist.lua (limited to 'MCServer/Plugins/Core/web_whitelist.lua') diff --git a/MCServer/Plugins/Core/web_whitelist.lua b/MCServer/Plugins/Core/web_whitelist.lua new file mode 100644 index 000000000..2c9ddb953 --- /dev/null +++ b/MCServer/Plugins/Core/web_whitelist.lua @@ -0,0 +1,79 @@ +local function HTMLDeleteButton( name ) + return "
" +end + +function HandleRequest_WhiteList( Request ) + local UpdateMessage = "" + if( Request.PostParams["whitelist-add"] ~= nil ) then + local PlayerName = Request.PostParams["whitelist-add"] + + if( WhiteListIni:GetValueB("WhiteList", PlayerName, false) == true ) then + UpdateMessage = "".. PlayerName.." is already on the whitelist" + else + WhiteListIni:SetValueB("WhiteList", PlayerName, true ) + UpdateMessage = "Added " .. PlayerName .. " to whitelist." + WhiteListIni:WriteFile() + end + elseif( Request.PostParams["whitelist-delete"] ~= nil ) then + local PlayerName = Request.PostParams["whitelist-delete"] + WhiteListIni:DeleteValue( "WhiteList", PlayerName ) + UpdateMessage = "Removed " .. PlayerName .. " from whitelist." + WhiteListIni:WriteFile() + elseif( Request.PostParams["whitelist-reload"] ~= nil ) then + WhiteListIni:Erase() -- Empty entire loaded ini first, otherwise weird shit goes down + WhiteListIni:ReadFile() + UpdateMessage = "Loaded from disk" + elseif( Request.Params["whitelist-setenable"] ~= nil ) then + local Enabled = Request.Params["whitelist-setenable"] + local CreateNewValue = false + if( WhiteListIni:FindValue( WhiteListIni:FindKey("WhiteListSettings"), "WhiteListOn" ) == cIniFile.noID ) then -- Find out whether the value is in the ini + CreateNewValue = true + end + + if( Enabled == "1" ) then + WhiteListIni:SetValueB("WhiteListSettings", "WhiteListOn", true, CreateNewValue ) + else + WhiteListIni:SetValueB("WhiteListSettings", "WhiteListOn", false, CreateNewValue ) + end + WhiteListIni:WriteFile() + end + + + local Content = "" + + local WhiteListEnabled = WhiteListIni:GetValueB("WhiteListSettings", "WhiteListOn", false) + if( WhiteListEnabled == false ) then + Content = Content .. "

Whitelist is currently disabled! Click here to enable.

" + end + + + Content = Content .. "

Whitelisted players

" + Content = Content .. "" + local KeyNum = WhiteListIni:FindKey("WhiteList") + local NumValues = WhiteListIni:GetNumValues(KeyNum) + if( NumValues > 0 ) then + for Num = 0, NumValues-1 do + if( WhiteListIni:GetValue(KeyNum, Num, "0") == "1" ) then + local PlayerName = WhiteListIni:GetValueName(KeyNum, Num ) + Content = Content .. "" + end + end + else + Content = Content .. "" + end + Content = Content .. "
" .. PlayerName .. "" .. HTMLDeleteButton( PlayerName ) .. "
None
" + Content = Content .. "

Add player to whitelist

" + Content = Content .. "
" + Content = Content .. "" + Content = Content .. "
" + Content = Content .. "
" + Content = Content .. "" + Content = Content .. "
" + Content = Content .. "
"..UpdateMessage + + if( WhiteListEnabled == true ) then + Content = Content .. "

Whitelist is currently enabled, click here to disable.

" + end + + return Content +end \ No newline at end of file -- cgit v1.2.3