i was wondering about ways to make ur script more random.......and i came up with the following one
PHP Code:
//FONTS TO BE USED
$font1 = 'TRASHED.ttf';
$font2 = 'trashco.ttf';
$font3 = 'ChalkboardBold.ttf';
$font4 = 'CHILLER.TTF';
$fonts = array($font1, $font2, $font3, $font4);
//IMAGES TO BE USED
$image1 = 'image.jpg';
$image2 = 'image (1).jpg';
$image3 = 'image (2).jpg';
$image4 = 'image (3).jpg';
$image5 = 'image (4).jpg';
$image6 = 'image (5).jpg';
$images = array($image1, $image2, $image3, $image4, $image5, $image6);
session_start();
//background image randomization
shuffle($images);
$im = imagecreatefromjpeg ($images[0]);
if ( function_exists( 'imagefilter' ) )
{
imagefilter( $im, IMG_FILTER_GAUSSIAN_BLUR );
}
$g2 = rand(1, 10);
if($g2 < 5){
$gaussian = array(array(1.0, 2.0, 1.0), array(2.0, 4.0, 2.0), array(1.0, 2.0, 1.0));
imageconvolution($im, $gaussian, 16, 0);
}
if($gd2 > 5){
imagefilter($im, IMG_FILTER_GRAYSCALE, 100);
}
$rand1 = rand(1,255);
$rand2 = rand(1,255);
$rand3 = rand(1,255);
$color = imagecolorallocate($im, $rand1, $rand2, $rand3);
$_direction = ( time() % 2 ) ? TRUE : FALSE;
//smart 'readable word' creation :P
$no2 = rand(1, 10);
if ($no2 == 10) {
$str = str_shuffle(ao);
}
if ($no2 == 1) {
$str = str_shuffle(da);
}
if ($no2 == 2) {
$str = str_shuffle(ge);
}
if ($no2 == 3) {
$str = str_shuffle(ji);
}
if ($no2 == 4) {
$str = str_shuffle(mo);
}
if ($no2 == 5) {
$str = str_shuffle(pu);
}
if ($no2 == 6) {
$str = str_shuffle(sa);
}
if ($no2 == 7) {
$str = str_shuffle(vi);
}
if ($no2 == 8) {
$str = str_shuffle(xe);
}
if ($no2 == 9) {
$str = str_shuffle(io);
}
$str1 = array(a, e, i, o, u);
shuffle($str1);
$str2 = array(a, b, c, d, f, g, j, k, l, m, n, p, q, r, s, t, x, z);
shuffle($str2);
$text = $str.$str1[0].$str2[0];
//font randomization
shuffle($fonts);
$font = $fonts[0];
//text size and offset randomization
$size = rand(30, 40);
$off = rand(0, 50);
//image creation
imagettftext($im, $size, 0, $off, 45, $color, $font, $text);
header('Content-type: image/jpg');
imagejpeg($im);
imagedestroy($im);
$_SESSION['captcha'] = $text;
?>