xXm0dzXx

Untitled

May 22nd, 2012
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. shell.run("clear")
  2.  
  3. function backup1()
  4.  
  5. backup = fs.open(".backupsaving123", "w")
  6.  
  7. files = fs.list("disk/")
  8. for i = 1,#files do
  9. if not fs.isReadOnly(files[i]) then
  10. if fs.isDir(files[i]) then
  11. backup.writeLine('fs.makeDir("' ..files[i].. '")')
  12. else
  13. -- Read in the file
  14. local sName = fs.getName( files[i] )
  15. if sName == ".backupsaving123" then else
  16. local file = fs.open( files[i], "r" )
  17. local sText = file.readAll()
  18. file.close()
  19.  
  20. -- POST the contents to pastebin
  21. write( "Backing up disk/" ..sName.. "..." )
  22. local key = "0ec2eb25b6166c0c27a394ae118ad829"
  23. local response = http.post(
  24. "http://pastebin.com/api/api_post.php",
  25. "api_option=paste&"..
  26. "api_dev_key="..key.."&"..
  27. "api_paste_format=lua&"..
  28. "api_paste_name="..textutils.urlEncode(sName).."&"..
  29. "api_paste_code="..textutils.urlEncode(sText)
  30. )
  31.  
  32. if response then
  33. local sResponse = response.readAll()
  34. response.close()
  35.  
  36. local sCode = string.match( sResponse, "[^/]+$" )
  37. backup.writeLine( 'shell.run("pastebin", "get", "'..sCode..'", "disk/'..files[i]..'")')
  38. end
  39. end
  40. end
  41. end
  42. end
  43.  
  44. backup.close()
  45.  
  46.  
  47. -- Read in the file
  48. local sName = fs.getName( ".backupsaving123" )
  49. local file = fs.open( ".backupsaving123" , "r" )
  50. local sText = file.readAll()
  51. file.close()
  52.  
  53. -- POST the contents to pastebin
  54. write( "Connecting to pastebin.com... " )
  55. local key = "0ec2eb25b6166c0c27a394ae118ad829"
  56. local response = http.post(
  57. "http://pastebin.com/api/api_post.php",
  58. "api_option=paste&"..
  59. "api_dev_key="..key.."&"..
  60. "api_paste_format=lua&"..
  61. "api_paste_name="..textutils.urlEncode(sName).."&"..
  62. "api_paste_code="..textutils.urlEncode(sText)
  63. )
  64.  
  65. if response then
  66. local sResponse = response.readAll()
  67. response.close()
  68.  
  69. local sCode = string.match( sResponse, "[^/]+$" )
  70.  
  71. shell.run("label","set","bottom", sCode)
  72. else
  73. print("Failed.")
  74. end
  75.  
  76. fs.delete(".backupsaving123")
  77. end
  78.  
  79. function backup2(id)
  80. shell.run("pastebin", "get", id, "backupretreiver")
  81. shell.run("backupretreiver")
  82. fs.delete("backupretreiver")
  83. shell.run("clear")
  84. os.reboot()
  85. end
  86.  
  87. os.pullEvent = os.pullEventRaw
  88. if fs.exists("disk") then
  89. print("NeXuS Vault v1 Booted.")
  90. print("1; Register")
  91. print("2; Send files")
  92. print("3; Download files")
  93. write("\n\nSelection: ")
  94.  
  95. repeat
  96. input = read()
  97. until tonumber(input) < 4
  98.  
  99. if input == "3" then
  100. backup1()
  101. shell.run("clear")
  102. os.reboot()
  103. elseif input == "2" then
  104. backup2(disk.getLabel("bottom"))
  105. end
  106. else
  107. print("Please insert a disk.")
  108. sleep(1)
  109. os.reboot()
  110. end
Advertisement
Add Comment
Please, Sign In to add comment