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