<?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/"
	>

<channel>
	<title>Twilight SEO</title>
	<atom:link href="http://twilightseo.fallenray.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://twilightseo.fallenray.com</link>
	<description>Standing at the border line. Beautiful color spectrum of Search Engine Optimization. White, Gray, Black Hat SEO learning by doing.</description>
	<pubDate>Sun, 05 Apr 2009 08:09:26 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Migrating from Apache2 to Lighttpd: Part 1 - Installing FastCGI, PHP5, Zend, eaccelerator</title>
		<link>http://twilightseo.fallenray.com/php4/migrating-from-apache2-to-lighttpd-installing-fastcgi-php5-zend-eaccelerator/</link>
		<comments>http://twilightseo.fallenray.com/php4/migrating-from-apache2-to-lighttpd-installing-fastcgi-php5-zend-eaccelerator/#comments</comments>
		<pubDate>Sun, 05 Apr 2009 08:07:25 +0000</pubDate>
		<dc:creator>ruru</dc:creator>
		
		<category><![CDATA[php4]]></category>

		<category><![CDATA[php5]]></category>

		<category><![CDATA[server]]></category>

		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://rainbowhatseo.fallenray.com/?p=96</guid>
		<description><![CDATA[Okay guys,
Before migrating to Lighttpd,
we need to recompile PHP to support FastCGI.
Folow the guide step by step.
It won&#8217;t take five minutes.
Promise 
In case you messed up somewhere.
DON&#8217;T WORRY, it&#8217;s just one email / comment away  
Step 1)
Prepare location for installer

Code:
mkdir -p /root/INSTALL
cd /root/INSTALL

Step 2)
Install FastCGI

Code:
wget http://www.fastcgi.com/dist/fcgi.tar.gz
tar -zxvf fcgi-2.4.0.tar.gz
cd fcgi-2.4.0
./configure
make
make install
cd ..

Step 3)
Rebuild PHP to [...]]]></description>
			<content:encoded><![CDATA[<p>Okay guys,</p>
<p>Before migrating to Lighttpd,<br />
we need to recompile PHP to support FastCGI.</p>
<p>Folow the guide step by step.<br />
It won&#8217;t take five minutes.</p>
<p>Promise <img class="inlineimg" title="Big Grin" src="images/smilies/biggrin.gif" border="0" alt="" /></p>
<p>In case you messed up somewhere.<br />
DON&#8217;T WORRY, it&#8217;s just one email / comment away <img src='http://twilightseo.fallenray.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><span style="font-size: large;">Step 1)</span></p>
<p>Prepare location for installer</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">Code:</div>
<pre class="alt2" style="border: 1px inset; margin: 0px; padding: 6px; overflow: auto; width: 640px; height: 50px; text-align: left;" dir="ltr">mkdir -p /root/INSTALL
cd /root/INSTALL</pre>
</div>
<p><span style="font-size: large;">Step 2)</span></p>
<p><span style="font-size: xx-large;">Install FastCGI</span></p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">Code:</div>
<pre class="alt2" style="border: 1px inset; margin: 0px; padding: 6px; overflow: auto; width: 640px; height: 130px; text-align: left;" dir="ltr">wget http://www.fastcgi.com/dist/fcgi.tar.gz
tar -zxvf fcgi-2.4.0.tar.gz
cd fcgi-2.4.0
./configure
make
make install
cd ..</pre>
</div>
<p><span style="font-size: large;">Step 3)</span></p>
<p><span style="font-size: xx-large;">Rebuild PHP </span>to support FastCGI</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">Code:</div>
<pre class="alt2" style="border: 1px inset; margin: 0px; padding: 6px; overflow: auto; width: 640px; height: 354px; text-align: left;" dir="ltr">wget http://files.directadmin.com/services/customapache/php-5.2.9.tar.gz
wget http://files.directadmin.com/services/customapache/php-5.2.9-mail-header.patch
tar -zxvf php-5.2.9.tar.gz
patch -p0 &lt; php-5.2.9-mail-header.patch
cd php-5.2.9
./configure --enable-soap --with-libxml-dir=/usr/include/libxml2 \
--with-curl=/usr/local/lib --with-gd \
--enable-gd-native-ttf --with-ttf --with-gettext \
--with-jpeg-dir=/usr/local/lib \
--with-freetype-dir=/usr/local/lib --with-kerberos \
--with-openssl --with-mcrypt --with-mhash \
--with-mysql=/usr/bin/mysql --with-mysqli=/usr/bin/mysql_config \
--with-pdo-mysql=/usr/bin/mysql \
--with-pear --with-png-dir=/usr/local/lib \
--with-zlib --with-zlib-dir=/usr/local/lib --enable-zip --with-iconv=/usr/local \
--enable-bcmath --enable-calendar --enable-ftp --enable-magic-quotes --enable-sockets \
--enable-mbstring --with-curlwrappers --enable-shared --enable-static \
--enable-fastcgi --enable-force-cgi-redirect
make
make install
cd ..</pre>
</div>
<p><span style="font-size: large;">Step 4)</span></p>
<p><span style="font-size: xx-large;">Install Zend Optimizer</span></p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">Code:</div>
<pre class="alt2" style="border: 1px inset; margin: 0px; padding: 6px; overflow: auto; width: 640px; height: 322px; text-align: left;" dir="ltr">wget http://files.directadmin.com/services/customapache/ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
tar -zxvf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
cd ZendOptimizer-3.3.3-linux-glibc23-i386
./install.sh
ENTER
ENTER
ENTER
ENTER
ENTER
ENTER
ENTER
ENTER
ENTER
ENTER
ENTER
ENTER
ENTER
ENTER
cd ..</pre>
</div>
<p><span style="font-size: large;">Step 5)</span></p>
<p><span style="font-size: xx-large;">Install eaccelerator</span></p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">Code:</div>
<pre class="alt2" style="border: 1px inset; margin: 0px; padding: 6px; overflow: auto; width: 640px; height: 226px; text-align: left;" dir="ltr">wget http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator-0.9.5.3.tar.bz2
tar -xjvf eaccelerator-0.9.5.3.tar.bz2
cd eaccelerator-0.9.5.3
make clean
export PHP_PREFIX="/usr/local"
$PHP_PREFIX/bin/phpize
./configure \
--enable-eaccelerator=shared \
--with-php-config=$PHP_PREFIX/bin/php-config
make clean
make
make install
cd ..</pre>
</div>
<p>Remember the location&#8230;.</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">Quote:</div>
<table border="0" cellspacing="0" cellpadding="6" width="100%">
<tbody>
<tr>
<td class="alt2" style="border: 1px inset ;">[root@server eaccelerator-0.9.5.3]# make install</p>
<p>Installing shared extensions:     <strong>/usr/local/lib/php/extensions/no-debug-non-zts-20060613/</strong></td>
</tr>
</tbody>
</table>
</div>
<p>If you forgot the location of your eaccelerator,</p>
<p>find it using this command:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">Code:</div>
<pre class="alt2" style="border: 1px inset; margin: 0px; padding: 6px; overflow: auto; width: 640px; height: 34px; text-align: left;" dir="ltr">locate eaccelerator.so</pre>
</div>
<p>Find the location of your php.ini</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">Code:</div>
<pre class="alt2" style="border: 1px inset; margin: 0px; padding: 6px; overflow: auto; width: 640px; height: 82px; text-align: left;" dir="ltr">php -r "phpinfo();" | grep php.ini

Configuration File (php.ini) Path =&gt; /usr/local/lib
Loaded Configuration File =&gt; <strong>/usr/local/Zend/etc/php.ini</strong></pre>
</div>
<p>Now, edit php.ini</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">Code:</div>
<pre class="alt2" style="border: 1px inset; margin: 0px; padding: 6px; overflow: auto; width: 640px; height: 34px; text-align: left;" dir="ltr">vi <strong>/usr/local/Zend/etc/php.ini</strong></pre>
</div>
<p>and add / modify this line&#8230;</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">Quote:</div>
<table border="0" cellspacing="0" cellpadding="6" width="100%">
<tbody>
<tr>
<td class="alt2" style="border: 1px inset ;">[Zend]<br />
zend_extension=&#8221;<strong>/usr/local/lib/php/extensions/no-debug-non-zts-20060613/</strong>eaccelerator.so&#8221;<br />
<em>zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.3</em><br />
<em>zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3</em><br />
<em>zend_optimizer.version=3.3.3</em><br />
<em>zend_extension=/usr/local/Zend/lib/ZendExtensionManager.so</em><br />
<em>zend_extension_ts=/usr/local/Zend/lib/ZendExtensionManager_TS.so</em><br />
eaccelerator.shm_size=&#8221;16&#8243;<br />
eaccelerator.cache_dir=&#8221;<strong>/tmp/eaccelerator</strong>&#8220;<br />
eaccelerator.enable=&#8221;1&#8243;<br />
eaccelerator.optimizer=&#8221;1&#8243;<br />
eaccelerator.check_mtime=&#8221;1&#8243;<br />
eaccelerator.debug=&#8221;0&#8243;<br />
eaccelerator.filter=&#8221;"<br />
eaccelerator.shm_max=&#8221;0&#8243;<br />
eaccelerator.shm_ttl=&#8221;0&#8243;<br />
eaccelerator.shm_prune_period=&#8221;0&#8243;<br />
eaccelerator.shm_only=&#8221;0&#8243;<br />
eaccelerator.compress=&#8221;1&#8243;<br />
eaccelerator.compress_level=&#8221;9&#8243;</td>
</tr>
</tbody>
</table>
</div>
<p>Create cache directory for eaccelerator</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">Code:</div>
<pre class="alt2" style="border: 1px inset; margin: 0px; padding: 6px; overflow: auto; width: 640px; height: 50px; text-align: left;" dir="ltr">mkdir <strong>/tmp/eaccelerator</strong>
chmod 0777 <strong>/tmp/eaccelerator</strong></pre>
</div>
<p><span style="font-size: large;">Step 6)</span></p>
<p><span style="font-size: xx-large;">Check</span> your <span style="font-size: xx-large;">php version</span></p>
<p><strong>Make sure</strong> all work fine before we restart apache.</p>
<p>DO NOT restart apache before passing this step.</p>
<p>eaccelerator and Zend must be loaded properly&#8230;</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">Quote:</div>
<table border="0" cellspacing="0" cellpadding="6" width="100%">
<tbody>
<tr>
<td class="alt2" style="border: 1px inset ;">[root@server eaccelerator-0.9.5.3]# php -v<br />
PHP 5.2.9 (cli) (built: Mar 23 2009 12:19:57)<br />
Copyright (c) 1997-2009 The PHP Group<br />
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies<br />
with <strong>eAccelerator </strong>v0.9.5.3, Copyright (c) 2004-2006 eAccelerator, by eAccelerator<br />
with <strong>Zend Extension Manager </strong>v1.2.2, Copyright (c) 2003-2007, by Zend Technologies<br />
with <strong>Zend Optimizer v3.3.3</strong>, Copyright (c) 1998-2007, by Zend Technologies</td>
</tr>
</tbody>
</table>
</div>
<p>php-cgi was compiled as fastcgi &#8212;&gt; <strong>cgi-fcgi</strong></p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">Quote:</div>
<table border="0" cellspacing="0" cellpadding="6" width="100%">
<tbody>
<tr>
<td class="alt2" style="border: 1px inset ;">[root@server eaccelerator-0.9.5.3]# php-cgi -v<br />
PHP 5.2.9 (<strong>cgi-fcgi</strong>) (built: Mar 23 2009 12:19:24)<br />
Copyright (c) 1997-2009 The PHP Group<br />
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies<br />
with eAccelerator v0.9.5.3, Copyright (c) 2004-2006 eAccelerator, by eAccelerator<br />
with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies<br />
with Zend Optimizer v3.3.3, Copyright (c) 1998-2007, by Zend Technologies</td>
</tr>
</tbody>
</table>
</div>
<p><span style="font-size: large;">Step 7)</span></p>
<p><span style="font-size: xx-large;">Restart apache</span></p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">Code:</div>
<pre class="alt2" style="border: 1px inset; margin: 0px; padding: 6px; overflow: auto; width: 640px; height: 34px; text-align: left;" dir="ltr">service httpd restart</pre>
</div>
<p><span style="font-size: large;">Step 8 9 10 &#8230;.</span></p>
<p>Troubleshooting <img class="inlineimg" title="Big Grin" src="images/smilies/biggrin.gif" border="0" alt="" /><br />
and take a break.</p>
<p>Next &#8230; <a>installing Lighttpd</a></p>
]]></content:encoded>
			<wfw:commentRss>http://twilightseo.fallenray.com/php4/migrating-from-apache2-to-lighttpd-installing-fastcgi-php5-zend-eaccelerator/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Lighttpd vs Nginx (Apache Benchmark)</title>
		<link>http://twilightseo.fallenray.com/server/lighttpd-vs-nginx-apache-benchmark/</link>
		<comments>http://twilightseo.fallenray.com/server/lighttpd-vs-nginx-apache-benchmark/#comments</comments>
		<pubDate>Sat, 21 Mar 2009 20:25:37 +0000</pubDate>
		<dc:creator>ruru</dc:creator>
		
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://rainbowhatseo.fallenray.com/?p=79</guid>
		<description><![CDATA[Continuing previous post Lighttp vs Apache2
Now, i&#8217;ve done another test Lighttpd vs Nginx using Apache Benchmark
Benchmark parameter
ab -c 300 -n 1000 &#8230;
.
.
.
.
.
Nginx + spawn-fcgi
14:31:34 up 9 days, 21:39,  2 users,  load average: 18.47, 7.77, 5.68
Server Software:        nginx/0.6.35
Document Path:         [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-thumbnail wp-image-80" title="lighttpd-vs-nginx-apache-benchmark" src="http://rainbowhatseo.fallenray.com/wp-content/uploads/2009/03/lighttpd-vs-nginx-apache-benchmark-150x150.jpg" alt="lighttpd-vs-nginx-apache-benchmark" width="150" height="150" align="left" />Continuing previous post <a href="http://rainbowhatseo.fallenray.com/php4/lighttpd-fastcgi-php-cli-vs-apache2-mod_php/">Lighttp vs Apache2</a><br />
Now, i&#8217;ve done another test <strong>Lighttpd vs Nginx using Apache Benchmark</strong></p>
<p>Benchmark parameter</p>
<blockquote><p>ab -c 300 -n 1000 &#8230;</p></blockquote>
<p>.<br />
.<br />
.<br />
.<br />
.<br />
<strong>Nginx + spawn-fcgi</strong><br />
14:31:34 up 9 days, 21:39,  2 users,  load average: <strong>18.47, </strong>7.77, 5.68</p>
<blockquote><p>Server Software:        nginx/0.6.35</p>
<p>Document Path:          /<br />
Document Length:        22355 bytes</p>
<p>Concurrency Level:      300<br />
Time taken for tests:   45.095 seconds<br />
Complete requests:      1000<br />
<strong>Failed requests:        120<br />
(Connect: 0, Receive: 0, Length: 120, Exceptions: 0)</strong><br />
Write errors:           0<br />
Non-2xx responses:      119<br />
Total transferred:      19941669 bytes<br />
HTML transferred:       19740333 bytes<br />
<strong>Requests per second:    22.18 [#/sec] (mean)</strong><br />
Time per request:       13528.485 [ms] (mean)<br />
Time per request:       45.095 [ms] (mean, across all concurrent requests)<br />
Transfer rate:          431.85 [Kbytes/sec] received</p></blockquote>
<p><strong>Lighttpd + spawn-fcgi</strong><br />
14:47:53 up 9 days, 21:55,  2 users,  load average: <strong>21.21</strong>, 6.73, 4.57</p>
<blockquote>
<p>Server Software:        lighttpd/1.4.22</p>
<p>Document Path:          /<br />
Document Length:        22388 bytes</p>
<p>Concurrency Level:      300<br />
Time taken for tests:   42.815 seconds<br />
Complete requests:      1000<br />
<strong>Failed requests:        0</strong><br />
Write errors:           0<br />
Total transferred:      22599690 bytes<br />
HTML transferred:       22388000 bytes<br />
<strong>Requests per second:    23.36 [#/sec] (mean)</strong><br />
Time per request:       12844.583 [ms] (mean)<br />
Time per request:       42.815 [ms] (mean, across all concurrent requests)<br />
Transfer rate:          515.47 [Kbytes/sec] received</p></blockquote>
<h3>Conclusion: Lighttpd vs Nginx (Apache Benchmark)</h3>
<p>Lighttpd gave me less error and slightly faster.</p>
<p>Nginx consume less resource, with slightly produce more error.<br />
Setting low amount of worker thread will greatly reduce resource usage,<br />
but couldn&#8217;t serve high concurrency.</p>
<p>Recommendation:</p>
<ul>
<li><del datetime="2009-03-23T04:19:35+00:00">Use Nginx for Desktop based server</del>,</li>
<li><del datetime="2009-03-23T04:19:35+00:00">and Lighttpd for Normal server</del>.</li>
<li>Throw away Apache  :p</li>
</ul>
<blockquote><p><em>Edit:<br />
I found the culprit that cause many errors on nginx was actually the spawn-fcgi parameters.<br />
Nginx itself works smoothly beyond expectation.</p>
<p>I remark the conclusion. Both are great Apache2 replacement.</p>
<p>But, so far&#8230;<br />
I coudn&#8217;t find a good numbers of childs to spawn and fork.<br />
With nginx, it either crash my server (too high) or many failed requests (too low).<br />
</em>
</p></blockquote>
<p>end of file &#8230; Lighttpd vs Nginx (Apache Benchmark)</p>
]]></content:encoded>
			<wfw:commentRss>http://twilightseo.fallenray.com/server/lighttpd-vs-nginx-apache-benchmark/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Lighttpd+FastCgi+Php-Cli vs Apache2+mod_php</title>
		<link>http://twilightseo.fallenray.com/php4/lighttpd-fastcgi-php-cli-vs-apache2-mod_php/</link>
		<comments>http://twilightseo.fallenray.com/php4/lighttpd-fastcgi-php-cli-vs-apache2-mod_php/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 15:08:38 +0000</pubDate>
		<dc:creator>ruru</dc:creator>
		
		<category><![CDATA[php4]]></category>

		<category><![CDATA[php5]]></category>

		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://rainbowhatseo.fallenray.com/?p=43</guid>
		<description><![CDATA[I heard a lot of good things about lighttpd and fastcgi.
People keep claiming that Lighttpd are faster than Apache2.
So here i want to prove it by myself.
If you&#8217;ve been on internet for more than 10 years,
you&#8217;ll understand that there&#8217;s a bunch of bullshit lying around.
I&#8217;m going to believe what i heard, only after i see [...]]]></description>
			<content:encoded><![CDATA[<p>I heard a lot of good things about lighttpd and fastcgi.<br />
People keep claiming that Lighttpd are faster than Apache2.<br />
So here i want to prove it by myself.</p>
<p>If you&#8217;ve been on internet for more than 10 years,<br />
you&#8217;ll understand that there&#8217;s a bunch of bullshit lying around.<br />
I&#8217;m going to believe what i heard, only after i see it.</p>
<p>Took almost 2 days to setup the environment.<br />
On my server, the monstrous AMD Phenom 9650 Quad Core with 4GB RAM,<br />
coated with the best operating system in the world CentOS 5.2<br />
(Didn&#8217;t i say there&#8217;s a bunch of bullshit on internet? You just heard one)</p>
<p>Okay, all set.</p>
<p>I install both:<br />
Apache2 + mod_php, and Lighttpd/1.4.22 + FastCgi + Php-FCLI<br />
Let me know if you need tutorial to put up these, i&#8217;ll post a guide by request.</p>
<p>Say the first configuration of Apache/2, i will name him [K]<br />
and the second one is [L] which stands for Lighttpd.</p>
<p>Both [K] and [L] are on the same machine,<br />
served on different static IP,<br />
which you can purchase for $0.5-$3 per IP &#8230;<br />
if you have a dedicated server.</p>
<p>Okay, let&#8217;s cut the crap.</p>
<p>I use ApacheBench, Version 2.3 as the judge.<br />
Isn&#8217;t [L] one brave challenger here.<br />
The situation doesn&#8217;t favor him.<br />
I wish i can have LighttpdBench to keep the fight fair.</p>
<p>Oh, well i said stop the crap. Let&#8217;s go&#8230;.</p>
<p>First round!!!!!</p>
<p><img class="alignnone size-full wp-image-46" title="fight-round-1" src="http://rainbowhatseo.fallenray.com/wp-content/uploads/2009/03/fight-round-1.jpg" alt="fight-round-1" width="140" height="188" /></p>
<p>Concurrency Level:      200<br />
Complete requests:      1000</p>
<p>The result is..<br />
Both has zero failed requests</p>
<p>[L] Requests per second:    67.22 [#/sec] (mean)<br />
[K] Requests per second:    47.01 [#/sec] (mean)</p>
<blockquote><p>WINNER: [L], FAST!<br />
Clearly shown that [L] is 43% faster than [K]</p></blockquote>
<p>Move to the second round!!!</p>
<p><img class="alignnone size-full wp-image-47" title="fight-round-2" src="http://rainbowhatseo.fallenray.com/wp-content/uploads/2009/03/fight-round-2.jpg" alt="fight-round-2" width="300" height="286" /></p>
<p>Concurrency Level:      400<br />
Complete requests:      2000</p>
<p>[L] Failed requests:        22<br />
[K] Failed requests:        1268</p>
<p>[L] Requests per second:    64.62 [#/sec] (mean)<br />
[K] Requests per second:    87.53 [#/sec] (mean)</p>
<blockquote><p>WINNER: [L]. HARD, STRONG, AND ROBUST.<br />
At high concurrency level [L] has 0.0017339218158890290037831021437579% less failure than than [K]</p></blockquote>
<p>FINAL ROUND!!!</p>
<p><img class="alignnone size-full wp-image-45" title="fight-final" src="http://rainbowhatseo.fallenray.com/wp-content/uploads/2009/03/fight-final.jpg" alt="fight-final" width="300" height="286" /></p>
<p>Concurrency Level:      100<br />
Complete requests:      2000</p>
<p>[L]<br />
Failed requests:        0<br />
Requests per second:    65.47 [#/sec] (mean)</p>
<p>[K]<br />
Failed requests:        7<br />
Requests per second:    62.67 [#/sec] (mean)</p>
<blockquote><p>WINNER: [L].<br />
Given normal condition both perform almost equally,<br />
but [L] is has less failure than [K]</p></blockquote>
<h3>Conclusion Lighttpd+FastCgi+Php-Cli vs Apache2+mod_php</h3>
<p>[L] sitting in the corner with satisfied looks on his &#8230; her face.<br />
Based on performance [L] beats [K] to dust<br />
and send him fly thousand kilometer to the blue sky.<br />
If performance is #1 int your life, then you must choose [L].</p>
<p><img src="http://rainbowhatseo.fallenray.com/wp-content/uploads/2009/03/fight-winner.jpg" alt="fight-winner" title="fight-winner" width="300" height="300" class="alignnone size-full wp-image-48" /></p>
<p>But remember, don&#8217;t overwhelmed with the benchmark result,<br />
and these lovely pictures.</p>
<p>Benchmarking and tweaking is for poor people.<br />
It took a lot of time just to improve the tiny bit of performance.</p>
<p>Take this into consideration.<br />
Right now the majority are using Apache,<br />
which means  bunch of people swimming in this pool.</p>
<p>You might want to sacrifice performance,<br />
spend less time on installation and tweaking,<br />
and spend more money on hardware.</p>
<p>In the end, outcome is everything.<br />
Means not only you have to cut hardware cost,<br />
but also time for soft-optimization.</p>
<p>Later~</p>
]]></content:encoded>
			<wfw:commentRss>http://twilightseo.fallenray.com/php4/lighttpd-fastcgi-php-cli-vs-apache2-mod_php/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Use OpenDNS. Period!</title>
		<link>http://twilightseo.fallenray.com/server/use-opendns-period/</link>
		<comments>http://twilightseo.fallenray.com/server/use-opendns-period/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 11:13:09 +0000</pubDate>
		<dc:creator>ruru</dc:creator>
		
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://rainbowhatseo.fallenray.com/?p=58</guid>
		<description><![CDATA[Yesterday after changing the DNS for several domain, i experienced a huge delay.
It doesn&#8217;t change on my side for more than 24 hours.
I&#8217;m getting mad and called the hosting server.
The technician on the edge of their temper i believe :p,
explains to me that it&#8217;s been propagated perfectly.
I said no no no! There&#8217;s no change on [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday after changing the DNS for several domain, i experienced a huge delay.<br />
It doesn&#8217;t change on my side for more than 24 hours.</p>
<p>I&#8217;m getting mad and called the hosting server.<br />
The technician on the edge of their temper i believe :p,<br />
explains to me that it&#8217;s been propagated perfectly.</p>
<p>I said no no no! There&#8217;s no change on my said.</p>
<p>Later i found out that the problem is on DNS Server of my ISP.<br />
The records were cached there, and it took 2-3 days until refreshed.<br />
I don&#8217;t like wasting every second just to wait<br />
for my domain to work properly.</p>
<p>Quick search on this issue.<br />
Browsed several pages of google result.</p>
<p>Got me landing on the OpenDNS Website.<br />
Do a small task setting my DNS Server.</p>
<p><img src="http://rainbowhatseo.fallenray.com/wp-content/uploads/2009/02/setting-up-opendns-on-vista.png" alt="setting-up-opendns-on-vista" title="setting-up-opendns-on-vista" width="679" height="499" class="alignnone size-full wp-image-61" /></p>
<p>And refresh the cache from http://cache.opendns.com/<br />
Works like a charm <img src='http://twilightseo.fallenray.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://twilightseo.fallenray.com/server/use-opendns-period/feed/</wfw:commentRss>
		</item>
		<item>
		<title>First month result from SSEC &#8230; $108.91</title>
		<link>http://twilightseo.fallenray.com/cloaking/first-month-result-ssec/</link>
		<comments>http://twilightseo.fallenray.com/cloaking/first-month-result-ssec/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 09:35:25 +0000</pubDate>
		<dc:creator>ruru</dc:creator>
		
		<category><![CDATA[cloaking]]></category>

		<guid isPermaLink="false">http://rainbowhatseo.fallenray.com/?p=55</guid>
		<description><![CDATA[Just a quick update.
Last month i build couple thousand of pages from around a hundred of affiliate.
So far only 4 sponsors convert which gave me &#8230; *tada*
a whooping $47.3 from 1st afiliate network and $61.61 from second one.
Still not enough to cover the cost  
Trying a couple of new techniques now.
Wish me luck!
]]></description>
			<content:encoded><![CDATA[<p>Just a quick update.<br />
Last month i build couple thousand of pages from around a hundred of affiliate.<br />
So far only 4 sponsors convert which gave me &#8230; *tada*<br />
a whooping $47.3 from 1st afiliate network and $61.61 from second one.<br />
Still not enough to cover the cost <img src='http://twilightseo.fallenray.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>Trying a couple of new techniques now.<br />
Wish me luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://twilightseo.fallenray.com/cloaking/first-month-result-ssec/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Simplified search engine cloaker, the journey begins</title>
		<link>http://twilightseo.fallenray.com/cloaking/simplified-search-engine-cloaker/</link>
		<comments>http://twilightseo.fallenray.com/cloaking/simplified-search-engine-cloaker/#comments</comments>
		<pubDate>Mon, 05 Jan 2009 05:58:25 +0000</pubDate>
		<dc:creator>ruru</dc:creator>
		
		<category><![CDATA[cloaking]]></category>

		<guid isPermaLink="false">http://rainbowhatseo.fallenray.com/?p=25</guid>
		<description><![CDATA[Despite of negative talks i read over BHW. I made up my mind to join SSEC, Simplified search engine cloaker. Actually fantomaster is my first choice, but my budget won&#8217;t allow. I thought it&#8217;s good to start with this one first.
I join without even knowing what cloaking is. I read the forum over and over. [...]]]></description>
			<content:encoded><![CDATA[<p>Despite of negative talks i read over BHW. I made up my mind to join SSEC, Simplified search engine cloaker. Actually fantomaster is my first choice, but my budget won&#8217;t allow. I thought it&#8217;s good to start with this one first.</p>
<p>I join without even knowing what cloaking is. I read the forum over and over. </p>
<p>First thing came up on my mind. This membership do over-price. I should&#8217;ve heard BHW ppl there. </p>
<p>Second opinion, this is nothing new to me. I&#8217;ve done it since years ago. I did it without even knowing what search engine cloaking is. My Gosh, i&#8217;m a genius! I just realized it.</p>
<p>Third opinion after hanging out for couple weeks. Brian, the owner, is pretty nice guy. I got impression though, people who start doing this since two three years ago &#8230; those who has hundreds or thousand posts on forum, is already on top of food pyramid. Che!</p>
<p>Fourth, the forum is pretty quiet. I can hear the echo. Maybe only around 50 active members over there. But wait!!! The forum is very active for a small community. Lot&#8217;s a cool guys there.</p>
<p>Fifth, I would keep my membership for couple months. Expect some updates from me. Simplified search engine cloaker, here we go!</p>
]]></content:encoded>
			<wfw:commentRss>http://twilightseo.fallenray.com/cloaking/simplified-search-engine-cloaker/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Subdomain 301 Redirection using .htaccess</title>
		<link>http://twilightseo.fallenray.com/uncategorized/subdomain-301-redirection-using-htaccess/</link>
		<comments>http://twilightseo.fallenray.com/uncategorized/subdomain-301-redirection-using-htaccess/#comments</comments>
		<pubDate>Thu, 18 Dec 2008 08:34:28 +0000</pubDate>
		<dc:creator>ruru</dc:creator>
		
		<guid isPermaLink="false">http://rainbowhatseo.fallenray.com/?p=23</guid>
		<description><![CDATA[I'm planning to post a lot more script, snipplets, whatever you called it. Mainly covering minisites, scraped pages, cycled pages, etc. Used properly, each of my post will help you making money. No guarantee. Period  
So i pick a better name for my blog, and figure out that i need to redirect it to [...]]]></description>
			<content:encoded><![CDATA[<p>I'm planning to post a lot more script, snipplets, whatever you called it. Mainly covering minisites, scraped pages, cycled pages, etc. Used properly, each of my post will help you making money. No guarantee. Period <img src='http://twilightseo.fallenray.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>So i pick a better name for my blog, and figure out that i need to redirect it to the new one. Here's the code i save it as <strong>.htaccess</strong> and put it on <strong>public_html/php</strong> folder:</p>
<div class="igBar"><span id="lphp-2"><a href="#" onclick="javascript:showPlainTxt('php-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-2">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">RewriteEngine on</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">RewriteCond %<span style="color:#006600; font-weight:bold;">&#123;</span>HTTP_HOST<span style="color:#006600; font-weight:bold;">&#125;</span> ^php.fallenray.com$ <span style="color:#006600; font-weight:bold;">&#91;</span>OR<span style="color:#006600; font-weight:bold;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">RewriteCond %<span style="color:#006600; font-weight:bold;">&#123;</span>HTTP_HOST<span style="color:#006600; font-weight:bold;">&#125;</span> ^www.php.fallenray.com$ <span style="color:#006600; font-weight:bold;">&#91;</span>NC<span style="color:#006600; font-weight:bold;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">RewriteRule ^<span style="color:#006600; font-weight:bold;">&#40;</span>.*<span style="color:#006600; font-weight:bold;">&#41;</span>$ http:<span style="color:#FF9933; font-style:italic;">//rainbowhatseo.fallenray.com/$1 [R=301,L] </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>My hosting use cPanel. It has the function to do this, but i simply doesn't satisfied with the result.<br />
Above code will permanently (301) redirect from php.fallenray.com to rainbowhatseo.fallenray.com</p>
]]></content:encoded>
			<wfw:commentRss>http://twilightseo.fallenray.com/uncategorized/subdomain-301-redirection-using-htaccess/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Kohana and Zend, Killer Combo! The best PHP5 framework and library in one package.</title>
		<link>http://twilightseo.fallenray.com/php5/kohana-and-zend-killer-combo-the-best-php5-framework-and-library-in-one-package/</link>
		<comments>http://twilightseo.fallenray.com/php5/kohana-and-zend-killer-combo-the-best-php5-framework-and-library-in-one-package/#comments</comments>
		<pubDate>Sun, 14 Dec 2008 10:24:14 +0000</pubDate>
		<dc:creator>ruru</dc:creator>
		
		<category><![CDATA[kohanaphp]]></category>

		<category><![CDATA[php5]]></category>

		<category><![CDATA[zend]]></category>

		<category><![CDATA[framework]]></category>

		<category><![CDATA[kohana]]></category>

		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://php.fallenray.com/uncategorized/kohana-and-zend-killer-combo-the-best-php5-framework-and-library-in-one-package/</guid>
		<description><![CDATA[My current favorite php framework is kohana. After several weeks playing with it, i feel that KohanaPhp far exceed CakePHP and CodeIgniter. Now i want to buid a *secret* site, after taking a look around i found that Zend framework has a neat library providing many classes that i need. Take a look of this [...]]]></description>
			<content:encoded><![CDATA[<p>My current favorite php framework is <a href="http://kohanaphp.com/" title="kohana">kohana</a>. After several weeks playing with it, i feel that KohanaPhp far exceed CakePHP and CodeIgniter. Now i want to buid a *secret* site, after taking a look around i found that <a href="http://framework.zend.com/" title="zend framework">Zend</a> framework has a neat library providing many classes that i need. Take a look of this list, you'll get the idea:</p>
<ul>
<li> Zend_Acl</li>
<li> Zend_Captcha</li>
<li> Zend_Feed</li>
<li> Zend_Gdata</li>
<li> Zend_Http</li>
<li> Zend_OpenId</li>
<li> Zend_Pdf</li>
<li> Zend_Rest</li>
<li> Zend_Service_Akismet</li>
<li> Zend_Service_Amazon</li>
<li> Zend_Service_Audioscrobbler</li>
<li> Zend_Service_Delicious</li>
<li> Zend_Service_Flickr</li>
<li> Zend_Service_Nirvanix</li>
<li> Zend_Service_ReCaptcha</li>
<li> Zend_Service_Simpy</li>
<li> Zend_Service_SlideShare</li>
<li> Zend_Service_StrikeIron</li>
<li> Zend_Service_Technorati</li>
<li> Zend_Service_Twitter</li>
<li> Zend_Service_Yahoo</li>
</ul>
<p>I really love it, but i don't like zend framework itself. So i search around and found this <a href="http://www.beyondcoding.com/2008/02/21/using-zend-framework-with-codeigniter/">cool tutorial</a>.</p>
<p>It gives cool trick but doesn't work well, so i modify a bit.</p>
<p>Put the 'Zend' folder (unpacked from the Zend Framework package, under 'Library/') in Kohana installation's '<strong>application/vendors/Zend</strong>' folder</p>
<p>Copy code below and paste it to a new file called <strong>Zend.php </strong>in <strong>application/libraries/</strong>.</p>
<div class="igBar"><span id="lphp-5"><a href="#" onclick="javascript:showPlainTxt('php-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-5">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">* Zend Framework Loader</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">*</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">* Put the 'Zend' folder (unpacked from the Zend Framework package, under 'Library/')</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">* in Kohana installation's 'application/vendors/Zend' folder</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">* You can put it elsewhere but remember to alter the script accordingly</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">*</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">* Usage:</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">*&nbsp; &nbsp;Zend::instance('Zend/Package/Name');</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">*&nbsp; &nbsp;Zend::instance('Zend/Service/Yahoo');</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">*</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">* * the second usage is useful for autoloading the Zend Framework library</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">* * Zend/Package/Name does not need the '.php' at the end</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">*/</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> Zend</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">* Returns a singleton instance of URI.</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">*</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">* @return&nbsp; object</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">*/</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public <a href="http://www.php.net/static"><span style="color:#000066;">static</span></a> <span style="color:#000000; font-weight:bold;">function</span> instance<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$class</span> = <span style="color:#000000; font-weight:bold;">NULL</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/static"><span style="color:#000066;">static</span></a> <span style="color:#0000FF;">$instance</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Create the singleton</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$instance</span> == <span style="color:#000000; font-weight:bold;">NULL</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Initialize the URI instance</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$instance</span> = <span style="color:#000000; font-weight:bold;">new</span> Zend<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$class</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#616100;">else</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$instance</span>-&amp;gt;load<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$class</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">return</span> <span style="color:#0000FF;">$instance</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">* Constructor</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">*</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">* @param&nbsp; &nbsp; string $class class name</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">*/</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> __construct<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$class</span> = <span style="color:#000000; font-weight:bold;">NULL</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// include path for Zend Framework</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// alter it accordingly if you have put the 'Zend' folder elsewhere</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/ini_set"><span style="color:#000066;">ini_set</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'include_path'</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/ini_get"><span style="color:#000066;">ini_get</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'include_path'</span><span style="color:#006600; font-weight:bold;">&#41;</span> . PATH_SEPARATOR . APPPATH . <span style="color:#FF0000;">'vendors'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$class</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">require_once</span> <span style="color:#006600; font-weight:bold;">&#40;</span>string<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#0000FF;">$class</span> . EXT;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//Log::add('debug', &quot;Zend Class $class Loaded&quot;);</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">else</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//Log::add('debug', &quot;Zend Class Initialized&quot;);</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/**</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">* Zend Class Loader</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">*</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">* @param&nbsp; &nbsp; string $class class name</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">*/</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> load<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$class</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">require_once</span> <span style="color:#006600; font-weight:bold;">&#40;</span>string<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#0000FF;">$class</span> . EXT;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//Log::add('debug', &quot;Zend Class $class Loaded&quot;);</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Do you have trouble figuring out how to use it?<br />
See an example below, you'll get a nice grab just within seconds:</p>
<div class="igBar"><span id="lphp-6"><a href="#" onclick="javascript:showPlainTxt('php-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-6">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> Welcome_Controller extends Controller <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public <span style="color:#000000; font-weight:bold;">function</span> index<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$zend</span> = Zend::<span style="color:#006600;">instance</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Zend/Service/Yahoo'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$yahoo</span> = <span style="color:#000000; font-weight:bold;">new</span> Zend_Service_Yahoo<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'zendtesting'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$keywords</span> = <span style="color:#FF0000;">"kitty"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$results</span> = <span style="color:#0000FF;">$yahoo</span>-&amp;gt;imageSearch<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$keywords</span>, <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"results"</span> =&amp;gt; <span style="color:#CC66CC;color:#800000;">5</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$results</span>-&amp;gt;totalResults<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>&amp;gt; <span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#FF0000;">'</span></div>
</li>
<li style="font-weight: bold;color:#26536A;"></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&lt;p id=&quot;image&quot;&gt;'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#FF0000;">'</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&lt;h2&gt;Image Search Results&lt;/h2&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">foreach</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$results</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$result</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#FF0000;">"&lt;a href="</span>http:<span style="color:#FF9933; font-style:italic;">//php.fallenray.com/wp-admin/%7B$result-%3EClickUrl%7D&quot; title=&quot;$result-&amp;gt;Title&quot;&gt;&lt;img src=&quot;http://php.fallenray.com/wp-admin/%7B$result-%3EThumbnail-%3EUrl-%3EgetUri%28%29%7D&quot; /&gt;&lt;/a&gt;&quot;;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#FF0000;">'</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"></li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Another way to do this also posted as an <a href="http://www.beyondcoding.com/2008/11/14/using-zend-framework-with-kohana/">updated tutorial</a>. Things are getting much simpler now. I still liked my own twisted approach though :p</p>
<p>Also you might want to check out the <a href="http://docs.kohanaphp.com/general/libraries#zend_framework">official tutorial</a>.</p>
<p>Happy ending, i can use the best PHP5 frameworks along with the best PHP5 library. It cannot get better than this. Try it, if you miss this you'll be sorry.</p>
]]></content:encoded>
			<wfw:commentRss>http://twilightseo.fallenray.com/php5/kohana-and-zend-killer-combo-the-best-php5-framework-and-library-in-one-package/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP5: Screen scraping with DOM and XPath</title>
		<link>http://twilightseo.fallenray.com/php5/php5-screen-scraping-with-dom-and-xpath/</link>
		<comments>http://twilightseo.fallenray.com/php5/php5-screen-scraping-with-dom-and-xpath/#comments</comments>
		<pubDate>Thu, 06 Mar 2008 07:09:00 +0000</pubDate>
		<dc:creator>ruru</dc:creator>
		
		<category><![CDATA[php5]]></category>

		<guid isPermaLink="false">http://php.fallenray.com/php5/php5-screen-scraping-with-dom-and-xpath/</guid>
		<description><![CDATA[This tutorial is continuation from previous yahoo screen-scraping using PHP4 tutorial.
We will try different method using DOM and XPath which only supported in PHP5.
First, a bit knowledge of XPath is required. More about XPATH can be read on:
http://www.zvon.org/xxl/XPathTutorial/General/examples.html
Also there's small concern that using XPATH is a bit slower than pure DOM Traversal. Read Speed: DOM [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial is continuation from previous <a href="/php4/php4-how-to-steal-from-yahoo-another-web-screen-scraper/">yahoo screen-scraping using PHP4 tutorial</a>.<br />
We will try different method using DOM and XPath which only supported in PHP5.</p>
<p>First, a bit knowledge of XPath is required. More about XPATH can be read on:<br />
http://www.zvon.org/xxl/XPathTutorial/General/examples.html</p>
<p>Also there's small concern that using XPATH is a bit slower than pure DOM Traversal. Read <a rel="external nofollow" href="http://www.sklar.com/blog/archives/85-Speed-DOM-traversal-vs.-XPath-in-PHP-5.html">Speed: DOM traversal vs. XPath in PHP 5</a><br />
But i personally also think that XPath is neat and easier.</p>
<p>Let's start. First we diagnose document structure using Mozilla Firebug.<br />
Try a very easy case, which is to grab the title "Top Movies":<br />
<img src="http://php.fallenray.com/wp-content/uploads/2008/03/xpath-example-1.png" alt="" border="0"><br />
Copy XPath using Firebug and get this query:</p>
<blockquote><p>
/html/body/center/table[8]/tbody/tr/td[5]/table[4]/tbody/tr/td/font/b
</p></blockquote>
<ol>
<li>Firefox automatically fix broken html structure, and it also add <b>tbody</b> tag. So, we need to remove this tag.</li>
<li>Only grab <b>first row</b> of table. Change .../<b>tr</b>/td/font/b into .../<b>tr[1]</b>/td/font/b</li>
</ol>
<p>Now we get our first XPath query:</p>
<blockquote><p>
/html/body/center/table[8]/tr/td[5]/table[4]/tr[1]/td/font
</p></blockquote>
<p>Next harder case is to grab contents.<br />
<img src="http://php.fallenray.com/wp-content/uploads/2008/03/xpath-example-2.png" alt="" border="0"><br />
XPath query from Firebug is:</p>
<blockquote><p>
/html/body/center/table[8]/tbody/tr/td[5]/table[4]/tbody/tr[2]/td[2]/a/font/b
</p></blockquote>
<ol>
<li>Same problem here. Firefox automatically fix broken html structure, and it also add <b>tbody</b> tag. Remove <b>tbody</b> tag from XPath query.</li>
<li>Grab <b>all row</b> of table. Change .../<b>tr[2]</b>/td[2]/a/font/b into .../<b>tr</b>/td[2]/a/font/b</li>
</ol>
<p>Final XPath query for content is:</p>
<blockquote><p>
/html/body/center/table[8]/tr/td[5]/table[4]/tr/td[2]/a/font/b
</p></blockquote>
<p>Now final step is to put all two XPath queries into few lines of code, and we're done:</p>
<div class="igBar"><span id="lphp-8"><a href="#" onclick="javascript:showPlainTxt('php-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-8">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/error_reporting"><span style="color:#000066;">error_reporting</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#000000; font-weight:bold;">E_ERROR</span><span style="color:#006600; font-weight:bold;">&#41;</span>;<span style="color:#FF9933; font-style:italic;">// | E_WARNING | E_PARSE);</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">include</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Snoopy.class.php'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$snooper</span> = <span style="color:#000000; font-weight:bold;">new</span> Snoopy<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$snooper</span>-&gt;<span style="color:#006600;">fetch</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'http://movies.yahoo.com/mv/boxoffice/'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$dom</span> = <span style="color:#000000; font-weight:bold;">new</span> DomDocument<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$dom</span>-&gt;<span style="color:#006600;">loadHTML</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$snooper</span>-&gt;<span style="color:#006600;">results</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$x</span> = <span style="color:#000000; font-weight:bold;">new</span> DomXPath<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$dom</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">//&nbsp; /html/body/center/table[8]/tbody/tr/td[5]/table[4]/tbody/tr/td/font/b</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$nodes</span> = <span style="color:#0000FF;">$x</span>-&gt;<span style="color:#006600;">query</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'/html/body/center/table[8]/tr/td[5]/table[4]/tr[1]/td/font/b'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$nodes</span>-&gt;<span style="color:#006600;">item</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span>-&gt;<span style="color:#006600;">nodeValue</span>, <span style="color:#FF0000;">"&lt;br/&gt;<span style="color:#000099; font-weight:bold;">\n</span>"</span>; <span style="color:#FF9933; font-style:italic;">//Top Movies</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">//&nbsp; /html/body/center/table[8]/tbody/tr/td[5]/table[4]/tbody/tr[2]/td[2]/a/font/b</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$nodes</span> = <span style="color:#0000FF;">$x</span>-&gt;<span style="color:#006600;">query</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'/html/body/center/table[8]/tr/td[5]/table[4]/tr/td[2]/a/font/b'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">foreach</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$nodes</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$node</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$node</span>-&gt;<span style="color:#006600;">nodeValue</span>, <span style="color:#FF0000;">"&lt;br/&gt;<span style="color:#000099; font-weight:bold;">\n</span>"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><!-- technorati tags begin --></p>
<p style="font-size: 10px; text-align: right;">Tags: <a href="http://technorati.com/tag/php5" rel="tag nofollow">php5</a>, <a href="http://technorati.com/tag/cakephp" rel="tag nofollow">screen scraping</a>, <a href="http://technorati.com/tag/code+example" rel="tag nofollow">code example</a></p>
<p><!-- technorati tags end --></p>
]]></content:encoded>
			<wfw:commentRss>http://twilightseo.fallenray.com/php5/php5-screen-scraping-with-dom-and-xpath/feed/</wfw:commentRss>
		</item>
		<item>
		<title>CakePHP: How to add Search Engine Friendly (SEF) URLs</title>
		<link>http://twilightseo.fallenray.com/cakephp/cakephp-how-to-add-search-engine-friendly-sef-urls/</link>
		<comments>http://twilightseo.fallenray.com/cakephp/cakephp-how-to-add-search-engine-friendly-sef-urls/#comments</comments>
		<pubDate>Mon, 18 Feb 2008 13:43:08 +0000</pubDate>
		<dc:creator>ruru</dc:creator>
		
		<category><![CDATA[cakephp]]></category>

		<guid isPermaLink="false">http://php.fallenray.com/cakephp/cakephp-how-to-add-search-engine-friendly-sef-urls/</guid>
		<description><![CDATA[How many times you wondered how great it would be if your URLs didn't look so much like:
http://www.server.com/posts/view/1058
But more like:
http://www.server.com/posts/view/my_first_post
Read the rest on:
http://bakery.cakephp.org/articles/view/adding-friendly-urls-to-the-cake-blog-tutorial
]]></description>
			<content:encoded><![CDATA[<p>How many times you wondered how great it would be if your URLs didn't look so much like:<br />
http://www.server.com/posts/view/1058</p>
<p>But more like:<br />
http://www.server.com/posts/view/my_first_post</p>
<p>Read the rest on:<br />
http://bakery.cakephp.org/articles/view/adding-friendly-urls-to-the-cake-blog-tutorial</p>
]]></content:encoded>
			<wfw:commentRss>http://twilightseo.fallenray.com/cakephp/cakephp-how-to-add-search-engine-friendly-sef-urls/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
