Advertisement
DOGGYWOOF

Untitled

Jan 23rd, 2025 (edited)
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.52 KB | None | 0 0
  1. -- Function to draw a border (remains the same)
  2. local function drawBorder()
  3. term.clear()
  4. local w, h = term.getSize()
  5. -- Drawing vertical sides of the border
  6. for y = 1, h do
  7. term.setCursorPos(1, y)
  8. term.write("|")
  9. term.setCursorPos(w, y)
  10. term.write("|")
  11. end
  12. -- Drawing horizontal sides of the border
  13. for x = 1, w do
  14. term.setCursorPos(x, 1)
  15. term.write("-")
  16. term.setCursorPos(x, h)
  17. term.write("-")
  18. end
  19. -- Drawing the corner points
  20. term.setCursorPos(1, 1)
  21. term.write("+")
  22. term.setCursorPos(w, 1)
  23. term.write("+")
  24. term.setCursorPos(1, h)
  25. term.write("+")
  26. term.setCursorPos(w, h)
  27. term.write("+")
  28. end
  29.  
  30. -- Function to draw buttons (with color and borders)
  31. local function drawButton(text, y)
  32. local w, h = term.getSize()
  33. local buttonWidth = #text + 4
  34. local buttonX = math.floor((w - buttonWidth) / 2)
  35.  
  36. -- Draw the button border
  37. term.setCursorPos(buttonX, y)
  38. term.write("+" .. string.rep("-", #text) .. "+")
  39. term.setCursorPos(buttonX, y + 1)
  40. term.write("| " .. text .. " |")
  41. term.setCursorPos(buttonX, y + 2)
  42. term.write("+" .. string.rep("-", #text) .. "+")
  43. end
  44.  
  45. -- Function to center text on the screen
  46. local function centerText(text, y)
  47. local w, _ = term.getSize()
  48. local x = math.floor((w - #text) / 2) + 1
  49. term.setCursorPos(x, y)
  50. term.write(text)
  51. end
  52.  
  53. -- Function to show UEFI options menu
  54. local function showMenu()
  55. drawBorder()
  56. local _, h = term.getSize()
  57. centerText("Doggy OS UEFI Options", math.floor(h / 2) - 4)
  58.  
  59. -- Draw buttons for the menu
  60. drawButton("1. Recovery", math.floor(h / 2))
  61. drawButton("2. Bootable devices", math.floor(h / 2) + 3)
  62. drawButton("3. Shutdown", math.floor(h / 2) + 6)
  63. end
  64.  
  65. -- Function to handle menu selection
  66. local function handleSelection()
  67. while true do
  68. local event, key = os.pullEvent("key")
  69. if key == keys.one then
  70. shell.run("/disk/boot/Recovery.lua")
  71. elseif key == keys.two then
  72. shell.run("bootman")
  73. elseif key == keys.three then
  74. os.shutdown()
  75. end
  76. end
  77. end
  78.  
  79. -- Function to verify user credentials (unchanged)
  80. local function verifyCredentials(username, password)
  81. local userPath = "/disk/users/" .. username
  82. if fs.exists(userPath .. "/admin.txt") and fs.exists(userPath .. "/password.txt") then
  83. local file = fs.open(userPath .. "/password.txt", "r")
  84. local storedPassword = file.readAll()
  85. file.close()
  86. return storedPassword == password
  87. end
  88. return false
  89. end
  90.  
  91. -- Function to authenticate user (unchanged)
  92. local function authenticate()
  93. term.clear()
  94. drawBorder()
  95. local _, h = term.getSize()
  96. centerText("Doggy OS UEFI Authentication", 3)
  97.  
  98. local w, _ = term.getSize()
  99. local usernameX = math.floor(w / 2) - 10
  100.  
  101. term.setCursorPos(usernameX, 5)
  102. term.write("Username: ")
  103. term.setCursorPos(usernameX + 10, 5)
  104. local username = read()
  105.  
  106. term.setCursorPos(usernameX, 7)
  107. term.write("Password: ")
  108. term.setCursorPos(usernameX + 10, 7)
  109. local password = read("*") -- Masked input for password
  110.  
  111. if verifyCredentials(username, password) then
  112. showMenu()
  113. handleSelection()
  114. else
  115. centerText("Invalid credentials. Access denied.", 10)
  116. os.sleep(2)
  117. os.reboot()
  118. end
  119. end
  120.  
  121. -- Start authentication process
  122. authenticate()
  123.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement