Este es parte del archivo funciones donde estan los templates
Código PHP:
function Template($fichero) {
global $nombre, $email, $url, $mensaje, $fecha, $nfirmas;
$template = fopen($fichero, "r");
while(!feof($template)) {
$buffer = fgets($template, 4096);
$buffer = str_replace("{Nombre}", $nombre, $buffer);
$buffer = str_replace("{Email}", $email, $buffer);
$buffer = str_replace("{URL}", $url, $buffer);
$buffer = str_replace("{Mensaje}", $mensaje, $buffer);
$buffer = str_replace("{Fecha}", $fecha, $buffer);
$buffer = str_replace("{Numero_Firmas}", $nfirmas, $buffer);
echo $buffer;
}
fclose($template);
return;
}
y este es el codigo donde me manda al template
Código PHP:
switch($accion) {
case firmar:
Template("tpl/tpl_formulario.html");
break;
case publicar:
$fecha = date("d-m-y H:i a");
$nombre = trim($nombre);
$email = trim($email);
$mensaje = trim($mensaje);
if(empty($nombre)) {
$error[] = $alerta[0];
}
if($email != "") {
if (!ereg("^[^@]+@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,}$", $email)) {
$error[] = $alerta[1];
}
}
if(empty($mensaje)) {
$error[] = $alerta[2];
}
if($FiltroGroserias == "SI") {
for($i = 0; $i < sizeof($palabrotas); $i++) {
if(ereg($palabrotas[$i], $nombre) OR ereg($palabrotas[$i], $email) OR ereg($palabrotas[$i], $mensaje)) {
$error[] = $alerta[3];
}
}
}
if($error) {
include("tpl/tpl_error.html");
} else {
HTML();
Remplazar();
$mensaje = ereg_replace("\r\n","<br>", $mensaje);
$fp = fopen($FicheroId,"r");
$id = fread($fp, filesize($FicheroId));
$id ++;
fclose($fp);
$fp = fopen($FicheroId, "w");
fwrite($fp, $id);
fclose($fp);
$firma = "$id|@|$nombre|@|$email|@|$url|@|$mensaje|@|$fecha|@|\n";
$fp = fopen($FicheroBase, "a");
fwrite($fp, $firma);
fclose($fp);
Template("tpl/tpl_correcto.html");
}