-- do return end -- --[=[ -- --[[ -- Some values that need to be setup by the server owner -- ]] -- -- local aes = include("aes.lua") -- local ECBMode = include("lockbox/ecb.lua") -- local ZeroPadding = include("lockbox/padding.lua") -- local Array = include("lockbox/array.lua") -- local Stream = include("lockbox/stream.lua") -- print("sh_setup included aes successfully") -- -- local valuesneeded = { -- ["mysql DB host"] = "String", -- ["mysql DB dbname"] = "String", -- ["mysql DB uname"] = "String", -- ["mysql DB pass"] = "String", -- ["mysql should encrypt pass"] = "Bool", -- ["mysql encrypt password"] = "String", -- ["world default server ip:port"] = "String", -- } -- -- ART.Config = ART.Config or {} -- -- if SERVER then -- util.AddNetworkString( "ART_CONFIG_WRITE" ) -- local function ReadConfig(encryptkey) -- encryptkey = encryptkey or "" -- local ftext = file.Read("artery/config.txt", "DATA") -- if ftext == nil then -- print("Failed to read Config file, if this is a new setup, use art_setup to get started.") -- return -- end -- local tbl = string.Explode("\n",ftext,false) -- local strtbl = {} -- for k,v in pairs(tbl) do -- local ltext = v:Explode(":",false) -- strtbl[ltext[1]] = ltext[2] -- end -- for k,v in pairs(valuesneeded) do -- local tfunc = "to" .. v:lower() -- ART.Config[k] = _G[tfunc](strtbl[k]) -- end -- if ART.Config["mysql should encrypt pass"] then -- if encryptkey == "" then -- print("Failed to retrive MySQL database password, please enter it with the \"artery_dbpasswordkey\" command.") -- return -- end -- ART.Config["mysql DB pass"] = aes.decrypt(lockstream.fromString(encryptkey),lockstream.fromString(ART.Config["mysql DB pass"])) -- end -- end -- -- ReadConfig() -- -- net.Receive( "ART_CONFIG_MYSQLPASS", function(len,ply) -- if not ply:IsAdmin() then -- return -- end -- end) -- -- net.Receive( "ART_CONFIG_WRITE", function(len,ply) -- print("Received write signal") -- if not ply:IsAdmin() then return end -- print("You're an admin!") -- for k,v in pairs(valuesneeded) do -- local ftype = "Read" .. v -- ART.Config[k] = net[ftype]() -- end -- if ART.Config["mysql should encrypt pass"] then -- local key = ART.Config["mysql encrypt password"] -- local block = ART.Config["mysql DB pass"] -- local akey = Array.fromString(key) -- local ablock = Array.fromString(block) -- local skey = Stream.fromString(key) -- local sblock = Stream.fromString(block) -- --print("sblock:" .. sblock) -- --print("skey:" .. skey) -- local cipher = ECBMode.Cipher().setKey(akey).setBlockCipher(aes).setPadding(ZeroPadding) -- local ciphertxt = cipher.init().update(sblock).finish().asHex() -- local decipher = ECBMode.Decipher().setKey(akey).setBlockCipher(aes).setPadding(ZeroPadding) -- local deciphertxt = decipher.init().update(Stream.fromHex(ciphertxt)).finish().asHex() -- print("Cyphertext of " .. block .. " is " .. ciphertxt) -- print("Deciphertext of " .. ciphertxt .. " is " .. deciphertxt) -- ART.Config["mysql DB pass"] = ciphertxt -- end -- local ftext = {} -- for k,v in pairs(ART.Config) do -- ftext[#ftext + 1] = k .. "=" .. tostring(v) -- end -- local wtext = table.concat(ftext,"\n") -- print("Writeing:" .. wtext) -- file.Write("artery/config.txt",wtext) -- end) -- -- net.Receive( "ART_CONFIG_REQUEST", function(len,ply) -- if not ply:IsAdmin() then return end -- for k,v in pairs(valuesneeded) do -- local ftype = "Write" .. v -- print("Calling " .. ftype .. " on " .. tostring(tbl[k])) -- net[ftype](tbl[k]) -- end -- end) -- end -- -- print("Got to before concommands were added") -- -- concommand.Add("artery_dbpasswordkey",function() -- if CLIENT then return end -- -- end, nil, "Sets the encryption key for the mysql database password") -- -- if CLIENT then -- print("Got to before setup command") -- -- concommand.Add("artery_setup", function(ply,cmd,args) -- print("setup called") -- if SERVER then return end -- print("Got past server gaurd") -- local width = ScrW() -- local height = ScrH() -- local configpanel = vgui.Create( "DFrame" ) -- configpanel:SetPos( 0, height/8 ) -- configpanel:SetSize( width/4, (height/4)*3 ) -- configpanel:SetTitle( "Artery Settings" ) -- configpanel:SetDraggable( true ) -- configpanel:MakePopup() -- local scrollpanel = vgui.Create( "DScrollPanel", configpanel ) -- scrollpanel:Dock(FILL) -- local entries = {} -- for k,v in pairs(valuesneeded) do -- local settinglabel = vgui.Create( "DLabel", scrollpanel ) -- settinglabel:Dock(TOP) -- settinglabel:SetText( k ) -- scrollpanel:AddItem(settinglabel) -- local settingentry -- if v == "String" then -- settingentry = vgui.Create( "DTextEntry", scrollpanel ) -- settingentry:SetSize(width/10,18) -- settingentry:Dock(TOP) -- elseif v == "Bool" then -- settingentry = vgui.Create( "DCheckBox", holder) -- settingentry:Dock(TOP) -- --settingentry:SetSize(18,18) -- end -- scrollpanel:AddItem(settingentry) -- entries[k] = settingentry -- end -- local savebutton = vgui.Create( "DButton",scrollpanel ) -- savebutton.DoClick = function() -- net.Start( "ART_CONFIG_WRITE") -- for k,v in pairs(valuesneeded) do -- local nfunc = "Write"..v -- local value = nil -- if v == "String" then value = entries[k]:GetValue() -- elseif v == "Bool" then value = entries[k]:GetChecked() end -- assert(value ~= nil, "Didn't know setting type:" .. v .. " for " .. k) -- print("Doing " .. nfunc .. " on " .. tostring(value)) -- net[nfunc](value) -- end -- net.SendToServer() -- end -- savebutton:SetText("Save config") -- savebutton:Dock(TOP) -- scrollpanel:AddItem(savebutton) -- end) -- end -- ]=]