Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- IPS - Improved Pastebin System --
- -- Created by XLzanfran. -----------
- -- Usage: Just follow with what it says!
- devKey = "814649b34fbb21e6452764a1cbfa9ace"
- userKey = ""
- if not http then
- print("You need HTTP to use IPS!")
- return
- end
- function post(uk, c, n)
- if uk == "" then
- resp = http.post("http://pastebin.com/api/api_post.php",
- "api_dev_key=" .. devKey .. "&" ..
- "api_option=paste&" ..
- "api_paste_code=" .. c .. "&" ..
- --"api_user_key=" .. uk .. "&" ..
- "api_paste_name=" .. n .. "&" ..
- "api_paste_format=lua"
- --"api_paste_private=0"
- )
- if resp then
- return resp.readAll()
- else
- return false
- end
- else
- resp = http.post("http://pastebin.com/api/api_post.php",
- "api_dev_key=" .. devKey .. "&" ..
- "api_option=paste&" ..
- "api_paste_code=" .. c .. "&" ..
- "api_paste_name=" .. n .. "&" ..
- "api_paste_format=lua&" ..
- "api_user_key=" .. uk .. "&" ..
- "api_paste_private=0"
- )
- if resp then
- web = resp.readAll()
- return web
- else
- return false
- end
- end
- end
- function loginProcess()
- print("")
- write("Enter your username: ")
- local user = read()
- print("")
- print("")
- write("Enter your password: ")
- local pass = read("*")
- print("Signing into Pastebin . . .")
- local resp = http.post("http://pastebin.com/api/api_login.php",
- "api_dev_key=" .. devKey .. "&" ..
- "api_user_name=" .. user .. "&" ..
- "api_user_password=" .. pass
- )
- if resp then
- webr = resp.readAll()
- if string.sub(webr, 1, 3) == "Bad" then
- print("An error has occured. (" .. webr .. ")")
- read()
- else
- print("Successfully logged in as " .. user)
- userKey = webr
- read()
- end
- end
- end
- function cmdSys()
- term.clear()
- term.setCursorPos(1, 1)
- print("What would you like to do? (login/post/download/exit)")
- term.write("> ")
- local response = read()
- if response == "login" then
- loginProcess()
- return cmdSys()
- elseif response == "post" then
- print("What program would you like to post?")
- term.write("> ")
- local f = read()
- local file = fs.open(f, "r")
- local data = file.readAll()
- print("What would you like to name this as on Pastebin?")
- term.write("> ")
- local nameitas = read()
- print("Posting " .. f .. " . . .")
- local posting = post(userKey, data, nameitas)
- if posting == false then
- print("An error has occured.")
- read()
- cmdSys()
- else
- print("Uploaded. Go to " .. posting .. " to see your upload.")
- read()
- cmdSys()
- end
- elseif response == "download" then
- print("Please enter the Pastebin ID:")
- local id = read()
- print("Please enter a filename to save it as:")
- local f = read()
- local fi = fs.open(f, "w")
- print("Connecting to pastebin . . .")
- local website = http.get("http://pastebin.com/raw.php?i=" .. textutils.urlEncode(id))
- if website then
- data = website.readAll()
- fi.write(data)
- fi.close()
- print("Saved " .. id .. " as " .. f .. " successfully.")
- read()
- cmdSys()
- else
- print("An error has occured.")
- read()
- cmdSys()
- end
- elseif response == "exit" then
- else
- print("Unknown command.")
- read()
- cmdSys()
- end
- end
- cmdSys()
Add Comment
Please, Sign In to add comment