Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Page = window.create( term.current(), 0, 3, 52,17)
- local Hd = window.create( term.current(), 0, 0, 52, 3)
- local box = window.create( term.current(), 0, 19, 52, 1)
- local time = os.time()
- local Tbe = {}
- local ID = os.getComputerID()
- local Adpass = "Admin"
- local Hs = "hom"
- local B = "biz"
- local function start()
- if fs.exists("startup") == false then
- term.setBackgroundColor(colors.white)
- term.clear()
- Page.setCursorPos(17, 6)
- term.setTextColor(colors.green)
- textutils.slowPrint("installing OaSiS")
- term.setTextColor(colors.lightGray)
- term.setCursorPos(6, 12)
- write("Tip:Put a disk in while setting up config!")
- term.setTextColor(colors.black)
- Page.setCursorPos(33, 6)
- sleep(0.7)
- textutils.slowPrint("...")
- fs.copy("disk/startup", "startup")
- fs.copy("disk/config.lua","config.lua")
- Page.setCursorPos(33, 6)
- sleep(0.7)
- textutils.slowPrint(" ")
- Page.setCursorPos(33, 6)
- sleep(0.7)
- textutils.slowPrint("...")
- sleep(0.7)
- Page.setCursorPos(33, 6)
- textutils.slowPrint(" ")
- term.setBackgroundColor(colors.white)
- term.clear()
- term.setTextColor(colors.green)
- Page.setCursorPos(15, 10)
- write("Installation complete.")
- local Driveside
- for _, side in ipairs(rs.getSides()) do
- if peripheral.isPresent(side) and peripheral.getType(side) == "drive" then
- Driveside = side
- break
- end
- end
- disk.eject(Driveside)
- sleep(1)
- else
- end
- end
- os.pullEvent = os.pullEventRaw
- function SecureV()
- local u = fs.open("saves/Admin.txt", "r")
- local Mt = textutils.unserialise(u.readAll())
- local name = Mt.name
- u.close()
- box.setBackgroundColor(colors.white)
- box.clear()
- Hd.setCursorPos(21,2)
- box.setTextColor(colors.gray)
- if type == Hs then
- Hd.write("User:"..name)
- else
- box.setCursorPos(2,1)
- box.write("Authorized personnel use only")
- end
- box.setCursorPos(48,1)
- box.setTextColor(colors.gray)
- box.write("V2.0")
- Hd.setCursorPos(2, 2)
- Hd.write("Pc:"..os.getComputerLabel())
- end
- local time = os.time()
- local function time()
- Hd.setCursorPos(45,2)
- Hd.setBackgroundColor( colors.white )
- Hd.clear()
- Hd.setTextColor(colors.gray)
- Hd.write(""..textutils.formatTime(os.time()))
- TimeDisplay = os.startTimer(1)
- end
- local function Reg( Au )
- local A = fs.open("saves/Admin.txt", "w")
- A.write(textutils.serialize(Au))
- A.close()
- end
- local function reg( user )
- local f = fs.open("saves/USER"..ID..".txt","w")
- f.write(textutils.serialize(user))
- f.close()
- end
- start()
- local T = false
- local function Regist()
- if fs.exists("saves/Admin.txt") == false then
- Page.setBackgroundColor(colors.white)
- Page.clear()
- time()
- local Au = {}
- local user = {}
- Page.setCursorPos(8, 3)
- Page.setTextColor(colors.black)
- Page.write("Is this for Business or Personal use?")
- Page.setBackgroundColor(colors.blue)
- Page.setCursorPos(15, 10)
- Page.write("Business")
- Page.setBackgroundColor(colors.green)
- Page.setTextColor(colors.white)
- Page.setCursorPos(33, 10)
- Page.write("personal")
- repeat
- local event, s1, s2, s3 = os.pullEvent()
- if event == "mouse_click" then
- if (s2 >= 15 and s2 <= 23) and (s3 >= 12 and s3 <= 12) then
- stype = "biz"
- T = true
- Page.clear()
- elseif (s2 >= 33 and s2 <= 41) and (s3 >= 12 and s3 <= 12) then
- stype = "hom"
- T = true
- Page.clear()
- end
- else
- T = false
- end
- until T == true
- user.type = stype
- Au.type = stype
- Page.setCursorPos(14, 3)
- Page.setBackgroundColor(colors.white)
- Page.clear()
- Page.setTextColor(colors.green)
- Page.write("Config")
- Page.setTextColor(colors.black)
- paintutils.drawLine(13, 7, 38, 7, colors.lightGray)
- Page.setCursorPos(14, 4)
- Page.write("Enter your desired name")
- fs.makeDir("saves")
- time()
- Page.setCursorPos(14, 8)
- paintutils.drawLine(13, 10, 38, 10, colors.lightGray)
- Page.setCursorPos(14, 7)
- Page.write("Enter a Password")
- Page.setCursorPos(14, 10)
- Page.write("PC-Name")
- paintutils.drawLine(13, 13, 38, 13, colors.lightGray)
- Page.setCursorPos(14, 13)
- Page.write("Redstone side?" )
- paintutils.drawLine(13, 16, 38, 16, colors.lightGray)
- Page.setCursorPos(14, 5)
- Uname = read()
- user.name = Uname
- Au.name = Uname
- time()
- paintutils.drawPixel(11, 7, colors.green)
- term.setCursorPos(11, 7)
- print("+")
- term.setBackgroundColor(colors.lightGray)
- Page.setCursorPos(14, 8)
- user.pass = read()
- Au.pass = Adpass
- time()
- paintutils.drawPixel(11, 10, colors.green)
- term.setCursorPos(11, 10)
- print("+")
- term.setBackgroundColor(colors.lightGray)
- Page.setCursorPos(14, 11)
- local Pc = read()
- os.setComputerLabel(Pc)
- paintutils.drawPixel(11, 13, colors.green)
- term.setCursorPos(11, 13)
- print("+")
- Page.setCursorPos(14, 14)
- term.setBackgroundColor(colors.lightGray)
- Uside = read()
- Au.side = Uside
- user.side = Uside
- time()
- paintutils.drawPixel(11, 16, colors.green)
- term.setCursorPos(11, 16)
- print("+")
- sleep(1)
- reg( user )
- Reg( Au )
- if fs.exists("disk/") == false then
- Page.clear()
- time()
- Page.setCursorPos(9, 5)
- Page.write("No disk was found to be formatted.")
- Page.setCursorPos(11, 6)
- Page.write("do you wish to format a disk?")
- Page.setTextColor(colors.black)
- paintutils.drawLine(15, 10, 19, 10, colors.green)
- Page.setCursorPos(17, 8)
- print("Yes")
- paintutils.drawLine(26, 10, 29, 10,colors.red)
- Page.setCursorPos(28, 8)
- print("No")
- while true do
- local event, arg1, arg2, arg3 = os.pullEvent()
- if event == "mouse_click" then
- if (arg2 >= 15 and arg2 <= 19) and (arg3 >= 10 and arg3 <= 10) then
- term.setBackgroundColor(colors.white)
- Page.clear()
- Page.setCursorPos(16, 12)
- Page.write("waiting for input..")
- repeat
- local S = os.pullEvent()
- Page.setCursorPos(33, 12)
- textutils.slowPrint("...")
- Page.setCursorPos(33, 12)
- textutils.slowPrint(" ")
- Page.setCursorPos(33, 12)
- textutils.slowPrint("...")
- if S == "disk" then
- sleep(0.5)
- o = true
- else
- o = false
- end
- until o == true
- diskb()
- elseif (arg2 >= 26 and arg2 <= 29) and (arg3 >= 10 and arg3 <= 10) then
- term.setBackgroundColor(colors.white)
- Page.clear()
- Page.setCursorPos(13,12)
- print("No disk has been formatted")
- sleep(1)
- os.reboot()
- end
- elseif event == "disk" then
- diskb()
- end
- end
- else
- diskb()
- end
- end
- end
- function diskb()
- term.setBackgroundColor(colors.white)
- Page.setCursorPos(16, 15)
- print("formatting disk..")
- sleep(1)
- if fs.exists("disk/") == true then
- if fs.exists("disk/OaSiS/USER"..ID.."txt") then
- fs.delete("disk/OaSiS/USER"..ID..".txt")
- end
- fs.copy("saves/Admin.txt", "disk/OaSiS/Admin.txt")
- fs.copy("saves/USER"..ID..".txt", "disk/OaSiS/USER"..ID..".txt")
- Page.write("Note: This will be your Admin card.")
- Page.setTextColor(colors.green)
- Page.setCursorPos(14, 3)
- Page.setCursorPos(16, 16)
- Page.write("Formatted!")
- name()
- else
- print("No disk!")
- end
- end
- function name()
- if fs.exists("disk/OaSiS/Admin.txt") == true then
- local driveside
- for _, side in ipairs(rs.getSides()) do
- if peripheral.isPresent(side) and peripheral.getType(side) == "drive" then
- driveside = side
- break
- end
- end
- if driveside then
- disk.getLabel(driveside)
- disk.setLabel(driveside, "AdminKey")
- Page.setCursorPos(13, 16)
- term.setBackgroundColor(colors.white)
- Page.write("Configuration finalized!")
- sleep(2)
- os.reboot()
- else
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.red)
- Page.setCursorPos(14, 16)
- print("formatting failed")
- end
- end
- end
- Regist()
- function Login()
- Page.setBackgroundColor( colors.black )
- Page.clear()
- box.clear()
- time()
- SecureV()
- Hd.setBackgroundColor( colors.white)
- term.setTextColor( colors.gray)
- Page.setTextColor( colors.lime )
- Page.setCursorPos(24,4)
- Page.write("OaSiS")
- paintutils.drawLine(13, 10, 38, 10, colors.gray)
- paintutils.drawLine(12, 9, 12, 10, colors.gray)
- paintutils.drawLine(13, 9, 38, 9, colors.lightGray)
- Page.setTextColor(colors.gray)
- Page.setCursorPos(17,7)
- print("Type Password")
- end
- local Gbe = {}
- local s = fs.open("saves/Admin.txt","r")
- local g = fs.open("saves/USER"..ID..".txt","r")
- local Gbe = textutils.unserialize(g.readAll())
- local Tbe = textutils.unserialize(s.readAll())
- local user1 = Tbe.name
- local pass1 = Tbe.pass
- local side1 = Tbe.side
- local type = Tbe.type
- local Gpass = Gbe.pass
- s.close()
- g.close()
- -- local d = fs.open("disk/USERS.txt","r")
- -- local Dtb = textutils.unserialize(d.readAll()
- function P()
- Login()
- Page.setCursorPos(14, 7)
- password = read("*")
- if (password == Gpass) then
- if type == B then
- U()
- elseif (password == pass1) then
- shell.run("config")
- else
- pass()
- end
- else
- Page.setTextColor(colors.red)
- Page.setCursorPos(17, 10)
- Page.write("Wrong Password.")
- sleep(0.8)
- P()
- end
- end
- function U()
- paintutils.drawLine(12, 9, 12, 10, colors.gray)
- paintutils.drawLine(13, 9, 38, 9, colors.lightGray)
- Page.setCursorPos(17, 7)
- print("Type Username")
- Page.setCursorPos(14, 7)
- username = read("*")
- if (username == user1) then
- pass()
- else
- Inv()
- end
- end
- function Con()
- shell.run("config")
- end
- local Dtb = {}
- function Disk()
- while true do
- local driveSide
- for _, side in ipairs(rs.getSides()) do
- if peripheral.isPresent(side) and peripheral.getType(side) == "drive" then
- driveSide = side
- break
- end
- end
- if disk.hasData(driveSide) == true then
- Login()
- Page.setTextColor(colors.green)
- Page.setCursorPos(16, 10)
- Page.write("Disk inserted! ")
- sleep(0.8)
- if fs.exists("disk/OaSiS/") then
- if fs.exists("disk/OaSiS/USER"..ID..".txt") then
- if fs.exists("disk/OaSiS/Admin.txt") then
- local Atb ={}
- local a = fs.open("disk/OaSiS/Admin.txt","r")
- local Atb = textutils.unserialize(a.readAll())
- local aPass = Atb.pass
- local auser = Atb.name
- a.close()
- if pass1 == aPass and user1 == auser then
- Page.setBackgroundColor(colors.white)
- Page.clear()
- Page.setCursorPos(10, 4)
- Page.write("setting up config page..")
- sleep(0.5)
- Con()
- error()
- else
- Inv()
- end
- end
- local d = fs.open("disk/OaSiS/USER"..ID..".txt","r")
- local Dtb = textutils.unserialize(d.readAll())
- local gpass = Dtb.pass
- local guser = Dtb.name
- d.close()
- if guser == nil then
- error("value = nil")
- else
- Page.setTextColor(colors.black)
- Page.setCursorPos(17, 12)
- Page.write("testing var ".. Gpass)
- Page.write("testing var ".. guser)
- Page.write("testing var ".. gpass)
- Page.write("testing var ".. user1)
- end
- if Gpass == gpass and user1 == guser then
- disk.eject(driveSide)
- pass()
- else
- disk.eject(driveSide)
- Inv()
- P()
- end
- else
- Page.setTextColor(colors.red)
- Page.setCursorPos(16, 10)
- Page.write("Invaild KeyCard! ")
- sleep(0.5)
- touch()
- end
- else
- Page.setTextColor(colors.orange)
- Page.setCursorPos(16, 10)
- Page.write("Invaild disk type!")
- sleep(0.5)
- touch()
- end
- else
- Page.setCursorPos(15,10)
- Page.write(" no disk is inserted.")
- sleep(0.5)
- touch()
- end
- end
- end
- local ds = false
- function touch()
- repeat
- Page.setTextColor(colors.gray)
- Page.setCursorPos(19, 16)
- Page.write("checking...")
- sleep(0.2)
- Page.setCursorPos(19, 16)
- Page.write(" ")
- local event, p1, p2, p3 = os.pullEvent()
- if event == "disk" then
- Disk()
- ds = true
- elseif event == "mouse_click" then
- if (p2 > 12 and p2 < 38) and (p3 > 8 and p3 < 11) then
- P()
- else
- Disk()
- ds = true
- end
- success = 0
- end
- until ds
- end
- function format()
- local DriveSide
- for _, side in ipairs(rs.getSides()) do
- if peripheral.isPresent(side) and peripheral.getType(side) == "drive" then
- DriveSide = side
- break
- end
- end
- if DriveSide then
- if disk.hasData(DriveSide) == true then
- if fs.exists("disk/") == true then
- if fs.exists("disk/OaSiS/USER"..ID..".txt") == false then
- Login()
- Page.setCursorPos(9, 6)
- Page.write("An unformatted disk had been found,")
- Page.setCursorPos(10, 7)
- Page.write("would you like to format it?")
- paintutils.drawLine(12, 10, 38, 10, colors.lightGray)
- Page.setCursorPos(14, 8)
- write(" [ Y / N ]")
- Page.setCursorPos(14, 8)
- local input = read()
- local y = "y","Y"
- local n = "n","N"
- if input == y then
- fs.copy("saves/USER"..ID..".txt","disk/OaSiS/USER"..ID..".txt")
- disk.getLabel(DriveSide)
- disk.setLabel(DriveSide,"U"..os.getComputerID())
- Page.setCursorPos(14, 11)
- Page.write("Formatted")
- sleep(1)
- shell.run("startup")
- elseif input == n then
- print("formatting cancelled")
- sleep(1)
- shell.run("startup")
- else
- print("formatting failed.")
- sleep(1)
- shell.run("startup")
- end
- end
- end
- end
- end
- end
- function pass()
- time()
- SecureV()
- Page.setTextColor( colors.green )
- Page.setCursorPos( 16, 10)
- Page.write(" Access Granted")
- sleep(0.5)
- time()
- SecureV()
- redstone.setOutput(side1, true)
- time()
- SecureV()
- sleep(3)
- redstone.setOutput(side1, false)
- format()
- shell.run("startup")
- end
- function Inv()
- time()
- SecureV()
- sleep(0.2)
- Page.setTextColor( colors.red)
- Page.setCursorPos( 16, 10)
- Page.write(" Access Denied")
- Page.setCursorPos( 22, 15)
- time()
- SecureV()
- sleep(0.5)
- time()
- SecureV()
- sleep(0.5)
- time()
- SecureV()
- sleep(1)
- shell.run("startup")
- end
- function void()
- while true do
- D = os.pullEvent()
- if D == "disk" then
- if fs.exists("disk/startup") then
- fs.move("disk/startup", "disk/noope")
- else
- end
- end
- end
- end
- repeat
- Login()
- touch()
- until success
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement