Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Made by Sapphire Tech
- --PLEASE DO NOT EDIT!
- local version = "9.1"
- local not_found = "term.setBackgroundColor(colors.white) term.setTextColor(colors.lightGray) term.clear() term.setCursorPos(1,1) print('Uh oh, captin, were lost!') print('The file was not found on the server!')"
- local sides = {
- "top",
- "bottom",
- "back",
- "left",
- "right"
- }
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.lightGray)
- if not fs.exists("settings") then
- write("WARN: Enter domain name: ")
- local newd = read()
- local dmn = fs.open("settings","w")
- dmn.write(newd)
- term.clear()
- term.setCursorPos(1,1)
- end
- if not fs.exists("index") then
- print("WARN: Missing file index!")
- term.clear()
- term.setCursorPos(1,1)
- print("INFO: Server version: "..version)
- for i = 1, #sides do
- if peripheral.isPresent(sides[i]) then
- if peripheral.getType(sides[i]) == "modem" then
- local modem = peripheral.find("modem")
- if modem.isWireless() then
- rednet.open(sides[i])
- print("INFO: Modem found on "..sides[i])
- else
- print("WARN: Modem not found!")
- end
- end
- end
- end
- local domainf = fs.open("settings")
- local domain = doaminf.readAll()
- domainf.close()
- print("INFO: Server hosted on "..domain)
- while true do
- fm2 = tostring(evnt[2])
- fm3 = tostring(evnt[3])
- if fm2 ~= nil and fm3 ~= nil then
- local evnt = { rednet.receive() }
- if evnt[3] == domain then
- if fs.exists(evnt[2]) then
- local codef = fs.open(evnt[2])
- local code = codef.readAll()
- codef.close()
- rednet.send(evnt[1],code)
- print("INFO: The computer at "..evnt[1].." has requested the page "..evnt[2].." the page has been sent!")
- else
- rednet.send(evnt[1],not_found)
- print("INFO: The computer at "..evnt[1].." has requested the page "..evnt[2].." the page has not been sent!")
- end
- end
- sleep(0)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement