<?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>Werx Limited &#187; php</title> <atom:link href="http://werxltd.com/wp/category/software-development/php-software-development/feed/" rel="self" type="application/rss+xml" /><link>http://werxltd.com/wp</link> <description>We make IT work.</description> <lastBuildDate>Mon, 23 Jan 2012 23:03:59 +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>Check an array for all null values</title><link>http://werxltd.com/wp/2011/06/13/check-an-array-for-all-null-values/</link> <comments>http://werxltd.com/wp/2011/06/13/check-an-array-for-all-null-values/#comments</comments> <pubDate>Mon, 13 Jun 2011 20:38:00 +0000</pubDate> <dc:creator>wes</dc:creator> <category><![CDATA[php]]></category> <category><![CDATA[software development]]></category> <category><![CDATA[function]]></category> <category><![CDATA[null]]></category> <category><![CDATA[utility]]></category><guid
isPermaLink="false">http://werxltd.com/wp/?p=978</guid> <description><![CDATA[Here is a simple function to check an array to see if it contains all null values. function allNulls($arr) { if(is_array($arr) &#038;&#038; count(array_diff($arr, array(null))) == 0) { return true; } return false; } echo (allNulls(array(null,null,null)) ? "true" : "false") . PHP_EOL; echo (allNulls(array(null,1,null)) ? "true" : "false") . PHP_EOL; echo (allNulls(array("test",null,null)) ? "true" : "false") [...]]]></description> <content:encoded><![CDATA[<p>Here is a simple function to check an array to see if it contains all null values.</p><pre class="brush:php">
function allNulls($arr) {
    if(is_array($arr) &#038;&#038; count(array_diff($arr, array(null))) == 0) {
            return true;
    }

    return false;
}

echo (allNulls(array(null,null,null)) ? "true" : "false") . PHP_EOL;
echo (allNulls(array(null,1,null)) ? "true" : "false") . PHP_EOL;
echo (allNulls(array("test",null,null)) ? "true" : "false") . PHP_EOL;
echo (allNulls(array("",null,null)) ? "true" : "false") . PHP_EOL;
echo (allNulls(array(0,null,null)) ? "true" : "false") . PHP_EOL;
</pre><div
class="betterrelated none"><p>No related content found.</p></div><p><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwerxltd.com%2Fwp%2F2011%2F06%2F13%2Fcheck-an-array-for-all-null-values%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwerxltd.com%2Fwp%2F2011%2F06%2F13%2Fcheck-an-array-for-all-null-values%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2011%2F06%2F13%2Fcheck-an-array-for-all-null-values%2F&amp;counturl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2011%2F06%2F13%2Fcheck-an-array-for-all-null-values%2F&amp;count=none&amp;text=Check%20an%20array%20for%20all%20null%20values" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2011%2F06%2F13%2Fcheck-an-array-for-all-null-values%2F&amp;counturl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2011%2F06%2F13%2Fcheck-an-array-for-all-null-values%2F&amp;count=none&amp;text=Check%20an%20array%20for%20all%20null%20values" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2011%2F06%2F13%2Fcheck-an-array-for-all-null-values%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2011%2F06%2F13%2Fcheck-an-array-for-all-null-values%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a
class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2011%2F06%2F13%2Fcheck-an-array-for-all-null-values%2F&amp;linkname=Check%20an%20array%20for%20all%20null%20values" title="LinkedIn" rel="nofollow" target="_blank"><img
src="http://werxltd.com/wp/wp-content/plugins/add-to-any/icons/linkedin.png?9d7bd4" width="16" height="16" alt="LinkedIn"/></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2011%2F06%2F13%2Fcheck-an-array-for-all-null-values%2F&amp;title=Check%20an%20array%20for%20all%20null%20values" id="wpa2a_2">Share/Save</a></p>]]></content:encoded> <wfw:commentRss>http://werxltd.com/wp/2011/06/13/check-an-array-for-all-null-values/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Simple PHP Proxy</title><link>http://werxltd.com/wp/2011/05/24/simple-php-proxy/</link> <comments>http://werxltd.com/wp/2011/05/24/simple-php-proxy/#comments</comments> <pubDate>Tue, 24 May 2011 12:00:17 +0000</pubDate> <dc:creator>wes</dc:creator> <category><![CDATA[php]]></category> <category><![CDATA[proxy]]></category><guid
isPermaLink="false">http://werxltd.com/wp/?p=765</guid> <description><![CDATA[While developing apps that use external web services, a proxy often comes in handy in order to bypass the pesky XSS security settings found in most browsers. Here is a simple PHP proxy I&#8217;ve found quite helpful.]]></description> <content:encoded><![CDATA[<p>While developing apps that use external web services, a proxy often comes in handy in order to bypass the pesky XSS security settings found in most browsers. Here is a simple PHP proxy I&#8217;ve found quite helpful.</p><pre class="brush:php">
<?

// http://benalman.com/projects/php-simple-proxy/

$url = "http://mcaf.ee/api/shorten";

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_FORBID_REUSE, true);
curl_setopt($ch, CURLOPT_MAXCONNECTS, 16);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($_REQUEST));
$result = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
curl_close($ch);  

if(!is_null($type)) $type = 'text/html';
header('Content-Type: '.$type);

switch($status) {
        case 500:
                header("HTTP/1.1 500 Internal Server Error");
                header("Cache-Control: no-cache");
        break;
        case 200:
        default:
                header("HTTP/1.1 200 OK");
        break;
}

echo $result;
</pre><div
class="betterrelated none"><p>No related content found.</p></div><p><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwerxltd.com%2Fwp%2F2011%2F05%2F24%2Fsimple-php-proxy%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwerxltd.com%2Fwp%2F2011%2F05%2F24%2Fsimple-php-proxy%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2011%2F05%2F24%2Fsimple-php-proxy%2F&amp;counturl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2011%2F05%2F24%2Fsimple-php-proxy%2F&amp;count=none&amp;text=Simple%20PHP%20Proxy" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2011%2F05%2F24%2Fsimple-php-proxy%2F&amp;counturl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2011%2F05%2F24%2Fsimple-php-proxy%2F&amp;count=none&amp;text=Simple%20PHP%20Proxy" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2011%2F05%2F24%2Fsimple-php-proxy%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2011%2F05%2F24%2Fsimple-php-proxy%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a
class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2011%2F05%2F24%2Fsimple-php-proxy%2F&amp;linkname=Simple%20PHP%20Proxy" title="LinkedIn" rel="nofollow" target="_blank"><img
src="http://werxltd.com/wp/wp-content/plugins/add-to-any/icons/linkedin.png?9d7bd4" width="16" height="16" alt="LinkedIn"/></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2011%2F05%2F24%2Fsimple-php-proxy%2F&amp;title=Simple%20PHP%20Proxy" id="wpa2a_4">Share/Save</a></p>]]></content:encoded> <wfw:commentRss>http://werxltd.com/wp/2011/05/24/simple-php-proxy/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Reading a file line by line in reverse with PHP</title><link>http://werxltd.com/wp/2010/10/29/reading-a-file-line-by-line-in-reverse-with-php/</link> <comments>http://werxltd.com/wp/2010/10/29/reading-a-file-line-by-line-in-reverse-with-php/#comments</comments> <pubDate>Fri, 29 Oct 2010 13:51:21 +0000</pubDate> <dc:creator>wes</dc:creator> <category><![CDATA[php]]></category> <category><![CDATA[file]]></category> <category><![CDATA[read]]></category><guid
isPermaLink="false">http://werxltd.com/wp/?p=821</guid> <description><![CDATA[Here is a handy function for reading a file line by line in reverse (from the end of the file). function rfgets($handle) { $line = null; $n = 0; if ($handle) { $line = ''; $started = false; $gotline = false; while (!$gotline) { if (ftell($handle) == 0) { fseek($handle, -1, SEEK_END); } else { [...]]]></description> <content:encoded><![CDATA[<p>Here is a handy function for reading a file line by line in reverse (from the end of the file).</p><pre class="brush:php">
function rfgets($handle) {
    $line = null;
    $n = 0;

    if ($handle) {
        $line = '';

        $started = false;
        $gotline = false;

        while (!$gotline) {
            if (ftell($handle) == 0) {
                fseek($handle, -1, SEEK_END);
            } else {
                fseek($handle, -2, SEEK_CUR);
            }

            $readres = ($char = fgetc($handle));

            if (false === $readres) {
                $gotline = true;
            } elseif ($char == "\n" || $char == "\r") {
                if ($started)
                    $gotline = true;
                else
                    $started = true;
            } elseif ($started) {
                $line .= $char;
            }
        }
    }

    fseek($handle, 1, SEEK_CUR);

    return strrev($line);
}

$filename = 'top-1m.csv';

echo "Reverse reading $filename" . PHP_EOL;

$handle = @fopen($filename, 'r');

for ($i = 0; $i < 10; $i++) {
    $buffer = rfgets($handle);
    echo $buffer . PHP_EOL;
}

fclose($handle);
</pre><p>The output produced (from the <a
href="http://www.alexa.com/topsites">Alexa top 1 million domains list</a>) is:</p><pre class="brush:text">
Reverse reading top-1m.csv
1000000,hingemarketing.com
999999,deluxecar.hu
999998,phototests.com
999997,slutwifegallery.com
999996,himawarigumi.net
999995,niel3d.com
999994,n2itall.blogspot.com
999993,solo-iphone.com
999992,adultmaven.com
999991,celoteh.web.id
</pre><div
class="betterrelated none"><p>No related content found.</p></div><p><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F29%2Freading-a-file-line-by-line-in-reverse-with-php%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F29%2Freading-a-file-line-by-line-in-reverse-with-php%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F29%2Freading-a-file-line-by-line-in-reverse-with-php%2F&amp;counturl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F29%2Freading-a-file-line-by-line-in-reverse-with-php%2F&amp;count=none&amp;text=Reading%20a%20file%20line%20by%20line%20in%20reverse%20with%20PHP" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F29%2Freading-a-file-line-by-line-in-reverse-with-php%2F&amp;counturl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F29%2Freading-a-file-line-by-line-in-reverse-with-php%2F&amp;count=none&amp;text=Reading%20a%20file%20line%20by%20line%20in%20reverse%20with%20PHP" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F29%2Freading-a-file-line-by-line-in-reverse-with-php%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F29%2Freading-a-file-line-by-line-in-reverse-with-php%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a
class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F29%2Freading-a-file-line-by-line-in-reverse-with-php%2F&amp;linkname=Reading%20a%20file%20line%20by%20line%20in%20reverse%20with%20PHP" title="LinkedIn" rel="nofollow" target="_blank"><img
src="http://werxltd.com/wp/wp-content/plugins/add-to-any/icons/linkedin.png?9d7bd4" width="16" height="16" alt="LinkedIn"/></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F29%2Freading-a-file-line-by-line-in-reverse-with-php%2F&amp;title=Reading%20a%20file%20line%20by%20line%20in%20reverse%20with%20PHP" id="wpa2a_6">Share/Save</a></p>]]></content:encoded> <wfw:commentRss>http://werxltd.com/wp/2010/10/29/reading-a-file-line-by-line-in-reverse-with-php/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Reading random lines from a file with PHP</title><link>http://werxltd.com/wp/2010/10/29/reading-random-lines-from-a-file-with-php/</link> <comments>http://werxltd.com/wp/2010/10/29/reading-random-lines-from-a-file-with-php/#comments</comments> <pubDate>Fri, 29 Oct 2010 12:00:53 +0000</pubDate> <dc:creator>wes</dc:creator> <category><![CDATA[php]]></category> <category><![CDATA[software development]]></category> <category><![CDATA[file]]></category> <category><![CDATA[random]]></category> <category><![CDATA[read]]></category> <category><![CDATA[sample]]></category><guid
isPermaLink="false">http://werxltd.com/wp/?p=818</guid> <description><![CDATA[While developing a testing framework I decided it would be nice to use a random sample of records from Alexa&#8217;s Top 1 million domains list. Here is the function I wrote to read a random number of lines from the file. function random_lines($filename, $numlines, $unique=true) { if (!file_exists($filename) &#124;&#124; !is_readable($filename)) return null; $filesize = filesize($filename); [...]]]></description> <content:encoded><![CDATA[<p>While developing a testing framework I decided it would be nice to use a random sample of records from <a
href="http://www.alexa.com/topsites">Alexa&#8217;s Top 1 million domains list</a>. Here is the function I wrote to read a random number of lines from the file.</p><pre class="brush:php">
function random_lines($filename, $numlines, $unique=true) {
    if (!file_exists($filename) || !is_readable($filename))
        return null;
    $filesize = filesize($filename);
    $lines = array();
    $n = 0;

    $handle = @fopen($filename, 'r');

    if ($handle) {
        while ($n < $numlines) {
            fseek($handle, rand(0, $filesize));

            $started = false;
            $gotline = false;
            $line = "";

            while (!$gotline) {
                if (false === ($char = fgetc($handle))) {
                    $gotline = true;
                } elseif ($char == "\n" || $char == "\r") {
                    if ($started)
                        $gotline = true;
                    else
                        $started = true;
                } elseif ($started) {
                    $line .= $char;
                }
            }

            if ($unique &#038;&#038; array_search($line, $lines))
                continue;

            $n++;
            array_push($lines, $line);
        }

        fclose($handle);
    }

    return $lines;
}

// Example usage
$lines = random_lines('top-1m.csv', 100);
echo json_encode($lines) . PHP_EOL;
</pre><p>The output produced is:</p><pre class="brush:text">
["804254,2z2z.info","298052,taronga.org.au","601192,bnsi.net","211144,best.sk","506296,bridge9.com","767784,zibashahr.com","294162,mrbookmarking.com","894095,youtube.com\/user\/Gaja2A","781514,hochschober.at","133134,global.gr"]
</pre><div
class="betterrelated none"><p>No related content found.</p></div><p><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F29%2Freading-random-lines-from-a-file-with-php%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F29%2Freading-random-lines-from-a-file-with-php%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F29%2Freading-random-lines-from-a-file-with-php%2F&amp;counturl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F29%2Freading-random-lines-from-a-file-with-php%2F&amp;count=none&amp;text=Reading%20random%20lines%20from%20a%20file%20with%20PHP" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F29%2Freading-random-lines-from-a-file-with-php%2F&amp;counturl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F29%2Freading-random-lines-from-a-file-with-php%2F&amp;count=none&amp;text=Reading%20random%20lines%20from%20a%20file%20with%20PHP" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F29%2Freading-random-lines-from-a-file-with-php%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F29%2Freading-random-lines-from-a-file-with-php%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a
class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F29%2Freading-random-lines-from-a-file-with-php%2F&amp;linkname=Reading%20random%20lines%20from%20a%20file%20with%20PHP" title="LinkedIn" rel="nofollow" target="_blank"><img
src="http://werxltd.com/wp/wp-content/plugins/add-to-any/icons/linkedin.png?9d7bd4" width="16" height="16" alt="LinkedIn"/></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F29%2Freading-random-lines-from-a-file-with-php%2F&amp;title=Reading%20random%20lines%20from%20a%20file%20with%20PHP" id="wpa2a_8">Share/Save</a></p>]]></content:encoded> <wfw:commentRss>http://werxltd.com/wp/2010/10/29/reading-random-lines-from-a-file-with-php/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Certificate Information Extractor</title><link>http://werxltd.com/wp/2010/10/15/certificate-information-extractor/</link> <comments>http://werxltd.com/wp/2010/10/15/certificate-information-extractor/#comments</comments> <pubDate>Fri, 15 Oct 2010 12:00:26 +0000</pubDate> <dc:creator>wes</dc:creator> <category><![CDATA[php]]></category> <category><![CDATA[security]]></category> <category><![CDATA[software development]]></category> <category><![CDATA[certificates]]></category> <category><![CDATA[ssl]]></category> <category><![CDATA[utility]]></category><guid
isPermaLink="false">http://werxltd.com/wp/?p=797</guid> <description><![CDATA[While working with SSL certificate based authentication I developed a handy tool to display the contents of certificates. Both PKCS12 .p12 certificates (commonly used for client authentication) as well as standard public .cer certificates. Here is my utility to check certificate information. And if you are looking for a couple of certificates to use to [...]]]></description> <content:encoded><![CDATA[<p><a
href="http://werxltd.com/wp/wp-content/uploads/2010/10/lock_open.png?9d7bd4"><img
class="alignleft size-full wp-image-801" style="margin: 5px;" title="lock_open" src="http://werxltd.com/wp/wp-content/uploads/2010/10/lock_open.png?9d7bd4" alt="" width="128" height="128" /></a>While working with <a
href="http://werxltd.com/wp/2010/09/28/secure-client-authentication-with-php-cert-auth/">SSL certificate based authentication</a> I developed a handy tool to display the contents of certificates. Both PKCS12 .p12 certificates (commonly used for client authentication) as well as standard public .cer certificates.</p><p><a
href="http://werxltd.com/lab/certinfo.php">Here is my utility to check certificate information.</a></p><p>And if you are looking for a couple of certificates to use to try this tool out, <a
href="http://werxltd.com/software/client.p12">here is a PKCS12 self-signed certificate</a>. Or, you could use my handy <a
href="http://werxltd.com/lab/pkcs12.php">self-signed PKCS12 certificate generator</a> and make your own.</p><p>Special thanks to <a
href="http://www.linein.org/blog/2010/09/28/color-pal-for-android/">John Veldboom for his ColorPal app</a> which helped me make the more appealing to the eye.</p><p><img
class="alignright size-full wp-image-798" title="openssl" src="http://werxltd.com/wp/wp-content/uploads/2010/10/openssl.png?9d7bd4" alt="" width="80" height="60" /></p><div
class="betterrelated"><p><strong>Related content:</strong></p><ol><li> <a
href="http://werxltd.com/wp/2010/09/28/secure-client-authentication-with-php-cert-auth/" title="Permanent link to Secure client authentication with php-cert-auth">Secure client authentication with php-cert-auth</a></li></ol><a
class="thanks" style="font-size: smaller; text-decoration: none;" title="Related content found by the Better Related Posts plugin" href="http://www.nkuttler.de/wordpress-plugin/wordpress-related-posts-plugin/">Better Related Posts Plugin</a></div><p><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F15%2Fcertificate-information-extractor%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F15%2Fcertificate-information-extractor%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F15%2Fcertificate-information-extractor%2F&amp;counturl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F15%2Fcertificate-information-extractor%2F&amp;count=none&amp;text=Certificate%20Information%20Extractor" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F15%2Fcertificate-information-extractor%2F&amp;counturl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F15%2Fcertificate-information-extractor%2F&amp;count=none&amp;text=Certificate%20Information%20Extractor" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F15%2Fcertificate-information-extractor%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F15%2Fcertificate-information-extractor%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a
class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F15%2Fcertificate-information-extractor%2F&amp;linkname=Certificate%20Information%20Extractor" title="LinkedIn" rel="nofollow" target="_blank"><img
src="http://werxltd.com/wp/wp-content/plugins/add-to-any/icons/linkedin.png?9d7bd4" width="16" height="16" alt="LinkedIn"/></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F15%2Fcertificate-information-extractor%2F&amp;title=Certificate%20Information%20Extractor" id="wpa2a_10">Share/Save</a></p>]]></content:encoded> <wfw:commentRss>http://werxltd.com/wp/2010/10/15/certificate-information-extractor/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Fred Brooks on the promise of object oriented programming</title><link>http://werxltd.com/wp/2010/10/12/fred-brooks-on-the-promise-of-object-oriented-programming/</link> <comments>http://werxltd.com/wp/2010/10/12/fred-brooks-on-the-promise-of-object-oriented-programming/#comments</comments> <pubDate>Tue, 12 Oct 2010 12:00:26 +0000</pubDate> <dc:creator>wes</dc:creator> <category><![CDATA[c++]]></category> <category><![CDATA[general]]></category> <category><![CDATA[it industry]]></category> <category><![CDATA[java]]></category> <category><![CDATA[javascript]]></category> <category><![CDATA[perl]]></category> <category><![CDATA[php]]></category> <category><![CDATA[python]]></category> <category><![CDATA[software development]]></category> <category><![CDATA[fred brooks]]></category> <category><![CDATA[no silver bullet]]></category> <category><![CDATA[object oriented]]></category><guid
isPermaLink="false">http://werxltd.com/wp/?p=698</guid> <description><![CDATA[One view of object-oriented programming is that it is a discipline that enforces modularity and clean interfaces. A second view emphasizes encapsulation, the fact that one cannot see, much less design, the inner structure of the pieces. Another view emphasizes inheritance, with its concomitant hierarchical structure of classes, with virtual functions. Yet another view emphasizes strong abstract data-typing, with [...]]]></description> <content:encoded><![CDATA[<blockquote><p>One view of object-oriented programming is that it is a discipline that enforces modularity and clean interfaces. A second view emphasizes encapsulation, the fact that one cannot see, much less design, the inner structure of the pieces. Another view emphasizes inheritance, with its concomitant hierarchical structure of classes, with virtual functions. Yet another view emphasizes strong abstract data-typing, with its assurance that a particular data-type will be manipulated only by operations proper to it.</p><p>Now any of these disciplines can be had without taking the whole Smalltalk or C++ package—many of them predated object-oriented technology. The attractiveness of object-oriented approach is that of a multivitamin pill: in one fell swoop (that is, programmer retraining), one gets them all. It is a very promising concept.</p><p>Why has object-oriented technique grown slowly? In the nine years since &#8220;NSB,&#8221; the expectancy has steadily grown. Why has growth been slow? Theories abound. James Coggins, author for four years of the column, &#8220;The Best of comp.lang.c++ &#8221; in The C++ Report, offers this explanation:</p><blockquote><p>The problem is that programmers in O-O have been experimenting in incestuous applications and aiming low in abstraction, instead of high. For example, they have been building classes such as linked-list or set instead of classes such as user-interface or radiation beam or finite-element model. Unfortunately the self-same strong type checking in C++ that helps programmers to avoid errors also makes it hard to build big things out of little ones.</p></blockquote><p>He goes back to the basic software problem, and argues that one way to address unmet software needs is to increase the size of the intelligent workforce by enabling and coopting our clients. This argues for top-down design:</p><blockquote><p>we design large-grained classes that address concepts our clients are already working with, they can understand and question the design as it grows, and they can cooperate in the design of test cases. My ophthalmology collaborators don&#8217;t care about stacks; they do care about Legendre polynomial shape descriptions of corneas. Small encapsulations yield small benefits.</p></blockquote><p>David Parnas, whose paper was one of the origins of object-oriented concepts, sees the matter differently. He writes me:</p><blockquote><p>The answer is simple. It is because [O-O] has been tied to a variety of complex languages. Instead of teaching people that O-O is a type of design, and giving them design principles, people have taught that O-O is the use of a particular tool. We can write good or bad programs with any tool. Unless we teach people how to design, the languages matter very little. The result is that people do bad designs with these languages and get very little value from them. If the value is small, it won&#8217;t catch on.</p></blockquote><p><em>-Fred Brooks, The Mythical Man-Month, pg. 220</em></p></blockquote><div
class="betterrelated"><p><strong>Related content:</strong></p><ol><li> <a
href="http://werxltd.com/wp/2011/02/28/fun-with-heatmaps/" title="Permanent link to Fun with heatmaps">Fun with heatmaps</a></li><li> <a
href="http://werxltd.com/wp/2010/09/27/mcafee-secure-url-shortener-firefox-add-on/" title="Permanent link to McAfee Secure URL Shortener Firefox Add-on">McAfee Secure URL Shortener Firefox Add-on</a></li><li> <a
href="http://werxltd.com/wp/2010/04/29/hiphop-for-php/" title="Permanent link to HipHop for PHP">HipHop for PHP</a></li><li> <a
href="http://werxltd.com/wp/2009/08/26/getting-starte-with-hadoop-and-mapreduce/" title="Permanent link to Getting started with Hadoop and MapReduce">Getting started with Hadoop and MapReduce</a></li><li> <a
href="http://werxltd.com/wp/2010/08/26/why-programming-is-fun/" title="Permanent link to Why programming is fun">Why programming is fun</a></li><li> <a
href="http://werxltd.com/wp/2010/09/22/mcafee-url-shortener-chrome-extension/" title="Permanent link to McAfee URL Shortener Chrome Extension">McAfee URL Shortener Chrome Extension</a></li><li> <a
href="http://werxltd.com/wp/2010/11/04/javascript-performance/" title="Permanent link to Javascript performance">Javascript performance</a></li><li> <a
href="http://werxltd.com/wp/2009/06/29/cloud-computing-101/" title="Permanent link to Cloud computing 101">Cloud computing 101</a></li><li> <a
href="http://werxltd.com/wp/2009/09/04/quick-and-dirty-image-sorting-script/" title="Permanent link to Quick and dirty image sorting script">Quick and dirty image sorting script</a></li><li> <a
href="http://werxltd.com/wp/2009/12/01/hacking-your-router-for-effective-internet-monitoring/" title="Permanent link to Hacking your router for effective internet monitoring">Hacking your router for effective internet monitoring</a></li></ol><a
class="thanks" style="font-size: smaller; text-decoration: none;" title="Related content found by the Better Related Posts plugin" href="http://www.nkuttler.de/wordpress-plugin/wordpress-related-posts-plugin/">Better Related Posts Plugin</a></div><p><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F12%2Ffred-brooks-on-the-promise-of-object-oriented-programming%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F12%2Ffred-brooks-on-the-promise-of-object-oriented-programming%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F12%2Ffred-brooks-on-the-promise-of-object-oriented-programming%2F&amp;counturl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F12%2Ffred-brooks-on-the-promise-of-object-oriented-programming%2F&amp;count=none&amp;text=Fred%20Brooks%20on%20the%20promise%20of%20object%20oriented%20programming" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F12%2Ffred-brooks-on-the-promise-of-object-oriented-programming%2F&amp;counturl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F12%2Ffred-brooks-on-the-promise-of-object-oriented-programming%2F&amp;count=none&amp;text=Fred%20Brooks%20on%20the%20promise%20of%20object%20oriented%20programming" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F12%2Ffred-brooks-on-the-promise-of-object-oriented-programming%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F12%2Ffred-brooks-on-the-promise-of-object-oriented-programming%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a
class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F12%2Ffred-brooks-on-the-promise-of-object-oriented-programming%2F&amp;linkname=Fred%20Brooks%20on%20the%20promise%20of%20object%20oriented%20programming" title="LinkedIn" rel="nofollow" target="_blank"><img
src="http://werxltd.com/wp/wp-content/plugins/add-to-any/icons/linkedin.png?9d7bd4" width="16" height="16" alt="LinkedIn"/></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F10%2F12%2Ffred-brooks-on-the-promise-of-object-oriented-programming%2F&amp;title=Fred%20Brooks%20on%20the%20promise%20of%20object%20oriented%20programming" id="wpa2a_12">Share/Save</a></p>]]></content:encoded> <wfw:commentRss>http://werxltd.com/wp/2010/10/12/fred-brooks-on-the-promise-of-object-oriented-programming/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Secure client authentication with php-cert-auth</title><link>http://werxltd.com/wp/2010/09/28/secure-client-authentication-with-php-cert-auth/</link> <comments>http://werxltd.com/wp/2010/09/28/secure-client-authentication-with-php-cert-auth/#comments</comments> <pubDate>Tue, 28 Sep 2010 12:00:23 +0000</pubDate> <dc:creator>wes</dc:creator> <category><![CDATA[php]]></category> <category><![CDATA[security]]></category> <category><![CDATA[software development]]></category> <category><![CDATA[authentication]]></category> <category><![CDATA[cert]]></category> <category><![CDATA[certificates]]></category> <category><![CDATA[encryption]]></category> <category><![CDATA[pkcs12]]></category> <category><![CDATA[public key infrastructure]]></category> <category><![CDATA[ssl]]></category><guid
isPermaLink="false">http://werxltd.com/wp/?p=704</guid> <description><![CDATA[Most websites employ a simple authentication mechanism generally consisting of a username and a password. While this method is certainly acceptable and secure for most applications, I want to take a minute to explore a more complex and, if employed correctly, more secure method of authenticating a user to a website. This method employs the [...]]]></description> <content:encoded><![CDATA[<p>Most websites employ a simple authentication mechanism generally consisting of a username and a password. While this method is certainly acceptable and secure for most applications, I want to take a minute to explore a more complex and, if employed correctly, more secure method of authenticating a user to a website.</p><p>This method employs the <a
href="http://en.wikipedia.org/wiki/Public_key_infrastructure">public key infrastructure (PKI)</a> via client based SSL <a
href="http://en.wikipedia.org/wiki/PKCS12">PKCS12</a> certificates.</p><p>First you need to make sure your server is conigured to use SSL properly. Setting up SSL in Apache is beyond the scope of this post, but <a
href="http://httpd.apache.org/docs/2.0/ssl/ssl_howto.html">here is a great HOWTO on it</a>. You&#8217;ll also need to make sure you configure Apache to export the SSL variables it gathers to PHP.</p><p>Here is the Apache config setting to allow the SSL environment variables to be correctly exported to PHP (via the $_SERVER variable).</p><pre class="brush:plain">
SSLVerifyClient optional_no_ca
SSLVerifyDepth  10

SSLOptions +ExportCertData +StdEnvVars
</pre><p>Next you&#8217;ll want to grab a copy of our handy <a
href="http://code.google.com/p/php-cert-auth/">php-cert-auth class from here</a>. The configuration is pretty straightforward, feel free to include config parameters in the class directly if you don&#8217;t want to worry about maintaining a seperate configuration file.</p><p>Here are a few examples of what our class will allow you to do.</p><p>To download a self-signed certificate:</p><pre class="brush:php">header("Content-Type: application/x-pkcs12");
header('Content-Disposition: attachment; filename=client.p12');

$countryName = "US";
$stateOrProvinceName = "Georgia";
$localityName = "Roswell";
$organizationName = "Werx Limited";
$organizationalUnitName = "Labs";
$commonName = "Wes Widner";
$emailAddress = "wes@werxltd.com";

$cert = new WerxLtd_Auth_Cert();
$pks12 = $cert-&gt;getPKCS12SelfSigned(
	$countryName,
	$stateOrProvinceName,
	$localityName,
	$organizationName,
	$organizationalUnitName,
	$commonName,
	$emailAddress
);

echo $pkcs12;

/*
 * You can also parse the pkcs12 data back out via: openssl_pkcs12_read($pks12, $data, null);
 */</pre><p>Here is how you could go about authenticating a user:</p><pre class="brush:php">$cert = new WerxLtd_Auth_Cert();
if($cert-&gt;hasClientCert()) {
	$keyid = $cert-&gt;getSubjectKeyIdentifier();
	// You can then use this key to query a list of known keys associated with valid users
}</pre><p>This package is not designed to work in a stand-alone fashion. It is designed to be a helpful passwordless enhancement to an existing authentication system. Since the subjectKeyIdentifier is unique for each certificate that is issued<sup><a
href="http://werxltd.com/wp/2010/09/28/secure-client-authentication-with-php-cert-auth/#footnote_0_704" id="identifier_0_704" class="footnote-link footnote-identifier-link" title="http://www.ietf.org/rfc/rfc3280.txt">1</a></sup>, it is wholly possible to associate it with a user&#8217;s account and check the supplied user certificate against a list of known client certificates in order to authorize the user in a transparent fashion.</p><p>There are many other ways a client certificate can be used to make your application even more secure. Like encrypting information before it is saved to permanent storage. You can also use the information contained in the client certificate to automatically fill in form fields. The biggest pitfall I can see to employing client certificates is the added complexity of the application.</p><p>Further reading:</p><ul><li><a
href="http://php-security.net/archives/3-X.509-PKI-login-with-PHP-and-Apache.html">X.509 PKI Login With PHP and Apache</a></li><li><a
href="http://hausheer.osola.com/docs/9">Creating a self-signed X509 server certificate and a PKCS12 client certificate with openssl</a></li></ul><div
class="betterrelated"><p><strong>Related content:</strong></p><ol><li> <a
href="http://werxltd.com/wp/2010/10/15/certificate-information-extractor/" title="Permanent link to Certificate Information Extractor">Certificate Information Extractor</a></li></ol><a
class="thanks" style="font-size: smaller; text-decoration: none;" title="Related content found by the Better Related Posts plugin" href="http://www.nkuttler.de/wordpress-plugin/wordpress-related-posts-plugin/">Better Related Posts Plugin</a></div><ol
class="footnotes"><li
id="footnote_0_704" class="footnote"><a
href="http://werxltd.com/wp/wp-content/uploads/2010/09/rfc3280.txt">http://www.ietf.org/rfc/rfc3280.txt</a></li></ol><p><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F09%2F28%2Fsecure-client-authentication-with-php-cert-auth%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F09%2F28%2Fsecure-client-authentication-with-php-cert-auth%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F09%2F28%2Fsecure-client-authentication-with-php-cert-auth%2F&amp;counturl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F09%2F28%2Fsecure-client-authentication-with-php-cert-auth%2F&amp;count=none&amp;text=Secure%20client%20authentication%20with%20php-cert-auth" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F09%2F28%2Fsecure-client-authentication-with-php-cert-auth%2F&amp;counturl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F09%2F28%2Fsecure-client-authentication-with-php-cert-auth%2F&amp;count=none&amp;text=Secure%20client%20authentication%20with%20php-cert-auth" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F09%2F28%2Fsecure-client-authentication-with-php-cert-auth%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F09%2F28%2Fsecure-client-authentication-with-php-cert-auth%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a
class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F09%2F28%2Fsecure-client-authentication-with-php-cert-auth%2F&amp;linkname=Secure%20client%20authentication%20with%20php-cert-auth" title="LinkedIn" rel="nofollow" target="_blank"><img
src="http://werxltd.com/wp/wp-content/plugins/add-to-any/icons/linkedin.png?9d7bd4" width="16" height="16" alt="LinkedIn"/></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F09%2F28%2Fsecure-client-authentication-with-php-cert-auth%2F&amp;title=Secure%20client%20authentication%20with%20php-cert-auth" id="wpa2a_14">Share/Save</a></p>]]></content:encoded> <wfw:commentRss>http://werxltd.com/wp/2010/09/28/secure-client-authentication-with-php-cert-auth/feed/</wfw:commentRss> <slash:comments>8</slash:comments> </item> <item><title>Process forking and threading with PHP</title><link>http://werxltd.com/wp/2010/08/23/process-forking-with-php/</link> <comments>http://werxltd.com/wp/2010/08/23/process-forking-with-php/#comments</comments> <pubDate>Mon, 23 Aug 2010 12:00:49 +0000</pubDate> <dc:creator>wes</dc:creator> <category><![CDATA[php]]></category> <category><![CDATA[software development]]></category> <category><![CDATA[distributed processing]]></category> <category><![CDATA[parallel processing]]></category> <category><![CDATA[php threads]]></category> <category><![CDATA[pid]]></category> <category><![CDATA[process id]]></category> <category><![CDATA[serializing]]></category> <category><![CDATA[shared memory]]></category> <category><![CDATA[threading]]></category><guid
isPermaLink="false">http://werxltd.com/wp/?p=663</guid> <description><![CDATA[I&#8217;ve been working on a rather large web application which is responsible for combining data from a variety of sources and presenting the data to the end user in a clean, unified fashion. During this process we sometimes run into cases where multiple related calls are made, each to perform some transformative work on a [...]]]></description> <content:encoded><![CDATA[<p>I&#8217;ve been working on a rather large web application which is responsible for combining data from a variety of sources and presenting the data to the end user in a clean, unified fashion. During this process we sometimes run into cases where multiple related calls are made, each to perform some transformative work on a single set of data. We decided these calls could be made in a more parallel fashion and as such started looking into ways of parallelizing PHP so that relatively expensive operations could be performed at the same time and then the results combined in the end.</p><p>We examined a few possible solutions such as <a
href="http://gearman.org/">Gearman</a>, <a
href="http://webforumz.com/php/12595-multithreaded-php.htm">popen</a>, and <a
href="http://www.developertutorials.com/tutorials/php/parallel-web-scraping-in-php-curl-multi-functions-375/">multi curl</a>. However all of these methods seemed to require more overhead than they were worth. What I really wanted to see was something more along the lines of <a
href="http://en.wikipedia.org/wiki/POSIX_Threads">POSIX threads</a> to distribute the work load and <a
href="http://en.wikipedia.org/wiki/Shared_memory">shared memory</a> for passing data between the parent and child threads.</p><p>After some searching through PHP extensions and the official documentation I ran across <a
href="http://us3.php.net/manual/en/refs.fileprocess.process.php">PHP&#8217;s Process Control Extensions</a> suite which contains <a
href="http://us3.php.net/manual/en/ref.pcntl.php">PCNTL functions</a>, one of which is <a
href="http://us3.php.net/manual/en/function.pcntl-fork.php">pcntl_fork</a>. Combined with PHP&#8217;s <a
href="http://us3.php.net/manual/en/ref.shmop.php">Shared Memory Functions</a>, this promises to fit the bill of inexpensive distribution of processing tasks along with low-overhead <a
href="http://en.wikipedia.org/wiki/Inter-process_communication">inter process communication</a>.</p><p>Here is a sample proof-of-concept script. I&#8217;ll outline what it does below:</p><pre class="brush:php">$data = array();

echo "Parent PID: ".getmypid().PHP_EOL;

function forkTest(array &amp;$data) {
	$pids = array();

	$parent_pid = getmypid();

	for($i = 0; $i &lt; 10; $i++) {
		if(getmypid() == $parent_pid) {
			$pids[] = pcntl_fork();
			echo "Forking child, \$pids now has ".count($pids)." elements".PHP_EOL;
		}
	} 	

	if (getmypid() == $parent_pid) {
		/* Parent thread */
		echo "Hello from parent: ".getmypid().PHP_EOL;
		array_push($data, "parent".getmypid()); 		  		 

		/* Process childrens' results as they exit */
		while(count($pids) &gt; 0) {
			$pid = pcntl_waitpid(-1, $status);
			echo "Attempting to open memory with pid: ".$pid.PHP_EOL;
			$shm_id = shmop_open($pid, "a", 0, 0);

			$shm_data = unserialize(shmop_read($shm_id, 0, shmop_size($shm_id)));
			shmop_delete($shm_id);
			shmop_close($shm_id);

			$data = array_merge($data, $shm_data);

			/* Hunt down and remove pid entry */
			foreach($pids as $key =&gt; $tpid) {
				if($pid == $tpid) unset($pids[$key]);
			}
		}

		echo "All children exited, \$data now has:".count($data)." elements".PHP_EOL;
		$pids = array();
	} else {
		/* Children threads */
		$pdata = array();
		echo "Hello from child: ".getmypid().PHP_EOL;
		array_push($pdata, "child".getmypid());
		$data_str = serialize($pdata);

		$shm_id = shmop_open(getmypid(), "c", 0644, strlen($data_str));
		if (!$shm_id) {
			echo "Couldn't create shared memory segment".PHP_EOL;
		} else {
			if(shmop_write($shm_id, $data_str, 0) != strlen($data_str)) {
				echo "Couldn't write shared memory data".PHP_EOL;
			}
		}

		sleep(rand(1,10));
		exit(0);
	}
}

/* Run the test 10 times */
for($f = 0; $f &lt; 10; $f++) {
	echo "Running $f forkTest()".PHP_EOL;
	forkTest($data);
}

echo "Fork test finished, \$data now contains ".count($data)." elements".PHP_EOL;
echo "\$data:".PHP_EOL.json_encode($data);</pre><p>This code describes a function that spawns 10 child worker threads, each of which gets a reference to the global $data array. Each child thread pushes a string element containing the child thread&#8217;s <a
href="http://en.wikipedia.org/wiki/Process_identifier">process identifier</a> into the array, serializes it, and then places it into a shared memory slot with the process id serving as the shared memory id. The parent process waits for each child thread to exit, gathers the data from shared memory, clears the shared memory, and then combines the results into the master $data array. My test application runs through this function 10 times to demonstrate how <a
href="http://www.electrictoolbox.com/article/php/process-forking/">forking in PHP</a> can be safe and memory efficient. The result should be a $data array with 110 elements in it. I&#8217;ve thrown in sleep commands with a random time between 1 and 10 seconds to show how threads can return at different times.</p><p>No doubt optimizations can be made but this should serve as at least a rudimentary example of true and efficient threading in PHP. Well, provided that the work you are planning on doing is worth the overhead (which, small as it may be, still exists and should be factored in) and provided that you do not mind locking your application down to a POSIX environment (meaning the above code will not work on windows platforms).</p><div
class="betterrelated none"><p>No related content found.</p></div><p><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F08%2F23%2Fprocess-forking-with-php%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F08%2F23%2Fprocess-forking-with-php%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F08%2F23%2Fprocess-forking-with-php%2F&amp;counturl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F08%2F23%2Fprocess-forking-with-php%2F&amp;count=none&amp;text=Process%20forking%20and%20threading%20with%20PHP" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F08%2F23%2Fprocess-forking-with-php%2F&amp;counturl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F08%2F23%2Fprocess-forking-with-php%2F&amp;count=none&amp;text=Process%20forking%20and%20threading%20with%20PHP" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F08%2F23%2Fprocess-forking-with-php%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F08%2F23%2Fprocess-forking-with-php%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a
class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F08%2F23%2Fprocess-forking-with-php%2F&amp;linkname=Process%20forking%20and%20threading%20with%20PHP" title="LinkedIn" rel="nofollow" target="_blank"><img
src="http://werxltd.com/wp/wp-content/plugins/add-to-any/icons/linkedin.png?9d7bd4" width="16" height="16" alt="LinkedIn"/></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F08%2F23%2Fprocess-forking-with-php%2F&amp;title=Process%20forking%20and%20threading%20with%20PHP" id="wpa2a_16">Share/Save</a></p>]]></content:encoded> <wfw:commentRss>http://werxltd.com/wp/2010/08/23/process-forking-with-php/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Using PHP to write PHP</title><link>http://werxltd.com/wp/2010/07/29/using-php-to-write-php/</link> <comments>http://werxltd.com/wp/2010/07/29/using-php-to-write-php/#comments</comments> <pubDate>Thu, 29 Jul 2010 19:00:49 +0000</pubDate> <dc:creator>wes</dc:creator> <category><![CDATA[php]]></category> <category><![CDATA[kml]]></category> <category><![CDATA[mapping]]></category> <category><![CDATA[utilities]]></category> <category><![CDATA[wkt]]></category><guid
isPermaLink="false">http://werxltd.com/wp/?p=630</guid> <description><![CDATA[I ran into a situation recently where I had a very large array object that was not going to change. It was the polygon coordinates for the world countries to be used in KML provided by Thematic Mapping. I didn&#8217;t wan&#8217;t to pull this data out of MySQL every time I went to build a [...]]]></description> <content:encoded><![CDATA[<p>I ran into a situation recently where I had a very large array object that was not going to change. It was the polygon coordinates for the world countries to be used in <a
href="http://code.google.com/apis/kml/documentation/">KML</a> provided by <a
href="http://thematicmapping.org/">Thematic Mapping</a>.</p><p>I didn&#8217;t wan&#8217;t to pull this data out of MySQL every time I went to build a map, I wanted to use one giant static array instead. So to write the array back out in a re-usable fashion I developed the following code which can take any array, of any depth, associative or index based, and spit out corresponding PHP that you can copy and paste back into your script.</p><pre class="brush:php">function phpPrintArr(array $arr) {
	echo "array(".PHP_EOL;

	$c = 1;
	$total = count($arr);

	foreach($arr as $i =&gt;$v) {
		$iq = is_numeric($i) ? '' : '"';
		$vq = is_numeric($v) ? '' : '"';
		$e = $c &lt; $total ? ',' : '';

		if(is_array($v)) {
			echo $iq.$i.$iq.'=&gt;'.PHP_EOL;
			phpPrintArr($v);
			echo $e.PHP_EOL;
		} else {
			echo $iq.$i.$iq.'=&gt;'.$vq.$v.$vq.$e.PHP_EOL;
		}
		$c++;
	}

	echo ")".PHP_EOL;
}</pre><p>Oh, and for anyone who is interested in the array of country polygons this produced from the Thematic Mapping Engine data, <a
href="http://werxltd.com/software/TME_Countries">here is the rather large array</a>. Feel free to use it in your own KML project.</p><div
class="betterrelated none"><p>No related content found.</p></div><p><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F07%2F29%2Fusing-php-to-write-php%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F07%2F29%2Fusing-php-to-write-php%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F07%2F29%2Fusing-php-to-write-php%2F&amp;counturl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F07%2F29%2Fusing-php-to-write-php%2F&amp;count=none&amp;text=Using%20PHP%20to%20write%20PHP" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F07%2F29%2Fusing-php-to-write-php%2F&amp;counturl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F07%2F29%2Fusing-php-to-write-php%2F&amp;count=none&amp;text=Using%20PHP%20to%20write%20PHP" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F07%2F29%2Fusing-php-to-write-php%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F07%2F29%2Fusing-php-to-write-php%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a
class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F07%2F29%2Fusing-php-to-write-php%2F&amp;linkname=Using%20PHP%20to%20write%20PHP" title="LinkedIn" rel="nofollow" target="_blank"><img
src="http://werxltd.com/wp/wp-content/plugins/add-to-any/icons/linkedin.png?9d7bd4" width="16" height="16" alt="LinkedIn"/></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F07%2F29%2Fusing-php-to-write-php%2F&amp;title=Using%20PHP%20to%20write%20PHP" id="wpa2a_18">Share/Save</a></p>]]></content:encoded> <wfw:commentRss>http://werxltd.com/wp/2010/07/29/using-php-to-write-php/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>HipHop for PHP</title><link>http://werxltd.com/wp/2010/04/29/hiphop-for-php/</link> <comments>http://werxltd.com/wp/2010/04/29/hiphop-for-php/#comments</comments> <pubDate>Thu, 29 Apr 2010 12:00:15 +0000</pubDate> <dc:creator>wes</dc:creator> <category><![CDATA[c++]]></category> <category><![CDATA[it industry]]></category> <category><![CDATA[php]]></category> <category><![CDATA[software development]]></category> <category><![CDATA[high performance]]></category> <category><![CDATA[hiphop]]></category> <category><![CDATA[web scale]]></category><guid
isPermaLink="false">http://werxltd.com/wp/?p=573</guid> <description><![CDATA[Earlier this year Facebook developers caused quite a stir in the PHP community by releasing HipHop, the central piece in their high-performance arsenal. Here is the video of the initial announcement along with some juicy technical details: If you are interested in seeing how your PHP project fares when run through HipHop, check out the [...]]]></description> <content:encoded><![CDATA[<p>Earlier this year <a
href="http://developers.facebook.com/blog/post/358">Facebook developers</a> caused quite a stir in the PHP community by releasing <a
href="http://en.wikipedia.org/wiki/HipHop_(software)">HipHop</a>, the central piece in their high-performance arsenal.</p><p><a
href="http://www.ustream.tv/recorded/4409735">Here is the video</a> of the initial announcement along with some juicy technical details:<br
/> <object
id="utv946196" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="386" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param
name="name" value="utv_n_687056" /><param
name="flashvars" value="loc=%2F&amp;autoplay=false&amp;vid=4409735&amp;locale=en_US" /><param
name="allowfullscreen" value="true" /><param
name="allowscriptaccess" value="always" /><param
name="src" value="http://www.ustream.tv/flash/video/4409735" /><embed
id="utv946196" type="application/x-shockwave-flash" width="480" height="386" src="http://www.ustream.tv/flash/video/4409735" allowscriptaccess="always" allowfullscreen="true" flashvars="loc=%2F&amp;autoplay=false&amp;vid=4409735&amp;locale=en_US" name="utv_n_687056"></embed></object></p><p>If you are interested in seeing how your PHP project fares when run through HipHop, check out the official <a
href="http://github.com/facebook/hiphop-php">HipHop project page</a>.</p><p>With tools like HipHop, scripting languages like PHP are no longer subject to the charges of gross computational inefficiency. In short, it&#8217;s a great day to be a web developer.</p><div
class="betterrelated"><p><strong>Related content:</strong></p><ol><li> <a
href="http://werxltd.com/wp/2010/10/12/fred-brooks-on-the-promise-of-object-oriented-programming/" title="Permanent link to Fred Brooks on the promise of object oriented programming">Fred Brooks on the promise of object oriented programming</a></li><li> <a
href="http://werxltd.com/wp/2011/02/28/fun-with-heatmaps/" title="Permanent link to Fun with heatmaps">Fun with heatmaps</a></li></ol><a
class="thanks" style="font-size: smaller; text-decoration: none;" title="Related content found by the Better Related Posts plugin" href="http://www.nkuttler.de/wordpress-plugin/wordpress-related-posts-plugin/">Better Related Posts Plugin</a></div><p><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F04%2F29%2Fhiphop-for-php%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F04%2F29%2Fhiphop-for-php%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F04%2F29%2Fhiphop-for-php%2F&amp;counturl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F04%2F29%2Fhiphop-for-php%2F&amp;count=none&amp;text=HipHop%20for%20PHP" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F04%2F29%2Fhiphop-for-php%2F&amp;counturl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F04%2F29%2Fhiphop-for-php%2F&amp;count=none&amp;text=HipHop%20for%20PHP" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F04%2F29%2Fhiphop-for-php%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F04%2F29%2Fhiphop-for-php%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a
class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F04%2F29%2Fhiphop-for-php%2F&amp;linkname=HipHop%20for%20PHP" title="LinkedIn" rel="nofollow" target="_blank"><img
src="http://werxltd.com/wp/wp-content/plugins/add-to-any/icons/linkedin.png?9d7bd4" width="16" height="16" alt="LinkedIn"/></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F04%2F29%2Fhiphop-for-php%2F&amp;title=HipHop%20for%20PHP" id="wpa2a_20">Share/Save</a></p>]]></content:encoded> <wfw:commentRss>http://werxltd.com/wp/2010/04/29/hiphop-for-php/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using apc
Page Caching using apc
Database Caching 2/51 queries in 0.195 seconds using apc
Object Caching 1202/1327 objects using apc

Served from: werxltd.com @ 2012-02-08 13:00:59 -->
