1
0
mirror of https://github.com/mosbth/cimage.git synced 2025-09-01 19:52:34 +02:00

* Now returns statuscode 500 when something fails #55.

* Three different modes: strict, production, development #44.
* Three files for all-in-one `imgs.php`, `imgp.php`, `imgd.php` #73.
This commit is contained in:
Mikael Roos
2015-01-29 21:16:32 +01:00
parent bc4e04c3cb
commit 16a7a3dad5
10 changed files with 7906 additions and 38 deletions

View File

@@ -19,8 +19,16 @@
*/
function errorPage($msg)
{
header("HTTP/1.0 404 Not Found");
die('img.php say 404: ' . $msg);
global $mode;
header("HTTP/1.0 500 Internal Server Error");
if ($mode == 'development') {
die("[img.php] $msg");
} else {
error_log("[img.php] $msg");
die("HTTP/1.0 500 Internal Server Error");
}
}
@@ -131,6 +139,13 @@ if (is_file($configFile)) {
/**
* verbose, v - do a verbose dump of what happens
*/
$verbose = getDefined(array('verbose', 'v'), true, false);
/**
* Set mode as strict, production or development.
* Default is production environment.
@@ -147,21 +162,32 @@ if (!extension_loaded('gd')) {
// Specific settings for each mode
if ($mode == 'strict') {
error_reporting(0);
ini_set('display_errors', 0);
ini_set('log_errors', 1);
$verbose = false;
} else if ($mode == 'production') {
error_reporting(0);
error_reporting(-1);
ini_set('display_errors', 0);
ini_set('log_errors', 1);
$verbose = false;
} else if ($mode == 'development') {
error_reporting(-1);
ini_set('display_errors', 1);
ini_set('display_errors', 1);
ini_set('log_errors', 0);
} else {
errorPage("Unknown mode: $mode");
}
verbose("mode = $mode");
verbose("error log = " . ini_get('error_log'));
/**
@@ -177,13 +203,6 @@ if ($defaultTimezone) {
/**
* verbose, v - do a verbose dump of what happens
*/
$verbose = getDefined(array('verbose', 'v'), true, false);
/**
* Check if passwords are configured, used and match.
* Options decide themself if they require passwords to be used.