Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ID = os.computerID()
- local Au = {}
- local user = {}
- local Us = {}
- local Edt = {}
- local Ddt = {}
- local u = fs.open("saves/USER"..ID..".txt","r")
- local u = fs.open("disk/OaSiS/USER"..ID..".txt","r")
- local Us = textutils.unserialize(u.readAll())
- local A = fs.open("saves/Admin.txt","r")
- local Ad = fs.open("disk/OaSiS/Admin.txt","r")
- local Edt = textutils.unserialize(A.readAll())
- local Ddt = textutils.unserialize(Ad.readAll())
- local guser = Us.name
- local gpass = Us.pass
- local gtype = Us.type
- local gside = Us.side
- local duser = Edt.name
- local dtype = Edt.type
- local dpass = Edt.pass
- local Cpass = Ddt.pass
- local dside = Edt.side
- local Bpass = "Admin"
- u.close()
- A.close()
- Ad.close()
- local function aCheck()
- Au.name = duser
- Au.type = dtype
- Au.pass = dpass
- Au.side = dside
- end
- local function uCheck()
- user.name = guser
- user.type = gtype
- user.pass = gpass
- user.side = gside
- end
- local function Dis()
- term.setBackgroundColor(colors.white)
- term.clear()
- term.setTextColor(colors.green)
- term.setCursorPos(16, 3)
- term.write("Admin Config")
- term.setTextColor(colors.black)
- end
- local function Edt( user )
- local c = fs.open("saves/USER"..ID..".txt","w")
- local dc = fs.open("disk/OaSiS/USER"..ID..".txt","w")
- c.write(textutils.serialize(user))
- dc.write(textutils.serialize(user))
- dc.close()
- c.close()
- end
- local function edit( Au )
- local S = fs.open("saves/Admin.txt", "w")
- local Ds = fs.open("disk/OaSiS/Admin.txt","w")
- S.write(textutils.serialize(Au))
- Ds.write(textutils.serialize(Au))
- S.close()
- Ds.close()
- end
- local function Blog()
- paintutils.drawLine(14, 4, 31, 4, colors.blue)
- term.setTextColor(colors.black)
- term.setCursorPos(14,4)
- write("Change Login info")
- end
- local function Bside()
- paintutils.drawLine(14, 6, 31, 6, colors.blue)
- term.setTextColor(colors.black)
- term.setCursorPos(16, 6)
- write("Change Side")
- end
- local function Btype()
- paintutils.drawLine(14, 8, 31, 8, colors.blue)
- term.setTextColor(colors.black)
- term.setCursorPos(16, 8)
- write("Change Type")
- end
- local function Bcon()
- paintutils.drawLine(14, 10, 31, 10, colors.blue)
- term.setTextColor(colors.black)
- term.setCursorPos(16, 10)
- write("Adv Config")
- end
- local function Bform()
- paintutils.drawLine(14, 12, 31, 12, colors.blue)
- term.setTextColor(colors.black)
- term.setCursorPos(17, 12)
- write("Format a Disk")
- end
- local function SideP()
- term.setCursorPos(7, 5)
- write("which side do you wish to output to?")
- paintutils.drawLine(10, 7, 30, 7, colors.lightGray)
- term.setCursorPos(11, 7)
- nside = read()
- uCheck()
- aCheck()
- user.side = nside
- Au.side = nside
- Edt( user )
- edit( Au )
- Dis()
- term.setCursorPos(9, 5)
- write("Output side has been changed!")
- sleep(0.2)
- menu()
- end
- local function LogP()
- while true do
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.white)
- term.setCursorPos(7, 5)
- write("What login info do you wish to change?")
- paintutils.drawLine(9, 7, 19, 7, colors.green)
- term.setTextColor(colors.white)
- term.setCursorPos(10, 7)
- write("Password")
- paintutils.drawLine(21, 7, 31, 7, colors.green)
- term.setCursorPos(22, 7)
- write("Username")
- paintutils.drawLine(12, 9, 27, 9, colors.green)
- term.setCursorPos(13,9)
- write("Admin password")
- paintutils.drawLine(44, 16, 50, 16, colors.lightGray)
- term.setCursorPos(45, 16)
- write("back")
- sleep(0.5)
- local event, a1, a2, a3 = os.pullEvent()
- if event == "mouse_click" then
- if (a2 >= 9 and a2 <= 19) and (a3 >= 7 and a3 <= 7) then
- Dis()
- term.setCursorPos(10, 6)
- write("Choose a new Password")
- paintutils.drawLine(10, 8, 30, 8, colors.lightGray)
- term.setCursorPos(11,8)
- local npass = read()
- uCheck()
- user.pass = npass
- Edt( user )
- Dis()
- term.setCursorPos(9, 5)
- write("Password successfully changed.")
- menu()
- elseif (a2 >= 21 and a2 <= 31) and (a3 >= 7 and a3 <= 7) then
- Dis()
- term.setCursorPos(10, 6)
- write("Choose a new Username")
- paintutils.drawLine(10, 8, 30, 8, colors.lightGray)
- term.setCursorPos(11, 8)
- local nuser = read()
- aCheck()
- uCheck()
- user.name = nuser
- Au.name = nuser
- Edt( user )
- edit( Au )
- Dis()
- term.setCursorPos(9, 5)
- write("Username successfully changed.")
- menu()
- elseif (a2 >= 12 and a2 <= 27) and (a3 >= 9 and a3 <= 9) then
- Dis()
- term.setCursorPos(10, 6)
- write("Choose a new Admin password")
- paintutils.drawLine(10, 8, 30, 8, colors.lightGray)
- term.setCursorPos(11,8)
- local anpass = read("*")
- if dpass == Cpass then
- aCheck()
- Au.pass = anpass
- edit( Au )
- Dis()
- term.setCursorPos(6, 5)
- write("Admin password successfully changed.")
- menu()
- else
- Dis()
- term.setCursorPos(10, 6)
- write("Invaild card!")
- sleep(2)
- menu()
- end
- elseif (a2 >= 44 and a2 <= 50) and (a3 >= 16 and a3 <= 16) then
- Dis()
- menu()
- end
- end
- end
- end
- function menu()
- while true do
- local event, arg1, arg2, arg3 = os.pullEvent()
- sleep(0.5)
- Dis()
- Blog()
- Bside()
- Btype()
- Bcon()
- Bform()
- if event == "mouse_click" then
- if (arg2 >= 8 and arg2 <= 25) and (arg3 >= 4 and arg3 <= 4) then
- Dis()
- LogP()
- elseif (arg2 >= 14 and arg2 <= 31) and (arg3 >= 6 and arg3 <= 6) then
- Dis()
- SideP()
- elseif (arg2 >= 14 and arg2 <= 31) and (arg3 >= 8 and arg3 <= 8) then
- Dis()
- TypeB()
- elseif (arg2 >= 14 and arg2 <= 31) and (arg3 >= 10 and arg3 <= 10) then
- elseif (arg2 >= 14 and arg2 <= 31) and (arg3 >= 12 and arg3 <= 12) then
- end
- end
- end
- end
- local function config()
- -- first time ruinng admin config
- if dpass == Bpass then
- Dis()
- term.setCursorPos(8,5)
- term.setTextColor(colors.black)
- write("please setup a proper Admin password")
- paintutils.drawLine(8, 7, 20, 7,colors.lightGray)
- term.setCursorPos(8,7)
- local Apass = read("*")
- aCheck()
- Au.pass = Apass
- edit( Au )
- menu()
- else
- Dis()
- term.setTextColor(colors.black)
- term.setCursorPos(4,4)
- write("For secure purposes we ask once more for adm pass")
- paintutils.drawLine(8, 7, 20, 7,colors.lightGray)
- term.setCursorPos(8,7)
- local adpass = read("*")
- if adpass == dpass then
- Dis()
- menu()
- else
- print("incorrect")
- shell.run("startup")
- end
- end
- end
- config()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement