Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Address
- local Lines = {}
- local CatchWords = {"pastebin","fs.delete","settings.set","settings.define","while true do","for i = 1","os.reboot","os.shutdown","exit","break","shell.run"}
- local function Clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- local function Textbar(y)
- term.setCursorPos(1,y)
- local input
- while true do
- local event = {os.pullEvent("key")}
- if event[2] == keys.enter then break end
- input = read()
- end
- return(input)
- end
- local function Scan(Fi)
- local file = fs.open(fs.combine("os/System/TempFiles",Fi),"r")
- local Pass = true
- for i = 1, #CatchWords do
- if string.find(file.readAll(),CatchWords[i]) then
- Pass = false
- end
- end
- return(Pass)
- end
- local function DrawPage(file)
- Lines = {}
- local page = fs.open(file,"r")
- while true do
- local Content = page.readLine()
- if Content ~= nil then
- Lines[#Lines + 1] = Content
- else
- break
- end
- end
- page.close()
- local options = {}
- local Actions = {}
- for i = 1, #Lines do
- loadstring(Lines[i])
- end
- if #options > 0 then
- local n = CUI(options)
- loadstring(Actions[n])
- end
- Menu()
- end
- function CUI(m) --declare function
- n=1
- local l = #m
- while true do
- term.setCursorPos(1,5)
- for i=1, #m, 1 do --traverse the table of options
- if i==n then term.clearLine() print(i, ">",m[i]) else term.clearLine() print(i, "-", m[i]) end --print them
- end
- a, b= os.pullEvent("key") --wait for keypress
- if b==keys.w and n>1 then n=n-1 end
- if b==keys.s and n<l then n=n+1 end
- if b==keys.enter then break end
- end
- return n --return the value
- end
- function Menu()
- Clear()
- print("web browser")
- local Search = TextBar(3)
- local id = rednet.lookup("1000",Search)
- if Search == "exit" then
- elseif id == nil then
- print("failed to find site")
- os.sleep(3)
- Menu()
- else
- rednet.send(id,"web_request")
- local a, b, c = rednet.receive()
- Address = Search
- local file = fs.open(fs.combine("os/System/TempFiles",Address),"w")
- file.write(b)
- file.close()
- if Scan(Fi) == true then
- DrawPage(fs.combine("os/System/TempFiles",Address))
- else
- Address = nil
- Menu()
- end
- end
- end
- print("sorry but the Web service is not available atm, you can tell when it’s ready by checking the App Store page once in a while")
- os.sleep(5)
Add Comment
Please, Sign In to add comment