<?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>0plus1 Blog</title>
	<atom:link href="http://0plus1.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://0plus1.com/blog</link>
	<description>Code snippets and programming news</description>
	<lastBuildDate>Fri, 13 Aug 2010 14:20:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Append value to multiselect with jquery</title>
		<link>http://0plus1.com/blog/2010/08/append-value-to-multiselect-with-jquery/</link>
		<comments>http://0plus1.com/blog/2010/08/append-value-to-multiselect-with-jquery/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 10:24:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://0plus1.com/blog/?p=44</guid>
		<description><![CDATA[This is a simple function to append values to a multiselect. In the comments you&#8217;ll find the explanation of each command. function appendMulti(value,target){ //Get old values from multiselect (they are an array) oldvalues= $(target).val(); //We need to check if the multiselect is empty if(oldvalues){ //It's not empty //Find the lenght of the array, the beauty [...]]]></description>
			<content:encoded><![CDATA[<p>This is a simple function to append values to a multiselect. In the comments you&#8217;ll find the explanation of each command.</p>
<pre class="brush: jscript;">
function appendMulti(value,target){
    //Get old values from multiselect (they are an array)
	oldvalues= $(target).val();
	//We need to check if the multiselect is empty
	if(oldvalues){
        //It's not empty
		//Find the lenght of the array, the beauty of this is that since arrays starts from 0, this number will always be the next available slot
		key = value.length;
	} else {
        //It's empty
		//Initialize a new array and set the key to the first element
		var oldvalues = [];
		key = 0;
	}
	//Append new value to the array
	oldvalues[key] = value;
	//Set the new values
	$(target).val(oldvalues);

	return true;
}
</pre>
<p>You can call the function like this:</p>
<pre class="brush: jscript;">
appendMulti('value','#multiselect');
</pre>
]]></content:encoded>
			<wfw:commentRss>http://0plus1.com/blog/2010/08/append-value-to-multiselect-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ajax calls vs MSSql</title>
		<link>http://0plus1.com/blog/2010/06/ajax-calls-vs-mssql/</link>
		<comments>http://0plus1.com/blog/2010/06/ajax-calls-vs-mssql/#comments</comments>
		<pubDate>Tue, 29 Jun 2010 13:40:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[utf-8]]></category>
		<category><![CDATA[windows-1252]]></category>

		<guid isPermaLink="false">http://0plus1.com/blog/?p=42</guid>
		<description><![CDATA[Please note that this article can be applied to any non utf-8 encoding. I recently needed to send data using ajax to an MSSql 2000 database (which requires windows-1252). As you may know javascript sends data encoded in utf-8 (utf-16 to be more precise), this must be accepted as a fact thus making the use [...]]]></description>
			<content:encoded><![CDATA[<p>Please note that this article can be applied to any non utf-8 encoding.</p>
<p>I recently needed to send data using ajax to an MSSql 2000 database (which requires windows-1252).<br />
As you may know javascript sends data encoded in utf-8 (<a href="http://interglacial.com/javascript_spec/a-8.html">utf-16 to be more precise</a>), this must be accepted as a fact thus making the use of a php function to convert the encoding before sending to the database. Here is the snippet I use:</p>
<pre class="brush: php;">
function convertor($array){
	if (is_array($array) &amp;&amp; count($array) &gt; 0){
		foreach ($array as $k =&gt; $v){
			$return[$k] = mb_convert_encoding($v, &quot;iso-8859-1&quot;,&quot;UTF-8&quot;);
		}
	} elseif (!empty($array)) {
		$return = mb_convert_encoding($array, &quot;iso-8859-1&quot;,&quot;UTF-8&quot;);
	} else {
		return false;
	}
	return $return;
}
</pre>
<p>Basically what it does is to check if we have an array or a single value then proceed to convert it to the desired encoding (in my case iso-8859-1), after converting the values these can be safely stored into the database.</p>
<p>I have also to add that I&#8217;ve encountered some jquery plugins that messes with the encoding of the strings. To be on the safe side you may use this line:</p>
<pre class="brush: jscript;">
unescape(encodeURIComponent(string))
</pre>
]]></content:encoded>
			<wfw:commentRss>http://0plus1.com/blog/2010/06/ajax-calls-vs-mssql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jquery-ui dialog with ajax how to avoid a common error</title>
		<link>http://0plus1.com/blog/2010/05/jquery-ui-dialog-with-ajax-how-to-avoid-a-common-error/</link>
		<comments>http://0plus1.com/blog/2010/05/jquery-ui-dialog-with-ajax-how-to-avoid-a-common-error/#comments</comments>
		<pubDate>Mon, 31 May 2010 14:40:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery-ui]]></category>

		<guid isPermaLink="false">http://0plus1.com/blog/?p=37</guid>
		<description><![CDATA[I&#8217;ve made this post because I got asked why this snippet gave problems: $.ajax({ type: &#34;POST&#34;, url: &#34;somepage.php&#34;, success: function(html){$(&#34;#someDiv&#34;).html(html).dialog();} }); The problem with this code is that it creates a new instance of dialog each time, basically adding a new dialog div in the html for each call. Aside from being unable to reopen [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve made this post because I got asked why this snippet gave problems:</p>
<pre class="brush: jscript;">
$.ajax({
   type: &quot;POST&quot;, url: &quot;somepage.php&quot;,
   success: function(html){$(&quot;#someDiv&quot;).html(html).dialog();}
});
</pre>
<p>The problem with this code is that it creates a new instance of dialog each time, basically adding a new dialog div in the html for each call.<br />
Aside from being unable to reopen the dialog after closing it, your are replicating your ajax code several times across the webpage creating all sort of problems with the jquery selectors.</p>
<p>The jquery-ui docs do not expalin well this issue, so to avoid headache here is the correct code:</p>
<pre class="brush: jscript;">
$(function() {
   $(&quot;#someDiv&quot;).dialog({ autoOpen: false });
});
</pre>
<p>then in the ajax call:</p>
<pre class="brush: jscript;">
$.ajax({
   type: &quot;POST&quot;, url: &quot;somepage.php&quot;,
   success: function(html){$(&quot;#someDiv&quot;).html(html).dialog('open');}
});
</pre>
]]></content:encoded>
			<wfw:commentRss>http://0plus1.com/blog/2010/05/jquery-ui-dialog-with-ajax-how-to-avoid-a-common-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>European Countries array</title>
		<link>http://0plus1.com/blog/2009/06/european-countries-array/</link>
		<comments>http://0plus1.com/blog/2009/06/european-countries-array/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 09:05:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[european countries array]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://0plus1.com/blog/?p=31</guid>
		<description><![CDATA[We recently had to create a select reserved only to contries from the european union, here&#8217;s the array with the standard countries codes: $eu_countries = array( &#34;AT&#34; =&#62; &#34;Austria&#34;, &#34;BE&#34; =&#62; &#34;Belgium&#34;, &#34;BG&#34; =&#62; &#34;Bulgaria&#34;, &#34;CY&#34; =&#62; &#34;Cyprus&#34;, &#34;CZ&#34; =&#62; &#34;Czech Republic&#34;, &#34;DK&#34; =&#62; &#34;Denmark&#34;, &#34;EE&#34; =&#62; &#34;Estonia&#34;, &#34;FI&#34; =&#62; &#34;Finland&#34;, &#34;FR&#34; =&#62; &#34;France&#34;, &#34;DE&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>We recently had to create a <em>select</em> reserved only to contries from the european union, here&#8217;s the array with the standard countries codes:</p>
<pre class="brush: php;">
$eu_countries = array(
  &quot;AT&quot; =&gt; &quot;Austria&quot;,
  &quot;BE&quot; =&gt; &quot;Belgium&quot;,
  &quot;BG&quot; =&gt; &quot;Bulgaria&quot;,
  &quot;CY&quot; =&gt; &quot;Cyprus&quot;,
  &quot;CZ&quot; =&gt; &quot;Czech Republic&quot;,
  &quot;DK&quot; =&gt; &quot;Denmark&quot;,
  &quot;EE&quot; =&gt; &quot;Estonia&quot;,
  &quot;FI&quot; =&gt; &quot;Finland&quot;,
  &quot;FR&quot; =&gt; &quot;France&quot;,
  &quot;DE&quot; =&gt; &quot;Germany&quot;,
  &quot;GR&quot; =&gt; &quot;Greece&quot;,
  &quot;HU&quot; =&gt; &quot;Hungary&quot;,
  &quot;IE&quot; =&gt; &quot;Ireland&quot;,
  &quot;IT&quot; =&gt; &quot;Italy&quot;,
  &quot;LV&quot; =&gt; &quot;Latvia&quot;,
  &quot;LT&quot; =&gt; &quot;Lithuania&quot;,
  &quot;LU&quot; =&gt; &quot;Luxembourg&quot;,
  &quot;MT&quot; =&gt; &quot;Malta&quot;,
  &quot;NL&quot; =&gt; &quot;Netherlands&quot;,
  &quot;PL&quot; =&gt; &quot;Poland&quot;,
  &quot;PT&quot; =&gt; &quot;Portugal&quot;,
  &quot;RO&quot; =&gt; &quot;Romania&quot;,
  &quot;SK&quot; =&gt; &quot;Slovakia (Slovak Republic)&quot;,
  &quot;SI&quot; =&gt; &quot;Slovenia&quot;,
  &quot;ES&quot; =&gt; &quot;Spain&quot;,
  &quot;SE&quot; =&gt; &quot;Sweden&quot;,
  &quot;GB&quot; =&gt; &quot;United Kingdom&quot;
);
</pre>
<p><a href="http://europa.eu/abc/european_countries/index_en.htm">source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://0plus1.com/blog/2009/06/european-countries-array/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to allow ad-sense bot to crawl phpbb3 private forums</title>
		<link>http://0plus1.com/blog/2009/05/how-to-allow-ad-sense-bot-to-crawl-phpbb3-private-forums/</link>
		<comments>http://0plus1.com/blog/2009/05/how-to-allow-ad-sense-bot-to-crawl-phpbb3-private-forums/#comments</comments>
		<pubDate>Fri, 29 May 2009 10:04:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Communities]]></category>
		<category><![CDATA[ad-sense]]></category>
		<category><![CDATA[phpbb3]]></category>
		<category><![CDATA[private forum]]></category>

		<guid isPermaLink="false">http://0plus1.com/blog/?p=26</guid>
		<description><![CDATA[If you operate a forum with private sections and public section, you&#8217;ll find that the ads that ad-sense pushes on your website are created based solely on the public content. If you want more accurate result you may want to look into the ad-sense&#8217; s &#8220;Site Authentication&#8221; feature. Here&#8217;s a small how-to on how to [...]]]></description>
			<content:encoded><![CDATA[<p>If you operate a forum with private sections and public section, you&#8217;ll find that the ads that ad-sense pushes on your website are created based solely on the public content. If you want more accurate result you may want to look into the ad-sense&#8217; s &#8220;<strong>Site Authentication</strong>&#8221; feature. Here&#8217;s a small how-to on how to achieve this:</p>
<p><strong>phpbb3</strong></p>
<ul>
<li>Create a user in the acp (for this example sake let&#8217;s use: adsense as username and adsense as password).</li>
<li>Give him permission based on your forum structure, we advise to give him read-only access on the whole forum.</li>
</ul>
<p><strong>ad-sense</strong></p>
<ul>
<li>go to the <em>AdSense Setup</em> tab, then click on the <em>Site Authentication</em> section.</li>
<li>click on the <em>add a login</em> link</li>
<li>Set it like this:
<ul>
<li><strong>Restricted Directory or URL:</strong> the forum url (example: http://www.example.com/forum)</li>
<li><strong>Authentication URL:</strong> the path to the ucp.php?mode=login file (example: http://www.example.com/forum/ucp.php?mode=login)</li>
<li><strong>Authentication method:</strong> POST</li>
<li><strong>Parameters:</strong> (you have to add them manually)
<ul>
<li>Attribute: login &#8211; Value: Login</li>
<li>Attribute: password &#8211; Value: userpassword (example: adsense)</li>
<li>Attribute: username &#8211; Value: username (example: adsense)</li>
</ul>
</ul>
</li>
<li>Now click on: Test My Authentication URL to check if everything went ok</li>
<ul>
<p>Hope this will help you</p>
]]></content:encoded>
			<wfw:commentRss>http://0plus1.com/blog/2009/05/how-to-allow-ad-sense-bot-to-crawl-phpbb3-private-forums/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>print_r output beautifier</title>
		<link>http://0plus1.com/blog/2009/05/print_r-output-beautifier/</link>
		<comments>http://0plus1.com/blog/2009/05/print_r-output-beautifier/#comments</comments>
		<pubDate>Wed, 13 May 2009 15:42:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[print_r]]></category>

		<guid isPermaLink="false">http://0plus1.com/blog/?p=9</guid>
		<description><![CDATA[Today I wrote a script that needed to manipulate several multidimensional arrays, some of them pretty deep. The standard php function print_r is an hellish mess, browsing through the marvellous php.net documentation I&#8217;ve found several examples to beautify the output of print_r (just to give credit: &#8220;Bob&#8221; and &#8220;Everett&#8221; were my inspiration) since no one [...]]]></description>
			<content:encoded><![CDATA[<p>Today I wrote a script that needed to manipulate several multidimensional arrays, some of them pretty deep.</p>
<p>The standard php function print_r is an hellish mess, browsing through the marvellous php.net documentation I&#8217;ve found several examples to beautify the output of print_r (just to give credit: &#8220;Bob&#8221; and &#8220;Everett&#8221; were my inspiration) since no one actually did it the way I wanted I made a custom one myself:</p>
<pre class="brush: php;">
function print_rr($array){
    foreach($array as $key=&gt;$value){
       if(is_array($value)){
          $id = md5(rand());
          echo '[&lt;a href=&quot;#&quot; onclick=&quot;return expandParent(\''.$id.'\')&quot;&gt;'.$key.'&lt;/a&gt;]&lt;br /&gt;';
          echo '&lt;div id=&quot;'.$id.'&quot; style=&quot;display:none;margin:10px;border-left:1px solid; padding-left:5px;&quot;&gt;';
          print_rr($value, $count);
          echo '&lt;/div&gt;';
       } else {
       echo &quot;&lt;b&gt;$key&lt;/b&gt;: &quot;.$value.&quot;&lt;br /&gt;&quot;;
       }
    }
echo '&lt;script language=&quot;Javascript&quot;&gt;
function expandParent(id){toggle=&quot;block&quot;;if(document.getElementById(id).style.display==&quot;block&quot;){toggle=&quot;none&quot;}document.getElementById(id).style.display=toggle};
&lt;/script&gt;';
}
</pre>
<p>Feel free to use it anyway you like it.</p>
]]></content:encoded>
			<wfw:commentRss>http://0plus1.com/blog/2009/05/print_r-output-beautifier/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Welcome</title>
		<link>http://0plus1.com/blog/2009/05/welcome/</link>
		<comments>http://0plus1.com/blog/2009/05/welcome/#comments</comments>
		<pubDate>Wed, 13 May 2009 14:27:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[0plus1]]></category>
		<category><![CDATA[welcome]]></category>

		<guid isPermaLink="false">http://0plus1.com/blog/?p=3</guid>
		<description><![CDATA[Welcome to the official blog from 0plus1.]]></description>
			<content:encoded><![CDATA[<p>Welcome to the official blog from 0plus1.</p>
]]></content:encoded>
			<wfw:commentRss>http://0plus1.com/blog/2009/05/welcome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
