PDA

View Full Version : newsletter (ezmlm) integration


Till
08-30-2003, 10:00 PM
Hello,

this is a really small hack, very basic. It's the first I released too, certainly not the first I have done. ;) It's so not rocket science or advanced l33t PHP code hacking. But since I didn't really find the same hack on the site, I guess it qualifies.

Preface:

We have Qmail running, and since we (ab)use Qmail a lot, we run ezmlm with it. Very nice combo, if I may add. ;)

Anyways, ezmlm handles the subscription via email. You send an email to listname-subscribe@whatever.domain.tld and the user recieves an email asking to confirm it (double opt-in style).

So I guess it really works with any listmanager that does the subscription via email request and confirm.

So, I had to write this in order to enable users to sign up for our newsletter on registration.

Here we go:

Create a file called "register_subscribe.php" in your forum's home directory. Put the following PHP code in it:


<?
// build headers
// $newsletter_email
$headers = "From: ".$newsletter_email." <".$newsletter_email.">\n";
$headers .= "Reply-To: ".$newsletter_email." <".$newsletter_email.">\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
$headers .= "X-Sender: ".$newsletter_email." <".$newsletter_email.">\n";
$headers .= "X-Mailer: PHP4\n";
$headers .= "X-Priority: 3\n";
$headers .= "Return-Path: <".$newsletter_email.">\n";

// send email
mail("listname-subscribe@domain.tld", "", "", $headers);

/*
send confirmation email
mail("youraddy@domain.com", "new subscription request", "email: $newsletter_email", "From: whatever <whatever@whatever.com>");
*/
?>


That's the first part where you should adjust "listname-subscribe@domain.tld" to your list manager's subscription email address.

You can remove the comments for the other mail() function and adjust it with your email address, if you feel like it. Starting it off, it can be pretty useful to track who makes use of it, and who doesn't.

Next step is to go into your control panel, then "Templates", "Modify" and "Expand..." the list. Find "Registration Templates" and edit "registeradult".

I added the following lines:


<tr>
<td bgcolor="#13486D"><normalfont><b>Would you like to recieve our newsletter?</b></normalfont></td>
<td bgcolor="#13486D"><normalfont>Yes</normalfont>&nbsp;<input type="checkbox" class="bginput" name="subscribe_newsletter" size="25" maxlength="15" value="yes" checked></td>
</tr>


Right underneath of:


<tr>
<td bgcolor="#1C5780"><normalfont><b>Enter Email Again:</b></normalfont></td>
<td bgcolor="#1C5780"><normalfont><input type="text" class="bginput" name="emailconfirm" size="25" maxlength="50"></normalfont></td>
</tr>


OK, I guess that was pretty easy so far. We are almost done. :)

Now, let's go into register.php.

Assuming that you didn't edit the file before (and that you run vBulletin 2.3.2), you should find the following piece of code on line 476:


$homepage = trim($homepage);
if ($homepage) {
if (preg_match('#^www\.#si', $homepage)) {
$homepage = "http://$homepage";
} else if (!preg_match('#^[a-z0-9]+://#si', $homepage)) {
// homepage doesn't match the http://-style format in the beginning -- possible attempted exploit
$homepage = '';
}
}


Right underneath, I added:


// do newsletter subscribing

if($_POST["subscribe_newsletter"]=="yes"){
// checkbox checked
$newsletter_email=$email;
@include(dirname(__FILE__)."/register_subscribe.php");
}


Why did I add it there? Well, just because that is the very last moment before the user gets written to the database. Which means that all validation has been done until this point, which means that there's not going to be another error message about the registration process.

Not being able to register for the board for whatever reason, but still getting the message to confirm list subscription might confuse users. If you know what I mean. :D

So yay! That should be it.

:banana:

You may change all variables used, you can even put the file into another directory or whatever. Please do not complain that it doesn't work after you changed everything.

The hack *should* work with any version of vBulletin. The line number may be different though, but I guess you can figure it out.

I won't have any screenshots right now, maybe later. If you guys need anything, let me know, I'll try to respond to each post in time - if possible.

Have fun,
Till

colicab-d
08-31-2003, 06:48 PM
plz put your hack as txt or php file so that un-licensed users cant use it...

or so one of the mods will tell you ;)

Till
08-31-2003, 07:19 PM
Today at 09:48 PM colicab-d said this in Post #2 (https://vborg.vbsupport.ru/showthread.php?postid=430129#post430129)
plz put your hack as txt or php file so that un-licensed users cant use it...

or so one of the mods will tell you ;)

Why am I paying for this if I can have all the hacks for free? :laugh:

I'll do so if one of the moderators will require me to do so.

Till
08-31-2003, 07:31 PM
Here it is.

I'll disclose a link and more info when the project is online (and we launched it). :)

Link14716
08-31-2003, 07:41 PM
The reason is not so that non-licensed users cannot get it, although you should never put the instructions into the hack database for that purpose. The purpose is so that people can download it and have a copy on their machine so they can re-install it when they upgrade:
From the Full Releases rules:
Please attache the hacking instructions in a text file of some sort, so that users can download and use them again in the case of a vBulletin upgrade.

Till
08-31-2003, 09:48 PM
Yesterday at 10:41 PM Link14716 said this in Post #5 (https://vborg.vbsupport.ru/showthread.php?postid=430159#post430159)
The reason is not so that non-licensed users cannot get it, although you should never put the instructions into the hack database for that purpose. The purpose is so that people can download it and have a copy on their machine so they can re-install it when they upgrade:

I gotcha. ;) Added the thread as .txt to it. I guess that works. I'll do a better release with my next hack.

Cheers,
Till

SmEdD
09-01-2003, 04:40 AM
Yesterday at 03:48 PM colicab-d said this in Post #2 (https://vborg.vbsupport.ru/showthread.php?postid=430129#post430129)
plz put your hack as txt or php file so that un-licensed users cant use it...

or so one of the mods will tell you ;)

They cannot see it any ways ;) A mod will also tell you that. As long as it is in the [ PHP ] or [ CODE ] tags it's fine.

Also you should add some screen shots.

Till
09-01-2003, 09:10 AM
Today at 07:40 AM SmEdD said this in Post #7 (https://vborg.vbsupport.ru/showthread.php?postid=430279#post430279)
They cannot see it any ways ;) A mod will also tell you that. As long as it is in the [ PHP ] or [ CODE ] tags it's fine.

Also you should add some screen shots.

I added one, if you scroll up two posts.

assassingod
09-01-2003, 09:15 AM
Yesterday at 08:48 PM colicab-d said this in Post #2 (https://vborg.vbsupport.ru/showthread.php?postid=430129#post430129)
plz put your hack as txt or php file so that un-licensed users cant use it...

or so one of the mods will tell you ;)

As mentioned above, you don't have to document it since unlicenced/guests cant view the code in them;)

Though its nice to put it in a txt file to make it more organized.:)