Bardzo fajny i przeze mnie spolszczony panelik.
Poprawki w kodzie autorstwa Grzesia ;)
Wyglada dobrze i co wazne, dziala bardzo dobrze:
Kod:
openside("Poleć nas!");
$numFriends = 1;
$webmasterEmail = "";
$returnPage = "http://twoja.strona.pl";
$sendNotification = 0;
$subject = "[SENDER_NAME] ([SENDER_EMAIL])";
$recommendMessage = <<<EOD
EOD;
$customMessage = <<<EOD
EOD;
$sendAsHtml = 0;
$htmlHeader = <<<EOD
EOD;
error_reporting(E_ERROR);
/* start main */
if(!isset($_POST["action"])) {
if($useHeader) include($headerFile);
show_form();
if($useFooter) include($footerFile);
} else {
//begin error checking
if(trim($_POST['senderName']) == "") {
$error[] = "Something is wrong...";
}
$_POST['senderEmail'] = trim($_POST['senderEmail']);
if(!isValid($_POST['senderEmail'])) {
$error[] = "Fill this form correctly.";
unset($_POST['senderEmail']);
}
$validRecips = check_valid($_POST['friend']);
if($validRecips == FALSE) {
$error[] = "Fill this form correctly.";
}
//end error checking
if($useHeader) include($headerFile);
if($error) {
echo "<center>\n";
foreach($error as $oneError) {
echo "$oneError<br>\n";
}
echo "</center>\n";
echo show_form();
if($useFooter) include($footerFile);
} 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" . $_POST['customMessage'] . "\n\n\n_________________________________________\n"
."Antyspam info! Wiadomość została wysłana z serwisu: ". $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] .""
." , IP: " . $_SERVER[REMOTE_ADDR] . ". W przypadku jeśli nie znasz nadawcy tego maila, prosimy o kontakt na adres: $webmasterEmail "
."";
echo "<center>\n";
if($_POST['toself'] == TRUE) {
array_push($validRecips, $_POST['senderEmail']);
}
$content = ($sendAsHtml == TRUE ? "text/html" : "text/plain");
$message = stripslashes($message);
if($sendAsHtml == 1) $message = $htmlHeader . nl2br(trim($message));
$headers = "From: " . $_POST['senderName'] . " <" . $_POST['senderEmail'] . ">\r\n";
$headers .= "X-Mailer: Your webside url address or different info eg. (helmuth.dk)\r\n";
$headers .= "Content-Type: $content";
foreach($validRecips as $recip) {
$friends .= $recip . " ";
@mail($recip, $subject, $message, $headers);
echo "Wiadomość została wysłana do: $recip<br>\n";
}
echo "</center>\n<br>\n<center><b>Dziękuję :)</b><br><br>Kliknij <a href=\"$returnPage\" target=\"_self\">tu</a>, aby przejść na stronę główną lub <a href='javascript: history.go(-1)'>tu</a> aby wrócić do poprzedniej.</center><br><br>\n\n";
if($useFooter) include($footerFile);
if($sendNotification) {
//build message string here.
$nMessage = $_POST['senderName'] . " (" . $_POST['senderEmail'] . ") " . $_SERVER['REMOTE_ADDR'] . " har benyttet Anbefal Hjemmeside-scriptet til at sende til fřlgende personer: " . count($validRecips) . " Ven(ner) ($friends).";
@mail($webmasterEmail, "...", $nMessage, "From: $webmasterEmail");
}
}
}
/* end main */
/* mixed */ 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;
}
}
/* void */ function show_form()
{
global $numFriends, $validRecips, $recommendMessage, $customMessage, $userdata;
$senderName = (!isset($_GET['sn']) ? $_POST['senderName'] : urldecode($_GET['sn']));
$senderEmail = (!isset($_GET['se']) ? $_POST['senderEmail'] : urldecode($_GET['se']));
//sender vars
echo "<form method=\"POST\" action='".FUSION_SELF.(FUSION_QUERY ? "?".str_replace("&","&",FUSION_QUERY) : "")."'>\n"
."<input type=\"hidden\" name=\"action\" value=\"submit\">\n"
."<table border=0 align=\"center\" cellpadding=1 cellspacing=0>\n"
."\t<tr>"
."<td><input type=\"hidden\" name=\"senderName\" value=\"Od przyjaciela\"></td></tr>\n"
."<tr><td>E-mail nadawcy:</td></tr><tr><td style=\"text-align:center\">".(iMEMBER ? "<input type=\"hidden\" name=\"senderEmail\" value=\"".$userdata['user_email']."\">".$userdata['user_email'] : "<input class='textbox' style='width:150px' type=\"text\" name=\"senderEmail\" value=\"$senderEmail\" size=10>")."</td></tr><tr>"
." ";
for($i = 1; $i <= $numFriends; $i++) {
echo "<td>E-mail adresata: </td></tr><tr><td><input class='textbox' style='width:150px' type=\"text\" name=\"friend[]\" value=\"".$validRecips[$i - 1]."\" size=10></td></tr>";
}
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);
}
function selfURL1() {
$s = empty($_SERVER["HTTPS"]) ? ''
: ($_SERVER["HTTPS"] == "on") ? "s"
: "";
$protocol = strleft1(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s;
$port = ($_SERVER["SERVER_PORT"] == "80") ? ""
: (":".$_SERVER["SERVER_PORT"]);
return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI'];
}
function strleft1($s1, $s2) {
return substr($s1, 0, strpos($s1, $s2));
}
echo ""
."<tr>"
.""
."<td colspan=2><input class='textbox' name='customMessage' type='hidden' value='Natrafiłem w internecie na bardzo ciekawą stronę! Jeśli masz ochotę obejrzeć, to kliknij w ten link: ";
print(selfURL1());
echo"'></td></tr>"
."<tr>"
."<td><input type=\"checkbox\" name=\"toself\"> Kopia do mnie </td></tr>"
."<tr><td align='center'><input class='button' type=\"submit\" value=\"Wyślij\"></td>\n\t</tr>\n"
."\t<tr>\n\t\t<td colspan=2></td>\n\t</tr>\n"
."</table>\n"
."</form>\n\n";
}
/* bool */ function isValid($email)
{
return eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,4}$", $email);
}
closeside();
Wklejamy jako nowy panel.
Edytowane przez Pieka dnia 22.07.2007 02:12:36
Jestem jaki jestem
|