image
Inicio » PHP » Biblioteca de Código PHP » Biblioteca de código

Comunidad

Libro de invitados

A very simple filebased guestbook for PHP-beginners. I wrote this guestbook due to a lack of a database.
A very nice feature is the search-engine-like number-of-pages indicator. As administrator, you can delete messages by checking boxes.

There is a new release (V1.0.1) out now. I fixed some bugs and cleaned up
some code. Enjoy!

Versión: V1.0.1
Fecha: 02/06/2002
Puntación: [2.5/5] Puntuar
  Volver Volver

Código

<?php
// -----------------------------------------------------------------------------------------------
// show.php
// -----------------------------------------------------------------------------------------------
// Project: Filebased guestbook.
// Author: Copyright (c) 2000 Urs Gehrig <admin@circle.ch>
// Version: 1.0.1
// Released: 31-5-2000
// Updated: 20-7-2000
// Licence: GPL
// PHP: php-4.0.0-win32
//
// -----------------------------------------------------------------------------------------------
// History: V 1.0.1:
// - cleaned up some code (show.php, form.php)
// - removed javawindow bug in form.php
// - if URL is not entered, it will not be shown
// - stripslashing all inputs
// - replacing delimiter "|" with "/", otherwise the readout of the datafile crashes
// - replaced "nr" with <br> -> one line for one item!
// V 1.0.0:
// - initial release
// -----------------------------------------------------------------------------------------------
// TODO:
// - adding an id to each item, because now, identical items would get deleted
// - fixing bug with item ennumeration -> no big deal, but have no time rite now
// -----------------------------------------------------------------------------------------------
// Enjoy!
// -----------------------------------------------------------------------------------------------

if(isset($pos)==0)
$pos=0; // start position for the page indexer
$count=3; // number of displayed items per page
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRansitional//EN">
<HTML>
<HEAD>
<TITLE>Gästebuch anzeigen</TITLE>
</HEAD>

<BODY style="font-family:arial; font-size:10px">
<CENTER>
<TABLE border="0" cellspacing="0" cellpadding="0" width="100%">
<TR>
<TD align="CENTER"><h2>G&auml;stebuch anzeigen</h2>
<TR align="CENTER">
<TD>
<TABLE border=0 width="80%">
<TR valign="top">
<TD colspan=4>
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
<TR valign="bottom">
<TD style="font-family:arial; font-size:10px" width="30%">
<a href="form.php"><img src="edit.gif" width="18" height="13" border="0"></a> eintragen.</TD>
<TD style="font-family:arial; font-size:10px" width="30%" align="center">&nbsp;</TD>
<TD style="font-family:arial; font-size:10px" width="30%">&nbsp;</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR valign="top">

<TD colspan=4 height="1">
<hr width="100%" noshade size="1"></TD>
</TR>
<?php
$content = file("data.txt"); // readfile
$size = count($content);

if($pos >= $size) $pos = 0; // break at manipulated inputs on $pos

for($i=$pos; $i<($count+$pos); $i++):
if($i > $size-1) break; // break due to not existing contents
$text = explode("|",stripslashes($content[$size-$i-1]));
?>
<TR valign="top">
<TD colspan=4>
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<TR>
<TD width="100" style="font-size: 10pt" valign="top">Beitrag <?php echo $i+1;?>:
<TD width="85%" style="font-size: 10pt"><?php echo $text[6]; ?>
<?php
if(!empty($text[5])):
?>
<TR>
<TD width="100" style="font-size: 10pt" valign="top">URL:
<TD width="85%" style="font-size: 10pt">
<font size="-1"><a href='<?php echo $text[5]; ?>'><?php echo $text[5]; ?></a></font>
<?php
endif;
?>
<TR>
<TD width="100" style="font-size: 10pt" valign="top">Author:
<TD width="85%" style="font-size: 10pt">
<font size="-1"><a href='mailto:<?php echo $text[2]; ?>'><?php echo $text[1]; ?></a></font>
<TR>
<TD width="100" style="font-size: 10pt" valign="top">Datum:
<TD width="85%" style="font-size: 10pt"><?php echo $text[0]; ?>
<TR>
<TD colspan="2"><hr width="100%" noshade size="1">
</TABLE>
</TD>
</TR>
<?php
endfor;
?>

<!-- number of pages index -->
<TR>
<TD ALIGN="LEFT" valign="top" style="font-size: 8pt" width="30%">Seiten:
<?php
for($j=0; $j<$size; $j++):
if(!($j % $count)):
?>
<a href="show.php?pos=<?php echo $j; ?>"><?php echo (($j/$count)+1); ?></a>
<?php
endif;
endfor;
?>
</TD>
<!-- forward / reverse -->
<TD ALIGN="center" valign="top" style="font-size: 8pt" width="30%">Bisher <?php echo $size;?> Einträge.</TD>
<TD ALIGN="right" valign="top" style="font-size: 8pt" width="30%">
<?php
if ($pos > 0):
?>
<a href="show.php?pos=<?php echo $pos-$count;?>">zurück</a>
<?php
endif;
if($size > $pos+$count):
?>
<a href="show.php?pos=<?php echo $pos+$count;?>"> weiter</a>
<?php
endif;
?>
</TD>
</TR>
<TR>
<TD colspan="4" align="CENTER"><font size="-2"><a href='mailto:admin@circle.ch'>(c) 2000 by urs gehrig</a></font>
</TR>
<!-- number of pages index -->

</TABLE>
</TD>
</TR>
</TABLE>
</CENTER>
</BODY>
</HTML>


Ejemplo

Ir al ejemplo

  Volver Volver







Comparte



 
Valid HTML 4.01!
Última modificación:31 de Agosto de 2017. Spain - Espa�a.
© 1998-2004 por . Todos los derechos reservados.