Advertisement
Guest User

pass.sys

a guest
Jul 19th, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.92 KB | None | 0 0
  1.   f = loadfile("/window.lib(copy)")
  2.  
  3.   if f == nil then
  4.     print("error: window.lib is required please download it an set it at the path '/window.lib(copy)'")
  5.     os.exit()
  6.   end
  7.  
  8.  
  9.   win = f()
  10.  
  11.  
  12.   term = require("term")
  13.   computer = require("computer")
  14.  
  15.   term.clear()
  16.  
  17.  
  18.  
  19.  
  20.   f = {}
  21.  
  22.  
  23.   function loadpass(mode, val)
  24.     if mode == "write" then
  25.    
  26.       local d = io.open("/.pass.info", "w")
  27.  
  28.       d: write(val)
  29.  
  30.       d: close()
  31.    
  32.     elseif mode == "read" then
  33.  
  34.       local d = io.open("/.pass.info", "r")
  35.  
  36.       if d == nil then
  37.  
  38.         t = nil
  39.  
  40.        else
  41.  
  42.         t = d: read(require("filesystem").size("/.pass.info"))
  43.  
  44.         d: close()
  45.  
  46.       end
  47.  
  48.       return t
  49.     else
  50.  
  51.       error("the mode: '"..mode.."' don't exists")
  52.     end
  53.   end
  54.  
  55.  
  56.   _test = loadpass("read")
  57.  
  58.   print(_test) io.read()
  59.  
  60.  
  61.   if _test == nil then
  62.    
  63.     print(win.load(w.np))
  64.     io.read()
  65.   end
  66.  
  67.  
  68.  
  69.  
  70.   function f.npf(ts)
  71.  
  72.     loadpass("write", ts[1])
  73.  
  74.     computer.shutdown()
  75.   end    
  76.  
  77.  
  78.   function f.mf(ts)
  79.     term.clear()
  80.     if ts[1] == loadpass("read") then
  81.      
  82.       --error("pass word true")          
  83.       d = io.open("/.open.info", "w")
  84.  
  85.       d: write("true")
  86.  
  87.       d: close()
  88.  
  89.       computer.shutdown(true)  
  90.  
  91.     else
  92.  
  93.       win.load(wi.nt)
  94.     end
  95.   end
  96.  
  97.  
  98.  
  99.   wi = {}
  100.  
  101.  
  102.   wi.np = {set={x = "center", y = "center"}, code = {{"centerText","please write a new pass word"}, {"space"}, {"input"}, {"space"}, {"button", "click her to safe and reboot", f.npf}}}
  103.  
  104.   wi.m  = {set={x = "center", y = "center"}, code = {{"centerText","please write the password"}, {"space"}, {"input"}, {"space"}, {"button", "click her to login", f.mf}}}
  105.  
  106.   wi.nt = {set={x = "center", y = "center",w = 27, h = 6}, code = {{"centerText","the pass word is wrong!"}, {"space"}, {"button", "OK", computer.shutdown}}}
  107.  
  108.  
  109.   function main()
  110.  
  111.  
  112.     d,_ = io.open("/.pass.info")
  113.     term.clear()
  114.     if d == nil then
  115.  
  116.       win.load(wi.np)
  117.  
  118.     else
  119.  
  120.       win.load(wi.m)
  121.     end
  122.   end
  123.  
  124.  
  125.  
  126.   main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement