[prev in list] [next in list] [prev in thread] [next in thread] 

List:       smarty-general
Subject:    Re: [SMARTY] Modifier with preg_replace_callback
From:       Gabriel Birke <birke () kontor4 ! de>
Date:       2004-03-12 8:27:37
Message-ID: 1EDB5456-73FF-11D8-85D6-003065FA313E () kontor4 ! de
[Download RAW message or body]

Well, yes, this would be very helpful if I just had some email address 
I wanted to generate a mailto from. My problem is that the email 
addresses are scattered throughout the text like this:

$text=	"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 
here is my problem again: The function I defined for the callback 
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/language.function.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=\"&#109;&#97;&#105;&#108;&#116;&#111;&#58;$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
>
>

-- 
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic