// PHP Kike Guestbook v1.1 // ---------------------------------------------------- // Autor : Luis Enrique Díaz Jara // Web : http://www.kikescripts.mx.kz // Email : el-kike@iespana.es // ---------------------------------------------------- include("config.php"); include("funciones.php"); Template("html/tpl_arriba.html"); switch($accion) { // Formulario para publicar un mensaje case firmar: Template("html/tpl_formulario.html"); break; // Publicar un mensaje case publicar: $fecha = date("d-m-y H:i a"); // Comprobación de campos $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]; } // Filtro de malas palabras 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("html/tpl_error.html"); } else { // Filtramos el mensaje HTML(); Remplazar(); $mensaje = ereg_replace("\r\n","
", $mensaje); // Guardamos la firma en el fichero $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("html/tpl_correcto.html"); } break; default: // Mostrar todas las firmas $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 Template("html/tpl_mensajes.html"); } echo ""; echo "
"; Paginacion(); echo ""; echo "Firmar libro"; echo "
"; } Template("html/tpl_abajo.html");