Changeset 403224
- Timestamp:
- 07/01/2011 12:07:24 PM (15 years ago)
- File:
-
- 1 edited
-
wp-s3/trunk/s3.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-s3/trunk/s3.php
r403201 r403224 60 60 61 61 $this->blockDirectory = array('wpcf7_captcha'); 62 $this->blockExtension = array('php' );62 $this->blockExtension = array('php', 'htm', 'html'); 63 63 64 64 $this->s3CacheFolder = ABSPATH . 'wp-content' . DIRECTORY_SEPARATOR . 's3temp' . DIRECTORY_SEPARATOR; … … 226 226 } 227 227 if ($shouldUpload) { 228 if ($s3Adapter->putObjectFile($filePath, $this->s3BucketName, $fileInfo ['path'], S3::ACL_PUBLIC_READ) === TRUE) { 228 $fileMimeType = $this->getFileType($filePath); 229 if ($s3Adapter->putObjectFile($filePath, $this->s3BucketName, $fileInfo ['path'], S3::ACL_PUBLIC_READ, array(), $fileMimeType) === TRUE) { 229 230 $fileStatus = 'done'; 230 231 } … … 240 241 } 241 242 243 function getFileType($file) { 244 $ext = strtolower(pathInfo($file, PATHINFO_EXTENSION)); 245 static $exts = array( 246 'jpg' => 'image/jpeg', 247 'gif' => 'image/gif', 248 'png' => 'image/png', 249 'tif' => 'image/tiff', 250 'tiff' => 'image/tiff', 251 'ico' => 'image/x-icon', 252 'swf' => 'application/x-shockwave-flash', 253 'pdf' => 'application/pdf', 254 'zip' => 'application/zip', 255 'gz' => 'application/x-gzip', 256 'tar' => 'application/x-tar', 257 'bz' => 'application/x-bzip', 258 'bz2' => 'application/x-bzip2', 259 'txt' => 'text/plain', 260 'asc' => 'text/plain', 261 'htm' => 'text/html', 262 'html' => 'text/html', 263 'css' => 'text/css', 264 'js' => 'text/javascript', 265 'xml' => 'text/xml', 266 'xsl' => 'application/xsl+xml', 267 'ogg' => 'application/ogg', 268 'mp3' => 'audio/mpeg', 269 'wav' => 'audio/x-wav', 270 'avi' => 'video/x-msvideo', 271 'mpg' => 'video/mpeg', 272 'mpeg' => 'video/mpeg', 273 'mov' => 'video/quicktime', 274 'flv' => 'video/x-flv', 275 'php' => 'text/x-php' 276 ); 277 return isset($exts[$ext]) ? $exts[$ext] : 'application/octet-stream'; 278 } 279 242 280 function script_loader_src($scriptURL) { 243 281 if (!is_admin()) { … … 265 303 } 266 304 return $fileCDNURL; 267 } else{305 } else { 268 306 $realPath = $this->getRealPath($justURL); 269 307 if (file_exists($realPath)) { 270 308 $cssFolder = dirname($realPath); 271 309 $cssRelatedFiles = $this->scanDirectoryRecursively($cssFolder); 272 if (!empty ($cssRelatedFiles)){273 foreach ($cssRelatedFiles as $relatedFile) {274 $queueFiles = self::getCDNURL($this->siteURL .'/'.$relatedFile);310 if (!empty($cssRelatedFiles)) { 311 foreach ($cssRelatedFiles as $relatedFile) { 312 $queueFiles = self::getCDNURL($this->siteURL . '/' . $relatedFile); 275 313 } 276 314 } … … 286 324 $directory = substr($directory, 0, -1); 287 325 } 288 289 $extensionToInclude = array('css', 'png','gif','jpg','jpeg');290 326 327 $extensionToInclude = array('css', 'png', 'gif', 'jpg', 'jpeg'); 328 291 329 if (!file_exists($directory) || !is_dir($directory)) { 292 330 return FALSE; … … 300 338 $directoryFiles = $this->scanDirectoryRecursively($path, $filter, $directoryFiles); 301 339 } elseif (is_file($path)) { 302 $extension = strtolower(end(explode('.', $path)));303 if (in_array($extension, $extensionToInclude)){304 $directoryFiles[] = str_replace(ABSPATH, '', $path) ;340 $extension = strtolower(end(explode('.', $path))); 341 if (in_array($extension, $extensionToInclude)) { 342 $directoryFiles[] = str_replace(ABSPATH, '', $path); 305 343 } 306 344 }
Note: See TracChangeset
for help on using the changeset viewer.