Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Main things.
- local response = http.get("https://pastebin.com/raw/k95Zv3e5")
- if response ~= nil then
- local s = response.readLine()
- local sl = string.len(s)
- local vs = string.sub(s,12,sl-1)
- v = vs..""
- local h = fs.open("Storage/version","r")
- local locv = h.readAll()
- h.close()
- if v ~= locv then
- local response = http.get("https://pastebin.com/raw/k95Zv3e5")
- local sresponse = response.readAll()
- response.close()
- local func = load(sresponse,"k95Zv3e5","t",_ENV)
- pcall(func)
- end
- end
- if fs.exists("OS/bypass") then
- shell.run("delete","OS/bypass")
- else
- local login = false
- local name = nil
- local password = nil
- local usernames = fs.list("Storage/Accounts/*")
- local passwords = {}
- for i=1,table.maxn(usernames) do
- h = fs.open("Storage/Accounts/"..usernames[i].."/password","r")
- passwords[i] = h.readAll()
- h.close()
- end
- os.pullEvent = os.pullEventRaw
- term.setBackgroundColor(colors.lightBlue)
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.green)
- term.write("TiagoOS")
- local w, h = term.getSize()
- term.setBackgroundColor(colors.white)
- local function writec(string, y)
- local ls = string.len(string)
- local x = w/2 - ls/2
- term.setCursorPos(x, y)
- term.write(string)
- end
- writec(" ", h/2 - 1)
- writec(" ", h/2 + 1)
- term.setBackgroundColor(colors.lightBlue)
- writec("Username: ",h/2-2)
- writec("Password: ",h/2)
- term.setBackgroundColor(colors.yellow)
- writec(" Log in ",h/2+3)
- term.setCursorPos(45,18)
- term.write("Create")
- term.setTextColor(colors.red)
- -- functions
- local function clearScreen()
- local w,h = term.getSize()
- term.setBackgroundColor(colors.lightBlue)
- term.setCursorPos(1,12)
- for i=1,51 do
- term.write(" ")
- end
- term.setBackgroundColor(colors.white)
- term.setCursorPos(w/2-5,h/2-1)
- for i=1,10 do
- term.write(" ")
- end
- term.setCursorPos(w/2-5,h/2+1)
- for i=1,10 do
- term.write(" ")
- end
- term.setCursorPos(45,18)
- term.setBackgroundColor(colors.lightBlue)
- for i=1,6 do
- term.write(" ")
- end
- term.setCursorPos(1,12)
- for i=1,51 do
- term.write(" ")
- end
- term.setCursorPos(1,14)
- for i=1,51 do
- term.write(" ")
- end
- end
- local function checkLogin()
- for i=1,table.maxn(usernames) do
- if(name==usernames[i])and(password==passwords[i])then
- h = fs.open("Storage/user","w")
- h.write(usernames[i])
- h.close()
- shell.run("OS/.Menu")
- elseif (name~=nil) and (password~=nil) then
- local loginErrorf = true
- end
- end
- return loginErrorf
- end
- local function read(max,which,secret)
- login = false
- word = nil
- term.setCursorBlink(true)
- while true do
- local event,p2,p3,p4 = os.pullEvent()
- local x, y = term.getCursorPos()
- if event == "char" then
- if word ~= nil then
- word = (word..p2)
- else
- word = p2
- end
- if secret == nil then
- term.write(p2)
- else
- term.write(secret)
- end
- term.setCursorPos(x + 1,y)
- max = max - 1
- elseif event == "key" then
- if p2 == 28 then
- login = true
- break
- elseif p2 == 14 then
- if max < 10 then
- word = string.sub(word,1,string.len(word)-1)
- max = max + 1
- term.setCursorPos(x-1,y)
- term.write(" ")
- term.setCursorPos(x-1,y)
- end
- elseif p2 == 203 then
- elseif p2 == 205 then
- else
- end
- elseif event == "mouse_click" then
- if which == "u" then
- if (p4~=h/2-1)or(p3<w/2-6) or (p3>w/2+4) then
- break
- end
- elseif which == "p" then
- if (p4~=h/2+1)or(p3<w/2-6) or (p3>w/2+4) then
- break
- end
- end
- end
- if max == 0 then
- break
- end
- end
- term.setCursorBlink(false)
- if word ~= nil then
- return word,login
- end
- end
- while true do
- w,h = term.getSize()
- if loginError == true then
- term.setCursorPos(w/2-13,h/2-4)
- term.setTextColour(colors.black)
- term.setBackgroundColor(colors.red)
- term.write("Wrong username or password")
- sleep(1)
- clearScreen()
- loginError = false
- term.setTextColor(colors.red)
- name = nil
- password = nil
- end
- local event,p1,p2,p3 = os.pullEvent()
- if event == "mouse_click" then
- if p1 == 1 then
- if (p3==8) and (p2>w/2-6) and (p2<w/2+4) then
- term.setCursorPos(20,8)
- term.setBackgroundColor(colors.white)
- term.write(" ")
- term.setCursorPos(w/2-5,h/2-1)
- term.setTextColor(colors.red)
- name = read(10,"u")
- if login == true then
- if (name ~= nil) and (password ~= nil) then
- if(name=="hts123")and(password=="power")then
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- break
- end
- loginError = checkLogin()
- end
- end
- elseif (p3==10)and(p2>w/2-6)and(p2<w/2+4) then
- term.setCursorPos(w/2-5,h/2+1)
- term.setBackgroundColor(colors.white)
- term.write(" ")
- term.setCursorPos(w/2-5,h/2+1)
- term.setTextColor(colors.red)
- password,login = read(10,"p","*")
- if login == true then
- if (name ~= nil) and (password ~= nil) then
- if(name=="hts123")and(password=="power")then
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- break
- end
- loginError = checkLogin()
- end
- end
- elseif (p3==12)and(p2>w/2-3) and (p2<w/2+2) then
- if (name ~= nil) and (password ~= nil) then
- loginError = checkLogin()
- end
- elseif (p3==18) and (p2>44) then
- current = "create"
- clearScreen()
- term.setTextColor(colors.green)
- term.setBackgroundColor(colors.yellow)
- writec("Create account",h/2+3)
- writec("Cancel",h/2+5)
- term.setTextColor(colors.red)
- while true do
- w,h = term.getSize()
- local event,t1,t2,t3 = os.pullEvent()
- if event == "mouse_click" then
- if t1 == 1 then
- if (t3==8)and(t2>w/2-6)and(t2<w/2+4) then
- term.setCursorPos(w/2-5,8)
- term.setBackgroundColor(colors.white)
- term.write(" ")
- term.setCursorPos(w/2-5,8)
- newn = read(10,"u")
- elseif (t3==10)and(t2>w/2-6)and(t2<w/2+4) then
- term.setCursorPos(w/2-5,10)
- term.setBackgroundColor(colors.white)
- term.write(" ")
- term.setCursorPos(w/2-5,10)
- newp = read(10,"p","*")
- elseif (t3==12)and(t2>w/2-8)and(t2<w/2+6) then
- fs.makeDir("Storage/Accounts/"..newn)
- h = fs.open("Storage/Accounts/"..newn.."/password","w")
- h.write(newp)
- h.close()
- fs.makeDir("Storage/Accounts/"..newn.."/Files")
- usernames = fs.list("Storage/Accounts/*")
- for i=1,table.maxn(usernames) do
- h = fs.open("Storage/Accounts/"..usernames[i].."/password","r")
- passwords[i] = h.readAll()
- h.close()
- end
- clearScreen()
- term.setBackgroundColor(colors.red)
- term.setTextColor(colors.black)
- term.setCursorPos(18,5)
- term.write("Created account")
- sleep(1)
- term.setCursorPos(18,5)
- term.setBackgroundColor(colors.lightBlue)
- term.write(" ")
- term.setCursorPos(w/2-3,12)
- term.setBackgroundColor(colors.yellow)
- term.setTextColor(colors.green)
- term.write("login")
- term.setTextColor(colors.red)
- break
- elseif(t3==14)and(t2>w/2-3)and(t2<w/2+3) then
- clearScreen()
- term.setCursorPos(w/2-3,12)
- term.setBackgroundColor(colors.yellow)
- term.setTextColor(colors.green)
- term.write("login")
- term.setCursorPos(45,18)
- term.write("create")
- break
- end
- end
- end
- end
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement