File: /home/httpd/html/camrub.com/public_html/includes/captcha.php
<?php
// save this code in your random script
include('../admin/config.php');
session_start();
$randChars = array("/","|","\\",".");
shuffle($randChars);
$randChar = $randChars[0];
$first = rand(1,10);
$second = rand(1,10);
$captchaString = "$randChar$first+$second = ?$randChar";
$_SESSION['captcha'] = $first+$second;
$imgX = 180;
$imgY = 60;
$image = imagecreatetruecolor(180, 60);
$backgr_col = imagecolorallocate($image, 255,255,255);
$border_col = imagecolorallocate($image, 208,208,208);
$text_col = imagecolorallocate($image, 80,80,80);
$noise_color = imagecolorallocate($image, 80, 80, 80);
imagefilledrectangle($image, 0, 0, 180, 60, $backgr_col);
imagerectangle($image, 0, 0, 179, 59, $border_col);
for( $i=0; $i<($imgX*$imgY)/3; $i++ ) {
imagefilledellipse($image, mt_rand(0,$imgX), mt_rand(0,$imgY), 1, 1, $noise_color);
}
$font = "$basepath/includes/captchaFont.ttf";
$font_size = 30;
$angle = rand(-6,6);
$box = imagettfbbox($font_size, $angle, $font, $captchaString);
$x = (int)($imgX - $box[4]) / 2;
$y = (int)($imgY - $box[5]) / 2;
imagettftext($image, $font_size, $angle, $x, $y, $text_col, $font, $captchaString);
header("Content-type: image/png");
imagepng($image);
imagedestroy ($image);