From cf2fc3de4ff66f1ac2a06d13e35c2003568037cf Mon Sep 17 00:00:00 2001 From: Mikael Roos Date: Fri, 11 Dec 2015 10:07:16 +0100 Subject: [PATCH] intermediate --- REVISION.md | 6 ++++++ src/CImage/CImage.php | 6 ++++-- test/config.php | 9 +++++++-- webroot/img.php | 12 +++++++----- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/REVISION.md b/REVISION.md index 25263e8..28f773e 100644 --- a/REVISION.md +++ b/REVISION.md @@ -12,6 +12,12 @@ v0.8.* (2015-12-05) (branch resize) * Require PHP 5.4. +v0.7.9* (2015-12-07) +------------------------------------- + +* Fix strict mode only reporting 404 when failure, #127. + + v0.7.9 (2015-12-07) ------------------------------------- diff --git a/src/CImage/CImage.php b/src/CImage/CImage.php index 887c498..bb30868 100644 --- a/src/CImage/CImage.php +++ b/src/CImage/CImage.php @@ -2542,8 +2542,10 @@ class CImage $this->log("Output format is: $format"); if (!$this->verbose && $format == 'json') { - header('Content-type: application/json'); - echo $this->json($file); + #header('Content-type: application/json'); + #echo $this->json($file); + return serialize(["hello", 1]); + #return; exit; } elseif ($format == 'ascii') { header('Content-type: text/plain'); diff --git a/test/config.php b/test/config.php index 4933b03..09ceee9 100644 --- a/test/config.php +++ b/test/config.php @@ -5,5 +5,10 @@ */ require __DIR__ . "/../autoload.php"; -define('IMAGE_PATH', __DIR__ . '/../webroot/img/'); -define('CACHE_PATH', __DIR__ . '/../cache/'); +if (!defined("IMAGE_PATH")) { + define("IMAGE_PATH", __DIR__ . "/../webroot/img/"); +} + +if (!defined("CACHE_PATH")) { + define("CACHE_PATH", __DIR__ . "/../cache/"); +} diff --git a/webroot/img.php b/webroot/img.php index c3586ce..fb9d81e 100644 --- a/webroot/img.php +++ b/webroot/img.php @@ -38,16 +38,16 @@ function errorPage($msg, $type = 500) $header = "500 Internal Server Error"; } + if ($mode == "strict") { + $header = "404 Not Found"; + } + header("HTTP/1.0 $header"); if ($mode == "development") { die("[img.php] $msg"); } - if ($mode == "strict") { - $header = "404 Not Found"; - } - error_log("[img.php] $msg"); die("HTTP/1.0 $header"); } @@ -1177,7 +1177,7 @@ EOD; /** * Load, process and output the image */ -$img->log("Incoming arguments: " . print_r(verbose(), 1)) +$res = $img->log("Incoming arguments: " . print_r(verbose(), 1)) ->setSaveFolder($cachePath) ->useCache($useCache) ->setSource($srcImage, $imagePath) @@ -1233,3 +1233,5 @@ $img->log("Incoming arguments: " . print_r(verbose(), 1)) ->save() ->linkToCacheFile($aliasTarget) ->output(); + +return $res;