<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Hussein Harake</title>
	<atom:link href="http://harake.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://harake.wordpress.com</link>
	<description>web engineering blog</description>
	<lastBuildDate>Tue, 01 Mar 2011 11:26:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='harake.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/bc0b5b37c2307c0ac706643868baa01a?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Hussein Harake</title>
		<link>http://harake.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://harake.wordpress.com/osd.xml" title="Hussein Harake" />
	<atom:link rel='hub' href='http://harake.wordpress.com/?pushpress=hub'/>
		<item>
		<title>My Validation Class</title>
		<link>http://harake.wordpress.com/2010/02/07/my-validation-class/</link>
		<comments>http://harake.wordpress.com/2010/02/07/my-validation-class/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 13:57:50 +0000</pubDate>
		<dc:creator>harake</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[boolean decimal id ids integer Validation]]></category>

		<guid isPermaLink="false">http://harake.wordpress.com/?p=110</guid>
		<description><![CDATA[The class Download My Validation Class From http://github.com/harake This is a very basic class that allows you to add more public static functions to validate more data types other than integer, boolean, decimal, and ids How To Use It Currently we have 4 public static methods MyValidation::ValidateBoolean(); MyValidation::ValidateInteger(); MyValidation::ValidateDecimal(); MyValidation::ValidateIds(); Every method returns an array [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=harake.wordpress.com&amp;blog=11737176&amp;post=110&amp;subd=harake&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>The class</h3>
<p><a title="My Validation Class" href="http://github.com/harake/MyValidation" target="_blank">Download My Validation Class From http://github.com/harake</a></p>
<p>This is a very basic class that allows you to add more public static functions to validate more data types other than integer, boolean, decimal, and ids<br />
<span id="more-110"></span></p>
<hr />
<h3>How To Use It</h3>
<p>Currently we have 4 public static methods</p>
<ol>
<li>MyValidation::ValidateBoolean();</li>
<li>MyValidation::ValidateInteger();</li>
<li>MyValidation::ValidateDecimal();</li>
<li>MyValidation::ValidateIds();</li>
</ol>
<p>Every method returns an array of values or empty array on failure.</p>
<p>Every method can accept any of these sets of consecutive arguments</p>
<ol>
<li>first set
<ol>
<li>$value_or_array_of_values</li>
</ol>
</li>
<li>second set
<ol>
<li>$value_or_array_of_values</li>
<li>$array_of_possible_values</li>
</ol>
</li>
<li>third set
<ol>
<li>$value_or_array_of_values</li>
<li>$array_of_possible_values</li>
<li>$skip_invalid_values</li>
</ol>
</li>
<li>fourth set
<ol>
<li>$value_or_array_of_values</li>
<li>$array_of_possible_values</li>
<li>$skip_invalid_values</li>
<li>$min_acceptable_number_of_values</li>
</ol>
</li>
<li>fifth set
<ol>
<li>$value_or_array_of_values</li>
<li>$array_of_possible_values</li>
<li>$skip_invalid_values</li>
<li>$min_acceptable_number_of_values</li>
<li>$max_acceptable_number_of_values</li>
</ol>
</li>
</ol>
<hr />
<h3>Examples</h3>
<p>// To validate if the value 3 is an integer</p>
<pre><span style="color:#800000;">MyValidation::ValidateInteger(3)</span>
<span style="color:#800000;">MyValidation::ValidateInteger(array(3))</span></pre>
<hr size="1" />
// To validate if the value 3 is an integer that is either 3 or 4</p>
<pre><span style="color:#800000;">MyValidation::ValidateInteger(3, array(3, 4))</span>
<span style="color:#800000;">MyValidation::ValidateInteger(array(3), array(3, 4))</span></pre>
<hr size="1" />
// To validate if the array(3, 4, 5) is an array of integers<br />
// where every value is either 3 or 4 or 5 or</p>
<pre><span style="color:#800000;">MyValidation::ValidateInteger(array(3, 4, 5), array(3, 4, 5, 6))</span></pre>
<hr size="1" />
// To validate if the array(3, 4, 5, &#8216;k&#8217;) is an array of integers<br />
// and skip invalid integers</p>
<pre><span style="color:#800000;">MyValidation::ValidateInteger(array(3, 4, 5, 'k'), null, true);</span></pre>
<hr size="1" />
// To validate if the array(3, 4, 5, &#8216;k&#8217;) is an array of integers<br />
// where every value is either 3 or 4 or 5 or 6 and skip invalid integers</p>
<pre><span style="color:#800000;">MyValidation::ValidateInteger(array(3, 4, 5, 'k'), array(3, 4, 5, 6), true)</span></pre>
<hr size="1" />
// To validate if the array(3, 4, 5, 6, &#8216;k&#8217;) is an array of integers<br />
// and skip invalid integers but must have at least 2 valid integers</p>
<pre><span style="color:#800000;">MyValidation::ValidateInteger(array(3, 4, 5, 6, 'k'), null, true, 2)</span></pre>
<hr size="1" />
// To validate if the array(3, 4, 5, 6, &#8216;k&#8217;) is an array of integers<br />
// and do not skip invalid integers but must have at least 2 valid integers</p>
<pre><span style="color:#800000;">MyValidation::ValidateInteger(array(3, 4, 5, 6, 'k'), null, false, 2)</span></pre>
<hr size="1" />
// To validate if the array(3, 4, 5, 6, &#8216;k&#8217;) is an array of integers<br />
// and skip invalid integers but must have at most 3 valid integers</p>
<pre><span style="color:#800000;">MyValidation::ValidateInteger(array(3, 4, 5, 6, 'k'), null, true, null, 3)

</span></pre>
<p>Please leave a comment, If you like this article or have one or more remark(s) on it</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/harake.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/harake.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/harake.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/harake.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/harake.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/harake.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/harake.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/harake.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/harake.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/harake.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/harake.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/harake.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/harake.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/harake.wordpress.com/110/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=harake.wordpress.com&amp;blog=11737176&amp;post=110&amp;subd=harake&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://harake.wordpress.com/2010/02/07/my-validation-class/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">harake</media:title>
		</media:content>
	</item>
		<item>
		<title>The Resize Helper to Resize Images On The Fly</title>
		<link>http://harake.wordpress.com/2010/02/02/the-resize-helper-to-resize-images-on-the-fly/</link>
		<comments>http://harake.wordpress.com/2010/02/02/the-resize-helper-to-resize-images-on-the-fly/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 20:08:14 +0000</pubDate>
		<dc:creator>harake</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[resize image jpeg jpg png gif crop pad wrap]]></category>

		<guid isPermaLink="false">http://harake.wordpress.com/?p=84</guid>
		<description><![CDATA[The class Download The Resize Helper From http://github.com/harake Copy it to your &#8216;app\views\helpers&#8217; folder and rename it as resize.php The Resize Helper requirements The $helpers array member variable of your controller or your AppController, should look like this var $helpers = array (..., ..., ..., 'Resize'); The class tries to construct its two public member [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=harake.wordpress.com&amp;blog=11737176&amp;post=84&amp;subd=harake&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>The class</h3>
<p><a title="Resize Helper" href="http://github.com/harake/ResizeHelper" target="_blank">Download The Resize Helper From http://github.com/harake</a></p>
<p>Copy it to your &#8216;app\views\helpers&#8217; folder and rename it as resize.php</p>
<h3>The Resize Helper requirements</h3>
<p><span id="more-84"></span>The $helpers array member variable of your controller or your AppController, should look like this</p>
<pre><span style="color:#800000;">var $helpers = array (..., ..., ..., 'Resize');</span></pre>
<p>The class tries to construct its two public member variables $versions_store and $versions_public where $versions_store is the directory path of the current original image (usually outside the webroot) and $versions_public is the directory path of the current resized image (usually inside the webroot)</p>
<p>How does the class construct them?</p>
<p><span style="text-decoration:underline;">Priority of detection</span></p>
<ol>
<li>Either you set them explicitly in the view because they are public
<ul>
<li>1.2 style or before, should be an absolute path, the trailing DS is optional
<ul>
<li><span style="color:#800000;">$resize-&gt;versions_store = APP . &#8216;uploads&#8217; . DS;</span></li>
<li><span style="color:#800000;">$resize-&gt;versions_store = APP . &#8216;uploads&#8217;;</span></li>
</ul>
</li>
<li>1.2 style or before, the webroot itself (default)
<ul>
<li><span style="color:#800000;">$resize-&gt;versions_public = &#8221;;</span></li>
</ul>
</li>
<li>1.2 style or before, relative path to the webroot, the trailing DS is optional
<ul>
<li><span style="color:#800000;">$resize-&gt;versions_public = &#8216;files&#8217; . DS . &#8216;versions&#8217; . DS;</span></li>
<li><span style="color:#800000;">$resize-&gt;versions_public = &#8216;files&#8217; . DS . &#8216;versions&#8217;;</span></li>
</ul>
</li>
<li>1.2 style or before, absolute path, the trailing DS is optional
<ul>
<li><span style="color:#800000;">$resize-&gt;versions_public = WWW_ROOT . &#8216;files&#8217; . DS . &#8216;versions&#8217; . DS;</span></li>
<li><span style="color:#800000;">$resize-&gt;versions_public = WWW_ROOT . &#8216;files&#8217; . DS . &#8216;versions&#8217;;</span></li>
</ul>
</li>
<li>1.3 style or higher
<ul>
<li><span style="color:#800000;">$this-&gt;Resize-&gt;versions_public = &#8230;;</span></li>
<li><span style="color:#800000;">$this-&gt;Resize-&gt;versions_store = &#8230;;</span></li>
</ul>
</li>
</ul>
</li>
<li><span style="color:#000000;">Either in your configuration file (&#8216;app\config\bootstrap.php&#8217;) </span>
<ul>
<li><span style="color:#800000;">Configure::write(&#8216;versions_store&#8217;, &#8230;);</span></li>
<li><span style="color:#800000;">Configure::write(&#8216;versions_public&#8217;, &#8230;);</span></li>
</ul>
</li>
<li><span style="color:#000000;">Or by defining two constants in your configuration file(&#8216;app\config\bootstrap.php&#8217;) </span>
<ul>
<li><span style="color:#800000;">define(&#8216;VERSIONS_STORE&#8217;, &#8230;);</span></li>
<li><span style="color:#800000;">define(&#8216;VERSIONS_PUBLIC&#8217;, &#8230;);</span></li>
</ul>
</li>
</ol>
<h3>The Features In The Resize Helper</h3>
<p>When resizing every original image to a smaller one, we have to choose one of the three options</p>
<ol>
<li>wrap (fixed-ratio option)
<ul>
<li><span style="color:#800000;">$resize-&gt;wrap($filename, $destination_width, $destination_height);</span></li>
</ul>
</li>
<li>pad (complete the smaller destination box with empty pixels)
<ul>
<li><span style="color:#800000;">$resize-&gt;pad($filename, $destination_width, $destination_height, $x = 2, $y = 2);</span></li>
</ul>
</li>
<li>crop (rarely used, it crop-centered the smaller image)
<ul>
<li><span style="color:#800000;">$resize-&gt;crop($filename, $destination_width, $destination_height);</span></li>
</ul>
</li>
</ol>
<h3>Remember that</h3>
<ol>
<li>$filename is the relative path to the $versions_store cited above, example &#8216;image1.jpg&#8217;, &#8216;folder1&#8242; . DS . &#8216;image1.jpg&#8217;, &#8216;folder1&#8242; . DS . &#8216;folder2&#8242; . DS . &#8216;image1.jpg&#8217;, etc&#8230;</li>
<li>$destination_width and $destination_height are strictly positive integer</li>
</ol>
<p>Please leave a comment, If you like this article or have one or more remark(s) on it</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/harake.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/harake.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/harake.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/harake.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/harake.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/harake.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/harake.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/harake.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/harake.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/harake.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/harake.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/harake.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/harake.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/harake.wordpress.com/84/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=harake.wordpress.com&amp;blog=11737176&amp;post=84&amp;subd=harake&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://harake.wordpress.com/2010/02/02/the-resize-helper-to-resize-images-on-the-fly/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">harake</media:title>
		</media:content>
	</item>
		<item>
		<title>How to make the jQuery UI Accordion widget multiple?</title>
		<link>http://harake.wordpress.com/2010/02/01/how-to-make-the-jquery-ui-accordion-widget-multiple/</link>
		<comments>http://harake.wordpress.com/2010/02/01/how-to-make-the-jquery-ui-accordion-widget-multiple/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 10:12:54 +0000</pubDate>
		<dc:creator>harake</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[jQuery accordion UI]]></category>

		<guid isPermaLink="false">http://harake.wordpress.com/?p=74</guid>
		<description><![CDATA[One of the missing features in  the jQuery UI Acordion widget is the possiblity to have more than one expanded section. Now you can download the new source code that allows you to add the feature (option) multiple: true when you initialize your accordion instrument. Download The jQuery UI Accordion Widget From http://github.com/Harake Please leave [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=harake.wordpress.com&amp;blog=11737176&amp;post=74&amp;subd=harake&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One of the missing features in  the jQuery UI Acordion widget is the possiblity to have more than one expanded section.</p>
<p>Now you can download the new source code that allows you to add the feature (option) multiple: true when you initialize your accordion instrument.</p>
<p><a title="Download The jQuery UI Accordion Widget From http://github.com/Harake" href="http://github.com/Harake/Accordion">Download The jQuery UI Accordion Widget From http://github.com/Harake</a></p>
<p>Please leave a comment, If you like this article or have one or more remark(s) on it</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/harake.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/harake.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/harake.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/harake.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/harake.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/harake.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/harake.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/harake.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/harake.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/harake.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/harake.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/harake.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/harake.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/harake.wordpress.com/74/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=harake.wordpress.com&amp;blog=11737176&amp;post=74&amp;subd=harake&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://harake.wordpress.com/2010/02/01/how-to-make-the-jquery-ui-accordion-widget-multiple/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">harake</media:title>
		</media:content>
	</item>
		<item>
		<title>How to make Base64 encoding and decoding safe?</title>
		<link>http://harake.wordpress.com/2010/01/30/how-to-make-base64-encoding-and-decoding-safe/</link>
		<comments>http://harake.wordpress.com/2010/01/30/how-to-make-base64-encoding-and-decoding-safe/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 23:29:46 +0000</pubDate>
		<dc:creator>harake</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[safe base64 encoding decoding]]></category>

		<guid isPermaLink="false">http://harake.wordpress.com/?p=53</guid>
		<description><![CDATA[base64 and the PHP manual string base64_encode ( string data ) base64_encode() returns data encoded with base64. This encoding is designed to make binary data survive transport through transport layers that are not 8-bit clean, such as mail bodies. Base64-encoded data takes about 33% more space than the original data. Example 1. base64_encode() example &#60;?php [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=harake.wordpress.com&amp;blog=11737176&amp;post=53&amp;subd=harake&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>base64 and the PHP manual</h2>
<p>string <strong>base64_encode </strong>( string data )<br />
<strong>base64_encode() </strong>returns data encoded with base64.<br />
This encoding is designed to make binary data survive transport through transport layers that are not 8-bit clean, such as mail bodies.<br />
Base64-encoded data takes about 33% more space than the original data.</p>
<p><strong>Example 1. base64_encode() example</strong></p>
<pre><span style="color:#800000;">&lt;?php</span>
<span style="color:#800000;">$str = 'This is an encoded string';</span>
<span style="color:#800000;">echo base64_encode($str);</span>
<span style="color:#800000;">?&gt;  </span></pre>
<p>This example will produce:</p>
<pre><span style="color:#800000;">VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==
</span></pre>
<p><span id="more-53"></span></p>
<hr />
<h2>Do we really need the base64?</h2>
<p>As far as I know, data at any rate should not be converted in database because conversion:</p>
<ol>
<li>consumes more memory resources (HDD and / OR RAM)</li>
<li>consumes more processing resources (CPU and usually this affects performance)&#8230;</li>
</ol>
<p>In fact, sometimes we need the base64 not for storage but for data transportation<br />
example, some non-alpha-numeric characters can not be transported easily via URL.<br />
Cconverting by encoding any string to base-64 leads to another string where each character is one of this set<br />
{</p>
<ul>
<li> A to Z (26 characters)</li>
<li> a to z (26 characters)</li>
<li> 0 to 9 (10 characters)</li>
<li> + (the plus operator character)</li>
<li> / (the famous URL slash character)</li>
</ul>
<p>}<br />
so there are 64 possible characters.</p>
<p>But there is also the = (the equal operator character) which is used for padding when the original string is not a multiple of three characters.<br />
we are not here to discuss the concept whether it is right or not, but as everyone of us knows, the three characters</p>
<ul>
<li> &#8220;+&#8221;</li>
<li> &#8220;/&#8221;</li>
<li> &#8220;=&#8221;</li>
</ul>
<p>have special meanings in URL,  so it is better to convert them to some safe non-alpha-numeric characters</p>
<p>One of the successfull solution I have tested is converting the</p>
<ul>
<li>+ to &#8211; (the dash or the minus operator character)</li>
<li>/ to _ (the underscore)</li>
<li>= to * (the star or the multiply by operator character)</li>
</ul>
<hr />
<h2>The code</h2>
<p>So In each application that needs to safely transfer some variables via URL, two functions are required</p>
<pre><span style="color:#800000;">function safe_base64_encode($value) {
 if (!is_string($value)) {
 return false;
 }
 return str_replace(array('+', '/', '='), array('-', '_', '*'), base64_encode($value));
}
</span><span style="color:#800000;"> </span></pre>
<p>which returns the safe encoded base-64 string or false when the argument was not string</p>
<p>and</p>
<pre><span style="color:#800000;">function isBase64($value, $safe = false) {
 if (!is_string($value)) {
 return false;
 }
 if (!$safe) {
 $regexp = '/^([A-Za-z0-9\+\/]{4})*([A-Za-z0-9\+\/]{2}(=|[A-Za-z0-9\+\/])=)?$/';
 } else {
 $regexp = '/^([A-Za-z0-9\-_]{4})*([A-Za-z0-9\-_]{2}(\*|[A-Za-z0-9\-_])\*)?$/';
 }
 if (preg_match($regexp, $value) != 1) {
 return false;
 }
 if ($safe) {
 $value = str_replace(array('-', '_' ,'*'), array('+', '/' ,'='), $value);
 }
 return base64_decode($value);
}</span></pre>
<p>which is used to check if the first argument is base64-encoded where the second argument is to force the safe option, it returns false on error or the original string (base64-decoded)</p>
<p>Please leave a comment, If you like this article or have one or more remark(s) on it</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/harake.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/harake.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/harake.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/harake.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/harake.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/harake.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/harake.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/harake.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/harake.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/harake.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/harake.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/harake.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/harake.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/harake.wordpress.com/53/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=harake.wordpress.com&amp;blog=11737176&amp;post=53&amp;subd=harake&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://harake.wordpress.com/2010/01/30/how-to-make-base64-encoding-and-decoding-safe/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">harake</media:title>
		</media:content>
	</item>
		<item>
		<title>The MySQL Connection Manager for classic (no-ORM) queries</title>
		<link>http://harake.wordpress.com/2010/01/30/the-mysql-connection-manager-for-classic-no-orm-queries/</link>
		<comments>http://harake.wordpress.com/2010/01/30/the-mysql-connection-manager-for-classic-no-orm-queries/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 18:04:50 +0000</pubDate>
		<dc:creator>harake</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[mysql mysqli connection manager]]></category>

		<guid isPermaLink="false">http://harake.wordpress.com/?p=44</guid>
		<description><![CDATA[Singleton And Connection Manager Singleton: one class that (via itself) creates one and only one instance (of itself) if that instance was not created before, and always returns that instance. ConnectionManager: Class that acts as a a set of singletons, so it creates for each database account one and only one singleton. The default database [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=harake.wordpress.com&amp;blog=11737176&amp;post=44&amp;subd=harake&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Singleton And Connection Manager</h2>
<p><span style="text-decoration:underline;">Singleton</span>: one class that (via itself) creates one and only one instance (of itself) if that instance was not created before, and always returns that instance.</p>
<p><span style="text-decoration:underline;">ConnectionManager</span>: Class that acts as a a set of singletons, so it creates for each database account one and only one singleton.</p>
<p>The default database account in CakePHP is &#8216;default&#8217; and it is is of type mysql.</p>
<p>Since most of PHP developers are fans of MySQL (both the mysql and mysqli extensions), I created the class below, to show you how to integrate your old Mysql Connection Manager into the CakePHP framework.</p>
<p><span id="more-44"></span></p>
<h2>Mysql Connection Manager Class</h2>
<p><a title="MysqlConnectionManager" href="http://github.com/Harake/MysqlConnectionManager">Downloaded the Mysql Connection Manager From http://github.com/Harake</a></p>
<p>(I personally put the class in &#8220;app\libs\mysql&#8221; folder and name it as &#8220;mysql_connection_manager.php&#8221;)</p>
<hr />
<h3><strong>The Changes in your own “app\config\bootstrap.php”</strong></h3>
<p>Just add this function</p>
<pre><span style="color:#800000;">function cn($account = 'default') {</span>
<span style="color:#800000;">  if (!class_exists('MysqlConnectionManager')) {</span>
<span style="color:#800000;"></span><span style="color:#800000;">    include_once APP . 'libs' . DS . 'mysql' . DS . 'mysql_connection_manager.php';</span>
<span style="color:#800000;"></span><span style="color:#800000;">  }</span>
  <span style="color:#800000;">return MysqlConnectionManager::connect($account);</span>
<span style="color:#800000;">}</span></pre>
<hr />
<h3><strong>Where and how to use it</strong></h3>
<p>In general, it can be used anywhere in your application like this</p>
<p><span style="color:#000000;">/*<br />
</span></p>
<p><span style="color:#000000;">when you call $c = cn();</span></p>
<p><span style="color:#000000;">you are sure that a MySQL connection is created</span></p>
<p><span style="color:#000000;">if it was not existing (singleton pattern)</span></p>
<p><span style="color:#800000;"><span style="color:#000000;">*/</span><br />
</span></p>
<p><span style="color:#800000;"> </span></p>
<pre><span style="color:#800000;">$c = cn();
if ($c) {
 //...
 $id = $c-&gt;loadValue("SELECT MAX(id) FROM users WHERE status = 1");
 $ids = $c-&gt;loadColumn("SELECT id FROM users WHERE status = 1");
 $user = $c-&gt;loadSingle("SELECT * FROM users WHERE status = 1 LIMIT 1");
 $users = $c-&gt;load("SELECT * FROM users WHERE status = 1");
 //... and many more...just read the class to discover
}</span></pre>
<p>Please leave a comment, If you like this article or have one or more remark(s) on it</p>
<div id="_mcePaste" style="overflow:hidden;position:absolute;left:-10000px;top:386px;width:1px;height:1px;">function cn($account = &#8216;default&#8217;) {<br />
if (!class_exists(&#8216;MysqlConnectionManager&#8217;)) {<br />
if (floatval(Configure::read(&#8216;Cake.version&#8217;)) &lt; 1.3) {<br />
include_once APP . &#8216;libs&#8217; . DS . &#8216;mysql&#8217; . DS . &#8216;mysql_connection_manager.php&#8217;;<br />
} else {<br />
App::import(&#8216;Lib&#8217;, &#8216;mysql&#8217; . DS . &#8216;mysql_connection_manager&#8217;);<br />
}<br />
}<br />
return MysqlConnectionManager::connect($account);<br />
}</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/harake.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/harake.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/harake.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/harake.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/harake.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/harake.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/harake.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/harake.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/harake.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/harake.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/harake.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/harake.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/harake.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/harake.wordpress.com/44/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=harake.wordpress.com&amp;blog=11737176&amp;post=44&amp;subd=harake&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://harake.wordpress.com/2010/01/30/the-mysql-connection-manager-for-classic-no-orm-queries/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">harake</media:title>
		</media:content>
	</item>
		<item>
		<title>The Include Engine</title>
		<link>http://harake.wordpress.com/2010/01/30/the-include-engine/</link>
		<comments>http://harake.wordpress.com/2010/01/30/the-include-engine/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 11:36:24 +0000</pubDate>
		<dc:creator>harake</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[caching cache file engine include]]></category>

		<guid isPermaLink="false">http://harake.wordpress.com/2010/01/30/10/</guid>
		<description><![CDATA[IncludeEngine is a subclass of the CakePHP FileEngine class. IncludeEngine caches forever or temporarily one or more variables as PHP not as text<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=harake.wordpress.com&amp;blog=11737176&amp;post=10&amp;subd=harake&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Include Engine Features<strong> </strong>
<p> </p>
<p><strong> </strong></p>
</h2>
<p>The FileEngine is currently the default cache engine in CakePHP.</p>
<p>In this article I will change the behavior of the FileEngine caching class by sub-classing it to make it able to do the following:</p>
<ol>
<li> Creates/reads a cached PHP file (real PHP file) that stores one more variable(s).</li>
<li> Although IncludeEngine is used for temporary caching (by default), however, adding the key &#8216;forever&#8217; =&gt; true in its configuration will make this cached version &#8220;permanent&#8221; so the date-time checking is skipped</li>
<li> The &#8216;serialize&#8217; key of the configuration is still true by default, and is still recommend (more secure and even faster!) for any non-resource data type variable (int, float, string, boolean, array, object). However, you may ask the IncludeEngine to create a human readable (in our case non serialized) cached version of the variables you want to store (cache). So setting the &#8216;serialize&#8217; key of the configuration to false is secure for just scalar variables and scalar arrays (int, float string, boolean and arrays that are based on primitive scalar data type</li>
</ol>
<p><span id="more-10"></span></p>
<p> </p>
<hr />
<p> </p>
<h2>Include Engine Class</h2>
<p><a title="IncludeEngine" href="http://github.com/Harake/IncludeEngine">Downloaded the Include Engine From http://github.com/Harake</a></p>
<p>(I personally put the class in the &#8220;app\libs\cache&#8221; directory, and I name it as &#8220;include.php&#8221;)</p>
<p> </p>
<hr />
<p> </p>
<h3><strong>Changes in your own &#8220;app\config\bootstrap.php&#8221;</strong></h3>
<p>You can create more than one configuration for the include engine, but assume that you want only two, you should do something like this</p>
<pre><span style="color:#800000;">if (floatval(Configure::read('Cake.version')) &lt; 1.3) {
 include_once APP . 'libs' . DS . 'cache' . DS . 'include.php';
} else {
 include_once APPLIBS . 'cache' . DS . 'include.php';
}
</span><span style="color:#800000;">Cache::config('cfg1', array(
 'engine' =&gt; 'Include',
 'path' =&gt; CACHE . 'persistent' . DS,
 'prefix' =&gt; 'CFG1_',
 'serialize' =&gt; true
));
Cache::config('cfg2', array(
 'engine' =&gt; 'Include',
 'path' =&gt; CACHE . 'persistent' . DS,
 'prefix' =&gt; 'CFG2_',
 'forever' =&gt; true,
 'serialize' =&gt; true
));
Cache::config('default');</span></pre>
<p> </p>
<hr />
<p> </p>
<h3><strong>Where and how to use it</strong></h3>
<p>In general, it can be used anywhere in your application like this</p>
<pre><span style="color:#800000;">Cache::config('cfg1'); // Comment it for 1.3 or higher
$cached_vars = Cache::read('put here the filename', 'cfg1');
if (empty($cached_vars)) {
 //collect the variables with their values before caching them
 Cache::write('put here the filename', array('var1_name' =&gt; 'var1_value', 'var2_name' =&gt; 'var2_value'), 'cfg1');
 Cache::config('default'); // Comment it for 1.3 or higher
} else {
 Cache::config('default'); // Comment it for 1.3 or higher
 //variables are already cached, let us retrieve them
 $var1_name = $cached_vars['var1_name'];
 $var2_name = $cached_vars['var2_name'];
}</span></pre>
<p>Please leave a comment, If you like this article or have one or more remark(s) on it</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/harake.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/harake.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/harake.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/harake.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/harake.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/harake.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/harake.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/harake.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/harake.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/harake.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/harake.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/harake.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/harake.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/harake.wordpress.com/10/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=harake.wordpress.com&amp;blog=11737176&amp;post=10&amp;subd=harake&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://harake.wordpress.com/2010/01/30/the-include-engine/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">harake</media:title>
		</media:content>
	</item>
	</channel>
</rss>
