Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Masking email addresses by making them images?
Old 03-20-2011, 01:18 PM Masking email addresses by making them images?
Super Talker

Posts: 113
Trades: 0
I would like to stop spambots from harvesting email addresses on my website by making the emails images in php. I found a script on another site but can't seem to get it to work. Here's the script:
Code:
<?PHP 
 
// Set your string somehow 
$string = 'your@example.com'; 
 
// Set font size 
$font_size = 4; 
 
// Create image width dependant on width of the string 
$width  = imagefontwidth($font_size)*strlen($string); 
// Set height to that of the font 
$height = imagefontheight($font_size); 
// Create the image pallette 
$img = imagecreate($width,$height); 
// Grey background 
$bg    = imagecolorallocate($img, 25, 25, 25); 
// White font color 
$color = imagecolorallocate($img, 255, 255, 255); 
// Length of the string 
$len = strlen($string); 
// Y-coordinate of character, X changes, Y is static 
$ypos = 0; 
// Loop through the string 
for($i=0;$i<$len;$i++){ 
    // Position of the character horizontally 
    $xpos = $i * imagefontwidth($font_size); 
    // Draw character 
    imagechar($img, $font_size, $xpos, $ypos, $string, $color); 
    // Remove character from string 
    $string = substr($string, 1);     
     
} 
// Return the image 
header("Content-Type: image/gif"); 
imagegif($img); 
// Remove image  
imagedestroy($img); 
 
?>
Does anyone have any experience with this?
Learnin' n00b is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-20-2011, 01:36 PM Re: Masking email addresses by making them images?
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Can you define "can't seem to get it to work"? I just ran the code on my server and it generated the image just fine. Note that if you have any output other than the image it won't work correctly.

To display images generated by this script you'll either need to store them somewhere, or have them generated on the fly in a separate script. Like this for example:
HTML Code:
<img src="/path/to/generator.php?email=test@test.com" />
generator.php
PHP Code:
$string $_GET['email'];
// .
// .
// . 
Of course passing the email as a GET parameter to the script kind of defeats the purpose since bots will be able to read it.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by NullPointer; 03-20-2011 at 01:41 PM..
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 03-20-2011, 01:44 PM Re: Masking email addresses by making them images?
Super Talker

Posts: 113
Trades: 0
Quote:
Note that if you have any output other than the image it won't work correctly.
That was my problem. Thanks!
Learnin' n00b is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Masking email addresses by making them images?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.30282 seconds with 12 queries