Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: [SMARTY] Modifier with preg_replace_callback
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

Report this thread to moderator Post Follow-up to this message
Old Post
Monte Ohrt
03-19-04 06:29 PM


Re: [SMARTY] Modifier with preg_replace_callback
Well, 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>"; 
>
>

Report this thread to moderator Post Follow-up to this message
Old Post
Gabriel Birke
03-19-04 06:29 PM


Re: [SMARTY] Modifier with preg_replace_callback
Gabriel 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

Report this thread to moderator Post Follow-up to this message
Old Post
Mark Rogers
03-19-04 06:29 PM


Re: [SMARTY] Modifier with preg_replace_callback
Thank 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
>
>

Report this thread to moderator Post Follow-up to this message
Old Post
Gabriel Birke
03-19-04 06:29 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP Smarty Templates archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:00 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.