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> <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
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> <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