Tema: captcha
Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/05/2010, 04:39
evoarte
 
Fecha de Ingreso: julio-2002
Mensajes: 813
Antigüedad: 21 años, 8 meses
Puntos: 2
captcha

buenos días,

trato de configurar php para poder utilizar un modulo captcha pero no lo consigo.

(utilizo windows web server 2008, y PHP Version 5.2.5)

he habilitado
extension=php_gd2.dll

no hay nada mas configurado en el bloque [gd]

lo que muestra phpinfo(); para [gd]

GD Support enabled
GD Version bundled (2.0.34 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.1.9
T1Lib Support enabled
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabled

el archivo php de generación del captcha:

<?php

session_start();
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

function _generateRandom($length=6){
$_rand_src = array(
array(48,57) //digits
, array(97,122) //lowercase chars
// , array(65,90) //uppercase chars
);
srand ((double) microtime() * 1000000);
$random_string = "";
for($i=0;$i<$length;$i++){
$i1=rand(0,sizeof($_rand_src)-1);
$random_string .= chr(rand($_rand_src[$i1][0],$_rand_src[$i1][1]));
}
return $random_string;
}

$im = imagecreatefromjpeg("captcha.jpg");

$rand1 = _generateRandom(6);
ImageString($im, 5, 2, 2, $rand1, ImageColorAllocate ($im, 0, 0, 0));
$_SESSION['co9k383'] = $rand1;
/*
$rand1 = _generateRandom(3);
ImageString($im, 5, 2, 2, $rand1[0]." ".$rand1[1]." ".$rand1[2]." ", ImageColorAllocate ($im, 0, 0, 0));
$rand2 = _generateRandom(3);
ImageString($im, 5, 2, 2, " ".$rand2[0]." ".$rand2[1]." ".$rand2[2], ImageColorAllocate ($im, 255, 0, 0));
$_SESSION['captcha'] = $rand1.$rand2;
*/
Header ('Content-type: image/jpeg');
imagejpeg($im,null,100);
ImageDestroy($im);
?>

un saludo,
josé carlos.

Última edición por evoarte; 11/05/2010 a las 04:45