[Supposed to be revising at the moment...]
I found “Colin Viebrock’s weblog”:http://viebrock.ca/ the other day, and it’s well worth reading as he has some very interesting code/ideas[1] on it. One that caught my eye was a discussion of “email protection”:http://viebrock.ca/code/11/email-protection by using a HTTP redirect to show the email address. With the amount of spam I receive increasing continually (currently 40% of my email, or ~45/day), I thought it was worth a try.
And being lazy and having a large number of existing pages on the “sendcard”:http://www.sendcard.org site, I didn’t want to edit each by hand (even if the alternative would increase server loading - well that’s what I pay “these guys”:http://www.fluidhosting.com for isn’t it?), so I wrote some code to convert mailto links automatically. Here it is:
ob_start('rewrite_mailto_links');
function rewrite_mailto_links($buffer)
{
return preg_replace_callback('!mailto:([^@]*)@([^'">&?]*)(\?subject=([^'">&]+))?!', 'rewrite_mailto_links_callback', $buffer);
}
function rewrite_mailto_links_callback($m)
{
$str = "/mailto.php/$m[1]/$m[2]";
if (isset($m[4]) && trim($m[4]) != '') {
$str .= "/$m[3]";
}
return $str;
}
You’ll need Colin’s “script”:http://viebrock.ca/downloads/send.phps as well. Writing that didn’t take long, but then I spent 40 min trying to get the prepended file to run. Memo to self: the syntax is
bc. php_var auto_prepend_file /path/to/file.php
NOT
bc. php_var auto_prepend /path/to/file.php
Uugh. Something so small wasted so much time. Still, it’s working now ![]()
fn1. While I faff around trying to decide how best to design the code, Colin just gets on and creates it, producing some very interesting stuff. Moral of the story: it’s better to do it than think about it.
0 comments ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment