Using new ini_get_bool function to work around a bug with ini_get where

the result is different for items set in htaccess
This commit is contained in:
moodler 2003-05-17 02:05:10 +00:00
parent 785ae439eb
commit c39c66a5e8
3 changed files with 32 additions and 14 deletions

View file

@ -22,29 +22,32 @@
$documentationlink = "please read the <A HREF=\"../doc/?frame=install.html&sub=webserver\">install documentation</A>"; $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 (ini_get_bool('session.auto_start')) {
error("The PHP server variable 'session.auto_start' should be Off - $documentationlink");
} }
if (!(bool)ini_get('magic_quotes_gpc')) { if (ini_get_bool('magic_quotes_runtime')) {
error("The PHP server variable 'magic_quotes_gpc' is not turned on - $documentationlink");
}
if ((bool)ini_get('magic_quotes_runtime')) {
error("The PHP server variable 'magic_quotes_runtime' should be Off - $documentationlink"); error("The PHP server variable 'magic_quotes_runtime' should be Off - $documentationlink");
} }
if (!(bool)ini_get('file_uploads')) { if (!ini_get_bool('magic_quotes_gpc')) {
error("The PHP server variable 'file_uploads' is not turned on - $documentationlink"); error("The PHP server variable 'magic_quotes_gpc' is not turned On - $documentationlink");
} }
if ((bool)ini_get('session.auto_start')) { if (!ini_get_bool('file_uploads')) {
error("The PHP server variable 'session.auto_start' should be Off - $documentationlink"); 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 /// 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'); $sessionpath = ini_get('session.save_path');
notify("Warning: It appears your server does not support sessions (session.save_path = '$sessionpath')"); notify("Warning: It appears your server does not support sessions (session.save_path = '$sessionpath')");
} }

View file

@ -1226,6 +1226,21 @@ function check_browser_version($brand="MSIE", $version=5.5) {
return false; 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() { function can_use_richtext_editor() {
/// Is the richedit editor enabled? /// Is the richedit editor enabled?
global $USER, $CFG; global $USER, $CFG;

View file

@ -122,19 +122,19 @@
/// If you have problems with slashes everywhere then you might want to /// 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. /// 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 /// 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) { // foreach ($GLOBALS["HTTP_".$GLOBALS["REQUEST_METHOD"]."_VARS"] as $key => $value) {
// if (!is_array($value)) { // Simple value // if (!is_array($value)) { // Simple value
// $newval = stripslashes($value); // $newval = stripslashes($value);
// $GLOBALS["HTTP_".$GLOBALS["REQUEST_METHOD"]."_VARS"][$key] = $newval; // $GLOBALS["HTTP_".$GLOBALS["REQUEST_METHOD"]."_VARS"][$key] = $newval;
// if (ini_get("register_globals")) { // if (ini_get_bool("register_globals")) {
// $GLOBALS[$key] = $newval; // $GLOBALS[$key] = $newval;
// } // }
// } else { // Array // } else { // Array
// foreach ($value as $k => $v) { // foreach ($value as $k => $v) {
// $newval = stripslashes($v); // $newval = stripslashes($v);
// $GLOBALS["HTTP_".$GLOBALS["REQUEST_METHOD"]."_VARS"][$key][$k] = $newval; // $GLOBALS["HTTP_".$GLOBALS["REQUEST_METHOD"]."_VARS"][$key][$k] = $newval;
// if (ini_get("register_globals")) { // if (ini_get_bool("register_globals")) {
// $GLOBALS[$key][$k] = $newval; // $GLOBALS[$key][$k] = $newval;
// } // }
// } // }