"; echo "$name"; echo "$value"; if ($badcomment) { echo "$badcomment"; } else { echo "Looks good"; } echo ""; } 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 check_php_version($version="4.1.0") { /// Returns true is the current version of PHP is greater that the specified one $minversion = intval(str_replace(".", "", $version)); $curversion = intval(str_replace(".", "", phpversion())); return ($curversion >= $minversion); } function check_gd_version() { /// Hack to find out the GD version by parsing phpinfo output $gdversion = 0; if (function_exists('gd_info')){ $gd_info = gd_info(); if (substr_count($gd_info['GD Version'], "2.")) { $gdversion = 2; } else if (substr_count($gd_info['GD Version'], "1.")) { $gdversion = 1; } } else { ob_start(); phpinfo(8); $phpinfo = ob_get_contents(); ob_end_clean(); $phpinfo = explode("\n",$phpinfo); foreach ($phpinfo as $text) { $parts = explode('',$text); foreach ($parts as $key => $val) { $parts[$key] = trim(strip_tags($val)); } if ($parts[0] == "GD Version") { if (substr_count($parts[1], "2.0")) { $parts[1] = "2.0"; } $gdversion = intval($parts[1]); } } } return $gdversion; // 1, 2 or 0 } ///////////////////////////////////////////////////////////////////////////////////// $error = 0; echo "

Moodle compatibility tester

"; echo ""; /// Check that PHP is of a sufficient version if (!check_php_version("4.1.0")) { print_row("PHP Version", "Old", "Moodle requires PHP 4.1.0 or later"); } else { print_row("PHP Version", "OK"); } /// Check some PHP server settings if (ini_get_bool('safe_mode')) { print_row("safe_mode", "On", "Moodle can not handle files properly with safe mode on"); $error++; } else { print_row("safe_mode", "Off"); } if (ini_get_bool('session.auto_start')) { print_row("session.auto_start", "On", "This should be Off"); $error++; } else { print_row("session.auto_start", "Off"); } if (ini_get_bool('magic_quotes_runtime')) { print_row("magic_quotes_runtime", "On", "This should be Off"); $error++; } else { print_row("magic_quotes_runtime", "Off"); } if (!ini_get_bool('file_uploads')) { print_row("file_uploads", "Off", "This should be On"); $error++; } else { print_row("file_uploads", "On"); } if (!is_readable(ini_get('session.save_path'))) { print_row("session.save_path", "Broken", "It seems your server does not support sessions"); $error++; } else { print_row("session.save_path", "Works"); } if (!$gdversion = check_gd_version()) { print_row("GD Library", "No", "The GD library should be present to process and create images"); $error++; } else { print_row("GD Library", $gdversion); } echo "
"; if ($error == 1) { echo "

$error error was found. See http://moodle.org/doc

"; } else if ($error) { echo "

$error errors were found. See http://moodle.org/doc

"; } else { echo "

Server looks good - clear to install!

"; } ?>