Changeset 403637
- Timestamp:
- 07/02/2011 07:13:14 AM (15 years ago)
- Location:
- wp-s3/trunk
- Files:
-
- 2 edited
-
s3-options.php (modified) (1 diff)
-
s3.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-s3/trunk/s3-options.php
r403515 r403637 107 107 </tr> 108 108 <tr valign="top"> 109 <th scope="row"><?php _e('Compress JS & CSS') ?></th> 110 <td> 111 <fieldset> 112 <legend class="screen-reader-text"><span><?php _e('Use SSL') ?></span></legend> 113 <label for="s3plugin_compress_files"> 114 <input name="s3plugin_compress_files" type="checkbox" id="s3plugin_compress_files" value="1" <?php checked('1', get_option('s3plugin_compress_files')); ?> /> 115 <?php _e('Enable this to compress and push js and css files to s3') ?> 116 </label> 117 </fieldset> 118 </td> 119 </tr> 120 <tr valign="top"> 109 121 <th scope="row"><label for="s3plugin_cloudfrontURL"><?php _e('Path prefix') ?></label></th> 110 122 <td> -
wp-s3/trunk/s3.php
r403515 r403637 24 24 var $s3UseCloudFrontURL; 25 25 var $s3CloudFrontURL; 26 var $s3CompressFiles; 26 27 var $s3DirPrefix; 27 28 var $cronScheduleTime; … … 72 73 $this->s3BucketName = get_option('s3plugin_amazon_bucket_name'); 73 74 $this->s3UseSSL = (bool) get_option('s3plugin_use_ssl', 0); 75 $this->s3CompressFiles = (bool) get_option('s3plugin_compress_files', 0); 74 76 $this->s3DirPrefix = get_option('s3plugin_dir_prefix'); 75 77 … … 82 84 $this->isCloudFrontURLEnabled = FALSE; 83 85 } 84 85 86 86 87 $this->cronScheduleTime = get_option('s3plugin_cron_interval', 300); … … 97 98 'deactivatePlugin')); 98 99 add_action('admin_menu', array(&$this, 's3AdminMenu')); 100 99 101 add_filter('script_loader_src', array(&$this, 'script_loader_src'), 99); 100 102 add_filter('style_loader_src', array(&$this, 'style_loader_src'), 99); … … 140 142 update_option('s3plugin_amazon_secret_key', $_POST ['s3plugin_amazon_secret_key']); 141 143 update_option('s3plugin_amazon_bucket_name', $_POST ['s3plugin_amazon_bucket_name']); 144 142 145 if (isset($_POST ['s3plugin_use_ssl'])) { 143 146 update_option('s3plugin_use_ssl', $_POST ['s3plugin_use_ssl']); … … 145 148 delete_option('s3plugin_use_ssl'); 146 149 } 150 151 if (isset($_POST ['s3plugin_compress_files'])) { 152 update_option('s3plugin_compress_files', $_POST ['s3plugin_compress_files']); 153 } else { 154 delete_option('s3plugin_compress_files'); 155 } 156 147 157 if (isset($_POST ['s3plugin_use_cloudfrontURL'])) { 148 158 update_option('s3plugin_use_cloudfrontURL', $_POST ['s3plugin_use_cloudfrontURL']); … … 150 160 delete_option('s3plugin_use_cloudfrontURL'); 151 161 } 162 152 163 if (isset($_POST ['s3plugin_clear_cache'])) { 153 164 $this->recursive_remove_directory($this->s3CacheFolder, FALSE); … … 210 221 ignore_user_abort(true); 211 222 set_time_limit(0); 212 223 224 ini_set('display_errors', 1); 225 ini_set('log_errors', 1); 226 ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); 227 error_reporting(E_ALL); 228 213 229 print "Hello"; 214 230 … … 218 234 $availableBuckets = @$s3Adapter->listBuckets(); 219 235 cmVarDebug($availableBuckets); 220 236 221 237 if (!empty($availableBuckets) && in_array($this->s3BucketName, $availableBuckets) == TRUE) { 222 238 $query = "SELECT * FROM {$this->tabeImageQueue} WHERE status='queue' ORDER BY added LIMIT {$this->cronUploadLimit};"; … … 224 240 if (!empty($filesToUpload)) { 225 241 foreach ($filesToUpload as $fileInfo) { 242 cmVarDebug($fileInfo); 226 243 $shouldUpload = TRUE; 227 244 $fileStatus = 'error'; … … 239 256 } 240 257 if ($shouldUpload) { 241 $fileMimeType = $this->getFileType($filePath); 242 if ($s3Adapter->putObjectFile($filePath, $this->s3BucketName, $this->s3DirPrefix . $fileInfo ['path'], S3::ACL_PUBLIC_READ, array(), $fileMimeType) === TRUE) { 258 $fileContentType = $this->getFileType($filePath); 259 $fileRequestHeaders = array( 260 'Content-Type' => $fileContentType 261 ); 262 $tempFile = ''; 263 if ($this->s3CompressFiles && ( $fileContentType == 'text/css' || $fileContentType == 'text/javascript')) { 264 $fileRequestHeaders['Content-Encoding'] = 'gzip'; 265 $tempFile = tempnam($this->s3CacheFolder, 'tmp_gzip'); 266 $gzipFilePointer = fopen($tempFile, "wb+"); 267 fwrite($gzipFilePointer, gzencode(file_get_contents($filePath), 9)); 268 fclose($gzipFilePointer); 269 $fileResource = $s3Adapter->inputResource(fopen($tempFile, 'rb'), filesize($tempFile)); 270 } else { 271 $fileResource = $s3Adapter->inputResource(fopen($filePath, 'rb'), filesize($filePath)); 272 } 273 if ($s3Adapter->putObject($fileResource, $this->s3BucketName, $this->s3DirPrefix . $fileInfo ['path'], S3::ACL_PUBLIC_READ, array(), $fileRequestHeaders) === TRUE) { 243 274 $fileStatus = 'done'; 275 } 276 if (!empty($tempFile)) { 277 @unlink($tempFile); 244 278 } 245 279 } … … 374 408 $instance = self::getInstance(); 375 409 $relativePath = ltrim(str_replace($instance->siteURL, '', $fileURL), '/'); 376 $realPath = $instance->getRealPath($fileURL); 410 $realPath = trim($instance->getRealPath($fileURL)); 411 if (empty($realPath)) { 412 return FALSE; 413 } 377 414 if (file_exists($realPath)) { 378 415 foreach ($instance->blockDirectory as $blokedDirectory) {
Note: See TracChangeset
for help on using the changeset viewer.