<?PHP
  // // Adapted for The Art of Web: www.the-art-of-web.com
  // // Please acknowledge use of this code by including this header.

  // // initialise image with dimensions of 160 x 45 pixels
  // $image = @imagecreatetruecolor(160, 45) or die("Cannot Initialize new GD image stream");

  // // set background and allocate drawing colours
  // $background = imagecolorallocate($image, 0x66, 0xCC, 0xFF);
  // imagefill($image, 0, 0, $background);
  // $linecolor = imagecolorallocate($image, 0x33, 0x99, 0xCC);
  // $textcolor1 = imagecolorallocate($image, 0x00, 0x00, 0x00);
  // $textcolor2 = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);

  // // draw random lines on canvas
  // for($i=0; $i < 8; $i++) {
  //   imagesetthickness($image, rand(1,3));
  //   imageline($image, rand(0,160), 0, rand(0,160), 45, $linecolor);
  // }

  // session_start();
  // $font_path = dirname(__FILE__) ;
  // error_log($font_path);
  // // using a mixture of TTF fonts
  // $fonts = [];
  // $fonts[] = $font_path."/DejaVuSerif-Bold.ttf";
  // $fonts[] = $font_path."./DejaVuSans-Bold.ttf";
  // $fonts[] = $font_path."./DejaVuSansMono-Bold.ttf";

  // // add random digits to canvas using random black/white colour
  // $digit = '';
  // for($x = 10; $x <= 130; $x += 30) {
  //   $textcolor = (rand() % 2) ? $textcolor1 : $textcolor2;
  //   $digit .= ($num = rand(0, 9));
  //   imagettftext($image, 20, rand(-30,30), $x, rand(20, 42), $textcolor, $fonts[array_rand($fonts)], $num);
  // }

  // // record digits in session variable
  // $_SESSION['digit'] = $digit;

  // // display image and clean up
  // header('Content-type: image/png');
  // imagepng($image);
  // imagedestroy($image);
?>
<?php
// // phpinfo();
// $functions = new Functions;

// session_start();
// //You can customize your captcha settings here

// $captcha_code = '';
// $captcha_image_height = 50;
// $captcha_image_width = 130;
// $total_characters_on_image = 6;

// //The characters that can be used in the CAPTCHA code.
// //avoid all confusing characters and numbers (For example: l, 1 and i)
// $possible_captcha_letters = 'bcdfghjkmnpqrstvwxyz23456789';
// $captcha_font = 'arial.ttf';

// $random_captcha_dots = 50;
// $random_captcha_lines = 25;
// $captcha_text_color = "0xFF0000";
// $captcha_noise_color = "0x0000FF";

// $count = 0;
// while ($count < $total_characters_on_image) { 
// $captcha_code .= substr(
// 	$possible_captcha_letters,
// 	mt_rand(0, strlen($possible_captcha_letters)-1),
// 	1);
// $count++;
// }

// $captcha_font_size = $captcha_image_height * 0.65;
// $captcha_image = @imagecreate(
// 	$captcha_image_width,
// 	$captcha_image_height
// 	);

// /* setting the background, text and noise colours here */
// $background_color = imagecolorallocate(
// 	$captcha_image,
// 	255,
// 	255,
// 	255
// 	);

// $array_text_color = $functions->hextorgbconv($captcha_text_color);
// $captcha_text_color = imagecolorallocate(
// 	$captcha_image,
// 	$array_text_color['red'],
// 	$array_text_color['green'],
// 	$array_text_color['blue']
// 	);

// $array_noise_color = $functions->hextorgbconv($captcha_noise_color);
// $image_noise_color = imagecolorallocate(
// 	$captcha_image,
// 	$array_noise_color['red'],
// 	$array_noise_color['green'],
// 	$array_noise_color['blue']
// 	);

// /* Generate random dots in background of the captcha image */
// for( $count=0; $count<$random_captcha_dots; $count++ ) {
// imagefilledellipse(
// 	$captcha_image,
// 	mt_rand(0,$captcha_image_width),
// 	mt_rand(0,$captcha_image_height),
// 	2,
// 	3,
// 	$image_noise_color
// 	);
// }

// /* Generate random lines in background of the captcha image */
// for( $count=0; $count<$random_captcha_lines; $count++ ) {
// imageline(
// 	$captcha_image,
// 	mt_rand(0,$captcha_image_width),
// 	mt_rand(0,$captcha_image_height),
// 	mt_rand(0,$captcha_image_width),
// 	mt_rand(0,$captcha_image_height),
// 	$image_noise_color
// 	);
// }

// /* Create a text box and add 6 captcha letters code in it */
// $text_box = imagettfbbox(
// 	$captcha_font_size,
// 	0,
// 	$captcha_font,
// 	$captcha_code
// 	); 
// $x = ($captcha_image_width - $text_box[4])/2;
// $y = ($captcha_image_height - $text_box[5])/2;
// error_log($x.' '.$y);
// imagettftext(
// 	$captcha_image,
// 	$captcha_font_size,
// 	0,
// 	$x,
// 	$y,
// 	$captcha_text_color,
// 	$captcha_font,
// 	$captcha_code
// 	);

// /* Show captcha image in the html page */
// // defining the image type to be shown in browser widow
// header('Content-Type: image/png'); 
// imagepng($captcha_image); //showing the image
// imagedestroy($captcha_image); //destroying the image instance
// $_SESSION['captcha'] = $captcha_code;



?>