Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.pullEvent = os.pullEventRaw
- local w,h = term.getSize()
- local password_server = 19
- local username = ""
- local password = ""
- rednet.open("left")
- local function printCentered(str,ypos)
- term.setCursorPos(w/2 - #str/2,ypos)
- term.write(str)
- end
- local function printLocation(str,xpos,ypos)
- term.setCursorPos(xpos,ypos)
- term.write(str)
- end
- function Login()
- rednet.send(password_server,"1")
- write("Username:")
- username = read()
- write("Password:")
- password = read()
- rednet.send(password_server,username);
- senderId,message,distance = rednet.receive(5)
- if message == password then
- runTekos()
- end
- end
- function SendFile()
- rednet.send(password_sever,"5")
- print("Filename:")
- local filename = read()
- if not fs.isDir("files") then
- fs.makeDir("files")
- end
- local FD = fs.combine("files",filename)
- rednet.send(password_server,filename)
- f = fs.open(FD,"r")
- local code = f.readAll()
- f.close()
- rednet.send(password_server,code)
- end
- function DownloadFile()
- rednet.send(password_server,"6")
- print("Filename:")
- local filename = read()
- if not fs.isDir("files") then
- fs.makeDir("files")
- end
- rednet.send(password_server,filename)
- FD = fs.combine("files", filename)
- f = fs.open(FD, "w")
- senderId, message, distance = rednet.receive(5)
- f.write(message)
- f.close()
- end
- function FileList()
- rednet.send(password_server,"7")
- rednet.send(password_server,"Hello")
- senderId,message,distance = rednet.receive(5)
- print(message)
- end
- function PrivateSend()
- rednet.send(password_server,"8")
- print("Filename:")
- local filename = read()
- local FD = fs.combine("files", filename)
- rednet.send(password_server,username)
- rednet.send(password_server,filename)
- f = fs.open(FD,"r")
- local code = f.readAll()
- f.close()
- rednet.send(password_server,code)
- end
- function PrivateDownload()
- rednet.send(password_server,"9")
- print("Filename:")
- local filename = read()
- if not fs.isDir("files") then
- fs.makeDir("files")
- end
- rednet.send(password_server,username)
- rednet.send(password_server,filename)
- FD = fs.combine("files", filename)
- f = fs.open(FD, "w")
- senderId, message, distance = rednet.receive(5)
- f.write(message)
- f.close()
- end
- function PrivateList()
- rednet.send(password_server,"10")
- rednet.send(password_server,username)
- senderId,message,distance = rednet.receive(5)
- print(message)
- end
- function runFTP()
- term.clear()
- term.setCursorPos(1,1)
- print("Welcome")
- print("What would you like to do")
- print("[1] SendFile")
- print("[2] DownloadFile")
- print("[3] fileList")
- print("[4] Send Private File")
- print("[5] Download Private File")
- print("[6] Private FileList")
- print("[7] Back")
- local input = read()
- if input == "1" then
- SendFile()
- elseif input == "2" then
- DownloadFile()
- elseif input == "3" then
- FileList()
- elseif input == "4" then
- PrivateSend()
- elseif input == "5" then
- PrivateDownload()
- elseif input == "6" then
- PrivateList()
- elseif input == "7" then
- runTekos()
- end
- end
- function getFileList()
- if not fs.isDir("files") then
- fs.makeDir("files")
- end
- list = fs.list("files")
- local str = textutils.serialize(list)
- print(str)
- end
- function copyFileFromDisk()
- print("Filename:")
- local filename = read()
- local FD = fs.combine("files",filename)
- local DD = fs.combine("disk",filename)
- fs.copy(DD,FD)
- end
- function copyFileToDisk()
- print("Filename:")
- local filename = read()
- local FD = fs.combine("files",filename)
- local DD = fs.combine("disk",filename)
- fs.copy(FD,DD)
- end
- function runFileSystem()
- term.clear()
- term.setCursorPos(1,1)
- print("Welcome")
- print("What would you like to do")
- print("[1] run file")
- print("[2] get FileList")
- print("[3] copy file from disk")
- print("[4] copy file to disk")
- print("[5] Back")
- local input = read()
- end
- function runTekos()
- while true do
- term.clear()
- term.setCursorPos(1,1)
- print("Welcome", username)
- print("What would you like to do?")
- print("[1] FileSystem")
- print("[2] FTP")
- print("[3] Quit")
- local input = read()
- if input == "1" then
- runFileSystem()
- elseif input == "2" then
- runFTP()
- elseif input =="3" then
- os.shutdown()
- end
- end
- end
- function runClient()
- while true do
- term.clear()
- term.setCursorPos(1,1)
- print("Welcome!")
- print("What would you like to do")
- print("[1] Login")
- print("[2] Exit")
- local input = read()
- if input == "1" then
- Login()
- elseif input == "2" then
- os.shutdown()
- end
- end
- end
- runClient()
Add Comment
Please, Sign In to add comment