Na hier isser... Grüsse Ute
<?php
$numFriends = 2;
$webmasterEmail = "abc@xyz.de";
$sendNotification = 1;
$subject = "Seiten - Empfehlung von [SENDER_NAME] ([SENDER_EMAIL])";
$recommendMessage = <<<EOD
[REFPAGE]
EOD;
$customMessage = <<<EOD
EOD;
$sendAsHtml = 0;
error_reporting(E_ERROR); // only stop for critical errors
/* start main */
if(!isset($_POST["action"])) {
show_form();
} else {
//begin error checking
if(trim($_POST['senderName']) == "") {
$error[] = "Sie haben Ihren Namen nicht eingefügt.<br>";
}
$_POST['senderEmail'] = trim($_POST['senderEmail']);
if(!isValid($_POST['senderEmail'])) {
$error[] = "Bitte überprüfen Sie Ihre Email - Adresse.<br>";
unset($_POST['senderEmail']);
}
$validRecips = check_valid($_POST['friend']);
if($validRecips == FALSE) {
$error[] = "Bitte überprüfen Sie die Empfänger Email - Adresse(n).<br>";
}
if($error) {
echo "\n";
foreach($error as $oneError) {
echo "$oneError<br>\n";
}
echo "\n";
echo show_form();
} else { //no error
$subject = str_replace("[SENDER_NAME]", $_POST['senderName'], $subject);
$subject = str_replace("[SENDER_EMAIL]", $_POST['senderEmail'], $subject);
$message = trim($_POST['recommendMessage']) . "\n\n" . "\n\n" . $_POST['customMessage'] . "\n\n\n____________________________________________________________________\n"
. $_POST['senderName'] . " hat Ihnen diese Nachricht geschickt von http://www.xyz.de";
if($_POST['toself'] == TRUE) {
array_push($validRecips, $_POST['senderEmail']);
}
$content = ($sendAsHtml == TRUE ? "text/html" : "text/plain");
$message = stripslashes($message);
$headers = "From: " . $_POST['senderName'] . " <" . $_POST['senderEmail'] . ">\r\n";
$headers .= "Content-Type: $content";
foreach($validRecips as $recip) {
$friends .= $recip . " ";
@mail($recip, $subject, $message, $headers);
echo "Nachricht gesendet an $recip<br>\n";
}
if($sendNotification) {
$nMessage = trim($_POST['recommendMessage']) . "\n\n" . $_POST['senderName'] . " (" . $_POST['senderEmail'] . ") " . $_SERVER['REMOTE_ADDR'] . " gesendet an " . count($validRecips) . " friends ($friends).";
@mail($webmasterEmail, "Seitenempfehlung", $nMessage, "From: $webmasterEmail");
}
}
}
function check_valid($list)
{
global $errorCode;
$numElements = sizeof($list);
$goodEmails = array();
foreach($list as $single) {
if(isValid($single)) {
$goodEmails[] = $single;
}
}
if(!empty($goodEmails)) {
return array_unique($goodEmails);
} else {
return FALSE;
}
}
function show_form()
{
global $numFriends, $validRecips, $recommendMessage, $customMessage;
$senderName = (!isset($_GET['sn']) ? $_POST['senderName'] : urldecode($_GET['sn']));
$senderEmail = (!isset($_GET['se']) ? $_POST['senderEmail'] : urldecode($_GET['se']));
echo "<form method=\"POST\" action=\"".$_SERVER['PHP_SELF']."\">\n"
."<input type=\"hidden\" name=\"action\" value=\"submit\">\n"
."<table border=0 align=\"center\" cellpadding=0 cellspacing=0>\n"
."\t<tr>\n"
."\t\t<td>Ihr Name:</td><td><input type=\"text\" name=\"senderName\" value=\"$senderName\" size=30 class=\"input1\"></td>\n"
."\t</tr>\n"
."\t<tr>\n"
."\t\t<td>Ihre Email:</td><td><input type=\"text\" name=\"senderEmail\" value=\"$senderEmail\" size=30 class=\"input1\"></td>\n"
."\t</tr>\n";
for($i = 1; $i <= $numFriends; $i++) {
echo "\t<tr>\n\t\t<td>Email Empfänger $i:</td><td><input type=\"text\" name=\"friend[]\" value=\"".$validRecips[$i - 1]."\" size=30 class=\"input1\"></td>\n\t</tr>\n";
}
if (strpos($recommendMessage, "[REFPAGE]") !== FALSE) {
if (!isset($_SERVER['HTTP_REFERER']))
$recommendMessage = str_replace("[REFPAGE]", "(Referrer Unavailable)", $recommendMessage);
else
$recommendMessage = str_replace("[REFPAGE]", $_SERVER['HTTP_REFERER'], $recommendMessage);
}
echo "\t<tr>\n"
."\t\t<td colspan=2 class=\"none\"><textarea name=\"recommendMessage\" cols=66 rows=2 readonly onFocus=\"this.blur()\" class=\"input1\">$recommendMessage</textarea></td>\n"
."\t</tr>\n"
."\t<tr>\n"
."\t\t<td colspan=2><br>Persönliche Nachricht<br><textarea name=\"customMessage\" cols=66 rows=5 class=\"input1\">$customMessage</textarea></td>\n"
."\t</tr>\n"
."\t<tr>\n\t\t<td colspan=2><input type=\"checkbox\" name=\"toself\"> Kopie der Nachricht per Email an Sie schicken<br><br></td>\n\t</tr>\n"
."\t<tr>\n\t\t<td colspan=2 align=\"center\"><input type=\"submit\" value=\"senden\" class=\"input2\"> <input type=\"reset\" value=\"löschen\" class=\"input2\"></td>\n\t</tr>\n"
."\t<tr>\n\t\t<td colspan=2><br>Die hier eingegebenen Daten werden von uns nur dazu verwendet, die Email in Ihrem Namen zu versenden. Es erfolgt keine Weitergabe an Dritte und keine Speicherung Ihrer Angaben.<br><br><a href=\"javascript:window.close()\" class=\"link1\">Fenster schliessen</a></td>\n\t</tr>\n"
."</table>\n"
."</form>\n\n";
}
function isValid($email)
{
return eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,4}$", $email);
}
?>
<?php
$numFriends = 2;
$webmasterEmail = "abc@xyz.de";
$sendNotification = 1;
$subject = "Seiten - Empfehlung von [SENDER_NAME] ([SENDER_EMAIL])";
$recommendMessage = <<<EOD
[REFPAGE]
EOD;
$customMessage = <<<EOD
EOD;
$sendAsHtml = 0;
error_reporting(E_ERROR); // only stop for critical errors
/* start main */
if(!isset($_POST["action"])) {
show_form();
} else {
//begin error checking
if(trim($_POST['senderName']) == "") {
$error[] = "Sie haben Ihren Namen nicht eingefügt.<br>";
}
$_POST['senderEmail'] = trim($_POST['senderEmail']);
if(!isValid($_POST['senderEmail'])) {
$error[] = "Bitte überprüfen Sie Ihre Email - Adresse.<br>";
unset($_POST['senderEmail']);
}
$validRecips = check_valid($_POST['friend']);
if($validRecips == FALSE) {
$error[] = "Bitte überprüfen Sie die Empfänger Email - Adresse(n).<br>";
}
if($error) {
echo "\n";
foreach($error as $oneError) {
echo "$oneError<br>\n";
}
echo "\n";
echo show_form();
} else { //no error
$subject = str_replace("[SENDER_NAME]", $_POST['senderName'], $subject);
$subject = str_replace("[SENDER_EMAIL]", $_POST['senderEmail'], $subject);
$message = trim($_POST['recommendMessage']) . "\n\n" . "\n\n" . $_POST['customMessage'] . "\n\n\n____________________________________________________________________\n"
. $_POST['senderName'] . " hat Ihnen diese Nachricht geschickt von http://www.xyz.de";
if($_POST['toself'] == TRUE) {
array_push($validRecips, $_POST['senderEmail']);
}
$content = ($sendAsHtml == TRUE ? "text/html" : "text/plain");
$message = stripslashes($message);
$headers = "From: " . $_POST['senderName'] . " <" . $_POST['senderEmail'] . ">\r\n";
$headers .= "Content-Type: $content";
foreach($validRecips as $recip) {
$friends .= $recip . " ";
@mail($recip, $subject, $message, $headers);
echo "Nachricht gesendet an $recip<br>\n";
}
if($sendNotification) {
$nMessage = trim($_POST['recommendMessage']) . "\n\n" . $_POST['senderName'] . " (" . $_POST['senderEmail'] . ") " . $_SERVER['REMOTE_ADDR'] . " gesendet an " . count($validRecips) . " friends ($friends).";
@mail($webmasterEmail, "Seitenempfehlung", $nMessage, "From: $webmasterEmail");
}
}
}
function check_valid($list)
{
global $errorCode;
$numElements = sizeof($list);
$goodEmails = array();
foreach($list as $single) {
if(isValid($single)) {
$goodEmails[] = $single;
}
}
if(!empty($goodEmails)) {
return array_unique($goodEmails);
} else {
return FALSE;
}
}
function show_form()
{
global $numFriends, $validRecips, $recommendMessage, $customMessage;
$senderName = (!isset($_GET['sn']) ? $_POST['senderName'] : urldecode($_GET['sn']));
$senderEmail = (!isset($_GET['se']) ? $_POST['senderEmail'] : urldecode($_GET['se']));
echo "<form method=\"POST\" action=\"".$_SERVER['PHP_SELF']."\">\n"
."<input type=\"hidden\" name=\"action\" value=\"submit\">\n"
."<table border=0 align=\"center\" cellpadding=0 cellspacing=0>\n"
."\t<tr>\n"
."\t\t<td>Ihr Name:</td><td><input type=\"text\" name=\"senderName\" value=\"$senderName\" size=30 class=\"input1\"></td>\n"
."\t</tr>\n"
."\t<tr>\n"
."\t\t<td>Ihre Email:</td><td><input type=\"text\" name=\"senderEmail\" value=\"$senderEmail\" size=30 class=\"input1\"></td>\n"
."\t</tr>\n";
for($i = 1; $i <= $numFriends; $i++) {
echo "\t<tr>\n\t\t<td>Email Empfänger $i:</td><td><input type=\"text\" name=\"friend[]\" value=\"".$validRecips[$i - 1]."\" size=30 class=\"input1\"></td>\n\t</tr>\n";
}
if (strpos($recommendMessage, "[REFPAGE]") !== FALSE) {
if (!isset($_SERVER['HTTP_REFERER']))
$recommendMessage = str_replace("[REFPAGE]", "(Referrer Unavailable)", $recommendMessage);
else
$recommendMessage = str_replace("[REFPAGE]", $_SERVER['HTTP_REFERER'], $recommendMessage);
}
echo "\t<tr>\n"
."\t\t<td colspan=2 class=\"none\"><textarea name=\"recommendMessage\" cols=66 rows=2 readonly onFocus=\"this.blur()\" class=\"input1\">$recommendMessage</textarea></td>\n"
."\t</tr>\n"
."\t<tr>\n"
."\t\t<td colspan=2><br>Persönliche Nachricht<br><textarea name=\"customMessage\" cols=66 rows=5 class=\"input1\">$customMessage</textarea></td>\n"
."\t</tr>\n"
."\t<tr>\n\t\t<td colspan=2><input type=\"checkbox\" name=\"toself\"> Kopie der Nachricht per Email an Sie schicken<br><br></td>\n\t</tr>\n"
."\t<tr>\n\t\t<td colspan=2 align=\"center\"><input type=\"submit\" value=\"senden\" class=\"input2\"> <input type=\"reset\" value=\"löschen\" class=\"input2\"></td>\n\t</tr>\n"
."\t<tr>\n\t\t<td colspan=2><br>Die hier eingegebenen Daten werden von uns nur dazu verwendet, die Email in Ihrem Namen zu versenden. Es erfolgt keine Weitergabe an Dritte und keine Speicherung Ihrer Angaben.<br><br><a href=\"javascript:window.close()\" class=\"link1\">Fenster schliessen</a></td>\n\t</tr>\n"
."</table>\n"
."</form>\n\n";
}
function isValid($email)
{
return eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,4}$", $email);
}
?>
Kommentar