kwasinski

WP_inuse_uploads_files_download

Sep 13th, 2018
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.99 KB | None | 0 0
  1. #!perl -w
  2.  
  3. use utf8;
  4. use File::Slurp qw/read_file/;
  5. use File::Basename;
  6.  
  7. my @links = read_file('requested_url_filelist');
  8.  
  9. `mkdir uploads && chmod 777 uploads`;
  10.  
  11. ##
  12. ##
  13. fileparse_set_fstype('MSWin32');
  14. foreach (@links)
  15. {
  16.         m/uploads\/(.*)\/([a-z0-9\-\_\.\w\%]*)$/igm;
  17.         my $url = 'https://xxxxxx.xxx.xx/wp-content/uploads/';
  18.         my ($filePath, $filename) = ($1, basename($2));
  19.         `mkdir -p uploads/$filePath && chmod 777 uploads/$filePath`;
  20.         $fullFilename = $filePath.'/'.$filename;
  21.  
  22.         next  if -e 'uploads/'.$fullFilename;
  23.         $url .= $filePath.'/'.$filename;
  24.         `wget -O $filename $url && chmod 777 $filename`;
  25.  
  26.         `cp $filename uploads/$fullFilename`;
  27.         unlink($filename);
  28. }
  29.  
  30. __END__
  31.  
  32. I have written this script to download a list of WordPress uploaded files that are actually in use,
  33. I have retrieved this files grepping Apache access log file and extracting just the url to theses files and used as an input to this program.
Add Comment
Please, Sign In to add comment