PDA

View Full Version : Email, MSN and Yahoo adresses as GD Images


corn
06-14-2005, 10:00 PM
First of all, I'm not sure if this is a hack or a template mod.
so, if its placed wrong, please advise.
this is my first 'hack', so be nice ;)

My forum members were complaining about the load of spam they received after the emailaddresses were publicly viewable.
We wouldn't use the secure mail function, because the users wanted to see eachothers mail addresses.


Installation:
Create a file called email.php.
It must contain the following lines of code:

<?php
header("Content-type: image/png");

########## Email, MSN and Yahoo adresses as GD Images ############
########## Made by Corn for vb.org ##########

$im = imagecreatefrompng("email.png");
$color = imagecolorallocate($im, 0, 0, 0);
$px = (imagesx($im) - 7.5 * strlen($user)) / 2;
imagestring($im, 4, $px, 1, $user, $color);
imagepng($im);
imagedestroy($im);
?>


or use the one attached.

in the attached .zip, you can find a email.png file.
put the files in your forum root dir.

Go to the AdminCP and open the MEMBERINFO template, and search for $userinfo[msn]
replace that with
<img src="email.php?user=$userinfo[msn]" border="0">

also in the MEMBERINFO template, search for
$userinfo[yahoo]
replace that with
<img src="email.php?user=$userinfo[yahoo]" border="0">

Go to the Phrase manager, and search for showemail variable.
you will find the following:
The email address for $destusername is <a href="mailto:$email">$email</a>

replace with:
The email address for $destusername is <a href="mailto:$email"><img src="email.php?user=$email" border="0"></a>

thats all :)

tamarian
06-15-2005, 11:18 AM
First of all, I'm not sure if this is a hack or a template mod.
so, if its placed wrong, please advise.
this is my first 'hack', so be nice

This is a hack, and a very good one :up:

cinq
06-15-2005, 11:26 AM
Was trying to do this a while back (https://vborg.vbsupport.ru/showthread.php?t=80292)

Good job :)
You can probably apply this to any email address posted as well by amending the functions_bbcode.php in your includes folder.

Andreas
06-15-2005, 11:49 AM
IMHO this does not make much sense, as the eMail address is still in the HTML and can be processed automatically by spammers.
If you really want to do this (which isn't worth it) you might want to use smth. like the attached script.

jugo
06-15-2005, 12:37 PM
Very nice Kirby.

tamarian
06-15-2005, 01:03 PM
If you really want to do this (which isn't worth it) you might want to use smth. like the attached script.
I think obfuscating emails is really worth it, if that's what you meant?

And as always, great job with the code recommendations :up:

One issue, I think, that might be a problem with both versions is the image caching. As it's called email.png and browsers will often cache this, and one will end up sending emails to the wrong members :)

I'd call the image something like this,
$im = imagecreatefrompng('email-' . $userinfo['userid'] . '.png');

or with a random string as a cache buster.

Andreas
06-15-2005, 01:21 PM
I think obfuscating emails is really worth it, if that's what you meant?

I meant that, but as said it's IMHO not worth it the processing overhead, aus you can simply turn off displaying eMails.


I'd call the image something like this,
$im = imagecreatefrompng('email-' . $userinfo['userid'] . '.png');

Erm ... for this to work you would need tohse image-userid.png files on your servers HD ;)
The users browser never gets to see this email.png, however if you want to prevent caching (which should only be an issue when a user changes his eMail) you can add No-Cache Headers.

tamarian
06-15-2005, 02:19 PM
I meant that, but as said it's IMHO not worth it the processing overhead, aus you can simply turn off displaying eMails.

That won't work, as it would fail the original requirement :)

My forum members were complaining about the load of spam they received after the emailaddresses were publicly viewable.
We wouldn't use the secure mail function, because the users wanted to see eachothers mail addresses.

Erm ... for this to work you would need tohse image-userid.png files on your servers HD
The users browser never gets to see this email.png, however if you want to prevent caching (which should only be an issue when a user changes his eMail) you can add No-Cache Headers.

What would be best, IMHO, and eliminate some of the overhead, is to be able to generate the image without calling a new php file.

Is this doable? Can it be done in a plugin through a hook? And be able to show the image on the fly?

Andreas
06-15-2005, 02:23 PM
This is the vB 3.0.x section, so there are no Plugins/Hooks ;)

Well, doing this without creating the images on the fly means you must create them when the user enters/changes his emai/msn/yahoo - and store them somewhere for later retrival (either in the database or on disk).