partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 4f86ae1abe20f30e570363dfe8b1b4ec2fb0596c
parent 264bc16c333579516fc099ae6baa52e190386d3d
Author: Felicitus <felicitus@felicitus.org>
Date:   Thu,  9 Feb 2012 01:08:26 +0100

Fixed the timezone check function, refactored the tests to be more readable.

Diffstat:
Msrc/setup/tests/check-php-settings.php | 47+++++++++++++++++++++++++++++++++++++++--------
1 file changed, 39 insertions(+), 8 deletions(-)

diff --git a/src/setup/tests/check-php-settings.php b/src/setup/tests/check-php-settings.php @@ -1,29 +1,60 @@ <?php +/* + * Check if safe_mode is active. If yes, bail out, as safe_mode is unsupported, deprecated with PHP 5.3.0 and will + * most likely be obsoleted with PHP 5.4.0. + */ if (ini_get("safe_mode")) { - echo json_encode(array("error" => true, "errormessage" => "PHP safe_mode is active. This feature is deprecated as of PHP 5.3.0 and causes problems of any kind. Please disable it by setting safe_mode=off in your php.ini file.")); + $errorMessage = "PHP safe_mode is active. This feature is deprecated as of PHP 5.3.0 and causes problems of any "; + $errorMessage .= "kind. Please disable it by setting safe_mode=off in your php.ini file (don't forget to restart "; + $errorMessage .= "your web server afterwards)"; + + echo json_encode(array("error" => true, "errormessage" => $errorMessage)); exit; } +/* + * Check if allow_url_fopen is enabled. This is required for downloading files due to lazyness (another solution, + * like cURL, needs to be implemented). + */ if (ini_get("allow_url_fopen") == false) { - echo json_encode(array("error" => true, "errormessage" => "PHP allow_url_fopen is set to off. Right now, we require that it is set to ON. Please set<br/><code>allow_url_fopen = On</code> in your php.ini file.")); + $errorMessage = "PHP allow_url_fopen is set to off. Right now, we require that it is set to ON. "; + $errorMessage .= "Please set<br/><code>allow_url_fopen = On</code> in your php.ini file. "; + $errorMessage .= "Don't forget to restart your web server afterwards."; + + echo json_encode(array("error" => true, "errormessage" => $errorMessage)); exit; } +/* + * Check for the cURL extension. + */ if (!function_exists("curl_init")) { - echo json_encode(array("error" => true, "errormessage" => "You are missing the curl-library for PHP. Please install and activate it.")); + $errorMessage = "You are missing the curl-library for PHP. Please install and activate it."; + echo json_encode(array("error" => true, "errormessage" => $errorMessage)); exit; } -if (!class_exists("\\finfo")) { - echo json_encode(array("error" => true, "errormessage" => "You are missing the fileinfo-library for PHP. Please install and activate it.")); +/* + * Check for the fileinfo extension. + */ +if (!class_exists("\\finfo")) { + $errorMessage = "You are missing the fileinfo-library for PHP. Please install and activate it."; + echo json_encode(array("error" => true, "errormessage" => $errorMessage)); exit; } -if (!class_exists("\\Imagick")) { - echo json_encode(array("error" => true, "errormessage" => "You are missing the Imagick library for PHP. Please install and activate it.")); +/* + * Check for the imagemagick extension. + */ +if (!class_exists("\\Imagick")) { + $errorMessage = "You are missing the Imagick library for PHP. Please install and activate it."; + echo json_encode(array("error" => true, "errormessage" => $errorMessage)); exit; } +/* + * Check if the timezone settings are valid. + */ if (!isTimezoneSetAndValid()) { $errorMessage = "The PHP timezone (%s) is not set or invalid. Please set the correct timezone in your"; $errorMessage .= " php.ini file (don't forget to restart the web server afterwards)"; @@ -41,6 +72,6 @@ exit; * @param none * @return bool True if the timezone is set and valid, false otherwise. */ -public function isTimezoneSetAndValid () { +function isTimezoneSetAndValid () { return @date_default_timezone_set(@date_default_timezone_get()); } \ No newline at end of file