<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: 10 code snippets for PHP developers</title>
	<atom:link href="http://htmlblog.net/10-code-snippets-for-php-developers/feed/" rel="self" type="application/rss+xml" />
	<link>http://htmlblog.net/10-code-snippets-for-php-developers/</link>
	<description>The web sandbox of Asvin Balloo</description>
	<lastBuildDate>Wed, 25 Nov 2009 02:36:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Pico RG</title>
		<link>http://htmlblog.net/10-code-snippets-for-php-developers/comment-page-2/#comment-33958</link>
		<dc:creator>Pico RG</dc:creator>
		<pubDate>Tue, 06 Oct 2009 07:58:40 +0000</pubDate>
		<guid isPermaLink="false">http://htmlblog.net/?p=38#comment-33958</guid>
		<description>Really nice functions, thanks for making this</description>
		<content:encoded><![CDATA[<p>Really nice functions, thanks for making this</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Collection of 10 top 10 lists about web development &#124; vijayjoshi.org</title>
		<link>http://htmlblog.net/10-code-snippets-for-php-developers/comment-page-2/#comment-33586</link>
		<dc:creator>Collection of 10 top 10 lists about web development &#124; vijayjoshi.org</dc:creator>
		<pubDate>Wed, 23 Sep 2009 13:02:34 +0000</pubDate>
		<guid isPermaLink="false">http://htmlblog.net/?p=38#comment-33586</guid>
		<description>[...] 1- 10 code snippets for PHP developers [...]</description>
		<content:encoded><![CDATA[<p>[...] 1- 10 code snippets for PHP developers [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://htmlblog.net/10-code-snippets-for-php-developers/comment-page-2/#comment-32596</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Thu, 20 Aug 2009 21:02:58 +0000</pubDate>
		<guid isPermaLink="false">http://htmlblog.net/?p=38#comment-32596</guid>
		<description>Like most lists of PHP code snippets, there are problems with all of these.

The email validator can be replaced with a single regex.  There is an official regex in the RFC.  While this one is much better than most email validators, it is rather heavy.

The password generator is not nearly random enough.  Even if you give it the greatest strength setting, it is still depressingly predictable without modifications.

Whether the password starts with a &quot;vowel&quot; or a &quot;consonant&quot; is dependent on the time with a 1 second resolution.  I can force that variable *by hand*.  I also know that every second letter in the password is drawn from an extremely small pool of only 8 characters.  The remainder of the password is drawn from a pool of 43 characters which isn&#039;t much better.

The complexity of the password will be 8^5 * 43^4 = 112,027,271,168 if the password is generated on an even second and 8^4 * 43^5 = 602,146,582,528 if it is generated on an odd second.  While these numbers might look big, in cryptographic terms, they are tiny.

They are also generated using rand() which is a pseudo random number generator.  If the seed of the PRNG is known, the passwords generated are highly predictable.

The Reform library was moved from the link you provided to OWASP and then to Google code.  http://code.google.com/p/reform/source/browse/trunk/src/php/Reform.inc.php  When looking at the code, all it does is return the same string with non-alpha-numeric characters replaced with their numeric html entities.  The whole class could be replaced with a single call to the PHP built-in function: htmlentities()

The functional difference is that characters such as : and ( that have a special meaning in a javascript context would not be converted by the PHP built-in.  Nonetheless, a filter that stripped these characters out (or rather, allowed the safe ones through) would be a better idea for user data that is going to end up as potentially executable javascript.code.

Upload is specifically designed for images and includes functions for processing them.  You kind of forgot to mention that.

As Giovanni said, a single PHP built-in does a better job: glob().</description>
		<content:encoded><![CDATA[<p>Like most lists of PHP code snippets, there are problems with all of these.</p>
<p>The email validator can be replaced with a single regex.  There is an official regex in the RFC.  While this one is much better than most email validators, it is rather heavy.</p>
<p>The password generator is not nearly random enough.  Even if you give it the greatest strength setting, it is still depressingly predictable without modifications.</p>
<p>Whether the password starts with a &#8220;vowel&#8221; or a &#8220;consonant&#8221; is dependent on the time with a 1 second resolution.  I can force that variable *by hand*.  I also know that every second letter in the password is drawn from an extremely small pool of only 8 characters.  The remainder of the password is drawn from a pool of 43 characters which isn&#8217;t much better.</p>
<p>The complexity of the password will be 8^5 * 43^4 = 112,027,271,168 if the password is generated on an even second and 8^4 * 43^5 = 602,146,582,528 if it is generated on an odd second.  While these numbers might look big, in cryptographic terms, they are tiny.</p>
<p>They are also generated using rand() which is a pseudo random number generator.  If the seed of the PRNG is known, the passwords generated are highly predictable.</p>
<p>The Reform library was moved from the link you provided to OWASP and then to Google code.  <a href="http://code.google.com/p/reform/source/browse/trunk/src/php/Reform.inc.php" rel="nofollow">http://code.google.com/p/reform/source/browse/trunk/src/php/Reform.inc.php</a>  When looking at the code, all it does is return the same string with non-alpha-numeric characters replaced with their numeric html entities.  The whole class could be replaced with a single call to the PHP built-in function: htmlentities()</p>
<p>The functional difference is that characters such as : and ( that have a special meaning in a javascript context would not be converted by the PHP built-in.  Nonetheless, a filter that stripped these characters out (or rather, allowed the safe ones through) would be a better idea for user data that is going to end up as potentially executable javascript.code.</p>
<p>Upload is specifically designed for images and includes functions for processing them.  You kind of forgot to mention that.</p>
<p>As Giovanni said, a single PHP built-in does a better job: glob().</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deacon</title>
		<link>http://htmlblog.net/10-code-snippets-for-php-developers/comment-page-2/#comment-32542</link>
		<dc:creator>Deacon</dc:creator>
		<pubDate>Tue, 18 Aug 2009 13:38:25 +0000</pubDate>
		<guid isPermaLink="false">http://htmlblog.net/?p=38#comment-32542</guid>
		<description>I liked these tips.. Keep up the good work!</description>
		<content:encoded><![CDATA[<p>I liked these tips.. Keep up the good work!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Emma</title>
		<link>http://htmlblog.net/10-code-snippets-for-php-developers/comment-page-2/#comment-31889</link>
		<dc:creator>Emma</dc:creator>
		<pubDate>Thu, 23 Jul 2009 13:46:42 +0000</pubDate>
		<guid isPermaLink="false">http://htmlblog.net/?p=38#comment-31889</guid>
		<description>Hey, this is great! I found it on Stumble also, good job.</description>
		<content:encoded><![CDATA[<p>Hey, this is great! I found it on Stumble also, good job.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 45+ Excellent Code Snippet Resources and Repositories &#124; Desinine</title>
		<link>http://htmlblog.net/10-code-snippets-for-php-developers/comment-page-2/#comment-31882</link>
		<dc:creator>45+ Excellent Code Snippet Resources and Repositories &#124; Desinine</dc:creator>
		<pubDate>Thu, 23 Jul 2009 08:19:13 +0000</pubDate>
		<guid isPermaLink="false">http://htmlblog.net/?p=38#comment-31882</guid>
		<description>[...] 10 Code Snippets for PHP DevelopersThis is a blog post covering ten useful code snippets. It includes an email address check, random password generator, get IP address, XSL transformation, force downloading of a file, string encoding to prevent harmful code, sending mail, uploading of files, list files in directory, and querying RDBMS with MDB2. [...]</description>
		<content:encoded><![CDATA[<p>[...] 10 Code Snippets for PHP DevelopersThis is a blog post covering ten useful code snippets. It includes an email address check, random password generator, get IP address, XSL transformation, force downloading of a file, string encoding to prevent harmful code, sending mail, uploading of files, list files in directory, and querying RDBMS with MDB2. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 45+ Excellent Code Snippet Resources and Repositories &#124; Developer&#8217;s Toolbox &#124; Smashing Magazine &#124; 51Feeling</title>
		<link>http://htmlblog.net/10-code-snippets-for-php-developers/comment-page-2/#comment-31878</link>
		<dc:creator>45+ Excellent Code Snippet Resources and Repositories &#124; Developer&#8217;s Toolbox &#124; Smashing Magazine &#124; 51Feeling</dc:creator>
		<pubDate>Thu, 23 Jul 2009 06:09:36 +0000</pubDate>
		<guid isPermaLink="false">http://htmlblog.net/?p=38#comment-31878</guid>
		<description>[...] 10 Code Snippets for PHP Developers This is a blog post covering ten useful code snippets. It includes an email address check, random password generator, get IP address, XSL transformation, force downloading of a file, string encoding to prevent harmful code, sending mail, uploading of files, list files in directory, and querying RDBMS with MDB2. [...]</description>
		<content:encoded><![CDATA[<p>[...] 10 Code Snippets for PHP Developers This is a blog post covering ten useful code snippets. It includes an email address check, random password generator, get IP address, XSL transformation, force downloading of a file, string encoding to prevent harmful code, sending mail, uploading of files, list files in directory, and querying RDBMS with MDB2. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 45+ Excellent Code Snippet Resources and Repositories &#124; Search Engine Optimisation</title>
		<link>http://htmlblog.net/10-code-snippets-for-php-developers/comment-page-2/#comment-31858</link>
		<dc:creator>45+ Excellent Code Snippet Resources and Repositories &#124; Search Engine Optimisation</dc:creator>
		<pubDate>Wed, 22 Jul 2009 09:22:32 +0000</pubDate>
		<guid isPermaLink="false">http://htmlblog.net/?p=38#comment-31858</guid>
		<description>[...] 10 Code Snippets for PHP DevelopersThis is a blog post covering ten useful code snippets. It includes an email address check, random password generator, get IP address, XSL transformation, force downloading of a file, string encoding to prevent harmful code, sending mail, uploading of files, list files in directory, and querying RDBMS with MDB2. [...]</description>
		<content:encoded><![CDATA[<p>[...] 10 Code Snippets for PHP DevelopersThis is a blog post covering ten useful code snippets. It includes an email address check, random password generator, get IP address, XSL transformation, force downloading of a file, string encoding to prevent harmful code, sending mail, uploading of files, list files in directory, and querying RDBMS with MDB2. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 45+ Excellent Code Snippet Resources and Repositories - Programming Blog</title>
		<link>http://htmlblog.net/10-code-snippets-for-php-developers/comment-page-2/#comment-31844</link>
		<dc:creator>45+ Excellent Code Snippet Resources and Repositories - Programming Blog</dc:creator>
		<pubDate>Tue, 21 Jul 2009 23:14:35 +0000</pubDate>
		<guid isPermaLink="false">http://htmlblog.net/?p=38#comment-31844</guid>
		<description>[...] 10 Code Snippets for PHP DevelopersThis is a blog post covering ten useful code snippets. It includes an email address check, random password generator, get IP address, XSL transformation, force downloading of a file, string encoding to prevent harmful code, sending mail, uploading of files, list files in directory, and querying RDBMS with MDB2. [...]</description>
		<content:encoded><![CDATA[<p>[...] 10 Code Snippets for PHP DevelopersThis is a blog post covering ten useful code snippets. It includes an email address check, random password generator, get IP address, XSL transformation, force downloading of a file, string encoding to prevent harmful code, sending mail, uploading of files, list files in directory, and querying RDBMS with MDB2. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 45+ Excellent Code Snippet Resources and Repositories &#171; Tech7.Net</title>
		<link>http://htmlblog.net/10-code-snippets-for-php-developers/comment-page-2/#comment-31817</link>
		<dc:creator>45+ Excellent Code Snippet Resources and Repositories &#171; Tech7.Net</dc:creator>
		<pubDate>Tue, 21 Jul 2009 10:01:50 +0000</pubDate>
		<guid isPermaLink="false">http://htmlblog.net/?p=38#comment-31817</guid>
		<description>[...] 10 Code Snippets for PHP DevelopersThis is a blog post covering ten useful code snippets. It includes an email address check, random password generator, get IP address, XSL transformation, force downloading of a file, string encoding to prevent harmful code, sending mail, uploading of files, list files in directory, and querying RDBMS with MDB2. [...]</description>
		<content:encoded><![CDATA[<p>[...] 10 Code Snippets for PHP DevelopersThis is a blog post covering ten useful code snippets. It includes an email address check, random password generator, get IP address, XSL transformation, force downloading of a file, string encoding to prevent harmful code, sending mail, uploading of files, list files in directory, and querying RDBMS with MDB2. [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
