Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Made by Esbenmine
- term.clear()
- term.setCursorPos(1,1)
- Start = true
- UP = false
- PP = false
- rednet.open("top")
- Start = function()
- id, x = rednet.receive()
- if x == "@Pass" then
- id, Uname = rednet.receive()
- id, Pass = rednet.receive()
- Check = LoginCheck(Uname, Pass)
- if Check == true then
- rednet.send(id, "@CP")
- print("User: ",Uname," logged in to Goggle Cloud")
- elseif Check == false then
- print("User: ",Uname," failed logging in to Goggle Cloud")
- rednet.send(id, "@WP")
- end
- elseif x == "@Upload" then
- id, Uname = rednet.receive()
- id, Pass = rednet.receive()
- id, File = rednet.receive()
- Login = LoginCheck(Uname, Pass)
- if Login == false then
- rednet.send(id, "@WP")
- else
- if fs.exists("/"..Uname.."/"..File.."") then
- rednet.send(id, "@File Exists")
- else
- rednet.send(id, "@StartUL")
- ID, Message = rednet.receive()
- if id == ID then
- if Message == "@File Exists" then
- id, FileLines = rednet.receive()
- if id == ID then
- file = fs.open("/"..Uname.."/"..File, "w")
- file.write(FileLines)
- file.close()
- print("User: ",Uname," uploaded ",File," to his Goggle Cloud")
- else
- rednet.send(id, "Nothing here")
- end
- elseif Message == "@CancelUL" then
- end
- else
- rednet.send(id, "You send a message to an wrong idea")
- end
- end
- end
- elseif x == "@Download" then
- ID, Uname = rednet.receive()
- ID2, Pass = rednet.receive()
- ID3, FileName = rednet.receive()
- if id == ID and ID2 == id and ID3 == id then
- Login = LoginCheck(Uname, Pass)
- if Login == true then
- rednet.send(id, true)
- if fs.exists("/"..Uname.."/"..FileName.."") then
- rednet.send(id, "@File exists")
- file = fs.open("/"..Uname.."/"..FileName.." ","r")
- Lines = file.readAll()
- rednet.send(id, Lines)
- print("User: ",Uname," downloaded ",FileName," from his Goggle Cloud")
- file.close()
- else
- rednet.send(id, "@File do not exists")
- end
- elseif Login == false then
- rednet.send(id, false)
- end
- else
- rednet.send(ID, "Wrong ID")
- end
- elseif x == "@List" then
- ID, Uname = rednet.receive()
- ID2, Pass = rednet.receive()
- if id == ID and id == ID2 then
- Login = LoginCheck(Uname, Pass)
- if Login == true then
- rednet.send(id, true)
- files = fs.list("/"..Uname.."/")
- rednet.send(id, files)
- elseif Login == false then
- rednet.send(id, false)
- end
- end
- elseif x == "@Delete" then
- ID, Uname = rednet.receive()
- ID2, Pass = rednet.receive()
- if id == ID and id == ID2 then
- Login = LoginCheck(Uname,Pass)
- if Login == true then
- rednet.send(ID, true)
- ID, FileName = rednet.receive()
- if id == ID then
- if fs.exists("/"..Uname.."/"..FileName.." ") then
- rednet.send(ID, true)
- fs.delete("/"..Uname.."/"..FileName.." ")
- else
- rednet.send(ID, false)
- end
- else
- rednet.send(ID, "Wrong ID")
- end
- elseif Login == false then
- rednet.send(ID, false)
- end
- else
- rednet.send(ID, "Wrong ID")
- end
- else
- rednet.send(id, "Wrong ID")
- end
- end
- LoginCheck = function(Username, Password)
- file = fs.open("/Users/"..Username,"r")
- if file then
- if Password == file.readLine() then
- return true
- else
- return false
- end
- else
- return false
- end
- file.close()
- end
- repeat
- Start()
- until Start == false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement