Ver Mensaje Individual
  #11 (permalink)  
Antiguo 23/12/2008, 10:14
Avatar de NnikoO
NnikoO
 
Fecha de Ingreso: agosto-2008
Ubicación: Rosario
Mensajes: 245
Antigüedad: 15 años, 8 meses
Puntos: 0
Respuesta: Ayuda Con Guestbook de Kike!!!!!

Perdon... no subi el codigo xq m tenia q ir a solucionar unos problemitas... aca estoy...

Los archivos son=

libro.php

Código php:
Ver original
  1. <?
  2.     include("config.php");
  3.     include("funciones.php");
  4.  
  5.     Template("htmll/tpl_arriba.html"); ?>
  6.           <table width="650" border="2" align="center" cellpadding="3" bordercolor="#FFCCFF" style="border-collapse:collapse">
  7.           <tr>
  8.             <td><br />
  9.               <?
  10.    
  11.    
  12.     switch($accion) {
  13.  
  14.     case firmar:
  15.     Template("htmll/tpl_formulario.html");
  16.     break;
  17.  
  18.     case publicar:
  19.  
  20.     $fecha = date("d-m-y H:i a");
  21.  
  22.     $nombre = trim($nombre);
  23.     $email = trim($email);
  24.     $mensaje = trim($mensaje);
  25.  
  26.     if(empty($nombre)) {
  27.         $error[] = $alerta[0];
  28.     }
  29.     if($email != "") {
  30.         if (!ereg("^[^@]+@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,}$", $email)) {
  31.             $error[] = $alerta[1];
  32.         }
  33.     }
  34.     if(empty($mensaje)) {
  35.         $error[] = $alerta[2];
  36.     }
  37.  
  38.    
  39.  
  40.     if($FiltroGroserias == "SI") {
  41.     for($i = 0; $i < sizeof($palabrotas); $i++) {
  42.     if(ereg($palabrotas[$i], $nombre) OR ereg($palabrotas[$i], $email) OR ereg($palabrotas[$i], $mensaje)) {       
  43.         $error[] = $alerta[3];
  44.     }
  45.     }
  46.     }
  47.  
  48.     if($error) {
  49.  
  50.     include("htmll/tpl_formulario.html");
  51.  
  52.     } else {
  53.  
  54.    
  55.  
  56.     HTML();
  57.     Remplazar();
  58.     $mensaje = ereg_replace("\r\n","<br>", $mensaje);
  59.  
  60.    
  61.  
  62.     $fp = fopen($FicheroId,"r");
  63.     $id = fread($fp, filesize($FicheroId));
  64.     $id ++;
  65.     fclose($fp);
  66.  
  67.     $fp = fopen($FicheroId, "w");
  68.     fwrite($fp, $id);
  69.     fclose($fp);
  70.  
  71.     $firma = "$id|@|$nombre|@|$email|@|$url|@|$mensaje|@|$fecha|@|\n";
  72.     $fp = fopen($FicheroBase, "a");
  73.     fwrite($fp, $firma);
  74.     fclose($fp);
  75.  
  76.     Template("htmll/tpl_correcto.html");
  77.  
  78.     }
  79.     break;
  80.     default:
  81.  
  82.     // Mostrar todas las firmas
  83.  
  84.     $Base = file($FicheroBase);
  85.     $Orden = array_reverse($Base);
  86.  
  87.     if(empty($paginado)) {
  88.         $paginado = 0;
  89.     }
  90.  
  91.     $Mostrar = $paginado + $LimiteMensajes;
  92.  
  93.     for ($i = $paginado; $i < count($Orden) AND $i < $Mostrar; $i++) {
  94.         $dato = explode("|@|", $Orden[$i]);
  95.  
  96.     $nombre = $dato[1];
  97.     $email = $dato[2];
  98.     $mensaje = $dato[4];
  99.     $fecha = $dato[5];
  100.  
  101.     // Template
  102.  
  103.     Template("htmll/tpl_mensajes.html");
  104.  
  105.     }
  106.  
  107.     echo "<table cellpadding='4' cellspacing='1' width='450' align='center' class='normal'>";
  108.     echo "<tr><td width='50%'>";
  109.     Paginacion();
  110.     echo "</td><td width='50%' align='right'>";
  111.     echo "<b><a href='libro.php?accion=firmar'>Firmar...</a></b>";
  112.     echo "</td></tr></table>";
  113.  
  114.     }
  115.    
  116. ?>


admin.php

Código PHP:
<?
    
include("config.php");

    switch(
$accion) {
    case 
panel:

    if(
$NombreAdmin == $user AND $Contrase&#241;aAdmin == $pass) {

    
if($idmensaje) {

    
$Base file($FicheroBase);

    for (
$i 0$i count($Base); $i++) {
    
$dato explode("|@|"$Base[$i]);

    if (
$dato[0] == $idmensaje) {
    
$Base[$i] = "";
    
    
$fp fopen("$FicheroBase""w+");
    for (
$i 0$i count($Base); $i++) {
    
fwrite($fp$Base[$i]);
    }
    
fclose($fp);

    echo 
"<br><table cellpadding=5 border=1  style='border-collapse:collapse' align=center><tr><td><p align='center'>";
    echo 
"<font face='Arial' size='3'><b><u>El mensaje se ha eliminado con exito!!!</u></b></font>";
    echo 
"<br><form name='form' action='admin.php' method='post'>";
    echo 
"<input type='hidden' name='accion' value='panel'>";
    echo 
"<input type='hidden' name='user' value='$user'>";
    echo 
"<input type='hidden' name='pass' value='$pass'></td></tr>";
    echo 
"<tr><td class='filacentro' align=center><input align=center type='submit' value='Volver' class='formulario'>";
    echo 
"</form></p></td></tr></table>";

    }
    }
    } else {

    echo 
"<table align=center cellpadding=5><tr><td><font face='Arial' size='2'><b><u>Borrar un mensaje:</u></b></font><p>";
    echo 
"<form action='admin.php' method='post'>";
    echo 
"<input type='hidden' name='accion' value='panel'>";
    echo 
"<input type='hidden' name='user' value='$user'>";
    echo 
"<input type='hidden' name='pass' value='$pass'>";
    echo 
"<font face='Arial' size='2'><b>Número de mensaje:</b></font><br>";
    echo 
"<input type='text' name='idmensaje' size='20' class='formulario'><p>";
    echo 
"<input type='submit' value='Borrar' class='formulario'></td></tr>";
    echo 
"<tr><td align=right><a href='/proyecto/libro.php'><b>Salir...</b></a></form><hr size='1' width='300' noshade><p></td></tr></table>";
    echo 
"<table style='border-collapse:collapse' border=1 width='500' cellspacing='2' cellpadding=5 align='center' style='font-family: Verdana; font-size: 11px'>";

    
$Base file($FicheroBase);

    for (
$i 0$i count($Base); $i++) {
    
$dato explode("|@|"$Base[$i]);

    
$dato[4] = str_replace("<br>"" - "$dato[4]);

    echo 
"<tr><td width='150' class='filatitulo' ><b>Número de mensaje:</b></td><td align=center><b> $dato[0]</b></font></td>";
    echo 
"<td width='300' class='filacentro'><br>$dato[4]</td></tr>";

    }
    echo 
"<table>";
    }
    } else {

    echo 
"<p align='center'>";
    echo 
"<font face='Arial' size='4'><b>Nombre ó contraseña incorrecta.</b></font>";
    echo 
"<br><form name='form' action='admin.php' method='post'>";
    echo 
"<input type='submit' value='Volver' class='formulario'>";
    echo 
"</form></p>";

    }
    break;
    default:

    echo 
"<br><table style='border-collapse:collapse' align=center border=1 cellpadding=5><tr><td><font face='Arial' size='2'><b><u>Identificate:</u></b><font><p>";
    echo 
"<form name='form' action='admin.php' method='post'>";
    echo 
"<input type='hidden' name='accion' value='panel'>";
    echo 
"<font face='Arial' size='2'><b>Nombre:</b></font><br>";
    echo 
"<input type='text' name='user' size='20' class='formulario'><br>";
    echo 
"<font face='Arial' size='2'><b>Pass:</b></font><br>";
    echo 
"<input type='password' name='pass' size='20' class='formulario'><p>";
    echo 
"<input type='submit' value='Entrar' class='formulario'></form><p>";
    echo 
"<font face='Arial' size='2'><a href='index.php'><b>Volver</b></a></font></td></tr></table>";

    }
?>



config.php

Código PHP:
<?

// Configuración del Script

$NombreAdmin "niko";        // Nombre del administrador
$Contrase&#241;aAdmin = "leproso";        // Contraseña del administrador
$LimiteMensajes 15;        // Número de mensajes por página
$FiltroGroserias "SI";        // Activar filtro de malas palabras (SI / NO)

// Ten cuidado aquí

$FicheroBase "mensajes/mensajes.php";
$FicheroId "mensajes/id.php";

// Manejo de mensajes

$alerta[0] = "<font color='#FF0000'>Olvidaste poner tu nombre.</font>";
$alerta[1] = "<font color='#FF0000'>Tu e-mail no parece valido, pero puedes dejarlo vacio.</font>";
$alerta[2] = "<font color='#FF0000'>No existe el mensaje.</font>";
$alerta[3] = "<font color='#FF0000'>Por favor, usa un lenguaje mas decente.</font>";

// Palabras no permitidas

$palabrotas[] = "";?>

Última edición por AlvaroG; 24/12/2008 a las 09:39 Razón: resaltado de sintaxis