image.php 851 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. // Begin the session
  3. session_start();
  4. // If the session is not present, set the variable to an error message
  5. if(!isset($_SESSION['captcha_id']))
  6. $str = 'ERROR!';
  7. // Else if it is present, set the variable to the session contents
  8. else
  9. $str = $_SESSION['captcha_id'];
  10. // Set the content type
  11. header('Content-Type: image/png');
  12. header('Cache-Control: no-cache');
  13. // Create an image from button.png
  14. $image = imagecreatefrompng('button.png');
  15. // Set the font colour
  16. $colour = imagecolorallocate($image, 183, 178, 152);
  17. // Set the font
  18. $font = '../fonts/Anorexia.ttf';
  19. // Set a random integer for the rotation between -15 and 15 degrees
  20. $rotate = rand(-15, 15);
  21. // Create an image using our original image and adding the detail
  22. imagettftext($image, 14, $rotate, 18, 30, $colour, $font, $str);
  23. // Output the image as a png
  24. imagepng($image);