Git Product home page Git Product logo

uploads-by-proxy's Issues

Multisite support

Multisite support basically comes down to three things:

The allowed path filter

class-404-template.php#L92
UBP checks to see if the requested $path from $_SERVER['REQUEST_URI'] contains $uploads['basedir'] with ABSPATH stripped out. So, for example, when requesting an image:

/wp-content/uploads/2012/10/image.jpg

$uploads['basedir'] without ABSPATH on a single site is:
wp-content/uploads
which exists in the requested path, so it passes.

On multisite, the requested $path would be:
/files/2012/10/image.jpg

But $uploads['basedir'] would be something like:
/wp-content/blogs.dir/3/files/ (where "3" is a blog ID)

So they don't match up. The check needs to be revised to accomidate multisite uploads directory path rewrites.

Download Path

class-404-template.php#L41
When an image is found, it's downloaded and saved to the local uploads directory. The download method, like allow_path, makes the assumption that the path to save the image to matches the path the image was requested from. In multisite, this isn't the case.

For example, single site:
image requested from: http://site.com/wp-content/uploads/2012/10/image.jpg
image saved to: ABSPATH.'/wp-content/uploads/2012/10/image.jpg'

But multisite:
image requested from: http://site.com/subsite/wp-content/uploads/2012/10/image.jpg
image saved to: ABSPATH.'/wp-content/blogs.dir/3/files/2012/10/image.jpg'

And "subsite" could also be a subdomain (subsite.site.com), or a mapped domain name. (subsite.com)

*Changes in 3.5 *

Trac ticket #19235

I haven't tested Nacin's final version of this in the 3.5 betas, but I'm pretty sure it's slated for release. Basically, in 3.5, there they'll be using wp-content/uploads/sites instead of wp-content/blogs.dir. wp_upload_dir() should account for this, but it of course needs to be tested, and the solutions for #1 and #2 need to be agnostic to whether they're running on 3.4- or 3.5+

To test any of these, you'd need to comment out the hook for requiring multisite to activate. But maybe you already did that? I was surprised to hear you activated the plugin on a multisite at all. Did it let you do it on the master site?

Infinit redirect loop if filename contains Unicode characters

If filename from uploads directory contains Unicode characters, infinite loop will occur.
This happens on Windows, not sure for Linux.

To fix this, two things needs to be changed in class-404-template.php file.

In function get_local_path() replace line
$this->local_path = $requested_path;
with
$this->local_path = urldecode($requested_path);

Then, in function download() add snippet

if(strcasecmp(substr(PHP_OS, 0, 3), 'WIN') == 0){
    $abspath = iconv('UTF-8', 'WINDOWS-1252', $abspath);
}

before line
$saved_image = $wp_filesystem->put_contents.....

Not working

The extension doesn't seem to be working. Is it still compatible with the current release of WordPress?

I've defined 'UBP_SITEURL', 'UBP_LIVE_DOMAIN' and 'UBP_IS_LOCAL', but not getting anything to work.

Doesn't work if the production/staging site is password protected

Hello,

I have added this to my local on different projects before it works fine if I am grabbing images from live sites, but if I am trying to get images from a production/staging server from my local computer, it doesn't work.

I believe this is because the production/staging server is username and password protected.

Is there a way to overcome these credentials (I have the logins) so I can call those images?

Kind regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.