<?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>Bits 'n Bytes</title>
	<atom:link href="http://www.arnas.net/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.arnas.net/blog</link>
	<description></description>
	<lastBuildDate>Thu, 20 Oct 2011 10:05:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>gzdecode()</title>
		<link>http://www.arnas.net/blog/2011/10/gzdecode/</link>
		<comments>http://www.arnas.net/blog/2011/10/gzdecode/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 10:05:08 +0000</pubDate>
		<dc:creator>Arnas</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.arnas.net/blog/?p=132</guid>
		<description><![CDATA[It looks like with version 5.4 (currently in beta), PHP will include native gzdecode() function. Until now developers were writing their own implementation of this function and usually name it gzdecode(). Now when PHP has a native function, when you upgrade to 5.4 you will get an error: &#8220;Cannot redeclare gzdecode()&#8220;. If you get this [...]]]></description>
			<content:encoded><![CDATA[<p>It looks like with version 5.4 (currently in beta), PHP will include native gzdecode() function. Until now developers were writing their own implementation of this function and usually name it gzdecode(). Now when PHP has a native function, when you upgrade to 5.4 you will get an error: &#8220;<em><strong>Cannot redeclare gzdecode()</strong></em>&#8220;. If you get this error, find the file and the line number where this function is declared (this information should be in the error message) and surround the whole function with &#8220;if&#8221; statement:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php-brief" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> function_exists<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'gzdecode'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">function</span> gzdecode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$data</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// Your function code goes here</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.arnas.net/blog/2011/10/gzdecode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CodeIgniter JavaScript validation</title>
		<link>http://www.arnas.net/blog/2011/03/codeigniter-javascript-validation/</link>
		<comments>http://www.arnas.net/blog/2011/03/codeigniter-javascript-validation/#comments</comments>
		<pubDate>Wed, 02 Mar 2011 10:44:58 +0000</pubDate>
		<dc:creator>Arnas</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.arnas.net/blog/?p=87</guid>
		<description><![CDATA[I use CodeIgniter&#8217;s Form Validation library for back-end and jQuery Validation plugin for front-end validation. For my latest project I decided to combine them and here&#8217;s what I got so far. First things first &#8211; demo and source code. jQuery Validation plugin has this handy remote() method, that basically sends AJAX request to back-end script [...]]]></description>
			<content:encoded><![CDATA[<p>I use CodeIgniter&#8217;s <a href="http://codeigniter.com/user_guide/libraries/form_validation.html">Form Validation</a> library for back-end and jQuery <a href="http://docs.jquery.com/Plugins/validation">Validation</a> plugin for front-end validation. For my latest project I decided to combine them and here&#8217;s what I got so far.</p>
<p>First things first &#8211; <a href="http://arnas.net/blog/validation/index.php/form"><strong>demo</strong></a> and <a href="https://bitbucket.org/arnaslu/codeigniter-javascript-validation"><strong>source code</strong></a>.</p>
<p>jQuery Validation plugin has this handy <a href="http://docs.jquery.com/Plugins/Validation/Methods/remote#options">remote()</a> method, that basically sends AJAX request to back-end script with form field data. Response from back-end script is evaluated as JSON and must be <em>true</em> for valid fields. When string is returned, form field is treated as invalid and returned string is displayed as error message. This allows to return standard CI Form Validation error messages. The code below is an example of back-end script that can handle <a href="http://docs.jquery.com/Plugins/Validation/Methods/remote#options">remote()</a> method from jQuery Validation plugin. You would place this function as a method in your controller where form logic is handled.</p>

<div class="wp_syntax"><div class="code"><pre class="php-brief" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> remote<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Set JSON headers, no cache</span>
	<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Cache-Control: no-cache, must-revalidate'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Expires: Mon, 26 Jul 1997 05:00:00 GMT'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Content-type: application/json'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #0000ff;">$field_name</span> <span style="color: #339933;">=</span> <span style="color: #990000;">key</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$_POST</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Load validation rules set in constructor</span>
	<span style="color: #0000ff;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_rules</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_rules</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// For JSON response, we don't want error delimiters</span>
	<span style="color: #0000ff;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_error_delimiters</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// run_single() is a method extended from core validation library</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">run_single</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$field_name</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000000; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #0000ff;">$response</span> <span style="color: #339933;">=</span> validation_errors<span style="color: #009900;">&#40;</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: #0000ff;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #990000;">echo</span> json_encode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$response</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Notice CI Form Validation library is calling <em>run_single()</em> method. I extended base library to add this method, it work exactly the same as standard <em>run()</em> method, but checks only one field. You will need to copy/download my extended validation library to your /application/libraries/MY_Form_validation.php file. This extended library also has helper method called <em>jquery_options()</em> method, that generates JSON encoded string containing validation rules in a format acceptable to jQuery Validation plugin. You can write your own rules in your view file, but this definitely makes it easier.</p>
<p>Speaking of the view file, you will need jQuery and jQuery Validation plugin loaded. Both of them have CDNs, so you can load them like this:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre></div></div>

<p>When required JavaScript files are loaded, you need to call <em>validate()</em> method on your form selector and pass parameters as JSON string generated by <em>jquery_options()</em> method from my extended validation library. Here&#8217;s an example:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot;&gt;
	$(document).ready(function(){
		$('#signupform').validate(&lt;?php echo $jquery_validation ?&gt;);
	});
&lt;/script&gt;</pre></div></div>

<p>I uploaded the whole application folder to Bitbucket &#8211; <a href="https://bitbucket.org/arnaslu/codeigniter-javascript-validation">here</a>, but you only need these 3 files to see how t works:</p>
<p><a href="https://bitbucket.org/arnaslu/codeigniter-javascript-validation/src/tip/application/libraries/MY_Form_validation.php">/application/libraries/MY_Form_validation.php</a><br />
<a href="https://bitbucket.org/arnaslu/codeigniter-javascript-validation/src/tip/application/controllers/form.php">/application/controllers/form.php</a><br />
<a href="https://bitbucket.org/arnaslu/codeigniter-javascript-validation/src/tip/application/views/form.php">/application/views/form.php</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.arnas.net/blog/2011/03/codeigniter-javascript-validation/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Password hashing class (phpass) converted to CodeIgniter library</title>
		<link>http://www.arnas.net/blog/2010/06/password-hashing-class-phpass-converted-to-codeigniter-library/</link>
		<comments>http://www.arnas.net/blog/2010/06/password-hashing-class-phpass-converted-to-codeigniter-library/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 13:11:59 +0000</pubDate>
		<dc:creator>Arnas</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.arnas.net/blog/?p=57</guid>
		<description><![CDATA[Password hashing class phpass was suggested in /r/php/ so I decided to use it on one of my CodeIgniter applications. I changed a bit how constructor works to be able to load it as any other CodeIgniter library and modified it&#8217;s methods to be able to call them statically. If you want to give it [...]]]></description>
			<content:encoded><![CDATA[<p>Password hashing class <a href="http://www.openwall.com/phpass/">phpass</a> was suggested in <a href="http://reddit.com/r/php/">/r/php/</a> so I decided to use it on one of my CodeIgniter applications. I changed a bit how constructor works to be able to load it as any other CodeIgniter library and modified it&#8217;s methods to be able to call them statically.</p>
<p>If you want to give it a try &#8211; <a href="http://www.arnas.net/blog/wp-content/plugins/download-monitor/download.php?id=Hashing+library+for+CodeIgniter"><strong>download</strong></a> it and copy Hash.php to your /application/libraries directory.</p>
<p>&nbsp;<br />
In your controller, load the library:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php-brief" style="font-family:monospace;"><span style="color: #0000ff;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'hash'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>&nbsp;<br />
Now you can use static methods anywhere in your application &#8211; your auth library, users controller, etc. </p>
<p>&nbsp;<br />
For example, to hash a password you can do this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php-brief" style="font-family:monospace;"><span style="color: #0000ff;">$hash</span> <span style="color: #339933;">=</span> Hash<span style="color: #339933;">::</span><span style="color: #004000;">HashPassword</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">input</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'password'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>&nbsp;<br />
To verify password:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php-brief" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>Hash<span style="color: #339933;">::</span><span style="color: #004000;">CheckPassword</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">input</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'password'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$hash</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!==</span> <span style="color: #000000; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Login failed</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>&nbsp;<br />
Hope you&#8217;ll find it useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.arnas.net/blog/2010/06/password-hashing-class-phpass-converted-to-codeigniter-library/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>POP3/IMAP library for CodeIgniter</title>
		<link>http://www.arnas.net/blog/2010/05/pop3imap-library-for-codeigniter/</link>
		<comments>http://www.arnas.net/blog/2010/05/pop3imap-library-for-codeigniter/#comments</comments>
		<pubDate>Fri, 07 May 2010 22:11:26 +0000</pubDate>
		<dc:creator>Arnas</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.arnas.net/blog/?p=46</guid>
		<description><![CDATA[I was looking for POP3/IMAP library to read and delete emails from POP3/IMAP accounts but one I found on CodeIgniter forums was quite buggy. Fortunately I noticed this post on Reddit which featured Flourish PHP &#8220;unframework&#8221; and it&#8217;s fMailbox class. I tried to run fMailbox class stand-alone and it worked quite well, so I decided [...]]]></description>
			<content:encoded><![CDATA[<p>I was looking for POP3/IMAP library to read and delete emails from POP3/IMAP accounts but one I found on CodeIgniter forums was quite buggy. Fortunately I noticed this <a href="http://www.reddit.com/r/PHP/comments/c0qc7/pure_php_imap_pop3_message_retrieval_and_parsing/">post</a> on Reddit which featured <a href="http://flourishlib.com/">Flourish</a> PHP <em>&#8220;unframework&#8221;</em> and it&#8217;s <a href="http://flourishlib.com/docs/fMailbox">fMailbox</a> class.</p>
<p>I tried to run <a href="http://flourishlib.com/docs/fMailbox">fMailbox</a> class stand-alone and it worked quite well, so I decided to use it on my CodeIgniter application. I had to change how this class is initiated to use it as regular CodeIgniter library. Also in some places I had to replace Flourish exceptions with CodeIgniter&#8217;s error handling.</p>
<p>So, this is how you initiate library with just required parameters:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php-brief" style="font-family:monospace;"><span style="color: #0000ff;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'imap'</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'host'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'mail.example.com'</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'info@example.com'</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'password'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'letsplay'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #0000ff;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mailbox'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$config</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>More options are available:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="php-brief" style="font-family:monospace;"><span style="color: #0000ff;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'imap'</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'host'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'mail.example.com'</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'info@example.com'</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'password'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'letsplay'</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'port'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">993</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'secure'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'timeout'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #0000ff;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mailbox'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$config</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>And this is how you call methods:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php-brief" style="font-family:monospace;"><span style="color: #0000ff;">$messages</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mailbox</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">listMessages</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>So it works basically as documented <a href="http://flourishlib.com/docs/fMailbox">here</a>, but you have to pass initial arguments as array. Hope someone will find it useful, here&#8217;s the <a href="http://www.arnas.net/blog/wp-content/plugins/download-monitor/download.php?id=Mailbox+library+for+CodeIgniter"><b>download</b></a>, just copy Mailbox.php to your &#8220;libraries&#8221; directory and you should be good to go.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.arnas.net/blog/2010/05/pop3imap-library-for-codeigniter/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>CodeIgniter&#8217;s forum member ranks</title>
		<link>http://www.arnas.net/blog/2010/04/codeigniters-forum/</link>
		<comments>http://www.arnas.net/blog/2010/04/codeigniters-forum/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 10:42:27 +0000</pubDate>
		<dc:creator>Arnas</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[codeigniter]]></category>

		<guid isPermaLink="false">http://www.arnas.net/blog/?p=36</guid>
		<description><![CDATA[Ever wondered what those member ranks in CodeIgniter&#8217;s forum were all about and how to get one? Well there&#8217;s a little back-story posted by Derek Jones from EllisLab, Inc. (creators of CodeIgniter). [...] But our forum activity has increased so much in the past 1-2 years that there are now many people with over 1000 [...]]]></description>
			<content:encoded><![CDATA[<p>Ever wondered what those member ranks in <a href="http://www.codeigniter.com/" target="_blank">CodeIgniter&#8217;s</a> <a href="http://www.codeigniter.com/forums/" target="_blank">forum</a> were all about and how to get one? Well there&#8217;s a little back-story posted by Derek Jones from EllisLab, Inc. (creators of CodeIgniter).</p>
<blockquote><p>[...] But our forum activity has increased so much in the past 1-2 years that  there are now many people with over 1000 posts, and some above 2500,  5000, 10000, etc.  It seemed time to add some new ranks in to  accommodate the upper tiers, but the current names bore me.  They should  be fun, but not goofy, and should work well for both ExpressionEngine  and CodeIgniter users, and other communities we might have as EllisLab  creates them.  Hence, the lab metaphor.</p></blockquote>
<p><br/><br />
And here is a full table of member ranks on <a href="http://www.codeigniter.com/" target="_blank">CodeIgniter&#8217;s</a> <a href="http://www.codeigniter.com/forums/" target="_blank">forums</a>:</p>
<table border="0" style="margin-right: auto; margin-left: auto;">
<tbody>
<tr>
<td>0</td>
<td>Summer Student</td>
</tr>
<tr>
<td>30</td>
<td>Grad Student</td>
</tr>
<tr>
<td>100</td>
<td>Lab Assistant</td>
</tr>
<tr>
<td>300</td>
<td>Research Assistant</td>
</tr>
<tr>
<td>1000</td>
<td>Lab Technician</td>
</tr>
<tr>
<td>2500</td>
<td>Sr. Research Associate</td>
</tr>
<tr>
<td>5000</td>
<td>Research Scientist</td>
</tr>
<tr>
<td>10000</td>
<td>?????</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.arnas.net/blog/2010/04/codeigniters-forum/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Check if hour falls between two hours</title>
		<link>http://www.arnas.net/blog/2009/03/check-hour-falls-between-two-hours/</link>
		<comments>http://www.arnas.net/blog/2009/03/check-hour-falls-between-two-hours/#comments</comments>
		<pubDate>Sun, 15 Mar 2009 18:30:26 +0000</pubDate>
		<dc:creator>Arnas</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.arnas.net/blog/?p=16</guid>
		<description><![CDATA[Part of the program I&#8217;m writing had to check if given hour falls between two hours, for example, if 1 pm is between 5 am &#8211; 5 pm, or 11 pm is between 9 pm &#8211; 9 am. I couldn&#8217;t find snippet on the net so I wrote my own function: 1 2 3 4 [...]]]></description>
			<content:encoded><![CDATA[<p>Part of the program I&#8217;m writing had to check if given hour falls between two hours, for example, if 1 pm is between 5 am &#8211; 5 pm, or 11 pm is between 9 pm &#8211; 9 am. I couldn&#8217;t find snippet on the net so I wrote my own function:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="php-brief" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/**
 * Checks if given hour is between two hours (in 24 hour format)
 * if $hour is not specified it defaults to current hour
 * 
 * @return bool 
 * @param integer $start
 * @param integer $end
 * @param integer $hour[optional] 
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> is_between_hours<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$start</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$end</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$hour</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #0000ff;">$hour</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_null</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$hour</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'G'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">$hour</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$start</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">$end</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$start</span> <span style="color: #339933;">&gt;</span> <span style="color: #0000ff;">$end</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$hour</span> <span style="color: #339933;">&lt;</span> <span style="color: #0000ff;">$start</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$hour</span> <span style="color: #339933;">&gt;</span> <span style="color: #0000ff;">$end</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000000; font-weight: bold;">FALSE</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$hour</span> <span style="color: #339933;">&gt;=</span> <span style="color: #0000ff;">$start</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$hour</span> <span style="color: #339933;">&lt;=</span> <span style="color: #0000ff;">$end</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000000; font-weight: bold;">TRUE</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>If you know better way of doing it or have a question &#8211; please leave a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.arnas.net/blog/2009/03/check-hour-falls-between-two-hours/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SitePoint forums switched to nofollow</title>
		<link>http://www.arnas.net/blog/2009/03/sitepoint-forums-switched-nofollow/</link>
		<comments>http://www.arnas.net/blog/2009/03/sitepoint-forums-switched-nofollow/#comments</comments>
		<pubDate>Sat, 14 Mar 2009 17:15:30 +0000</pubDate>
		<dc:creator>Arnas</dc:creator>
				<category><![CDATA[SEO]]></category>
		<category><![CDATA[SitePoint]]></category>

		<guid isPermaLink="false">http://www.arnas.net/blog/?p=26</guid>
		<description><![CDATA[Just noticed this morning that my SitePoint Forum posts have rel=&#8221;nofollow&#8221; attribute added to signature links. Not cool. I always thought SitePoint was dofollow forum. After a little digging I found this post: Fluff posting on the forum. Apparently change was made on Nov 17th 2008 and SitePoint now requires at least 100 posts to [...]]]></description>
			<content:encoded><![CDATA[<p>Just noticed this morning that my <a href="http://www.sitepoint.com/forums/">SitePoint Forum</a> posts have <i>rel=&#8221;nofollow&#8221;</i> attribute added to signature links. Not cool. I always thought SitePoint was  dofollow forum. After a little digging I found this post: <a href="http://www.sitepoint.com/forums/showthread.php?t=583351">Fluff posting on the forum</a>. Apparently change was made on Nov 17th 2008 and SitePoint now requires at least 100 posts to have signature links without <i>rel=&#8221;nofollow&#8221;</i> attribute.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.arnas.net/blog/2009/03/sitepoint-forums-switched-nofollow/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Moving WordPress to another directory</title>
		<link>http://www.arnas.net/blog/2009/03/moving-wordpress-to-another-directory/</link>
		<comments>http://www.arnas.net/blog/2009/03/moving-wordpress-to-another-directory/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 02:22:19 +0000</pubDate>
		<dc:creator>Arnas</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.arnas.net/blog/?p=1</guid>
		<description><![CDATA[Yesterday I had to move WordPress directory for a client (don&#8217;t ask why). After following basic instructions outlined in Codex Moving WordPress page I had only one problem left &#8211; missing images in blog posts. In database they are saved using full path and were pointing to the old directory. I came up with following [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I had to move WordPress directory for a client (don&#8217;t ask why). After following basic instructions  outlined in <a href="http://codex.wordpress.org/Moving_WordPress">Codex Moving WordPress</a> page I had only one problem left &#8211; missing images in blog posts. In database they are saved using full path and were pointing to the old directory.</p>
<p>I came up with following query to fix the problem:</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">UPDATE</span> wp_posts 
<span style="color: #990099; font-weight: bold;">SET</span> guid <span style="color: #CC0099;">=</span> <span style="color: #000099;">replace</span><span style="color: #FF00FF;">&#40;</span>guid<span style="color: #000033;">,</span> <span style="color: #008000;">'http://website.com/dir1/'</span><span style="color: #000033;">,</span> <span style="color: #008000;">'http://website.com/dir2/'</span><span style="color: #FF00FF;">&#41;</span>
<span style="color: #990099; font-weight: bold;">WHERE</span> post_type <span style="color: #CC0099;">=</span> <span style="color: #008000;">'attachment'</span></pre></div></div>

<p>It looks in your wp_posts table and and replaces paths to uploaded files, in this case case &#8211; from &#8220;http://website.com/dir1/&#8221; to &#8220;http://website.com/dir2/&#8221;.</p>
<p>Use at your own risk!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.arnas.net/blog/2009/03/moving-wordpress-to-another-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

