serverBroadcastIDs = {}
function getNumTable(tbl)
sReturn = 0
for i = 1,math.huge do
if tbl[i] == nil then
return sReturn
else
sReturn = sReturn+1
end
end
end
PAGE1 = {}
rednet.open("back")
rednet.open("front")
rednet.open("left")
rednet.open("right")
rednet.open("top")
rednet.open("bottom")
function Start()
while true do
print("+-----------------------------------------------+")
print("| |")
print("+-----------------------------------------------+")
print("| |")
print("| |")
print("| |")
print("| |")
print("| |")
print("| |")
print("| |")
print("| |")
print("| |")
print("| |")
print("| |")
print("| |")
print("| |")
print("+-----------------------------------------------+")
term.setCursorPos(3,2)
websiteInput = read()
if string.sub(websiteInput,1,9) ~= "download:" then
if string.sub(websiteInput,1,7) ~= "upload:" then
for i = 1, numberOfServerBroadcastIDs do
sentCheck = rednet.send(serverBroadcastIDs[i], "getHTTP"..websiteInput)
inputStuff()
break
end
else
if fs.exists(string.sub(websiteInput,8)) == true then
for i = 1, numberOfServerBroadcastIDs do
local sFile = fs.open(string.sub(websiteInput,8), "r")
rednet.send(serverBroadcastIDs[i], "UPL"..checkLines(string.sub(websiteInput,8)))
rednet.send(serverBroadcastIDs[i], string.sub(websiteInput,8))
broadcastID = serverBroadcastIDs[i]
for i = 1, checkLines(string.sub(websiteInput,8)) do
rednet.send(broadcastID, tostring(sFile:readLine()))
end
end
sFile:close()
else
term.clear()
term.setCursorPos(1,1)
error("File does not exist.")
end
end
else
for i = 1, numberOfServerBroadcastIDs do
rednet.send(serverBroadcastIDs[i], "DWN"..string.sub(websiteInput,10))
id, numOfLines = rednet.receive()
numOfLines = tonumber(numOfLines)
local sFilez = fs.open(string.sub(websiteInput,10), "w")
for i = 1,numOfLines do
id, received = rednet.receive()
lol = sFilez.write(received.."n")
end
sFilez:close()
end
end
end
end
function inputStuff()
for i = 1, 15 do
if i == 1 then
CODE = io.open("WEBSITECODE","w")
id, msg = rednet.receive()
CODE:write(msg)
CODE:close()
else
id, PAGE1[i] = rednet.receive()
end
end
for i = 1, 14 do
if PAGE1[i] ~= nil then
term.setCursorPos(2, 2+i)
io.write(PAGE1[i])
end
end
while true do
shell.run("WEBSITECODE")
event, key = os.pullEvent()
if event == "key" then
if key ~= 1 then
term.clear()
term.setCursorPos(1,1)
Start()
end
end
end
end
function checkLines(file)
if fs.exists(file) == true then
sFile = fs.open(file, "r")
sCount = 0
for i = 1, math.huge do
line = sFile:readLine()
if line ~= nil then
sCount = sCount+1
else
return sCount
end
end
else
return false
end
end
if fs.exists("clientConnect") == true then
local filez = fs.open("clientConnect","r")
for i = 1,checkLines("clientConnect") do
table.insert(serverBroadcastIDs, tonumber(filez.readLine()))
end
filez.close()
else
error("Make clientConnect file!")
end
numberOfServerBroadcastIDs = getNumTable(serverBroadcastIDs)
Start()