Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local MAX_ATTEMPTS = 3 -- Maximum number of incorrect password attempts allowed
- local LOCKOUT_TIME = 30 -- Lockout time in seconds after reaching maximum attempts
- local USERS_FOLDER = "/disk/users/"
- local ERROR_FOLDER = "/disk/error/"
- local BSOD_PROGRAM = "BSOD.lua"
- local RECOVERY_PROGRAM = "/disk/boot/Recovery.lua"
- local function getUserCredentials(username)
- local passwordFile = fs.combine(USERS_FOLDER .. username, "password.txt")
- if fs.exists(passwordFile) then
- local file = fs.open(passwordFile, "r")
- local storedPassword = file.readLine()
- file.close()
- return storedPassword
- else
- return nil -- User does not exist
- end
- end
- -- Define functions for drawing GUI elements
- local function drawGUI()
- term.setBackgroundColor(colors.red)
- term.clear()
- term.setCursorPos(1, 1)
- term.setTextColor(colors.white)
- term.write("Reboot")
- term.setCursorPos(1, 3)
- term.write("Shutdown")
- term.setCursorPos(1, 5)
- term.write("Reboot to Recovery")
- end
- local function handleGUI()
- local selectedOption = 1
- while true do
- drawGUI()
- term.setCursorPos(1, selectedOption * 2 - 1)
- term.setTextColor(colors.red)
- term.write(">")
- local _, key = os.pullEvent("key")
- if key == keys.up and selectedOption > 1 then
- selectedOption = selectedOption - 1
- elseif key == keys.down and selectedOption < 3 then
- selectedOption = selectedOption + 1
- elseif key == keys.enter then
- if selectedOption == 1 then
- -- Reboot
- term.clear()
- term.setCursorPos(1, 1)
- print("Rebooting...")
- os.sleep(2)
- os.reboot()
- elseif selectedOption == 2 then
- -- Shutdown
- term.clear()
- term.setCursorPos(1, 1)
- print("Shutting down...")
- os.sleep(2)
- os.shutdown()
- elseif selectedOption == 3 then
- -- Reboot to Recovery
- term.clear()
- term.setCursorPos(1, 1)
- print("Rebooting to Recovery...")
- os.sleep(3)
- shell.run(RECOVERY_PROGRAM)
- end
- end
- end
- end
- -- Rest of your code...
- local function main()
- -- Your existing code here...
- end
- -- Intercept the terminate event
- local oldTerm = os.pullEvent
- os.pullEvent = function(event, ...)
- if event == "terminate" then
- print("Termination is not allowed.")
- return
- end
- return oldTerm(event, ...)
- end
- main()
- -- After main function call, start handling GUI
- handleGUI()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement