1
0
mirror of https://github.com/mosbth/cimage.git synced 2025-01-17 19:18:15 +01:00

even more testing

This commit is contained in:
Mikael Roos 2016-08-08 11:19:53 +02:00
parent 493ed45311
commit 689865a8b2
10 changed files with 56 additions and 29 deletions

View File

@ -11,11 +11,11 @@ v0.7.13 (2016-08-08)
* Moved functions from img.php to `functions.php`. * Moved functions from img.php to `functions.php`.
* Added function `trace()` to measure speed and memory consumption, only for development. * Added function `trace()` to measure speed and memory consumption, only for development.
* Added fast cache #149. * Added fast cache #149.
* Added `imgf.php` as shortcut to check for fast cache, before loading `img.php` as usual. * Added `imgf.php` as shortcut to check for fast cache, before loading `img.php` as usual, adding `imgf_config.php` as symlink to `img_config.php`.
* Created `defines.php` and moved definition av version there. * Created `defines.php` and moved definition av version there.
* Fixed images in README, #148. * Fixed images in README, #148.
* Initiated dependency injection to `CImage`, class names can be set in config file and will be injected to `CImage` from `img.php`. Not implemented for all classes. #151. * Initiated dependency injection to `CImage`, class names can be set in config file and will be injected to `CImage` from `img.php`. Not implemented for all classes. #151.
* Enabled debug mode to make it easeier to trace what actually happens while processing the image, #150. * Enabled debug mode to make it easier to trace what actually happens while processing the image, #150.
v0.7.12 (2016-06-01) v0.7.12 (2016-06-01)

View File

@ -4,9 +4,3 @@ define("CIMAGE_VERSION", "v0.7.13 (2016-08-08)");
// For CRemoteImage // For CRemoteImage
define("CIMAGE_USER_AGENT", "CImage/" . CIMAGE_VERSION); define("CIMAGE_USER_AGENT", "CImage/" . CIMAGE_VERSION);
// Change to true to enable debug mode which logs additional information
// to file. Only use for test and development.
define("CIMAGE_DEBUG", true);
define("CIMAGE_DEBUG_FILE", "/tmp/cimage");
//define("CIMAGE_DEBUG", false);

View File

@ -19,7 +19,8 @@ function trace($msg)
return; return;
} }
$details = ":" . (string) round((microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"]), 6) . "ms"; $timer = number_format((microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"]), 6);
$details = "{$timer}ms";
$details .= ":" . round(memory_get_peak_usage()/1024/1024, 3) . "MB"; $details .= ":" . round(memory_get_peak_usage()/1024/1024, 3) . "MB";
$details .= ":" . count(get_included_files()); $details .= ":" . count(get_included_files());
file_put_contents($file, "$details:$msg\n", FILE_APPEND); file_put_contents($file, "$details:$msg\n", FILE_APPEND);

View File

@ -20,6 +20,11 @@ if (is_file($configFile)) {
$config = array(); $config = array();
} }
// Make CIMAGE_DEBUG false by default, if not already defined
if (!defined("CIMAGE_DEBUG")) {
define("CIMAGE_DEBUG", false);
}
/** /**

View File

@ -5,6 +5,24 @@
* config-file imgtest_config.php. * config-file imgtest_config.php.
* *
*/ */
/**
* Change to true to enable debug mode which logs additional information
* to file. Only use for test and development. You must create the logfile
* and make it writable by the webserver or log entries will silently fail.
*
* CIMAGE_DEBUG will be false by default, if its not defined.
*/
if (!defined("CIMAGE_DEBUG")) {
//define("CIMAGE_DEBUG", false);
define("CIMAGE_DEBUG", true);
define("CIMAGE_DEBUG_FILE", "/tmp/cimage");
}
return array( return array(
/** /**
@ -61,7 +79,7 @@ return array(
* Default values: * Default values:
* fast_track_allow: false * fast_track_allow: false
*/ */
//'fast_track_allow' => true, 'fast_track_allow' => true,

View File

@ -43,12 +43,6 @@ define("CIMAGE_VERSION", "v0.7.13 (2016-08-08)");
// For CRemoteImage // For CRemoteImage
define("CIMAGE_USER_AGENT", "CImage/" . CIMAGE_VERSION); define("CIMAGE_USER_AGENT", "CImage/" . CIMAGE_VERSION);
// Change to true to enable debug mode which logs additional information
// to file. Only use for test and development.
define("CIMAGE_DEBUG", true);
define("CIMAGE_DEBUG_FILE", "/tmp/cimage");
//define("CIMAGE_DEBUG", false);
/** /**
@ -68,10 +62,11 @@ function trace($msg)
{ {
$file = CIMAGE_DEBUG_FILE; $file = CIMAGE_DEBUG_FILE;
if (!is_writable($file)) { if (!is_writable($file)) {
die("Using trace without a writable logfile. Create the file '$file' and make it writable for the web server."); return;
} }
$details = ":" . (string) round((microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"]), 6) . "ms"; $timer = number_format((microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"]), 6);
$details = "{$timer}ms";
$details .= ":" . round(memory_get_peak_usage()/1024/1024, 3) . "MB"; $details .= ":" . round(memory_get_peak_usage()/1024/1024, 3) . "MB";
$details .= ":" . count(get_included_files()); $details .= ":" . count(get_included_files());
file_put_contents($file, "$details:$msg\n", FILE_APPEND); file_put_contents($file, "$details:$msg\n", FILE_APPEND);
@ -4316,6 +4311,11 @@ if (is_file($configFile)) {
$config = array(); $config = array();
} }
// Make CIMAGE_DEBUG false by default, if not already defined
if (!defined("CIMAGE_DEBUG")) {
define("CIMAGE_DEBUG", false);
}
/** /**

View File

@ -13,12 +13,17 @@ if (is_file($configFile) && is_readable($configFile)) {
$config = require $configFile; $config = require $configFile;
} elseif (!isset($config)) { } elseif (!isset($config)) {
$config = array( $config = array(
"debug" => false, "fast_track_allow" => true,
"autoloader" => __DIR__ . "/../autoload.php", "autoloader" => __DIR__ . "/../autoload.php",
"cache_path" => __DIR__ . "/../cache/", "cache_path" => __DIR__ . "/../cache/",
); );
} }
// Make CIMAGE_DEBUG false by default, if not already defined
if (!defined("CIMAGE_DEBUG")) {
define("CIMAGE_DEBUG", false);
}
// Debug mode needs additional functions // Debug mode needs additional functions
if (CIMAGE_DEBUG) { if (CIMAGE_DEBUG) {
require $config["autoloader"]; require $config["autoloader"];
@ -37,6 +42,9 @@ $query = $_GET;
// Do not use cache when no-cache is active // Do not use cache when no-cache is active
$useCache = !(array_key_exists("no-cache", $query) || array_key_exists("nc", $query)); $useCache = !(array_key_exists("no-cache", $query) || array_key_exists("nc", $query));
// Only use cache if enabled by configuration
$useCache = $useCache && isset($config["fast_track_allow"]) && $config["fast_track_allow"] === true;
// Remove parts from querystring that should not be part of filename // Remove parts from querystring that should not be part of filename
$clear = array("nc", "no-cache"); $clear = array("nc", "no-cache");
foreach ($clear as $value) { foreach ($clear as $value) {

1
webroot/imgf_config.php Symbolic link
View File

@ -0,0 +1 @@
img_config.php

View File

@ -43,12 +43,6 @@ define("CIMAGE_VERSION", "v0.7.13 (2016-08-08)");
// For CRemoteImage // For CRemoteImage
define("CIMAGE_USER_AGENT", "CImage/" . CIMAGE_VERSION); define("CIMAGE_USER_AGENT", "CImage/" . CIMAGE_VERSION);
// Change to true to enable debug mode which logs additional information
// to file. Only use for test and development.
define("CIMAGE_DEBUG", true);
define("CIMAGE_DEBUG_FILE", "/tmp/cimage");
//define("CIMAGE_DEBUG", false);
/** /**
@ -68,10 +62,11 @@ function trace($msg)
{ {
$file = CIMAGE_DEBUG_FILE; $file = CIMAGE_DEBUG_FILE;
if (!is_writable($file)) { if (!is_writable($file)) {
die("Using trace without a writable logfile. Create the file '$file' and make it writable for the web server."); return;
} }
$details = ":" . (string) round((microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"]), 6) . "ms"; $timer = number_format((microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"]), 6);
$details = "{$timer}ms";
$details .= ":" . round(memory_get_peak_usage()/1024/1024, 3) . "MB"; $details .= ":" . round(memory_get_peak_usage()/1024/1024, 3) . "MB";
$details .= ":" . count(get_included_files()); $details .= ":" . count(get_included_files());
file_put_contents($file, "$details:$msg\n", FILE_APPEND); file_put_contents($file, "$details:$msg\n", FILE_APPEND);
@ -4316,6 +4311,11 @@ if (is_file($configFile)) {
$config = array(); $config = array();
} }
// Make CIMAGE_DEBUG false by default, if not already defined
if (!defined("CIMAGE_DEBUG")) {
define("CIMAGE_DEBUG", false);
}
/** /**

File diff suppressed because one or more lines are too long