<html>
<head>
<title>Gästebuch</title>
<link rel='stylesheet' type='text/css' href='gaestebuch.css'>
</head>
<body>
<?php
$filename = "eintraege.txt";
if (!empty ($_POST['sign']) && !empty ($_POST['name']) && !empty ($_POST['comments'])) {
$fh = @fopen ($filename, 'a+') or die ("Could not open file: $filename");
fwrite ($fh, date ("d.m.Y H:i:s")."|--|".
htmlentities(stripslashes($_POST['name']))."|--|".
htmlentities(stripslashes($_POST['email']))."|--|".
str_replace("\n","<br>",htmlentities(stripslashes($_POST['comments'])))."\r\n");
fclose ($fh);
}
?>
<h3 align="center">Gästebuch</h3>
<br>
<script language="JavaScript">
<!--
function SE(Smiley) {
document.eingabeformular.comments.value+=Smiley+" ";
document.eingabeformular.comments.focus();
}
//-->
</script>
<table border="0" style="position:absolute; left:80px; top:150px; border-collapse:collapse;">
<tr>
<td style="height="19" width="19"><a href="JavaScript:SE(':-o')"><img src="smileys/smile.bmp" border=0></a></td>
<td style="height="19" width="19"><a href="JavaScript:SE(':-(')"><img src="smileys/traurig.bmp" border=0></a></td>
<td style="height="19" width="19"><a href="JavaScript:SE(':-p')"><img src="smileys/zunge.bmp" border=0></a></td>
</tr>
<td style="height="19" width="19"><a href="JavaScript:SE('|-)')"><img src="smileys/cool.bmp" border=0></a></td>
<td style="height="19" width="19"><a href="JavaScript:SE(':-D')"><img src="smileys/hlachen.gif" border=0></a></td>
<td style="height="19" width="19"><a href="JavaScript:SE(':love:')"><img src="smileys/love.bmp" border=0></a></td>
</tr>
<td style="height="19" width="19"><a href="JavaScript:SE(':rot:')"><img src="smileys/rot.gif" border=o></a></td>
<td style="height="19" width="19"><a href="JavaScript:SE(':-)')"><img src="smileys/grins.bmp" border=0></a></td>
<td style="height="19" width="19"><a href="JavaScript:SE(':-|')"><img src="smileys/grimmig.bmp" border=0></a></td>
</tr>
</tr>
<td style="height="19" width="19"><a href="JavaScript:SE(':girl:')"><img src="smileys/girl.bmp" border=o></a></td>
<td style="height="19" width="19"><a href="JavaScript:SE(':teufel:')"><img src="smileys/boese.bmp" border=0></a></td>
<td style="height="19" width="19"><a href="JavaScript:SE(':-s')"><img src="smileys/verbissen.bmp" border=0></a></td>
</tr>
</table>
<form method='post' name='eingabeformular' action='<?=$_SERVER['PHP_SELF']?>'>
<input type='hidden' name='sign' value='1'>
<table border="0" width="281" class="tabelleeingabe" align="center">
<tr>
<td class="linkeseite">Name:</td>
<td><input type="text" name='name'></td>
</tr>
<tr>
<td class="linkeseite">E-Mail:</td>
<td><input type="text" name='email'></td>
</tr>
<tr>
<td class="linkeseite" valign="top">Posting:</td>
<td><textarea name='comments'></textarea></td>
</tr>
<tr>
<td> </td>
<td> </td>
</table>
<table border='0' width='285' class='tabelleeingabe' align='center'>
</tr>
<tr>
<td width='85'> </td>
<td align='center' width='200'>
<input type="submit" id="go" value="Senden"> <input type="reset" id="go" value="Löschen">
</td>
</tr>
</table>
</form>
<?php
$lines = file("eintraege.txt");
$total = count($lines);
$proseite = 10;
if (! isset($_GET['page']))
{ $_GET['page'] = 1;}
$seiten = ceil($total /$proseite);
for ($i = ($total - ($proseite*($_GET['page']-1))); $i >= ($total - (($proseite*$_GET['page'])-1)) ;$i--)
{
if (!isset($lines[$i-1])) {echo "";}
else {
$zeile = $lines[$i-1];
list($date,$name,$email,$ohne) = explode ("|--|", $zeile);
$suchen[0] = ":-o";
$suchen[1] = ":-(";
$suchen[2] = ":-p";
$suchen[3] = ":-g";
$suchen[4] = ":-D";
$suchen[5] = "|-)";
$suchen[6] = ":dev:";
$suchen[7] = ":love:";
$suchen[8] = ":rot:";
$suchen[9] = ":-)";
$suchen[10] = ":-|";
$ersetzungen[0] = " <img src='smileys/smile.bmp'> ";
$ersetzungen[1] = " <img src='smileys/traurig.bmp'> ";
$ersetzungen[2] = " <img src='smileys/zunge.bmp'> ";
$ersetzungen[3] = " <img src='smileys/gsfs.bmp'> ";
$ersetzungen[4] = " <img src='smileys/hlachen.gif'> ";
$ersetzungen[5] = " <img src='smileys/cool.bmp'> ";
$ersetzungen[6] = " <img src='smileys/teufel.bmp'> ";
$ersetzungen[7] = " <img src='smileys/love.bmp'> ";
$ersetzungen[8] = " <img src='smileys/rot.gif'> ";
$ersetzungen[9] = " <img src='smileys/grins.bmp'> ";
$ersetzungen[10] = " <img src='smileys/grimmig.bmp'> ";
$comments = str_ireplace($suchen, $ersetzungen, $ohne);
?>
<table border='0' width='400' style='border-collapse:collapse;'>
<tr>
<td width='280' height='20' valign='center' style='background-color:rgb(220,220,220); font-size:9pt; font-family:Arial;'><b><?=$name?></b> <a class='adresse' href='mailto:<?=$email?>'><?=$email?></a></td>
<td width='120' align='center' height='20' valign='center' style='background-color:rgb(220,220,220); font-family:Arial; font-size:9pt;'><?=$date?></td>
</tr>
<tr>
<td colspan='2' width='400' style='font-size:1pt; background-color:rgb(240,240,240);'> </td>
</tr>
<tr>
<td colspan='2' width='400' valign='top' style='background-color:rgb(240,240,240); font-size:9pt; font-family:Arial;'><?=$comments?></td>
</tr>
<tr>
<td colspan='2' width='400'> </td>
</tr>
</table>
<?php
}
}
$max = "10";
if (! $_GET['page'] > 0) {
$_GET['page'] = 1;
}
if (intval($total/$max)+1 < $_GET['page']) {
$_GET['page']=1;
}
if ($total >= $_GET['page']*$max) {
$lastrec = $_GET['page']*$max;
}
else {
$lastrec = (($_GET['page']-1)*$max) + ($total % $max);
}
$range= 2;
if ($_GET['page'] - $range > 1){
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=1\">1</a>\n";
}
if($_GET['page'] -1 > 0){
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=".($_GET['page']-1)."\"><<</a>\n";
}
if ($_GET['page'] - $range <= 0){
$start = 1;
}
else {
$start = $_GET['page'] - $range;
}
if ($_GET['page'] + $range > $total/$max){
if($total%$max > 0){
$ende = intval($total/$max) +1;
}
else{
$ende = intval($total/$max);
}
}
else {
$ende = $_GET['page'] + $range;
}
for ($i=$start; $i<= $ende; $i++) {
if ($i != $_GET['page']) {
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a>\n";
}
else {
echo "<span class=\"navizahl\">$i</span>";
}
print " ";
}
if ($_GET['page'] < intval($total/$max)){
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=".($_GET['page']+1)."\">>></a>\n";
}
if ( $page < ($total/$max) - $range) {
if($total%$max > 0){
$ende = intval($total/$max) +1;
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$ende\">$ende</a>\n";
}
else{
$ende = intval($total/$max);
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$ende\">$ende</a>\n";
}
}
?>
</body>
</html>