Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local verze = "22.0222.R1"
- local anim = 0.1
- local RamCesta = ("/C/system/RAM/SM")
- local w, h = term.getSize()
- local nRul = {}
- local pRul = {}
- local iRul = {}
- local bRul = {}
- ----------------------------------------------------
- local f=fs.open("/C/system/RAM/user","r")
- user=f.readLine()
- pass=f.readLine()
- Fname=f.readLine()
- Lname=f.readLine()
- f.close()
- local function Barvy()
- if fs.exists ("/C/system/Users/"..user.."/.Registry/colors") then
- local data = fs.open("/C/system/Users/"..user.."/.Registry/colors", "r")
- BarPoz = tonumber(data.readLine())
- BarTxt = tonumber(data.readLine())
- data.close()
- end
- if BarPoz == nil or BarTxt == nil then BarPoz = 2048 BarTxt = 1 end
- end
- function ukonceni ()
- fs.delete (RamCesta)
- os.exit()
- end
- function cbarva()
- lista.setTextColor(colors.black)
- lista.setBackgroundColor(colors.gray)
- end
- function defaultvalue()
- end
- function start()
- defaultvalue()
- Barvy()
- local myWindow = window.create(term.current(),w/2-11,h/2-5,25,9)
- myWindow.setBackgroundColor(colors.lightBlue)
- myWindow.clear()
- myWindow.setCursorPos (7, 5)
- myWindow.write"Server Manager"
- myWindow.setCursorPos (1, 1)
- myWindow.write"Pepek@Soft"
- myWindow.setCursorPos (22, 9)
- myWindow.write"2020"
- sleep(1)
- menu()
- end
- function plocha()
- w, h = term.getSize()
- paintutils.drawLine(1, 1, w, 1, BarPoz)
- paintutils.drawPixel (w,1, colors.red)
- term.setCursorPos (w,1)
- term.setTextColor(BarTxt)
- write "×"
- barW = window.create(term.current(),1,2,w,1)
- barW.setBackgroundColor(colors.gray)
- barW.clear()
- barW.setTextColor(colors.white)
- barW.setCursorPos(2,1)
- barW.write"Server Manager >"
- pozadi = window.create(term.current(),13,3,w,h-2)
- pozadi.setBackgroundColor(colors.white)
- pozadi.setTextColor(colors.black)
- pozadi.clear()
- lista = window.create(term.current(),1,3,12,h-2)
- lista.setBackgroundColor(BarPoz)
- lista.setTextColor(BarTxt)
- lista.clear()
- lista.setCursorPos(2,3)
- lista.write"Dashboard"
- lista.setCursorPos(2,5)
- lista.write"Rules"
- lista.setCursorPos(2,7)
- lista.write"Services"
- lista.setCursorPos(2,h-2)
- lista.setTextColor(colors.white)
- lista.write("Pepek@Soft")
- term.setBackgroundColor(colors.lightGray)
- end
- -----------------------------------------------------------------------------
- local page = "Fdb"
- function Fdb()
- barW.setCursorPos(19,1)
- barW.write"Dashboard"
- pozadi.setCursorPos(2,2)
- pozadi.write"Instaled Version:"
- pozadi.setCursorPos(2,4)
- pozadi.write"BootLoader:"
- pozadi.setCursorPos(2,5)
- pozadi.write"Explorer:"
- pozadi.setCursorPos(2,6)
- pozadi.write"Server manager:"
- pozadi.setCursorPos(2,8)
- pozadi.write"Logged in user:"
- pozadi.setCursorPos(2,9)
- pozadi.write"Instaled rules:"
- pozadi.setCursorPos(2,10)
- pozadi.write"Active services:"
- pozadi.setCursorPos(2,11)
- pozadi.write"Computer ID:"
- pozadi.setCursorPos(2,12)
- pozadi.write"Computer name:"
- pozadi.setCursorPos(2,13)
- pozadi.write"Primary modem:"
- pozadi.setTextColor(colors.lightGray)
- if fs.exists("/C/system/RAM/versions.tmp") then
- local x = fs.open("/C/system/RAM/versions.tmp","r")
- pozadi.setCursorPos(19,4)
- pozadi.write(x.readLine())
- pozadi.setCursorPos(19,5)
- pozadi.write(x.readLine())
- x.close()
- end
- pozadi.setCursorPos(19,6)
- pozadi.write(verze)
- pozadi.setCursorPos(19,8)
- pozadi.write(user)
- if fs.exists("/C/system/server/rules/") then cRul = fs.list("/C/system/server/rules/") cRul = #cRul else cRul = 0 end
- pozadi.setCursorPos(19,9)
- pozadi.write(cRul)
- if fs.exists("/C/service/") then cRul = fs.list("/C/service/") cRul = #cRul else cRul = 0 end
- pozadi.setCursorPos(19,10)
- pozadi.write(cRul)
- pozadi.setCursorPos(19,11)
- pozadi.write(os.getComputerID())
- pozadi.setCursorPos(19,12)
- if not (os.getComputerLabel() == nil) then pozadi.write(os.getComputerLabel())end
- if fs.exists("/C/system/.core/defmodem") then
- local x = fs.open("/C/system/.core/defmodem","r")
- pozadi.setCursorPos(19,13)
- pozadi.write(x.readLine())
- x.close()
- end
- end
- ---------------------------------------------------------------------------------------------------
- local function downloading(kod, cestaP)
- local WinDown = window.create(term.current(),15,8,w-15,5)
- WinDown.setBackgroundColor(colors.lightGray)
- WinDown.clear()
- WinDown.setTextColor(colors.black)
- WinDown.setCursorPos(2,1)
- WinDown.write "Downloading files..."
- term.setCursorPos(16,-5)
- term.setBackgroundColor(colors.lightGray)
- shell.run("/stahni get "..kod.." /C/system/server/rules/"..cestaP..".lua")
- end
- function preInRul()
- term.setCursorPos(13,3)
- shell.run("pastebin get JWk3Qhi2 /stahni")
- end
- function instalRul(ins)
- plocha()
- barW.setCursorPos(19,1)
- barW.write"Rules > Install"
- pozadi.setCursorPos(2,2)
- pozadi.write"The selected role is installed"
- preInRul()
- downloading(pRul[ins], iRul[ins])
- local sh = fs.open("/C/system/Users/"..user.."/Desktop/Rules/"..iRul[ins]..".src","w")
- sh.writeLine("shell.run(\"/C/system/server/rules/"..iRul[ins]..".lua\")")
- sh.close()
- sleep(1)
- end
- function Rul()
- barW.setCursorPos(19,1)
- barW.write"Rules"
- barW.setCursorPos(w-7,1)
- barW.write"Refresh"
- pozadi.setCursorPos(2,2)
- pozadi.write"List of available roles"
- RulT = window.create(term.current(),14,6,w-14,h-6)
- RulT.setBackgroundColor(colors.lightBlue)
- RulT.setTextColor(colors.black)
- RulT.clear()
- if fs.exists(RamCesta.."/rules.cat") then
- local rul = fs.open(RamCesta.."/rules.cat","r")
- local a = 1
- for i = 1, 7 do
- nRul[i] = rul.readLine()
- pRul[i] = rul.readLine()
- iRul[i] = rul.readLine()
- RulT.setCursorPos(2,a)
- RulT.setBackgroundColor(colors.lightBlue)
- if not (nRul[i] == nil) then
- RulT.write(nRul[i])
- RulT.setCursorPos(w-22,a) RulT.setBackgroundColor(colors.lightGray)
- if not fs.exists("/C/system/server/rules/"..iRul[i]..".lua") then bRul[i] = "Install" else bRul[i] = "Manager" end
- RulT.write(" "..bRul[i].." ")
- a= a+2
- end
- end
- rul.close()
- else
- term.setCursorPos(13,-5)
- shell.run("pastebin get zdcN43an "..RamCesta.."/rules.cat")
- menu()
- end
- end
- ---------------------------------------------------------------------------------------------------
- local sPage = "allo"
- local aService = {}
- local pService = {}
- function Ser()
- barW.setCursorPos(19,1)
- barW.write"Services"
- barW.setCursorPos(w-7,1)
- barW.write"Refresh"
- if (sPage == "allo") then pozadi.setBackgroundColor(colors.lightBlue) else pozadi.setBackgroundColor(colors.lightGray) end
- pozadi.setCursorPos(2,3)
- pozadi.write" Allowed "
- if (sPage == "proh") then pozadi.setBackgroundColor(colors.lightBlue) else pozadi.setBackgroundColor(colors.lightGray) end
- pozadi.setCursorPos(11,3)
- pozadi.write" Prohibited "
- SerT = window.create(term.current(),14,6,w-14,h-6)
- SerT.setBackgroundColor(colors.lightBlue)
- SerT.setTextColor(colors.black)
- SerT.clear()
- if (sPage == "allo") then
- if fs.exists("/C/service/") then
- cSer = fs.list("/C/service/")
- local a=1
- for i = 1, #cSer do
- local name = tostring(cSer[i])
- SerT.setBackgroundColor(colors.lightBlue)
- SerT.setCursorPos(2,a)
- SerT.write(cSer[i])
- SerT.setBackgroundColor(colors.lightGray)
- SerT.setCursorPos(w-25,a)
- SerT.write(" Proh ")
- SerT.setCursorPos(w-18,a)
- SerT.write(" Run ")
- a = a+2
- end
- end
- elseif (sPage == "proh") then
- if fs.exists("/C/stopService/") then
- cSer = fs.list("/C/stopService/")
- local a=1
- for i = 1, #cSer do
- local name = tostring(cSer[i])
- SerT.setBackgroundColor(colors.lightBlue)
- SerT.setCursorPos(2,a)
- SerT.write(cSer[i])
- SerT.setBackgroundColor(colors.lightGray)
- SerT.setCursorPos(w-18,a)
- SerT.write(" Run ")
- SerT.setCursorPos(w-25,a)
- SerT.write(" Allo ")
- a = a+2
- end
- end
- end
- end
- ---------------------------------------------------------------------------------------------------
- function sel(y)
- inst = 0
- if (y==6) then
- inst = 1
- elseif (y==8) then
- inst = 2
- elseif (y==10) then
- inst = 3
- elseif (y==12) then
- inst = 4
- elseif (y==14) then
- inst = 5
- elseif (y==16) then
- inst = 6
- elseif (y==18) then
- inst = 7
- end
- end
- function menu()
- plocha()
- if (page == "Fdb") then
- Fdb ()
- elseif (page == "Rul") then
- Rul ()
- elseif (page == "Ser") then
- Ser ()
- end
- while true do
- local event, button, x, y = os.pullEvent("mouse_click")
- xy = x..","..y
- if event == "mouse_click" and x >= 2 and x <= 12 and y == 5 then
- cbarva()
- lista.setCursorPos(1,3)--
- lista.write" Dashboard "
- sleep(anim)
- page = "Fdb"
- menu()
- elseif event == "mouse_click" and x >= 2 and x <= 12 and y == 7 then
- cbarva()
- lista.setCursorPos(1,5)--
- lista.write" Rules "
- sleep(anim)
- page = "Rul"
- menu()
- elseif event == "mouse_click" and x >= 2 and x <= 12 and y == 9 then
- cbarva()
- lista.setCursorPos(1,7)--
- lista.write" Services "
- sleep(anim)
- page = "Ser"
- menu()
- elseif event == "mouse_click" and x >= w-37 and x <= w-29 and y == 5 then -- povolene sluzby
- sPage = "allo"
- menu()
- elseif event == "mouse_click" and x >= w-28 and x <= w-17 and y == 5 then -- zakazane sluzby
- sPage = "proh"
- menu()
- elseif event == "mouse_click" and x >= w-12 and x <= w-7 and (page == "Ser") then -- zakazat/povolit sluzby
- sel(y)
- term.setBackgroundColor(colors.gray)
- if (sPage == "allo") then
- fs.move("C/service/"..cSer[inst], "C/stopService/"..cSer[inst])
- term.setCursorPos(w-12,y)
- term.write(" Proh ")
- else
- fs.move("C/stopService/"..cSer[inst], "C/service/"..cSer[inst])
- term.setCursorPos(w-12,y)
- term.write(" Allo ")
- end
- sleep(anim)
- menu()
- elseif event == "mouse_click" and x >= w-5 and x <= w-1 and y > 2 and (page == "Ser") then -- spustit sluzby
- sel(y)
- term.setCursorPos(w-5,y) term.setBackgroundColor(colors.gray)
- if not (sPage == "allo") then
- fs.move("C/stopService/"..cSer[inst], "C/service/"..cSer[inst])
- end
- term.write(" Run ")
- sleep(anim)
- multishell.launch({}, "C/service/"..cSer[inst])
- menu()
- elseif event == "mouse_click" and x >= w-7 and x <= w and y == 2 then -- refresh Rules
- barW.setTextColor(colors.lightGray)
- barW.setCursorPos(w-7,1)
- barW.write"Refresh"
- sleep(anim)
- if (page == "Rul") then
- term.setCursorPos(13,3)
- barW.setTextColor(colors.black)
- if fs.exists(RamCesta.."/rules.cat") then fs.delete(RamCesta.."/rules.cat") end
- shell.run("pastebin get zdcN43an "..RamCesta.."/rules.cat")
- end
- menu()
- elseif event == "mouse_click" and x >= w-9 and x <= w-1 and (page == "Rul") then -- install/manage rules
- sel(y)
- term.setCursorPos(w-9,y) term.setBackgroundColor(colors.gray)
- if not fs.exists("/C/system/server/rules/"..iRul[inst]..".lua") then term.write(" Install ") sleep(anim) instalRul(inst) else term.write(" Manager ") shell.run("/C/system/server/rules/"..iRul[inst])end
- end
- if x == w and y == 1 then
- ukonceni ()
- else
- menu() -------- stejne jako nazev funkce
- end
- end
- end
- start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement