For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > March 2004 > Modifier with preg_replace_callback









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Modifier with preg_replace_callback
Gabriel Birke

2004-03-19, 1:29 pm

Hello!

I'm trying to obfuscate and "linkify" mail addresses in a text with the =20=

following modifier:

function smarty_modifier_mail_escape($string)
{
return =20
preg_replace_callback("/[_a-z0-9.A-Z]+@[-a-z0-9.A-=20
Z]+/","escape_mail",$string);
}

function escape_mail($text)
{
echo "escape_mail called";//<-- for debugging purposes, to test if =
=20
the func is called
$text=3D$text[0];
for($i=3D0;$i<strlen($text);$i++)
{
$mailto.=3D"&#".ord($text[$i]).";";
}
return "<a =20
href=3D\"mailto:$mailto\">$mailto</a>";
}

The two functions are in the same file but escape_mail doesn't get =20
called (Smarty 2.3, PHP 4.1). What am I doing wrong?

Is there another way to accomplish the obfuscation of email adresses =20
that are mingled with normal text?

With best regards

Gabriel Birke

--=20
KONTOR4_Neue Medien
Plathnerstra=DFe 5
30175 Hannover
Fax: +49 51184 48 98 99
mailto:birke@kontor4.de
http://www.kontor4.de=
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com