MyBB Community Forums

Full Version: Very diffucult to read the code in captcha in my forum after 1.4.3 update
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
<?php
$img_width=200;
$img_height=100;
if(gd_version() >= 2)
{
        $im = imagecreatetruecolor($img_width, $img_height);
}
else
{
        $im = imagecreate($img_width, $img_height);
}

$bg_color = imagecolorallocate($im, 255, 255, 255);
imagefill($im, 0, 0, $bg_color);

// Output the image
header("Content-type: image/png");
imagepng($im);
imagedestroy($im);
exit;

function gd_version()
{
        static $gd_version;

        if($gd_version)
        {
                return $gd_version;
        }
        if(!extension_loaded('gd'))
        {
                return;
        }

        if(function_exists("gd_info"))
        {
                $gd_info = gd_info();
                preg_match('/\d/', $gd_info['GD Version'], $gd);
                $gd_version = $gd[0];
        }
        else
        {
                ob_start();
                phpinfo(8);
                $info = ob_get_contents();
                ob_end_clean();
                $info = stristr($info, 'gd version');
                preg_match('/\d/', $info, $gd);
                $gd_version = $gd[0];
        }

        return $gd_version;
} 
(2008-10-31, 04:33 PM)Ryan Gordon Wrote: [ -> ]I'm getting a 404 to the url
Go now to the url
Yeah it still gives a 404

http://galileo2007.netsons.org/forum/try.php = 404
(2008-10-31, 07:08 PM)Matt_ Wrote: [ -> ]Yeah it still gives a 404

http://galileo2007.netsons.org/forum/try.php = 404
Excuse me!, I handstood http://galileo2007.netsons.org/forum
Now I reuploaded try.php. Let go to the url.
Try my latest code. Sorry I am not at home so I don't have a server to test the code on.

(2008-10-31, 05:38 PM)DennisTT Wrote: [ -> ]
<?php
$img_width=200;
$img_height=100;
if(gd_version() >= 2)
{
        $im = imagecreatetruecolor($img_width, $img_height);
}
else
{
        $im = imagecreate($img_width, $img_height);
}

$bg_color = imagecolorallocate($im, 255, 255, 255);
imagefill($im, 0, 0, $bg_color);

// Output the image
header("Content-type: image/png");
imagepng($im);
imagedestroy($im);
exit;

function gd_version()
{
        static $gd_version;

        if($gd_version)
        {
                return $gd_version;
        }
        if(!extension_loaded('gd'))
        {
                return;
        }

        if(function_exists("gd_info"))
        {
                $gd_info = gd_info();
                preg_match('/\d/', $gd_info['GD Version'], $gd);
                $gd_version = $gd[0];
        }
        else
        {
                ob_start();
                phpinfo(8);
                $info = ob_get_contents();
                ob_end_clean();
                $info = stristr($info, 'gd version');
                preg_match('/\d/', $info, $gd);
                $gd_version = $gd[0];
        }

        return $gd_version;
} 
(2008-10-31, 09:34 PM)DennisTT Wrote: [ -> ]Try my latest code. Sorry I am not at home so I don't have a server to test the code on.

(2008-10-31, 05:38 PM)DennisTT Wrote: [ -> ]
<?php
$img_width=200;
$img_height=100;
if(gd_version() >= 2)
{
        $im = imagecreatetruecolor($img_width, $img_height);
}
else
{
        $im = imagecreate($img_width, $img_height);
}

$bg_color = imagecolorallocate($im, 255, 255, 255);
imagefill($im, 0, 0, $bg_color);

// Output the image
header("Content-type: image/png");
imagepng($im);
imagedestroy($im);
exit;

function gd_version()
{
        static $gd_version;

        if($gd_version)
        {
                return $gd_version;
        }
        if(!extension_loaded('gd'))
        {
                return;
        }

        if(function_exists("gd_info"))
        {
                $gd_info = gd_info();
                preg_match('/\d/', $gd_info['GD Version'], $gd);
                $gd_version = $gd[0];
        }
        else
        {
                ob_start();
                phpinfo(8);
                $info = ob_get_contents();
                ob_end_clean();
                $info = stristr($info, 'gd version');
                preg_match('/\d/', $info, $gd);
                $gd_version = $gd[0];
        }

        return $gd_version;
} 
Ok Dennys. The change is done. Go to the url.
Ok now change
$bg_color = imagecolorallocate($im, 255, 255, 255);
imagefill($im, 0, 0, $bg_color);
to this:
$bg_color = imagecolorallocate($im, 255, 255, 255);
if($bg_color === false || $bg_color == -1)
{
die('imagecolorallocate failed');
}
$test = imagefill($im, 0, 0, $bg_color);
if(!$test)
{
die('imagefill failed');
}
(2008-11-02, 06:45 AM)DennisTT Wrote: [ -> ]Ok now change
$bg_color = imagecolorallocate($im, 255, 255, 255);
imagefill($im, 0, 0, $bg_color);
to this:
$bg_color = imagecolorallocate($im, 255, 255, 255);
if($bg_color === false || $bg_color == -1)
{
die('imagecolorallocate failed');
}
$test = imagefill($im, 0, 0, $bg_color);
if(!$test)
{
die('imagefill failed');
}
done!
Ok now change
$bg_color = imagecolorallocate($im, 255, 255, 255);
to
$bg_color = imagecolorallocate($im, 255, 0, 0);

Then it should become a red box.
Done! But the image is still black
Pages: 1 2 3