mirror of
https://github.com/moodle/moodle.git
synced 2025-07-12 18:06:41 +02:00
Add a check for GD library
This commit is contained in:
@ -42,6 +42,44 @@ function check_php_version($version="4.1.0") {
|
|||||||
return ($curversion >= $minversion);
|
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('</td>',$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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -97,6 +135,14 @@ function check_php_version($version="4.1.0") {
|
|||||||
print_row("session.save_path", "Works");
|
print_row("session.save_path", "Works");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$gdversion = check_gd_version()) {
|
||||||
|
print_row("GD Library", "No", "The GD library should be present");
|
||||||
|
$error++;
|
||||||
|
} else {
|
||||||
|
print_row("GD Library", $gdversion);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
echo "</table>";
|
echo "</table>";
|
||||||
|
|
||||||
if ($error == 1) {
|
if ($error == 1) {
|
||||||
|
Reference in New Issue
Block a user