Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Function to draw a border (remains the same)
- local function drawBorder()
- term.clear()
- local w, h = term.getSize()
- -- Drawing vertical sides of the border
- for y = 1, h do
- term.setCursorPos(1, y)
- term.write("|")
- term.setCursorPos(w, y)
- term.write("|")
- end
- -- Drawing horizontal sides of the border
- for x = 1, w do
- term.setCursorPos(x, 1)
- term.write("-")
- term.setCursorPos(x, h)
- term.write("-")
- end
- -- Drawing the corner points
- term.setCursorPos(1, 1)
- term.write("+")
- term.setCursorPos(w, 1)
- term.write("+")
- term.setCursorPos(1, h)
- term.write("+")
- term.setCursorPos(w, h)
- term.write("+")
- end
- -- Function to draw buttons (with color and borders)
- local function drawButton(text, y)
- local w, h = term.getSize()
- local buttonWidth = #text + 4
- local buttonX = math.floor((w - buttonWidth) / 2)
- -- Draw the button border
- term.setCursorPos(buttonX, y)
- term.write("+" .. string.rep("-", #text) .. "+")
- term.setCursorPos(buttonX, y + 1)
- term.write("| " .. text .. " |")
- term.setCursorPos(buttonX, y + 2)
- term.write("+" .. string.rep("-", #text) .. "+")
- end
- -- Function to center text on the screen
- local function centerText(text, y)
- local w, _ = term.getSize()
- local x = math.floor((w - #text) / 2) + 1
- term.setCursorPos(x, y)
- term.write(text)
- end
- -- Function to show UEFI options menu
- local function showMenu()
- drawBorder()
- local _, h = term.getSize()
- centerText("Doggy OS UEFI Options", math.floor(h / 2) - 4)
- -- Draw buttons for the menu
- drawButton("1. Recovery", math.floor(h / 2))
- drawButton("2. Bootable devices", math.floor(h / 2) + 3)
- drawButton("3. Shutdown", math.floor(h / 2) + 6)
- end
- -- Function to handle menu selection
- local function handleSelection()
- while true do
- local event, key = os.pullEvent("key")
- if key == keys.one then
- shell.run("/disk/boot/Recovery.lua")
- elseif key == keys.two then
- shell.run("bootman")
- elseif key == keys.three then
- os.shutdown()
- end
- end
- end
- -- Function to verify user credentials (unchanged)
- local function verifyCredentials(username, password)
- local userPath = "/disk/users/" .. username
- if fs.exists(userPath .. "/admin.txt") and fs.exists(userPath .. "/password.txt") then
- local file = fs.open(userPath .. "/password.txt", "r")
- local storedPassword = file.readAll()
- file.close()
- return storedPassword == password
- end
- return false
- end
- -- Function to authenticate user (unchanged)
- local function authenticate()
- term.clear()
- drawBorder()
- local _, h = term.getSize()
- centerText("Doggy OS UEFI Authentication", 3)
- local w, _ = term.getSize()
- local usernameX = math.floor(w / 2) - 10
- term.setCursorPos(usernameX, 5)
- term.write("Username: ")
- term.setCursorPos(usernameX + 10, 5)
- local username = read()
- term.setCursorPos(usernameX, 7)
- term.write("Password: ")
- term.setCursorPos(usernameX + 10, 7)
- local password = read("*") -- Masked input for password
- if verifyCredentials(username, password) then
- showMenu()
- handleSelection()
- else
- centerText("Invalid credentials. Access denied.", 10)
- os.sleep(2)
- os.reboot()
- end
- end
- -- Start authentication process
- authenticate()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement