<?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>Thu, 20 Jun 2013 01:00:59 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[SitePoint.com: How to Create Your Own Random Number Generator in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17524</guid>
      <link>http://www.phpdeveloper.org/news/17524</link>
      <description><![CDATA[<p>
On SitePoint.com today there's a new tutorial showing how to <a href="http://www.sitepoint.com/php-random-number-generator/">create a random number generator</a> in PHP (with the help of methods like <a href="http://php.net/mt_rand">mt_rand</a> and <a href="http://php.net/mt_srand">mt_srand</a>).
</p>
<blockquote>
Computers cannot generate random numbers. A machine which works in ones and zeros is unable to magically invent its own stream of random data. However, computers can implement mathematical algorithms which produce pseudo-random numbers. They look like random numbers. They feel like random distributions. But they're fake; the same sequence of digits is generated if you run the algorithm twice.
</blockquote>
<p>
Included in the post is code showing how to use the random functions and how to create a class (Random) that provides a few methods to help make generation easier - "seed" and "num". It first calls "seed" with a number to start the random generator off with and then "num" in a loop to pull out random values based on that. 
</p>]]></description>
      <pubDate>Thu, 09 Feb 2012 10:03:35 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Anthony Ferrara's Blog: Random Number Generation In PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/16617</guid>
      <link>http://www.phpdeveloper.org/news/16617</link>
      <description><![CDATA[<p>
<i>Anthony Ferrara</i> has a new post to his blog today looking at true random number generation as it relates to predictability and bias. He <a href="http://blog.ircmaxell.com/2011/07/random-number-generation-in-php.html">also talks about</a> a method/tool you can use (based on RFC 4086) to generate truly random numbers - <a href="https://github.com/ircmaxell/PHP-CryptLib/">PHP-CryptLib</a>.
</p>
<blockquote>
When we talk about "random" numbers, we generally talk about two fundamental properties: Predictability and Bias. Both are closely related, but are subtly different. Predictability in reference to random numbers is the statistical problem of predicting the next value when knowing any number of previous values. Bias on the other hand is the statistical problem of predicting the next value when knowing the distribution of previous values.
</blockquote>
<p>
He looks at how predictability can effect true random number generation and a common mistake in generation related to bias in the calculation method. He talks about <a href="http://us.php.net/manual/en/function.rand.php">some</a> of <a href="http://us.php.net/manual/en/function.mt-rand.php">the</a> <a href="http://us.php.net/manual/en/function.lcg-value.php">functions</a> <a href="http://us.php.net/manual/en/function.uniqid.php">PHP includes</a> to work with randomness, but notes that they all have their flaws. He points to <a href="https://github.com/ircmaxell/PHP-CryptLib/">the PHP-CryptLib</a> package as a solution (adhering to the <a href="http://tools.ietf.org/html/rfc4086">guidelines in RFC 4086</a> for randomness). He includes some sample code of how to use it to generate random numbers, tokens and sets of bytes. You can find the full source <a href="https://github.com/ircmaxell/PHP-CryptLib">over on github</a>.
</p>]]></description>
      <pubDate>Thu, 21 Jul 2011 10:03:28 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Lorna Mitchell's Blog: Script for Database Patching at Deploy Time]]></title>
      <guid>http://www.phpdeveloper.org/news/16202</guid>
      <link>http://www.phpdeveloper.org/news/16202</link>
      <description><![CDATA[<p>
As a part of one of her projects, <i>Lorna Mitchell</i> had a need to deploy database patches as a part of her overall deployment process. Obviously, doing this manually every time can be a hassle so she <a href="http://www.lornajane.net/posts/2011/Script-for-Database-Patching-at-Deploy-Time">came up with a script</a> that does the work for her (based on a patch_history table).
</p>
<blockquote>
My current project (<a href="http://bitestats.com/">BiteStats</a>, a simple report of your google analytics data) uses a basic system where there are numbered patches, and a patch_history table with a row for every patch that was run, showing the version number and a timestamp. When I deploy the code to production, I have a script that runs automatically to apply the patches.
</blockquote>
<p>
The script uses the number-based patch names (such as patch1.sql) and finds the latest ones that haven't been applied based on the highest values for the patch_number column in the database. This number is updated by the patches themselves when they're run to avoid any confusion in the script itself. She has it running as a part of her <a href=http://phing.info">phing</a> build process as a part of a Zend Framework application.
</p>]]></description>
      <pubDate>Fri, 15 Apr 2011 08:51:31 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[AjaxRay.com: Extending Zend Form Element to create customized Phone number field]]></title>
      <guid>http://www.phpdeveloper.org/news/15063</guid>
      <link>http://www.phpdeveloper.org/news/15063</link>
      <description><![CDATA[<p>
On the AjaxRay.com site today there's <a href="http://www.ajaxray.com/blog/2010/08/25/extending-zend-form-element-for-customized-phone-number/">a new tutorial</a> for the Zend Framework users out there with a library they can use to extend Zend_Form for custom phone number fields.
</p>
<blockquote>
When taking Phone number as user input, we can worn users about phone number format by setting a hint/description and can validate using Regular Expression. [...] Now, if we try provide this feature in Zend Form, that's possible. We can create three individual Zend_Form_Element_Text objects and join there value together to make the phone number. But, in this case, validating them together is a hassle.
</blockquote>
<p>
Instead of separate fields, <a href="http://www.ajaxray.com/blog/downloads/Zend_Form_Element_Phone">the library</a> they create makes it simple to handle them as a whole field. It works as a helper for Zend_Form and lets you set things like the separator between the text fields, a "format" string and a validator to apply to their fields (in the example code, it's the "digits" validator). Sample code is included to show you how it fits in your form.
</p>]]></description>
      <pubDate>Thu, 02 Sep 2010 08:05:06 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[php|architect: Possible vulnerabilities found in PHP session IDs ]]></title>
      <guid>http://www.phpdeveloper.org/news/14331</guid>
      <link>http://www.phpdeveloper.org/news/14331</link>
      <description><![CDATA[<p>
<i>Beth Tucker Long</i> has posted a new warning <a href="http://www.phparch.com/2010/04/09/possible-vulnerabilities-found-in-php-session-ids">about a possible issue with session IDs</a> in PHP dealing with <a href="http://seclists.org/fulldisclosure/2010/Mar/519">weak random numbers</a> being generated by the language when making the IDs.
</p>
<blockquote>
Seclists.org has posted an advisory titled "<a href="http://seclists.org/fulldisclosure/2010/Mar/519">Weak RNG in PHP session ID generation leads to session hijacking</a>." RNG stands for Random Number Generation, and the advisory is warning that not enough entropy is being used to seed the RNG; this, in turn, can lead to a reduced number of possible session IDs under certain specific conditions, thus making brute force session spoofing easier, if not bringing it into the realm of feasibility.
</blockquote>
<p>
The threat is only marked at a "medium" level of severity, but it could still cause problems if you're not careful. There are specific conditions that have to be in place for it to be a problem including using the standard PHP session generation and that the app shares the information about remote users. To protect yourself you can either install <a href="http://www.hardened-php.net/suhosin/">Suhosin</a> and don't use the result of <a href="http://php.net/uniqid</a> directly, hash it. You can also <a href="http://www.php.net/manual/en/session.configuration.php#ini.session.entropy-file">set an external source</a> for entropy to help randomize the session ID even more.
</p>]]></description>
      <pubDate>Mon, 12 Apr 2010 08:29:00 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Klaus Graefensteiner's Blog: Two ways to test for prime numbers in PHP: Sieve and File]]></title>
      <guid>http://www.phpdeveloper.org/news/14099</guid>
      <link>http://www.phpdeveloper.org/news/14099</link>
      <description><![CDATA[<p>
In a new post to his blog <i>Klaus Graefensteiner</i> takes a look at <a href="http://www.tellingmachine.com/post/Two-ways-to-test-for-prime-numbers-in-PHP-Sieve-and-File.aspx">two ways to test for prime numbers</a> both with Sieve and from a file.
</p>
<blockquote>
In PHP is really no ideal way to test large integers and determine whether they are prime numbers or not. The most popular algorithm for finding prime numbers is a memory and resource hog. It is called The <A href="http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes">Sieve of Eratosthenes</a>.
</blockquote>
<p>
You can get more of an idea on this method in <a href="http://www.youtube.com/watch?v=9m2cdWorIq8">this video </a> and in <a href="http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes">this example</a> from Wikipedia. He includes the full source for his solution that includes methods like isInteger, isPositive, isPerfectSquare and isPalindromicPrime. The script is also available for <a href="http://www.tellingmachine.com/file.axd?file=PrimesWIthSieveAndFromFile.zip">download</a>.
</p>]]></description>
      <pubDate>Fri, 26 Feb 2010 13:33:43 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPBuilder.com: Math & Number Handling in PHP - The ABCs of PHP Part 6 ]]></title>
      <guid>http://www.phpdeveloper.org/news/12383</guid>
      <link>http://www.phpdeveloper.org/news/12383</link>
      <description><![CDATA[<p>
On PHPBuilder.com today they've <a href="http://www.phpbuilder.com/columns/peter_shaw04202009.php3">posted the next article</a> in their "ABCs of PHP" series. This time they focus on math and number handling.
</p>
<blockquote>
Last time we looked at text and strings in variables, in this episode we're going to continue with our exploration of PHP variables and delve deeper into math and number handling in PHP. Using numbers is not much different to using text and strings, you allocate variables and fill them in, using exactly the same techniques as you do using strings & text. 
</blockquote>
<p>
They covers some of the basic operators (+,-,*,etc), evaluation with equals, number shifting, binary and creating a "barrel shifter" to work with the binary bits of a number.
</p>]]></description>
      <pubDate>Wed, 22 Apr 2009 07:57:17 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Danne Lundqvist's Blog: Zend Framework and locales]]></title>
      <guid>http://www.phpdeveloper.org/news/12258</guid>
      <link>http://www.phpdeveloper.org/news/12258</link>
      <description><![CDATA[<p>
In <a href="http://www.dotvoid.com/2009/04/zend-framework-and-locales/">a new post</a> to his blog <i>Danne Lundqvist</i> take a look at using locales in the <a href="http://framework.zend.com">Zend Framework</a> and a "gotcha" that made him look deeper.
</p>
<blockquote>
Last night I spent a couple of hours with <a href="http://framework.zend.com/">Zend Framework</a> and especially Zend_Form. I discovered, and now also <a href="http://framework.zend.com/issues/browse/ZF-6175">reported as ZF-6175</a>, a bug in Zend_Validate_Float when using a locale with a decimal point other than ".". There are unit tests but none that test Zend_Validate_Float under a different locale.
</blockquote>
<p>
He points out that floats are locale-aware in PHP itself (code examples) and how the current Zend_Validate float package handled it. He has already proposed a fix for the problem and, until its changed in the framework, has provided the simplified code you can use.
</p>]]></description>
      <pubDate>Wed, 01 Apr 2009 13:44:18 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Kae Verens' Blog: Extracting a sudoku puzzle from a photo]]></title>
      <guid>http://www.phpdeveloper.org/news/11881</guid>
      <link>http://www.phpdeveloper.org/news/11881</link>
      <description><![CDATA[<p>
<i>Kae Verens</i> has posted a <a href="http://verens.com/archives/2009/02/03/extracting-a-sudoku-puzzle-from-a-photo/">cool little application</a> of how to pull information out of a photo and parse it with the GD library. His example is a <a href="http://verens.com/archives/2009/02/02/visual-sudoku-solver/">visual sudoku solver</a> (part one, at least).
</p>
<blockquote>
The plan for this one is that, if you're doing a sudoku puzzle in the pub or on the train, and you get stuck, you just take a snapshot of the puzzle with your camera-phone, send the photo to a certain mobile number, and a few seconds later the solution is sent back as an SMS message. The solution costs you something small - 50 cents, maybe.
</blockquote>
<p>
The script looks at a picture of a sudoku puzzle, converts it to b&w and tries to find the squares surrounding each position of the board. With these measurements, the next step is to grab the numbers already in the puzzle and hand those off to the puzzle solver to be processed.
</p>]]></description>
      <pubDate>Wed, 04 Feb 2009 12:57:18 -0600</pubDate>
    </item>
    <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>
  </channel>
</rss>
