From 7c3f98e4ed7a0b7239e082731fc8ead71d4ba2d0 Mon Sep 17 00:00:00 2001 From: faketruth Date: Wed, 1 Feb 2012 00:15:59 +0000 Subject: Forgot a file git-svn-id: http://mc-server.googlecode.com/svn/trunk@205 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- Plugins/Core/web_manageplugins.lua | 93 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 Plugins/Core/web_manageplugins.lua diff --git a/Plugins/Core/web_manageplugins.lua b/Plugins/Core/web_manageplugins.lua new file mode 100644 index 000000000..3030efc7a --- /dev/null +++ b/Plugins/Core/web_manageplugins.lua @@ -0,0 +1,93 @@ +local function Button_RemovePlugin( Name, Index ) + return "
" +end + +local function HandlePluginListChanges( Request, SettingsIni ) + local Content = "" + if( Request.PostParams["RemovePlugin"] ~= nil + and Request.PostParams["PluginName"] ~= nil + and Request.PostParams["PluginIndex"] ~= nil ) then -- Removing a plugin + + local KeyIdx = SettingsIni:FindKey("Plugins") + local PluginIdx = Request.PostParams["PluginIndex"] + + local PluginName = SettingsIni:GetValue( KeyIdx, PluginIdx ) + if( (PluginName == Request.PostParams["PluginName"]) and (SettingsIni:DeleteValueByID( KeyIdx, PluginIdx ) == true) ) then + SettingsIni:WriteFile() + Content = "Removed plugin '" .. PluginName .. "'" + else + Content = "Whoops! Something went wrong!" + end + + + elseif( Request.PostParams["AddPlugin"] ~= nil + and Request.PostParams["PluginName"] ~= nil ) then -- Add a plugin + + SettingsIni:SetValue("Plugins", "NewPlugin", Request.PostParams["PluginName"], true ) + SettingsIni:WriteFile() + + Content = "Added plugin '".. Request.PostParams["PluginName"] .."'" + + end + + if( #Content > 0 ) then + return "

INFO: " .. Content .. "

" + else + return "" + end +end + +function HandleRequest_ManagePlugins( Request ) + local Content = "" + + if( Request.PostParams["reload"] ~= nil ) then + Content = Content .. "" + Content = Content .. "

Reloading plugins... This can take a while depending on the plugins you're using.

" + cRoot:Get():GetPluginManager():ReloadPlugins() + return Content + end + + local PluginManager = cRoot:Get():GetPluginManager() + local PluginList = PluginManager:GetAllPlugins() + + Content = Content .. "

Currently active plugins

" + Content = Content .. "" + for k, Plugin in pairs(PluginList) do + Content = Content .. "" + end + Content = Content .. "
" .. Plugin:GetName() .. " V. " .. Plugin:GetVersion() .. "
" + + local SettingsIni = cIniFile("settings.ini") + if( SettingsIni:ReadFile() == true ) then + Content = Content .. "

Plugins according to settings.ini

" + + Content = Content .. HandlePluginListChanges( Request, SettingsIni ) + + Content = Content .. "" + + local KeyIdx = SettingsIni:FindKey("Plugins") + local NumValues = SettingsIni:GetNumValues( KeyIdx ) + for i = 0, NumValues-1 do + local ValueName = SettingsIni:GetValueName(KeyIdx, i ) + local PluginName = SettingsIni:GetValue(KeyIdx, i) + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + end + Content = Content .. "
" .. ValueName .. ": " .. PluginName .. "" .. Button_RemovePlugin( PluginName, i ) .. "
" + end + + Content = Content .. "

Add plugin to settings.ini

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

Reload

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

Click the reload button to reload all plugins!
" + Content = Content .. "

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