How I do this

From: Date: Mon, 13 Jun 2005 14:25:28 +0000
Subject: How I do this
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-12677@lists.php.net to get a copy of this message
Well, I try to put some graphic code generated dinamically. The script count with 2 pages basically. The firs page contains a function to generate a random key. See them below: ******************************************************************* <?php function genera_password($longitud,$tipo="alfanumerico"){ if ($tipo=="alfanumerico"){ $exp_reg="[^A-Z0-9]"; } elseif ($tipo=="numerico"){ $exp_reg="[^0-9]"; } return substr(eregi_replace($exp_reg, "", md5(time())) . eregi_replace($exp_reg, "", md5(time())) . eregi_replace($exp_reg, "", md5(time())), 0, $longitud); } ?> ******************************************************************* The other page call gen-codigo.php look like this ******************************************************************* <?php session_start(); $codigo = $_SESSION['password']; $tipografias = array("arial","comic","times"); $tipografias_ruta = "C:\WINDOWS\Fonts\\"; $espacio = 0; $tamano_fuente = 15; $profundidad_codigo = 10; // (alfanuméricos) $x=$profundidad_codigo*$tamano_fuente; $y=$tamano_fuente; $im = imagecreate($x, $y); $color_fondo = imagecolorallocate($im, 255, 255, 255); $color_texto = imagecolorallocate($im, 0, 0, 0); for($caracter=0; $caracter<$profundidad_codigo; $caracter++){ $indice_aleatorio=array_rand($tipografias); $tipografia=$tipografias_ruta.$tipografias[$indice_aleatorio].'.ttf'; imagettftext($im, $tamano_fuente, 0, $espacio, $tamano_fuente, $color_texto, $tipografia , $codigo{$caracter}); $espacio +=$tamano_fuente; } header('Content-type: image/png'); imagepng($im); imagedestroy($im); ?> ******************************************************************* As you can see all is PHP Code. Well the way to use them is this: in the page contains HTML code I must put this code: <img src="<? gen-codigo.php; ?>">> And this show me the image with code generated. I try to do this on Smarty TPL but results are not showed. So, how I do this? Regards Reynier Pérez Mira 3er. año Ing. Informática

« previous php.smarty.general (#12677) next »