From e7b51a9bf0d89fc9d9be952fb4bfb584835342d8 Mon Sep 17 00:00:00 2001 From: moodler Date: Sat, 6 Dec 2003 06:47:32 +0000 Subject: [PATCH] Add a check for GD library --- lib/compatible.php | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/lib/compatible.php b/lib/compatible.php index 057a539509..e7541ad619 100644 --- a/lib/compatible.php +++ b/lib/compatible.php @@ -42,6 +42,44 @@ function check_php_version($version="4.1.0") { 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 +} + ///////////////////////////////////////////////////////////////////////////////////// @@ -97,6 +135,14 @@ function check_php_version($version="4.1.0") { 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 ""; if ($error == 1) { -- 2.39.5