diff --git a/class-404-template.php b/class-404-template.php index add91ef..ddfff55 100644 --- a/class-404-template.php +++ b/class-404-template.php @@ -44,8 +44,9 @@ public function download() { $u = wp_upload_dir(); - $basedir = str_replace( $this->uploads_basedir(), '', $u['basedir'] ); - $abspath = $basedir . $this->get_local_path(); + $remove = str_replace( get_option( 'siteurl' ), '', $u['baseurl'] ); + $basedir = str_replace( $remove, '', $u['basedir'] ); + $abspath = $basedir . $this->get_dated_path(); $dir = dirname( $abspath ); if ( !is_dir( $dir ) && !wp_mkdir_p( $dir ) ) { @@ -55,7 +56,9 @@ public function download() { $saved_image = $wp_filesystem->put_contents( $abspath, $this->response['body'], FS_CHMOD_FILE ); // predefined mode settings for WP files if ( $saved_image ) { - wp_redirect( get_site_url( get_current_blog_id(), $this->get_local_path() ) ); + $path = $this->get_ms_adjusted_path(); + $redirect = get_site_url( get_current_blog_id(), $path ); + wp_redirect( $redirect ); exit; }else { $this->display_and_exit( "Please check permissions. Could not write image $dir" ); @@ -84,6 +87,7 @@ public function display_and_exit( $message=false ) { */ public function allow_path() { $path = $this->get_remote_path(); + if ( empty( $path ) ) { return false; } $allowed_paths = array( @@ -120,12 +124,31 @@ public function get_siteurl() { $url = str_replace( array( 'http://', 'https://' ), '', UBP_LIVE_DOMAIN ); $url = 'http://' . $url; - }else if ( defined( 'UBP_SITEURL' ) && false !== UBP_SITEURL ) { - + }else if ( is_multisite() && ( $siteurl = get_option( '_ubp_site_url' ) ) ) { + + $url = parse_url( $siteurl ); + $url = 'http://' . $url['host'] . @$url['path']; + + }else if ( is_multisite() && defined( 'UBP_SITEURL' ) && false !== UBP_SITEURL ) { + + + $details = get_blog_details(); + $url = parse_url( UBP_SITEURL ); + $ms_url = ''; + if ( SUBDOMAIN_INSTALL ) { + $parts = explode( '.', $details->domain ); + $ms_url = $parts[0] . '.' . $url['host']; + } else { + $ms_url = $url['host'] . $details->path; + } + $url = 'http://' . $ms_url . @$url['path']; + + } else if ( defined( 'UBP_SITEURL' ) && false !== UBP_SITEURL ) { + $url = parse_url( UBP_SITEURL ); $url = 'http://' . $url['host'] . @$url['path']; - }else if ( !is_multisite() ) { + } else { // Nothing set... Get original siteurl from database remove_filter( 'option_siteurl', '_config_wp_siteurl' ); @@ -147,6 +170,27 @@ public function get_domain() { return $this->domain; } + public function get_dated_path() { + $path = $this->get_local_path(); + + if ( function_exists( 'is_multisite' ) && is_multisite() && strpos( $path, '/files/' ) === 0 ) { + $path = str_replace( '/files', '', $path ); + } + + return $path; + } + + public function get_ms_adjusted_path() { + $path = $this->get_local_path(); + + //switch to the "new" multisite files location + if ( function_exists( 'is_multisite' ) && is_multisite() && strpos( $path, '/files/' ) === 0 ) { + $path = 'wp-content/uploads/sites/' . get_current_blog_id() . str_replace( '/files', '', $path ); + } + + return $path; + } + public function get_auth() { if ( !isset( $this->auth ) ) { $user = parse_url( $this->get_siteurl(), PHP_URL_USER ); @@ -170,8 +214,10 @@ public function get_local_path() { // If local install is in a subdirectory, modify path to request from WordPress root $local_wordpress_path = parse_url( get_site_url(), PHP_URL_PATH ) . '/'; $requested_path = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ); + if (substr($requested_path, 0, strlen($local_wordpress_path)) == $local_wordpress_path) { - $requested_path = substr($requested_path, strlen($local_wordpress_path)-1, strlen($requested_path)); + //$requested_path = substr($requested_path, strlen($local_wordpress_path), strlen($requested_path)); + $requested_path = substr($requested_path, strlen($local_wordpress_path)-1, strlen($requested_path)); } $this->local_path = $requested_path; @@ -186,6 +232,7 @@ public function get_remote_path() { // If remote install is in a subdirectory, prepend the remote path $remote_path = parse_url( $this->get_siteurl(), PHP_URL_PATH ); + if ( !empty( $remote_path ) ) { $this->remote_path = $remote_path . $this->get_local_path(); }else { diff --git a/class-get-public-ip.php b/class-get-public-ip.php index 47f3f0d..e035817 100644 --- a/class-get-public-ip.php +++ b/class-get-public-ip.php @@ -44,7 +44,7 @@ function __toString() { public function get_ip( $url, $args=array() ) { $defaults = array( 'method' => 'GET', - 'referer'=> $domain, + 'referer'=> $this->domain, 'body' => '', 'index' => 0, ); @@ -58,7 +58,7 @@ public function get_ip( $url, $args=array() ) { ); $response = wp_remote_get( $url, $query_args ); - + if ( ! is_wp_error( $response ) ) { $body = strip_tags($response['body']); diff --git a/class-helpers.php b/class-helpers.php index e546bd3..a95a7a9 100644 --- a/class-helpers.php +++ b/class-helpers.php @@ -13,7 +13,7 @@ static public function init_404_template( $template ) { } static public function requirements_check() { - add_action( 'admin_init', 'UBP_Helpers::require_no_multisite', 11 ); + //add_action( 'admin_init', 'UBP_Helpers::require_no_multisite', 11 ); add_action( 'admin_notices', 'UBP_Helpers::request_uploads_writable' ); add_action( 'admin_footer', 'UBP_Helpers::request_permalinks_enabled' ); } @@ -21,7 +21,7 @@ static public function requirements_check() { /** * Require single-site install before activating. */ - static public function require_no_multisite() { + static public function require_no_multisite() { if ( function_exists( 'is_multisite' ) && !is_multisite() ) { return true; } if ( is_admin() && (!defined('DOING_AJAX') || !DOING_AJAX) ) { @@ -64,4 +64,31 @@ static public function request_uploads_writable() { return false; } + static public function print_multisite_setting( $id ) { + switch_to_blog( $id ); + $ubp_site_url = get_option( '_ubp_site_url' ); + restore_current_blog(); + ?> +
define('WP_SITEURL', 'http://development-domain.com');
or define('UBP_SITEURL', 'http://live-domain.com/wordpress');
in wp-config.php.
-Version: 1.1.2
+Version: 1.1.3ms
*/
/**
@@ -54,3 +54,10 @@
add_action( 'admin_init', 'UBP_Helpers::requirements_check' );
add_filter( '404_template', 'UBP_Helpers::init_404_template' );
}
+
+if ( function_exists( 'is_multisite' ) && is_multisite() ) {
+ add_action( 'wpmueditblogaction', 'UBP_Helpers::print_multisite_setting' );
+ add_filter( 'ubp_allowed_paths', 'UBP_Helpers::ubp_extra_paths' );
+ add_action( 'init','UBP_Helpers::stop_ms_files_rewriting' );
+ add_filter( 'pre_site_option_ms_files_rewriting', 'UBP_Helpers::pre_site_option_ms_files_rewriting' );
+}