Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --]] Ease Functions [[--
- os.pullEvent = os.pullEventRaw
- os.loadAPI("sha256")
- function loader()
- bg(colors.green)
- cl()
- printxyc(15,2,colors.white,"Loading Main Screen...")
- local py = 25
- for i=0,5 do
- printxyc(py,15,colors.white, ":")
- sleep(0.1)
- printxyc(py,15,colors.white,"/")
- sleep(0.1)
- printxyc(py,15,colors.white,"-")
- sleep(0.1)
- end
- end
- local w,h = term.getSize()
- cont=false
- wsign=false;
- rs_side = 'right'
- function cl() term.clear() end
- function bg(color) term.setBackgroundColor(color) end
- function tc(color) term.setTextColor(color) end
- --function cprint_y(y,t) opx = ((w/2) - #t) - 2; setPos(opx,y); print(t) end
- function setPos(x,y) term.setCursorPos(x,y) end
- function printxyc(x,y,c,t) setPos(x,y); tc(c); print(t) end
- --]] Keycard Signin System By Redxone [[--
- function getKey()
- if(fs.exists(".key"))then
- k = fs.open(".key", "r")
- adkey = k.readLine()
- k.close()
- else
- local rndk = math.random(1,1000000)
- k = fs.open(".key", "w")
- k.writeLine(rndk)
- k.close()
- getKey()
- end
- end
- getKey()
- local aal = ".admin/.login/."..adkey
- function admin_pass()
- bg(colors.gray)
- setPos(16,10)
- print(string.rep(" ", 19) )
- printxyc(16,10,colors.red,"Enter Admin Password")
- setPos(16,11)
- print(" ")
- bg(colors.gray)
- setPos(35,11)
- print(" ")
- setPos(16,12)
- print(string.rep(" ", 20) )
- setPos(17,11)
- bg(colors.white)
- tc(colors.black)
- print(string.rep(" ", 18))
- f = fs.open(aal,"r")
- cpass = f.readLine()
- f.close()
- setPos(17,11)
- upass = read('*')
- upass = sha256.sha256(upass)
- bg(colors.gray)
- if(cpass == upass)then
- printxyc(17,12,colors.green,"CORRECT")
- sleep(0.5)
- return true
- end
- if(cpass ~= upass)then
- printxyc(17,12,colors.red,"DENIED")
- sleep(0.5)
- return false
- end
- end
- function lockpass()
- bg(colors.gray)
- setPos(11,10)
- print(string.rep(" ", 34) )
- printxyc(11,10,colors.red,"LOCKED DOWN - Enter Admin Password!")
- setPos(11,11)
- print(" ")
- bg(colors.gray)
- setPos(45,11)
- print(" ")
- setPos(11,12)
- print(string.rep(" ", 35) )
- setPos(12,11)
- bg(colors.white)
- tc(colors.black)
- print(string.rep(" ", 33))
- f = fs.open(aal,"r")
- cpass = f.readLine()
- f.close()
- setPos(12,11)
- upass = read('*')
- upass = sha256.sha256(upass)
- bg(colors.gray)
- locked=true
- while locked do
- if(cpass == upass)then
- printxyc(17,12,colors.green,"CORRECT")
- sleep(0.5)
- locked=false
- drawm()
- break
- end
- if(cpass ~= upass)then
- printxyc(17,12,colors.red,"DENIED")
- sleep(0.5)
- lockpass()
- end
- end
- end
- --]] Login GUI And Input Taker [--
- function print_login(type)
- --]] Admin Login [[--
- if(type == "c")then --]] >> Create <<
- bg(colors.green)
- tc(colors.white)
- cl()
- printxyc(5,2,colors.white,"No Admin Account Detected Please Create One.")
- printxyc(1,5,colors.red,"Username: Administrator")
- printxyc(1,7,colors.white,"Password: ")
- bg(colors.gray)
- printxyc(10,7,colors.white,string.rep(" ", 15))
- bg(colors.red)
- printxyc(20,13,colors.black,"[== CONFIRM ==]")
- bg(colors.gray)
- setPos(10,7)
- passinput = read("*")
- passinput = sha256.sha256(passinput)
- cont=true
- while cont do
- local event ,mb ,mx, my = os.pullEvent("mouse_click")
- --printxyc(1,1,colors.black,"X: "..mx.." Y: "..my.." B: "..mb)
- if(mx >= 20 and mx <= 34 and my == 13 and mb == 1)then
- --]] Continues Rest Of Code [[--
- cont=false
- break
- end
- end
- end
- if(type == "l")then --]] >> Login <<
- local mo = {}
- mo[1] = "[Unlock Entrance]"
- mo[2] = "[Create Account]"
- mo[3] = "[Delete Account]"
- mo[4] = "[Lock Interface]"
- local restricted = { [1] = false, [2] = true, [3] = true, [4] = true}
- local so = 1
- local mxo = 4
- menu=true;
- function drawm()
- bg(colors.green)
- tc(colors.white)
- cl()
- printxyc(4,2,colors.white,"Admin Account Detected Please Select An Option \n Some Options May Require Administrator Password.")
- for i=1,mxo do
- if(so == i)then
- setPos(15,7+i)
- print(">")
- setPos(18,7+i)
- bg(colors.blue)
- print(mo[i])
- else
- bg(colors.green)
- setPos(15,7+i)
- print(" ")
- setPos(18,7+i)
- print(mo[i])
- end
- end
- end
- drawm()
- function handledest()
- if(so == 1)then
- bg(colors.green)
- tc(colors.white)
- cl()
- xtl = 12
- printxyc(13,2,colors.white,"============================")
- printxyc(13,3,colors.white,"Please Login To User Profile")
- printxyc(13,4,colors.white,"============================")
- printxyc(1+xtl,8,colors.white,"Username: ")
- bg(colors.gray)
- printxyc(10+xtl,8,colors.white,string.rep(" ", 15))
- bg(colors.green)
- printxyc(1+xtl,10,colors.white,"Password: ")
- bg(colors.gray)
- printxyc(10+xtl,10,colors.white,string.rep(" ", 15))
- bg(colors.blue)
- printxyc(20,13,colors.black,"[== SIGN IN ==]")
- tc(colors.white)
- bg(colors.gray)
- setPos(10+xtl,8)
- iuser = read()
- setPos(10+xtl,10)
- ipass = read('*')
- ipass = sha256.sha256(ipass)
- wsign=true
- while wsign do
- local ev, button, mx, my = os.pullEvent("mouse_click")
- if(mx >= 20 and mx <= 34 and my == 13 and button == 1)then
- --]] Check Login [[--
- logpath = ".logins/.users/"
- if(fs.exists(logpath..iuser) and not fs.isDir(iuser) and iuser ~= " ")then
- f = fs.open(logpath..iuser,"r")
- cpass = f.readLine()
- f.close()
- if(ipass == cpass)then
- setPos(20,14)
- bg(colors.green)
- tc(colors.blue)
- textutils.slowPrint("Access Granted.")
- rs.setOutput(rs_side, true)
- sleep(1.5)
- rs.setOutput(rs_side, false)
- wsign=false
- drawm()
- break
- else
- setPos(20,14)
- bg(colors.green)
- tc(colors.red)
- textutils.slowPrint("Access Denied.")
- sleep(0.5)
- wsign=false;
- drawm()
- break
- end
- else
- setPos(20,14)
- bg(colors.green)
- tc(colors.red)
- textutils.slowPrint("Access Denied.")
- sleep(0.5)
- wsign=false;
- drawm()
- break
- end
- end
- end
- end
- if(so == 2)then
- bg(colors.green)
- tc(colors.white)
- cl()
- xtl = 12
- printxyc(13,2,colors.white,"============================")
- printxyc(13,3,colors.white,"| Create User Profile |")
- printxyc(13,4,colors.white,"============================")
- printxyc(1+xtl,8,colors.white,"Username: ")
- bg(colors.gray)
- printxyc(10+xtl,8,colors.white,string.rep(" ", 15))
- bg(colors.green)
- printxyc(1+xtl,10,colors.white,"Password: ")
- bg(colors.gray)
- printxyc(10+xtl,10,colors.white,string.rep(" ", 15))
- bg(colors.blue)
- printxyc(20,13,colors.black,"[== CREATE ==]")
- bg(colors.red)
- printxyc(20,15,colors.black,"[== CANCEL ==]")
- tc(colors.white)
- bg(colors.gray)
- setPos(10+xtl,8)
- iuser = read()
- setPos(10+xtl,10)
- ipass = read("*")
- ipass = sha256.sha256(ipass)
- wsign=true
- while wsign do
- local ev, button, mx, my = os.pullEvent("mouse_click")
- if(mx >= 20 and mx <= 32 and my == 13 and button == 1)then
- --]] Check Login [[--
- logpath = ".logins/.users/"
- if(fs.exists(logpath..iuser))then
- setPos(20,12)
- bg(colors.green)
- tc(colors.red)
- textutils.slowPrint("User Already Exists!")
- sleep(0.8)
- wsign=false;
- drawm()
- break
- else
- f = fs.open(logpath..iuser,"w")
- f.writeLine(ipass)
- f.close()
- setPos(20,12)
- bg(colors.green)
- tc(colors.red)
- textutils.slowPrint("User Created Successfully!")
- sleep(0.8)
- wsign=false;
- drawm()
- break
- end
- end
- if(mx >= 20 and mx <= 32 and my == 15 and button == 1)then
- wsign=false;
- drawm()
- break
- end
- end
- end
- if(so == 3)then
- bg(colors.green)
- tc(colors.white)
- cl()
- xtl = 12
- printxyc(13,2,colors.white,"============================")
- printxyc(13,3,colors.white,"| Delete User Profile |")
- printxyc(13,4,colors.white,"============================")
- printxyc(1+xtl,8,colors.white,"Username: ")
- bg(colors.gray)
- printxyc(10+xtl,8,colors.white,string.rep(" ", 15))
- bg(colors.blue)
- printxyc(20,13,colors.black,"[== DELETE ==]")
- bg(colors.red)
- printxyc(20,15,colors.black,"[== CANCEL ==]")
- tc(colors.white)
- bg(colors.gray)
- setPos(10+xtl,8)
- iuser = read()
- wsign=true
- while wsign do
- local ev, button, mx, my = os.pullEvent("mouse_click")
- if(mx >= 20 and mx <= 32 and my == 13 and button == 1)then
- --]] Check Login [[--
- logpath = ".logins/.users/"
- if(fs.exists(logpath..iuser))then
- fs.delete(logpath..iuser)
- setPos(20,12)
- bg(colors.green)
- tc(colors.green)
- textutils.slowPrint("User Deleted Successfully!")
- sleep(0.8)
- wsign=false;
- drawm()
- break
- else
- setPos(20,12)
- bg(colors.green)
- tc(colors.red)
- textutils.slowPrint("User Doesn't Exists!")
- sleep(0.8)
- wsign=false;
- drawm()
- break
- end
- end
- if(mx >= 20 and mx <= 32 and my == 15 and button == 1)then
- wsign=false;
- drawm()
- break
- end
- end
- end
- if(so == 4)then
- lockpass()
- end
- end
- while menu do
- local ev, key = os.pullEvent("key")
- if(key == keys.down and so < mxo)then so = so + 1; drawm() end
- if(key == keys.up and so > 1)then so = so - 1; drawm() end
- if(key == keys.enter)then
- if(restricted[so])then
- if(admin_pass())then
- drawm()
- handledest()
- else
- drawm()
- end
- else
- handledest()
- end
- end
- end
- end
- end
- function continue()
- --]] Check Administrator Account Exists [[--
- if(fs.exists(aal))then
- print_login("l")
- else
- --]] Create Account [[--
- print_login("c")
- f = fs.open(aal,"w")
- f.writeLine(passinput)
- f.close()
- loader()
- continue()
- end
- end
- continue()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement