Permalink
Browse files

Convert extension retrieval to pathinfo().

  • Loading branch information...
1 parent 18a7bb0 commit e4d97d6e874b13f6ef6bcb3f1116702dcb5cdd82 @sofar committed Oct 8, 2012
Showing with 6 additions and 5 deletions.
  1. +6 −5 image.php
View
@@ -76,8 +76,8 @@ function imagerotate($src_img, $angle) {
}
function pass_file_and_exit($file) {
- preg_match("'^(.*)\.(gif|jpe?g|png|thm|ogv|mp4)$'i", $file, $e);
- switch (strtolower($e[2])) {
+ $i = pathinfo($file);
+ switch (strtolower($i['extension'])) {
case 'jpg':
case 'jpeg':
case 'thm':
@@ -134,7 +134,8 @@ function pass_file_and_exit($file) {
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($obj)).' GMT', true, 200);
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + (80640 * 180)) . ' GMT', true, 200);
-preg_match("'^(.*)\.(gif|jpe?g|png|thm)$'i", $image, $ext);
+$i = pathinfo($image);
+$ext = strtolower($i['extension']);
# fetch the (already rotated) cached file if present
if (file_exists($cache_file))
@@ -151,7 +152,7 @@ function pass_file_and_exit($file) {
}
}
-switch (strtolower($ext[2])) {
+switch ($ext) {
case 'jpg':
case 'jpeg':
case 'thm':
@@ -204,7 +205,7 @@ function pass_file_and_exit($file) {
break;
}
-switch (strtolower($ext[2])) {
+switch ($ext) {
case 'thm' :
imagejpeg($save);
break;

0 comments on commit e4d97d6

Please sign in to comment.