Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.78 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2.  
  3. users = {"Deklungel" , "Blaze" , "Anubis" , "adi" , "bob"}
  4. pass  = {"aap" , "3804" , "2971", "jammin" , "101" }
  5. accesslevels = {5, 6 , 5 , 5 , 2 }
  6.  
  7. requiredaccess = 5
  8. monitoringstation = 1694
  9. modemside = "back"
  10.  
  11.  
  12. repeat
  13.  
  14. correctuser = false
  15. correctpassword = false
  16. canaccess = false
  17. accessed = false
  18.  
  19.    term.clear()
  20.    term.setCursorPos(16,7)
  21.    write("Username: ")
  22.    user = read()
  23.  
  24.    for i,v in ipairs(users) do
  25.       if user == v
  26.       then
  27.          
  28. correctuser = true
  29.          password = pass[i]
  30.          accesslevel = accesslevels[i]
  31.          term.setCursorPos(16,8)
  32.          write("Password: ")
  33.       if  read("*") == password
  34.          
  35.  
  36.          then
  37.             correctpassword = true
  38.             if accesslevel >= requiredaccess
  39.  
  40.             then
  41.                canaccess = true
  42.  
  43.             end
  44.          end
  45.       end
  46.    end
  47.  
  48.    if correctuser == true and correctpassword == true and
  49. canaccess == true
  50.  
  51.    then term.setCursorPos(1,7)
  52.    term.clear()
  53.    print("                Access Allowed")
  54.    print("")
  55.    print("              Welcome Back "..user)
  56.    accessed = true
  57.    
  58.    
  59. elseif correctuser == true and correctpassword == true and canaccess == false
  60.  
  61.    then
  62.       n = tonumber(accesslevel)
  63.       s = ""
  64.       for i = 1, n do
  65.          s = s.."*"
  66.       end
  67.  
  68.       m = tonumber(requiredaccess)
  69.       d = ""
  70.       for i = 1, m do
  71.          d = d.."*"
  72.       end
  73.      
  74.       term.setCursorPos(1,6)
  75.       term.clear()
  76.       print("                  Access Denied")
  77.       print("               Failed Access check")
  78.       print("")
  79.       print("")
  80.       print("")
  81.       print("               Your Access is "..s)
  82.       print("           This process requires "..d)
  83.       sleep(3)
  84.  
  85.  
  86.    elseif
  87.  
  88.       correctuser == false
  89.       then
  90.          term.setCursorPos(1,7)
  91.          print("                  Access Denied")
  92.          print("          "..user.." is not a registered user")
  93.          sleep(1)
  94. rednet.open(modemside)
  95. rednet.send(monitoringstation, user.." attempted access")
  96. rednet.close(modemside)
  97. fs.makeDir("Logins")
  98. local file = fs.open("Logins/Fails", "a")
  99. file.writeLine(tostring("User: "..user.." attempted access"))
  100. file.close()
  101.  
  102.       elseif
  103.  
  104.          correctuser == true and correctpassword == false
  105.          
  106.          then
  107.          term.clear()
  108.          term.setCursorPos(1,8)
  109.          print("               Incorrect Password")
  110.          sleep(1)
  111. rednet.open(modemside)
  112. rednet.send(monitoringstation, "Username "..user.." failed password check")
  113. rednet.close(modemside)
  114. local file = fs.open("Logins/Accessed","a")
  115. file.writeLine(user.." Accessed this terminal")
  116. file.close()    
  117.  
  118. else
  119.          
  120. print("Access Denied")
  121.  
  122.       end
  123.  
  124.    until
  125.    accessed == true
  126.    sleep(1)
  127. rs.setOutput("top", true)
  128.  
  129. shell.run("menu")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement