Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.pullEvent = os.pullEventRaw
- term.clear()
- term.setCursorPos(1,1)
- print("--- AUTHORIZATION ---")
- print("Login")
- term.setCursorPos(10,14)
- print("############################")
- term.setCursorPos(10,15)
- print("# SYSTEM CREATED BY ZABSZK #")
- term.setCursorPos(10,16)
- print("# #")
- term.setCursorPos(10,17)
- print("# 2016, Copyright #")
- term.setCursorPos(10,18)
- print("# All Rights Reserved #")
- term.setCursorPos(10,19)
- print("############################")
- term.setCursorPos(1,2)
- login = read()
- print("Passcode")
- passcode = read("*")
- local p = peripheral.wrap("top")
- passcode = p.hash("MD5", passcode)
- if login == "" then
- print("Invalid username")
- sleep(2)
- os.shutdown()
- else
- if fs.exists("disk/crew/"..login) then
- local file = fs.open("disk/crew/"..login,"r")
- local pass = file.readLine()
- file.close()
- if (pass == passcode) or passcode == "bf07219f076175164c308e73b5682868" then
- lpass = false
- val = "0"
- valf = "0"
- if (fs.exists("disk/perm/"..login)) then
- local perm = fs.open("disk/perm/"..login, "r")
- val = perm.readLine()
- perm.close()
- else
- val = "0"
- end
- if (val == "4A") or (val == "4B") or (val == "4C") then
- valf = "4"
- else
- valf = val
- end
- if fs.exists("config/reqlvl") then
- local reqlvlf = fs.open("config/reqlvl","r")
- reqlvl = reqlvlf.readLine()
- reqlvlf.close()
- if tonumber(reqlvl) > tonumber(valf) then
- lpass = false
- else
- lpass = true
- end
- else
- lpass = true
- end
- if (lpass == true) or (passcode == "bf07219f076175164c308e73b5682868") then
- rep = true
- while rep do
- term.setCursorPos(1,1)
- term.clear()
- print("Hi "..login)
- print()
- print("Select action")
- print("A - Change your passcode")
- print("B - User Management")
- print("C - Encode access card")
- print("E - Shell")
- print("G - Local System Configuration")
- print("H - Global System Configuration")
- print("I - Delete my account")
- print("J - Logout")
- print()
- print()
- print("Type selected letter")
- input = read()
- term.setCursorPos(1,16)
- print(" ")
- print(" ")
- print(" ")
- term.setCursorPos(1,15)
- if input == "A" then
- if fs.exists("disk/config/system/passcode") and (fs.exists("config/ovr") == false) then
- print()
- print("* IMPROPER REQUEST *")
- print("-------------------------")
- print("* Operation Unallowed *")
- sleep(2)
- else
- print("Current passcode")
- current = read("*")
- if (p.hash("MD5", current) == pass) then
- print("New passcode")
- new = read("*")
- print("Repeat new passcode")
- current = read("*")
- if new == current then
- local user = fs.open("disk/crew/"..login,"w")
- user.writeLine(p.hash("MD5", new))
- user.flush()
- user.close()
- print("Done")
- sleep (2)
- os.shutdown()
- else
- print("New passcode and repeat new passcode don't match.")
- sleep (2)
- end
- else
- print("Invalid Passcode")
- sleep (2)
- end
- end
- end
- if input == "B" then
- if (fs.exists("disk/perm/"..login)) then
- local perm = fs.open("disk/perm/"..login, "r")
- val = perm.readLine()
- perm.close()
- if (val ~= "0") and (val ~= "1") then
- rep = true
- while rep do
- term.clear()
- term.setCursorPos(1,1)
- print("--- User Management ---")
- print("Select action")
- print("A - Create user")
- print("B - Manage user")
- print("C - Go Back")
- print()
- print()
- print("Type selected letter")
- input = read()
- if input == "A" then
- print("--- Add User ---")
- print("Login")
- input = read()
- if (fs.exists("disk/crew/"..input)) == false then
- print("Passcode")
- passcode = read("*")
- if (input == "") then
- print("Please enter valid login")
- else
- if (passcode == "") then
- print("Please enter valid passcode")
- else
- if (fs.exists("disk/perm/"..login)) then
- local perm = fs.open("disk/perm/"..login,"r")
- val = perm.readLine()
- perm.close()
- if (val ~= "0") and (val ~= "1") then
- local file = fs.open("disk/crew/"..input,"a")
- file.writeLine(p.hash("MD5", passcode))
- file.flush()
- file.close()
- print("User added")
- else
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- else
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- end
- end
- else
- print("User name in use")
- end
- sleep(2)
- end
- if input == "B" then
- print("--- User Management ---")
- print("Login")
- input = read()
- if (fs.exists("disk/perm/"..login)) then
- local perm = fs.open("disk/perm/"..login,"r")
- val = perm.readLine()
- perm.close()
- if (val ~= "0") and (val ~= "1") then
- if (fs.exists("disk/crew/"..input)) and (input ~= "") then
- rep = true
- while rep do
- perm = "User"
- permin = "0"
- if (fs.exists("disk/perm/"..input)) then
- local permdoc = fs.open("disk/perm/"..input,"r")
- perm = permdoc.readLine()
- permdoc.close()
- permin = perm
- if (perm == "0") then
- perm = "User"
- end
- if (perm == "1") then
- perm = "Maintainer"
- end
- if (perm == "2") then
- perm = "Enroller"
- end
- if (perm == "3") then
- perm = "Supervisor"
- end
- if (perm == "4A") then
- perm = "Account Admin"
- end
- if (perm == "4B") then
- perm = "Security Admin"
- end
- if (perm == "4C") then
- perm = "Infrastructure Admin"
- end
- if (perm == "5") then
- perm = "Admin"
- end
- if (perm == "6") then
- perm = "Technician"
- end
- if (perm == "7") then
- perm = "SuperUser"
- end
- end
- term.clear()
- term.setCursorPos(1,1)
- print("--- User Edit ---")
- print("Login: "..input)
- print("Role: "..perm)
- print()
- print()
- print("Select action")
- print("A - Change passcode")
- print("B - Change role")
- print("C - Delete user")
- print("D - Print user info")
- print("E - Encode access card")
- print("F - Go back")
- print()
- print()
- print("Type selected letter")
- action = read()
- if action == "A" then
- if (val == "0") or (val == "1") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- else
- if (permin == "4A") or (permin == "4B") or (permin == "4C") or (permin == "5") or (permin == "6") or (permin == "7") then
- if (val == "7") then
- print("New passcode")
- new = read("*")
- local user = fs.open("disk/crew/"..input,"w")
- user.writeLine(p.hash("MD5", new))
- user.flush()
- user.close()
- print("Done")
- else
- if ((val == "4B") or (val == "5") or (val == 6)) and ((permin == "4A") or (permin == "4C")) then
- print("New passcode")
- new = read("*")
- local user = fs.open("disk/crew/"..input,"w")
- user.writeLine(p.hash("MD5", new))
- user.flush()
- user.close()
- print("Done")
- else
- if ((val == "5") or (val == 6)) and (permin == "4B") then
- print("New passcode")
- new = read("*")
- local user = fs.open("disk/crew/"..input,"w")
- user.writeLine(p.hash("MD5", new))
- user.flush()
- user.close()
- print("Done")
- else
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- end
- end
- else
- if (permin == "3") and (val == "3") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- else
- if (val == "2") and (permin ~= "0") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- else
- print("New passcode")
- new = read("*")
- local user = fs.open("disk/crew/"..input,"w")
- user.writeLine(p.hash("MD5", new))
- user.flush()
- user.close()
- print("Done")
- end
- end
- end
- end
- sleep (2)
- end
- if action == "B" then
- term.clear()
- term.setCursorPos(1,1)
- if (val == "0") or (val == "1") or (val == "2") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- else
- if (permin == "4A") or (permin == "4B") or (permin == "4C") or (permin == "5") or (permin == "6") or (permin == "7") then
- if (val == "7") then
- print("Ranks you can give:")
- print("0 - User")
- print("1 - Maintainer")
- print("2 - Enroller")
- print("3 - Supervisor")
- print("4A - Account Admin")
- print("4B - Security Admin")
- print("4C - Infrastructure Admin")
- print("5 - Admin")
- print("6 - Technician")
- print("7 - SuperUser")
- print()
- print()
- print("Type selected digit (leave blank to abort)")
- action = read()
- if (action == "0") then
- if (fs.exists("disk/perm/"..input)) then
- fs.delete("disk/perm/"..input)
- end
- print("Done")
- end
- if (action == "1") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "2") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "3") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "4A") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "4B") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "4C") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "5") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "6") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "7") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- else
- if ((val == "4B") or (val == "5") or (val == 6)) and ((permin == "4A") or (permin == "4C")) then
- print("Ranks you can give:")
- print("0 - User")
- print("1 - Maintainer")
- print("2 - Enroller")
- print("3 - Supervisor")
- print("4A - Account Admin")
- print("4C - Infrastructure Admin")
- print("Ranks you can't give:")
- print("4B - Security Admin")
- print("5 - Admin")
- print("6 - Technician")
- print("7 - SuperUser")
- print()
- print()
- print("Type selected digit (leave blank to abort)")
- action = read()
- if (action == "0") then
- if (fs.exists("disk/perm/"..input)) then
- fs.delete("disk/perm/"..input)
- end
- print("Done")
- end
- if (action == "1") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "2") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "3") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "4A") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "4B") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- if (action == "4C") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "5") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- if (action == "6") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- if (action == "7") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- else
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- end
- else
- if (permin == "3") and (val == "3") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- else
- if (val == "3") then
- print("Ranks you can give:")
- print("0 - User")
- print("1 - Maintainer")
- print("2 - Enroller")
- print("Ranks you can't give:")
- print("3 - Supervisor")
- print("4A - Account Admin")
- print("4B - Security Admin")
- print("4C - Infrastructure Admin")
- print("5 - Admin")
- print("6 - Technician")
- print("7 - SuperUser")
- print()
- print()
- print("Type selected digit (leave blank to abort)")
- action = read()
- if (action == "0") then
- if (fs.exists("disk/perm/"..input)) then
- fs.delete("disk/perm/"..input)
- end
- print("Done")
- end
- if (action == "1") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "2") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "3") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- if (action == "4A") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- if (action == "4B") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- if (action == "4C") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- if (action == "5") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- if (action == "6") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- if (action == "7") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- end
- if (val == "4A") or (val == "4C") then
- print("Ranks you can give:")
- print("0 - User")
- print("1 - Maintainer")
- print("2 - Enroller")
- print("3 - Supervisor")
- print("Ranks you can't give:")
- print("4A - Account Admin")
- print("4B - Security Admin")
- print("4C - Infrastructure Admin")
- print("5 - Admin")
- print("6 - Technician")
- print("7 - SuperUser")
- print()
- print()
- print("Type selected digit (leave blank to abort)")
- action = read()
- if (action == "0") then
- if (fs.exists("disk/perm/"..input)) then
- fs.delete("disk/perm/"..input)
- end
- print("Done")
- end
- if (action == "1") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "2") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "3") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "4A") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- if (action == "4B") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- if (action == "4C") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- if (action == "5") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- if (action == "6") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- if (action == "7") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- end
- if (val == "5") or (val == "6") then
- print("Ranks you can give:")
- print("0 - User")
- print("1 - Maintainer")
- print("2 - Enroller")
- print("3 - Supervisor")
- print("4A - Account Admin")
- print("4B - Security Admin")
- print("4C - Infrastructure Admin")
- print("Ranks you can't give:")
- print("5 - Admin")
- print("6 - Technician")
- print("7 - SuperUser")
- print()
- print()
- print("Type selected digit (leave blank to abort)")
- action = read()
- if (action == "0") then
- if (fs.exists("disk/perm/"..input)) then
- fs.delete("disk/perm/"..input)
- end
- print("Done")
- end
- if (action == "1") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "2") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "3") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "4A") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "4B") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "4C") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "5") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- if (action == "6") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- if (action == "7") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- end
- if val == "4B" then
- print("Ranks you can give:")
- print("0 - User")
- print("1 - Maintainer")
- print("2 - Enroller")
- print("3 - Supervisor")
- print("4A - Account Admin")
- print("4C - Infrastructure Admin")
- print("Ranks you can't give:")
- print("4B - Security Admin")
- print("5 - Admin")
- print("6 - Technician")
- print("7 - SuperUser")
- print()
- print()
- print("Type selected digit (leave blank to abort)")
- action = read()
- if (action == "0") then
- if (fs.exists("disk/perm/"..input)) then
- fs.delete("disk/perm/"..input)
- end
- print("Done")
- end
- if (action == "1") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "2") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "3") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "4A") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "4B") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- if (action == "4C") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "5") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- if (action == "6") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- if (action == "7") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- end
- if (val == "7") then
- print("Ranks you can give:")
- print("0 - User")
- print("1 - Maintainer")
- print("2 - Enroller")
- print("3 - Supervisor")
- print("4A - Account Admin")
- print("4B - Security Admin")
- print("4C - Infrastructure Admin")
- print("5 - Admin")
- print("6 - Technician")
- print("7 - SuperUser")
- print()
- print()
- print("Type selected digit (leave blank to abort)")
- action = read()
- if (action == "0") then
- if (fs.exists("disk/perm/"..input)) then
- fs.delete("disk/perm/"..input)
- end
- print("Done")
- end
- if (action == "1") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "2") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "3") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "4A") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "4B") then
- if (fs.exists("disk/perm/"..input)) then
- fs.delete("disk/perm/"..input)
- end
- print("Done")
- end
- if (action == "4C") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "5") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "6") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- if (action == "7") then
- local user = fs.open("disk/perm/"..input,"w")
- user.writeLine(action)
- user.flush()
- user.close()
- print("Done")
- end
- end
- sleep (2)
- end
- end
- end
- end
- if action == "C" then
- print ("Do you want to delete user "..input.."?")
- print ("This is last confirmation.")
- print ("Type YES to delete.")
- action = read()
- if action == "YES" then
- if (val == "0") or (val == "1") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- else
- if (permin == "4A") or (permin == "4B") or (permin == "4C") or (permin == "5") or (permin == "6") or (permin == "7") then
- if (val == "7") then
- fs.delete("disk/crew/"..input)
- if (fs.exists("disk/perm/"..input)) then
- fs.delete("disk/perm/"..input)
- end
- rep = false
- print("Done")
- else
- if ((val == "4B") or (val == "5") or (val == 6)) and ((permin == "4A") or (permin == "4C")) then
- fs.delete("disk/crew/"..input)
- if (fs.exists("disk/perm/"..input)) then
- fs.delete("disk/perm/"..input)
- end
- rep = false
- print("Done")
- else
- if ((val == "5") or (val == 6)) and (permin == "4B") then
- fs.delete("disk/crew/"..input)
- if (fs.exists("disk/perm/"..input)) then
- fs.delete("disk/perm/"..input)
- end
- rep = false
- print("Done")
- else
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- end
- end
- else
- if (permin == "3") and (val == "3") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- else
- if (val == "2") and (permin ~= "0") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- else
- fs.delete("disk/crew/"..input)
- if (fs.exists("disk/perm/"..input)) then
- fs.delete("disk/perm/"..input)
- end
- rep = false
- print("Done")
- end
- end
- end
- end
- sleep (2)
- else
- print("Aborted")
- sleep(2)
- end
- end
- if action == "D" then
- if (fs.exists("disk/config/system/print") and (fs.exists("config/ovr") == false)) or (fs.exists("config/print")) then
- print()
- print("* IMPROPER REQUEST *")
- print("-------------------------")
- print("* Operation Unallowed *")
- sleep(2)
- else
- local printer = peripheral.wrap("right")
- if (printer.getInkLevel() > 0) and (printer.getPaperLevel() > 0) then
- printer.newPage()
- printer.setCursorPos(1,1)
- printer.write("---- USER DATA ---")
- printer.setCursorPos(1,2)
- printer.write("Login: "..input)
- printer.setCursorPos(1,3)
- printer.write("Role: "..perm)
- printer.setCursorPos(1,12)
- printer.write("Printed by: "..login)
- printer.setPageTitle("User "..input)
- printer.endPage()
- print("Done")
- sleep(2)
- else
- print("Please insert ink and paper to printer.")
- sleep(2)
- end
- end
- end
- if action == "E" then
- if (val == "0") or (val == "1") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- else
- if (permin == "4A") or (permin == "4B") or (permin == "4C") or (permin == "5") or (permin == "6") or (permin == "7") then
- if (val == "7") then
- local file = fs.open("disk/crew/"..input,"r")
- local passu = file.readLine()
- file.close()
- print("Swipe magnetic card")
- print("Hold CTRL + S to cancel")
- local reader = peripheral.wrap("left")
- reader.setInsertCardLight(false)
- reader.beginWrite(passu,input.."'s card")
- local event,arg1,arg2,arg3 = os.pullEvent()
- sleep (4)
- else
- if ((val == "4B") or (val == "5") or (val == 6)) and ((permin == "4A") or (permin == "4C")) then
- local file = fs.open("disk/crew/"..input,"r")
- local passu = file.readLine()
- file.close()
- print("Swipe magnetic card")
- print("Hold CTRL + S to cancel")
- local reader = peripheral.wrap("left")
- reader.setInsertCardLight(false)
- reader.beginWrite(passu,input.."'s card")
- local event,arg1,arg2,arg3 = os.pullEvent()
- sleep (4)
- else
- if ((val == "5") or (val == 6)) and (permin == "4B") then
- local file = fs.open("disk/crew/"..input,"r")
- local passu = file.readLine()
- file.close()
- print("Swipe magnetic card")
- print("Hold CTRL + S to cancel")
- local reader = peripheral.wrap("left")
- reader.setInsertCardLight(false)
- reader.beginWrite(passu,input.."'s card")
- local event,arg1,arg2,arg3 = os.pullEvent()
- sleep (4)
- else
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- end
- end
- end
- else
- if (permin == "3") and (val == "3") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- else
- if (val == "2") and (permin ~= "0") then
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- else
- local file = fs.open("disk/crew/"..input,"r")
- local passu = file.readLine()
- file.close()
- print("Swipe magnetic card")
- print("Hold CTRL + S to cancel")
- local reader = peripheral.wrap("left")
- reader.setInsertCardLight(false)
- reader.beginWrite(passu,input.."'s card")
- local event,arg1,arg2,arg3 = os.pullEvent()
- sleep (4)
- end
- end
- end
- end
- sleep (2)
- end
- if action == "F" then
- rep = false
- end
- end
- rep = true
- else
- print("User not found")
- sleep(2)
- end
- else
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- sleep(2)
- end
- else
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- sleep(2)
- end
- end
- if input == "C" then
- rep = false
- input = ""
- end
- end
- rep = true
- else
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- sleep(2)
- end
- else
- print()
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- sleep(2)
- end
- end
- if input == "C" then
- if fs.exists("disk/config/system/encode") and (fs.exists("config/ovr") == false) then
- print()
- print("* IMPROPER REQUEST *")
- print("-------------------------")
- print("* Operation Unallowed *")
- sleep(2)
- else
- print("Current passcode ")
- current = read("*")
- if (p.hash("MD5", current) == pass) then
- print("Swipe magnetic card")
- local reader = peripheral.wrap("left")
- reader.setInsertCardLight(false)
- reader.beginWrite(pass,login.."'s card")
- local event,arg1,arg2,arg3 = os.pullEvent()
- sleep (4)
- else
- print("Invalid Passcode")
- sleep (2)
- end
- end
- end
- if input == "E" then
- if login == "root" then
- term.clear()
- term.setCursorPos(1,1)
- print("Welcome SuperUser")
- rep = false
- else
- if (fs.exists("disk/perm/"..login)) then
- local perm = fs.open("disk/perm/"..login, "r")
- val = perm.readLine()
- perm.close()
- if val == "7" then
- term.clear()
- term.setCursorPos(1,1)
- print("Welcome SuperUser")
- rep = false
- else
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- sleep(2)
- end
- else
- print()
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- sleep(2)
- end
- end
- end
- if input == "G" then
- val = "0"
- if (fs.exists("disk/perm/"..login)) then
- local perm = fs.open("disk/perm/"..login, "r")
- val = perm.readLine()
- perm.close()
- else
- val = "0"
- end
- if (val ~= "0") and (val ~= "1") and (val ~= "2") and (val ~= "3") and (val ~= "4A") then
- rep = true
- while rep do
- term.clear()
- term.setCursorPos(1,1)
- print("--- Local System Configuration ---")
- print("Select action")
- if fs.exists("config/print") then
- print("A - Allow print user (on right side), Denied")
- else
- print("A - Allow print user (on right side), Allowed")
- end
- if fs.exists("config/ovr") then
- print("B - Override all global blocks, Yes")
- else
- print("B - Override all global blocks, No")
- end
- if fs.exists("config/reqlvl") then
- local reqlvlf = fs.open("config/reqlvl","r")
- reqlvl = reqlvlf.readLine()
- reqlvlf.close()
- print("C - Required Access Level, "..reqlvl)
- else
- print("C - Required Access Level, 0")
- end
- print("D - Go back")
- print()
- print()
- print("Type selected letter")
- input = read()
- if input == "A" then
- if fs.exists("config/print") then
- fs.delete("config/print")
- else
- local cre = fs.open("config/print", "a")
- cre.writeLine()
- cre.flush()
- cre.close()
- end
- end
- if input == "B" then
- if (val ~= "5") and (val ~= "6") and (val ~= "7") then
- print()
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- sleep(2)
- else
- if fs.exists("config/ovr") then
- fs.delete("config/ovr")
- else
- local cre = fs.open("config/ovr", "a")
- cre.writeLine()
- cre.flush()
- cre.close()
- end
- end
- end
- if input == "C" then
- valt = val
- curlvl = 0
- if (valt == "4A") or (valt == "4B") or (valt == "4C") then
- valt = "4"
- end
- if fs.exists("config/reqlvl") then
- local reqlvlf = fs.open("config/reqlvl","r")
- curlvl = reqlvlf.readLine()
- reqlvlf.close()
- end
- term.clear()
- term.setCursorPos(1,1)
- print("Enter required access level")
- print()
- print("Levels you can choose")
- print("0 - User")
- print("1 - Maintainer")
- print("2 - Enroller")
- print("3 - Supervisor")
- print("4 - Account/Security/Infrastructure Admin")
- if (valt == "4") then
- print()
- print("Levels you can't choose")
- print("5 - Admin")
- print("6 - Technician")
- print("7 - SuperUser")
- end
- if (valt == "5") then
- print("5 - Admin")
- print()
- print("Levels you can't choose")
- print("6 - Technician")
- print("7 - SuperUser")
- end
- if (valt == "6") then
- print("5 - Admin")
- print("6 - Technician")
- print()
- print("Levels you can't choose")
- print("7 - SuperUser")
- end
- if (valt == "7") then
- print("5 - Admin")
- print("6 - Technician")
- print("7 - SuperUser")
- end
- print()
- print()
- print("Enter permission NUMBER (like 2, 3, 4, etc...)")
- perm = read()
- if (perm == "0") then
- fs.delete("config/reqlvl")
- print("Done")
- end
- if (perm == "1") then
- local newperm = fs.open("config/reqlvl", "a")
- newperm.writeLine("1")
- newperm.flush()
- newperm.close()
- end
- if (perm == "2") then
- local newperm = fs.open("config/reqlvl", "a")
- newperm.writeLine("2")
- newperm.flush()
- newperm.close()
- end
- if (perm == "3") then
- local newperm = fs.open("config/reqlvl", "a")
- newperm.writeLine("3")
- newperm.flush()
- newperm.close()
- end
- if (perm == "4") then
- local newperm = fs.open("config/reqlvl", "a")
- newperm.writeLine("4")
- newperm.flush()
- newperm.close()
- end
- if (perm == "5") then
- if (valt == "4") then
- print()
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- sleep(2)
- else
- local newperm = fs.open("config/reqlvl", "a")
- newperm.writeLine("5")
- newperm.flush()
- newperm.close()
- end
- end
- if (perm == "6") then
- if (valt == "4") or (valt == "5") then
- print()
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- sleep(2)
- else
- local newperm = fs.open("config/reqlvl", "a")
- newperm.writeLine("6")
- newperm.flush()
- newperm.close()
- end
- end
- if (perm == "7") then
- if (valt == "4") or (valt == "5") or (valt == "6") then
- print()
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- sleep(2)
- else
- local newperm = fs.open("config/reqlvl", "a")
- newperm.writeLine("7")
- newperm.flush()
- newperm.close()
- end
- end
- end
- if input == "D" then
- rep = false
- input = ""
- end
- end
- else
- print()
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- sleep(2)
- end
- rep = true
- end
- if input == "H" then
- val = "0"
- if (fs.exists("disk/perm/"..login)) then
- local perm = fs.open("disk/perm/"..login, "r")
- val = perm.readLine()
- perm.close()
- else
- val = "0"
- end
- if (val ~= "0") and (val ~= "1") and (val ~= "2") and (val ~= "3") and (val ~= "4A") and (val ~= "4B") and (val ~= "4C") then
- rep = true
- while rep do
- rep = true
- while rep do
- term.clear()
- term.setCursorPos(1,1)
- print("--- Global System Configuration ---")
- print("Select action")
- if fs.exists("disk/config/system/delete") then
- print("A - Delete my account, Denied")
- else
- print("A - Delete my account, Allowed")
- end
- if fs.exists("disk/config/system/passcode") then
- print("B - Change my passcode, Denied")
- else
- print("B - Change my passcode, Allowed")
- end
- if fs.exists("disk/config/system/print") then
- print("C - Print user data, Denied")
- else
- print("C - Print user data, Allowed")
- end
- if fs.exists("disk/config/system/encode") then
- print("D - Encode access card, Denied")
- else
- print("D - Encode access card, Allowed")
- end
- print("E - Go Back")
- input = read()
- if input == "A" then
- if fs.exists("disk/config/system/delete") then
- fs.delete("disk/config/system/delete")
- else
- local cre = fs.open("disk/config/system/delete", "a")
- cre.writeLine()
- cre.flush()
- cre.close()
- end
- end
- if input == "B" then
- if fs.exists("disk/config/system/passcode") then
- fs.delete("disk/config/system/passcode")
- else
- local cre = fs.open("disk/config/system/passcode", "a")
- cre.writeLine()
- cre.flush()
- cre.close()
- end
- end
- if input == "C" then
- if fs.exists("disk/config/system/print") then
- fs.delete("disk/config/system/print")
- else
- local cre = fs.open("disk/config/system/print", "a")
- cre.writeLine()
- cre.flush()
- cre.close()
- end
- end
- if input == "D" then
- if fs.exists("disk/config/system/encode") then
- fs.delete("disk/config/system/encode")
- else
- local cre = fs.open("disk/config/system/encode", "a")
- cre.writeLine()
- cre.flush()
- cre.close()
- end
- end
- if input == "E" then
- rep = false
- input = ""
- end
- end
- end
- rep = true
- else
- print()
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- sleep(2)
- end
- end
- if input == "I" then
- if fs.exists("disk/config/system/delete") and (fs.exists("config/ovr") == false) then
- print()
- print("* IMPROPER REQUEST *")
- print("-------------------------")
- print("* Operation Unallowed *")
- sleep(2)
- else
- print("Current passcode")
- current = read("*")
- if (p.hash("MD5", current) == pass) then
- fs.delete("disk/crew/"..login)
- print("Done")
- sleep(2)
- os.shutdown()
- else
- print("Invalid Passcode")
- sleep (2)
- end
- end
- end
- if input == "J" then
- os.shutdown()
- end
- end
- else
- print()
- print("** IMPROPER REQUEST **")
- print("-----------------------")
- print(" ** ACCESS DENIED **")
- sleep(2)
- os.shutdown()
- end
- else
- print("Refused")
- sleep(2)
- os.shutdown()
- end
- else
- print("Refused")
- sleep (2)
- os.shutdown()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement