<?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>Nivas.hr blog &#187; php</title>
	<atom:link href="http://www.nivas.hr/blog/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nivas.hr/blog</link>
	<description>From the Nivas crew to the galaxy of unknown</description>
	<lastBuildDate>Thu, 19 Jan 2012 11:52:42 +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>rim &#8211; PHP Remote Image Library</title>
		<link>http://www.nivas.hr/blog/2012/01/16/rim-php-remote-image-library/</link>
		<comments>http://www.nivas.hr/blog/2012/01/16/rim-php-remote-image-library/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 13:35:47 +0000</pubDate>
		<dc:creator>Matej B.</dc:creator>
				<category><![CDATA[developers journal]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.nivas.hr/blog/?p=2174</guid>
		<description><![CDATA[Working on recent home project I found there is no library in PHP to get dimensions of remote images. So I made rim php library to get type and size of remote images in optimized way. Fork it on github The easiest way of getting a image dimension is by using getimagesize PHP function. It has one great fault when working [...]]]></description>
			<content:encoded><![CDATA[<p>Working on recent home project I found there is no library in PHP to get dimensions of remote images.<br />
So I made <a title="Remote Image Library" href="https://github.com/MatejB/rim" target="_blank">rim php library</a> to get type and size of remote images in optimized way.<span id="more-2174"></span></p>
<p><a href="https://github.com/MatejB/rim" target="_blank"><strong>Fork it on github</strong></a></p>
<p>The easiest way of getting a image dimension is by using <a href="http://php.net/manual/en/function.getimagesize.php" target="_blank">getimagesize</a> PHP function.<br />
It has one great fault when working with remote images, whole image must be downloaded in order for getimagesize to read it's dimensions.<br />
So if you want to find out dimensions of jpeg 2MB in size getimagesize will first download it. There goes bandwidth!</p>
<p><em>Rim downloads only few byes need to determine image type and dimensions.</em><br />
Also if you need to get dimensions of lot's of pictures <em>rim will thread fetch request</em> for further speed increase.</p>
<p>Take a look at this benchmark, fetching image types and sizes of all images on <a href="http://www.amazon.com/gp/new-releases/books/ref=sv_b_2">Hot New Releases in Books</a> at amazon.com:<br />
<img class="alignnone" src="https://github.com/MatejB/rim/raw/master/tests/tests_resources/performance.jpg" alt="" width="480" /></p>
<p>Have fun!</p>
<p>P.S.<br />
Bug reports would be appreciated ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nivas.hr/blog/2012/01/16/rim-php-remote-image-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Payment processing in the region and PayPal integration woes</title>
		<link>http://www.nivas.hr/blog/2011/04/21/payment-processing-in-the-region-and-paypal-integration-woes/</link>
		<comments>http://www.nivas.hr/blog/2011/04/21/payment-processing-in-the-region-and-paypal-integration-woes/#comments</comments>
		<pubDate>Thu, 21 Apr 2011 09:36:44 +0000</pubDate>
		<dc:creator>seven</dc:creator>
				<category><![CDATA[developers journal]]></category>
		<category><![CDATA[nivas]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.nivas.hr/blog/?p=1960</guid>
		<description><![CDATA[From mid March, companies in Croatia can finally receive electronic money transfers via PayPal (read background story in my article published in Nacional). Payment processing isn't something new in Croatia, but PayPal is. On-line stores were able for years to process user credit cards via some of our local popular credit card processing services like [...]]]></description>
			<content:encoded><![CDATA[<p>From mid March, companies in Croatia can finally receive electronic money transfers via PayPal (read background story in my <a href="http://www.nacional.hr/clanak/105965/paypal-dostupan-u-hrvatskoj-unosi-drasticno-promjene-u-svijet-e-trgovine">article published in Nacional</a>).</p>
<p>Payment processing isn't something new in Croatia, but PayPal is. On-line stores were able for years to process user credit cards via some of our local popular credit card processing services like T-Com Pay Way or Webteh - WebPay (or directly through connections with each bank - less popular method). But only recently (a year ago), with arrival of <a href="http://hr.kolektiva.net">Kolektiva</a> and similar sites oriented to wider online consumer public, online payments started to become more popular, widely accepted and less frightened to a regular Joe.</p>
<p>In our e-commerce web development work so far, we had chance to work in close with following regional internet payment service providers:</p>
<ul>
<li><a href="http://www.t-com.hr/poslovni/internet/etrgovina/pay_way.asp">T-Com Pay Way</a> (Croatia)</li>
<li><a href="http://www.webteh.hr/">Webteh - WebPay payment gateway</a> (Croatia)</li>
<li><a href="http://www.pbzcard.hr/hr/online-usluge/prodajna-mjesta/mycheckout">PBZ MyCheckout</a> (Croatia)</li>
<li><a href="http://www.e-services.rs/">EMS</a> (Serbia)</li>
<li><a href="http://www.qvoucher.rs/">qVoucher</a> (Serbia)</li>
<li><a href="http://www.telemach.si/sl/poslovni-uporabniki/e-trgovina/predstavitev">Telemach - EON MegaPOS</a> (Slovenia)</li>
<li>direct connection with various banks in the region</li>
</ul>
<p>And just recently - the <a href="https://www.paypal.com/">PayPal</a>.</p>
<p>No matter PayPal is mature product, integration was not walk in the park. From developers standpoint, I would definitely commend T-Com Pay Way, Webteh and qVoucher services for ease of integration and support they have. In contrast to PayPal's undocumented features (or lack of documentation and examples) or EMS's infinite redirects to 3rd party pages (enforced by other parties) in payment process.</p>
<p><strong>PayPal</strong><br />
After some headache &#038; time spent at the PayPal sandbox (self-contained environment within which you can prototype and test PayPal features and APIs) we finally managed to get it working. </p>
<p>We used widely used HTML way to integrate Website Payments Standard with our shopping cart (please see “<a href="https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&#038;content_ID=developer/e_howto_html_cart_upload">Third-Party Shopping Carts – The Cart Upload Command</a>”) since integration via API has been proven to be more complex and undocumented than Facebook's SDK.</p>
<p>For security we used Encrypted Website Payments (please see “<a href="https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&#038;content_ID=developer/e_howto_html_encryptedwebpayments#id08A3I0P017Q">Protecting Payment Buttons by Using Encrypted Website Payments</a>”.</p>
<p>Encrypted Website Payments relies on <a href="http://en.wikipedia.org/wiki/Public-key_cryptography">public-key cryptography</a> using <a href="http://www.openssl.org/">OpenSSL</a> which is available  both as external program that can be executed from PHP and as php extension. Prepare to enter world of pain with this one, since most of examples use executable file to do actual encoding.</p>
<p>Using  OpenSSL as extension with PayPal is not straightforward, best example can be found at <a href="https://www.x.com/community/ppx/sdks">PayPal SDK</a> in <a href="https://cms.paypal.com/cms_content/US/en_US/files/developer/PP_PHP_WPS_Toolkit.zip">php toolkit</a>.</p>
<p>We implemented support for both IPN and PDT notifications:</p>
<ul>
<li>PDT (Payment Data Transfer) – is secure method to retrieve details about PayPal transaction after (and if) user chooses to return to our site after paying on the PayPal.  It should be used only to display information to the user. Our system is not depending on it since there is no guarantee that this action will be executed.</li>
<li>IPN(Instant Payment Notification) – is direct PayPal to our system communication.  In order to verify authenticity of IPN data received from PayPal should be checked and then sent back to PayPal in exact order it was received. PayPal should respond with “VERIFIED”. </li>
</ul>
<p>Please note that although PayPal send newline as CR+LF (%0D%0A), PHP returns these new lines as LF (%0A) – so, newlines transformed by PHP into LF must be replaced with CR+LF before data is sent back to PayPal. This bug can easily be reproduced if you enter both Address line 1 and Address line 2 during payment, because those two lines PayPal combines into one field separated with CR+LF.</p>
<p>You can try all all this, or you can just <a href="http://www.nivas.hr/en/contact">contact us</a> for consulting and/or implementation services. :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nivas.hr/blog/2011/04/21/payment-processing-in-the-region-and-paypal-integration-woes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Will Internet Explorer 6 finally die on August 31, 2009?</title>
		<link>http://www.nivas.hr/blog/2009/06/04/will-internet-explorer-6-finally-die-on-august-31-2009/</link>
		<comments>http://www.nivas.hr/blog/2009/06/04/will-internet-explorer-6-finally-die-on-august-31-2009/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 13:50:28 +0000</pubDate>
		<dc:creator>seven</dc:creator>
				<category><![CDATA[developers journal]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.nivas.hr/blog/?p=1208</guid>
		<description><![CDATA[We have been using very strange setups here at the office to test sites on Internet Explorer 6. Lot's of us still use Windows XP, and some of us still had default Internet Explorer 6 on our computers. When IE8 was released, we didn't upgrade immidiately so we could still test sites in default IE6 [...]]]></description>
			<content:encoded><![CDATA[<p>We have been using very strange setups here at the office to test sites on Internet Explorer 6. Lot's of us still use Windows XP, and some of us still had default Internet Explorer 6 on our computers. When IE8 was released, we didn't upgrade  immidiately so we could still test sites in default IE6 installations (lots of different fake/multi IE setups throw most bizzare errors, so testing under default IE installation was a must).</p>
<p>But couple of days ago we finally give in to the dark forces of Windows Auto update, and we upgraded to Internet Explorer 8. </p>
<p>The only correct way now for site testing under different Internet Explorer versions is by using virtual machine of some sort. Vmware is option, but you have to build your own virtual setup which can be a pain. However, Microsoft has been good enough to finally provide developers with <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=21EABB90-958F-4B64-B5F1-73D0A413C8EF&#038;displaylang=en">Internet Explorer Application Compatibility VPC Images</a> for their <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=21EABB90-958F-4B64-B5F1-73D0A413C8EF&#038;displaylang=en">Virtual PC</a>.  You can download completely free, perfectly legal and working images of followign operating systems packed with IE's:</p>
<ul>
<li>Windows XP SP3 with IE6, </li>
<li>Windows XP SP3 with IE7, </li>
<li>Windows XP SP3 with IE8, </li>
<li>Vista with IE7 and  </li>
<li>Vista with IE8.</li>
</ul>
<p>All XP images will expire on August 31, 2009, which is the end-of-life for good old Windows XP, and hopefully end-of-life of Internet Explorer 6. Hello Windows Seven! :) (Btw, I've tried RC1 of Windows Seven and it ROCKS, not only because of the name).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nivas.hr/blog/2009/06/04/will-internet-explorer-6-finally-die-on-august-31-2009/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>View source crashes Firefox v3.0.9</title>
		<link>http://www.nivas.hr/blog/2009/04/24/view-source-crashes-firefox-v309/</link>
		<comments>http://www.nivas.hr/blog/2009/04/24/view-source-crashes-firefox-v309/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 14:50:05 +0000</pubDate>
		<dc:creator>seven</dc:creator>
				<category><![CDATA[developers journal]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.nivas.hr/blog/?p=1069</guid>
		<description><![CDATA[Since I updated FF to 3.0.9 (on Win XP), view source doesn't work. Even "firefox -safe-mode" crashes browser every time. Thank you Mozilla Html Validator plugin! Hope 10.000 error reports I sent will help you. update 27-04-2009: Yes, my friends were right. Html Validator plugin was causing this. After updating to v0.8.5.6 problem gone. And [...]]]></description>
			<content:encoded><![CDATA[<p>Since I updated FF to 3.0.9 (on Win XP), view source doesn't work. Even "firefox -safe-mode" crashes browser every time. Thank you <del datetime="2009-04-27T13:18:47+00:00">Mozilla</del> Html Validator plugin! Hope 10.000 error reports I sent will help you.</p>
<p><strong>update 27-04-2009:</strong> Yes, my friends were right. Html Validator plugin was causing this. After updating to v0.8.5.6 problem gone. And note to FireFox plugin developers - please <strong>DON'T</strong> put this in install.rdf without being completely sure that your plugin won't break anything (maybe 10% of plugins can do this):<br />
<code>&lt;em:maxVersion&gt;3.0.*&lt;/em:maxVersion&gt;</code> </p>
<p><img src="http://www.nivas.hr/blog/wp-content/uploads/2009/04/fferror.png" alt="fferror" title="fferror" width="378" height="387" class="alignnone size-full wp-image-1070" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nivas.hr/blog/2009/04/24/view-source-crashes-firefox-v309/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>goto</title>
		<link>http://www.nivas.hr/blog/2009/04/22/goto/</link>
		<comments>http://www.nivas.hr/blog/2009/04/22/goto/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 20:04:12 +0000</pubDate>
		<dc:creator>seven</dc:creator>
				<category><![CDATA[developers journal]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.nivas.hr/blog/?p=1061</guid>
		<description><![CDATA[Ha! I completely missed new function implemented in php 5.3 - old'skool "goto"! :) I am not particularly happy. Not happy at all. Outputs: Bar]]></description>
			<content:encoded><![CDATA[<p>Ha! I completely missed new function implemented in php 5.3 - old'skool "<a href="http://www.php.net/manual/en/control-structures.goto.php">goto</a>"! :) I am not particularly happy. Not happy at all.<br />
<div id="ftf-1061-0" style="width: 490px; height: 150px;overflow:auto;"><pre></pre></div>
		
			<script type="text/javascript">
			// <![CDATA[
			var swf = new SWFObject("http://www.nivas.hr/blog/wp-content/plugins/FlashTextFormatter/ftf_wp.swf", "ftf_swf-1061-0", "486", "146", "6");
			swf.addParam("quality", "high");
			swf.addParam("scale", "noscale");
			swf.addParam("bgcolor", "#ffffff");
			swf.addParam("flashvars", "w=490&h=150&file=http://www.nivas.hr/blog/index.php&ftf=true&postID=1061&no=0&def=http://www.nivas.hr/blog/wp-content/plugins/FlashTextFormatter/definitions/as2.xml&auto=true&");
			swf.write("ftf-1061-0");
			// ]]&gt;</script>Outputs: Bar</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nivas.hr/blog/2009/04/22/goto/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Online tickets for U2 concert in Zagreb = fail</title>
		<link>http://www.nivas.hr/blog/2009/03/27/online-tickets-for-u2-concert-in-zagreb-fail/</link>
		<comments>http://www.nivas.hr/blog/2009/03/27/online-tickets-for-u2-concert-in-zagreb-fail/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 23:34:59 +0000</pubDate>
		<dc:creator>seven</dc:creator>
				<category><![CDATA[developers journal]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://www.nivas.hr/blog/?p=948</guid>
		<description><![CDATA[U2 is (aside from Lepa Brena) - the most anticipated concert of the year in Croatia. Marketing campaign was pretty strong (so I guess organizers invested some money) and commercials strongly advertised online ticket sale which started just couple of minutes ago (at 00:01AM). Unfortunately for U2 fans, online ticket sales maybe did start, but [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.u2.com/">U2</a> is (aside from <a href="http://en.wikipedia.org/wiki/Lepa_Brena">Lepa Brena</a>) - the most anticipated concert of the year in Croatia. Marketing campaign was pretty strong (so I guess organizers invested some money) and commercials strongly advertised online ticket sale which started just couple of minutes ago (at 00:01AM).</p>
<p><img src="http://www.nivas.hr/blog/wp-content/uploads/2009/03/u2concert.jpg" alt="u2concert" title="u2concert" width="450" height="278" class="alignnone size-full wp-image-951" /></p>
<p>Unfortunately for U2 fans, online ticket sales maybe did start, but they sure did end pretty fast. But not because web shop run out of tickets, but because web shop and organizers of the concert ran out of professionalism. </p>
<p>Look guys, if you decided to run <strong>so strong</strong> advertising campaign across couple of countries which loudly and clearly says: "Ticket sales start online on Friday at 00:01", I suppose one who does all that, would also build a website which can sustain such number of customers? </p>
<p>Well, I guess not. </p>
<p>Exactly the same thing happened some time ago when Croatian Football Association launched online reservation of world cup tickets (if I can recall correctly). I am not big sports fan but many of my friends are and they were very pissed. </p>
<p>Servers are so dirty cheap, and downtime <strong>costs a lot</strong> of money (nerves, reputation...), Especially if downtime happens a minute you launch your service. My personal preference/advice regarding server configuration in time of special events or service launch is - tend to over engineer your network! EC2, EBS, S3 (<a href="http://en.wikipedia.org/wiki/Amazon_Web_Services">Amazon Web services</a>) and other cloud computing solutions do their job pretty good in situations like this.</p>
<p>Otherwise you get this beauty...<br />
<img src="http://www.nivas.hr/blog/wp-content/uploads/2009/03/serviceunavailable-450x246.jpg" alt="serviceunavailable" title="serviceunavailable" width="450" height="246" class="alignnone size-medium wp-image-947" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nivas.hr/blog/2009/03/27/online-tickets-for-u2-concert-in-zagreb-fail/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Letter Đ mistery &#8211; Ð!=Đ and ð != đ</title>
		<link>http://www.nivas.hr/blog/2008/10/27/letter-d-mistery-%c3%b0d-and-%c3%b0-d/</link>
		<comments>http://www.nivas.hr/blog/2008/10/27/letter-d-mistery-%c3%b0d-and-%c3%b0-d/#comments</comments>
		<pubDate>Mon, 27 Oct 2008 14:14:09 +0000</pubDate>
		<dc:creator>seven</dc:creator>
				<category><![CDATA[developers journal]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://www.nivas.hr/blog/?p=652</guid>
		<description><![CDATA[We spent couple of hours trying to figure out this one, so we decided to share it with our fellow readers and hopefully, save some time and unnecessary stress for them. UTF-8 is defacto standard encoding for multilanguage websites. PHP5 doesn't have native support for it, but you can integrate it. MYSQL supports utf8, but [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.nivas.hr/blog/wp-content/uploads/2008/10/djdj.png" alt="" title="djdj" width="250" height="210" class="alignright size-full wp-image-678" align="right" border="5" />We spent couple of hours trying to figure out this one, so we decided to share it with our fellow readers and hopefully, save some time and unnecessary stress for them. UTF-8 is defacto standard encoding for multilanguage websites. PHP5 doesn't have native support for it, but you can integrate it. MYSQL supports utf8, but not utf8_croatian_collation. But you can also hack your way around that for sorting. If you are not dealing with Croatian letters and UTF-8, you probably won't encounter this problem. However, if you ARE using UTF-8 read on!</p>
<p>We are redesigning one large website and naturally, some content from old website has to be migrated to new site. Since we don't have access to their database, we have to manually copy content from old website's HTML source. Client's old site is in UTF-8. Imagine following entry in old HTML source:<br />
<div id="ftf-652-0" style="width: 480px; height: 105px;overflow:auto;"><pre>
&#208;akovo
...
</pre></div>
		
			<script type="text/javascript">
			// <![CDATA[
			var swf = new SWFObject("http://www.nivas.hr/blog/wp-content/plugins/FlashTextFormatter/ftf_wp.swf", "ftf_swf-652-0", "476", "101", "6");
			swf.addParam("quality", "high");
			swf.addParam("scale", "noscale");
			swf.addParam("bgcolor", "#ffffff");
			swf.addParam("flashvars", "w=480&h=105&file=http://www.nivas.hr/blog/index.php&ftf=true&postID=652&no=0&def=http://www.nivas.hr/blog/wp-content/plugins/FlashTextFormatter/definitions/as2.xml&auto=true&");
			swf.write("ftf-652-0");
			// ]]&gt;</script><br />
This is a select tag with list of cities in Croatia, the city in example is <a href="http://en.wikipedia.org/wiki/%C4%90akovo">Đakovo</a>. So as I said, we are copy-ing large amounts of data from old HTML's, and we do not care why old site displays this city as <strong>"&amp;#208;akovo"</strong> and not as <strong>"Đakovo"</strong>. After we pasted "Ðakovo" into our engine, we momentarily started to get all sorts of different errors. The most bizare one was comming from our utf8_strtolower function which had to return string <strong>"đakovo"</strong>. Instead it was returning string <strong>"ðakovo"</strong>. Wicked! </p>
<p>After some digging, we found out that there was nothing wrong with our utf8 php methods nor our mysql database. We found out that the letter Ð (hex d0 00) we pasted from HTML was just not the letter Đ (hex 10 01)  we needed. Somebody (or something) very brilliant, used letter <a href="http://en.wikipedia.org/wiki/Eth">Eth</a> instead of standard Croatian letter <a href="http://en.wikipedia.org/wiki/D_with_stroke">D with stroke</a>.</p>
<p>Eth (Ð, ð; also spelled edh or eð) is a letter used in Old English, Icelandic, Faroese (in which it is called edd). In the Unicode universal character encoding standard, upper and lower case eth are represented by U+00D0 and U+00F0. These code points are inherited from the older ISO 8859-1 standard. In HTML, eth is represented by the Latin character entities &ETH; and &eth;.</p>
<p>Đ (lowercase đ) is a letter of the Latin alphabet, formed from D with the addition of a bar or stroke through the letter. This is the same modification that was used to create eth (ð), but eth is based on an insular variant of d while đ is based on its usual upright shape. In Unicode the letter is represented as U+0110 LATIN CAPITAL LETTER D WITH STROKE and U+0111 LATIN SMALL LETTER D WITH STROKE.</p>
<p>So there you have it. No matter the letters look the same, beware what you copy/paste. :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nivas.hr/blog/2008/10/27/letter-d-mistery-%c3%b0d-and-%c3%b0-d/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>We got Super Mario</title>
		<link>http://www.nivas.hr/blog/2008/06/27/we-got-super-mario/</link>
		<comments>http://www.nivas.hr/blog/2008/06/27/we-got-super-mario/#comments</comments>
		<pubDate>Fri, 27 Jun 2008 14:54:44 +0000</pubDate>
		<dc:creator>Daemon</dc:creator>
				<category><![CDATA[developers journal]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.nivas.hr/blog/?p=334</guid>
		<description><![CDATA[So anyways, it is bleedin' hot outside, therefore, logical conclusion is that I should make Super Mario out of Post-It papers on the wall. Check it: It really looks awesome in our chill out ... sorry, I mean, in our conference room. So how are you spending your hot hot hot summer days?]]></description>
			<content:encoded><![CDATA[<p>So anyways, it is bleedin' hot outside, therefore, logical conclusion is that I should make Super Mario out of Post-It papers on the wall. Check it:</p>
<p><img src="http://www.nivas.hr/pub/blog-images/mario1.jpg" alt="Super Mario" /></p>
<p>It really looks awesome in our chill out ... sorry, I mean, in our conference room.<br />
<img src="http://www.nivas.hr/pub/blog-images/mario2.jpg" alt="Super Mario" /></p>
<p>So how are you spending your hot hot hot summer days?</p>
<table border=0>
<tr>
<td>
<script>
digg_url = 'http://digg.com/design/DIY_Super_Mario_wall_decoration_made_of_12x17_Post_It_papers';
</script><br />
<script src="http://digg.com/api/diggthis.js"></script>
</td>
<td>
<script type="text/javascript">
croportal_url = 'http://www.croportal.net/racunalne-igre/Sam_svoj_majstor_Super_Mario_zidni_ukras_od_Post_Ita-156805';
</script><br />
<script src="http://www.croportal.net/assets/js/croportal.js" type="text/javascript"></script>
</td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.nivas.hr/blog/2008/06/27/we-got-super-mario/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How HRT failed in their intention to become Croatian BBC</title>
		<link>http://www.nivas.hr/blog/2008/05/17/how-hrt-failed-in-their-intention-to-become-croatian-bbc/</link>
		<comments>http://www.nivas.hr/blog/2008/05/17/how-hrt-failed-in-their-intention-to-become-croatian-bbc/#comments</comments>
		<pubDate>Sat, 17 May 2008 10:08:06 +0000</pubDate>
		<dc:creator>seven</dc:creator>
				<category><![CDATA[developers journal]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.nivas.hr/blog/?p=303</guid>
		<description><![CDATA[This one goes to all our foreign readers which would otherwise probably be left out from knowing news of the week in Croatia - Croatian National Television (HRT.hr) bluntly copied British Broadcasting Corporation (BBC.co.uk) website! The shit hit the fan few days ago and whole Croatian web community got pretty pissed off. HRT spokesman said [...]]]></description>
			<content:encoded><![CDATA[<p>This one goes to all our foreign readers which would otherwise probably be left out from knowing news of the week in Croatia - Croatian National Television (<a href="http://www.hrt.hr">HRT.hr</a>) bluntly copied British Broadcasting Corporation (<a href="http://www.bbc.co.uk">BBC.co.uk</a>) website!</p>
<p>The shit hit the fan few days ago and whole Croatian web community got pretty pissed off. HRT spokesman said (in defence to accusations of stealing BBC's design) that HRT wishes to be Croatian BBC, and ok - I absolutely respect that. I also respect their understanding for the need to redesign the site. <a href="http://web.archive.org/web/20070202022730rn_1/www.hrt.hr/index.xml">The old HRT.hr website</a> was 8-10 years old and not something to look at.</p>
<p>But lets get one thing straight - <strong>I totally and absolutely disrespect the method of execution</strong> of their intentions. Whoever did the production of this monstrosity lacks the proper knowledge and experience... 10 years of experience in web development field at least.</p>
<p>Client is always right, but clients are not web designers (no matter how bad they would want it to be), and our sole professional and moral obligation is to notify client of possible breach in copyright laws, breach in functionality or any kind of possible side-effect that some of their ideas could do to harm the project, harm them self or harm web developers reputation. </p>
<p>Not once, but every time, we ask client - which websites do they like, who are their competitors, who is their role model in business... And based on our previous <strong>experience, knowledge, research, strategic planning and comprehensive user tests - we produce results</strong>. Results which are <strong>specially suited for our client</strong>. Not fake copy of website they wish to have. </p>
<p>As our friend <a href="http://www.maratz.com/">Maratz</a> nicely wrote, and I couldn't agree with him more: "This is <em>the</em> embarrassment of the decade for the Croatian web community.".</p>
<p>Compare and cry (tm):<br />
<img src="http://www.nivas.hr/blog/wp-content/uploads/2008/05/hrt-vs-bbc-03.jpg" alt="" title="hrt-vs-bbc-03" width="450" height="213" class="alignnone size-full wp-image-305" /></p>
<p>More voices:</p>
<ul>
<li><a href="http://google.com/translate?u=http://www.mi3dot.org/forum/viewtopic.php?p=130688&#038;sl=hr&#038;tl=en">http://www.mi3dot.org/forum/</a></li>
<li><a href="http://www.maratz.com/blog/archives/2008/05/15/croatian-hrt-rips-off-bbccouk/">http://www.maratz.com/blog/archives/2008/05/15/croatian-hrt-rips-off-bbccouk/</a><br />
<a href="http://zytzagoo.net/blog/2008/05/15/hrt-vs-bbc/">http://zytzagoo.net/blog/2008/05/15/hrt-vs-bbc/</a></li>
<li><a href="http://mcville.net/journal/archives/30">http://mcville.net/journal/archives/30</a></li>
<li><a href="http://marketingservis.com/internet/hrt-hr-i-bbc-co-uk/">http://marketingservis.com/internet/hrt-hr-i-bbc-co-uk/</a></li>
<li><a href="http://www.index.hr/vijesti/clanak/iz-koda-hrtove-stranice-najednom-nestalo-ime-tvrtke-koja-ju-je-radila/386937.aspx">http://www.index.hr/vijesti/clanak/iz-koda-hrtove-stranice-najednom-nestalo-ime-tvrtke-koja-ju-je-radila/386937.aspx</a></li>
<li><a href="http://www.delo.si/index.php?sv_path=41,790,296704">http://www.delo.si/index.php?sv_path=41,790,296704</a></li>
<li><a href="http://regionalexpress.hr/site/more/puleani-kreirali-web-hrt-a/">http://regionalexpress.hr/site/more/puleani-kreirali-web-hrt-a/</a></li>
</ul>
<p><strong>Updated 20.05.</strong> - Big up to our comrades in arms at BBC. And thanks to <a href="http://www.bbc.co.uk/blogs/bbcinternet/2008/05/iplayer_bafta_on_tour.html">Alan Connor</a> (co-editor of <a href="http://www.bbc.co.uk/blogs/bbcinternet/">BBC Internet Blog</a>) who linked to my article, and hey I really don't know how I missed this beauty - <a href="http://www.rtl.hu/">http://www.rtl.hu/</a>. It seems that BBC was true inspiration for many "web designers". But, RTL.hu is light AGES ahead of HRT.hr. Whoever did the job, they did it well. There is just a small we-copied-bbc-design fact... but hey. :) </p>
]]></content:encoded>
			<wfw:commentRss>http://www.nivas.hr/blog/2008/05/17/how-hrt-failed-in-their-intention-to-become-croatian-bbc/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>mysql utf8 latin2 utf8 weirdness</title>
		<link>http://www.nivas.hr/blog/2007/09/10/mysql-utf8-latin2-utf8-weirdness/</link>
		<comments>http://www.nivas.hr/blog/2007/09/10/mysql-utf8-latin2-utf8-weirdness/#comments</comments>
		<pubDate>Mon, 10 Sep 2007 18:44:58 +0000</pubDate>
		<dc:creator>seven</dc:creator>
				<category><![CDATA[developers journal]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.nivas.hr/blog/2007/09/10/mysql-utf8-latin2-utf8-weirdness/</guid>
		<description><![CDATA[This one is a keeper, have to write it down somewhere in case I forget it by tomorrow morning. :) Today I was doing routine deploy of one of our new websites to production server. Everything went smoothly, except the fact I couldn't see any of Croatian letters on the site texts (which were stored [...]]]></description>
			<content:encoded><![CDATA[<p>This one is a keeper, have to write it down somewhere in case I forget it by tomorrow morning. :) Today I was doing routine deploy of one of our new websites to production server. Everything went smoothly, except the fact I couldn't see any of Croatian letters on the site texts (which were stored in mysql)!! We did migration to UTF8 some time ago, and this was highly unexpected. So I started to dig into the dump. :)</p>
<p>Looking at the mysqldump of a database I was a bit surprised to see Croatian letters screwed up beyond recognition. For example letter "š" was represented as "ÄąÄO„" (4 bytes), "č" was "ÄO" (two bytes)... etc. OMG! All our tables are "CHARSET=utf8", we force "AddDefaultCharset utf-8" in Apache and all of our markup uses "charset=utf-8" for content type encoding. BUT, we unintentionally left one very bad call in our config file which got triggered if site was running on development server - "SET NAMES 'latin2' COLLATE 'latin2_croatian_ci". The production config had SET NAMES utf8, but development didn't. Oh boy. </p>
<p>Ok so now I had a real mess - utf8 tables with utf8 data in them stored as re-encoded latin2 but in utf8!? I tried converting the dump from ISO8859-2 to UTF8 but that just made things worse, some of characters now used 6 bytes which isn't good. The solution was pretty straight forward. I converted the dump from UTF8 to ISO-8859-2 and I got real UTF8 again. I imported the converted dump and changed for good config files to "SET NAMES 'utf8' COLLATE 'utf8_general_ci".<br />
iconv to the rescue:</p>
<p><div id="ftf-215-0" style="width: 400px; height: 150px;overflow:auto;"><pre>
mysqldump -u root -p db > weirdo-dump.sql
iconv -f UTF-8 -t ISO_8859-2//TRANSLIT weirdo-dump.sql > dump-latin2-aka-realUTF8.sql
mysql -u root -p db < dump-latin2-aka-realUTF8.sql</pre></div>
		
			<script type="text/javascript">
			// <![CDATA[
			var swf = new SWFObject("http://www.nivas.hr/blog/wp-content/plugins/FlashTextFormatter/ftf_wp.swf", "ftf_swf-215-0", "396", "146", "6");
			swf.addParam("quality", "high");
			swf.addParam("scale", "noscale");
			swf.addParam("bgcolor", "#ffffff");
			swf.addParam("flashvars", "w=400&h=150&file=http://www.nivas.hr/blog/index.php&ftf=true&postID=215&no=0&def=http://www.nivas.hr/blog/wp-content/plugins/FlashTextFormatter/definitions/as2.xml&auto=true&");
			swf.write("ftf-215-0");
			// ]]&gt;</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nivas.hr/blog/2007/09/10/mysql-utf8-latin2-utf8-weirdness/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PHP4 must die!</title>
		<link>http://www.nivas.hr/blog/2007/09/10/php4-must-die/</link>
		<comments>http://www.nivas.hr/blog/2007/09/10/php4-must-die/#comments</comments>
		<pubDate>Mon, 10 Sep 2007 02:28:45 +0000</pubDate>
		<dc:creator>seven</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.nivas.hr/blog/2007/09/10/php4-must-die/</guid>
		<description><![CDATA[Harsh as it may sound, lately the web is full of headlines like that. Why, why!? Mass panic mode activated! What does it all mean?? The end of PHP as we know it? The PHP development team finally announced end of life for PHP4. After 2007-12-31 there will be no more releases of PHP 4, [...]]]></description>
			<content:encoded><![CDATA[<p>Harsh as it may sound, lately the web is full of headlines like that. Why, why!? Mass panic mode activated! What does it all mean?? The end of PHP as we know it?</p>
<p>The PHP development team finally announced end of life for PHP4. After 2007-12-31 there will be no more releases of PHP 4, and critical security fixes will be available until 2008-08-08. After that, you are running php4 on your own risk, and we all know how risky the business Internet is. Do you still have Windows NT 4.0 or RedHat 7.1 on your servers? Are they developed or supported? No! </p>
<p>It was about a damn time they let go php4. PHP5 has been available for 3 years, and hosting companies have had plenty of time to make the switch. From developer standpoint I have absolutely no sympathy for those who have left it until the last minute, and even then needed to be pushed. I understand the problem they have - they didn't realize the importance of php5. And now gazillion of php3/4 sites (which make a large majority of php users) have to be "upgraded". What will happen to them? PHP dev. team could avoid this hassle, by just plotting the php's development road map better, and being more direct with timelines. They are still doing it wrong, since they are killing php4, and not giving enough info on forthcoming PHP6.</p>
<p>Our migration was also being dictated by hosting company. We asked our provider for php5 in the beginning of 2006, and begged, and cursed and then asked polite again and some time in January this year, we just couldn't take any more of that bullshit and switched to php5. How hard was to migrate lots of messy code from php4 to php5? We did migration surprisingly fast and painless for many of our old projects. If you had error_reporting set to E_ALL durring development in php4, haven't used register_globals or magic quotes, you should be just fine. And we introduced new PHP5 OOP stuff to our new projects immediately. All in all, PHP5.2 is now what php4 had to be back then, and I am keeping my hopes high for PHP6.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nivas.hr/blog/2007/09/10/php4-must-die/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some geeky statistics</title>
		<link>http://www.nivas.hr/blog/2007/09/06/some-geeky-statistics/</link>
		<comments>http://www.nivas.hr/blog/2007/09/06/some-geeky-statistics/#comments</comments>
		<pubDate>Thu, 06 Sep 2007 00:59:16 +0000</pubDate>
		<dc:creator>seven</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.nivas.hr/blog/2007/09/06/some-geeky-statistics/</guid>
		<description><![CDATA[If you don't have a life anymore (like me), you will probably find these statistics/penetration reports interesting. :) Flash 9 is kicking, together with php5 and Apache. That's all I wanted to hear. Read on! Adobe Flash Player Version Penetration PHP usage statistics for October 2007 PHP stats evolution for August 2007 Programming Community Index [...]]]></description>
			<content:encoded><![CDATA[<p>If you don't have a life anymore (like me), you will probably find these statistics/penetration reports interesting. :) Flash 9 is kicking, together with php5 and Apache. That's all I wanted to hear. Read on! </p>
<ul>
<li><a href="http://www.adobe.com/products/player_census/flashplayer/version_penetration.html">Adobe Flash Player Version Penetration</a></li>
<li><a href="http://www.nexen.net/chiffres_cles/phpversion/17504-php_statistics_for_august_2007.php">PHP usage statistics for October 2007</a></li>
<li><a href="http://www.nexen.net/chiffres_cles/phpversion/17507-php_stats_evolution_for_august_2007.php">PHP stats evolution for August 2007</a></li>
<li><a href="http://www.tiobe.com/tpci.htm">Programming Community Index for September 2007</a></li>
<li><a href="http://www.securityspace.com/s_survey/data/man.200708/cookieReport.html">Usage of the Cookies on the Internet</a></li>
</ul>
<p>Php5 finally gained some points, probably because Zend announced php4's end of life. That should happen years ago. :) Too bad Php6 release date isn't scheduled yet. </p>
<p>Netcraft's last report says that Windows IIS takes 34.2% and Apache 48.4% of market share. Microsoft's recent gains raise the prospect that Windows may soon challenge Apache's leadership position. Apache has been the leading web server software since the March 1996 Netcraft Web Server Survey. In November 2005, Apache was found on 71 percent of web sites. It's worth noting that Apache has lost market share to another open source server, lighttpd (1.2% of all sites), and Google (4.4%) as well as Windows. But if Microsoft continues to gain share at its current pace, it could close the gap on Apache sometime in 2008.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nivas.hr/blog/2007/09/06/some-geeky-statistics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mysql + google</title>
		<link>http://www.nivas.hr/blog/2007/04/25/mysql-google/</link>
		<comments>http://www.nivas.hr/blog/2007/04/25/mysql-google/#comments</comments>
		<pubDate>Wed, 25 Apr 2007 16:40:57 +0000</pubDate>
		<dc:creator>seven</dc:creator>
				<category><![CDATA[developers journal]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.nivas.hr/blog/2007/04/25/mysql-google/</guid>
		<description><![CDATA[A recent post on the Google Developer Blog announces some enhancements Google's made to MySQL, in hopes that they will be adopted in the next release, and to allow everyone to begin using them. At the moment, patches are available for mysql v4.x only. DO-h!]]></description>
			<content:encoded><![CDATA[<p>A recent <a href="http://google-code-updates.blogspot.com/2007/04/google-releases-patches-that-enhance.html">post on the Google Developer Blog</a> announces some enhancements Google's made to MySQL, in hopes that they will be adopted in the next release, and to allow everyone to begin using them. At the moment, <a href ="http://code.google.com/p/google-mysql-tools/">patches</a> are available for mysql v4.x only. DO-h! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.nivas.hr/blog/2007/04/25/mysql-google/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP Optimization Tips &#8211; The Balkan way!</title>
		<link>http://www.nivas.hr/blog/2007/03/31/php-optimization-tips-the-balkan-way/</link>
		<comments>http://www.nivas.hr/blog/2007/03/31/php-optimization-tips-the-balkan-way/#comments</comments>
		<pubDate>Sat, 31 Mar 2007 15:06:38 +0000</pubDate>
		<dc:creator>seven</dc:creator>
				<category><![CDATA[developers journal]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.nivas.hr/blog/2007/03/31/php-optimization-tips-the-balkan-way/</guid>
		<description><![CDATA[Lately I became obsessed with a speed and optimization of PHP web applications. Namely, we are currently working heavily on a new release of voodoo [vudu] (a content engine we built using our in-house developed framework which utilizes few common PHP design patterns). I guess that ActionScript optimization got under my skin and now it's [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I became obsessed with a speed and optimization of PHP web applications. Namely, we are currently working heavily on a new release of voodoo [vudu] (a content engine we built using our in-house developed framework which utilizes few common PHP design patterns). I guess that ActionScript optimization got under my skin and now it's kicking in into PHP front. :) We are reinventing the wheel, but hey - what else would we do? Play Quake all day long? :)</p>
<p>Soooo, I did some benchmarking, I did some reading, and this is what I've came up so far:</p>
<ol>
<li>If a method can be static, declare it static. Speed improvement is by a factor of 4</li>
<li>Avoid magic like __get, __set, __autoload</li>
<li>require_once() is expensive</li>
<li>Use full paths in includes and requires, less time spent on resolving the OS paths</li>
<li>See if you can use strncasecmp, strpbrk and stripos instead of regex</li>
<li>preg_replace is faster than str_replace, but strtr is faster than preg_replace by a factor of 4</li>
<li>Error suppression with @ is very slow</li>
<li>$row[’id’] is 7 times faster than $row[id]</li>
<li>Single quotes are faster than double quotes</li>
<li>(42 == $foo) is faster then if ($foo == 42)</li>
<li>++$i is faster than $i++</li>
<li>true is faster than TRUE, And 1 is even faster than true</li>
<li>Calling isset() happens to be faster then strlen()</li>
<li>
While is faster than do while:<br />
<code>while (--$i) { //do nothing }</code></p>
<p>as opposed to</p>
<p><code>do { //do nothing } while (--$i);</code></p>
<p>And this performs even better:<br />
<code>for ($i=0; $i++<$count; ) { ... }</code>
</li>
<li>Using persistant over non-persistant DB connections in mysql can increase number of requests per second by 41%</li>
<li>You can save yet another 40% of time spent for parsing and compiling by using an opcode cache like APC</li>
<li>References do not provide any performance benefits for strings, integers and other basic data types. In contrast, functions that accept array and object parameters have a performance advantage when references are used. This is because arrays and objects do not use reference counting, so multiple copies of an array or object are created if "pass by value" is used. So the following code:<br />
<code>function ObjRef(&#038;$o) { $a =$o->name; }</code><br />
is faster than:<br />
<code>function ObjRef($o) { $a = $o->name; }</code>
</li>
<li>
In PHP 5, all objects are passed by reference automatically, without the need of an explicit &#038; in the parameter list. PHP 5 object performance should be significantly faster.
</li>
<li>Fastest PHP <a href="http://php.net/filter">Input filtering</a> comes as a filter extension built in PHP 5.2 and is available for 5.1 as a separate download. There is a good tutorial on <a href="http://devzone.zend.com/node/view/id/1113">zend devzone</a></li>
<li>The <a href="http://ie.php.net/ctype">ctype extension</a> offers a series of function wrappers around C's is*() function that check whether a particular character is within a certain range. Unlike the C function that can only work a character at a time, PHP function can operate on entire strings and are far faster then equivalent regular expressions.<br />
<code>preg_match("![0-9]+!", $foo);</code><br />
vs<br />
<code>ctype_digit($foo);</code>
</li>
<li>Internally arrays are stored inside hash tables when they array element (key) is the key of the hashtables used to find the data and result is the value associated with that key. Since hashtable lookups are quite fast, you can simplify array searching by making the data you intend to search through the key of the array, then searching for the data is as simple as $value = isset($foo[$bar])) ? $foo[$bar] : NULL;. This searching mechanism is way faster then manual array iteration, even though having string keys maybe more memory intensive then using simple numeric keys. Second example is is roughly 3 times faster.
<p><code>$keys = array("apples", "oranges", "mangoes", "tomatoes", "pickles");<br />
if (in_array('mangoes', $keys)) { ... }</code></p>
<p>vs</p>
<p><code>$keys = array("apples" => 1, "oranges" => 1, "mangoes" => 1, "tomatoes" => 1, "pickles" => 1);<br />
if (isset($keys['mangoes'])) { ... }</code>
</li>
</ol>
<p>Some tips may be completely out dated or completely wrong due to different hardware/software configurations on systems used for benchmarking.</p>
<p>And for over-obsessed characters - I've found interesting articles about how stuff is handled differently in php5.1 and 5.2 opcode - <a href="http://blog.libssh2.org/index.php?/archives/21-Compiled-Variables.html">compiled variables</a> and <a href="http://blog.libssh2.org/index.php?/archives/28-How-long-is-a-piece-of-string.html">strings</a>.</p>
<p>Sources: <a href="http://www.moskalyuk.com/blog/php-optimization-tips/1272">moskalyuk.com</a>, <a href="http://www.whenpenguinsattack.com/2006/08/14/using-php-in-large-websites-redone/?artid=134">whenpenguinattacks</a>,<br />
<a href="http://ilia.ws/archives/12-PHP-Optimization-Tricks.html">iBlog</a>, <a href="http://phplens.com/lens/php-book/optimizing-debugging-php.php">phpLens</a>, <a href="http://meta.wikimedia.org/wiki/PHP_caching_and_optimization">wikimedia</a>, <a href="http://www.php.lt/benchmark/phpbench.php">phpbench</a>, <a href="http://talks.php.net/show/oscon06/">php.net</a>, <a href="http://www.php.net/manual/en/migration5.incompatible.php">php.net - migration</a>, </p>
]]></content:encoded>
			<wfw:commentRss>http://www.nivas.hr/blog/2007/03/31/php-optimization-tips-the-balkan-way/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hiring Hobos To Wait in Line for PS3</title>
		<link>http://www.nivas.hr/blog/2006/11/17/hiring-hobos-to-wait-in-line-for-ps3/</link>
		<comments>http://www.nivas.hr/blog/2006/11/17/hiring-hobos-to-wait-in-line-for-ps3/#comments</comments>
		<pubDate>Fri, 17 Nov 2006 01:20:53 +0000</pubDate>
		<dc:creator>seven</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.nivas.hr/blog/2006/11/17/hiring-hobos-to-wait-in-line-for-ps3/</guid>
		<description><![CDATA[PS3 release in the States is delayed again, and mob is getting crazy! Some wait in lines, some pay homeless to wait for them, and some get killed in drive by waiting for PS3, including reporter. I never EVER had console, so I thought, it's time to get one. I will wait to see how [...]]]></description>
			<content:encoded><![CDATA[<p>PS3 release in the States is delayed again, and mob is getting crazy! Some wait in lines, some <a target="_blank" href="http://www.wral.com/technology/10331292/detail.html">pay homeless to wait for them</a>, and some get <a target="_blank" href="http://www.wkyt.com/news/headlines/4661551.html">killed in drive by waiting for PS3, including reporter</a>. I never EVER had console, so I thought, it's time to get one. I will wait to see how Wii and PS3 will compare in the end.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nivas.hr/blog/2006/11/17/hiring-hobos-to-wait-in-line-for-ps3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>some notes on php design</title>
		<link>http://www.nivas.hr/blog/2006/10/28/76/</link>
		<comments>http://www.nivas.hr/blog/2006/10/28/76/#comments</comments>
		<pubDate>Sat, 28 Oct 2006 10:17:16 +0000</pubDate>
		<dc:creator>seven</dc:creator>
				<category><![CDATA[developers journal]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.nivas.hr/blog/2006/10/29/76/</guid>
		<description><![CDATA[Today, I have read on metapundit.net some thoughts on how to improve php coding. Don't see the real point in this, except the faster coding. Readability and maintenance is degraded slightly. Update - 18.11.2006. - After taking some time to think about this, I have to agree with MetaPundit. Putting var names into array, and [...]]]></description>
			<content:encoded><![CDATA[<p>Today, I have read on <a target="_blank" href="http://metapundit.net/sections/blog/code_smells_and_design_principles">metapundit.net</a> some thoughts on how to improve php coding. Don't see the real point in this, except the faster coding. Readability and maintenance is degraded slightly.</p>
<p>Update - 18.11.2006. - After taking some time to think about this, I have to agree with MetaPundit. Putting var names into array, and looping trough them makes code more maintainable. But I still have some issues with this, regarding more complex stuff.<br />
<span id="more-76"></span></p>
<pre>Example 1:</pre>
<pre><code>class foo{
function foo($duration, $height, $width, $quality){
$this->_duration = $duration;
$this->_height = $height;
$this->_width = $width;
$this->_quality = $quality;
}
/* Useful code goes here*/</code></pre>
<pre><code>...</code></pre>
<pre><code>class foo{
function foo($duration, $height, $width, $quality){
foreach(array('duration', 'height', 'width', 'quality') as $arg)
{
$this->{"_$arg"} = $$arg;
}
}</code></pre>
<pre>
<pre><code>Example 2:</code>
<code /></pre>
<p>$row = $db->query('select * from foo');<br />
$template->setVariable('fname',$row['fname']);<br />
$template->setVariable('lname',$row['lname']);<br />
$template->setVariable('zip',$row['zip']);<br />
$template->setVariable('city',$row['city']);<br />
$template->setVariable('state',$row['state']);<br />
$template->setVariable('street',$row['street']);<code><br />
$template->setVariable('county',$row['county']);</code></p>
<pre><code>...</code></pre>
<pre><code>$row = $db->query('select * from foo');
foreach(array('fname','lname','zip','city','state','street','zip','county') as $field)
$template->setVariable($field,$row[$field]);</code><code>
...</code></pre>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.nivas.hr/blog/2006/10/28/76/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Filesystem corruption with PHP</title>
		<link>http://www.nivas.hr/blog/2006/10/20/filesystem-corruption-with-php/</link>
		<comments>http://www.nivas.hr/blog/2006/10/20/filesystem-corruption-with-php/#comments</comments>
		<pubDate>Fri, 20 Oct 2006 01:04:40 +0000</pubDate>
		<dc:creator>seven</dc:creator>
				<category><![CDATA[developers journal]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.nivas.hr/blog/2006/10/20/filesystem-corruption-with-php/</guid>
		<description><![CDATA[Writing to a file is easy with PHP. But what will happen if 2 processes try to write to a file at once? Exactly, your data might easily become corrupted and useless. You don't want that to happen, of course. That's why you need to implement file locking. flock() is your friend. For writing to [...]]]></description>
			<content:encoded><![CDATA[<p>Writing to a file is easy with PHP. But what will happen if 2 processes try to write to a file at once? Exactly, your data might easily become corrupted and useless. You don't want that to happen, of course. That's why you need to implement file locking. flock() is your friend. For writing to a file, you want to obtain an exclusive lock on the file. There must never be concurrent writes to a file, after all. Here's an example.</p>
<p><span id="more-71"></span> <?php<br />
$fp = fopen('foo.txt', 'w');<br />
if(flock($fp, LOCK_EX))<br />
{<br />
fputs($fp, "some contents");<br />
flock($fp, LOCK_UN);<br />
}<br />
fclose($fp);<br />
?></p>
<p>For reading from a file, you want to obtain a shared lock. Here's an example on how to do this.</p>
<p><?php<br />
$fp = fopen('foo.txt', 'r');<br />
if(flock($fp, LOCK_SH))<br />
{<br />
while(!feof($fp))<br />
{<br />
echo fgets($fp);<br />
}<br />
flock($fp, LOCK_UN);<br />
}<br />
fclose($fp);<br />
?></p>
<p>Keep in mind that flock() will not work on NFS mounted filesystems or FAT filesystems.</p>
<h2></h2>
]]></content:encoded>
			<wfw:commentRss>http://www.nivas.hr/blog/2006/10/20/filesystem-corruption-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Security &#8211; Never trust user input</title>
		<link>http://www.nivas.hr/blog/2006/06/20/php-security-never-trust-user-input/</link>
		<comments>http://www.nivas.hr/blog/2006/06/20/php-security-never-trust-user-input/#comments</comments>
		<pubDate>Tue, 20 Jun 2006 08:48:15 +0000</pubDate>
		<dc:creator>seven</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.nivas.hr/blog/2006/06/20/php-security-never-trust-user-input/</guid>
		<description><![CDATA[No mater if you are beginner or experienced PHP programmer, you should definitely check out PHP Security Guide by Rob Miller. SQL Injection, Spoofed Form Input, Cross-Site Request Forgery, File Uploads, Including Files, Register Globals, Magic Quotes… He is trying to keep it up to date, so please support him if you can. UPDATED 2.7.2006. [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal"><span lang="EN-US">No mater if you are beginner or experienced PHP programmer, you should definitely check out <a title="PHP Security Guide by Rob Miller" target="_blank" href="http://php.robm.me.uk/#">PHP Security Guide by Rob Miller</a>. SQL Injection, Spoofed Form Input, Cross-Site Request Forgery, File Uploads, Including Files, Register Globals, Magic Quotes… He is trying to keep it up to date, so please support him if you can.</p>
<p>UPDATED 2.7.2006. - Here are some <a target="_blank" href="http://brainbulb.com/talks/php-security-by-example.swf">examples</a> (PHP Security by Example).<br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nivas.hr/blog/2006/06/20/php-security-never-trust-user-input/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

