Code Comments
Programming Forum and web based access to our favorite programming groups.The Smarty mailto function has some obfuscation built-in. http://smarty.php.net/manual/en/lan...tion.mailto.php On Thu, 2004-03-11 at 10:16, Gabriel Birke wrote: > Hello! > > I'm trying to obfuscate and "linkify" mail addresses in a text with the > following modifier: > > function smarty_modifier_mail_escape($string) > { > return > preg_replace_callback("/[_a-z0-9.A-Z]+@[-a-z0-9.A- > Z]+/","escape_mail",$string); > } > > function escape_mail($text) > { > echo "escape_mail called";//<-- for debugging purposes, to test if > the func is called > $text=$text[0]; > for($i=0;$i<strlen($text);$i++) > { > $mailto.="".ord($text[$i]).";"; > } > return "<a > href=\"mailto:$mailto\">$mailto</a>"; > } > > The two functions are in the same file but escape_mail doesn't get > called (Smarty 2.3, PHP 4.1). What am I doing wrong? > > Is there another way to accomplish the obfuscation of email adresses > that are mingled with normal text? > > With best regards > > Gabriel Birke > > -- > KONTOR4_Neue Medien > Plathnerstraße 5 > 30175 Hannover > Fax: +49 51184 48 98 99 > mailto:birke@kontor4.de > http://www.kontor4.de
Post Follow-up to this messageWell, yes, this would be very helpful if I just had some email address=20=
I wanted to generate a mailto from. My problem is that the email=20
addresses are scattered throughout the text like this:
$text=3D "This is the content of my website.
More stuff ...
If you want to contact me, write to: myemail@myserver.de
You can also write a letter to ...";
$smarty->assign("text",$text);
So I think I HAVE to use some regex_replace in a custom modifier. So=20
here is my problem again: The function I defined for the callback=20
doesn't get called.
Am 11.03.2004 um 18:04 schrieb Monte Ohrt:
> The Smarty mailto function has some obfuscation built-in.
>
> http://smarty.php.net/manual/en/lan...tion.mailto.php
>
> On Thu, 2004-03-11 at 10:16, Gabriel Birke wrote:
href=3D\"mailto:$mailto\">$mailto</a>";
>
>
Post Follow-up to this messageGabriel writes: > So I think I HAVE to use some regex_replace in > a custom modifier. So here is my problem again: > The function I defined for the callback > doesn't get called. Silly question, but have you checked the code outside Smarty? Eg: if there were no matches being found based on your regexp, then the callback wouldn't be called, so have you tested the same functions with known search text? What happens if you subsitute the preg_replace_callback with preg_replace? (As it stands you should get your email addresses changed to the text "escape_mail"; if it doesn't either your regexp is wrong (looks ok to me) or the input text doesn't look the way you thought it did. Sorry if I'm teaching you to suck eggs here... -- Mark Rogers, More Solutions Ltd
Post Follow-up to this messageThank you for your suggestions. I've tried them all with no result,=20 changed something in the template - and voil=E0 everything worked. The=20= Smarty-cache has tricked me again :-( What a great feature and what a=20 great source of frustration! Thank you all for trying to help me. The function I posted works as I=20 thought. Gabriel > Silly question, but have you checked the code outside Smarty? Eg: if=20= > there > were no matches being found based on your regexp, then the callback=20 > wouldn't > be called, so have you tested the same functions with known search=20 > text? > > What happens if you subsitute the preg_replace_callback with=20 > preg_replace? > (As it stands you should get your email addresses changed to the text > "escape_mail"; if it doesn't either your regexp is wrong (looks ok to=20= > me) or > the input text doesn't look the way you thought it did. > > Sorry if I'm teaching you to suck eggs here... > > --=20 > Mark Rogers, > More Solutions Ltd > > --=20 > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.