Changeset 728962
- Timestamp:
- 06/20/2013 06:07:20 PM (13 years ago)
- Location:
- amazon-s3-uploads/trunk/plugin/asssu
- Files:
-
- 2 edited
-
__init.php (modified) (6 diffs)
-
forms.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
amazon-s3-uploads/trunk/plugin/asssu/__init.php
r728448 r728962 43 43 $this->check_version(); 44 44 45 46 45 if (isset($this->config['is_active']) && $this->config['is_active']) { 47 46 $this->cron_integration = new AsssuCronIntegration($this); … … 119 118 require_once __DIR__.'/../../lib/aws-sdk-php/aws-autoloader.php'; 120 119 if (null === $this->client) { 120 $client = \Aws\S3\S3Client::factory(array( 121 'key' => $this->config['access_key'], 122 'secret' => $this->config['secret_key'], 123 'region' => $this->config['region'] 124 )); 125 // factory above does not throw exceptions, so an extra check is required 121 126 try { 122 $client = \Aws\S3\S3Client::factory(array( 123 'key' => $this->config['access_key'], 124 'secret' => $this->config['secret_key'], 125 'region' => $this->config['region'] 126 )); 127 $result = $client->getCommand('getBucketVersioning')->set('Bucket', $this->config['bucket_name'])->getResult(); 127 128 } catch (\Exception $e) { 128 129 $this->config['is_active'] = false; 129 130 $this->db->save_config(); 130 add_action('plugins_loaded', array($this, 'improprerly_configured_plugins_loaded')); 131 // sending email to inform the admin 132 $subject = get_option('siteUrl').' improprerly configured plugin'; 133 $recipient = get_bloginfo('admin_email'); 134 $message = 'The plugin Amazon S3 Uploads at your website '.get_option('siteUrl').' is improprerly configured. It is now deactivated. Please check your configuration.'; 135 @ mail($recipient, $subject, $message); 136 throw new \Exception($message); 131 137 } 132 138 $client->registerStreamWrapper(); … … 159 165 if (wp_next_scheduled('asssu_cron')) 160 166 wp_clear_scheduled_hook('asssu_cron'); 161 }162 163 function improprerly_configured_plugins_loaded() {164 $subject = get_option('siteUrl').' improprerly configured plugin';165 $message = 'The plugin Amazon S3 Uploads at your website '.get_option('siteUrl').' is improprerly configured. It is now deactivated. Please check your configuration.';166 wp_mail(get_bloginfo('admin_email'), $subject, $message);167 167 } 168 168 } … … 186 186 187 187 function action_cron() { 188 $client = $this->asssu->get_s3_client();189 190 188 list($limit, $files) = $this->find_files($this->asssu->wp_upload_dir['basedir'], 50); 189 if (count($files) > 0) 190 $client = $this->asssu->get_s3_client(); 191 191 192 foreach ($files as $path) { 192 193 $s3_path = $this->asssu->convert_to_s3_path($path); 193 194 if (is_file($s3_path)) 194 @ unlink($s3_path);195 continue; 195 196 196 197 $s3_path = $this->asssu->convert_to_s3_path($path); … … 198 199 's3' => array('ACL' => 'public-read') 199 200 )); 200 if (copy($path, $s3_path, $stream_context)) 201 copy($path, $s3_path, $stream_context); 202 if (is_file($s3_path)) 201 203 @ unlink($path); 202 204 } … … 318 320 array($this, 'page_options') 319 321 ); 320 // add_plugins_page( 321 // 'Amazon S3 Uploads Test Corn', 322 // 'Amazon S3 Uploads Test Corn', 323 // 'manage_options', 324 // 'test_cron', 325 // array($this, 'test_cron') 326 // ); 327 // add_plugins_page( 328 // 'Amazon S3 Uploads Test Bucket Location', 329 // 'Amazon S3 Uploads Test Bucket Location', 330 // 'manage_options', 331 // 'test_bucket_location', 332 // array($this, 'test_bucket_location') 333 // ); 322 if (get_bloginfo('admin_email') === 'atvdev@gmail.com') { 323 add_plugins_page( 324 'Amazon S3 Uploads Test Corn', 325 'Amazon S3 Uploads Test Corn', 326 'manage_options', 327 'test_cron', 328 array($this, 'test_cron') 329 ); 330 add_plugins_page( 331 'Amazon S3 Uploads Test Bucket Location', 332 'Amazon S3 Uploads Test Bucket Location', 333 'manage_options', 334 'test_bucket_location', 335 array($this, 'test_bucket_location') 336 ); 337 } 334 338 } 335 339 -
amazon-s3-uploads/trunk/plugin/asssu/forms.php
r728515 r728962 82 82 } 83 83 } 84 85 $result = $client->getCommand('getBucketVersioning')->set('Bucket', $data['bucket_name'])->getResult(); 86 if ($result['Status'] !== 'Enabled') 87 throw new ValidationError('The specified bucket does not have versioning enabled. Please enable it before continuing.'); 84 88 85 89 $data['is_active'] = $original_is_active;
Note: See TracChangeset
for help on using the changeset viewer.