Example #1
0
 function action_captcha()
 {
     include_once "lib/Captcha.php";
     $captcha = new Captcha();
     $captcha->image($captcha->captchaword());
 }
Example #2
0
 /**
  * Creates an image resource with the dimensions specified in config.
  * If a background image is supplied, the image dimensions are used.
  *
  * @throws  Kohana_Exception  if no GD2 support
  * @param   string  path to the background image file
  * @return  void
  */
 protected function image_create($background = null)
 {
     // Check for GD2 support
     if (!function_exists('imagegd2')) {
         Core::show_500(__('captcha.requires_GD2'));
     }
     // Create a new image (black)
     Captcha::$image = imagecreatetruecolor(Captcha::$config['width'], Captcha::$config['height']);
     // Use a background image
     if (!empty($background)) {
         /*
                     // Create the image using the right function for the filetype
                     $function = 'imagecreatefrom' . Captcha::image_type($filename);
                     Captcha::$background_image = $function($background);
         // Resize the image if needed
                     if ( imagesx(Captcha::background_image) !== Captcha::$config['width'] or imagesy(Captcha::background_image) !== Captcha::$config['height'] )
                     {
                         imagecopyresampled(Captcha::image, Captcha::background_image, 0, 0, 0, 0, Captcha::$config['width'], Captcha::$config['height'], imagesx(Captcha::background_image), imagesy(Captcha::background_image));
                     }
         // Free up resources
                     imagedestroy(Captcha::background_image);
         */
     }
 }