<script type="text/javascript">
function checkform()
{
if (document.Form.User.value.length < 3) {
alert("Es wurde noch kein Name eingegeben!")
document.Form.User.focus();
return false} else if (document.Form.Comment.value.length < 20) {
alert("Es wurde noch kein Kommentar eingegeben!")
document.Form.Comment.focus();
return false} else if (document.Form.Comment.value.length > 250) {
alert("Dein Kommentar ist zu lang!\rMaximal 250 Zeichen.")
document.Form.Comment.focus();
return false} else {
document.Form.elements["absenden1"].value="gesendet";
}
document.Form.elements["absenden1"].disabled="disabled";
return true
}
</script>
<form name="Form" action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post" onSubmit="return checkform();">
<?php
$mailto = "support@e-hahn.de";
if ($_POST) {
$Page = $_POST["Page"];
$datum = date("d.m.y, H:i",time());
$User = $_POST["User"];
$Mail = $_POST["eMail"];
$Comment = $_POST["Comment"];
if ($Page !="" && $User !="" && $Comment !="") {
$file = "comments/".$Page.".txt";
// Kommentar schreiben
$fp = fopen($file,"a+");
fputs($fp,"
[b]$User[/b] ($datum):
$Comment</p>\n");
fclose($fp);
}
// E-Mail versenden
$betreff = "Neuer Kommentar";
$text = "Datum: $datum - Seite: \"$Page\" - Autor: $User\nE-Mail: $eMail\n\nKommentar: $Comment\r";
@mail($mailto,$betreff,$text,"From: ".$mailto);
}
?>
<table>
<tr>
<td colspan="2">[b]Kommentar schreiben:[/b]
<textarea style="width: 99%" rows="4" cols="21" name="Comment"></textarea>
</td>
</tr>
<tr>
<td style="width: 25%"><input type="text" name="User" size="28"></td>
<td style="width: 75%">Name</td>
</tr>
<tr>
<td style="width: 25%"><input type="text" name="eMail" size="28"></td>
<td style="width: 75%">E-Mail (wird nicht veröffentlicht)</td>
</tr>
<tr>
<td colspan="2"><input class="button" type="submit" name="sendfeedback" value="Speichern" /></td>
</tr>
</table>
<?php
// Dateiname ermitteln
$titel=explode("/","$_SERVER[PHP_SELF]");
$file=explode('.',ucfirst($titel[count($titel)-1]));
echo " <input type='hidden' name='Page' value='".$file[0]."'>\r";
?>
<div id="Comments">
<?php
// Kommentarausgabe
$ausgabe = "comments/".$file[0].".txt";
if(file_exists($ausgabe)) {
readfile($ausgabe);
}
else {
echo "Es sind noch keine Kommentare vorhanden.";
}
?>
</div>
</div>
</form>