El codigo que pusieron aqui si funciona solo le tienes que corregir un pequeño error de sintaxis, aqui esta el codigo ya corregido
Código PHP:
<?php
function FUNC_generaPassw($num,$may){
if(empty($num)){$num=5;}
$voc = array ("a","e","i","o","u");
$con = array ("b","c","d","f","g","h","j","k","l","m","n","ñ","p","q","r","s","t","w","x","y","z");
$psw = "";
$vc = mt_rand(0,1);
for ($n=0; $n<$num; $n++){
if ($vc==1){
$vc=0;
$psw .= $con[mt_rand(0,count($con)-1)];
}
$psw .= $voc[mt_rand(0,count($voc)-1)];
$psw .= $con[mt_rand(0,count($con)-1)];
}
$psw = ereg_replace ("q","qu",$psw);
$psw = ereg_replace ("quu","que",$psw);
$psw = ereg_replace ("yi","ya",$psw);
$psw = ereg_replace ("iy","ay",$psw);
if(empty($may)){
$psw = strtoupper($psw);
}
$psw = substr($psw,0,$num);
session_name('codePaswSession');
session_start();
session_cache_limiter('nocache,private');
ini_set("session.cache_limiter","6400");
if(empty($_SESSION['psw'])){
$_SESSION['psw'] = $psw;
}else{
$psw = $_SESSION['psw'];
}
return $psw;
}
function FUNC_imprimePasswImg($psw,$fontSize,$winSizeW,$winSizeH) {
if(empty($psw)){$psw = "ERROR PASSW";}
if(empty($fontSize)){$fontSize=5;}
if(empty($winSizeW)){$winSizeW=72;}
if(empty($winSizeH)){$winSizeH=18;}
$width = ImageFontWidth($fontSize) * strlen($string);
$height = ImageFontHeight($fontSize);
$img = ImageCreate($winSizeW,$winSizeH);
$bgColor = ImageColorAllocate($img,102,102,202);
$txColor = ImageColorAllocate($img,220,220,220);
ImageFilledRectangle($img,0,0,$winSizeW,$winSizeH, $bgColor);
ImageString($img,$fontSize,0,0,$psw,$txColor);
header("content-type: image/png");
ImagePng($img);
Imagedestroy($img);
}
FUNC_imprimePasswImg(FUNC_generaPassw(8,1),5,72,18 );
/*
1º= numero de letras = 8
2º= minusculas = 1 o mayusculas = 0
3º= size-text = 5
4º= sizeW-win = 100
5º= sizeH-win = 20
Para usarlo, crea un fichero xxx.html o xxx.php y le pones esto
1º= Si es HTML solo:
<img src="func_codeletras.inc.php">
2º= Si ademas de HTML, quieres usar php:
<img src="func_codeletras.inc.php">
session_name('codePaswSession');
session_start();
session_cache_limiter('nocache,private');
ini_set("session.cache_limiter","6400");
echo $_SESSION['psw'];
*/
?>