1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
<?php
error_reporting(E_ALL ^ E_NOTICE);
$vars=explode(",","pw,send,subject,message,email,action");
foreach($vars as $v){
if ($HTTP_GET_VARS[$v]!=""){$$v=$HTTP_GET_VARS[$v];}
if ($HTTP_POST_VARS[$v]!=""){$$v=$HTTP_POST_VARS[$v];}
}
# Set the password for the eMail List editor!
$pass="libreantenne";
# Where is your newsletter located? (For deletion link)
$newsletterlocation="http://www.xxxxxxxxxxxxxxx.fr";
# Name of the datafile
$filelocation="liste.txt";
# Title of the newsletter, will be displayed in the FROM field of the mailclient
$lettername="xxxxxxxxx@xxxxxxxxxx.fr";
# Your email, will be the reply-to mail,
$youremail="xxxxxx@xxxxx.com";
# pattern for filtering out own emails
$pattern = "xxxxx.com";
$welcomemessage = "Welcome";
# Sorrymessage for failed subscription, will be followed by the email!
$sorrysignmessage = "<div class=\"warning\">Sorry, but there is already an entry for $email</div>";
# Sorrymessage for blank email
$sorryblankmailmessage = "<div class=\"warning\">Sorry, but with a blank mail I get lost in cyberspace</div>";
# Sorrymessage for invalid emails
$sorryoddmailmessage = "<div class=\"warning\">Sorry, but \"$email\" that does not look like an email to me</div>";
# Sorrymessage if someone entered your own mail
$sorryownmailmessage = "<div class=\"warning\">Sorry, but I don't really want to get my own newsletter!</div>";
# Subscribemessage, will be shown when someone subscribes.
$subscribemessage = "<div class=\"thanks\">Thank you for subscribing to the newsletter, a confirmation email is on its way!</div>";
# Subscribemail, will be sent when someone subscribes.
$subscribemail = "Thank you for subscribing to the newsletter.";
# Unsubscribemessage for deletion, will be followed by the email!
$unsubscribemessage = "<div class=\"thanks\">We deleted the email</div>";
# Unsubscribemessage for failed deletion, will be followed by the email!
$failedunsubscriptionmessage = "<div class=\"warning\">Sorry, you cannot unsubscribe as we didn't find an entry for $email</div>";
if (!file_exists($filelocation)) {
$newfile = fopen($filelocation,"w+");
fclose($newfile);
}
$newfile = fopen($filelocation,"r");
$content = @fread($newfile, filesize($filelocation));
fclose($newfile);
$content=stripslashes($content);
$out="";
$lines = explode("%",$content);
foreach($lines as $l){
if ($l != $email){$out .= "%".$l;}
else{$found=1;}
}
if ($action=="sign"){
if ($found==1 or $email=="" or !checkmail($email) or preg_match("/".$pattern."/",$email)){
if ($email==""){echo $sorryblankmailmessage;}
else if ($found==1){echo $sorrysignmessage;}
else if (!checkmail($email)){echo $sorryoddmailmessage;}
else if (preg_match("/".$pattern."/",$email)){echo $sorryownmailmessage;}
$disp="yes";
}
else {
$disp="yes";
$newfile = fopen($filelocation,"a+");
$add = "%".$email;
fwrite($newfile, $add);
fclose($newfile);
echo $subscribemessage;
mail ($youremail,"New newsletter subscriber.",$email."\nDelete? $newsletterlocation?action=delete&email=".$email,"From: Newsletter\nReply-To: $email\n");
$submailheaders = "From: $lettername subscription form\n";
$submailheaders .= "Reply-To: $youremail\n";
mail ($email,$lettername." subscription",$subscribemail,$submailheaders);
}
}
if ($action=="delete"){
$disp="yes";
if ($found == 1){
$newfile = fopen($filelocation,"w+");
fwrite($newfile, $out);
fclose($newfile);
echo $unsubscribemessage;
$disp="no";
}
if ($found != 1){
echo $failedunsubscriptionmessage;
$disp="YES";
}
}
if ($pw == $pass){
if ($send != "yes" && $send != "test"){
print'<form method="post"><input type="hidden" name=pw value='.$pass.' /><input type="hidden" name="send" value="yes">
<br /><b>Newsletter editor:</b><br /><br />
Subject:<br />
<input type="text" class="input" name="subject" size="20"><br />
Message:<br />
<textarea cols="50" rows="10" class="input" wrap="virtual" name="message"></textarea>*
<input type="submit" value="send" />
</form>';
}
$mailheaders = "From: $lettername\n";
$mailheaders .= "Reply-To:$youremail\n";
# If you want to send HTML mail, uncomment this line!
// $mailheaders .= "Content-Type: text/html; charset=iso-8859-1\n";
if ($send == "yes"){
$message="".stripslashes($message);
$subject=stripslashes($subject);
$lines = explode("%",$content);
foreach ($lines as $l){mail ($l,$subject,$message,$mailheaders);}
print "<b>The following email has been sent!</b>";
print "<pre>$mailheaders\n$subject\n$message</pre>";
}
}
if ($pw != $pass && $disp != "no"){
print $welcomemessage;
print'
<form method="post">
Your email:*<input type="text" name="email" class="inputsmall" value="" size="20" />*
<input type="radio" name="action" value="sign" checked="checked" />subscribe
<input type="radio" name="action" value="delete" />unsubscribe*
<input type="submit" value=" Send! " class="button" />
</form>
';
}
function checkmail($string){
return preg_match("/^[^\s()<>@,;:\"\/\[\]?=]+@\w[\w-]*(\.\w[\w-]*)*\.[a-z]{2,}$/i",$string);
}
?> |