<?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>Thijs Lensselink&#039;s Blog</title>
	<atom:link href="http://lenss.nl/feed/" rel="self" type="application/rss+xml" />
	<link>http://lenss.nl</link>
	<description>Webdevelopment and stuff...</description>
	<lastBuildDate>Sun, 05 Feb 2012 11:39:43 +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>PHP critical bug CVE-2012-0830</title>
		<link>http://lenss.nl/2012/02/php-critical-bug-cve-2012-0830/</link>
		<comments>http://lenss.nl/2012/02/php-critical-bug-cve-2012-0830/#comments</comments>
		<pubDate>Sun, 05 Feb 2012 11:39:43 +0000</pubDate>
		<dc:creator>Thijs Lensselink</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[attack]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[Crash]]></category>
		<category><![CDATA[CVE-2012-0830]]></category>
		<category><![CDATA[remote]]></category>

		<guid isPermaLink="false">http://lenss.nl/?p=1423</guid>
		<description><![CDATA[Ok it&#8217;s a bit late But i have been laying under a rock for the last week. And i guess it can&#8217;t hurt! Last week a critical bug was discovered in PHP. Which affects versions 5.3.9 and 5.2.17. The bug could be exploited to run arbitrary code on a remote PHP system. So upgrade your [...]]]></description>
			<content:encoded><![CDATA[<p>Ok it&#8217;s a bit late But i have been laying under a rock for the last week. And i guess it can&#8217;t hurt!</p>
<p>Last week a critical bug was discovered in PHP. Which affects versions 5.3.9 and 5.2.17. The bug could be exploited to run arbitrary code on a remote PHP system. So upgrade your systems. And of course Stefan Esser <a href="http://news.php.net/php.internals/57655">popped up</a> with some wise words :)&#8230; O well i still think the guy does great work.</p>
<p>More info about the issue can be found on packetstorm (<a href="http://packetstormsecurity.org/files/cve/CVE-2012-0830">CVE-2012-0830</a>) </p>
]]></content:encoded>
			<wfw:commentRss>http://lenss.nl/2012/02/php-critical-bug-cve-2012-0830/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP getting strict sessions</title>
		<link>http://lenss.nl/2011/11/php-getting-strict-sessions/</link>
		<comments>http://lenss.nl/2011/11/php-getting-strict-sessions/#comments</comments>
		<pubDate>Wed, 30 Nov 2011 13:38:28 +0000</pubDate>
		<dc:creator>Thijs Lensselink</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[5.4]]></category>
		<category><![CDATA[patch]]></category>
		<category><![CDATA[session fixation]]></category>
		<category><![CDATA[strict_session]]></category>

		<guid isPermaLink="false">http://lenss.nl/?p=1405</guid>
		<description><![CDATA[For years PHP has been vulnerable to session adoption which can enable session fixation. And since sessions are a major part of web applications now a days. A lot of platforms are open and waiting for an attack to happen. session adoption &#038; session fixation The problem exists because the current session module does not [...]]]></description>
			<content:encoded><![CDATA[<p>For years <a href="http://php.net/">PHP</a> has been vulnerable to session adoption which can enable <a href="http://en.wikipedia.org/wiki/Session_fixation">session fixation</a>. And since sessions are a major part of web applications now a days. A lot of platforms are open and waiting for an attack to happen.</p>
<p><strong>session adoption &#038; session fixation</strong></p>
<p>The problem exists because the current session module does not validate the session id that comes in from a cookie. This means uninitialized session id&#8217;s can be passed by the client. This happens due to the fact that browsers overwrite cookie if multiple cookies are send per request.<br />
Some people would say this is solvable by implementing <a href="http://nl3.php.net/manual/en/function.session-regenerate-id.php">session_regenerate_id()</a>. But this is not the case.</p>
<p>Because session fixation can be used to take over control of web applications. Validation is required when multiple cookies are send per request. When multiple cookie are send with a request. Browsers send multiple cookies without domain / path information. This way it&#8217;s impossible to tell which cookie belongs to which domain. </p>
<p><strong>So how do we fix this?</strong></p>
<p>There is some userland code that does offer the ability to validate session data. But this has not been widely adopted by other developers.</p>
<p>Code that adds the session ID as a validation key:</p>
<pre class="php" name="code">
session_destory();
session_regenerate_id();
$_SESSION['valid_id'] = session_id();
</pre>
<p>And the code to check if the session was properly initialized:</p>
<pre class="php" name="code">
if ($_SESSION['valid_id'] !== session_id()) {
  die('Invalid use of session ID');
}
</pre>
<p>Thank god the internal developer know this. And are working to fix this. For the past days there has been an interesting discussion going on on the <a href="http://news.php.net/php.internals">internals</a> list. About applying a patch that will fix this. The patch will add some new php.ini features and a new method validate_id() for the session save handler. Hopefully this will be available in version 5.4.</p>
<p>To not break BC strict_mode will be disabled by default. But can be enabled by setting the following setting in php.ini. When enabled uninitialized session ID will be discarded.</p>
<blockquote><p>session.use_strict_mode=0</p></blockquote>
<p>To prevent a DoS instead of session fixation. An new feature has been added that deletes possible malicious cookies that prevent new session ID.</p>
<blockquote><p>session.safe_session_cookie=1</p></blockquote>
<p>You can read more about session fixation and the upcoming patch on the <a href="https://wiki.php.net/rfc/strict_sessions">PHP-Wiki</a></p>
]]></content:encoded>
			<wfw:commentRss>http://lenss.nl/2011/11/php-getting-strict-sessions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Abbywinters.com is hiring!</title>
		<link>http://lenss.nl/2011/11/abbywinters-com-is-hiring/</link>
		<comments>http://lenss.nl/2011/11/abbywinters-com-is-hiring/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 12:46:51 +0000</pubDate>
		<dc:creator>Thijs Lensselink</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[abbywinters.com]]></category>
		<category><![CDATA[Adult]]></category>
		<category><![CDATA[Agile]]></category>
		<category><![CDATA[Job]]></category>
		<category><![CDATA[naturally delicious]]></category>
		<category><![CDATA[SCRUM]]></category>
		<category><![CDATA[Sexy]]></category>
		<category><![CDATA[Webdeveloper]]></category>

		<guid isPermaLink="false">http://lenss.nl/?p=1386</guid>
		<description><![CDATA[If you&#8217;re looking for a new challenging and exiting Senior Webdeveloper position. Don&#8217;t look any further. If you already think you have the job of your dreams. Think again! abbywinters.com (NSFW) is one of the largest and most ethical, highly rated, well designed, and successful erotic websites in the world today. abbywinters.com is the WINNER [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://careers.abbywinters.com/job-opportunities/senior-php-developer/" target="_blank"><img src="http://lenss.nl/wp-content/uploads/2011/11/aw-logo-roundel-blue.png" alt="" title="abbywinters.com - Delivering game-changing experiences" style="float:left;margin:10px;" width="140" height="140" class="alignright size-full wp-image-1385" /></a> If you&#8217;re looking for a new challenging and exiting Senior Webdeveloper position. Don&#8217;t look any further. If you already think you have the job of your dreams. Think again!</p>
<p><em><a href="http://www.abbywinters.com" target="_blank">abbywinters.com</a> <b>(NSFW)</b> is one of the largest and most ethical, highly rated, well designed, and successful erotic websites in the world today. abbywinters.com is the WINNER of the AVN 2011 Awards for Best Membership site!</em></p>
<p>And we are looking to hire a new talented webdeveloper to expand our small team. What would you think about joining our small Agile team of highly qualified professionals? </p>
<p>You will be creating sexy, exiting and game changing experiences for the web, work for one of the industry leaders. And just be part of an awesome company. Some of the jobs key elements are:</p>
<ul>
<li>Implementing development projects</li>
<li>Leading informal mentoring during day-to-day work</li>
<li>Contribute to design of development projects</li>
<li>Track, reduce, and prevent technical debt in Web Development projects</li>
</ul>
<p><br/></p>
<blockquote><p>Motivated by principles of social responsibility, we deliver provocative media by embracing imagination, creativity and emerging technologies. Our models, customers and business partners are inspired by our fervid passion.</p>
<p><br/></p>
<p>Our experienced staff use state-of-the-art content production facilities to produce 10 shoots a week from concept to finished art, utilizing the most advanced digital capture, post production and delivery systems in the world.</p>
<p><br/></p>
<p>You will be working directly with our Web Dev Manager, Lead developer and colleagues in the web dev team. We need each individual to contribute for us to continue as a pioneer in our industry.</p>
</blockquote>
<p><br/></p>
<p>If you posses a &#8220;Can do&#8221; attitude. Would like to work in the center of Amsterdam. And are able to identify your self in the criteria below. You might want to head over to our <a href="http://careers.abbywinters.com/job-opportunities/senior-php-developer/">career portal</a> for a more detailed description.<br/></p>
<p><strong>Technical competencies – Required</strong></p>
<ul>
<li>High level of skill with PHP 5</li>
<li>High level of skill with Object Oriented Programming</li>
<li>High level of skill with HTML/CSS</li>
<li>High level of skill with JavaScript</li>
<li>High level of skill with Internet Applications</li>
<li>Moderate level of skill with Unit Testing and Test Driven Design</li>
<li>Moderate level of skill with MySQL</li>
<li>Moderate level of skill with Windows XP operating system</li>
<li>Experience with the GNU/Linux operating system</li>
<li>Competent with Revision Control systems (Subversion)</li>
<li>Bachelor of Science in Computer Science, or equivalent experience</li>
<li>Zend Certified Engineer, or equivalent experience</li>
<li>At least 5 years experience in Web Application Development</li>
</ul>
<p><br/></p>
<p><strong>Technical competencies – Desired</strong></p>
<ul>
<li>Moderate level of skill with the Apache HTTP server</li>
<li>Good understanding of the Model-View-Controller pattern</li>
<li>Good understanding of the ActiveRecord Object-Relational-Mapping pattern</li>
<li>Familiarity with Agile software development practices (Scrum)</li>
<li>E-commerce</li>
<li>Agile development experience</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://lenss.nl/2011/11/abbywinters-com-is-hiring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu 11.10 issues after fresh install</title>
		<link>http://lenss.nl/2011/11/ubuntu-11-10-issues-after-fresh-install/</link>
		<comments>http://lenss.nl/2011/11/ubuntu-11-10-issues-after-fresh-install/#comments</comments>
		<pubDate>Sun, 06 Nov 2011 22:26:27 +0000</pubDate>
		<dc:creator>Thijs Lensselink</dc:creator>
				<category><![CDATA[/home]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Crash]]></category>
		<category><![CDATA[GNOME]]></category>
		<category><![CDATA[nvidia]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Unity]]></category>
		<category><![CDATA[WoW]]></category>

		<guid isPermaLink="false">http://lenss.nl/?p=1361</guid>
		<description><![CDATA[Update: 13-11-2011 I decided to give Ubuntu another try. After downloading and burning a fresh image. I did a clean install. And this time the result was a lot better then the first time. Maybe i just had a bad disk. Unity still caused me issues. Mainly because i am running a dual monitor setup. [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update: 13-11-2011</strong></p>
<p>I decided to give Ubuntu another try. After downloading and burning a fresh image. I did a clean install. And this time the result was a lot better then the first time. Maybe i just had a bad disk.</p>
<p>Unity still caused me issues. Mainly because i am running a dual monitor setup. And i wan to use a TwinView setup. This just does not seem to work at the moment. So i install GNOME Shell. And that seems to work a lot smoother with two screens. Even my sound issues have been resolved magically. Maybe i should stick with Ubuntu a bit longer.</p>
<p><del datetime="2011-11-13T21:33:08+00:00">This weekend i decided to finally try to upgrade Ubuntu to the latest version (11.10). And since the upgrade process was not working out for me. I had no other choice but to do a clean install. No problem. It was time for a clean install anyway.</del></p>
<p><del datetime="2011-11-13T21:33:08+00:00">After fighting my way through a pile of bad rewritable DVDs i finally managed to write to disc that didn&#8217;t halt in the middle of the install process. And finished the install quite quickly. No problem there.</del></p>
<p><del datetime="2011-11-13T21:33:08+00:00">The <a href="https://launchpad.net/lightdm">Lightgdm</a> greeting instead of the old <a href="http://projects.gnome.org/gdm/">GDM</a> interface was nice. I logged in. And then it hit me. O shit they hooked Ubuntu up with the <a href="http://unity.ubuntu.com/">Unity</a> interface. The last time i upgraded Ubuntu that was the first thing i disabled. But my second screen wasn&#8217;t activated. So i decided to install the Nvidia drivers first. And then did a reboot.</del></p>
<p><del datetime="2011-11-13T21:33:08+00:00">After the system came back up. The desktop environment didn&#8217;t load anymore. And if i waited long enough the whole system would crawl to a halt. Damn! At this point i was getting sleepy. And didn&#8217;t want to spend the whole night poking around the system trying to fix this. So a bit of Google magic later i found <a href="http://blog.al4.co.nz/2011/10/slow-desktop-performance-on-ubuntu-11-10-with-nvidia-graphics-cards/">this</a>. Some issues related to the current Nvidia driver. So i upgraded to the 285.05 version</del></p>
<p><del datetime="2011-11-13T21:33:08+00:00"><br />
<blockquote>$ sudo bash<br />
$ add-apt-repository ppa:ubuntu-x-swat/x-updates<br />
$ apt-get update &#038;&#038; apt-get upgrade<br />
$ reboot</p></blockquote>
<p></del></p>
<p><del datetime="2011-11-13T21:33:08+00:00">And after a reboot the desktop was fine again. Nice!</del></p>
<p><strong>World of Warcraft</strong></p>
<p>After that i installed wine and copied back the old files i already had installed previously. But World of Warcraft didn&#8217;t want to start anymore. And although i planned not to play for a while. This got me poking around. And of course couldn&#8217;t find a solution. So i downloaded a new game client from battle.net. And started a fresh install. But when the launcher came up. It crashed just like before. Tried it a couple more times. When i noticed it was crashing starting the download. SO i started poking around in the download settings. And disabled peer-to peer. And voila! It started working for me again.</p>
<blockquote><p>Options > Downloader Preferences<br />
(uncheck ¨Enable peer-to-peer Transfer¨)</p></blockquote>
<p><del datetime="2011-11-13T21:33:08+00:00"><strong>Lets remove Unity!</strong></del></p>
<p><del datetime="2011-11-13T21:33:08+00:00">Although i kind alike the <a href="http://unity.ubuntu.com/">Unity</a> interface. It wasn&#8217;t running smoothly. And i was having some serious CPU load issues. So i decided to remove it once again. This time. It wasn&#8217;t as easy though. I followed the steps in <a href="http://linux-software-news-tutorials.blogspot.com/2011/10/ubuntu-1110-oneiric-remove-unity-and.html">this</a> post. Only to come to the realization that its <a href="http://www.gnome.org/gnome-3/">Gnome 3</a> i´m dealing with and not Gnome2. O well lets give it a try. </del></p>
<p><del datetime="2011-11-13T21:33:08+00:00">So after messing with the themes a bit. I got the normal look back. Now the only thing annoying left is the bottom bar. That has to go. And preferably moved to the second screen. This was surprisingly easy for a change. Start up DConfig Editor from the Applications menu. And navigate to.</del></p>
<p><del datetime="2011-11-13T21:33:08+00:00"><br />
<blockquote>org > gnome > gnome-panel > layout > toplevels</p></blockquote>
<p></del></p>
<p><del datetime="2011-11-13T21:33:08+00:00">(then change)</p>
<blockquote><p>monitor : 1<br />
orientation : top</p></blockquote>
<p></del></p>
<p><del datetime="2011-11-13T21:33:08+00:00">And fix the freaking <a href="http://askubuntu.com/questions/69306/tilde-and-double-quote-keys-dont-work-on-the-command-line">keyboard</a></del></p>
<p><del datetime="2011-11-13T21:33:08+00:00">Sound still makes a crackling noise!</del></p>
<p><del datetime="2011-11-13T21:33:08+00:00">But at least i have a desktop that looks reasonably the same as my old and trusted Gnome2 one did. </del></p>
<p><a href="http://lenss.nl/wp-content/uploads/2011/11/Screenshot-at-2011-11-06-231619.png"><img src="http://lenss.nl/wp-content/uploads/2011/11/Screenshot-at-2011-11-06-231619-300x93.png" alt="" title="Screenshot at 2011-11-06 23:16:19" width="300" height="93" class="alignright size-medium wp-image-1368" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://lenss.nl/2011/11/ubuntu-11-10-issues-after-fresh-install/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Lack of better content</title>
		<link>http://lenss.nl/2011/10/lack-of-better-content/</link>
		<comments>http://lenss.nl/2011/10/lack-of-better-content/#comments</comments>
		<pubDate>Sat, 08 Oct 2011 09:58:14 +0000</pubDate>
		<dc:creator>Thijs Lensselink</dc:creator>
				<category><![CDATA[/home]]></category>
		<category><![CDATA[SparkleBunnies of Doom]]></category>
		<category><![CDATA[WoW]]></category>

		<guid isPermaLink="false">http://lenss.nl/?p=1347</guid>
		<description><![CDATA[Just something funny for a change ;)]]></description>
			<content:encoded><![CDATA[<p>Just something funny for a change ;)</p>
<p><a href="http://lenss.nl/wp-content/uploads/2011/10/Screenshot.png"><img src="http://lenss.nl/wp-content/uploads/2011/10/Screenshot-300x235.png" alt="" title="Screenshot" width="300" height="235" class="alignright size-medium wp-image-1346" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://lenss.nl/2011/10/lack-of-better-content/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The current state of SSL And The Future Of Authenticity</title>
		<link>http://lenss.nl/2011/09/the-current-state-of-ssl-and-the-future-of-authenticity/</link>
		<comments>http://lenss.nl/2011/09/the-current-state-of-ssl-and-the-future-of-authenticity/#comments</comments>
		<pubDate>Sun, 11 Sep 2011 23:13:33 +0000</pubDate>
		<dc:creator>Thijs Lensselink</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[CA]]></category>
		<category><![CDATA[certificate]]></category>
		<category><![CDATA[Convergence]]></category>
		<category><![CDATA[MITM]]></category>
		<category><![CDATA[notary]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://lenss.nl/?p=1333</guid>
		<description><![CDATA[Last week i had a blast while listening to Moxie Marlinspike&#8217;s Blackhat talk the past and future of SSL. The video is an absolute must see if you have any concern about the current state of SSL or the whole web for that matter. As many know. There has been quite the turmoil in the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://convergence.io/"><img src="http://lenss.nl/wp-content/uploads/2011/09/convergence.png" alt="" title="convergence" width="291" height="66" class="alignleft size-full wp-image-1338" style="float:left;margin:10px;" /></a> Last week i had a blast while listening to <a href="http://www.thoughtcrime.org/">Moxie Marlinspike&#8217;s</a> Blackhat talk <a href="http://www.youtube.com/watch?v=Z7Wl2FW2TcA">the past and future of SSL</a>. The video is an absolute must see if you have any concern about the current state of SSL or the whole web for that matter.</p>
<p>As many know. There has been quite the turmoil in the SSL world lately with some big CA&#8217;s (<a href="http://www.comodo.com">Comodo</a>, <a href="http://www.startcom.org/">StartCom</a>, <a href="http://www.diginotar.com/">Diginotar</a>, <a href="http://www.globalsign.com/">GlobalSign</a>) getting hacked. And rogue certificates being generated for major domains like microsoft.com, google.com, etc for who knows what type of malicious purpose. The real problem here are the centralized CA&#8217;s. For SSL to work you need to explicitly trust the major CA&#8217;s. And if one gets hacked. Well.. we know the deal by now. And the funny thing is that Moxie mentions in his talk. The whole CA wasn&#8217;t even part of the original SSL protocol. As the creator of SSL said &#8220;It&#8217;s something we through in at the end&#8221;.</p>
<p>But instead of only bashing the CA&#8217;s. Moxie comes with a solution to the problem. In the form of a new protocol <a href="http://convergence.io/">Convergence</a>, Which exists of a client and a server package. The client right now is a simple Firefox extension. And when installed it disables the current CA system in the browser. And will use one or more of the selected notaries instead. It even works with self signed certificates. And the back-end is a modular one. And the standard CA verification can be swapped with for instance <a href="http://www.dnssec.net/">DNSSEC</a> based verification.</p>
<p>There is still a level of trust involved. But you won&#8217;t lay all your trust in one specific CA. Convergence uses notaries. Notaries are anonymous nodes that can be picked at will and can be used to verify the requested certificate. And like i said the notaries are anonymous. No more browser leakage at this point. One of th notaries will act as a bounce node to which a SSL connection is made. All other notaries are contacted through this secure connection.</p>
<p>I am probably not the best person to explain this all. So go ahead and listen/watch <a href="http://www.youtube.com/watch?v=Z7Wl2FW2TcA">Moxie&#8217;s talk</a> and form your own opinion. But i think everybody should install <a href="http://convergence.io/">this</a> Firefox plugin. And forget about the whole CA system. I went ahead and installed a notary node myself. Which can be found <a href="http://lenss.nl/lenssnl.notary">here</a>. More information about setting up a notary node yourself can be found <a href="https://github.com/moxie0/Convergence/wiki/Running-a-Notary">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://lenss.nl/2011/09/the-current-state-of-ssl-and-the-future-of-authenticity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP slow on 32-bit Ubuntu</title>
		<link>http://lenss.nl/2011/09/php-slow-on-32-bit-ubuntu/</link>
		<comments>http://lenss.nl/2011/09/php-slow-on-32-bit-ubuntu/#comments</comments>
		<pubDate>Wed, 07 Sep 2011 11:09:44 +0000</pubDate>
		<dc:creator>Thijs Lensselink</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[32-bit]]></category>
		<category><![CDATA[largefile]]></category>
		<category><![CDATA[slow]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://lenss.nl/?p=1325</guid>
		<description><![CDATA[My last post was about the 32-bit integer issue i was having with PHP. And besides setting up a 64-bit server one of the solutions is to compile PHP with the CFLAGS mentioned in my previous post. Intrigued by the fact that my 32-bit Ubuntu installation did not suffer from the same issue. I started [...]]]></description>
			<content:encoded><![CDATA[<p>My last <a href="http://lenss.nl/2011/08/php5-filesize-limit-on-32-bit-system/">post</a> was about the 32-bit integer issue i was having with PHP. And besides setting up a 64-bit server one of the solutions is to compile PHP with the CFLAGS mentioned in my previous post. </p>
<p>Intrigued by the fact that my 32-bit Ubuntu installation did not suffer from the same issue. I started to read the PHP5 changelog for Ubuntu.</p>
<blockquote><p>
CFLAGS=”-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64″ ./configure</p></blockquote>
<p>But this has a negative side effect. Namely PHP running 50% slower then it should be. And to my surprise Ubuntu applies the CFLAGS above when compiling PHP5 for a 32-bit platform. So that would mean PHP on Ubuntu is always running 50% slower? Well according to <a href="https://bugs.php.net/bug.php?id=45942">this</a> is should be the case. </p>
<p>I downloaded <a href="http://nl.php.net/get/php-5.3.8.tar.gz/from/a/mirror">php-5.3.8</a> from php.net and compiled two versions. One with the CFLAGS set for large files. And one normal without any changes. After that i downloaded the benchmark script from <a href="http://www.php-benchmark-script.com">php-benchmark-script.com</a>. And did a couple of runs on each of the two installs. The results are stunning.</p>
<p><strong>PHP-5.3.8 compiled with large file support:</strong></p>
<blockquote><p>test_math                 : 4.414 sec.<br />
test_stringmanipulation   : 4.968 sec.<br />
test_loops                : 3.529 sec.<br />
test_ifelse               : 2.344 sec.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Total time:               : 15.255 sec.</p></blockquote>
<p><strong>PHP-5.3.8 compiled without large file support:</strong></p>
<blockquote><p>test_math                 : 2.274 sec.<br />
test_stringmanipulation   : 2.286 sec.<br />
test_loops                : 1.619 sec.<br />
test_ifelse               : 1.228 sec.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Total time:               : 7.407 sec.</p></blockquote>
<p>That&#8217;s pretty much a 50% speed decrease. One more thing i tried is adding the &#8216;AC_SYS_LARGEFILE&#8217; macro to configure.in and rebuild the configure script. But this had no effect at all.</p>
<blockquote><p>$ cd php-5.3.8<br />
$ vi configure.in (add AC_SYS_LARGEFILE somewhere)<br />
$ export PHP_AUTOCONF=/usr/share/autoconf2.59<br />
$ ./buildconf &#8211;force</p></blockquote>
<p>I then tried two things. First i build without the CFLAGS. But this didn&#8217;t seem to do much. Then i used the same configure script with the CFLAGS for large file support. But there was no speed increase measurable. </p>
<p>So why would Ubuntu have made the choice to compile PHP with the large file support on a 32-bit platform? Are there really that much developers that work on large files in web / cli applications written in PHP? Enough to sacrifice a 50% speed decrease?</p>
<p>I don&#8217;t really know the answer to that. But i will do my large file processing on 64-bit machines. And will compile PHP from scratch from now on. Until i have upgraded my aging hardware.</p>
]]></content:encoded>
			<wfw:commentRss>http://lenss.nl/2011/09/php-slow-on-32-bit-ubuntu/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP5 filesize limit on 32-bit system</title>
		<link>http://lenss.nl/2011/08/php5-filesize-limit-on-32-bit-system/</link>
		<comments>http://lenss.nl/2011/08/php5-filesize-limit-on-32-bit-system/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 22:38:00 +0000</pubDate>
		<dc:creator>Thijs Lensselink</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[filesize]]></category>
		<category><![CDATA[is_file]]></category>
		<category><![CDATA[limit]]></category>
		<category><![CDATA[workaround]]></category>

		<guid isPermaLink="false">http://lenss.nl/?p=1313</guid>
		<description><![CDATA[So we have a PHP based importer script that does some heavy duty media processing at the office. And i had to import some new media today. But for some reason a couple of files weren&#8217;t picked up without a message. So i cleaned up the upload folder. The only files left were the files [...]]]></description>
			<content:encoded><![CDATA[<p>So we have a PHP based importer script that does some heavy duty media processing at the office. And i had to import some new media today. But for some reason a couple of files weren&#8217;t picked up without a message. So i cleaned up the upload folder. The only files left were the files not being processed. And when i started the importer. The result was.</p>
<blockquote><p>
Importer found (0) files to import!</p></blockquote>
<p>Hmmm. That&#8217;s not right. So i had a look at the code behind the importer. Which basically is a loop using a <a href="http://nl2.php.net/manual/en/class.directoryiterator.php">DirectoryIterator</a> object. And some var_dump calls revealed the issue. For some reason <a href="http://nl2.php.net/manual/en/splfileinfo.isfile.php">->isFile()</a> was returning <em>(false)</em> for regular files. WTF! Let&#8217;s test that on the command line.</p>
<blockquote><p>$ php -r &#8220;var_dump(is_file(&#8216;/some/file.ext&#8217;));&#8221;;<br />
<em>bool(false)</em></p></blockquote>
<p>Ok so we have an issue here. How big are these files really. A inspection revealed they are all over 2GB. Maybe some 32 bit issue? As the platform the code is running on is a 32 bit server. So i asked my colleagues, Googled a bit and read through php.net. To find out that there is an issue with PHP and files larger then 2GB.</p>
<blockquote><p><a href="https://bugs.php.net/bug.php?id=27792">https://bugs.php.net/bug.php?id=27792</a><br />
<a href="https://bugs.php.net/bug.php?id=48886">https://bugs.php.net/bug.php?id=48886</a><br />
<a href="http://nl.php.net/manual/en/function.filesize.php">http://nl.php.net/manual/en/function.filesize.php</a></p></blockquote>
<p>Those however all seem related to filesize. The filesize function manual page even has a note about it. Maybe it&#8217;s related?</p>
<blockquote><p>    <strong>Note:</strong> Because PHP&#8217;s integer type is signed and many platforms use 32bit integers, <strong>filesize() </strong> may return unexpected results for files which are larger than <strong>2GB</strong>. For files between 2GB and 4GB in size this can usually be overcome by using <strong>sprintf(&#8220;%u&#8221;, filesize($file))</strong>. </p></blockquote>
<p>But i can&#8217;t apply that patch on a production server. So i came up with a simple solution for now. I extended the <a href="http://nl2.php.net/manual/en/class.directoryiterator.php">DirectoryIterator</a> class and have overwritten the <em>isFile</em> method. Which works for now (don&#8217;t think this will work on windows).</p>
<pre name="code" class="php">
Class MyDirectoryIterator extends DirectoryIterator {
	public function isFile() {
		return (integer) exec("[ -f {$this->getPathname()} ] &#038;&#038; echo 1 || echo 0");
	}
}
</pre>
<p>Convinced it was a 32 bit issue. I came home later that day. And wanted to try it out on my own desktop. That is a 32 bit system and runs Ubuntu 11.04. To my surprise the result was different then i expected.</p>
<blockquote><p>$ php -r &#8220;var_dump(is_file(&#8216;/some/file.ext&#8217;));&#8221;;<br />
<em>bool(true)</em></p></blockquote>
<p>I used the same files as before. And tested some more big files. But the result was the same. Weird. Let&#8217;s try some other 32 bit machines.</p>
<blockquote><p>Ubuntu 11.04: bool(true)</p>
<p>CentOS release 5.6 (Final): bool(false)<br />
Debian 6.0.2 (squeeze): bool(false)</p></blockquote>
<p>Only my desktop at home seems to have a good result. Ubuntu must have some patch somewhere to fix this issue? To confirm i compiled PHP 5.3.8 from source. And did the same test again on Ubuntu 11.04. And this time it was <em>(false)</em>.</p>
<blockquote><p>$ php -r &#8220;var_dump(is_file(&#8216;/some/file.ext&#8217;));&#8221;;<br />
<em>bool(false)</em></p></blockquote>
<p>I am not really in the mood to search the Ubuntu <a href="http://changelogs.ubuntu.com/changelogs/pool/main/p/php5/">changelog</a>. And for now the work around will do. But i really would like to know what patch is applied to resolve the issue.</p>
<p><strong>[ update ]</strong></p>
<p>While applying the patch for the is_file issue. I was confronted with the fact that way more function calls cause issues. So while waiting for PHP to get patched i had to create some workarounds for the time being.</p>
<p>Getting the filesize:</p>
<pre name="code" class="php">
(integer) exec("stat -c%s {$file->getFilename()}");
</pre>
<p>Calculate a MD5 checksum:</p>
<pre name="code" class="php">
$md5 = exec("md5sum {$file->getFilename()}");
$expl = explode('\t', $md5);
return (string) $expl[0];
</pre>
<p>Calculate the CRC32 checksum:</p>
<pre name="code" class="php">
$hash = exec("cksum {$this->path}");
$expl = explode(' ', $hash);
return $expl[0];
</pre>
<p>Get the modified time:</p>
<pre name="code" class="php">
$stat = explode('.', exec("stat -c%y {$this->path}"));
$timestamp = strtotime($stat[0]);
return $timestamp;
</pre>
<p>Hopefully that will do for now. On a side note the issue is solvable by setting certain <strong>CFLAGS</strong> when compiling PHP. I have no idea what the impact of that will be on the PHP binary. But it does seem to solve the issue. Not sure how one would apply that when PHP is installed from the distro&#8217;s repository though.</p>
<blockquote><p>CFLAGS=&#8221;-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64&#8243; ./configure</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://lenss.nl/2011/08/php5-filesize-limit-on-32-bit-system/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Jquery unrecognized expression error</title>
		<link>http://lenss.nl/2011/08/jquery-unrecognized-expression-error/</link>
		<comments>http://lenss.nl/2011/08/jquery-unrecognized-expression-error/#comments</comments>
		<pubDate>Sat, 20 Aug 2011 10:20:59 +0000</pubDate>
		<dc:creator>Thijs Lensselink</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Jquery]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[bind]]></category>
		<category><![CDATA[click]]></category>
		<category><![CDATA[expression]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://lenss.nl/?p=1308</guid>
		<description><![CDATA[While doing some front end work yesterday. I got trapped by a jQuery issue. Well not JQuery specific. The issue was actually triggered by some other hand crafted code. Every time i would click a link inside my grid view firebug would throw an error. uncaught exception: Syntax error, unrecognized expression: . And the markup [...]]]></description>
			<content:encoded><![CDATA[<p>While doing some front end work yesterday. I got trapped by a <a href="http://jquery.com/">jQuery</a> issue. Well not JQuery specific. The issue was actually triggered by some other hand crafted code. Every time i would click a link inside my grid view firebug would throw an error.</p>
<blockquote><p>uncaught exception: Syntax error, unrecognized expression: .</p></blockquote>
<p>And the markup that triggered the error was</p>
<pre name="code" class="html">
<a href="" class="zipDownload"><span class="icon_zipSmall"></span></a>
</pre>
<p>Nothing wrong there right? And it actually took my quite some time to figure this one out. It would be nice to have a tool that can tell you there are multiple click events assigned to a element? But for now it was just some manual searching and testing.</p>
<p>The issue was caused by an other snippet of Javascript code inside another .js file. This piece of code attached a click event to every div inside a grid td. Which may be a bit to greedy.</p>
<pre name="code" class="javascript">
$('.admin .gridbg tr td span').click(function() {
</pre>
<p>And my link was in a nested td inside the grid. And also contained a span tag. So it was actually firing off two click events. From which one failed. Fixing it after that was easy. Either make the first click binding less greedy. Or change the markup of my second grid. I choose the last one.</p>
<pre name="code" class="html">
<a href="http://lenss.nl" class="zipDownload icon_zipSmall"></a>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://lenss.nl/2011/08/jquery-unrecognized-expression-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP locale dates adventure</title>
		<link>http://lenss.nl/2011/08/php-locale-dates-adventure/</link>
		<comments>http://lenss.nl/2011/08/php-locale-dates-adventure/#comments</comments>
		<pubDate>Mon, 15 Aug 2011 21:54:46 +0000</pubDate>
		<dc:creator>Thijs Lensselink</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[locale]]></category>
		<category><![CDATA[strftime]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://lenss.nl/?p=1295</guid>
		<description><![CDATA[About a week ago i was working on a twitter widget for a website. This required some dates to be displayed in Dutch. And i found out the hard way my knowledge on this has faded away over time. So the code i was working on. Did something like this. $date = date('D M d [...]]]></description>
			<content:encoded><![CDATA[<p>About a week ago i was working on a twitter widget for a website. This required some dates to be displayed in Dutch. And i found out the hard way my knowledge on this has faded away over time.</p>
<p>So the code i was working on. Did something like this.</p>
<pre name="code" class="php">
$date = date('D M d H:i:s Y', strtotime($someVar));
</pre>
<p>My thought was that by setting the correct locale the dates would appear in the correct language. Wrong!</p>
<pre name="code" class="php">
date_default_timezone_set('Europe/Amsterdam');
setlocale(LC_ALL, 'nl_NL.utf8');
</pre>
<p>After a reload i was greeted by the same dates as before. In plain English. Oke no worries. Let&#8217;s see what setlocale returns.</p>
<pre name="code" class="php">
var_dump(setlocale(LC_ALL, 'nl_NL.utf8'));
</pre>
<blockquote><p>
bool(false)</p></blockquote>
<p>That&#8217;s not good. Seems like we are missing some locales on the server. Let&#8217;s check.</p>
<blockquote><p>locale -a</p></blockquote>
<blockquote><p>en_AG<br />
en_AG.utf8<br />
en_AU.utf8<br />
en_BW.utf8<br />
en_CA.utf8<br />
en_DK.utf8<br />
en_GB.utf8<br />
en_HK.utf8<br />
en_IE.utf8<br />
en_IN<br />
en_IN.utf8<br />
en_NG<br />
en_NG.utf8<br />
en_NZ.utf8<br />
en_PH.utf8<br />
en_SG.utf8<br />
en_US.utf8<br />
en_ZA.utf8<br />
en_ZW.utf8<br />
&#8230;</p></blockquote>
<p>And some more output after that. But not the one i am looking for. But thankfully aptitude was kind enough to provide the missing language packages.</p>
<blockquote><p>nl_NL<br />
nl_NL@euro<br />
nl_NL.iso88591<br />
nl_NL.iso885915@euro<br />
nl_NL.utf8</p></blockquote>
<p>So let&#8217;s set the correct locale for this script.</p>
<pre name="code" class="php">
setlocale(LC_ALL, 'nl_NL.utf8');
</pre>
<p>But still no changes. I must be missing something&#8230;.. Let&#8217;s consult the <a href="http://www.php.net/manual/en/function.date.php">manual</a>. The last line in the <strong>examples</strong> section is what i was looking for</p>
<blockquote><p>To format dates in other languages, you should use the <a href="http://www.php.net/manual/en/function.setlocale.php">setlocale()</a> and <a href="http://www.php.net/manual/en/function.strftime.php">strftime()</a> functions instead of date(). </p></blockquote>
<p>Duuh! Completely forgot about <a href="http://www.php.net/manual/en/function.strftime.php">strftime</a>. Let&#8217;s change the code.</p>
<pre name="code" class="php">
strftime('%a %b %d %H:%M:%S %Y', strtotime($somevar));
</pre>
<blockquote><p>ma aug 15 14:55:06 2011</p></blockquote>
<p>Perfect. That did it. </p>
]]></content:encoded>
			<wfw:commentRss>http://lenss.nl/2011/08/php-locale-dates-adventure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
