Ok.. this CAN be done… I KNOW it can… I'm close… but not quite there… Here's my "plan" for the code:
Create an intermediate "processing" file that will be the "action" instead of the mt-comments.cgi. On this page I will:
1) see if a "subsribe email list" file exists.
2) if so, parse it into an array
3) iterate through the array sending emails to each person's email (that's whats in the array – it's an array of emails of people who have subscribed to the comments for that post) with just the Author and text of the comment
5) We'll load all the values of the comment form (from the previous page) into hidden form elements.
4) Then onLoad, we'll submit the form like normal – to mt-comments.cgi so that the comment is logged, and the blog author gets their comment notification, etc.
Creating a "subscribe to comments" form has still yet to be completed, but that, I would imagine would be pretty simple… on the page itself create a secondary form – creating that subscribe email list (with the post ID in the filename to seperate it from other posts).
Ok, here's where I am, and here's the problems I'm having: (Everyone and anyone is free to comment and help out with the script! This is all in the name of fun and learning, and all are welcome to participate!!!)
Here's the code I came up with… it's not really complete… but you get the idea…
<?
$fileString = "/honme/PATH_TO_COMMENTSUBSCRIBE_FOLDER/commentsubscribe/";
$fileString .= "$entry_id";
$fileString .= "email.ini";
if (file_exists($fileString)) {
$emailList = parse_ini_file("$fileString");
$count = count($emailList);
}
if (!strcasecmp($isSent, "false")) {
for ($i = 0; $i < $count; $i++) {
mail("$emailList[$i]", "New Comment on $entry_id", "Author: $author\ncomment: $text", "From: scriptyATscriptygoddessDOTcom");
}
$submitForm = "document.comments_form.submit()";
$isSent = true;
} else {
$submitForm = "document.location='YOUR_HOME_PAGE'";
/*
I put this here in case someone tried to reload THIS page…
that way the $isSent variable is set to true (at the bottom)…
and the form won't process again post the comment again
and annoy people with bogus emails
*/
}
?>
<html><head><title></title></head><body onLoad="<? echo $submitForm ?>">
<form method="post" action="PATH_TO_YOUR_MTCOMMENTSFILE/mt-comments.cgi" name="comments_form">
<input type="hidden" name="static" value="<? echo $static ?>" />
<input type="hidden" name="entry_id" value="<? echo $entry_id ?>" />
<input type="hidden" name="ipadd" value="<? echo $ip ?>" />
<input type="hidden" name="author" value="<? echo $author ?>" />
<input type="hidden" name="email" value="<? echo $email ?>" />
<input type="hidden" name="url" value="<? echo $url ?>" />
<input type="hidden" name="text" value="<? echo $text ?>" />
<input type="hidden" name="post" value="submit" />
</form>
<?
$isSent = "true";
?>
</body>
Problem #1:
That $isSent failover… doesn't work.. it processes the comment again
Problem #2:
I did some bug-testing feedback thingys and it doesn't seem to be parsing the email list file (I set up a temporary one manually)
However, the comment DOES go through… so once we get this page working, it should work!
Thoughts? Comments? Ideas???