Server:
rednet.open("top")
while true do
id, msg = rednet.receive()
if msg == "login" then
id, user = rednet.receive()
id, pass = rednet.receive()
if fs.isDir(user) then
h = fs.open(user.."/pass", "r")
rpass = h.readAll()
if pass == rpass then
rednet.send(id, "true")
else
rednet.send(id, "false")
end
else
rednet.send(id, "falseuser")
end
elseif msg == "newuser" then
id, newuser = rednet.receive()
id, newpass = rednet.receive()
if fs.isDir(newuser) then
rednet.send(id, "already")
else
fs.makeDir(newuser)
fs.copy("pass", newuser.."/pass")
h = fs.open(newuser.."/pass", "w")
h.write(newpass)
h.close()
fs.copy("programs", newuser.."/programs")
rednet.send(id, "other")
end
elseif msg == "needdata" then
id, user = rednet.receive()
h = fs.open(user.."/programs", "r")
one = h.readLine()
two = h.readLine()
tree = h.readLine()
four = h.readLine()
fve = h.readLine()
six = h.readLine()
even = h.readLine()
ate = h.readLine()
nine = h.readLine()
ten = h.readLine()
n = h.readLine()
rednet.send(id, one)
rednet.send(id, two)
rednet.send(id, tree)
rednet.send(id, four)
rednet.send(id, fve)
rednet.send(id, six)
rednet.send(id, even)
rednet.send(id, ate)
rednet.send(id, nine)
rednet.send(id, ten)
rednet.send(id, n)
end
end
Client:rednet.open("top")
-- Login function
function login()
term.setCursorPos(27, 9)
local pass = read("*")
rednet.send(4, "login")
sleep(1)
rednet.send(4, user)
sleep(1)
rednet.send(4, pass)
id,msg = rednet.receive()
if msg == "true" then
cloud()
elseif msg == "falseuser" then
term.setBackgroundColor(colors.white)
term.clear()
term.setTextColor(colors.red)
term.setCursorPos(1, 2)
print("Unknown account. Would you like to create an account?")
term.setCursorPos(1, 4)
print("Type y or n")
term.setCursorPos(10, 5)
local y = read()
if y == "n" then
os.reboot()
elseif y == "y" then
makeuser()
end
elseif msg == "false" then
term.setBackgroundColor(colors.white)
term.setCursorPos(10, 2)
term.setTextColor(colors.red)
print("Unknown username or password.")
sleep(3)
os.reboot()
end
end
-- Startup screen function
function graphics()
term.setBackgroundColor(colors.white)
term.clear()
term.setTextColor(colors.lightBlue)
term.setCursorPos(20, 1)
print("iCloud")
term.setTextColor(colors.red)
term.setCursorPos(1,17)
print("Copyright iCloud Systems 2013")
print("Do not distribute")
term.setCursorPos(17, 7)
term.setTextColor(colors.yellow)
print("Username:")
term.setCursorPos(17, 9)
print("Password:")
term.setCursorPos(27, 7)
term.setBackgroundColor(colors.blue)
term.write(" ")
term.setCursorPos(27, 9)
term.write(" ")
term.setCursorPos(27, 7)
term.setTextColor(colors.orange)
end
--Make new user funtion
function makeuser()
term.setBackgroundColor(colors.white)
term.clear()
term.setTextColor(colors.lightBlue)
term.setCursorPos(20, 1)
print("iCloud")
term.setTextColor(colors.red)
term.setCursorPos(1,17)
print("Copyright iCloud Systems 2013")
print("Do not distribute")
term.setCursorPos(17, 7)
term.setTextColor(colors.yellow)
print("New Username:")
term.setCursorPos(17, 9)
print("New Password:")
term.setCursorPos(31, 7)
term.setBackgroundColor(colors.blue)
term.write(" ")
term.setCursorPos(31, 9)
term.write(" ")
term.setCursorPos(31, 7)
term.setTextColor(colors.orange)
local newuser = read()
term.setCursorPos(31,9)
local newpass = read("*")
rednet.send(4, "newuser")
rednet.send(4, newuser)
rednet.send(4, newpass)
id,msg = rednet.receive()
if msg == "already" then
term.setTextColor(colors.red)
term.setCursorPos(17, 2)
print("Account already made.")
sleep(2)
makeuser()
else
term.setTextColor(colors.red)
term.setCursorPos(17, 2)
print("User "..newuser.."Created Sucessfully!")
sleep(3)
graphics()
local user = read()
login()
end
end
--Startup screen
graphics()
--Login system
local user = read()
-- Cloud main screen
function cloud()
rednet.send(4, "needdata")
rednet.send(4, user)
id,programs = rednet.receive()
h = fs.open("list", "w")
h.write(programs)
h.close()
term.setBackgroundColor(colors.white)
term.setTextColor(colors.lightBlue)
term.clear()
term.setCursorPos(20,1)
print("iCloud")
term.setTextColor(colors.black)
term.setCursorPos(2, 3)
print("Press the plus button to add a program to your cloud.")
term.setCursorPos(2, 5)
print("Press the arrow to find and download your programs.")
term.setCursorPos(2, 7)
print("Press the C to share your programs and see community programs.")
term.setBackgroundColor(colors.green)
term.setCursorPos(10, 15)
term.write(" ")
term.setCursorPos(10, 14)
term.write(" ")
term.setCursorPos(10, 13)
term.write(" ")
term.setCursorPos(8, 14)
term.write(" ")
term.setCursorPos(12, 14)
term.write(" ")
term.setBackgroundColor(colors.blue)
term.setCursorPos(20, 14)
term.write(" ")
term.setCursorPos(29, 14)
term.write(" ")
term.setCursorPos(28, 15)
term.write(" ")
term.setCursorPos(27, 16)
term.write(" ")
term.setCursorPos(28, 13)
term.write(" ")
term.setCursorPos(27, 12)
term.write(" ")
term.setBackgroundColor(colors.yellow)
term.setCursorPos(40, 11)
term.write(" ")
term.setCursorPos(40, 12)
term.write(" ")
term.setCursorPos(40, 13)
term.write(" ")
term.setCursorPos(40, 14)
term.write(" ")
term.setCursorPos(40, 15)
term.write(" ")
term.setCursorPos(40, 16)
term.write(" ")
term.setCursorPos(40, 17)
term.write(" ")
end
login()











