<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
ob_start();
session_start();
$cfg['url'] = "";
$cfg['naam'] = "";
$cfg['email'] = "";
$cfg['spam'] = 10;
$cfg['text'] = TRUE;
$cfg['input'] = TRUE;
$cfg['HTML'] = TRUE;
$cfg['CAPTCHA'] = FALSE;
// E-mail Checker / Validator
function checkmail($email)
{
if(eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$", $email))
{
return TRUE;
}
return FALSE;
}
$formulier = TRUE;
if(!isset($_COOKIE['formulier']))
{
if(isset($_POST['wis']) && ($_SERVER['REQUEST_METHOD'] == "POST"))
{
foreach($_POST as $key => $value)
{
unset($value);
}
header("Location: ".$_SERVER['PHP_SELF']."");
}
if(isset($_POST['verzenden']) && ($_SERVER['REQUEST_METHOD'] == "POST"))
{
$aFout = array();
$naam = trim($_POST['naam']);
$email = trim($_POST['email']);
$leeftijd = trim($_POST['leeftijd']);
$character = trim($_POST['character']);
$xfire = trim($_POST['xfire']);
$steam = trim($_POST['steam']);
$onderwerp = trim($_POST['onderwerp']);
$bericht = trim($_POST['bericht']);
if($cfg['CAPTCHA'])
{
$code = $_POST['code'];
}
if(empty($naam) || (strlen($naam) < 3) || eregi("[<>]", $naam) )
{
$aFout[] = "Er is geen naam ingevuld.";
unset($naam);
$fout['text']['naam'] = TRUE;
$fout['input']['naam'] = TRUE;
}
if(empty($email))
{
$aFout[] = "Er is geen e-mail adres ingevuld.";
unset($email);
$fout['text']['email'] = TRUE;
$fout['input']['email'] = TRUE;
}
elseif(checkmail($email) == 0)
// Wanneer je PHP 5.2 > gebruikt
//elseif(!filter_var($email, FILTER_VALIDATE_EMAIL))
{
$aFout[] = "Er is geen correct e-mail adres ingevuld.";
unset($email);
$fout['text']['email'] = TRUE;
$fout['input']['email'] = TRUE;
}
if(empty($onderwerp))
{
$aFout[] = "Er is geen onderwerp ingevuld.";
unset($onderwerp);
$fout['text']['onderwerp'] = TRUE;
$fout['input']['onderwerp'] = TRUE;
}
if(empty($leeftijd))
{
$aFout[] = "Er is geen leeftijd ingevuld.";
unset($leeftijd);
$fout['text']['leeftijd'] = TRUE;
$fout['input']['leeftijd'] = TRUE;
}
if(empty($xfire))
{
$aFout[] = "Er is geen xfire ingevuld.";
unset($xfire);
$fout['text']['xfire'] = TRUE;
$fout['input']['xfire'] = TRUE;
}
if(empty($steam))
{
$aFout[] = "Er is geen steam ingevuld.";
unset($steam);
$fout['text']['steam'] = TRUE;
$fout['input']['steam'] = TRUE;
}
if(empty($character))
{
$aFout[] = "Er is geen character ingevuld. (In game naam)";
unset($character);
$fout['text']['character'] = TRUE;
$fout['input']['character'] = TRUE;
}
if(empty($bericht))
{
$aFout[] = "Er is geen bericht ingevuld.";
unset($bericht);
$fout['text']['bericht'] = TRUE;
$fout['input']['bericht'] = TRUE;
}
if($cfg['CAPTCHA'])
{
if(strtoupper($code) != $_SESSION['captcha_code'])
{
$aFout[] = "Er is geen correcte code ingevuld.";
$fout['text']['code'] = TRUE;
$fout['input']['code'] = TRUE;
}
}
if(!$cfg['text'])
{
unset($fout['text']);
}
if(!$cfg['input'])
{
unset($fout['input']);
}
if(!empty( $aFout ))
{
$errors = '
<div id="errors">
<ul>';
foreach($aFout as $sFout)
{
$errors .= " <li>".$sFout."</li>\n";
}
$errors .= "</ul>
</div>";
}
else
{
$formulier = FALSE;
if($cfg['HTML'])
{
// Headers
$headers = "From: \"Contact Formulier\" <".$cfg['email'].">\r\n";
$headers .= "Reply-To: \"".$naam."\" <".$email.">\n";
$headers .= "Return-Path: Mail-Error <".$cfg['email'].">\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$bericht = '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
</head>
<body>
<br />
<b>Naam:</b> '.$naam.'<br />
<b>Email:</b> <a href="mailto:'.$email.'">'.$email.'</a><br />
<b>Leeftijd:</b> '.$leeftijd.'<br />
<b>Character:</b> '.$character.'<br />
<b>xfire:</b> '.$xfire.'<br />
<b>Steam:</b> '.$steam.'<br />
<br />
<b>Bericht:</b><br />
'.$bericht.'
<br />
<br />
<br />
--------------------------------------------------------------------------<br />
<b>Datum:</b> '.date("d-m-Y @ H:i:s").'<br />
<b>IP:</b> <a href=\"http://sunny.nic.com/cgi-bin/whois?domain='.$_SERVER['REMOTE_ADDR'].'\">'.$_SERVER['REMOTE_ADDR'].'</a><br />
<b>Host:</b> '.gethostbyaddr($_SERVER['REMOTE_ADDR']).'<br />
</body>
</html>';
}
else
{
$bericht_wrap = wordwrap ($bericht, 40, "\n", 1);
// Headers
$headers = "From: \"Contact Formulier\" <".$cfg['email'].">\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset='iso-8859-1'\n";
// Bericht
$message = "Naam: ".$naam." \n";
$message .= "E-mail: ".$email." \n";
$message .= "Leeftijd: ".$leeftijd." \n";
$message .= "Character: ".$character." \n";
$message .= "Xfire: ".$xfire." \n";
$message .= "Steam: ".$steam." \n";
$message .= "Bericht:\n".$bericht_wrap." \n ";
$message .= " \n ";
$message .= "Datum: ".date("d-m-Y H:i:s")." \n";
$message .= "------------------------------------------------------- \n ";
$message .= "IP: ".$_SERVER['REMOTE_ADDR']." \n ";
$message .= "Host: ".gethostbyaddr($_SERVER['REMOTE_ADDR'])." \n ";
}
if(mail($cfg['email'], "[Contact] ".$onderwerp, $bericht, $headers))
{
if(isset($_POST['stuurkopie']))
{
$headers = "From: \"Contact Formulier\" <".$email.">\r\n";
$headers .= "Reply-To: \"".$naam."\" <".$email.">\n";
$headers .= "Return-Path: Mail-Error <".$email.">\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
mail($email, "[Contact] ".$onderwerp, $bericht, $headers);
}
unset($naam, $email, $onderwerp, $bericht);
setcookie("formulier", 1, time() + ( $cfg['spam'] * 60 ) );
echo "
<p>
Uw bericht is succesvol verzonden, er word zo snel mogelijk gereageerd.<br />
<br />
Met vriendelijke groeten,<br />
<b>".$cfg['naam']."</b>
</p>
";
}
else
{
echo "Er is een fout opgetreden bij het verzenden van de email";
}
header("refresh:3;url=".$cfg['url']."");
}
}
if($formulier)
{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="style.css" rel="stylesheet" type="text/css" />
<title>Join Us2</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Language" content="nl" />
</head>
<body bgcolor='#2C2C2C' text='#33FF00'>
<table align="center" width="400px">
<td><img src="logo.png" width="auto" height="auto" />
<div id="container">
<?php
if(isset($errors)) {
echo $errors;
}
?>
<h3>Contact Formulier</h3>
<form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
<p>
<label <?php if(isset($fout['text']['naam'])) { echo 'class="fout"'; } ?>>Naam:</label>
<input type="text" id="naam" name="naam" maxlength="30" <?php if(isset($fout['input']['naam'])) { echo 'class="fout"'; } ?> value="<?php if (!empty($naam)) { echo stripslashes($naam); } ?>" /><br />
<label <?php if(isset($fout['text']['email'])) { echo 'class="fout"'; } ?>>Email:</label>
<input type="text" id="email" name="email" maxlength="255" <?php if(isset($fout['input']['email'])) { echo 'class="fout"'; } ?> value="<?php if (!empty($email)) { echo stripslashes($email); } ?>" /><br />
<label <?php if(isset($fout['text']['onderwerp'])) { echo 'class="fout"'; } ?>>Onderwerp:</label>
<input type="text" id="onderwerp" name="onderwerp" maxlength="40" <?php if(isset($fout['input']['onderwerp'])) { echo 'class="fout'; } ?> value="<?php if (!empty($onderwerp)) { echo stripslashes($onderwerp); } ?>" /><br />
<label <?php if(isset($fout['text']['leeftijd'])) { echo 'class="fout"'; } ?>>Leeftijd:</label>
<input type="text" id="leeftijd" name="leeftijd" maxlength="2" <?php if(isset($fout['input']['leeftijd'])) { echo 'class="fout'; } ?> value="<?php if (!empty($leeftijd)) { echo stripslashes($leeftijd); } ?>" /><br />
<label <?php if(isset($fout['text']['character'])) { echo 'class="fout"'; } ?>>Character:</label>
<input type="text" id="character" name="character" maxlength="40" <?php if(isset($fout['input']['character'])) { echo 'class="fout'; } ?> value="<?php if (!empty($character)) { echo stripslashes($character); } ?>" /><br />
<label <?php if(isset($fout['text']['xfire'])) { echo 'class="fout"'; } ?>>Xfire:</label>
<input type="text" id="xfire" name="xfire" maxlength="40" <?php if(isset($fout['input']['xfire'])) { echo 'class="fout'; } ?> value="<?php if (!empty($xfire)) { echo stripslashes($xfire); } ?>" /><br />
<label <?php if(isset($fout['text']['steam'])) { echo 'class="fout"'; } ?>>Steam:</label>
<input type="text" id="steam" name="steam" maxlength="40" <?php if(isset($fout['input']['steam'])) { echo 'class="fout'; } ?> value="<?php if (!empty($steam)) { echo stripslashes($steam); } ?>" /><br />
<label <?php if(isset($fout['text']['bericht'])) { echo 'class="fout"'; } ?>>Bericht:</label>
<textarea id="bericht" name="bericht" <?php if(isset($fout['input']['bericht'])) { echo 'class="fout"'; } ?> cols="35" rows="6"><?php if (!empty($bericht)) { echo stripslashes($bericht); } ?></textarea><br />
<?php
if($cfg['CAPTCHA'])
{
?>
<label></label>
<img src="captcha.php" alt="" /><br />
<label <?php if(isset($fout['text']['code'])) { echo 'class="fout"'; } ?>>Code:</label>
<input type="text" id="code" name="code" maxlength="4" size="4" <?php if(isset($fout['input']['code'])) { echo 'class="captcha fout"'; } ?> /><br />
<?php
}
?>
<label for="stuurkopie">Stuur mij een kopie</label><input type="checkbox" id="stuurkopie" name="stuurkopie" value="1" /><br />
<label></label>
<input type="submit" id="verzenden" name="verzenden" value="verzenden" />
<input type="submit" id="wis" name="wis" value="Wis velden" />
</p>
</form>
</div>
</td>
</table>
</body>
</html>
<?php
}
}
else
{
echo "
<p>
U kunt maar eens in de ".$cfg['spam']." minuten een e-mail versturen!<br />
U wordt nu automatisch doorgestuurd.
</p>";
header("refresh:3;url=".$cfg['url']."");
}
?>