----------------------------------- --Welcome to Rednet Explorer 3.1!-- ----------------------------------- --Made by ComputerCraftFan11 (IGN: xXm0dzXx) --Please don't steal this without giving credits. --To change the database of the sites you are connecting to, edit this: local WebsiteDatabase = "http://nexusindustries.x10.mx/Websites/folder/" --Folder with all the sites local ApiPath = "http://nexusindustries.x10.mx/Websites/mcmain.php" --Path API is stored --All sites will be downloaded from there. --Default: "http://nexusindustries.x10.mx/Websites/folder/" --Change to "http://" to just browse the internet --API path is used for downloading and uploading files. Change it to the path of your API local autoUpdater = true; local updaterPath = "http://pastebin.com/1EAc6tFd"; --COMING SOON --If you are making a custom version of this browser, edit this variable for browser compatibility browserAgent = "rednetexplorer3.0" local x,y = term.getSize() local language = 1 --1 = LUA local EditingValue = ""; function rednetV() return "3.1" end title = "Rednet Explorer " ..rednetV() --Add title = "name" to change the webpage's title! local website = "home"; if fs.exists(".cache") then fs.delete(".cache") end if fs.exists(".websiteedited") then fs.delete(".websiteedited") end fs.makeDir(".cache") function displayError() print("Unable to connect.") print("\n1) The requested site may be down or doesn't exist.") print("2) You mistyped the website URL.") print("3) A database admin may have deleted the requested site.") print("4) A server admin may have blocked this website (Only if you are on multiplayer)") print("5) The database might be down.") print("6) The requested site may have faked this message and secretly gave you a virus.") end local cPrint = function(text) local x2,y2 = term.getCursorPos() term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2) print(text) end function reDirect(url) website = url loadWebpage() end function createSite() term.clear() term.setCursorPos(1,1) cPrint("Rednet Explorer Online Servers") write("Domain (ex: YourDomain.com): rdnt://") domain = read() write("Path to file: ") path = read() if fs.exists(path) then file = fs.open(path, "r") if file then data = file.readAll() file.close() if not data then print("Failed to read " ..path) return end local response = http.post( ApiPath, "type=upload&".. "user=guest&".. "pass=guest&".. "name=".. textutils.urlEncode(domain) .. "&".. "data=" ..textutils.urlEncode(data) ) if response then local sResponse = response.readAll() response.close() print("Done!") print("Log: ") sleep(0.5) if string.find(sResponse, "success") then print("Uploading " ..shell.resolve(path).. " complete!") print("Errors: 0") print("\nGo to " ..domain.. " to check the site!") else print("Failed : " ..sResponse) print() if sResponse == "Write_lock" then print("The write_lock error means you have been locked out from uploading because are a hacker, a troll, or a spammer that is trying to upload a file to mess up my database and you are gonna be hunted down and killed (not IRL) by my team :)\n\nFYI, your IP has been traced.") end end else print("Failed to connect to database.") end else print("Failed to open " ..path) end else print(path.. " doesn't exist.") end end local Address = function() if WebsiteDatabase == "http://" then text = "http://" else text = "rdnt://" end term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), 2) term.clearLine() write(text) website = read() loadWebpage() end function done() term.setCursorPos(1, y) name = "F5 = Refresh" write("Press CTRL to travel the web! :D") term.setCursorPos(x - name:len(), y) write(name) while true do sleep(0) -- stop crashing e, k = os.pullEvent("key") if k == 63 then loadWebpage() break elseif k == 29 then Address() break end end end loadWebpage = function() term.clear() term.setCursorPos(1,1) cPrint(title) if WebsiteDatabase == "http://" then cPrint("http://" ..website.. "\n") else cPrint("rdnt://" ..website.. "\n") end if website == "home" then print("Welcome to RedNet explorer (3.0)! This requires you to HTTP enabled.") print("Host a website at: ") print("rdnt://newsite! ") print("Edit settings at:") print("rdnt://settings") print(" -ComputerCraftFan11 ") elseif website == "newsite" then createSite() elseif website == "settings" then --COMING SOON selection = 1 function lzy(aa, bb) term.setCursorPos(1,bb + 1) if aa == selection then cPrint("[ " ..bb.. " ]") else cPrint(bb) end end while true do term.clear() term.setCursorPos(1,1) cPrint("RedNet Explorer Settings") local event, key = os.pullEvent("key") if key == 208 then selection = selection +1 if selection == 5 then selection = 4 end elseif key == 200 then selection = selection -1 if selection == -1 then selection = 1 end elseif key == 28 then print("Coming Soon!") break end lzy(1, "Edit Homepage") lzy(2, "Edit Execution Settings") lzy(3, "Edit Database Settings") lzy(4, "Exit") --Options: --Homepage: rdnt://home --Execution Settings: -- Lua (Default) (.lua) -- Batch (BETA) (.bat) -- HTML (BETA) (.html) -- Text Document (.txt) --Database Settings: -- Edit Whitelist -- Edit Blacklist -- Edit Database folder: -- Edit Database path: end else title = "Rednet Explorer " ..rednetV() rednet.broadcast(website) print("Connecting...") website1 = "Rednet_Explorer_RequestedSite" if WebsiteDatabase == "http://" then while true do http.request(WebsiteDatabase..website) timer = os.startTimer(5) local event, body, url = os.pullEvent() if event == "http_success" then if language == 1 then if fs.exists(".cache/" ..website1) then fs.delete(".cache/" ..website1) end webpage = fs.open(".cache/" ..website1, "w") webpage.write(body.readAll()) webpage.close() term.clear() term.setCursorPos(1,1) cPrint(title) if WebsiteDatabase == "http://" then cPrint("http://" ..website.. "\n") else cPrint("rdnt://" ..website.. "\n") end shell.run(".cache/" ..website1) break end elseif event == "http_failed" then displayError() elseif event == "timer" and body == timer then print("Failed to connect:") print("* Read timed out.") end end else local response = http.post( ApiPath, "user=guest&".. "pass=guest&".. "type=download&".. "data=blank&".. "name=".. textutils.urlEncode(website) ) if response then local body = response.readAll() response.close() if body == nil or body == "" or string.find(body, "auth_error") or string.find(body, "file_not_found") then displayError() else if language == 1 then if fs.exists(".cache/" ..website1) then fs.delete(".cache/" ..website1) end webpage = fs.open(".cache/" ..website1, "w") webpage.write(body) webpage.close() term.clear() term.setCursorPos(1,1) cPrint(title) if WebsiteDatabase == "http://" then cPrint("http://" ..website.. "\n") else cPrint("rdnt://" ..website.. "\n") end if string.sub(body, 1, string.len("--%warn%")) == "--%warn%" then print("Warning, you are about to enter a malicous site.") print("Would you like to continue? (Y/N) ") while true do input = read() if input == "Y" then shell.run(".cache/" ..website1) elseif input == "N" then print("Aborted.") break else print("Unknown input... exiting.") break end end else shell.run(".cache/" ..website1) end end end else displayError() end end end done() end loadWebpage()