[SMARTY] How I do this
"Reynier Perez Mira" <[email protected]>
| Newsgroups | gmane.comp.php.smarty.general |
|---|---|
| Message-ID | <[email protected]> |
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
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php