<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>I want to be free</title>
	
	<link>http://i1t2b3.com</link>
	<description>Any fool can make things bigger and more complex</description>
	<lastBuildDate>Wed, 01 Sep 2010 09:03:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/i1t2b3com" /><feedburner:info uri="i1t2b3com" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Interview with Matt Mullenweg, the WordPress creator</title>
		<link>http://feedproxy.google.com/~r/i1t2b3com/~3/FnCF6cd_fNY/</link>
		<comments>http://i1t2b3.com/2010/09/01/interview-with-matt-mullenweg-the-wordpress-creator/#comments</comments>
		<pubDate>Wed, 01 Sep 2010 09:00:46 +0000</pubDate>
		<dc:creator>Skakunov Alexander</dc:creator>
				<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://i1t2b3.com/?p=617</guid>
		<description><![CDATA[How did the idea to create WordPress come to you and why did you decide to make it a free product? WordPress evolved out of my own desire for a blogging product to make my site better, and a frustration with the existing solutions that I felt were too complicated and hard to use. WordPress was [...]]]></description>
			<content:encoded><![CDATA[<p><strong>How did the idea to create WordPress come to you and why did you decide to make it a free product?</strong></p>
<p><img class="alignright wp-image-619" title="Matt Mullenweg" src="http://i1t2b3.com/wp-content/uploads/2010/09/mcm_22771-199x300.jpg" alt="Matt Mullenweg" />WordPress evolved out of my own desire for a blogging product to make my site better, and a frustration with the existing solutions that I felt were too complicated and hard to use. WordPress was built on the code of an existing GPL product called b2, so it was completely natural for it to continue the GPL license and preserve the freedoms of our users.</p>
<p><strong>How do you make money on it now and what do you plan in the future to earn more?</strong></p>
<p>About 5 years ago I founded a company called Automattic to create commercial services around WordPress that would help grow the market. The first of these was an anti-spam service, Akismet, and we later followed up with WordPress.com, Gravatar, Polldaddy, IntenseDebate, VideoPress, VaultPress, and more to come.</p>
<p><strong>How does your development process work: how many developers do you have, are they full/part time workers, are they located in an office (where?) or are they remote? What IDE and environment do they use to work on WordPress?</strong></p>
<p>There are about 200 active contributors to core WordPress development, all of them volunteers although some are paid by their employers (including Automattic) to contribute to WordPress. There is no set development environment, everyone uses what is most comfortable to them. I have noticed a a definite bias toward using Macs, though.</p>
<div>
<div><strong>What influence have WordPress got on the market and how does this affect the competitor produсts (both commercial and free)?</strong></p>
<p>WordPress is definitely one of the largest publishing platforms now, but there are excellent competitors including Blogger. Innovation in the market is good because it keeps us all on our toes.</p>
<p><strong>Starting from 2.3.3 version the biggest part of changes were connected with admin area and look-and-feel, and not with the code optimization. Can we hope that one day the engine will become more robust?</strong></p>
<div>
<div>
<p>We are constantly rewriting, refactoring, and optimizing the code in WordPress, ofter as much as 10-20% in a single release. Since 2.3.3, probably 95% of the code has been rewritten. This deliberate process of improving the code is better than a massive rewrite because us to test each change more and preserve backward compatibility.</p>
<div>
<p><strong>Do you plan to stop to support PHP4 and avoid deprecated.php usage?</strong></p>
<p>Yes, in 2011.</p>
<div>
<div>
<p><strong>Are there any plans to make plugins approval system more tough? </strong><strong>Some public plugins still are of poor quality.</strong></p>
<div>Eventually I&#8217;d like to bring more of the review process that we have for themes to the plugin directory, but since we encourage people to host their development on the directory I think we should be open to hosting everything.</p>
<p><strong>Do you reward the plugins and themes developers?</strong></p>
<div>
<p>I&#8217;m sure many plugin and theme developers are highly rewarded by their work, but we don&#8217;t give out money or anything from WordPress.org.</p>
<div>
<div>
<p><strong>Will you add some more plugins out-the-box apart from Akismet and Hello Dolly?</strong></p>
<p>Probably not.</p>
<div>
<div>
<p><strong>What do you think on WordPress turning from a blog engine into a </strong><strong>full featured website CMS?</strong></p>
<p>This is a pretty natural transition that started with the introduction of the Pages feature and has grown from there. More than half of new WordPress installations aren&#8217;t being used as blogs at all.</p>
<div>
<div>
<p><strong>If you start to write WordPress now from the scratch &#8211; what would it look like?</strong></p>
<p>Starting today I would probably leave off some features that aren&#8217;t used as much anymore, like a blogroll manager, and focus more on SEO and social integration.</p>
<div>
<div><strong>What do you think about such frameworks like ZendFramework, Сodeigniter, Symfony, etc.? Didn&#8217;t you think to use it for Wordpress development?</strong></p>
<p>WordPress itself is a framework you can use to build highly advanced and scalable applications.</p>
<p><strong>Which CMS/CMF do you like? What projects did you keep in mind while creating WordPress?</strong></p>
<p>Our about page mentions and links to Textpattern, Movable Type, and Drupal as inspirations</p>
<p><strong>Thank you, Matt!</strong></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://i1t2b3.com/2010/09/01/interview-with-matt-mullenweg-the-wordpress-creator/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://i1t2b3.com/2010/09/01/interview-with-matt-mullenweg-the-wordpress-creator/</feedburner:origLink></item>
		<item>
		<title>Convert latin1 to utf8</title>
		<link>http://feedproxy.google.com/~r/i1t2b3com/~3/B-izXChfiN8/</link>
		<comments>http://i1t2b3.com/2010/04/14/convert-latin1-to-utf8/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 12:51:35 +0000</pubDate>
		<dc:creator>Skakunov Alexander</dc:creator>
				<category><![CDATA[db]]></category>
		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://i1t2b3.com/?p=598</guid>
		<description><![CDATA[If you import unicode text into latin1 database column, the symbols would be screwed up — russian symbols become a shit like &#8220;Ð·Ð°Ð»Ð¾Ð³Ð¾Ð²Ñ‹Ð¹ Ð´ÐµÐ¿Ð¾Ð·Ð¸Ñ‚&#8221;. To convert such quickly (as a test) you can use Lebedev&#8217;s convertor. To convert the whole table do the following (thanks to dull.ru): The most important step: dump such data in [...]]]></description>
			<content:encoded><![CDATA[<p>If you import unicode text into latin1 database column, the symbols would be screwed up — russian symbols become a shit like &#8220;Ð·Ð°Ð»Ð¾Ð³Ð¾Ð²Ñ‹Ð¹ Ð´ÐµÐ¿Ð¾Ð·Ð¸Ñ‚&#8221;.</p>
<p><img class="aligncenter size-full wp-image-599" title="extras" src="/wp-content/uploads/2010/04/extras.png" alt="" width="484" height="218" /></p>
<p>To convert such quickly (as a test) you can use <a rel="nofollow" href="http://www.artlebedev.ru/tools/decoder/">Lebedev&#8217;s convertor</a>.</p>
<p>To convert the whole table do the following (thanks to <a rel="nofollow" href="http://dull.ru/2008/11/06/konvertirovat_bazu_v_utf8/">dull.ru</a>):</p>
<ol>
<li>The most important step: dump such data in a file with <code>mysqldump</code>
<pre><code>mysqldump -u user -p <strong>--default-character-set=latin1 </strong>--skip-set-charset --no-create-info --extended-insert --complete-insert dbname table &gt; dbname.sql</code></pre>
<p>If not the whole table data is bad, create another table (<code>CREATE TABLE t2 LIKE t1</code>) and copy wrong rows to the new table.</li>
<li>Replace <code>latin1</code> by <code>utf8</code> in the file<br />
This can be done manually in your editor or by this command:</p>
<pre><code>sed -r 's/latin1/utf8/g' dbname.sql &gt; dbname_utf.sql</code></pre>
</li>
<li>Convert your latin1-table to utf8 (and maybe truncate it):
<pre><code>ALTER TABLE `table` CONVERT TO CHARACTER SET 'utf8';</code></pre>
</li>
<li>Import the utf8 data back to the table:
<pre><code>mysql -u user -p --default-character-set=utf8 dbname &lt; dbname_utf.sql</code></pre>
</li>
</ol>
<p>That&#8217;s it.</p>
]]></content:encoded>
			<wfw:commentRss>http://i1t2b3.com/2010/04/14/convert-latin1-to-utf8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://i1t2b3.com/2010/04/14/convert-latin1-to-utf8/</feedburner:origLink></item>
		<item>
		<title>Zend View Helpers inheritance</title>
		<link>http://feedproxy.google.com/~r/i1t2b3com/~3/0KfoWFQ5TOc/</link>
		<comments>http://i1t2b3.com/2010/04/06/zend-view-helpers-inheritance/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 16:01:38 +0000</pubDate>
		<dc:creator>Skakunov Alexander</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://i1t2b3.com/?p=591</guid>
		<description><![CDATA[It&#8217;s handy to use View Helpers in Zend FW driven project. For example, you want to make an in-place tracker (e.g. Google Analytics) &#8212; you create a helper class My_View_Helper_Tracker inherited from Zend_View_Helper, Zend finds its automatically and then you are free to use your helper method: echo $this->tracker( $trackerID ); The question is what [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s handy to use <noindex><a rel="nofollow" href="http://framework.zend.com/manual/en/zend.view.helpers.html">View Helpers</a></noindex> in Zend FW driven project. For example, you want to make an in-place tracker (e.g. Google Analytics) &mdash; you create a helper class My_View_Helper_Tracker inherited from Zend_View_Helper, Zend finds its automatically and then you are free to use your helper method:</p>
<pre><code>echo $this->tracker( $trackerID );</code></pre>
<p>The question is what you gonna do if you want a base class for a family of trackers?</p>
<p>It&#8217;s not so obvoius due to naming conventions.</p>
<p>Let&#8217;s say you want 2 kinds of trackers: Google Analytics and Euroads.</p>
<p>1. You create such files structure:</p>
<pre><code>
library
 - My
   - View
    - Helper
      - Tracker
        Abstract.php
        - Google
          Page.php
        - Euroads
          Owner.php
          Guest.php
</code></pre>
<p>2. You name your classes as:</p>
<ul>
<li>My_View_Helper_Tracker_Euroads_Guest (extends My_View_Helper_Tracker_Abstract)</li>
<li>&#8230; so on &#8230;</li>
</ul>
<p>3. Class methods are:</p>
<pre><code class="php">public function tracker_euroads_guest(...) ...</code></pre>
<p>4. And the trickiest part: the helper call:</p>
<pre><code class="php">echo $this->tracker_<strong>E</strong>uroads_<strong>G</strong>uest</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://i1t2b3.com/2010/04/06/zend-view-helpers-inheritance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://i1t2b3.com/2010/04/06/zend-view-helpers-inheritance/</feedburner:origLink></item>
		<item>
		<title>Cannot upload a big file?</title>
		<link>http://feedproxy.google.com/~r/i1t2b3com/~3/WlemJFsZ08c/</link>
		<comments>http://i1t2b3.com/2010/03/25/cannot-upload-a-big-file/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 14:43:02 +0000</pubDate>
		<dc:creator>Skakunov Alexander</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://i1t2b3.com/?p=588</guid>
		<description><![CDATA[If you want to work with big files uploads (photos, videos, CSV data dumps) you might need to prepare your PHP server for this &#8212; increase the values of these variables in your php.ini: upload_max_filesize = 512M post_max_size = 512M memory_limit = 512M The same should be done if you try to upload SQL dumps [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to work with big files uploads (photos, videos, CSV data dumps) you might need to prepare your PHP server for this &mdash; increase the values of these variables in your <code>php.ini</code>:</p>
<pre><code>upload_max_filesize = 512M
post_max_size = 512M
memory_limit = 512M
</code></pre>
<p>The same should be done if you try to upload SQL dumps by phpMyAdmin and get a correspondent error message.</p>
]]></content:encoded>
			<wfw:commentRss>http://i1t2b3.com/2010/03/25/cannot-upload-a-big-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://i1t2b3.com/2010/03/25/cannot-upload-a-big-file/</feedburner:origLink></item>
		<item>
		<title>How to rate Points Of Interest automatically</title>
		<link>http://feedproxy.google.com/~r/i1t2b3com/~3/0Yum6RPpOrM/</link>
		<comments>http://i1t2b3.com/2010/03/13/how-to-rate-points-of-interest-automatically/#comments</comments>
		<pubDate>Sat, 13 Mar 2010 13:13:31 +0000</pubDate>
		<dc:creator>Skakunov Alexander</dc:creator>
				<category><![CDATA[api]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[ideas]]></category>

		<guid isPermaLink="false">http://i1t2b3.com/?p=579</guid>
		<description><![CDATA[During my work on SunnyRentals I&#8217;ve got a task to add 2 closest airports to every property an owner creates. I implemented it quite fast since we have a database of airports with coordinates. While playing with this feature, we found out that it is not good enough — the real task must be to [...]]]></description>
			<content:encoded><![CDATA[<p>During my work on <a href="http://www.sunnyrentals.com">SunnyRentals</a> I&#8217;ve got a task to add 2 closest airports to every property an owner creates.</p>
<p>I implemented it quite fast since we have a database of airports with coordinates.</p>
<p>While playing with this feature, we found out that it is not good enough — the real task must be to add 2 <strong>closest and biggest</strong> airports. The problem is that we don&#8217;t have any data in airports DB to guess how big or famous a particular airport is.</p>
<p>So we need to rate every airport somehow&#8230;</p>
<p>The solution we found was simple — we need to google for the airport name and get the search results count. The count can be considered as rating value — London Heathrow airport has 2.33 million results while Kiev Zhulyany airport has only 0.77 mln which looks fair.</p>
<p>Several things to pay attention to:</p>
<ul>
<li>the query we formed was [city name] + [airport name] + &#8216; airport&#8217;</li>
<li>if this query gives zero result, I omit the city name — at times it hepls</li>
<li>we put the query into quotes to google for the exact phrase, otherwise the London City airport gets the highest rating due to the fact that &#8220;<em>city</em>&#8221; is a general term</li>
<li>if the airport name includes the city name (<em>Melbourne Intl</em>), we omit the city name — &#8221;<em>Melbourne Intl airport</em>&#8221; is better then &#8220;<em>Melbourne Melbourne Intl airport</em>&#8220;</li>
<li>in addition to previous idea — if the airport name sounds like the city name, we omit the city name as well. Example: Narsarsuaq airport in Narssarssuaq city. I used <code>soundex</code> function for this comparison — it&#8217;s present in PHP and MySQL.</li>
</ul>
<p>To get the google results you can use the <noindex><a rel="nofollow" href="http://code.google.com/intl/en-US/apis/ajaxsearch/documentation/#fonje">Google Search API</a></noindex>:</p>
<pre><code>$queryTemplate = 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&amp;q=%s';
$airportQuery = '"London Heathrow airport"';
$query = sprintf( $queryTemplate, urlencode( $airportQuery ) );
$json = json_decode( file_get_contents( $query ), 1 );
$rating = (int)$json['responseData']['cursor']['estimatedResultCount'];</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://i1t2b3.com/2010/03/13/how-to-rate-points-of-interest-automatically/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://i1t2b3.com/2010/03/13/how-to-rate-points-of-interest-automatically/</feedburner:origLink></item>
		<item>
		<title>Federated engine – MySQL table as symlink</title>
		<link>http://feedproxy.google.com/~r/i1t2b3com/~3/6sttoUzsKGc/</link>
		<comments>http://i1t2b3.com/2010/01/29/federated-table-as-symlink/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 13:54:38 +0000</pubDate>
		<dc:creator>Skakunov Alexander</dc:creator>
				<category><![CDATA[db]]></category>
		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://i1t2b3.com/?p=570</guid>
		<description><![CDATA[Are you aware of Federated engine in MySQL (apart from MyISAM and InnoDB)? This engine allows you to define a table that sucks data from another table, even from a remore server. The tables definition must be the same. I use it for the following: Every time I rebuild the project, I have wait for [...]]]></description>
			<content:encoded><![CDATA[<p>Are you aware of <a href="http://dev.mysql.com/doc/refman/5.1/en/federated-storage-engine.html">Federated engine</a> in MySQL (apart from MyISAM and InnoDB)?</p>
<p>This engine allows you to define a table that sucks data from another table, even from a remore server. The tables definition must be the same.</p>
<p>I use it for the following:</p>
<ol>
<li>Every time I rebuild the project, I have wait for 15 minutes while two big tables are created and filled with data — these are geo data tables (world cities, regions, etc), 4 mln records, and <acronym title="Points Of Interest">POI</acronym> table, 2 mln records. I use Federated tables to create two separate databases and just link these tables in my project.</li>
<li>These tables are shared between several environments (dev, test and live) on the same server.</li>
</ol>
<p>To check if your MySQL server has the Federated engine supported, you can use just a phpMyAdmin — go to home page of you phpMyAdmin installation (click Home picture), then choose Engines tab and check there.</p>
<p>If it&#8217;s not enabled (gray), open your <em>my.ini</em> file, find the &#8220;<em>[mysqld]</em>&#8221; part and make it to look like this:</p>
<pre><code>[mysqld]
federated</code></pre>
<p>P.S. If you have an error in the table definition, phpMyAdmin shows your database as empty. To fix this, log in via mysql console and try to make a SELECT from this poorly defined table and you get the error message to work with.</p>
]]></content:encoded>
			<wfw:commentRss>http://i1t2b3.com/2010/01/29/federated-table-as-symlink/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://i1t2b3.com/2010/01/29/federated-table-as-symlink/</feedburner:origLink></item>
		<item>
		<title>Currency exchange in your application</title>
		<link>http://feedproxy.google.com/~r/i1t2b3com/~3/Y2K6DLvRvwk/</link>
		<comments>http://i1t2b3.com/2009/09/28/currency-exchange/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 10:53:17 +0000</pubDate>
		<dc:creator>Skakunov Alexander</dc:creator>
				<category><![CDATA[db]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://i1t2b3.com/?p=555</guid>
		<description><![CDATA[That&#8217;s easy, you need 2 things: Fresh currencies exchange rates Some way to excange amount from one currency to another. This how I did it: get values from European Central Bank (ECB) for step #1 and wrote MySQL user defined function for step #2. Here is how to export currencies rates from ECB (EUR is [...]]]></description>
			<content:encoded><![CDATA[<p>That&#8217;s easy, you need 2 things:</p>
<ol>
<li>Fresh currencies exchange rates</li>
<li>Some way to excange amount from one currency to another.</li>
</ol>
<p>This how I did it: get values from European Central Bank (ECB) for step #1 and wrote MySQL user defined function for step #2.</p>
<p>Here is how to export currencies rates from ECB (EUR is a base currency, and I add self rate as 1:1). First I create such  database table:</p>
<pre><code class="sql">CREATE TABLE IF NOT EXISTS `currency` (
  `code` char(3) NOT NULL DEFAULT '',
  `rate` decimal(10,5) NOT NULL COMMENT 'Rate to EUR got from www.ecb.int',
  PRIMARY KEY (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Currency rates (regularly updated)';
</code></pre>
<p>Now let&#8217;s fill it with rates:</p>
<pre><code class="php">&lt;?php

class CurrencyController extends Controller_Ajax_Action {

  public function importAction() {

    $db = Zend_Registry::get('db');
    $db-&gt;beginTransaction();

    $url = 'http://www.ecb.int/stats/eurofxref/eurofxref.zip?1c7a343768baab4322620e3498553b5a';
    try {
      $contents = file_get_contents($url);
      $contents = archive::unzip($contents);
      $contents = explode(&quot;\n&quot;, $contents);

      $names = explode(',', $contents[0]);
      $rates = explode(',', $contents[1]);

      $names[] = 'EUR';
      $rates[] = 1;

      for ($i = 1; $i &lt; sizeof($names); $i++) {
        if (!(float) $rates[$i]) continue;
        $db-&gt;query( sprintf('INSERT INTO `currency`(`code`, `rate`)
              VALUES (&quot;%s&quot;, %10.5f)
              ON DUPLICATE KEY UPDATE `rate`=VALUES(`rate`)',
             trim( $names[$i] ),
             trim( $rates[$i] )
        ) );
      }

      $db-&gt;commit();
    } catch ( Exception $O_o ) {
      error_log( $O_o-&gt;getMessage() );
      $db-&gt;rollback();
    }

  }
}</code></pre>
<p>Now let&#8217;s create a SQL function for handy converts. Create a <code>udf.sql</code> file and add this in it:</p>
<pre><code class="sql">DELIMITER //

DROP  FUNCTION IF EXISTS EXCHANGE;
CREATE FUNCTION EXCHANGE( amount DOUBLE, cFrom CHAR(3), cTo CHAR(3) ) RETURNS DOUBLE READS SQL DATA DETERMINISTIC
    COMMENT 'converts money amount from one currency to another'
BEGIN
    DECLARE rateFrom DOUBLE DEFAULT 0;
    DECLARE rateTo DOUBLE DEFAULT 0;

    SELECT `rate` INTO rateFrom FROM `currency` WHERE `code` = cFrom;
    SELECT `rate` INTO rateTo   FROM `currency` WHERE `code` = cTo;

    IF ISNULL( rateFrom ) OR ISNULL( rateTo ) THEN
        RETURN NULL;
    END IF;

    RETURN amount * rateTo / rateFrom;
END; //

DELIMITER ;</code></pre>
<p>and run this command in your shell:</p>
<pre><code>mysql --user=USER --password=PASS DATABASE &lt; udf.sql</code></pre>
<p>This is how you can use this function &mdash; how to convert 10 US dollars to Canadian dollars:</p>
<pre><code class="sql">SELECT EXCHANGE( 10, 'USD', 'CAD')</code></pre>
<p>which results in $10 = 10.93 Canadian dollars.</p>
<p>P.S. Consider adding the currency export action call to your cron scripts.</p>
<p>P.P.S. A function to unzip the data file can be got at <noindex><a rel="nofollow" href="http://ua2.php.net/manual/en/ref.zip.php">php.net</a></noindex></p>
]]></content:encoded>
			<wfw:commentRss>http://i1t2b3.com/2009/09/28/currency-exchange/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://i1t2b3.com/2009/09/28/currency-exchange/</feedburner:origLink></item>
		<item>
		<title>Ajax controller in Zend project</title>
		<link>http://feedproxy.google.com/~r/i1t2b3com/~3/vrsRf88mv0I/</link>
		<comments>http://i1t2b3.com/2009/09/22/ajax-controller-in-zend-project/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 14:34:35 +0000</pubDate>
		<dc:creator>Skakunov Alexander</dc:creator>
				<category><![CDATA[ideas]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://i1t2b3.com/?p=543</guid>
		<description><![CDATA[I want to share a couple of features I use to handle AJAX requests in projects based on Zend Framework. 1. AJAX request handling What: some parts of your application can be not loaded if currect request is AJAX. Why: you don&#8217;t need views, templates, some routes &#8212; so you can add an AJAX check [...]]]></description>
			<content:encoded><![CDATA[<p>I want to share a couple of features I use to handle AJAX requests in projects based on Zend Framework.</p>
<h3>1. AJAX request handling</h3>
<p><strong>What</strong>: some parts of your application can be not loaded if currect request is AJAX.</p>
<p><strong>Why</strong>: you don&#8217;t need views, templates,  some routes &mdash; so you can add an AJAX check in your Initializer or bootstrap file and avoid loading not necessary things.</p>
<p><strong>How</strong>: Zend Request object has a <noindex><a rel="nofollow" href="http://framework.zend.com/manual/en/zend.controller.request.html#zend.controller.request.http.ajax"><code>isXmlHttpRequest</code> method</a></noindex> to find out whether it&#8217;s AJAX request or not. It&#8217;s based on &#8216;<code>X-Requested-With</code>&#8216; header, which is sent by jQuery, Prototype, Scriptaculous, YUI and MochiKit frameworks.</p>
<h3>2. AJAX Controller</h3>
<p>Most AJAX controller&#8217;s methods I saw had an <code>exit()</code> inside to not to output Zend&#8217;s template &mdash; it is a work-around. The proper way to do so is to tell to Zend not to load anything. One step forward is to create an abstract Controller class and inherit all you AJAX classes from it:</p>
<p><code>/library/Koodix/Controller/Ajax/Action.php</code>:</p>
<pre><code>&lt;?php

require_once 'Zend/Controller/Action.php';

abstract class Koodix_Controller_Ajax_Action
  extends Zend_Controller_Action
{
    public function init() {
        //disable the standard layout output
        $this-&gt;_helper-&gt;layout()-&gt;disableLayout();
        $this-&gt;_helper-&gt;viewRenderer-&gt;setNoRender();
    }

    public function postDispatch() {
        //envelope and output json field
            if( !empty( $this-&gt;json ) ) {
                echo json_encode( $this-&gt;json );
            }
        }
}</code></pre>
<p><code>/application/modules/default/controllers/AjaxController.php</code>:</p>
<pre><code>&lt;?php

class AjaxController extends Koodix_Controller_Ajax_Action
{
 // bla-bla-bla
</code></pre>
<p>Take a look at <code>postDispatch</code> method &mdash; idea behind it is to convert to JSON and output anything that is set to <code>json</code> field of your controller. If you want to send JSON data in special header (and not in body, like it&#8217;s done in my example), you can do it in this method.</p>
]]></content:encoded>
			<wfw:commentRss>http://i1t2b3.com/2009/09/22/ajax-controller-in-zend-project/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://i1t2b3.com/2009/09/22/ajax-controller-in-zend-project/</feedburner:origLink></item>
		<item>
		<title>Flash uploader and HTTP password protection</title>
		<link>http://feedproxy.google.com/~r/i1t2b3com/~3/oqdd2s7dssU/</link>
		<comments>http://i1t2b3.com/2009/09/11/how-to-skip-http-password-by-flash-uploader/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 16:24:43 +0000</pubDate>
		<dc:creator>Skakunov Alexander</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://i1t2b3.com/?p=535</guid>
		<description><![CDATA[You are working on a project and you want to protect the beta version with password so that only allowed people (beta testers) could access it. You decide not to invent the wheel and to use the standard HTTP authentication. First idea is to use your Apache web server to do this, so you write [...]]]></description>
			<content:encoded><![CDATA[<p>You are working on a project and you want to protect the beta version with password so that only allowed people (beta testers) could access it.</p>
<p>You decide not to invent the wheel and to use the standard HTTP authentication.</p>
<p>First idea is to use your Apache web server to do this, so you write something like that in <code>.htaccess</code> file: </p>
<pre><code>AuthName "Private zone"
AuthType Basic
AuthUserFile /path/to/.htpasswd
require valid-use</code></pre>
<p>This solution is simple and that&#8217;s why good.</p>
<p>A problem comes on stage when a Flash file uploader is added to your project &#8211; usually it cannot &#8220;login&#8221; to your site, i.e. users are not able to use the Flash file uploader behind beta login.</p>
<p>That&#8217;s how I solved it.</p>
<p>It&#8217;s not the web server who must solve this (Apache), it&#8217;s the application server (PHP). So remove the lines above from <code>.htaccess</code> and use <noindex><a rel="nofollow" href="http://framework.zend.com/manual/en/zend.auth.adapter.http.html">Zend_Auth_Adapter_Http</a></noindex>  for this purpose &mdash; it&#8217;s Zend&#8217;s HTTP Authentication Adapter.</p>
<p>What concerns the Flash uploader: it sends &#8216;Shockwave Flash&#8217; as value of &#8216;User-Agent&#8217; request header. So in your Initializer or Bootstrap file (where you load Zend_Auth_Adapter_Http) check this header value, and if it&#8217;s not Flash&#8217;s, go for HTTP authentication.</p>
<p>P.S. Hackers can assume this and fake the header to access your site. To cope with that, use an additional secret request variable (Flash uploaders allow this) and check it at server side.</p>
]]></content:encoded>
			<wfw:commentRss>http://i1t2b3.com/2009/09/11/how-to-skip-http-password-by-flash-uploader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://i1t2b3.com/2009/09/11/how-to-skip-http-password-by-flash-uploader/</feedburner:origLink></item>
		<item>
		<title>Reverse Geocoding</title>
		<link>http://feedproxy.google.com/~r/i1t2b3com/~3/QCYxUAEH5Y0/</link>
		<comments>http://i1t2b3.com/2009/09/06/reverse-geocoding/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 07:48:18 +0000</pubDate>
		<dc:creator>Skakunov Alexander</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[geo]]></category>

		<guid isPermaLink="false">http://i1t2b3.com/?p=512</guid>
		<description><![CDATA[Reverse Geocoding is process opposite to Geocoding (when you get map coordinates by city/country given). So the idea is to get city name by coordinates on the map. Why you may need it? For example, user is supposed to add a marker on the map, and you want to check that the marker is within [...]]]></description>
			<content:encoded><![CDATA[<p>Reverse Geocoding is process opposite to Geocoding (when you get map coordinates by city/country given). So the idea is to get city name by coordinates on the map.</p>
<p>Why you may need it? For example, user is supposed to add a marker on the map, and you want to check that the marker is within a particular country or region.</p>
<p>Solutions:</p>
<ol>
<li><noindex><a rel="nofollow" href="http://code.google.com/intl/en/apis/maps/documentation/services.html#ReverseGeocoding">Google GeoCoder </a></noindex>(JavaScript) can work with coordinates to retrieve location name. Advantage is that return information is translated to the preferred language of your browser. Here is <noindex><a rel="nofollow" href="http://code.google.com/intl/en/apis/maps/documentation/examples/geocoding-reverse.html">an example</a></noindex> you can play with.</li>
<li><noindex><a rel="nofollow" href="http://www.geonames.org/export/web-services.html">GeoNames.org</a></noindex> offers several services, among which you can find Reverse Geocoding web service (REST or JSON) which can work with coordinates and postal codes. Advantage &mdash; you can download city/region/country names and <abbr title="Points of Interest">POI</abbr> with coordinates.</li>
</ol>
<p><img src="http://i1t2b3.com/wp-content/uploads/2009/09/globe1.gif" alt="GeoNames" title="GeoNames" width="50" height="50" class="alignright size-full wp-image-520" />By the way, here are results of benchmarking <noindex><a rel="nofollow" href="http://www.peterbe.com/plog/google-reverse-geocoding-vs.-geonames">Google vs. GeoNames</a></noindex>.</p>
]]></content:encoded>
			<wfw:commentRss>http://i1t2b3.com/2009/09/06/reverse-geocoding/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://i1t2b3.com/2009/09/06/reverse-geocoding/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 5.236 seconds. --><!-- Cached page generated by WP-Super-Cache on 2010-09-06 16:31:21 --><!-- Compression = gzip -->
