|
Posted by Steve on 10/03/06 13:48
i prototype on my windows pc. i'm trying to rollout a demo version on a rh
linux box. both use apache and php 5. i'm having problems with generating
graphics on the linux side. in particular, the login page creates a graphic
that has a security code that the user types in and submits with their
un/passwd. on the linux box, eventually the image request just times out in
the browser leaving the familiar X-in-a-square-where-an-image-should-be. i'm
pulling the gd2 dll into php cgi on windows and linux appears to have it
configured in as well. both show the following in phpinfo(). any light
someone could shed on this would be a tremendous help...tia!
php info for gd (same for windows and linux):
GD Support => enabled
GD Version => bundled (2.0.28 compatible)
FreeType Support => enabled
FreeType Linkage => with freetype
FreeType Version => 2.1.9
GIF Read Support => enabled
GIF Create Support => enabled
JPG Support => enabled
PNG Support => enabled
WBMP Support => enabled
XBM Support => enabled
here's the pertinent login html:
<img src="http://dev.example.com/get.security.image.php">
and here's the intermediate php script (get.security.image.php):
<?
require_once 'relative.path.php';
require_once $relativePath . 'site.cfg.php';
require_once $site->classDirectory . 'security.image.class.php';
$image = new securityImage($site->securityCode, $site->imagesDirectory .
'security.image.jpg');
$image->create(securityImageConstants::PNG);
?>
here's the security.image.class.php:
<?
class securityImageConstants
{
const GD = 0;
const GIF = 1;
const JPG = 2;
const PNG = 3;
}
class securityImage
{
public $codeLength = 6;
public $accentColor = '990000';
public $fontColor = '990000';
public $fontSize = 48;
public $image = null;
public $securityCode = '';
public $securityImage = '';
private function __clone(){}
public function __construct($securityCode, $securityImage)
{
$this->securityCode = $securityCode;
$this->securityImage = $securityImage;
}
private function __copy(){}
public function create($type = securityImageConstants::PNG)
{
$imageSize = getimagesize($this->securityImage);
$this->image = imagecreatefromjpeg($this->securityImage);
$imageWidth = $imageSize[0];
$imageHeight = $imageSize[1];
$accentColor = imagecolorallocate(
$this->image
,
hexdec(substr($this->accentColor,
0, 2)) ,
hexdec(substr($this->accentColor,
2, 2)) ,
hexdec(substr($this->accentColor,
4, 2))
);
$fontColor = imagecolorallocate(
$this->image
,
hexdec(substr($this->fontColor,
0, 2)) ,
hexdec(substr($this->fontColor,
2, 2)) ,
hexdec(substr($this->fontColor,
4, 2))
);
$fontHeight = imagefontheight($this->fontSize);
$fontWidth = imagefontwidth($this->fontSize);
$text = substr(preg_replace('//', '$1 ',
$this->securityCode), 0, - 1);
$x = ($imageWidth - strlen($text) * $fontWidth) / 2;
$y = ($imageHeight - $fontHeight) / 2;
for ($i = 0; $i < strlen($text); $i++)
{
imagechar(
$this->image ,
$fontHeight ,
$x + ($fontWidth * $i) - 1 ,
$y ,
$text[$i] ,
$accentColor
);
imagechar(
$this->image ,
$fontHeight ,
$x + ($fontWidth * $i) ,
$y - 1 ,
$text[$i] ,
$fontColor
);
}
switch ($type)
{
case securityImageConstants::GD : imagegd($this->image) ; break;
case securityImageConstants::GIF : imagegif($this->image) ; break;
case securityImageConstants::JPG : imagejpeg($this->image) ; break;
default : imagepng($this->image) ; break;
}
imagedestroy($this->image);
}
}
?>
Navigation:
[Reply to this message]
|