1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
|
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">Dein Kommentar:<br>
<textarea cols="55" rows="4" name="comment">
</textarea><br>
Dein Name:<input type="text" name="name"><br>
Deine Email: <input type="text" name="Email"><br>
Homepage :<input type="text" name="home" value="http://"><br>
<input type="hidden" name="uw" value="<?php echo time(); ?>">
<input type="submit" value="Eintragen"></form>
<h3>Bisherige Meinungen:</h3>
<div style="height:250px; width:600px; overflow:auto">
<?php
function no_reload()
{
$gleichheit = false;
if (isset($_POST["uw"])) {
$datei = "unique.txt";
$fp = fopen($datei, "r+");
$aw = fgets($fp, 30);
if ($aw == $_POST["uw"]) {
$gleichheit = true;
}
rewind($fp);
fputs($fp, $_POST["uw"]);
fclose($fp);
}
return $gleichheit;
}
$unique = no_reload();
// Dateiname in Variable speichern
$datei = "comment.txt";
// Variable Kommentar gesetzt? Name und E-Mail nicht leer?
if (!empty($_POST["comment"]) && !empty($_POST["name"]) && !empty($_POST["Email"]) && !$unique) {
$comment = $_POST["comment"];
$name = $_POST["name"];
$Email = $_POST["Email"];
$home = $_POST["home"];
// Datei wird im Lese- und Schreib-Modus geöffnet
$fp = fopen($datei, "r+");
// alte Daten herauslesen und in $old sichern
$old = fread($fp,filesize($datei));
// E-Mail-Link entsteht
$Email = "<a href='mailto:$Email'>Email</a>";
$home = "<a href='$home' target='_blank'>Homepage</a>";
// Datum ermitteln und formatieren
$datum = date("j.n.Y");
// HTML-Zeichen maskieren, Slashes weg, Umbrüche erhalten
$comment = htmlspecialchars($comment);
$comment = stripslashes($comment);
$comment = nl2br($comment);
// Meinung zusammensetzen
$meinung="<p><b>$name</b>($home) ($Email) schrieb am " .
"<i>$datum</i>:<br>$comment</p>\n";
// Dateizeiger marschiert an den Anfang
rewind($fp);
// neue Meinung vor alte in Datei schreiben
fputs($fp, "$meinung \n $old");
// Datei schließen
fclose($fp);
}
readfile($datei);
?> |