Friday, March 03, 2006

Bug with definition of GD. Attempt #2

I have decided to go by the simple way, but 100% correct. If function createimagetruecolor() exists it is determined as GD2 if is not - present GD. Actually, likely, only I still have GD, therefore I had problems with it.
In a file /usr/system/image_resize.inc.php instead of it (contents standard file /usr/system/image_resize.inc.php from Sapid 1.2.3.06):
function _sysB_chkgd2()
{
$rep=false;
if(isset($GLOBALS["gBGDVersion"])) {
$rep=$GLOBALS["gBGDVersion"];
} else {
if(function_exists("gd_info")) {
$gdver=gd_info();
$GLOBALS["gBGDVersion"]=$rep=preg_replace("/^(.*)(\d+?\.?\d+?\.?)(.*)$/", "\\2", $gdver["GD Version"]);
} else {
$arr=get_loaded_extensions();
if(in_array("gd", $arr) and $im=@imagecreatetruecolor(1,1)) {
imagedestroy($im);
$GLOBALS["gBGDVersion"]=$rep="2.0";
}elseif (in_array("gd", $arr) and $im=@imagecreate(1,1)){
imagedestroy($im);
$GLOBALS["gBGDVersion"]=$rep="1.6";
}
}
}
return $GLOBALS["gBGDVersion"];
}
Input next:
function _sysB_chkgd2()
{
$rep=false;
if(isset($GLOBALS["gBGDVersion"])) {
$rep=$GLOBALS["gBGDVersion"];
} else {
$arr=get_loaded_extensions();
if(in_array("gd", $arr) and function_exists(imagecreatetruecolor)) {
$GLOBALS["gBGDVersion"]=$rep="2.0";
}elseif (in_array("gd", $arr) and !function_exists(imagecreatetruecolor)){
$GLOBALS["gBGDVersion"]=$rep="1.6";
}
}
return $GLOBALS["gBGDVersion"];
}
It's all.

0 Comments:

Post a Comment

<< Home