<?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>OhRyan.ca &#187; php</title>
	<atom:link href="http://ohryan.ca/blog/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://ohryan.ca/blog</link>
	<description>Canadian Tech News, Hacks &#38; How To</description>
	<lastBuildDate>Wed, 25 Jan 2012 06:46:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Assault on the Hash (or how to make secure your passwords)</title>
		<link>http://ohryan.ca/blog/2011/07/04/assault-on-the-hash-or-how-to-make-secure-your-passwords/</link>
		<comments>http://ohryan.ca/blog/2011/07/04/assault-on-the-hash-or-how-to-make-secure-your-passwords/#comments</comments>
		<pubDate>Mon, 04 Jul 2011 05:47:19 +0000</pubDate>
		<dc:creator>RyanN</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[passwords]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://ohryan.ca/blog/?p=1527</guid>
		<description><![CDATA[In a recent episode of Build &#38; Analyze Marco Armet (creator of Instapaper) explained that the standard practice of salting a hash is no longer a really good way to secure passwords. CPUs (and GPUs) are so fast that they can effectively guess your salt in a reasonable amount of time*. The solution, use bcrypt. [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://5by5.tv/buildanalyze/31" target="_blank">a recent episode of Build &amp; Analyze</a> <a href="http://www.marco.org/about" target="_blank">Marco Armet</a> (creator of <a href="http://www.instapaper.com/" target="_blank">Instapaper</a>) explained that the standard practice of <a href="http://en.wikipedia.org/wiki/Salt_(cryptography)">salting a hash</a> is no longer a really good way to secure passwords. CPUs (and GPUs) are so fast that they can effectively guess your salt in a reasonable amount of time*.</p>
<p>The solution, <a href="http://codahale.com/how-to-safely-store-a-password/">use bcrypt</a>. Essentially, it&#8217;s an extremely slow hashing algorithm.</p>
<p>To me this seems a little bit like security through obscurity, every once in awhile &#8211; as CPU speed increases - you&#8217;ll have to update your algorithm to generate hashes even slower.</p>
<p>See also.</p>
<ul>
<li><a href="http://www.marco.org/2011/06/29/simple-php-bcrypt-class-phpass">Marco&#8217;s Blog Post</a>.</li>
<li><a href="https://gist.github.com/1053158">His PHP implementation of bcrypt</a>.</li>
</ul>
<p><small>*<a href="http://www.cryptopp.com/benchmarks-amd64.html">A modern server can calculate over 300MB of hash data per second!</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://ohryan.ca/blog/2011/07/04/assault-on-the-hash-or-how-to-make-secure-your-passwords/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To: File Upload Progress Bar. No Flash. No PHP addons.</title>
		<link>http://ohryan.ca/blog/2011/06/28/how-to-file-upload-progress-bar-no-flash-no-php-addons/</link>
		<comments>http://ohryan.ca/blog/2011/06/28/how-to-file-upload-progress-bar-no-flash-no-php-addons/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 02:11:20 +0000</pubDate>
		<dc:creator>RyanN</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://ohryan.ca/blog/?p=1502</guid>
		<description><![CDATA[Upload progressbars are pretty common on the web these days, they add a touch of feedback to the long and mysterious process of uploading a file to a website. Unfortunately, the most common methods for doing so involve flash or baring that PHP addons that require a recompiling. In this post I&#8217;m going to talk about [...]]]></description>
			<content:encoded><![CDATA[<p>Upload progressbars are pretty common on the web these days, they add a touch of feedback to the long and mysterious process of uploading a file to a website. Unfortunately, the most common methods for doing so involve flash or baring that PHP addons that require a recompiling.</p>
<p>In this post I&#8217;m going to talk about creating an upload progress bar without the need for a clunky flash object. I&#8217;m going to do it with PHP, jQueryUI and a gracefully-degrading framework-independent library.</p>
<h1><span id="more-1502"></span></h1>
<h2>AJAX Upload</h2>
<p>I stumbled across the aptly named <a href="http://valums.com/ajax-upload/" target="_blank">AJAX Upload</a> code library (developed by <a href="http://valums.com/" target="_blank">Andrew Valums</a>) at work the other day.</p>
<p>The feature list is quite impressive:</p>
<blockquote>
<ul>
<li>multiple file select, progress-bar in FF, Chrome, Safari</li>
<li>drag-and-drop file select in FF, Chrome</li>
<li>uploads are cancellable</li>
<li>no external dependencies</li>
<li>doesn&#8217;t use Flash</li>
<li>fully working with https</li>
<li>keyboard support in FF, Chrome, Safari</li>
<li>tested in IE7,8; Firefox 3,3.6,4; Safari4,5; Chrome; Opera10.60;</li>
</ul>
</blockquote>
<p>The package includes a javascript library to handle DOM creation and magical ajax-ey transactions, as well as server-side code written in PHP, CGI, Java and Cold Fusion. The server-side code is required to manage the file upload, where some other solutions use <a href="http://php.net/manual/en/book.apc.php" target="_blank">APC</a> or <a href="http://pecl.php.net/package/uploadprogress" target="_blank">PECL&#8217;s uploadprogress</a>, Andrews code makes clever use of <a href="http://www.php.net/manual/en/stream.resources.php" target="_blank">PHP streams</a> to track the upload progress.</p>
<p>Relevant snippet from php.php:</p>
<pre class="brush:html">    function save($path) {
        $input = fopen("php://input", "r");
        $temp = tmpfile();
        $realSize = stream_copy_to_stream($input, $temp);
        fclose($input);

        if ($realSize != $this-&gt;getSize()){
            return false;
        }

        $target = fopen($path, "w");
        fseek($temp, 0, SEEK_SET);
        stream_copy_to_stream($temp, $target);
        fclose($target);

        return true;
    }</pre>
<p>Why didn&#8217;t I think of that?!</p>
<h2>The Javascript &amp; HTML</h2>
<p>Here&#8217;s an example of a really basic uploader utilizing jQueryUI&#8217;s progressbar.</p>
<pre>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;AJAX Upload Test&lt;/title&gt;
    &lt;link rel="stylesheet" href="/path/to/js/uploader/fileuploader.css" type="text/css" &gt;
    &lt;link rel="stylesheet" href="/path/to/js/css/blitzer/jquery-ui-1.8.13.custom.css" type="text/css" media="screen" title="no title" charset="utf-8"&gt;
    &lt;script src="/path/to/js/jquery-1.6.1.min.js"&gt;&lt;/script&gt;
    &lt;script src="/path/to/js/jquery-ui-1.8.13.custom.min.js"&gt;&lt;/script&gt;
    &lt;script src="/path/to/js/jquery.altAlert.js"&gt;&lt;/script&gt;
    &lt;script src="/path/to/js/uploader/fileuploader.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;div id="progressbar"&gt;&lt;/div&gt;
    &lt;a href="javascript:void(0)" id="uplbtn"&gt;Upload A File!&lt;/a&gt;
    &lt;div id="file-uploader"&gt;
        &lt;noscript&gt;
            &lt;p&gt;Please enable JavaScript to use file uploader.&lt;/p&gt;
            &lt;!-- or put a simple form for upload here --&gt;
        &lt;/noscript&gt;
    &lt;/div&gt;
    &lt;script&gt;
    $(function() {
            // Initialize the jQueryUI Progressbar
			$( "#progressbar" ).progressbar({
				value: 0
			});

			// Initialize the uploader
			uploader = new qq.FileUploaderBasic({
				debug: true,
				element: document.getElementById('file-uploader'),
				button: $('#uplbtn')[0],
		        action: '/js/uploader/uploader.php',
				multiple: false,

                // Update the progress bar
				onProgress: function(id, fileName, loaded, total){
					var percentLoaded = (loaded / total) * 100;
					$( "#progressbar" ).progressbar({
						value: percentLoaded
					});
				},                        

				// display a fancy message
				onComplete: function () {
                    alert('Tada!');
				}
		    });
	});
    &lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>The real key here is updating the progressbar value in the uploader&#8217;s onChange event.</p>
<p>So there you have it!</p>
]]></content:encoded>
			<wfw:commentRss>http://ohryan.ca/blog/2011/06/28/how-to-file-upload-progress-bar-no-flash-no-php-addons/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>DIGG: 4000% PERFORMANCE INCREASE BY SORTING IN PHP RATHER THAN MYSQL</title>
		<link>http://ohryan.ca/blog/2010/03/26/digg-4000-performance-increase-by-sorting-in-php-rather-than-mysql/</link>
		<comments>http://ohryan.ca/blog/2010/03/26/digg-4000-performance-increase-by-sorting-in-php-rather-than-mysql/#comments</comments>
		<pubDate>Fri, 26 Mar 2010 20:37:27 +0000</pubDate>
		<dc:creator>RyanN</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[digg]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://ohryan.ca/blog/?p=573</guid>
		<description><![CDATA[To scale at Digg they followed a set of practices very similar to those used at eBay. No joins, no foreign key constraints (to scale writes), primary key look-ups only, limited range queries, and joins were done in memory. When implementing the comment feature a 4,000 percent increase in performance was created by sorting in [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>To scale at Digg they followed a set of practices very similar to those used at eBay. No joins, no foreign key constraints (to scale writes), primary key look-ups only, limited range queries, and joins were done in memory. When implementing the comment feature a 4,000 percent increase in performance was created by sorting in PHP instead of MySQL. All this effort required to make a relational database scale basically meant you were using a non-relational database anyway. So why not just use a non-relational database from the start?</p>
<p>[via <a href="http://highscalability.com/blog/2010/3/23/digg-4000-performance-increase-by-sorting-in-php-rather-than.html" target="_blank">High Scalability</a>]</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://ohryan.ca/blog/2010/03/26/digg-4000-performance-increase-by-sorting-in-php-rather-than-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To: Exclude Words Like &#8220;An, A, The&#8221; From Alphabetized MySQL ORDER</title>
		<link>http://ohryan.ca/blog/2009/07/17/how-to-exclude-words-like-an-a-the-from-alphabetized-mysql-order/</link>
		<comments>http://ohryan.ca/blog/2009/07/17/how-to-exclude-words-like-an-a-the-from-alphabetized-mysql-order/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 15:10:42 +0000</pubDate>
		<dc:creator>RyanN</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://ohryan.ca/blog/?p=419</guid>
		<description><![CDATA[When ordering lists of names or titles it&#8217;s sometimes desirable to exclude articles or other words from the order clause (eg. you want &#8220;The Burning Hell&#8221; to show up before &#8220;Great Lake Swimmers&#8221; in a list ordered by name). Early on in my career I must have assumed it was not possible and never bothered [...]]]></description>
			<content:encoded><![CDATA[<p>When ordering lists of names or titles it&#8217;s sometimes desirable to exclude articles or other words from the order clause (eg. you want &#8220;The Burning Hell&#8221; to show up before &#8220;Great Lake Swimmers&#8221; in a list ordered by name). Early on in my career I must have assumed it was not possible and never bothered to look into again because I don&#8217;t recall ever ordering a list like this.<br />
Anyways. Here&#8217;s how you do it:</p>
<p><code>SELECT name FROM artists ORDER BY TRIM( LEADING "a " FROM TRIM( LEADING "an " FROM TRIM( LEADING "the " FROM LOWER( name ) ) ) )</code></p>
<p><small><a href="http://ask.metafilter.com/52434/How-to-get-mySQL-to-ignore-A-An-amp-The-when-presenting-alphabetized-book-titles">[thanks metafilter]</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://ohryan.ca/blog/2009/07/17/how-to-exclude-words-like-an-a-the-from-alphabetized-mysql-order/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Round Unixtime To Midnight</title>
		<link>http://ohryan.ca/blog/2008/05/28/how-to-round-unixtime-to-midnight/</link>
		<comments>http://ohryan.ca/blog/2008/05/28/how-to-round-unixtime-to-midnight/#comments</comments>
		<pubDate>Wed, 28 May 2008 14:59:00 +0000</pubDate>
		<dc:creator>RyanN</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[time]]></category>

		<guid isPermaLink="false">http://ohryan.ca/blog/?p=77</guid>
		<description><![CDATA[This might be pretty obvious to anyone with basic math skills. It took me a few minutes to figure out, so I thought I&#8217;d share with the world. To round a unix timestamp to the previous midnight (UTC) use the following function: function unixtime_round_to_midnight ($t) { return $t &#8211; ($t%86400); } Thanks to Ian for [...]]]></description>
			<content:encoded><![CDATA[<p>This might be pretty obvious to anyone with basic math skills. It took me a few minutes to figure out, so I thought I&#8217;d share with the world. To round a unix timestamp to the previous midnight (UTC) use the following function:</p>
<blockquote><p>function unixtime_round_to_midnight ($t) {<br />
return $t &#8211; ($t%86400);<br />
}</p></blockquote>
<p>Thanks to <a href="http://www.notian.net/" target="_blank">Ian</a> for pointing out my math ineptitude.</p>
]]></content:encoded>
			<wfw:commentRss>http://ohryan.ca/blog/2008/05/28/how-to-round-unixtime-to-midnight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Top 5%</title>
		<link>http://ohryan.ca/blog/2008/05/02/top-5/</link>
		<comments>http://ohryan.ca/blog/2008/05/02/top-5/#comments</comments>
		<pubDate>Sat, 03 May 2008 04:03:47 +0000</pubDate>
		<dc:creator>RyanN</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[digg]]></category>
		<category><![CDATA[diggnation]]></category>
		<category><![CDATA[kevin rose]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://ohryan.ca/blog/2008/05/02/top-5/</guid>
		<description><![CDATA[According to Kevin Rose (of digg and diggnation fame) I am in the top 5% of php developers. In the last episode of This Week in Tech, he mentioned that 95% of the resumes he receives for digg.com positions are from developers who haven&#8217;t even worked on a site that gets 1 million uniques, let [...]]]></description>
			<content:encoded><![CDATA[<p>According to <a href="http://www.kevinrose.com">Kevin Rose</a> (of <a href="http://www.digg.com/">digg </a>and <a href="http://www.diggnation.com/">diggnation </a>fame) I am in the top 5% of php developers. In the <a href="http://twit.tv/140">last episode of This Week in Tech</a>, he mentioned that 95% of the resumes he receives for digg.com positions are from developers who haven&#8217;t even worked on a site that gets 1 million uniques, let alone anything near the 26 million digg gets.</p>
<p>I have!</p>
<p>*toot toot* (that&#8217;s the sound of my own horn)</p>
]]></content:encoded>
			<wfw:commentRss>http://ohryan.ca/blog/2008/05/02/top-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TinyMy, Quick and Dirty MySQL Shell</title>
		<link>http://ohryan.ca/blog/2007/12/07/tinymy-quick-and-dirty-mysql-shell/</link>
		<comments>http://ohryan.ca/blog/2007/12/07/tinymy-quick-and-dirty-mysql-shell/#comments</comments>
		<pubDate>Fri, 07 Dec 2007 13:30:22 +0000</pubDate>
		<dc:creator>RyanN</dc:creator>
				<category><![CDATA[Review]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://ohryan.ca/blog/2007/12/07/tinymy-quick-and-dirty-mysql-shell/</guid>
		<description><![CDATA[Stumbled across a tiny mysql shell &#8211; appropriately named &#8216;tinymy&#8217; &#8211; a few months ago. It&#8217;s quite a useful little bit of PHP code. Very lightweight and function interface and shell for MySQL. I use it whenever I need to verify the contents of a database table or test a couple of queries but don&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>Stumbled across a tiny mysql shell &#8211; appropriately named &#8216;tinymy&#8217; &#8211; a few months ago.</p>
<p>It&#8217;s quite a useful little bit of PHP code. Very lightweight and function interface and shell for MySQL.  I use it whenever I need to verify the contents of a database table or test a couple of queries but don&#8217;t need a full install phpMyAdmin.</p>
<p>Thought I&#8217;d share.<br />
<a href="http://elfz.laacz.lv/tinymy/">Link</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ohryan.ca/blog/2007/12/07/tinymy-quick-and-dirty-mysql-shell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

