<?php

if($_GET['action'] != "" && !empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['message']) && ereg ("^[0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}$", $_POST['email']))
{
setcookie("spam_protection", "spam_protection", time()+500);
}

// Erstellen einer Rechenaufgabe

$Zahl_1 = intval(rand(1, 5));
$Zahl_2 = intval(rand(1, 5));

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<title>Lindenstrasse Fanclub</title>

<STYLE TYPE="text/css">
<!--

body{
 scrollbar-base-color: #ffffff;
 scrollbar-arrow-color: #16366F;

}
//-->
</STYLE>

</head>


<body bgcolor="#ffffff">

<?php

// Wenn das Formular gesendet werden soll...
if($_GET['action'] == "send")
{

// ...der Cookie gegen Spam nicht gesetzt ist...
if($_COOKIE["spam_protection"] != "spam_protection")
{

// ... und die Rechenaufgabe FALSCH geloest wurde...
if($_POST['number'] != md5($_POST['arithmetic']))
{

// ...dann eine Fehlermeldung ausgeben!
echo "<p><img src=\"stop.gif\" width=\"20\" height=\"20\" alt=\"Fehler\" /> <font style=\"color:black; font-family:Geneva, Arial, Helvetica, sans-serif; font-size:12px\"><b>Die Rechenaufgabe wurde falsch gel&ouml;st!</b></font></p>";

}

// Ansonsten, wenn die Rechenaufgabe RICHTIG geloest wurde stimmt...
if($_POST['number'] == md5($_POST['arithmetic']))
{

// ...und die eingegeben E-Mail Adresse in Wahrheit keine ist...
if(!ereg ("^[0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}$", $_POST['email']))
{

// ...dann eine Fehlermeldung ausgeben!
echo "<p>&nbsp;<font style=\"color:black; font-family:Geneva, Arial, Helvetica, sans-serif; font-size:12px\"><b>Die eingegebene E-Mail-Adresse ist ung&uuml;ltig!</b></font></p>";

}

// Ansonsten, wenn die eingegebene E-Mail Adresse auch wirklich eine ist...
if(ereg ("^[0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}$", $_POST['email']))
{

// ...und kein Feld leer ist...
if(!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['message'])  && !empty($_POST['street'])  && !empty($_POST['city']) && !empty($_POST['birthday']) && !empty($_POST['fan']) && !empty($_POST['member']))
{

// dann den ganzen Muell von Spambots oder auch menschlichen Spammern entfernen...
$name          = nl2br(stripslashes(htmlspecialchars($_POST['name'])));
$IP            = getenv("REMOTE_ADDR");

$absender      = preg_replace( "/[^a-z0-9 !?:;,.\/_\-=+@#$&\*\(\)]/im", "", $_POST['email'] );
$absender      = preg_replace( "/(content-type:|bcc:|cc:|to:|from:)/im", "", $absender );

$nachricht     = nl2br(stripslashes(htmlspecialchars($_POST['message'])));

$steet         = nl2br(stripslashes(htmlspecialchars($_POST['steet'])));

$city          = nl2br(stripslashes(htmlspecialchars($_POST['city'])));

$birthday      = nl2br(stripslashes(htmlspecialchars($_POST['birthday'])));

$fan           = nl2br(stripslashes(htmlspecialchars($_POST['fan'])));

$date          = $_POST['date'];

// ...die Nachricht, die Sie erhalten moechten, wenn eine neue Nachricht an Sie versandt wurde, definieren...
$mailnachricht = "Hallo!\n\nEs ist eine neue Anmeldung fŸr den Listra-Fans Fanclub eingetroffen:\n\n---------------------------------------------\n\nName:\n$name\n\nIP:\n$IP\n\nE-Mail:\n$absender\n\nStrasse:\n$steet\n\nPLZ und Wohnort:\n$city\n\nGeburtstag:\n$birthday\n\Anmeldedatum:\n$date\n\n$name \n\nMfG\nBotty ;-)";

// ...an Sie verschicken...
mail("fanclub@muster.de", "Anmeldung zum Listra-Fans Fanclub", $mailnachricht, "From: $name <$absender>");

// ...und dem Benutzer sagen, dass alles glatt lief!
echo "<p>&nbsp;<font style=\"color:black; font-family:Geneva, Arial, Helvetica, sans-serif; font-size:12px\"><b>Vielen Dank f&uuml;r Deine Nachricht!</b> Ich lasse Dir umgehend eine Antwort zukommen.</font></p>";

}

// Wenn nicht alle Felder ausgefuellt wurden, dann...
else

{

// eine Fehlermeldung ausgeben!
echo "<p>&nbsp;<font style=\"color:black; font-family:Geneva, Arial, Helvetica, sans-serif; font-size:12px\"><b>Bitte f&uuml;llen Sie alle Felder aus!</b></font></p>";

}

}

}

}

}

?>

<form id="form" name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?action=send">

<div align="center">

<center>

<b><font face="Arial" size="3" color="#000000">Anmeldung<br>
&nbsp;</font></b><table width="407" cellpadding="2" cellspacing="0" style="background-color:#ffffff; font-family:Geneva, Arial, Helvetica, sans-serif; font-size:12px; border-collapse:collapse" bordercolor="#111111">

<tr>

<td width="133" style="background-color:#ffffff" align="left">
<strong><font color="#000000"><span style="font-size: 8pt">Dein </span> </font></strong>
<font color="#000000">
<strong><span style="font-size: 8pt">Vor-/Nachname:</span></strong></font></td>

<td width="14">

<input name="name" type="text" id="name" style="background-color:#ffffff; color: #000000; font-size:11px; font-family:Geneva, Arial, Helvetica, sans-serif; border : 1px solid #000000; width:186px" value="<?php echo $_POST['name']; ?>" size="20"/></td>
</tr>

<tr>

<td width="133" style= "background-color:#ffffff" align="left">
<font color="#000000" style="font-size: 8pt">
<strong>Deine E-Mail Adresse:</strong></font></td>

<td width="14">

<input name="email" type="text" id="email" style="background-color:#ffffff; color: #000000; font-size:11px; font-family:Geneva, Arial, Helvetica, sans-serif; border : 1px solid #000000; width:186px" value="<?php echo $_POST['email']; ?>" size="20"/></td>
</tr>

<tr>

<td width="133" style= "background-color:#ffffff" align="left">
<font color="#000000" style="font-size: 8pt">
<strong>Strasse:</strong></font></td>

<td width="14">

<input name="street" type="text" id="street" style="background-color:#ffffff; color: #000000; font-size:11px; font-family:Geneva, Arial, Helvetica, sans-serif; border : 1px solid #000000; width:186px" value="<?php echo $_POST['street']; ?>" size="20"/></td>
</tr>

<tr>

<td width="133" style= "background-color:#ffffff" align="left">
<font color="#000000" style="font-size: 8pt">
<strong>PLZ und Ort:</strong></font></td>

<td width="14">

<input name="city" type="text" id="city" style="background-color:#ffffff; color: #000000; font-size:11px; font-family:Geneva, Arial, Helvetica, sans-serif; border : 1px solid #000000; width:186px" value="<?php echo $_POST['city']; ?>" size="20"/></td>
</tr>

<tr>

<td width="133" style= "background-color:#ffffff" align="left">
<font color="#000000" style="font-size: 8pt">
<strong>Geburtsdatum:</strong></font></td>

<td width="14">

<input name="birthday" type="text" id="birthday" style="background-color:#ffffff; color: #000000; font-size:11px; font-family:Geneva, Arial, Helvetica, sans-serif; border : 1px solid #000000; width:186px" value="<?php echo $_POST['birthday']; ?>" size="20"/></td>
</tr>

<tr>

<td width="133" style= "background-color:#ffffff" align="left">
<font color="#000000" style="font-size: 8pt">
<strong>Ich bin Fan, weil:</strong></font></td>

<td width="14">

<textarea name="fan" id="fan" style="background-color:#ffffff; color: #000000; font-size:11px; font-family:Geneva, Arial, Helvetica, sans-serif; border : 1px solid #000000; width:186px; height:100px" rows="4" cols="15"><?php echo $_POST['fan']; ?></textarea>

</td>
</tr>

<tr>

<td width="133" style= "background-color:#ffffff" align="left">
<font color="#000000" style="font-size: 8pt">
<strong>Das möchte ich gerne mitteilen:</strong></font></td>

<td width="14">

<textarea name="member" id="member" style="background-color:#ffffff; color: #000000; font-size:11px; font-family:Geneva, Arial, Helvetica, sans-serif; border : 1px solid #000000; width:186px; height:100px" rows="4" cols="15"><?php echo $_POST['member']; ?></textarea>

</td>
<tr>

<td width="133" style= "background-color:#ffffff" align="left">
<font color="#000000" style="font-size: 8pt">
<strong>Datum:</strong></font></td>

<td width="14">

<input name="date" type="text" id="date" style="background-color:#ffffff; color: #000000; font-size:11px; font-family:Geneva, Arial, Helvetica, sans-serif; border : 1px solid #000000; width:186px" value="<?php echo date(d.m.Y); ?>" size="20" readonly="true"/></td>
</tr>

<tr>

<td width="133" style="background-color:#ffffff" align="left">

<font color="#000000" style="font-size: 8pt">

<strong>Wieviel ist <?php echo $Zahl_1; ?> plus <?php echo $Zahl_2; ?>?</strong>
</font>

</td>

<td width="14">

<input name="number" type="hidden" id="number"  value="<?php echo md5(( $Zahl_1 + $Zahl_2 )); ?>"/>
<input name="arithmetic" type="text" id="arithmetic" style="background-color:#ffffff; font-size:11px; color: #000000; font-family:Geneva, Arial, Helvetica, sans-serif; border : 1px solid #000000; width:186px" onfocus="if(this.value=='Das Ergebnis bitte hier hinein...')this.value=''" onblur="if(this.value=='')this.value='Das Ergebnis bitte hier hinein...'" value="Das Ergebnis bitte hier hinein..." size="20"/>

</td>

</tr>

<tr>

<td style="background-color:#ffffff;" width="133">
&nbsp;</td>

<td width="14">

<?php

// Wenn KEIN Cookie gegen Spam gesetzt wurde, dann soll der "Senden"-Button anklickbar sein
if($_COOKIE["spam_protection"] != "spam_protection")
{

?>

<input name="submit" type="submit" id="submit" value="Senden" style="background-color: #ffffff; color: #000000; font-size:11px; font-family: Verdana; border: 1px solid #000000; font-weight:bold; "><p align="left">&nbsp;<?php

}

// Wenn aber ein Cookie gegen Spam gesetzt wurde, dann soll der "Senden"-Button blockiert werden
if($_COOKIE["spam_protection"] == "spam_protection")
{

?>&nbsp;

<?php

}

?>

</td>

</tr>

</table>

  </center>
</div>

</form>

</body>

</html>