Hola buenas tardes, he visto muchos captchas que tienen unas lineas por la imagen.
Me gustaria poner de esas lineas a mi captcha aqui os dejo los codigos:
Captcha_config.php
Código PHP:
<?php
// Captcha image generator configuration
$background = "images/imagecaptcha.gif"; // this is the image used for random background creation
$sizex = 167; // captcha image width pixels
$sizey = 50; // captcha image height pixels
$lineas = 4; // Cantidad de lineas de relleno
$yofs = 3; // VERTICAL text offset for font (varies with font) to get it 'just so'
$random = 1; // 1 is random rotation, 0 is no rotation
$length = 6; // number of characters in security code (must fit on your image!)
$font = "Vrev.TTF";
$size = 16; // pixel size of the font used may need adjusting depending on your chosen font
$bold = 1; // 0=OFF. Some fonts/backgrounds will need bold text, so change $bold=0 to $bold=1
$red = 225; // RGB red channel 0-255 for font color
$green = 225; // RGB green channel 0-255 for font color
$blue = 225; // RGB blue channel 0-255 for font color
?>
Captcha_image.php
Código PHP:
<?php
session_start();
include("captcha_config.php"); // file with configuration data
// create random character code for the captcha image
$text = "";
$key_chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
$rand_max = strlen($key_chars) - 1;
for ($i = 0; $i < $length; $i++) {
$rand_pos = rand(0, $rand_max);
$text.= $key_chars{$rand_pos};
}
$_SESSION['captcha'] = $text; // save what we create
// center text in the 'box' regardless of rotation
function imagettftext_cr(&$img, $size, $angle, $x, $y, $content_color, $font, $text) {
// retrieve boundingbox
$bbox = imagettfbbox($size, $angle, $font, $text);
// calculate deviation
$dx = ($bbox[2]-$bbox[0])/2.0 - ($bbox[2]-$bbox[4])/2.0; // deviation left-right
$dy = ($bbox[3]-$bbox[1])/2.0 + ($bbox[7]-$bbox[1])/2.0; // deviation top-bottom
// new pivotpoint
$px = $x-$dx;
$py = $y-$dy;
return imagettftext($img, $size, $angle, $px, $py, $content_color, $font, $text);
}
// get background image dimensions
$imgsize = getimagesize($background);
$height = $imgsize[1];
$width = $imgsize[0];
$xmax = $width - $sizex;
$ymax = $height - $sizey;
// create the background in memory so we can grab chunks for each random image
$copy = imagecreatefromgif($background);
// create the image
$img = imagecreatetruecolor($sizex,$sizey);
$content_color = imagecolorallocate($img, $red, $green, $blue);
// choose a random block (right size) of the background image
$x0 = rand(0,$xmax); $x1 = $x0 + $sizex;
$y0 = rand(0,$ymax); $y1 = $y0 + $sizey;
imagecopy($img,$copy, 0, 0, $x0, $y0, $x1, $y1);
$angle = $random * (5*rand(0,8) - 20); // random rotation -20 to +20 degrees
// add text to image once or twice (offset one pixel to emulate BOLD text if needed)
imagettftext_cr($img, $size, $angle, $sizex/2, $sizey/2-$yofs, $content_color, $font, $text);
if ($bold==1) {
imagettftext_cr($img, $size, $angle, $sizex/2+1, $sizey/2-$yofs, $content_color, $font, $text);
}
header ("content-type: image/png");
imagepng ($img);
imagedestroy ($img);
?>
¿Que añado para tener esas lineas?
Gracias a todos los q me ayuden de antemano