From: moodler Date: Sat, 17 May 2003 02:05:10 +0000 (+0000) Subject: Using new ini_get_bool function to work around a bug with ini_get where X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=c39c66a5e871014820c7c58acb8b0636d84c23ac;p=moodle.git Using new ini_get_bool function to work around a bug with ini_get where the result is different for items set in htaccess --- diff --git a/admin/index.php b/admin/index.php index d5d79b3ee3..2a702d10db 100644 --- a/admin/index.php +++ b/admin/index.php @@ -22,29 +22,32 @@ $documentationlink = "please read the install documentation"; - if (!(bool)ini_get('short_open_tag')) { - error("The PHP server variable 'short_open_tag' is not turned on - $documentationlink"); - } - if (!(bool)ini_get('magic_quotes_gpc')) { - error("The PHP server variable 'magic_quotes_gpc' is not turned on - $documentationlink"); + if (ini_get_bool('session.auto_start')) { + error("The PHP server variable 'session.auto_start' should be Off - $documentationlink"); } - if ((bool)ini_get('magic_quotes_runtime')) { + + if (ini_get_bool('magic_quotes_runtime')) { error("The PHP server variable 'magic_quotes_runtime' should be Off - $documentationlink"); } - if (!(bool)ini_get('file_uploads')) { - error("The PHP server variable 'file_uploads' is not turned on - $documentationlink"); + if (!ini_get_bool('magic_quotes_gpc')) { + error("The PHP server variable 'magic_quotes_gpc' is not turned On - $documentationlink"); } - if ((bool)ini_get('session.auto_start')) { - error("The PHP server variable 'session.auto_start' should be Off - $documentationlink"); + if (!ini_get_bool('file_uploads')) { + error("The PHP server variable 'file_uploads' is not turned On - $documentationlink"); } + if (!ini_get_bool('short_open_tag')) { + error("The PHP server variable 'short_open_tag' is not turned On - $documentationlink"); + } + + /// Check that sessions are supported - if (!is_readable(ini_get('session.save_path')) and !(bool)ini_get('safe_mode')) { + if (!is_readable(ini_get('session.save_path')) and !ini_get_bool('safe_mode')) { $sessionpath = ini_get('session.save_path'); notify("Warning: It appears your server does not support sessions (session.save_path = '$sessionpath')"); } diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 42ed7df0d0..d31a8357f6 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -1226,6 +1226,21 @@ function check_browser_version($brand="MSIE", $version=5.5) { return false; } +function ini_get_bool($ini_get_arg) { +/// This function makes the return value of ini_get consistent if you are +/// setting server directives through the .htaccess file in apache. +/// Current behavior for value set from php.ini On = 1, Off = [blank] +/// Current behavior for value set from .htaccess On = On, Off = Off +/// Contributed by jdell@unr.edu + + $temp = ini_get($ini_get_arg); + + if ($temp == "1" or strtolower($temp) == "on") { + return true; + } + return false; +} + function can_use_richtext_editor() { /// Is the richedit editor enabled? global $USER, $CFG; diff --git a/lib/setup.php b/lib/setup.php index 011bbde045..7063a576a4 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -122,19 +122,19 @@ /// If you have problems with slashes everywhere then you might want to /// uncomment this code. It will not be necessary on 99.9% of PHP servers. /// Got this from http://www.php.net/manual/en/configuration.php -// if (ini_get("magic_quotes_gpc") ) { +// if (ini_get_bool("magic_quotes_gpc") ) { // foreach ($GLOBALS["HTTP_".$GLOBALS["REQUEST_METHOD"]."_VARS"] as $key => $value) { // if (!is_array($value)) { // Simple value // $newval = stripslashes($value); // $GLOBALS["HTTP_".$GLOBALS["REQUEST_METHOD"]."_VARS"][$key] = $newval; -// if (ini_get("register_globals")) { +// if (ini_get_bool("register_globals")) { // $GLOBALS[$key] = $newval; // } // } else { // Array // foreach ($value as $k => $v) { // $newval = stripslashes($v); // $GLOBALS["HTTP_".$GLOBALS["REQUEST_METHOD"]."_VARS"][$key][$k] = $newval; -// if (ini_get("register_globals")) { +// if (ini_get_bool("register_globals")) { // $GLOBALS[$key][$k] = $newval; // } // }