Ver Mensaje Individual
  #7 (permalink)  
Antiguo 24/11/2003, 15:43
Avatar de Gerald
Gerald
 
Fecha de Ingreso: julio-2003
Mensajes: 1.356
Antigüedad: 20 años, 8 meses
Puntos: 2
este es funciones.php

Código PHP:
<?
    
    
function HTML() {
        global 
$mensaje$nombre$email$url$tema$sms;
        
$mensaje str_replace("<","&lt",$mensaje);
        
$mensaje str_replace(">","&gt",$mensaje);
                        
$mensaje =  wordwrap($mensaje$sms ,"<br>",1); 
        
        
$nombre str_replace("<","&lt",$nombre);
        
$nombre str_replace(">","&gt",$nombre);
        
$email str_replace("<","&lt",$email);
        
$email str_replace(">","&gt",$email);
        
$url str_replace("<","&lt",$url);
        
$url str_replace(">","&gt",$url);
    return;
    }

        function 
Remplazar() {
        global 
$mensaje;
        
$mensaje str_replace("[:)]","<img src=\"img/sonrisa.gif\">"$mensaje);
        
$mensaje str_replace("[:(]","<img src=\"img/triste.gif\">"$mensaje);
        
$mensaje str_replace("[;)]","<img src=\"img/ginando.gif\">"$mensaje);
        
$mensaje str_replace("[8)]","<img src=\"img/ojotes.gif\">"$mensaje);
        
$mensaje str_replace("[:P]","<img src=\"img/lengua.gif\">"$mensaje);
        
$mensaje str_replace("[:D]","<img src=\"img/risa.gif\">"$mensaje);
        
$mensaje str_replace("[cool]","<img src=\"img/cool.gif\">"$mensaje);
        
$mensaje str_replace("[llorar]","<img src=\"img/llorando.gif\">"$mensaje);
        
$mensaje str_replace("[enojo]","<img src=\"img/enojado.gif\">"$mensaje);
        
$mensaje str_replace("[duda]","<img src=\"img/duda.gif\">"$mensaje);
        
$mensaje str_replace("[bien]","<img src=\"img/bien.gif\">"$mensaje);
        
$mensaje str_replace("[mal]","<img src=\"img/mal.gif\">"$mensaje);
    return;
    }

    
    function 
FatalError() {
        global 
$error;
        for(
$i 0$i sizeof($error); $i++) {
          echo 
"- $error[$i]<br>";
        }
    return;
    }

    
    function 
Template($fichero) {
        global 
$nombre$email$url$mensaje$fecha$nfirmas;
        
$template fopen($fichero"r");
        while(!
feof($template)) {
        
$buffer fgets($template4096);
        
$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;
    }

    
$nfirmas count(file($FicheroBase));

        function 
Paginacion() {
        global 
$LimiteMensajes$Base;
        if(
$LimiteMensajes count($Base)) {
        
$Paginas count($Base) / $LimiteMensajes;
        echo 
"<b>Páginas : </b>";
        for(
$i 0$i $Paginas$i++) {
        echo 
"<a href=index.php?paginado=".$i $LimiteMensajes.">".( $i )."</a> ";
        }
        }
    return;
    }
?>

<script language="JavaScript">
<!--
function Smile(texto){
document.form.mensaje.value = document.form.mensaje.value + texto;
}
// -->
</script>
este es el index.php
Código PHP:
<?

    
include("config.php");
    include(
"funciones.php");

    
Template("tpl/tpl_arriba.html");

    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($fpfilesize($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");

    }
    break;
    default:

    
$Base file($FicheroBase);
    
$Orden array_reverse($Base);

    if(empty(
$paginado)) {
        
$paginado 0;
    }

    
$Mostrar $paginado $LimiteMensajes;

    for (
$i $paginado$i count($Orden) AND $i $Mostrar$i++) {
        
$dato explode("|@|"$Orden[$i]);

    
$nombre $dato[1];
    
$email $dato[2];
    
$url $dato[3];
    
$mensaje $dato[4];
    
$fecha $dato[5];
                 
    
Template("tpl/tpl_mensajes.html");

    }

    echo 
"<table cellpadding='4' cellspacing='1' width='450' align='center' class='normal'>";
                     echo 
"<tr><td width='50%'>";
    
Paginacion();
    echo 
"</td><td width='50%' align='right'>";
    echo 
"<b><a href='index.php?accion=firmar'>Firmar libro</a></b>";
    echo 
"</td></tr></table>";

    }

    
Template("tpl/tpl_abajo.html");
?>
__________________
Solo por Hoy: Trataré de fortalecer mi mente. Estudiaré y aprenderé algo útil
Hoteldipity
Arte Caracol