Skip to content

Commit

Permalink
simplified the check for GD routines
Browse files Browse the repository at this point in the history
git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@2855 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
thraxisp committed Aug 16, 2004
1 parent 65230dd commit 099f72e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 34 deletions.
23 changes: 11 additions & 12 deletions core/utility_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: utility_api.php,v 1.14 2004-08-14 15:26:21 thraxisp Exp $
# $Id: utility_api.php,v 1.15 2004-08-16 02:14:55 thraxisp Exp $
# --------------------------------------------------------

### Utility API ###
Expand Down Expand Up @@ -169,16 +169,15 @@ function copy_array_item_if_exist( &$p_arr_src, &$p_arr_dst, $key ) {
# It doesn't use gd_info() so it works with PHP < 4.3.0 as well
function get_gd_version()
{
ob_start();
phpinfo(8);
$module_info = ob_get_contents();
ob_end_clean();
if( preg_match( "/\bgd\s+version\b[^\d\n\r]+?([\d\.]+)/i", $module_info, $matches ) ) {
$gd_version_number = $matches[1];
}
else {
$gd_version_number = 0;
}
return $gd_version_number;
$t_GDfuncList = get_extension_funcs('gd');
if( ! is_array( $t_GDfuncList ) ) {
return 0;
} else {
if( in_array('imagegd2',$t_GDfuncList) ) {
return 2;
} else {
return 1;
}
}
}
?>
24 changes: 2 additions & 22 deletions make_captcha_img.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: make_captcha_img.php,v 1.2 2004-08-14 17:45:29 thraxisp Exp $
# $Id: make_captcha_img.php,v 1.3 2004-08-16 02:14:55 thraxisp Exp $
# --------------------------------------------------------

# --------------------------------------------------------
Expand Down Expand Up @@ -59,7 +59,7 @@ class masc_captcha
function masc_captcha( $config )
{
// Test for GD-Library(-Version)
$this->gd_version = $this->get_gd_version();
$this->gd_version = get_gd_version();
if($this->gd_version == 0) die("There is no GD-Library-Support enabled. The Captcha-Class cannot be used!");
if($this->debug) echo "\n<br>-Captcha-Debug: The available GD-Library has major version ".$this->gd_version;

Expand Down Expand Up @@ -250,26 +250,6 @@ function change_TTF()
return $this->TTF_file;
}

function get_gd_version()
{
static $gd_version_number = null;
if($gd_version_number === null)
{
ob_start();
phpinfo(8);
$module_info = ob_get_contents();
ob_end_clean();
if(preg_match("/\bgd\s+version\b[^\d\n\r]+?([\d\.]+)/i", $module_info, $matches))
{
$gd_version_number = $matches[1];
}
else
{
$gd_version_number = 0;
}
}
return $gd_version_number;
}
} // END CLASS masc_captcha

?>

0 comments on commit 099f72e

Please sign in to comment.