Advertisement
Guest User

startup

a guest
Nov 12th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.94 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw -- This Does Not Allow You to CTRL+T
  2.  
  3. ----------------------
  4. -- Use              --
  5. -- User: ADMIN      --
  6. -- Password: ADMIN  --
  7. --                  --
  8. -- To exit program  --
  9. ----------------------
  10. -- To Create A User --
  11. -- Create a file in --
  12. -- Directory acc/   --
  13. -- And the filename --
  14. -- Is the Username  --
  15. -- The First Line   --
  16. -- Is The Password  --
  17. -- And The Second   --
  18. -- Line Is The # of --
  19. -- Tries Left.      --
  20. ----------------------
  21.  
  22. if not fs.exists("config.cfg") then
  23.   po = fs.open("config.cfg", "w")
  24.   po.write("false")
  25.   po.close()
  26. else
  27.   ip = fs.open("config.cfg", "r")
  28.   if ip.readLine() == "true" then
  29.     ip.close()
  30.     checkTries(MaxTries)
  31.   else
  32.     login()
  33.   end
  34.  
  35. end
  36.  
  37.  
  38. function clear()
  39.   term.clear()
  40.   term.setCursorPos(1,1)
  41. end
  42.  
  43. if Ch == nil then
  44.   Ch = 0
  45. end
  46.  
  47.  
  48.  
  49. password = "super"
  50. Side = "left"
  51. Sec = 5
  52. MaxTries = 5
  53.  
  54. function login()
  55.   clear()
  56.   -- print("You have used "..Ch.."/"..MaxTries.." tries")
  57.   write("Username: ")
  58.   User = read()
  59.   -- print()
  60.   write("Enter Password: ")
  61.   input = read("*")
  62.   if User ~= "ADMIN" and input ~= "ADMIN" then
  63.     checkUser(User, input)
  64.   else
  65.     error()
  66.   end
  67.  
  68.   login()
  69. if false then  
  70.   if input == password then
  71.     rs.setOutput(Side, true)
  72.     clear()
  73.     print("Welcome User!")
  74.     sleep(Sec)
  75.     rs.setOutput(Side, false)
  76.     Ch = 0
  77.   else
  78.     Ch = Ch + 1
  79.     clear()
  80.     textutils.slowPrint("Incorrect Password You Have "..Ch.."/"..MaxTries.." tries left")
  81.     if not checkTries(Ch) then
  82.       login()
  83.     end
  84.   end
  85. end  
  86. end
  87.  
  88. function checkTries(Tries)
  89.   Tries = tonumber(Tries)
  90.   if Tries >= MaxTries then
  91.     clear()
  92.     print("This Computer Is Locked Please Contact Your Admin")
  93.     up = fs.open("config.cfg", "w")
  94.     up.write("true")
  95.     up.close()
  96.     while true do
  97.       ce = read()
  98.       if string.lower(ce) == "reset md5 hash" then
  99.         break
  100.       end
  101.     end
  102.     Ch = 0
  103.     login()
  104.   else
  105.     return false
  106.   end
  107. end
  108.  
  109. function checkUser(N, P)
  110.   -- N = User Submitted Username
  111.   -- P = User Submitted Password
  112.   if fs.exists("acc/"..N) then
  113.     OP = fs.open("acc/"..N, "r")
  114.     -- Things = OP.readAll()
  115.     -- OP.close()
  116.     Pass = OP.readLine()
  117.     Ch = OP.readLine()
  118.     if P == Pass then
  119.       Chs = 0
  120.       OI = fs.open("acc/"..N,"w")
  121.       OI.write(P.."\n"..Chs)
  122.       OI.close()
  123.       rs.setOutput(Side, true)
  124.       print()
  125.       print("Welcome "..N)
  126.       sleep(Sec)
  127.       rs.setOutput(Side, false)
  128.       login()
  129.     else
  130.       clear()
  131.       Ch = tonumber(Ch)
  132.       Chs = Ch + 1
  133.       ff = fs.open("acc/"..N, "w")
  134.       ff.write(Pass.."\n"..Chs)
  135.       ff.close()
  136.       checkTries(Chs)
  137.       print("Incorrect Password You Have "..Chs.."/"..MaxTries.." left")
  138.       sleep(3)
  139.       login()
  140.     end
  141.   else
  142.     printError("Error: Account Does Not Exist")
  143.     sleep(5)
  144.     login()
  145.   end
  146. end
  147.  
  148. if not checkTries(Ch) then
  149.   login()
  150. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement