<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Juozas devBlog &#187; flash</title>
	<atom:link href="http://dev.juokaz.com/tag/flash/feed" rel="self" type="application/rss+xml" />
	<link>http://dev.juokaz.com</link>
	<description>Random ideas, scripts and facts</description>
	<lastBuildDate>Mon, 22 Mar 2010 10:48:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Passing data from PHP to Silverlight</title>
		<link>http://dev.juokaz.com/winphp-2009/passing-parameters-from-php-to-silverlight</link>
		<comments>http://dev.juokaz.com/winphp-2009/passing-parameters-from-php-to-silverlight#comments</comments>
		<pubDate>Fri, 15 May 2009 21:38:23 +0000</pubDate>
		<dc:creator>Juozas</dc:creator>
				<category><![CDATA[WinPhp 2009]]></category>
		<category><![CDATA[asynchronous]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[connect]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[params]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[winphp]]></category>

		<guid isPermaLink="false">http://dev.juokaz.com/?p=745</guid>
		<description><![CDATA[Only on rare cases applications created with Silverlight (or Flash) are static &#8211; it&#8217;s very common to have information coming from a RSS feed, REST service or any other data source. What is more important, these applications usually needs configuration variables (user name, language, products category, etc.) to be passed to them. But how to [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://dev.juokaz.com/wp-content/uploads/2009/04/microsoft_silverlight_c-269x300.jpg" alt="Silverlight" title="Silverlight" width="90" height="100" class="alignnone size-medium wp-image-457" />Only on rare cases applications created with <a href="http://en.wikipedia.org/wiki/Silverlight">Silverlight</a> (or Flash) are static &#8211; it&#8217;s very common to have information coming from a RSS feed, <a href="http://en.wikipedia.org/wiki/REST">REST</a> service or any other data source. What is more important, these applications usually needs configuration variables (user name, language, products category, etc.) to be passed to them. But how to do all that?</p>
<h5>Configuration syntax</h5>
<p>Flash uses <a href="http://www.permadi.com/tutorial/flashVars/index.html"><em>flashvars</em></a> <em>object</em> parameter which is easy to use and passed variables automatically become available within actionscript variables scope. Luckily, Silverlight has almost the same thing.</p>
<p>Flash: <em>name1=value1<strong>&#038;</strong>name2=value2<strong>&#038;</strong>name3=value3</em><br />
Silverlight: <em>name1=value1<strong>,</strong>name2=value2<strong>,</strong>name3=value3</em></p>
<p>To start with, lets create a simple script which will form an arguments string (you can use <em>array</em> of params and then implode with &#8216;,&#8217;, but for the sake of simplicity I just use static string):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$connect</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/users/juozas'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Connect=&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$connect</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;,id=1,somethingElse=true&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Inside an <em>object</em> element in HTML add this code (depending on framework you (not)use you may need to change it to work as a template or a view script):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;param name=&quot;initParams&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$args</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;</pre></div></div>

<h5>Reading configuration in Silverlight</h5>
<p><a href="http://dev.juokaz.com/wp-content/uploads/2009/05/silverlight-1.png"><img src="http://dev.juokaz.com/wp-content/uploads/2009/05/silverlight-1-150x150.png" alt="silverlight-1" title="silverlight-1" style="float: right; margin-left: 5px;" width="100" height="95" class="alignnone size-thumbnail wp-image-762" /></a>If you start with a default Silverlight project in Visual Studio, you initially have two classes: App and Page. <em>App</em> is a main class, which (by default) on start up creates a new <em>Page</em> instance and assigns it to a root visual element of itself (<em>App</em>), where <em>Page</em> is your actual Silverlight application (visual part, controls, etc.). Standard start up event in <em>App</em> looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">private</span> <span style="color: #0600FF;">void</span> Application_Startup<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, StartupEventArgs e<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">RootVisual</span> <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Page<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>To use parameters from HTML tag, we need to get <em>initParams</em> from the passed <strong>e</strong> argument (which has type of <a href="http://msdn.microsoft.com/en-us/library/system.windows.startupeventargs.aspx">StartupEventArgs</a>) and set corresponding properties of some object to their values. You can have global static configuration class, but (also for simplicity) I just pass them to the <em>Page</em> instance:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">private</span> <span style="color: #0600FF;">void</span> Application_Startup<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, StartupEventArgs e<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    Page page <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Page<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>e.<span style="color: #0000FF;">InitParams</span>.<span style="color: #0000FF;">Keys</span>.<span style="color: #0000FF;">Contains</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Connect&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;&amp;</span> 
        <span style="color: #008000;">!</span><span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #000000;">&#40;</span>e.<span style="color: #0000FF;">InitParams</span><span style="color: #000000;">&#91;</span><span style="color: #666666;">&quot;Connect&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
     page.<span style="color: #0000FF;">connectPath</span> <span style="color: #008000;">=</span> HttpUtility.<span style="color: #0000FF;">UrlDecode</span><span style="color: #000000;">&#40;</span>e.<span style="color: #0000FF;">InitParams</span><span style="color: #000000;">&#91;</span><span style="color: #666666;">&quot;Connect&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">RootVisual</span> <span style="color: #008000;">=</span> page<span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Here I&#8217;m setting <em>connectPath</em> using <em>Connect</em> from <em>initParams</em>. One last thing &#8211; don&#8217;t trust user input, if you have integers, use <em>Int32.Parse()</em> and always check if passed values are in range of expected values. It&#8217;s really important to remember that SQL injections and other similar attacks are also threat in Silverlight (as Flash also).</p>
<h5>Outside information sources</h5>
<p>However, not all properties can be passed initially &#8211; some times it&#8217;s required to refresh information from server during actual runtime (think <a href="http://en.wikipedia.org/wiki/Ajax_(programming)">AJAX</a>). You can easily create asynchronous calls to server from Silverlight too (works almost exactly the same as normal JavaScript AJAX script):</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> Page<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    InitializeComponent<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    LoadButton.<span style="color: #0000FF;">Click</span> <span style="color: #008000;">+=</span> <span style="color: #008000;">new</span> RoutedEventHandler<span style="color: #000000;">&#40;</span>LoadButton_Click<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0600FF;">void</span> LoadButton_Click<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, RoutedEventArgs e<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    var wc <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> WebClient<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    wc.<span style="color: #0000FF;">OpenReadCompleted</span>
            <span style="color: #008000;">+=</span><span style="color: #008000;">new</span> OpenReadCompletedEventHandler<span style="color: #000000;">&#40;</span>wc_OpenReadCompleted<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    wc.<span style="color: #0000FF;">OpenReadAsync</span><span style="color: #000000;">&#40;</span> <span style="color: #008000;">new</span> Uri<span style="color: #000000;">&#40;</span> <span style="color: #666666;">&quot;/script.php?id=1&quot;</span>, UriKind.<span style="color: #0000FF;">Relative</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    Text.<span style="color: #0000FF;">Text</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Loading...&quot;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0600FF;">void</span> wc_OpenReadCompleted<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, OpenReadCompletedEventArgs e<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span> e.<span style="color: #0000FF;">Error</span> <span style="color: #008000;">!=</span> <span style="color: #0600FF;">null</span> <span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #008080; font-style: italic;">// Do something with an error</span>
        Text.<span style="color: #0000FF;">Text</span> <span style="color: #008000;">=</span> e.<span style="color: #0000FF;">Error</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #0600FF;">else</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">try</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #008080; font-style: italic;">// e.Result has a type of Stream, so we need to read it first</span>
            <span style="color: #008080; font-style: italic;">// (not just cast to string)</span>
            StreamReader rdr <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> StreamReader<span style="color: #000000;">&#40;</span>e.<span style="color: #0000FF;">Result</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            Text.<span style="color: #0000FF;">Text</span> <span style="color: #008000;">=</span> rdr.<span style="color: #0000FF;">ReadToEnd</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
        <span style="color: #0600FF;">finally</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span> e.<span style="color: #0000FF;">Result</span> <span style="color: #008000;">!=</span> <span style="color: #0600FF;">null</span> <span style="color: #000000;">&#41;</span> e.<span style="color: #0000FF;">Result</span>.<span style="color: #0000FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p><a href="http://dev.juokaz.com/wp-content/uploads/2009/05/silverlight-2.png"><img src="http://dev.juokaz.com/wp-content/uploads/2009/05/silverlight-2-150x150.png" alt="silverlight-2" title="silverlight-2" style="float: right; margin-left: 5px;" width="100" height="95" class="alignnone size-thumbnail wp-image-764" /></a>This code creates <em>onClick</em> event which asynchronously downloads &#8220;/script.php?id=1&#8243; and sets results to <em>TextBlock</em> element named &#8220;Text&#8221;. You can use absolute URLs too, but don&#8217;t forget that cross-domain requests protection will try to block it. Look <a href="http://timheuer.com/blog/archive/2008/04/06/silverlight-cross-domain-policy-file-snippet-intellisense.aspx">here</a> to read more about how to avoid it. Not even localhost will work if you are testing with VisualStudio (witch creates temporary &#8220;ASP.NET development server&#8221; with random port (not 80)), so make sure to check it first. </p>
<p>As you can see it&#8217;s very easy and simple to create dynamical Silverlight applications. I have done some work with Flash too (probably more than with Silverlight, especially with <a href="http://en.wikipedia.org/wiki/ActionScript">ActionScript language</a>) and I can confirm that there isn&#8217;t much difference. Silverlight is more like <a href="http://en.wikipedia.org/wiki/Adobe_Flex">Flex</a> though.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.juokaz.com/winphp-2009/passing-parameters-from-php-to-silverlight/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spam-safe email links</title>
		<link>http://dev.juokaz.com/php/spam-safe-email-links</link>
		<comments>http://dev.juokaz.com/php/spam-safe-email-links#comments</comments>
		<pubDate>Tue, 10 Feb 2009 16:21:13 +0000</pubDate>
		<dc:creator>Juozas</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[anchor]]></category>
		<category><![CDATA[bin2hex]]></category>
		<category><![CDATA[crypt]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[encode]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[hide]]></category>
		<category><![CDATA[hiding]]></category>
		<category><![CDATA[image hide]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://dev.juokaz.com/?p=76</guid>
		<description><![CDATA[There are thousands of ways to protect your email from being read by a spam bot. Complex ones uses images or Flash to display email as graphics, other uses JavaScript to dynamically create email anchors. I always try to use simple and still powerful methods, which both work as expected and are easy to implement, [...]]]></description>
			<content:encoded><![CDATA[<p>There are thousands of ways to protect your email from being read by a spam bot. Complex ones uses images or Flash to display email as graphics, other uses JavaScript to dynamically create email anchors. I always try to use simple and still powerful methods, which both work as expected and are easy to implement, today I&#8217;m going to show email protection in my way.</p>
<p>For email addresses hiding I use simple <a href="http://www.php.net">PHP</a> function, which takes email address as a string and HEX-encodes it. This function can also create whole anchor tag for you if you specify text for anchor (<em>&lt;a&gt;TEXT&lt;/a&gt;</em>). Code looks like this (main part from <a href="http://www.smarty.net">Smarty</a> plugin &#8220;mailto&#8221;):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> getMailToEncoded <span style="color: #009900;">&#40;</span><span style="color: #000088;">$address</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$address_prepend</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'mailto:'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$address_encode</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$x</span> <span style="color: #339933;">&lt;</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$address_prepend</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$x</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	    <span style="color: #000088;">$address_encode</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">''</span> <span style="color: #339933;">.</span> <span style="color: #990000;">bin2hex</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$address_prepend</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">';'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$x</span> <span style="color: #339933;">&lt;</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$address</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$x</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	   <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'!\w!'</span><span style="color: #339933;">,</span><span style="color: #000088;">$address</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$address_encode</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'%'</span> <span style="color: #339933;">.</span> <span style="color: #990000;">bin2hex</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$address</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	   <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$address_encode</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$address</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	   <span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span>
           <span style="color: #b1b100;">return</span> <span style="color: #000088;">$address_encode</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$text_encode</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$x</span> <span style="color: #339933;">&lt;</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$x</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	   <span style="color: #000088;">$text_encode</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">''</span> <span style="color: #339933;">.</span> <span style="color: #990000;">bin2hex</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">';'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'&lt;a href=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$address_encode</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$text_encode</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/a&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> getMailToEncoded <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'juozas@juokaz.com'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'email me'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Output will look like this: <a href="mailto:%6a%75%6f%7a%61%73@%6a%75%6f%6b%61%7a.%63%6f%6d">email me</a>, but actual HTML code has been transformed to:</p>
<p>&lt;a href=&#8221;&amp;#x6d;&amp;#x61;&amp;#x69;&amp;#x6c;&amp;#x74;&amp;#x6f;&amp;#x3a;%6a%75%6f%7a%61%73@%6a%75%6f%6b%61%7a.%63%6f%6d&#8221;&gt;&amp;#x65;&amp;#x6d;&amp;#x61;&amp;#x69;&amp;#x6c;&amp;#x20;&amp;#x6d;&amp;#x65;&lt;/a&gt;</p>
<p>Nasty! Bots are getting smarter and smarter, so after a while they will understand this code, but for initial protection this code works well. If you want additional protection, you can easily modify this function to put output in javascript block, where hex-encoded string is outputted by unescape() and then eval() functions. Try it!</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.juokaz.com/php/spam-safe-email-links/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
