הדבר מכיל הערות ככה שיהיה קל ללמוד. כל מי שלא מבין משהו שיגיד.
קוד PHP:
<?
session_start();
#####################################
## Captcha Verifaction ##
## By JsT ##
#####################################
// Create a random string
$randomChar = microtime() * mktime();
// Encode string in MD5 Enctyptoin
$randomEncrypetString = md5($randomChar);
// Creating a new String
$finalString = substr($randomEncrypetString, 0, 6);
// Create a random Pic num
$randPicNum = mt_rand(1, 3);
// Get image from dir
$capatchaImage = imagecreatefromjpeg("img".$randPicNum.".jpg");
// Creats a line and back collers
$line = imagecolorallocate($capatchaImage,233,239,239);
// Creats an Line on the random picture
imageline($capatchaImage,0,0,39,29,$line);
imageline($capatchaImage,40,0,64,29,$line);
// Creats The string over The picture
imagestring($capatchaImage, 5, 10, 5, $finalString, $line);
// Sends the captcha real value through Session
$_SESSION['captcha'] = md5($finalString);
// Outputs the image to the user
header("Content-type: image/jpeg");
imagejpeg($capatchaImage);
?>