1 (edited by druvans 2005-04-15 14:35)

Topic: New bb code to hide or imagize e mail address

I modified parser.php file to add  a new bbcode namely [x] -[/x]. if you place an email address between them, then it will be converted to a .png (1k approx), file.

demo:
http://jobs.gotoguide.org/viewtopic.php?id=400
see the emai, it is a png file created on the fly

In case anyone want try it, upload this new  parser.php file.

http://www.gotoguide.org/parser.zip

all code to create image is at the end of the file, modify  $foreground and $background  for diff color pics.

any suggestions, comments !

2 (edited by Ataxy 2005-04-15 06:16)

Re: New bb code to hide or imagize e mail address

does this code need certain php capacity enabled on the server side like GD enabled

Re: New bb code to hide or imagize e mail address

(PHP 4 >= 4.0.6, PHP 5) and  GD 2.0.1 or later.

Re: New bb code to hide or imagize e mail address

druvans
thank you for make this idea ALIVE and working wink

Re: New bb code to hide or imagize e mail address

I wanted to try something in php to start with, sort of glad that my first prg in php works ok !

Re: New bb code to hide or imagize e mail address

another one think, is to put this into profile wink

7 (edited by druvans 2005-04-15 18:59)

Re: New bb code to hide or imagize e mail address

In case anyone decide to use this, please make the following changes also to make the pics more managable.

change line 498 as follows - basically moves the png files to their own directory

$filename ="img/imagize/".substr($email, 0,strrpos($email, '.')).".png";

and create a directory called imagize inside the img directory.

Re: New bb code to hide or imagize e mail address

druvans
anyway, the text described e-mail is already in the source, so i think it should generate images from a profile id, but what about separate e-mail addresses that not in a db?

Re: New bb code to hide or imagize e mail address

Aleksei wrote:

druvans
anyway, the text described e-mail is already in the source, so i think it should generate images from a profile id, but what about separate e-mail addresses that not in a db?

Dint follow ur question fully, the function basically creates an image file and returns a the corresponding html tag for the pic.

10 (edited by Aleksei 2005-05-22 11:08)

Re: New bb code to hide or imagize e mail address

yeh, I know that. I want to say that this is not enought for protection against spammers, becouse they can use a source-code of html pages generated by forum for collectiong e-mail addresses.

[x] tag generate image from string(like blalba@bla.com), but I think, it should do it from an user ID (etc 3252) ?r nickname (eth druvans)

[x]druvans[/x] or [x]1973[/x] should produce image with druvans@yahoo.com, NOT [x]druvans@yahoo.com[/x]

and the name of genegated file should not be : druvans_yahoo.png, just a druvans

but there is a problem: we can`t imagize e-mail that is not in a profile of some registered member...

BTW:
this version of function generate _transparent_ image (works in IE6, Mozilla, Opera not tested)

$fontsize=3;
// Create the image
$im = imagecreate( strlen($email)*8, 16 ) or die( "Cannot Initialize new GD image stream" );
//Create background color
$bg = imagecolorallocate($im, 255, 255, 255); 
imagecolortransparent($im,$bg); 
imagefill($im,0,0,$bg); 

// Create foreground color
$foreground = imagecolorallocate($im, 0, 150, 0); 
// write the string at the top left
imagestring($im,$fontsize, 0, 0, $email, $foreground);

// Using imagepng() results in clearer text compared with imagejpeg()
//filename modified as per spider8's comments - need to clean it up
$email =trim(preg_replace( '/^[^a-zA-Z0-9]+$/', '_', str_replace("@","_",$email)));
$filename ="img/imagize/".substr($email, 0,strrpos($email, '.')).".png";
imagepng($im,$filename);
return '<img src="'.$filename.'">';
}
//imagize code ends

Re: New bb code to hide or imagize e mail address

I think, the image file is created dynamically every time you load the page, so there is no need to have a readable name, you cld use a "random number".png  file. only problem is, it will fill up your hard drive, so you need to a process to clean up  imagize folder. if you want i can modify and send the code.

Re: New bb code to hide or imagize e mail address

druvans
it would be great...

Re: New bb code to hide or imagize e mail address

Inside imagize function  locate this line
$filename ="img/imagize/".substr($email, 0,strrpos($email, '.')).".png";

and replace it with the following

srand(time());
$filename = "img/imagize/".(rand()).".png";


now file names are absolutely random useless to anyone

CAUTION: You may need to  clean up the image files. as they grows n times faster now.
I wld not recommend using random number file names