Exemplo n.º 1
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;
 }