From 6e2a149cc815bdf4564b56babe3ce87a46fd5f90 Mon Sep 17 00:00:00 2001 From: Ryan Parlee Date: Thu, 6 Nov 2014 17:27:25 -0600 Subject: [PATCH 01/16] added support for MU url formating --- wpro.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/wpro.php b/wpro.php index 0346193..cb8b0d2 100644 --- a/wpro.php +++ b/wpro.php @@ -520,8 +520,20 @@ function upload_dir($data) { $data['baseurl'] = '//' . trim(str_replace('//', '/', wpro_get_option('wpro-aws-bucket') . '.s3.amazonaws.com/' . trim(wpro_get_option('wpro-folder'))), '/'); } } - $data['path'] = $this->upload_basedir . $data['subdir']; - $data['url'] = $data['baseurl'] . $data['subdir']; + //see wp-includes/functions.php [ + $ms_dir = ''; + if ( is_multisite() && ! ( is_main_network() && is_main_site() && defined( 'MULTISITE' ) ) ) { + if ( ! get_site_option( 'ms_files_rewriting' ) ) { + if ( defined( 'MULTISITE' ) ) + $ms_dir = '/sites/' . get_current_blog_id(); + else + $ms_dir = '/' . get_current_blog_id(); + } elseif ( defined( 'UPLOADS' ) && ! ms_is_switched() ) { + //?? + } + } + $data['path'] = $this->upload_basedir . $ms_dir . $data['subdir']; + $data['url'] = $data['baseurl'] . $ms_dir . $data['subdir']; $this->removeTemporaryLocalData($data['path']); // $this->debug('-> RETURNS = '); // $this->debug(print_r($data, true)); From 61fbb87661074642bdcd1974cffa2e535befb6b8 Mon Sep 17 00:00:00 2001 From: Ryan Parlee Date: Fri, 7 Nov 2014 03:36:06 +0000 Subject: [PATCH 02/16] adjust ['baseurl'] --- wpro.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wpro.php b/wpro.php index cb8b0d2..7004850 100644 --- a/wpro.php +++ b/wpro.php @@ -521,7 +521,6 @@ function upload_dir($data) { } } //see wp-includes/functions.php [ - $ms_dir = ''; if ( is_multisite() && ! ( is_main_network() && is_main_site() && defined( 'MULTISITE' ) ) ) { if ( ! get_site_option( 'ms_files_rewriting' ) ) { if ( defined( 'MULTISITE' ) ) @@ -531,9 +530,10 @@ function upload_dir($data) { } elseif ( defined( 'UPLOADS' ) && ! ms_is_switched() ) { //?? } + $data['baseurl'] .= $ms_dir; } - $data['path'] = $this->upload_basedir . $ms_dir . $data['subdir']; - $data['url'] = $data['baseurl'] . $ms_dir . $data['subdir']; + $data['path'] = $this->upload_basedir . $data['subdir']; + $data['url'] = $data['baseurl'] . $data['subdir']; $this->removeTemporaryLocalData($data['path']); // $this->debug('-> RETURNS = '); // $this->debug(print_r($data, true)); From a5e019689182706e6e16a13b4657fdc512d09520 Mon Sep 17 00:00:00 2001 From: Ryan Parlee Date: Fri, 5 Dec 2014 16:39:54 -0600 Subject: [PATCH 03/16] added back compatibility for wp <3.9 --- wpro.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wpro.php b/wpro.php index 7004850..5a7cd61 100644 --- a/wpro.php +++ b/wpro.php @@ -521,7 +521,7 @@ function upload_dir($data) { } } //see wp-includes/functions.php [ - if ( is_multisite() && ! ( is_main_network() && is_main_site() && defined( 'MULTISITE' ) ) ) { + if ( is_multisite() && ! ( function_exists('is_main_network') && is_main_network() && is_main_site() && defined( 'MULTISITE' ) ) ) { if ( ! get_site_option( 'ms_files_rewriting' ) ) { if ( defined( 'MULTISITE' ) ) $ms_dir = '/sites/' . get_current_blog_id(); From 261d98262e884ff72ac2037d9c324f49e65b97d6 Mon Sep 17 00:00:00 2001 From: Ryan Parlee Date: Tue, 9 Dec 2014 10:39:19 -0600 Subject: [PATCH 04/16] update to support Multisites created on WP<3.0 using old-form blogs.dir uploads --- wpro.php | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/wpro.php b/wpro.php index 5a7cd61..fbcb540 100644 --- a/wpro.php +++ b/wpro.php @@ -26,6 +26,12 @@ function sys_get_temp_dir() { } } +if ( !function_exists('is_main_network')) { + function is_main_network() { + return true; + } +} + // open_basedir / safe_mode disallows CURLOPT_FOLLOWLOCATION function curl_exec_follow($ch, &$maxredirect = null) { $mr = $maxredirect === null ? 5 : intval($maxredirect); @@ -509,28 +515,48 @@ function upload_dir($data) { while (is_dir($this->upload_basedir)) $this->upload_basedir = $this->tempdir . 'wpro' . time() . rand(0, 999999); } $data['basedir'] = $this->upload_basedir; + + // Begin building baseurl switch (wpro_get_option('wpro-service')) { case 'ftp': - $data['baseurl'] = '//' . trim(str_replace('//', '/', trim(wpro_get_option('wpro-ftp-webroot'), '/') . '/' . trim(wpro_get_option('wpro-folder'))), '/'); + $data['baseurl'] = '//' . trim(str_replace('//', '/', trim(wpro_get_option('wpro-ftp-webroot'))), '/'); break; default: if (wpro_get_option('wpro-aws-virthost')) { - $data['baseurl'] = '//' . trim(str_replace('//', '/', wpro_get_option('wpro-aws-bucket') . '/' . trim(wpro_get_option('wpro-folder'))), '/'); + $data['baseurl'] = '//' . trim(str_replace('//', '/', wpro_get_option('wpro-aws-bucket')), '/'); } else { - $data['baseurl'] = '//' . trim(str_replace('//', '/', wpro_get_option('wpro-aws-bucket') . '.s3.amazonaws.com/' . trim(wpro_get_option('wpro-folder'))), '/'); + $data['baseurl'] = '//' . trim(str_replace('//', '/', wpro_get_option('wpro-aws-bucket') . '.s3.amazonaws.com'), '/'); } } + // Append the appropriate wpro-folder to baseurl //see wp-includes/functions.php [ - if ( is_multisite() && ! ( function_exists('is_main_network') && is_main_network() && is_main_site() && defined( 'MULTISITE' ) ) ) { + if ( is_multisite() && ! ( is_main_network() && is_main_site() && defined( 'MULTISITE' ) ) ) { if ( ! get_site_option( 'ms_files_rewriting' ) ) { + $data['baseurl'] .= '/' . trim(str_replace('//', '/', trim(wpro_get_option('wpro-folder'))), '/'); if ( defined( 'MULTISITE' ) ) $ms_dir = '/sites/' . get_current_blog_id(); else $ms_dir = '/' . get_current_blog_id(); } elseif ( defined( 'UPLOADS' ) && ! ms_is_switched() ) { - //?? + /*error_log('WPRO: defined("UPLOADS") && ! ms_is_switched():' . + ' get_current_blog_id() = ' . get_current_blog_id() . + ', oldbaseurl = ' . $oldbaseurl . + ', oldbasedir = ' . $oldbasedir . + ', oldpath = ' . $data['path'] . + ', oldurl = ' . $data['url'] . + ', $data[\'baseurl\'] = ' . $data['baseurl'] . + ', $data[\'basedir\'] = ' . $data['basedir'] . + ', $data[\'subdir\'] = ' . $data['subdir'] . + ', $data[\'path\'] = ' . $this->upload_basedir . $data['subdir'] . + ', $data[\'url\'] = ' . $data['baseurl'] . $data['subdir'] ); + */ + // Handle the old-form ms-files.php rewriting if the network still has that enabled. + $data['baseurl'] .= '/' . trim(str_replace('//', '/', trim(wpro_get_option('wpro-blogsfolder', 'wp-content/blogs.dir'))), '/'); + $ms_dir = '/' . get_current_blog_id() . '/files'; } $data['baseurl'] .= $ms_dir; + } else { + $data['baseurl'] .= '/' . str_replace('//', '/', trim(wpro_get_option('wpro-folder'))) . '/'; } $data['path'] = $this->upload_basedir . $data['subdir']; $data['url'] = $data['baseurl'] . $data['subdir']; From 35ebb4abe633e9796e99fd2c97bdf9b2eaa21ee7 Mon Sep 17 00:00:00 2001 From: Ryan Parlee Date: Tue, 9 Dec 2014 10:39:19 -0600 Subject: [PATCH 05/16] update to support Multisites created on WP<3.0 using old-form blogs.dir uploads --- wpro.php | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/wpro.php b/wpro.php index 5a7cd61..ac60f33 100644 --- a/wpro.php +++ b/wpro.php @@ -26,6 +26,12 @@ function sys_get_temp_dir() { } } +if ( !function_exists('is_main_network')) { + function is_main_network() { + return true; + } +} + // open_basedir / safe_mode disallows CURLOPT_FOLLOWLOCATION function curl_exec_follow($ch, &$maxredirect = null) { $mr = $maxredirect === null ? 5 : intval($maxredirect); @@ -509,28 +515,36 @@ function upload_dir($data) { while (is_dir($this->upload_basedir)) $this->upload_basedir = $this->tempdir . 'wpro' . time() . rand(0, 999999); } $data['basedir'] = $this->upload_basedir; + + // Begin building baseurl switch (wpro_get_option('wpro-service')) { case 'ftp': - $data['baseurl'] = '//' . trim(str_replace('//', '/', trim(wpro_get_option('wpro-ftp-webroot'), '/') . '/' . trim(wpro_get_option('wpro-folder'))), '/'); + $data['baseurl'] = '//' . trim(str_replace('//', '/', trim(wpro_get_option('wpro-ftp-webroot'))), '/'); break; default: if (wpro_get_option('wpro-aws-virthost')) { - $data['baseurl'] = '//' . trim(str_replace('//', '/', wpro_get_option('wpro-aws-bucket') . '/' . trim(wpro_get_option('wpro-folder'))), '/'); + $data['baseurl'] = '//' . trim(str_replace('//', '/', wpro_get_option('wpro-aws-bucket')), '/'); } else { - $data['baseurl'] = '//' . trim(str_replace('//', '/', wpro_get_option('wpro-aws-bucket') . '.s3.amazonaws.com/' . trim(wpro_get_option('wpro-folder'))), '/'); + $data['baseurl'] = '//' . trim(str_replace('//', '/', wpro_get_option('wpro-aws-bucket') . '.s3.amazonaws.com'), '/'); } } + // Append the appropriate wpro-folder to baseurl //see wp-includes/functions.php [ - if ( is_multisite() && ! ( function_exists('is_main_network') && is_main_network() && is_main_site() && defined( 'MULTISITE' ) ) ) { + if ( is_multisite() && ! ( is_main_network() && is_main_site() && defined( 'MULTISITE' ) ) ) { if ( ! get_site_option( 'ms_files_rewriting' ) ) { + $data['baseurl'] .= '/' . trim(str_replace('//', '/', trim(wpro_get_option('wpro-folder'))), '/'); if ( defined( 'MULTISITE' ) ) $ms_dir = '/sites/' . get_current_blog_id(); else $ms_dir = '/' . get_current_blog_id(); } elseif ( defined( 'UPLOADS' ) && ! ms_is_switched() ) { - //?? + // Handle the old-form ms-files.php rewriting if the network still has that enabled. + $data['baseurl'] .= '/' . trim(str_replace('//', '/', trim(wpro_get_option('wpro-blogsfolder', 'wp-content/blogs.dir'))), '/'); + $ms_dir = '/' . get_current_blog_id() . '/files'; } $data['baseurl'] .= $ms_dir; + } else { + $data['baseurl'] .= '/' . str_replace('//', '/', trim(wpro_get_option('wpro-folder'))) . '/'; } $data['path'] = $this->upload_basedir . $data['subdir']; $data['url'] = $data['baseurl'] . $data['subdir']; From 8841b737e6fa970481ad2387c9a1cf00a15276fc Mon Sep 17 00:00:00 2001 From: Ryan Parlee Date: Tue, 9 Dec 2014 15:39:18 -0600 Subject: [PATCH 06/16] support for s3 SSL --- wpro.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wpro.php b/wpro.php index ac60f33..dd7eda9 100644 --- a/wpro.php +++ b/wpro.php @@ -525,7 +525,11 @@ function upload_dir($data) { if (wpro_get_option('wpro-aws-virthost')) { $data['baseurl'] = '//' . trim(str_replace('//', '/', wpro_get_option('wpro-aws-bucket')), '/'); } else { - $data['baseurl'] = '//' . trim(str_replace('//', '/', wpro_get_option('wpro-aws-bucket') . '.s3.amazonaws.com'), '/'); + if (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] !== 'off')) { + $data['baseurl'] = 'https://s3.amazonaws.com/' . trim(str_replace('//', '/', wpro_get_option('wpro-aws-bucket')), '/'); + } else { + $data['baseurl'] = '//' . trim(str_replace('//', '/', wpro_get_option('wpro-aws-bucket') . '.s3.amazonaws.com'), '/'); + } } } // Append the appropriate wpro-folder to baseurl From 4654d3c231ea1749e9fefe36f541967e1b1d324f Mon Sep 17 00:00:00 2001 From: Ryan Parlee Date: Tue, 9 Dec 2014 17:29:13 -0600 Subject: [PATCH 07/16] cleanup --- wpro.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/wpro.php b/wpro.php index dd7eda9..e8d09bd 100644 --- a/wpro.php +++ b/wpro.php @@ -523,13 +523,15 @@ function upload_dir($data) { break; default: if (wpro_get_option('wpro-aws-virthost')) { + // Use Virtual Hosted-Style with CNAME $data['baseurl'] = '//' . trim(str_replace('//', '/', wpro_get_option('wpro-aws-bucket')), '/'); + } else if (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] !== 'off')) { + // Force Path-Style when using SSL, otherwise user will get a certificate error if the + // bucket contains periods. (i.e. S3's certificate won't match www.mydomain.com.s3.amazonaws.com) + $data['baseurl'] = '//s3.amazonaws.com/' . trim(str_replace('//', '/', wpro_get_option('wpro-aws-bucket')), '/'); } else { - if (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] !== 'off')) { - $data['baseurl'] = 'https://s3.amazonaws.com/' . trim(str_replace('//', '/', wpro_get_option('wpro-aws-bucket')), '/'); - } else { - $data['baseurl'] = '//' . trim(str_replace('//', '/', wpro_get_option('wpro-aws-bucket') . '.s3.amazonaws.com'), '/'); - } + // Use Virtual Hosted-Style without CNAME + $data['baseurl'] = '//' . trim(str_replace('//', '/', wpro_get_option('wpro-aws-bucket') . '.s3.amazonaws.com'), '/'); } } // Append the appropriate wpro-folder to baseurl From 42f666c1f75c4d68047b43b51c49af836239ffa2 Mon Sep 17 00:00:00 2001 From: Ryan Parlee Date: Tue, 9 Dec 2014 22:34:58 -0600 Subject: [PATCH 08/16] WP 3.2 compatibility --- wpro.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/wpro.php b/wpro.php index e8d09bd..a975551 100644 --- a/wpro.php +++ b/wpro.php @@ -26,12 +26,21 @@ function sys_get_temp_dir() { } } +// WP < 3.5 compatibility if ( !function_exists('is_main_network')) { function is_main_network() { return true; } } +// WP < 3.2 compatibility +if ( !function_exists('ms_is_switched')) { + define('USEBLOGSDIR', true); + function ms_is_switched() { + return true; + } +} + // open_basedir / safe_mode disallows CURLOPT_FOLLOWLOCATION function curl_exec_follow($ch, &$maxredirect = null) { $mr = $maxredirect === null ? 5 : intval($maxredirect); @@ -537,7 +546,7 @@ function upload_dir($data) { // Append the appropriate wpro-folder to baseurl //see wp-includes/functions.php [ if ( is_multisite() && ! ( is_main_network() && is_main_site() && defined( 'MULTISITE' ) ) ) { - if ( ! get_site_option( 'ms_files_rewriting' ) ) { + if ( ! defined('USEBLOGSDIR') && ! get_site_option( 'ms_files_rewriting' ) ) { $data['baseurl'] .= '/' . trim(str_replace('//', '/', trim(wpro_get_option('wpro-folder'))), '/'); if ( defined( 'MULTISITE' ) ) $ms_dir = '/sites/' . get_current_blog_id(); @@ -550,7 +559,7 @@ function upload_dir($data) { } $data['baseurl'] .= $ms_dir; } else { - $data['baseurl'] .= '/' . str_replace('//', '/', trim(wpro_get_option('wpro-folder'))) . '/'; + $data['baseurl'] .= '/' . trim(str_replace('//', '/', trim(wpro_get_option('wpro-folder'))), '/'); } $data['path'] = $this->upload_basedir . $data['subdir']; $data['url'] = $data['baseurl'] . $data['subdir']; From 15d8a14ceb964da6960a8efb86aeb3c6d43e4a7c Mon Sep 17 00:00:00 2001 From: Ryan Parlee Date: Fri, 9 Jan 2015 20:34:52 -0500 Subject: [PATCH 09/16] fix for ssl in upload function --- wpro.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wpro.php b/wpro.php index a975551..ae3d139 100644 --- a/wpro.php +++ b/wpro.php @@ -199,6 +199,10 @@ function upload($file, $fullurl, $mime) { if (!preg_match('/^\/\/([^\/]+)\/(.*)$/', $fullurl, $regs)) return false; $url = $regs[2]; + if (preg_match('/^' . str_replace('.', '\\.', str_replace('/', '\/', trim(str_replace('//', '/', wpro_get_option('wpro-aws-bucket')), '/'))) . '\/(.*)$/', $url, $regs)) { + $url = $regs[1]; + } + if (!file_exists($file)) return false; $this->removeTemporaryLocalData($file); From e330f1d0e936991b2bda58c308065707c8509ffc Mon Sep 17 00:00:00 2001 From: Ryan Parlee Date: Fri, 16 Jan 2015 15:53:29 -0600 Subject: [PATCH 10/16] fix virthost --- wpro.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wpro.php b/wpro.php index ae3d139..a0b5c20 100644 --- a/wpro.php +++ b/wpro.php @@ -537,7 +537,7 @@ function upload_dir($data) { default: if (wpro_get_option('wpro-aws-virthost')) { // Use Virtual Hosted-Style with CNAME - $data['baseurl'] = '//' . trim(str_replace('//', '/', wpro_get_option('wpro-aws-bucket')), '/'); + $data['baseurl'] = '//' . trim(str_replace('//', '/', wpro_get_option('wpro-aws-virthost')), '/'); } else if (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] !== 'off')) { // Force Path-Style when using SSL, otherwise user will get a certificate error if the // bucket contains periods. (i.e. S3's certificate won't match www.mydomain.com.s3.amazonaws.com) From ef3666ba65fbc69fe4b14e8b97231f43bc5e11c9 Mon Sep 17 00:00:00 2001 From: Ryan Parlee Date: Tue, 10 Feb 2015 10:55:50 -0600 Subject: [PATCH 11/16] updated version to 1.1 and updated authorship --- wpro.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wpro.php b/wpro.php index a0b5c20..7ac57be 100644 --- a/wpro.php +++ b/wpro.php @@ -1,11 +1,11 @@ Date: Mon, 9 Mar 2015 16:42:08 -0500 Subject: [PATCH 12/16] fix gravityforms upload when running wpro as mu-plugin; handle post_image type fields --- wpro.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/wpro.php b/wpro.php index 7ac57be..ff45181 100644 --- a/wpro.php +++ b/wpro.php @@ -303,9 +303,10 @@ function __construct() { add_filter('shutdown', array($this, 'shutdown')); // Support for Gravity Forms if Gravity Forms is enabled - if(class_exists("GFCommon")) { + //RYAN:commented out class_exists check because when running as mu-plugin the GFCommon class does not yet exist. + //if(class_exists("GFCommon")) { add_action("gform_after_submission", array($this, 'gravityforms_after_submission'), 10, 2); - } + //} switch (wpro_get_option('wpro-service')) { case 'ftp': @@ -752,18 +753,27 @@ function handle_upload_prefilter($file) { } function gravityforms_after_submission($entry, $form) { + + // Upload any file attachments $this->debug('WordpressReadOnly::gravityforms_after_submission($entry, $form);'); $upload_dir = wp_upload_dir(); foreach($form['fields'] as $field) { - if ($field['type'] == 'fileupload') { + if ($field['type'] == 'fileupload' || $field['type'] == 'post_image') { $id = (int) $field['id']; $file_to_upload = $entry[$id]; if($file_to_upload) { $url = $entry[$id]; + if ($field['type'] == 'post_image') { + if (strpos($file_to_upload, '|')) { + $file_to_upload = strstr($file_to_upload, '|', true); + } + if (strpos($url, '|')) { + $url = strstr($url, '|', true); + } + } $file_to_upload = str_replace($upload_dir['baseurl'], $upload_dir['basedir'], $file_to_upload); $mime = wp_check_filetype($file_to_upload); - $response = $this->backend->upload($file_to_upload, $url, $mime['type']); if (!$response) return false; } From acad9cea0822d3060b1b3a1c456624c06a63e267 Mon Sep 17 00:00:00 2001 From: Ryan Parlee Date: Wed, 11 Mar 2015 12:30:59 -0500 Subject: [PATCH 13/16] fix name collissions for mixed case filename extensions-WP lowers extensions on upload --- wpro.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/wpro.php b/wpro.php index ff45181..681bba4 100644 --- a/wpro.php +++ b/wpro.php @@ -732,6 +732,14 @@ function handle_upload_prefilter($file) { $upload = wp_upload_dir(); $name = $file['name']; + + // If a filename extension exists, lower it. + if (preg_match('/\.([^\.\/]+)$/', $file['name'], $regs)) { + $ending = '.' . $regs[1]; + $preending = substr($file['name'], 0, 0 - strlen($ending)); + $name = $preending . strtolower($ending); + } + $path = trim($upload['url'], '/') . '/' . $name; $counter = 0; @@ -739,7 +747,7 @@ function handle_upload_prefilter($file) { if (preg_match('/\.([^\.\/]+)$/', $file['name'], $regs)) { $ending = '.' . $regs[1]; $preending = substr($file['name'], 0, 0 - strlen($ending)); - $name = $preending . '_' . $counter . $ending; + $name = $preending . '_' . $counter . strtolower($ending); } else { $name = $file['name'] . '_' . $counter; } From f2b4fbe7e1013a5690642235217ad868c229cfb2 Mon Sep 17 00:00:00 2001 From: Ryan Parlee Date: Tue, 7 Apr 2015 08:31:31 -0500 Subject: [PATCH 14/16] renamed to wp-s3, updated version to 1.2 --- readme.txt => README.md | 16 ++++++++++++---- wpro.php => wp-s3.php | 8 ++++---- 2 files changed, 16 insertions(+), 8 deletions(-) rename readme.txt => README.md (92%) rename wpro.php => wp-s3.php (99%) diff --git a/readme.txt b/README.md similarity index 92% rename from readme.txt rename to README.md index 4bb7508..b8058fe 100644 --- a/readme.txt +++ b/README.md @@ -1,12 +1,20 @@ -=== WP Read-Only === +=== WP S3 === -* Contributors: alfreddatakillen +* Contributors: parleer * Tags: wordpress, amazon, s3, readonly * Requires at least: 3.3 -* Tested up to: 3.3.1 -* Stable tag: 1.0 +* Tested up to: 4.2 +* Stable tag: 1.2 * License: GPLv2 + +This plugin was modified from work frc's modified wpro plugin, which was +forked from alfreddatakillen. I've renamed the plugin to WP S3 because +I have no intention of supporting other distributed file systems, and +because alfreddatakillen has now rewritten his wpro plugin to be much +more generic. + + Plugin for running your Wordpress site without Write Access to the web directory. Amazon S3 is used for uploads/binary storage. This plugin was made with cluster/load balancing server setups in diff --git a/wpro.php b/wp-s3.php similarity index 99% rename from wpro.php rename to wp-s3.php index 681bba4..fcd4be0 100644 --- a/wpro.php +++ b/wp-s3.php @@ -1,10 +1,10 @@ Date: Tue, 7 Apr 2015 08:41:24 -0500 Subject: [PATCH 15/16] updated README to markdown syntax --- README.md | 55 ++++++++++++++++++++++--------------------------------- 1 file changed, 22 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index b8058fe..353b929 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -=== WP S3 === +# WP S3 -* Contributors: parleer +* Contributors: parleer, frc, alfreddatakillen * Tags: wordpress, amazon, s3, readonly * Requires at least: 3.3 * Tested up to: 4.2 @@ -21,7 +21,7 @@ This plugin was made with cluster/load balancing server setups in mind - where you do not want your WordPress to write anything to the local web directory. -== Description == +## Description This plugin will put your media uploads on Amazon S3. Unlike other S3 plugins, this plugin does not require your uploads to first be @@ -40,20 +40,20 @@ Note: You still need write access to the system /tmp directory for this plugin to work. It will use the system /tmp directory for temporary storage during uploads, image editing/scaling, etc. -= Wordpress MU/Multisite = +## Wordpress MU/Multisite This plugin works out-of-the box with Wordpress Multisite/MU. You will find the settings for this plugin in the Network Admin, when in a MU/Multisite environment. -== Installation == +## Installation 1. Put the plugin in the Wordpress `/wp-content/plugins/` directory. 2. Activate the plugin through the 'Plugins' menu in WordPress. 3. Enter your Amazon S3 settings in `Settings` > `WPRO Settings`. -= Alternative: Configure by constants in wp-config.php = +### Alternative: Configure by constants in wp-config.php Instead of configuring the plugin in `Settings` > `WPRO Settings`, you may use constants in your `wp-config.php`. This might be an @@ -89,42 +89,42 @@ Those are the AWS endpoints: * `s3-ap-northeast-1.amazonaws.com` - Asia Pacific (Tokyo) Region * `s3-sa-east-1.amazonaws.com` - South America (Sao Paulo) Region -== Frequently Asked Questions == +## Frequently Asked Questions -= Will this plugin work in Wordpress MU/Multisite environments? = +### Will this plugin work in Wordpress MU/Multisite environments? Yes. -= Where do I report bugs? = +### Where do I report bugs? Report any issues at the github issue tracker: -https://github.com/alfreddatakillen/wpro/issues +https://github.com/parleer/wp-s3/issues -= Where do I contribute with code, bug fixes, etc.? = +### Where do I contribute with code, bug fixes, etc.? At github: -https://github.com/alfreddatakillen/wpro +https://github.com/parleer/wp-s3 -And, plz, use tabs for indenting! :) - -= What should I think of when digging the code? = +### What should I think of when digging the code? If you define the constant WPRO_DEBUG in your wp-config.php, then some debug data will be written to /tmp/wpro-debug -= What about the license? = +### What about the license? Read more about GPLv2 here: http://www.gnu.org/licenses/gpl-2.0.html -= Do you like beer? = -If we meet some day, and you think this stuff is worth it, you may buy -me a beer in return. (GPLv2 still applies.) +## Changelog + +### 1.2 + +* Fixed bugs for WordPress MU deployment +* Added support for older WP, I think down to 2.9 -== Changelog == -= 1.1 = +### 1.1 * Added support for configuring by constants in `wp-config.php`. * Plugin now works in open_basedir and safe_mode environments. @@ -139,18 +139,7 @@ for contributing with code! Also, thanks to [mavesell](https://github.com/maveseli "mavesell") and [nmagee](https://github.com/nmagee "nmagee") for feedback and comments! -= 1.0 = +### 1.0 * The first public release. -== Roadmap == - -Todo list: - -* Add support for FTP:ing uploads to somewhere, as an alternative to - Amazon S3. -* For WPMU: Store media in a single bucket, but separate them by site, in - sub-folders. -* Only handle `new` medias when activating this plugin on an existing - site. Today it's an all-or-nothing approach, and you will have to - migrate your media to S3. From 230d75975a2016b6b8eb0ce998d93befda376b4f Mon Sep 17 00:00:00 2001 From: Ryan Parlee Date: Wed, 11 May 2016 22:56:10 -0500 Subject: [PATCH 16/16] add Cache-Control header to S3 and fix ssl urls to always use s3.amazonaws.com domain-style paths --- wp-s3.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wp-s3.php b/wp-s3.php index fcd4be0..9a30227 100644 --- a/wp-s3.php +++ b/wp-s3.php @@ -225,6 +225,7 @@ function upload($file, $fullurl, $mime) { $query = "PUT /" . $this->bucket . "/" . $url . " HTTP/1.1\n"; $query .= "Host: " . $this->endpoint . "\n"; $query .= "x-amz-acl: public-read\n"; + $query .= "Cache-Control: max-age=86400\n"; $query .= "Connection: keep-alive\n"; $query .= "Content-Type: " . $mime . "\n"; $query .= "Content-Length: " . filesize($file) . "\n"; @@ -545,7 +546,9 @@ function upload_dir($data) { $data['baseurl'] = '//s3.amazonaws.com/' . trim(str_replace('//', '/', wpro_get_option('wpro-aws-bucket')), '/'); } else { // Use Virtual Hosted-Style without CNAME - $data['baseurl'] = '//' . trim(str_replace('//', '/', wpro_get_option('wpro-aws-bucket') . '.s3.amazonaws.com'), '/'); + //RYAN: Use the same Path-Style to be compatible with the broken dynamic-featured-image plugin. + //$data['baseurl'] = '//' . trim(str_replace('//', '/', wpro_get_option('wpro-aws-bucket') . '.s3.amazonaws.com'), '/'); + $data['baseurl'] = '//s3.amazonaws.com/' . trim(str_replace('//', '/', wpro_get_option('wpro-aws-bucket')), '/'); } } // Append the appropriate wpro-folder to baseurl