Fatal error: Call to a member function show() on a non-object in /home/xxxxx/public_html/Captcha.php on line 86
<?php class Captcha { private $text; private $image; public function __construct($characters=5) { $font = '/inc/captcha/Arial_Black.ttf'; $font2 = '/inc/captcha/Arial.ttf'; $pos_ini = 20; $font_len = 35; $letters = array( array('a', 'e', 'i', 'o', 'u'), array('c', 'c', 'd', 'f', 'g') ); $colors = array( array(0, 0, 0), array(255, 0, 0), array(0, 255, 0), array(0, 0, 255) ); $colors_nam = array('pretas', 'vermelhas', 'verdes', 'azuis'); $colors_len = count($colors); $this->image = imagecreate($characters * $font_len + $pos_ini * 2, 80); imagecolorallocate($this->image, 233, 234, 235); $avail = array(array() /* letters */, array() /* colors */); for ($i=0; $i < $characters; $i++) { $letter_type = rand(0, 1); $letter = $letters[$letter_type][rand(0, count($letters[$letter_type]) - 1)]; if (empty($avail[0][$letter_type])) $avail[0][$letter_type] = $letter; else $avail[0][$letter_type] .= $letter; $color = rand(0, $colors_len - 1); if (empty($avail[1][$color])) $avail[1][$color] = $letter; else $avail[1][$color] .= $letter; list($r, $g, $b) = $colors[$color]; imagettftext($this->image, 30, ($i % 2 == 0 ? rand(0, 25) : - rand(0, 25)), $pos_ini + ($font_len * $i), 45, imagecolorallocate($this->image, $r, $g, $b), $font, $letter); } $ask = rand(0, 1); $options = array_keys($avail[$ask]); $type = $options[rand(0, count($options) - 1)]; $this->text = $avail[$ask][$type]; $question = $ask ? $colors_nam[$type] : ($type ? 'consoantes' : 'vogais'); imagettftext($this->image, 10.5, 0, 5, 72, imagecolorallocate($this->image, 0, 0, 0), $font2, "Quais letras são {$question}?"); } public function text() { return $this->text; } public function show() { header('Pragma: no-cache'); header('Cache-Control: private, no-cache, no-cache="Set-Cookie", proxy-revalidate'); header('Content-type: image/png'); imagepng($this->image); imagedestroy($this->image); } } session_start(); $captcha = new Captcha(5); $_SESSION['captcha'] = $captcha->text(); $captcha->show(); //LINHA 86 ?>
Edição feita por: erloracc, 07/09/2009, 10:35.