Changeset 737670
- Timestamp:
- 07/08/2013 09:37:42 AM (13 years ago)
- Location:
- amazon-s3-uploads/trunk
- Files:
-
- 4 edited
-
asssu.php (modified) (1 diff)
-
plugin/asssu/__init.php (modified) (10 diffs)
-
plugin/asssu/forms.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
amazon-s3-uploads/trunk/asssu.php
r730022 r737670 6 6 Author URI: https://profiles.google.com/117859515361389646005 7 7 Description: Moves your uploads to Amazon S3 via cron jobs. 8 Version: 1.9. 38 Version: 1.9.4 9 9 */ 10 10 -
amazon-s3-uploads/trunk/plugin/asssu/__init.php
r730022 r737670 43 43 44 44 public static 45 $version = '1.9. 3';45 $version = '1.9.4'; 46 46 47 47 public … … 63 63 $this->site_url = \get_option('siteUrl'); 64 64 $this->site_url = trim(substr($this->site_url, strpos($this->site_url, '://') + 3), '/'); 65 $this->wp_upload_dir = \wp_upload_dir(); 65 66 $wp_upload_dir = \wp_upload_dir(); 67 $wp_upload_dir['local_path'] = $wp_upload_dir['path']; 68 $wp_upload_dir['local_basedir'] = $wp_upload_dir['basedir']; 69 $wp_upload_dir['path'] = $this->convert_to_s3_path($wp_upload_dir['path']); 70 $wp_upload_dir['basedir'] = $this->convert_to_s3_path($wp_upload_dir['basedir']); 71 $this->wp_upload_dir = $wp_upload_dir; 66 72 67 73 $this->db = new AsssuDb($this, $wpdb); … … 152 158 return $this->config['version']; 153 159 } 160 161 function upgrade_1_9_3() { 162 $this->config['version'] = '1.9.4'; 163 $this->db->save_config(); 164 return $this->config['version']; 165 } 154 166 155 167 function convert_to_s3_path($path, $stream_wrapper_format=true) { 156 168 if (strpos($path, 's3://') === 0) 157 169 return $path; 158 $s3_path = trim(str_replace($this->wp_upload_dir[' basedir'], '', $path), '/');170 $s3_path = trim(str_replace($this->wp_upload_dir['local_basedir'], '', $path), '/'); 159 171 if (!empty($this->config['bucket_subdir'])) 160 172 $s3_path = trim($this->config['bucket_subdir'].'/'.$s3_path, '/'); … … 198 210 $amazon_path = sprintf('%s%s/', $amazon_path, $this->config['bucket_subdir']); 199 211 200 $htaccess_file = $this->wp_upload_dir[' basedir'].'/.htaccess';212 $htaccess_file = $this->wp_upload_dir['local_basedir'].'/.htaccess'; 201 213 202 214 ob_start(); … … 239 251 240 252 function action_cron() { 241 list($limit, $files) = $this->find_files($this->asssu->wp_upload_dir[' basedir'], 50);253 list($limit, $files) = $this->find_files($this->asssu->wp_upload_dir['local_basedir'], 50); 242 254 if (count($files) > 0) 243 255 $client = $this->asssu->get_s3_client(); … … 292 304 function __construct($asssu) { 293 305 $this->asssu = $asssu; 294 // \add_filter('upload_dir', array($this, 'upload_dir')); 295 \add_filter('wp_handle_upload_prefilter', array($this, 'wp_handle_upload_prefilter')); 296 \add_filter('wp_delete_file', array($this, 'wp_delete_file')); 306 // \add_filter('upload_dir', array($this, 'upload_dir'), 20); 307 // \add_filter('wp_handle_upload', array($this, 'wp_handle_upload'), 20); 308 // \add_filter('image_make_intermediate_size', array($this, 'image_make_intermediate_size'), 20); 309 \add_filter('wp_handle_upload_prefilter', array($this, 'wp_handle_upload_prefilter'), 20); 310 \add_filter('wp_delete_file', array($this, 'wp_delete_file'), 20); 297 311 } 298 312 299 313 function upload_dir($args) { 300 314 $client = $this->asssu->get_s3_client(); 315 $args['local_path'] = $args['path']; 316 $args['local_basedir'] = $args['basedir']; 301 317 $args['path'] = $this->asssu->convert_to_s3_path($args['path']); 302 318 $args['basedir'] = $this->asssu->convert_to_s3_path($args['basedir']); 319 if (!file_exists($args['path'])) 320 file_put_contents($args['path'].'/index', ''); 303 321 return $args; 322 } 323 324 function wp_handle_upload($options) { 325 $client = $this->asssu->get_s3_client(); 326 list($wrapper, $key) = explode($this->asssu->config['bucket_name'], $options['file']); 327 $result = $client->putObjectAcl(array( 328 'Bucket' => $this->asssu->config['bucket_name'], 329 'Key' => $key, 330 'ACL' => 'public-read' 331 )); 332 return $options; 333 } 334 335 function image_make_intermediate_size($filename) { 336 $client = $this->asssu->get_s3_client(); 337 list($wrapper, $key) = explode($this->asssu->config['bucket_name'], $filename); 338 $result = $client->putObjectAcl(array( 339 'Bucket' => $this->asssu->config['bucket_name'], 340 'Key' => $key, 341 'ACL' => 'public-read' 342 )); 343 return $filename; 304 344 } 305 345 … … 311 351 function wp_unique_filename($filename) { 312 352 $client = $this->asssu->get_s3_client(); 313 $path = $this->asssu->wp_upload_dir[' path'];314 $s3_path = $this->asssu-> convert_to_s3_path($this->asssu->wp_upload_dir['path']);353 $path = $this->asssu->wp_upload_dir['local_path']; 354 $s3_path = $this->asssu->wp_upload_dir['path']; 315 355 $filename = str_replace('+', '-', $filename); 316 356 … … 397 437 'Amazon S3 Uploads', 398 438 'manage_options', 399 ' options',439 'amazon-s3-uploads-options', 400 440 array($this, 'page_options') 401 441 ); … … 405 445 'Amazon S3 Uploads Test Corn', 406 446 'manage_options', 407 ' test_cron',447 'amazon-s3-uploads-test_cron', 408 448 array($this, 'test_cron') 409 449 ); … … 412 452 'Amazon S3 Uploads Test Bucket Location', 413 453 'manage_options', 414 ' test_bucket_location',454 'amazon-s3-uploads-test_bucket_location', 415 455 array($this, 'test_bucket_location') 416 456 ); -
amazon-s3-uploads/trunk/plugin/asssu/forms.php
r729295 r737670 117 117 'eu-west-1' => 'eu-west-1', 118 118 'ap-southeast-1' => 'ap-southeast-1', 119 'ap-southeast-2' => 'ap-southeast-2', 119 120 'ap-northeast-1' => 'ap-northeast-1', 120 121 'sa-east-1' => 'sa-east-1' … … 126 127 'eu-west-1' => 'eu-west-1', 127 128 'ap-southeast-1' => 'ap-southeast-1', 129 'ap-southeast-2' => 'ap-southeast-2', 128 130 'ap-northeast-1' => 'ap-northeast-1', 129 131 'sa-east-1' => 'sa-east-1' -
amazon-s3-uploads/trunk/readme.txt
r730022 r737670 5 5 Requires at least: 3.5.2 6 6 Tested up to: 3.5.2 7 Stable tag: 1.9. 37 Stable tag: 1.9.4 8 8 License: GPLv2.1 9 9 … … 21 21 REQUIREMENTS 22 22 23 * Wordpress 3.5. 1+23 * Wordpress 3.5.2+ 24 24 * PHP 5.3.3+ compiled with the cURL extension 25 25 * A recent version of cURL 7.16.2+ compiled with OpenSSL and zlib
Note: See TracChangeset
for help on using the changeset viewer.