<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Sun, 07 Sep 2008 02:57:57 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Suspekt Blog: mt_srand and not so random numbers]]></title>
      <guid>http://www.phpdeveloper.org/news/10851</guid>
      <link>http://www.phpdeveloper.org/news/10851</link>
      <description><![CDATA[<p>
<i>Stefan Esser</i> <a href="http://www.suspekt.org/2008/08/17/mt_srand-and-not-so-random-numbers/">points out</a> a problem with the <a href="http://www.php.net/mt_rand">mt_rand</a> and <a href="http://www.php.net/rand">rand</a> methods in PHP that makes them not quite random enough for cryptographic uses.
</p>
<blockquote>
PHP comes with two random number generators named rand() and mt_rand(). The first is just a wrapper around the libc rand() function and the second one is an implementation of the Mersenne Twister pseudo random number generator. Both of these algorithms are seeded by a single 32 bit dword when they are first used in a process or one of the seeding functions srand() or mt_srand() is called.
</blockquote>
<p>
He looks at how its currently implemented, some examples of bad methods to get "random" numbers, how shared resources are a problem and an example of a cross-application attack (the application in more than once place using the same method for getting random numbers). 
</p>
<p>
In the comments he recommends either grabbing from /dev/random (if you're on a unix-based system) or making the creation of your numbers a bit more complex to include things the outside world wouldn't know.
</p>]]></description>
      <pubDate>Mon, 18 Aug 2008 13:49:31 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPEverywhere: Octalpussy]]></title>
      <guid>http://www.phpdeveloper.org/news/9559</guid>
      <link>http://www.phpdeveloper.org/news/9559</link>
      <description><![CDATA[<p>
In an <a href="http://www.phpdeveloper.org/news/9543">earlier post</a> <i>John Lim</i> pointed out an interesting issue with how certain numbers are handled in PHP - ones starting with a zero:
</p>
<blockquote>
That's because any number preceded by 0 is treated as an octal number, and 9 is an invalid octal number. [...] The silly thing is that hardly anyone uses octal nowadays, but it continues to be part of the C, C++, Java and PHP standards. The mistake is also <a href="http://mindprod.com/jgloss/octal.html">very common</a>.
</blockquote>
<p>
There's not much way around it, he notes - the format's been in use for a long time now and is so ingrained in just about every C-based language out there that it's "too deeply imprinted in modern compiler DNA" to take out.
</p>]]></description>
      <pubDate>Mon, 04 Feb 2008 10:25:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPEverywhere: Octopussy numbers in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/9543</guid>
      <link>http://www.phpdeveloper.org/news/9543</link>
      <description><![CDATA[<p>
<i>John Lim</i> has <a href="http://phplens.com/phpeverywhere/?q=node/view/249">posted about</a> an interesting bug he's come across when working with the output of two strings that should look the same:
</p>
<blockquote>
Someone reported a bug in ADOdb, the open source db library i maintain. I went crazy for half an hour until i realised the problem.
</blockquote>
<p>
According to him, "if you expect the above code to produce the same values, you are sadly mistaken". His example gives an interesting result for the first echo statement - not echoing the 9 in the first character like it seems would make sense. Check out <a href="http://phplens.com/phpeverywhere/?q=node/view/249">his post</a> for the code and try it out for yourself.
</p>]]></description>
      <pubDate>Fri, 01 Feb 2008 09:21:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[DeveloperTutorials.com: Floating Point Comparisons In PHP and Javascript]]></title>
      <guid>http://www.phpdeveloper.org/news/9370</guid>
      <link>http://www.phpdeveloper.org/news/9370</link>
      <description><![CDATA[<p>
On the DeveloperTutorials website, there's <a href="http://www.developertutorials.com/tutorials/php/floating-point-comparisons-in-php-and-javascript-8-01-05/page1.html">a new tutorial</a> posted that warns against the perils of floating point comparisons between PHP and Javascript.
</p>
<blockquote>
The problem is if you've done any calculations to arrive at these numbers they might actually be stored as 71.00000000001. Now if one of them is stored that way and the other isn't and you compare the two to see if they are equal you'll get a FALSE as the response, even though they should be the same. This isn't a bug, it's how floating point comparisons are designed to work.
</blockquote>
<p>
In order to help combat this, he's provided two functions - one in PHP and one in Javascript - that compare the numbers in a more "sane" way that someone using them to store, say, currency values might want to use to compare them.
</p>]]></description>
      <pubDate>Tue, 08 Jan 2008 07:57:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Lorenzo Alberton's Blog: PEAR::Pager Tutorials]]></title>
      <guid>http://www.phpdeveloper.org/news/6303</guid>
      <link>http://www.phpdeveloper.org/news/6303</link>
      <description><![CDATA[<p>
<i>Lorenzo Alberton</i> has <a href="http://www.alberton.info/pear_pager_tutorial_mod_rewrite.html">posted a tutorial</a> today about using teh PEAR::Pager package to create "pretty links" with a little help from mod_rewrite.
</p>
<blockquote>
<p>
Most PHP pager classes can work just fine with GET parameters, correctly forwarding them through the pages. Few of them let you control the navigation links they create, though. This can be particularly annoying when you have some nice urls (thanks to some mod_rewrite rules o to your hand-crafted front controller) and the pager class can't respect them, showing the real, ugly links to the world.
</p>
<p>
If the above scenario is not new to you, then you should probably have a look at <a href="http://www.alberton.info/http:://pear.php.net/package/Pager">PEAR::Pager</a>. It's a <a href="http://pear.php.net/manual/en/package.html.pager.factory.php">fully customizable</a> package that should satisfy all your needs, including your preferred link format.
</p>
</blockquote>
<p>
In <a href="http://www.alberton.info/pear_pager_tutorial_mod_rewrite.html">his examples</a>, he provides the mod_rewrite rules to use, a sample PHP script that would normally use the $_GET values (in an ugly URL) to paginate the results. He also compensates for if the page number is actually a part of the path and not just at the end of the file name. 
</p>]]></description>
      <pubDate>Tue, 19 Sep 2006 07:31:52 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPBuilder.com: An introduction to PEAR's Validate package]]></title>
      <guid>http://www.phpdeveloper.org/news/5880</guid>
      <link>http://www.phpdeveloper.org/news/5880</link>
      <description><![CDATA[<p>
On PHPBuilder.com today, there's a <a href="http://www.phpbuilder.com/columns/ian_gilfillan20060630.php3">new article</a> introducing yet another valuable PEAR package - <a href="http://pear.php.net/package/Validate">PEAR::Validate</a>.
</p>
<blockquote>
<p>
Poor validation is a key weakness many scripts are guilty of, enabling security exploits. The Validate package can be used to validate any data, and is especially useful for validating user input.
</p>
<p>
There are also related packages that apply specific validation rules according to geographic location. I don't cover these packages in this article, though once you've grasped the basics of the main Validate package, using these won't present much of a challenge.
</p>
</blockquote>
<p>
They <a href="http://www.phpbuilder.com/columns/ian_gilfillan20060630.php3">introduce the package</a> by showing a quick install of it, including dependencies. From there, it's examples of different validation types:
<ul>
<li>email addresses
<li>numbers
<li>strings
<li>dates
<li>URLs
</ul>
</p>
<p>
And it wouldn't be <a href="http://www.phpbuilder.com/columns/ian_gilfillan20060630.php3">a tutorial</a> without some code, so for each example there's a snippet or two and a breakdown of its usage.
</p>]]></description>
      <pubDate>Wed, 26 Jul 2006 12:22:49 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[DevShed: Building a PHP5 Form Processor - Coding the Form Validator Module]]></title>
      <guid>http://www.phpdeveloper.org/news/4718</guid>
      <link>http://www.phpdeveloper.org/news/4718</link>
      <description><![CDATA[DevShed has the second part of their "Building a PHP5 Form Processor" series posted today - <a href="http://www.devshed.com/c/a/PHP/Building-a-PHP5-Form-Processor-Coding-the-Form-Validator-Module/">Coding the Form Validator Module</a>. It looks at how to construct a set of functions that will check the data inputted to ensure it exists and correct/valid.
<p>
<quote>
<i>
In this second part of a three-part series, we take up the topic of server-side validation. By the time you finish this article, you'll have the general guidelines for how to build a form validating class. You'll use some PHP built-in introspection functions, along with regular expressions, to assist you in building this class.
</i>
</quote>
<p>
They create several functions, including validateEmpty, validateInteger, validateNumber, validateRange, and validateEmail. Each one (obviously) serves their own purpose, and some are more complex that others (validating an integer versus a valid email address), but they walk you through each, showing you plenty of code and explainations along the way...]]></description>
      <pubDate>Tue, 24 Jan 2006 06:57:09 -0600</pubDate>
    </item>
  </channel>
</rss>
