Guest User

Untitled

a guest
Apr 9th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. pc33c1_26126_08_hd.jpg /photos/pvo/transfertvo/photos/pc33c1/pc33c1_x48_08_hd.jpg 1a71ffb90de7628b8b1585b7e85c68e7
  2.  
  3. get /photos/pvo/transfertvo/photos/pc33c1/pc33c1_x48_08_hd.jpg pc33c1_26126_08_hd.jpg
  4.  
  5. $f = Get-Content "photos.txt"
  6. $i = 0
  7.  
  8. foreach ($line in $f) {
  9.  
  10.  
  11.  
  12. $fields = $line.Split("`t")
  13.  
  14.  
  15. $First = $fields[0]
  16. $Second = $fields[1]
  17. $Third = $fields[2]
  18. $number = $i++
  19.  
  20. $url = $Second +" "+ $First
  21.  
  22.  
  23. write-host "Title is: "$First
  24. write-host "Path is: "$Second
  25. write-host "Hash is: "$Third
  26. write-host "Number is: " $number
  27. Write-Host "This is the url: " $url
  28. get $url
  29. Write-Host ""
  30. }
  31.  
  32. $FTPServer = "ftp.example.com"
  33. $FTPUsername = "user"
  34. $FTPPassword = "pass"
  35. $credential = New-Object System.Net.NetworkCredential($FTPUsername, $FTPPassword)
  36.  
  37. $FTP = [System.Net.FtpWebRequest]::Create($FTPServer)
  38.  
  39. $FTP.Credentials=$credential
  40. $FTP.UseBinary = 1
  41. $FTP.KeepAlive = 0
  42.  
  43. <?php
  44.  
  45. $ftp_server = 'ftp.example.com';
  46. $ftp_user_name = 'user';
  47. $ftp_user_pass = 'pass';
  48. $remoteFilePath = '/data/photos.txt.zip';
  49. $localFilePath = $_SERVER['DOCUMENT_ROOT']."/path/";
  50.  
  51.  
  52. // set up basic connection
  53. $conn_id = ftp_connect($ftp_server);
  54.  
  55. // login with username and password
  56. $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
  57.  
  58. if ((!$conn_id) || (!$login_result)) {
  59. echo 'FTP connection has failed! Attempted to connect to '. $ftp_server. ' for user '.$ftp_user_name.'.';
  60. }else{
  61. echo 'FTP connection was a success.<br>';
  62. $directory = ftp_nlist($conn_id,'');
  63. echo '<pre>'.print_r($directory,true).'</pre>';
  64.  
  65. $contents = ftp_nlist($conn_id, "/data/");
  66. var_dump($contents);
  67.  
  68. $bla = ftp_nlist($conn_id, "/photos/");
  69. var_dump($bla);
  70.  
  71. ftp_pasv($conn_id, true);
  72.  
  73. if (ftp_get($conn_id, $localFilePath.'/photos.txt.zip', $remoteFilePath, FTP_BINARY)) {
  74.  
  75. echo "File has been downloaded!!";
  76. return true;
  77.  
  78. } else {
  79. echo "fail ... ";
  80. echo "Connected has be stopped!!";
  81. return false;
  82.  
  83. }
  84.  
  85. }
  86. ftp_close($conn_id);
  87.  
  88. ?>
  89.  
  90. <?php
  91.  
  92. // assuming file.zip is in the same directory as the executing script.
  93. $file = 'photos.txt.zip';
  94.  
  95. // get the absolute path to $file
  96. $path = pathinfo(realpath($file), PATHINFO_DIRNAME);
  97.  
  98. $zip = new ZipArchive;
  99. $res = $zip->open($file);
  100. if ($res === TRUE) {
  101. // extract it to the path we determined above
  102. $zip->extractTo($path);
  103. $zip->close();
  104. echo " $file extracted to $path";
  105. } else {
  106. echo "Couldn't open $file";
  107. }
  108.  
  109. ?>
  110.  
  111. header("Content-Type: text/html; charset=UTF-8");
  112. $lines = file("photos.txt");
  113. $dir = "localpathtofile";
  114.  
  115.  
  116.  
  117.  
  118. foreach ($lines as $line) {
  119. $parts = explode("t", $line);
  120. $something = $parts[1];
  121. $somethingelse = $parts[0];
  122. $var1 = $ftp_server.$something;
  123.  
  124. file_put_contents($dir, file_get_contents($var1));
  125. }
Add Comment
Please, Sign In to add comment