Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 function createImageData()
 {
     $image_name = PhocaguestbookHelperCaptchaMath::getRandomImage();
     $image = @imagecreatefromjpeg($image_name);
     $math = PhocaguestbookHelperCaptchaMath::getMath();
     $items = array(0 => $math['first'], 1 => $math['operation'], 2 => $math['second'], 3 => 15);
     $x = 18;
     //Position X (first)
     for ($i = 0; $i < 4; $i++) {
         $randChar = PhocaguestbookHelperCaptchaMath::createImageItem($items[$i]);
         // Position Y (first) ---
         if ($i == 1) {
             $y = 20;
         } else {
             $y = 10;
         }
         // -----------------------
         foreach ($randChar['array'] as $key => $value) {
             $font_color = PhocaguestbookHelperCaptchaMath::getRandomFontColor();
             if ($i == 1 || $i == 3) {
                 $font_size = 2;
             } else {
                 $font_size = 5;
             }
             $position_x = $x;
             $position_y = $y;
             ImageString($image, $font_size, $position_x, $position_y, $value, ImageColorAllocate($image, $font_color[0], $font_color[1], $font_color[2]));
             if ($i == 1) {
                 $y = $y + 7;
             } else {
                 $y = $y + 11;
             }
         }
         if ($i == 0 || $i == 2) {
             $x = $x + 70;
         } else {
             $x = $x + 50;
         }
     }
     // Here is not the rand char but the matematical outcome
     $image_data['outcome'] = $math['outcome'];
     $image_data['image'] = $image;
     return $image_data;
 }
Exemplo n.º 3
0
 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;
 }