<?php
/
EasyLetter 1.2
This script is part of Onlinetools
http://www.onlinetools.org/tools/easyletter.php
/
$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="blankblank";
Where is your newsletter located? (For deletion link)
$newsletterlocation="http://www.encrucijada.net/gary/easy/easyletter.php";
Name of the datafile
$filelocation="subscribers.txt";
Title of the newsletter, will be displayed in the FROM field of the mailclient
$lettername="email@theraid.co.uk";
Your email, will be the reply-to mail,
$youremail="email@theraid.co.uk";
pattern for filtering out own emails
$pattern = "theraid.co.uk";
$welcomemessage = "***";
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 joining The Raid's mailing list, a confirmation email is on its way!</div>";
Subscribemail, will be sent when someone subscribes.
$subscribemail = "Thank you for joining The Raid's mailing list.";
Unsubscribemessage for deletion, will be followed by the email!
$unsubscribemessage = "<div class=\"thanks\">You have successfully unsubscribed</div>";
Unsubscribemessage for failed deletion, will be followed by the email!
$failedunsubscriptionmessage = "<div class=\"warning\">Theres no need un unsubscribe as $email isn't on our list</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="no";
$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="no";
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">
<center><font colour="#ffffff">Your email: <input type="text" name="email" class="inputsmall" value="" size="20" /> 
<br>
<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" /> </font></center>
</form>
';
}
print "<The Raid";
function checkmail($string){
return preg_match("/[\s()<>@,;:\"\/[]?=]+@\w[\w-](.\w[\w-])*.[a-z]{2,}$/i",$string);
}
?>