Jeg bruger denne på min side, men det er kun brugerne der kan bruge den. Kan jeg rette den, så en gæst også kan bruge den Altså uden at skulle log ind.
Kode <?php
/*---------------------------------------------------+
| PHP-Fusion 7 Content Management System
+----------------------------------------------------+
| Copyright © 2002 - 2005 Nick Jones
| http://www.php-fusion.co.uk/
+----------------------------------------------------+
| Released under the terms & conditions of v2 of the
| GNU General Public License. For details refer to
| GNU Affero GPL.txt file or visit http://fsf.org/
+----------------------------------------------------*
| Ported to v7 by Assensvej
| Assensvej.dk http:www.assensvejdk/7
|----------------------------------------------------*/
require_once "maincore.php";
require_once THEMES."templates/header.php";
if (iGUEST) { redirect("index.php"); }
opentable("Anbefal denne hjemmeside til en ven");
//Configuration Below
$numFriends = 3;
//how many form fields for friends' email addresses to show.
$webmasterEmail = "c©iuul.com";
//your email address, used for sending notifications
$returnPage = "http://www.iuul.com";
//after a person sends a message, a link will be shown for them to click in order to
//return to a page on your site. here is where you specify that page.
$sendNotification = 1;
//whether or not to notify you when someone completes the form. 1 for yes, 0 for no
$subject = "Hjemmesideanbefaling af [SENDER_NAME] ([SENDER_EMAIL])";
//the subject line of sent messages. [SENDER_NAME] will be replaced with the actual sender name
//and [SENDER_EMAIL] will be replaced with the senders email address.
$recommendMessage = <<<EOD
Hejsa,
Din ven er begejstret for denne hjemmeside og anbefaler dig at besøge: http://www.iuul.com
Mvh.
IUUL FYS
EOD;
//This is the message you, the site owner write that CANNOT be edited by the sender.
//This message will appear to all who receive messages from friends. It is what will
//hopefully get the friend to click to your site (aside from a friend recommending it).
//Start editing on the line AFTER <<<EOD and stop editing before EOD; be sure to leave
//those two lines the way they are or you will receive an error.
//NEW: If you place [REFPAGE] in this text, it will be replaced with the page that the person
//clicked to the tell a friend page from. Good for sites with many pages with different content.
//Keep in mind some browsers hide or change the referring page, so use this at your own risk.
$customMessage = <<<EOD
Slet denne tekst Og skriv din personlige besked her ...
EOD;
//This is a box that the sender can edit if they wish to enter a personal
//message to their friend if they wish. You can make it say whatever you want
//but make sure they know they can edit it for personalization.
$sendAsHtml = 0;
//Set to 1 to send messages as html (note some email clients can not display html emails and
//will result in the recipient seeing the html code with their message.
$htmlHeader = <<<EOD
<body bgcolor="#E0E0E0" text="#00ff00" link="#0000ff">
<center><b>Anbefalings besked</b></center><br>
<center><img src="http://www.dansk-thai.dk/banner/banner.gif"></center>
<br><br>
EOD;
//the above html will show up at the top of the message to set up
//the colors and anything else you'd like to be in the email. if $sendAsHtml is set to 1
//this will show up in the message, otherwise it wont.
//thats it, nothing else needs to be done. I hope you like it PHPBuddy
###############################################################################################
###############################################################################################
## ##
## END OF CONFIGURATION, PLEASE DO NOT EDIT PAST THIS LINE UNLESS YOUR SOMEONE LIKE ##
## CRAPPOMAN :p ##
###############################################################################################
###############################################################################################
error_reporting(E_ERROR); // only stop for critical errors
/* 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[] = "Du har ikke indtastet et navn.";
}
$_POST['senderEmail'] = trim($_POST['senderEmail']);
if(!isValid($_POST['senderEmail'])) {
$error[] = "Din emailadresse er ikke gyldig.";
unset($_POST['senderEmail']);
}
$validRecips = check_valid($_POST['friend']);
if($validRecips == FALSE) {
$error[] = "Du har ikke indtastet en gyldig emailadresse.";
}
//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"
."Note: Ingen Spam ! En ven sender dig denne besked fra ". $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] .""
." Hvis du mener det er en fejltagelse, så kontakt venligst $webmasterEmail med følgende IP-adresse " . $_SERVER[REMOTE_ADDR] . ", eller slet denne email. Ved modtagelsen af denne "
."email er du hverken tilføjet en Newsletter Liste og din emailadresse er heller ikke blevet gemt på nogen måde!";
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: Anbefal hjemmeside (helmuth.dk)\r\n";
$headers .= "Content-Type: $content";
foreach($validRecips as $recip) {
$friends .= $recip . " ";
@mail($recip, $subject, $message, $headers);
echo "Email sendt til $recip<br>\n";
}
echo "</center>\n<br>\n<center><b>Tak fordi du har anbefalet min hjemmeside!</b><br><br>\nKlik <a href=\"$returnPage\" target=\"_self\">her</a>, for "
."at komme til forsiden eller <a href=\"".$_SERVER['PHP_SELF']."?sn=".urlencode($_POST['senderName'])."&se=".urlencode($_POST['senderEmail'])
."\">her</a>, for at anbefale til flere.</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, "Din hjemmeside blev anbefalet", $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;
$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=\"".$_SERVER['PHP_SELF']."\">\n"
."<input type=\"hidden\" name=\"action\" value=\"submit\">\n"
."<table border=0 align=\"center\" cellpadding=5 cellspacing=0>\n"
."\t<tr>\n"
."\t\t<td>Dit Navn:</td><td><input type=\"text\" name=\"senderName\" value=\"$senderName\" size=30></td>\n"
."\t</tr>\n"
."\t<tr>\n"
."\t\t<td>Din email:</td><td><input type=\"text\" name=\"senderEmail\" value=\"$senderEmail\" size=30></td>\n"
."\t</tr>\n";
for($i = 1; $i <= $numFriends; $i++) {
echo "\t<tr>\n\t\t<td>Ven $i:</td><td><input type=\"text\" name=\"friend[]\" value=\"".$validRecips[$i - 1]."\" size=30></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><textarea name=\"recommendMessage\" cols=37 rows=5 readonly onFocus=\"this.blur()\">$recommendMessage</textarea></td>\n"
."\t</tr>\n"
."\t<tr>\n"
."\t\t<td colspan=2><textarea name=\"customMessage\" cols=37 rows=5>$customMessage</textarea></td>\n"
."\t</tr>\n"
."\t<tr>\n\t\t<td colspan=2><input type=\"checkbox\" name=\"toself\"> Marker her, hvis du vil modtage en kopi selv</td>\n\t</tr>\n"
."\t<tr>\n\t\t<td colspan=2><input type=\"submit\" value=\"Send besked\"> <input type=\"reset\" value=\"Fortryd\"></td>\n\t</tr>\n"
."\t<tr>\n\t\t<td colspan=2><font size=1 color=red>***OBS !!! Dette script gemmer ikke de indtastede emailadresser på nogen måde***</font></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);
}
closetable();
require_once THEMES."templates/footer.php";
?>
|