function &getData() { //$app = JFactory::getApplication(); $paramsC = JComponentHelper::getParams('com_phocaguestbook'); $enable_captcha = $paramsC->get('enable_captcha', 1); $captchaId = PhocaguestbookHelperFront::getCaptchaId($enable_captcha); switch ((int) $captchaId) { case 3: $this->_image_data = PhocaguestbookHelperCaptchaTTF::createImageData(); break; case 2: $this->_image_data = PhocaguestbookHelperCaptchaMath::createImageData(); break; case 1: default: $this->_image_data = PhocaguestbookHelperCaptcha::createImageData(); break; } return $this->_image_data; }
function createImageData() { $rand_char = PhocaguestbookHelperCaptcha::generateRandomChar(6); $rand_char_array = array($rand_char[0] . " ", " " . $rand_char[1] . " ", " " . $rand_char[2] . " ", " " . $rand_char[3] . " ", " " . $rand_char[4] . " ", " " . $rand_char[5]); $image_name = PhocaguestbookHelperCaptcha::getRandomImage(); $image = @imagecreatefromjpeg($image_name); foreach ($rand_char_array as $key => $value) { $font_color = PhocaguestbookHelperCaptcha::getRandomFontColor(); $position_x = mt_rand(5, 8); $position_y = mt_rand(6, 9); $font_size = mt_rand(4, 5); ImageString($image, $font_size, $position_x, $position_y, $value, ImageColorAllocate($image, $font_color[0], $font_color[1], $font_color[2])); } $image_data['outcome'] = $rand_char; $image_data['image'] = $image; return $image_data; }
function &getData() { global $mainframe; $params =& $mainframe->getParams(); $enable_captcha = 1; if ($params->get('enable_captcha') != '') { $enable_captcha = $params->get('enable_captcha'); } //krumo($params); //echo $enable_captcha;exit; switch ((int) $enable_captcha) { case 10: $random = mt_rand(1, 3); switch ((int) $random) { case 3: $this->_image_data = PhocaguestbookHelperCaptchaTTF::createImageData(); break; case 2: $this->_image_data = PhocaguestbookHelperCaptchaMath::createImageData(); break; case 1: default: $this->_image_data = PhocaguestbookHelperCaptcha::createImageData(); break; } break; case 11: $random = mt_rand(1, 2); switch ((int) $random) { case 2: $this->_image_data = PhocaguestbookHelperCaptchaMath::createImageData(); break; case 1: default: $this->_image_data = PhocaguestbookHelperCaptcha::createImageData(); break; } break; case 12: $random = mt_rand(1, 2); switch ((int) $random) { case 2: $this->_image_data = PhocaguestbookHelperCaptchaTTF::createImageData(); break; case 1: default: $this->_image_data = PhocaguestbookHelperCaptcha::createImageData(); break; } break; case 13: $random = mt_rand(1, 2); switch ((int) $random) { case 2: $this->_image_data = PhocaguestbookHelperCaptchaTTF::createImageData(); break; case 1: default: $this->_image_data = PhocaguestbookHelperCaptchaMath::createImageData(); break; } break; case 3: $this->_image_data = PhocaguestbookHelperCaptchaTTF::createImageData(); break; case 2: $this->_image_data = PhocaguestbookHelperCaptchaMath::createImageData(); break; case 1: default: $this->_image_data = PhocaguestbookHelperCaptcha::createImageData(); break; } return $this->_image_data; }