-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcaptcha.php
25 lines (18 loc) · 890 Bytes
/
captcha.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
header("Content-Type: image/png");
session_start();
$_SESSION['captcha'] = substr(md5(rand(10000, 2147483647)), -8);
$fontList = array
(
"arial.ttf", "arialbd.ttf", "arialbi.ttf", "ariali.ttf", "ARIALN.TTF",
"ARIALNB.TTF", "ARIALNBI.TTF", "ARIALNI.TTF", "ariblk.ttf", "consola.ttf",
"consolab.ttf", "consolai.ttf", "consolaz.ttf", "micross.ttf", "pala.ttf",
"palab.ttf", "palabi.ttf", "palai.ttf", "PAPYRUS.TTF", "segoeui.ttf",
"segoeuib.ttf", "segoeuii.ttf", "segoeuil.ttf", "segoeuiz.ttf", "seguisb.ttf"
);
$imageHandle = imagecreatefromjpeg("images/captcha.jpg");
$imageTextColor = imagecolorallocate($imageHandle, rand(50, 150), rand(50, 150), rand(50, 150));
imagettftext($imageHandle, 35, 0, 10, 50, $imageTextColor, "ttffonts/".$fontList[array_rand($fontList)], "" . $_SESSION['captcha'] . "");
imagepng($imageHandle);
imagedestroy($imageHandle);
?>