]> git.mjollnir.org Git - moodle.git/commitdiff
Using new ini_get_bool function to work around a bug with ini_get where
authormoodler <moodler>
Sat, 17 May 2003 02:05:10 +0000 (02:05 +0000)
committermoodler <moodler>
Sat, 17 May 2003 02:05:10 +0000 (02:05 +0000)
the result is different for items set in htaccess

admin/index.php
lib/moodlelib.php
lib/setup.php

index d5d79b3ee35fdfab33c1935a2c881806b8db48cc..2a702d10db08a6c875be283409c11a69950e3986 100644 (file)
 
     $documentationlink = "please read the <A HREF=\"../doc/?frame=install.html&sub=webserver\">install documentation</A>";
 
-    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')");
     }
index 42ed7df0d078d2d2f1466e0d22d1a502dd6f0280..d31a8357f64058bf6cd00d9e190ec63a335c93d0 100644 (file)
@@ -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;
index 011bbde045b811e888cf6fbd7bc190e696d93a06..7063a576a47c1356dd6cff20332b91fc4a10588b 100644 (file)
 /// 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;
 //                    }
 //                }