Page 1 of 1

I hacked the GT mod (good if you use it for e-mail address)

Posted: Sat 9. Oct 2004, 00:13
by GTakacs
I was going to use the GT mod to show my e-mail address on my website and make it into a link to a web-email form. I just really don't want bots to harvest my e-mail address.

It is all nice and dandy, however GT does not really solve this problem as my e-mail address was still part of the HTML code after displaying it as an image, thanks to the ingenious little thing called ALT tag. GT will use your original text as the ALT tag for the generated image. While it makes sense for the most part, it defeats the whole purpose of having your e-mail address displayed via graphic text to avoid spam robots.

So I extended the GT tag to my liking where I can set the ALT tag to whatever I prefer.

Code: Select all

#
#-----[ OPEN ]------------------------------------------ 
# 


include/inc_module/mod_graphical_text/inc_front/gt.func.inc.php




# 
#-----[ FIND ]------------------------------------------ 
# 


$content["all"] = preg_replace('/\{GT:(.+?)\}(.*?)\{\/GT\}/ei', "get_gt_by_style(\$gt, \"\$1\", \"\$2\")", $content["all"]);	


# 
#-----[ BEFORE, ADD ]------ 
# 

$content["all"] = preg_replace('/\{GT:(.+?):(.*?)\}(.*?)\{\/GT\}/ei', "get_gt_by_style(\$gt, \"\$1\", \"\$3\", \"\$2\")", $content["all"]);	

# 
#-----[ FIND ]------------------------------------------ 
# 

function get_gt_by_style ($gt, $style_name, $text)

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 

function get_gt_by_style ($gt, $style_name, $text, $alt_txt="")

# 
#-----[ FIND ]------------------------------------------ 
# 

$result = show_picture($font, $text, $antialiasing, $size, $fgcolor, $fgtransparency, $bgcolor, $bgtransparency, $line_width, $format);

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 

$result = show_picture($font, $text, $antialiasing, $size, $fgcolor, $fgtransparency, $bgcolor, $bgtransparency, $line_width, $format, $alt_txt);

# 
#-----[ FIND ]------------------------------------------ 
# 

function show_picture ($font, $text, $antialiasing, $size, $fgcolor, $fgtransparency, $bgcolor, $bgtransparency, $line_width, $format) 

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 

function show_picture ($font, $text, $antialiasing, $size, $fgcolor, $fgtransparency, $bgcolor, $bgtransparency, $line_width, $format, $alt_txt ="") 

# 
#-----[ FIND ]------------------------------------------ 
# 

return '<img src="'.$displayfile.'" alt="'.htmlentities($alt_txt).'" border="0" />';

# 
#-----[ BEFORE, ADD]------------------------------------------ 
# 
if (empty($alt_txt)) {
	$alt_txt = $text;
}
After these changes you can use your new GT Replacement tag!

Usage:

{GT:style}Text{/GT}
Works just like before, adding the entire text as ALT tag

{GT:style:}Text{/GT}
Works just like before, adding the entire text as ALT tag

{GT:style:bla}Text{/GT}
Instead of the word "Text" being the ALT tag, when you hover over with your mouse, you'll see the word "bla" being displayed.

{GT:style: }Text{/GT} (notice the extra space after the second colon)
The new ALT tag will be a single space, when you hover over you will get an empty string.



With this mod in place, I am not that worried about having my e-mail address showing on my website as robots can't really harvest it. Feel free to add this hack to the next release of the GT MOD. I would actually prefer to have it in the next release, I'd hate to have to re-add it myself.

Posted: Sat 9. Oct 2004, 01:41
by Peekay
Haven't used this mod yet, but your idea sounds like an excellent way to utilise it.

Email link harvesting is the easiest source of addresses for spammers. Whenever my clients allow it, I put their email address on their websites as a Flash movie. It's just a single frame SWF with an on-click action to launch a mail client. Saved in Flash 3 format, virtually every browser can render it. I manually add a polite ALT text explaining alternative ways to communicate with the client for those peolple that may be using an assisted-technology browser.

Your use of this mod sounds like a great way to get the same result without using Flash. Look forward to trying it out.

Posted: Sun 10. Oct 2004, 02:58
by GTakacs
I had to change one more thing in the above tweak, I didn't know that show_picture() was called from the back end module control screen, and it would give a warning about the missing argument. So re-read the tweak if you have applied it before, now it shows the correct syntax. Let me know how it goes!

Posted: Sun 10. Oct 2004, 22:47
by Peekay
I sure will. Got a few other PHPWCMS mysteries to unravel first! :lol: