swte

Bypass Amazon Images

Mar 26th, 2021
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * Plugin Name: Bypass Amazon Images
  5.  */
  6.  
  7. add_action('init', function(){
  8.     ob_start(function($buffer){
  9.         preg_replace_callback('~url\('([^']*)url=(.*)'\)~', function($matches){
  10.             $url = base64_decode($matches[2]);
  11.             $image = wp_remote_get($url);
  12.             if (!is_wp_error($image)){
  13.                 $upload = wp_upload_dir();
  14.                 $filename = 'aws-' . $matches[2].jpg, $image['response']['body'];
  15.                 file_put_contents(trailingslashit($upload['path']) . $filename);
  16.                 return "url('" . trailingslashit($upload['url']) . $filename .  "')";
  17.             }
  18.             return $matches[0];
  19.         }, $buffer);
  20.     });
  21. });
Add Comment
Please, Sign In to add comment