5 <title
>Moodle Environment Test
</title
>
11 function print_row($name, $value, $badcomment='') {
13 echo "<th align=\"right\">$name</th>";
14 echo "<td align=\"left\">$value</td>";
16 echo "<td align=\"left\"><font color=red>$badcomment</font></td>";
18 echo "<td align=\"left\"><font color=green>Looks good</font></td>";
23 function ini_get_bool($ini_get_arg) {
24 /// This function makes the return value of ini_get consistent if you are
25 /// setting server directives through the .htaccess file in apache.
26 /// Current behavior for value set from php.ini On = 1, Off = [blank]
27 /// Current behavior for value set from .htaccess On = On, Off = Off
28 /// Contributed by jdell@unr.edu
30 $temp = ini_get($ini_get_arg);
32 if ($temp == "1" or strtolower($temp) == "on") {
38 function check_php_version($version="4.1.0") {
39 /// Returns true is the current version of PHP is greater that the specified one
40 $minversion = intval(str_replace(".", "", $version));
41 $curversion = intval(str_replace(".", "", phpversion()));
42 return ($curversion >= $minversion);
45 function check_gd_version() {
46 /// Hack to find out the GD version by parsing phpinfo output
49 if (function_exists('gd_info')){
51 if (substr_count($gd_info['GD Version'], "2.")) {
53 } else if (substr_count($gd_info['GD Version'], "1.")) {
60 $phpinfo = ob_get_contents();
63 $phpinfo = explode("\n",$phpinfo);
66 foreach ($phpinfo as $text) {
67 $parts = explode('</td>',$text);
68 foreach ($parts as $key => $val) {
69 $parts[$key] = trim(strip_tags($val));
71 if ($parts[0] == "GD Version") {
72 if (substr_count($parts[1], "2.0")) {
75 $gdversion = intval($parts[1]);
80 return $gdversion; // 1, 2 or 0
85 /////////////////////////////////////////////////////////////////////////////////////
89 echo "<h2 align=\"center\">Moodle compatibility tester</h2>";
91 echo "<table align=\"center\" border=1>";
93 /// Check that PHP is of a sufficient version
95 if (!check_php_version("4.1.0")) {
96 print_row("PHP Version", "Old", "Moodle requires PHP 4.1.0 or later");
98 print_row("PHP Version", "OK");
101 /// Check some PHP server settings
103 if (ini_get_bool('safe_mode')) {
104 print_row("safe_mode", "On", "Moodle can not handle files properly with safe mode on");
107 print_row("safe_mode", "Off");
110 if (ini_get_bool('session.auto_start')) {
111 print_row("session.auto_start", "On", "This should be Off");
114 print_row("session.auto_start", "Off");
117 if (ini_get_bool('magic_quotes_runtime')) {
118 print_row("magic_quotes_runtime", "On", "This should be Off");
121 print_row("magic_quotes_runtime", "Off");
124 if (!ini_get_bool('file_uploads')) {
125 print_row("file_uploads", "Off", "This should be On");
128 print_row("file_uploads", "On");
131 if (!is_readable(ini_get('session.save_path'))) {
132 print_row("session.save_path", "Broken", "It seems your server does not support sessions");
135 print_row("session.save_path", "Works");
138 if (!$gdversion = check_gd_version()) {
139 print_row("GD Library", "No", "The GD library should be present to process and create images");
142 print_row("GD Library", $gdversion);
149 echo "<h2 align=\"center\"><font color=red>$error error was found. See <a href=\"http://moodle.org/doc\">http://moodle.org/doc</a></font></h2>";
151 echo "<h2 align=\"center\"><font color=red>$error errors were found. See <a href=\"http://moodle.org/doc\">http://moodle.org/doc</a></font></h2>";
153 echo "<h2 align=\"center\"><font color=green>Server looks good - clear to install!</font></a></h2>";