przerabiam token Crasha na klase. jednak caly czas wywala blad - blad grafiki. zadnego innego bledu nie wyswietla. czy ktos moze mi pomoc ?
pozdrawiam
<?php
class token {
var $fontDir = '../font'; // katalog z czcionkami
var $fontFiles = array('TT1221M_.TTF'); // nazwy używanych plików czcionek var $imgType = 'gif'; // format wyświetlanej grafiki (png, gif, jpeg)
var $length = 6; // długo�ć losowego cišgu
var $backColor = '#ffffff'; // kolor tła grafiki
var $fontColor = '#2a2a2a'; // kolor czcionki
var $dotsColor = '#c0c0c0'; // kolor plam ;-)
var $token;
function token( $length ){
for($i = 0; $i < strlen($token); $i++) {
if(($token{$i} >= 'a' and
$token{$i} <= 'z') and
(rand(0
, 10
) > 5
)) {
}
}
$this->token = $token;
$_SESSION['token'] = $token;
}
function make_color($img, $color)
{
{
for($i = 0; $i < 6; $i += 2)
{
$rgb[] = (int
)hexdec($color{$i}.$color{$i + 1
}); }
return imagecolorallocate($img, $rgb[0], $rgb[1], $rgb[2]);
}
else
{
return 0;
}
}
function display(){
header('Content-type: image/'.$this->imgType);
$width = strlen($this->token) * 15
+ 10; $height = 25;
$img = imagecreate($width, $height);
$back = $this->make_color($img, $this->backColor);
$font = $this->make_color($img, $this->fontColor);
$dots = $this->make_color($img, $this->dotsColor);
for($i = 0; $i < round($width / 1
.5
); $i++) {
{
imageellipse
($img, $x, $y, rand(2
, 7
), rand(3
, 6
), $dots); $pts[] = $x.'_'.$y;
}
else
{
$i--;
}
}
for($i = 0; $i < strlen($this->token); $i++) {
imagettftext
($img, rand(14
, 16
), rand(-10
, 10
), rand(3
, 5
) + $i * 15
, 20
+ rand(-3
, 3
), $font, $this->fontDir.'/'.$this->fontFiles[rand(0
, count($this->fontFiles) - 1
)], $this->token{$i}); }
switch($this->imgType)
{
case 'jpeg':
imagejpeg($img);
break;
case 'gif':
imagegif($img);
break;
default:
imagepng($img);
break;
}
imagedestroy($img);
}
}
?>
Ten post edytował Balon 8.10.2006, 11:40:32