<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>World Gone WebPHP &#187; World Gone Web</title>
	<atom:link href="http://www.worldgoneweb.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.worldgoneweb.com</link>
	<description></description>
	<lastBuildDate>Sun, 09 Oct 2011 20:57:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Using WordPress Hooks by Example &#8211; hiding a category</title>
		<link>http://www.worldgoneweb.com/2011/using-wordpress-hooks-by-example-hiding-a-specific-category/</link>
		<comments>http://www.worldgoneweb.com/2011/using-wordpress-hooks-by-example-hiding-a-specific-category/#comments</comments>
		<pubDate>Sat, 26 Mar 2011 11:08:33 +0000</pubDate>
		<dc:creator>shalfon</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Me myself I]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[category]]></category>
		<category><![CDATA[customization]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[hooks]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[world gone web]]></category>

		<guid isPermaLink="false">http://www.worldgoneweb.com/?p=644</guid>
		<description><![CDATA[The plugin used on the homepage of this blog to display featured articles is called Related Posts with Thumbs. It will display the last X posts published in a given category. For flexibility, I created a categoruy called &#8220;Editorial&#8221; for the posts which should be displayed with the plugin. The problem was : I didn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.worldgoneweb.com/wp-content/uploads/2011/03/wordpress_codex.png"><img class="alignleft size-thumbnail wp-image-645" title="wordpress_codex" src="http://www.worldgoneweb.com/wp-content/uploads/2011/03/wordpress_codex-150x150.png" alt="" width="150" height="150" /></a>The plugin used on the homepage of this blog to display featured articles is called <a href="http://www.hackingethics.com/blog/wordpress-plugins/igit-related-posts-with-thumb-image-after-posts/">Related Posts with Thumbs</a>. It will display the last X posts published in a given category. For flexibility, I created a categoruy called &#8220;Editorial&#8221; for the posts which should be displayed with the plugin. The problem was : I didn&#8217;t want this category to appear anywhere else. That is, this category shoulnd&#8217;t appear in the category list (in the left sidebar) or on the Archives Page. It should also be excluded from the post metadata&#8230; As I worked on this, I decided to also hide the &#8220;Uncategorized&#8221; category.</p>
<p>In order to accomplish this, I studied WordPress hooks. WordPress hooks are small functions customizable in one&#8217;s WordPress theme which will be called by WordPress core code. The reason behind hooks is to enable some custom code to be called in a given theme, plugin or widget, without modifying the WordPress core code which will be erased every time we upgrade our blog to the newest version of WordPress.</p>
<p style="text-align: center;"><a href="http://www.worldgoneweb.com/wp-content/uploads/2011/03/Screen-shot-2011-03-26-at-12.01.46-PM.png"><img class="aligncenter size-full wp-image-647" title="Screen shot 2011-03-26 at 12.01.46 PM" src="http://www.worldgoneweb.com/wp-content/uploads/2011/03/Screen-shot-2011-03-26-at-12.01.46-PM.png" alt="" width="560" height="477" /></a></p>
<h2>Hiding a category from the post metadata:</h2>
<p>The post category at the end of a post are displayed using the following method : <strong>the_category()</strong>. This method is defined in <strong>wp-includes/category-template.php</strong>. This method calls <strong>get_the_category_list()</strong>, itself defined in the same file. This function gets the category list by calling <strong>get_the_category()</strong> also defined in this category-template.php file. Now, the important part is that this method get_the_category calls a custom filter named <strong>get_the_categories</strong>.</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:678px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> get_the_category<span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #339933;">....</span><br />
<span style="color: #b1b100;">return</span> apply_filters<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'get_the_categories'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$categories</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Let&#8217;s enable the filter get_the_categories and use it to skip the &#8220;Editorial&#8221; category. We will do that by editing (or creating) the <strong>functions.php</strong> file of the blog&#8217;s theme file.</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:678px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">// We enable the filter</span><br />
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'get_the_categories'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'hideCategories'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #666666; font-style: italic;">// The filter method (it hides the Editorial category, but you can change that to suit you rneeds</span><br />
<span style="color: #000000; font-weight: bold;">function</span> hideCategories<span style="color: #009900;">&#40;</span><span style="color: #000088;">$categories</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_admin<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$categories</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$resCategories</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$categories</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$category</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$category</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>name <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;Editorial&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$resCategories</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$category</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$resCategories</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Notice that we will not skip the category if we are logged in as super admin (that is to let the category appear in the administration panel)</p>
<h2>Hiding a category from the category widget :</h2>
<p>The same solution applies to the category widget. After identifying the method used by the category widget which is Walker_CategoryDropdown in the same wp-includes/category-templates.php file, it is clear it calls the list_cats filter somehwere down the road (in start_el). The only problem was, if the category was filtered out in the apply_filter method, it would display an empty line. Therefore, I submitted the <a href="http://core.trac.wordpress.org/ticket/16792#comment:1">following patch</a> to the wordpress team.</p>
<p>In functions.php (in our blog&#8217;s theme folder)</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:678px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">// Apply the filter</span><br />
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'list_cats'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'hideCat'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #666666; font-style: italic;">// The filter code</span><br />
<span style="color: #000000; font-weight: bold;">function</span> hideCat<span style="color: #009900;">&#40;</span><span style="color: #000088;">$catName</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_admin<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$catName</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$catName</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;Editorial&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$catName</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;Uncategorized&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$catName</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>If you wish to use this code, <a href="http://samanthahalfon.net/resources/patchCategoryWalkerSkippedCategory.patch">download</a> and apply the patch (tested on WordPress 3.1) I hope the patch will make into the later versions by the WordPress dev team.</p>
<p>&nbsp;</p>
<p>I hope this example of use of hooks and filters will enable you to create your own custom code for WordPress. Happy coding <img src='http://www.worldgoneweb.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>&nbsp;</p>
<h2>References:</h2>
<p>Below are great articles about WordPress development in general and WordPress hooks in particular</p>
<ul>
<li><a href="http://www.wordpresscreme.com/best-practices-for-wordpress-coding/">Best practices for WordPress coding</a></li>
<li><a href="http://codex.wordpress.org/Plugin_API#Hooks.2C_Actions_and_Filters">Hooks, Actions and Filters</a> (WordPress codex)</li>
<li><a href="http://www.smashingmagazine.com/2009/08/18/10-useful-wordpress-hook-hacks/">How to Use Hooks on your WordPress Blog</a> (Smashing Magazine)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.worldgoneweb.com/2011/using-wordpress-hooks-by-example-hiding-a-specific-category/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:thumbnail url="http://www.worldgoneweb.com/wp-content/uploads/2011/03/wordpress_codex-150x150.png" />
		<media:content url="http://www.worldgoneweb.com/wp-content/uploads/2011/03/wordpress_codex.png" medium="image">
			<media:title type="html">wordpress_codex</media:title>
			<media:thumbnail url="http://www.worldgoneweb.com/wp-content/uploads/2011/03/wordpress_codex-150x150.png" />
		</media:content>
		<media:content url="http://www.worldgoneweb.com/wp-content/uploads/2011/03/Screen-shot-2011-03-26-at-12.01.46-PM.png" medium="image">
			<media:title type="html">Screen shot 2011-03-26 at 12.01.46 PM</media:title>
			<media:thumbnail url="http://www.worldgoneweb.com/wp-content/uploads/2011/03/Screen-shot-2011-03-26-at-12.01.46-PM-150x150.png" />
		</media:content>
	</item>
		<item>
		<title>Detect Links in a text content with PHP</title>
		<link>http://www.worldgoneweb.com/2011/detect-links-in-a-text-content-with-php/</link>
		<comments>http://www.worldgoneweb.com/2011/detect-links-in-a-text-content-with-php/#comments</comments>
		<pubDate>Tue, 08 Mar 2011 21:21:31 +0000</pubDate>
		<dc:creator>shalfon</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[preg_replace]]></category>
		<category><![CDATA[regexp]]></category>
		<category><![CDATA[regular expressions]]></category>
		<category><![CDATA[uri]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://www.worldgoneweb.com/?p=638</guid>
		<description><![CDATA[Here&#8217;s a quick code snipet allowing to parse some content (a string), detect the URLs it can contain and make them clickable links. The method uses preg_replace and a regular expression to detect URLs. 123function detectLinks&#40;$content&#41; &#123; return preg_replace&#40;'/\s((http&#124;https&#124;ftp&#124;ftps)\:\/\/[a-zA-Z0-9\-\.\/]+\.[a-zA-Z\/]{2,3}(\/\S*)?)/', '&#60;a href=&#34;${1}&#34;&#62;${1}&#60;/a&#62;', $content&#41;; &#125; &#160; Let&#8217;s test this snipet by doing : 12$content = &#34;This is [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.worldgoneweb.com/wp-content/uploads/2011/03/Web-Internet-Spider.jpg"><img class="alignleft size-thumbnail wp-image-639" title="Web-Internet-Spider" src="http://www.worldgoneweb.com/wp-content/uploads/2011/03/Web-Internet-Spider-150x150.jpg" alt="" width="150" height="150" /></a><br />
Here&#8217;s a quick code snipet allowing to parse some content (a string), detect the URLs it can contain and make them clickable links. The method uses preg_replace and a regular expression to detect URLs.</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:678px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> detectLinks<span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #b1b100;">return</span> <a href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/\s((http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.\/]+\.[a-zA-Z\/]{2,3}(\/\S*)?)/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;a href=&quot;${1}&quot;&gt;${1}&lt;/a&gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>&nbsp;</p>
<p>Let&#8217;s test this snipet by doing :</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:678px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;This is a sample text containing a link to my blog http://www.worlgoneweb.com and a link to my flickr photos http://www.flickr.com/photos/worldwideangle as well as an incomplete www.wwangle.com URI which won't be detected. It also contains a clickable link to &amp;lt;a href='http://www.samanthahalfon.net'&amp;gt;my profile site&amp;lt;/a&amp;gt; which must not be processed either.&quot;</span><span style="color: #339933;">;</span><br />
<a href="http://www.php.net/print_r"><span style="color: #990000;">print_r</span></a><span style="color: #009900;">&#40;</span>detectLinks<span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>&nbsp;</p>
<p>This will output the following text :</p>
<blockquote><p>is a sample text containing a link to my blog<a href="http://www.worldgoneweb.com">http://www.worldgoneweb.com</a> and a link to my flickr photos<a href="http://www.flickr.com/photos/worldwideangle">http://www.flickr.com/photos/worldwideangle</a> as well as an incomplete www.wwangle.com URI which won&#8217;t be detected. It also contains a clickable link to <a href="http://www.samanthahalfon.net">my profile site</a> which must not be processed either.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.worldgoneweb.com/2011/detect-links-in-a-text-content-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:thumbnail url="http://www.worldgoneweb.com/wp-content/uploads/2011/03/Web-Internet-Spider-150x150.jpg" />
		<media:content url="http://www.worldgoneweb.com/wp-content/uploads/2011/03/Web-Internet-Spider.jpg" medium="image">
			<media:title type="html">Web-Internet-Spider</media:title>
			<media:thumbnail url="http://www.worldgoneweb.com/wp-content/uploads/2011/03/Web-Internet-Spider-150x150.jpg" />
		</media:content>
	</item>
		<item>
		<title>PHP: Working with the YouTube API with Zend Framework</title>
		<link>http://www.worldgoneweb.com/2011/php-working-with-the-youtube-api-with-zend-framework/</link>
		<comments>http://www.worldgoneweb.com/2011/php-working-with-the-youtube-api-with-zend-framework/#comments</comments>
		<pubDate>Sat, 05 Mar 2011 08:30:25 +0000</pubDate>
		<dc:creator>shalfon</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[YouTube]]></category>
		<category><![CDATA[zend]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.worldgoneweb.com/?p=615</guid>
		<description><![CDATA[The YouTube API allows a user to retrieve a lot of information about an user&#8217;s profile and his videos (his uploads, his favorite videos). For each of these videos, it also allows to retrieve a lot of information like duration, keywords, comments and trackbacks&#8230; These information are accessible without the need of an API key. [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://www.worldgoneweb.com/wp-content/uploads/2011/03/Screen-shot-2011-03-05-at-9.26.43-AM.png"><img class="aligncenter size-full wp-image-616" title="YouTube Shelby Mustang" src="http://www.worldgoneweb.com/wp-content/uploads/2011/03/Screen-shot-2011-03-05-at-9.26.43-AM.png" alt="" width="369" height="289" /></a></p>
<p>The <a title="YouTube API" href="http://code.google.com/intl/fr/apis/youtube/overview.html">YouTube API</a> allows a user to retrieve a lot of information about an user&#8217;s profile and his videos (his uploads, his favorite videos). For each of these videos, it also allows to retrieve a lot of information like duration, keywords, comments and trackbacks&#8230; These information are accessible without the need of an API key. Most of these information can also be set though this time (to write) an API key will be needed.</p>
<p>The<a title="Zend Framework" href="http://framework.zend.com/"> Zend Framework</a> offers a serie of classes in its <a title="Zend Framework GData" href="http://framework.zend.com/manual/en/zend.gdata.html">GData</a> (Google Data) module and a few of them are aimed at working with <a title="Zend Framework Gdata for youTube" href="http://framework.zend.com/manual/en/zend.gdata.youtube.html">youTube</a>. These GData classes are well written and very staraightforward to use.</p>
<p>Here is a simple example of code to get information for a given video about the <a title="Mustang Shelby GT500 2005" href="http://www.youtube.com/watch?v=_YTYaB7fP-A">Mustang Shelby GT500 2005</a>. Out of the <a href="http://www.youtube.com/watch?v=_YTYaB7fP-A">URL</a>, you can easily extract the video id: <strong>_YTYaB7fP-A</strong></p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:678px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># Include the Gdata_YouTube class<br />
</span><span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'Zend/Gdata/YouTube.php'</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$yt</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Gdata_YouTube<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># Declare the videoId<br />
</span><span style="color: #000088;">$videoId</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'videoIds'</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">#Get the video entry calling the YouTube API<br />
</span><span style="color: #000088;">$videoEntry</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$yt</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getVideoEntry</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$videoId</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># Now what we have a Video Entry Object, we can use the methods declared in the VideoEntry Class (in the Zend GData module)<br />
</span><span style="color: #666666; font-style: italic;"># to obtain information about the video<br />
</span><span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;VideoId: &lt;strong&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$videoId</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/strong&gt;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Title: &lt;strong&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$videoEntry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getVideoTitle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/strong&gt;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Duration: &lt;strong&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$videoEntry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getVideoDuration</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; seconds&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Description: &lt;br /&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$videoEntry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getVideoDescription</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br /&gt;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Keywords: &lt;br /&gt;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <a href="http://www.php.net/implode"><span style="color: #990000;">implode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$videoEntry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getVideoTags</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">', '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;br /&gt;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Can Be embeded: &lt;strong&gt;&quot;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">echo</span> <span style="color: #339933;">!</span><span style="color: #000088;">$videoEntry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getNoEmbed</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$videoEntry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getNoEmbed</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> Zend_Gdata_YouTube_Extension_NoEmbed ? <span style="color: #0000ff;">&quot;true&quot;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;false&quot;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/strong&gt;&lt;/br /&gt;&quot;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Watch: &lt;a href='&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$videoEntry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getVideoWatchPageUrl</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;'&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$videoEntry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getVideoWatchPageUrl</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/a&gt;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;URL: &lt;a href='&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$videoEntry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getFlashPlayerUrl</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;'&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$videoEntry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getFlashPlayerUrl</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Thumb: &lt;br /&gt;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$thumbs</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$videoEntry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getVideoThumbnails</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>    <span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_array"><span style="color: #990000;">is_array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$thumbs</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$thumbs</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$thumbs</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$thumb</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;img width=&quot;200&quot; src=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$thumb</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; /&gt;'</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.worldgoneweb.com/2011/php-working-with-the-youtube-api-with-zend-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:thumbnail url="http://www.worldgoneweb.com/wp-content/uploads/2011/03/Screen-shot-2011-03-05-at-9.26.43-AM-150x150.png" />
		<media:content url="http://www.worldgoneweb.com/wp-content/uploads/2011/03/Screen-shot-2011-03-05-at-9.26.43-AM.png" medium="image">
			<media:title type="html">YouTube Shelby Mustang</media:title>
			<media:thumbnail url="http://www.worldgoneweb.com/wp-content/uploads/2011/03/Screen-shot-2011-03-05-at-9.26.43-AM-150x150.png" />
		</media:content>
	</item>
		<item>
		<title>ZendServer Community Edition on Mac OS X: compiling PHP extensions</title>
		<link>http://www.worldgoneweb.com/2011/zendserver-community-edition-on-mac-os-x-compiling-php-extensions/</link>
		<comments>http://www.worldgoneweb.com/2011/zendserver-community-edition-on-mac-os-x-compiling-php-extensions/#comments</comments>
		<pubDate>Sat, 29 Jan 2011 15:53:11 +0000</pubDate>
		<dc:creator>shalfon</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Système]]></category>
		<category><![CDATA[memcache]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[pecl]]></category>
		<category><![CDATA[phpinfo]]></category>
		<category><![CDATA[phpize]]></category>
		<category><![CDATA[Zend Server]]></category>

		<guid isPermaLink="false">http://www.worldgoneweb.com/?p=524</guid>
		<description><![CDATA[This post aims to explain how to compile a PHP extension for ZendServer CE on Mac OS X based on my experience with the memcache extension. As it turns out, the memcache extension included in ZendServer CE 5.0.4 is version 2.2.5 which doesn&#8217;t work with the latest version of the memcached server insatlled by macposts [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.worldgoneweb.com/wp-content/uploads/2011/01/phpicon.png"><img class="alignleft size-thumbnail wp-image-530" title="phpicon" src="http://www.worldgoneweb.com/wp-content/uploads/2011/01/phpicon-150x150.png" alt="" width="150" height="150" /></a>This post aims to explain how to compile a PHP extension for ZendServer CE on Mac OS X based on my experience with the memcache extension. As it turns out, the memcache extension included in ZendServer CE 5.0.4 is version 2.2.5 which doesn&#8217;t work with the latest version of the memcached server insatlled by macposts as detailed in <a title="Installing Memcached with MacPorts" href="http://www.worldgoneweb.com/2011/install-and-query-memcache-on-mac-os-x/">my earlier post about memcached</a>. I had to build the memcache.so extension version 2.6 using pecl. Here&#8217;s how</p>
<ul>
<li>go to /usr/local/zend/lib/php_extensions and backup your memcache.so file in memcache.so.bak</li>
<li>go to /tmp and extract libmemcached which you can download from the <a href="https://launchpad.net/libmemcached/+download">libmemcached website</a></li>
<li>go to the extracted directory named libmemcached-0.44 and install the library</li>
</ul>
<div class="codecolorer-container bash dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:678px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-xvzf</span> libmemcahed-<span style="color: #000000;">0.44</span>.tar.gz<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> libmemcached-<span style="color: #000000;">0.44</span><br />
.<span style="color: #000000; font-weight: bold;">/</span>configure ; <span style="color: #c20cb9; font-weight: bold;">make</span><br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></div></td></tr></tbody></table></div>
<ul>
<li>now, still being in /tmp, using pecl and phpize, download and install memcache</li>
</ul>
<div class="codecolorer-container bash dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:678px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>zend<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>pecl download memcache<br />
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-xvzf</span> memcache-2.2.6<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> memcache-2.2.6<br />
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>zend<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>phpize<br />
<span style="color: #666666; font-style: italic;">#configure using the php-config of Zend Server AND forcing the architecture to 32bits as it is what was used to compile the ZendServer</span><br />
.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--with-php-config</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>zend<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php-config  <span style="color: #007800;">MACOSX_DEPLOYMENT_TARGET</span>=<span style="color: #000000;">10.6</span> <span style="color: #007800;">CFLAGS</span>=<span style="color: #ff0000;">&quot;-arch i386 -g -Os -pipe -no-cpp-precomp&quot;</span> <span style="color: #007800;">CCFLAGS</span>=<span style="color: #ff0000;">&quot;-arch i386 -g -Os -pipe&quot;</span> <span style="color: #007800;">CXXFLAGS</span>=<span style="color: #ff0000;">&quot;-arch i386 -g -Os -pipe&quot;</span> <span style="color: #007800;">LDFLAGS</span>=<span style="color: #ff0000;">&quot;-arch i386 -bind_at_load&quot;</span><br />
<span style="color: #c20cb9; font-weight: bold;">make</span><br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></div></td></tr></tbody></table></div>
<ul>
<li>Enable the extension in your php.ini by uncommenting the line extension=memcache.so</li>
<li>Restart Apache</li>
</ul>
<div class="codecolorer-container bash dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:678px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>zend<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>apachectl restart</div></td></tr></tbody></table></div>
<ul>
<li>Go to a phpinfo page to make sure the extension memcache was installed</li>
</ul>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-526" title="Memcache phpinfo" src="http://www.worldgoneweb.com/wp-content/uploads/2011/01/Screen-shot-2011-01-29-at-3.57.02-PM.png" alt="" width="384" height="193" /></p>
<p style="text-align: left;">This should work for most extensions available in the <a title="pecl" href="http://pecl.php.net/">PECL library</a>.</p>
<p style="text-align: left;"><strong>External Links</strong></p>
<ul>
<li><a href="http://akrabat.com/php/some-notes-on-zend-server-ce-for-mac-os-x/">Some notes on Zend Server CE for Mac OS X</a></li>
<li><a href="http://www.glenscott.co.uk/blog/2009/08/30/install-memcached-php-extension-on-os-x-snow-leopard/">Installing memcached PHP extension on OS X Snow Leopard</a></li>
<li><a href="http://devzone.zend.com/article/4512">Compiling PHP extensions with Zend Server</a></li>
</ul>
<p style="text-align: left;">&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.worldgoneweb.com/2011/zendserver-community-edition-on-mac-os-x-compiling-php-extensions/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:thumbnail url="http://www.worldgoneweb.com/wp-content/uploads/2011/01/phpicon-150x150.png" />
		<media:content url="http://www.worldgoneweb.com/wp-content/uploads/2011/01/phpicon.png" medium="image">
			<media:title type="html">phpicon</media:title>
			<media:thumbnail url="http://www.worldgoneweb.com/wp-content/uploads/2011/01/phpicon-150x150.png" />
		</media:content>
		<media:content url="http://www.worldgoneweb.com/wp-content/uploads/2011/01/Screen-shot-2011-01-29-at-3.57.02-PM.png" medium="image">
			<media:title type="html">Memcache phpinfo</media:title>
			<media:thumbnail url="http://www.worldgoneweb.com/wp-content/uploads/2011/01/Screen-shot-2011-01-29-at-3.57.02-PM-150x150.png" />
		</media:content>
	</item>
		<item>
		<title>Install and query Memcache on Mac OS X</title>
		<link>http://www.worldgoneweb.com/2011/install-and-query-memcache-on-mac-os-x/</link>
		<comments>http://www.worldgoneweb.com/2011/install-and-query-memcache-on-mac-os-x/#comments</comments>
		<pubDate>Wed, 19 Jan 2011 21:12:17 +0000</pubDate>
		<dc:creator>shalfon</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[load]]></category>
		<category><![CDATA[macports]]></category>
		<category><![CDATA[memcache]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[telnet]]></category>

		<guid isPermaLink="false">http://www.worldgoneweb.com/?p=481</guid>
		<description><![CDATA[Memcached if a free and open source distributed memory object caching system. It is used by web applications to lower database load by caching data in a key-value format for faster retrieval. If you happen to develop on Mac OS X, you can easily setup a development memcached server locally using MacPorts. 1sudo port install [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.worldgoneweb.com/wp-content/uploads/2011/01/memcache.jpg"><img class="alignleft size-thumbnail wp-image-482" title="memcache" src="http://www.worldgoneweb.com/wp-content/uploads/2011/01/memcache-150x150.jpg" alt="" width="150" height="150" /></a> <a title="Memcached.org" href="http://memcached.org/">Memcached</a> if a free and open source distributed memory object caching system. It is used by web applications to lower database load by caching data in a key-value format for faster retrieval. If you happen to develop on Mac OS X, you can easily setup a development memcached server locally using <a href="http://www.macports.org/">MacPorts</a>.</p>
<div class="codecolorer-container bash dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:678px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> port <span style="color: #c20cb9; font-weight: bold;">install</span> memcached</div></td></tr></tbody></table></div>
<p>Easy enough&#8230; Now, you can start the server by running</p>
<div class="codecolorer-container bash dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:678px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">memcached <span style="color: #660033;">-vv</span></div></td></tr></tbody></table></div>
<p>Memcached is listening on port 11211.</p>
<p>One thing that memcached is used for is storing PHP sessions (memcached is distributed, rememer?) In order to do that, you must edit php.ini and set</p>
<div class="codecolorer-container ini dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:678px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="ini codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">session.save_handler <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> memcache</span><br />
session.save_path <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> tcp://localhost:11211</span></div></td></tr></tbody></table></div>
<p>Don&#8217;t forget to enable the memcahe.so extension and restart your Apache server.</p>
<p>Now, you can start storing data in memcache from your web app. If you wish/need to debug the value of a given key, you can simply do so using telnet</p>
<div class="codecolorer-container bash dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:678px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">telnet localhost <span style="color: #000000;">11211</span><br />
get foo<br />
quit</div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://www.worldgoneweb.com/2011/install-and-query-memcache-on-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:thumbnail url="http://www.worldgoneweb.com/wp-content/uploads/2011/01/memcache-150x150.jpg" />
		<media:content url="http://www.worldgoneweb.com/wp-content/uploads/2011/01/memcache.jpg" medium="image">
			<media:title type="html">memcache</media:title>
			<media:thumbnail url="http://www.worldgoneweb.com/wp-content/uploads/2011/01/memcache-150x150.jpg" />
		</media:content>
	</item>
		<item>
		<title>World Gone Web hacked</title>
		<link>http://www.worldgoneweb.com/2011/world-gone-web-hacked/</link>
		<comments>http://www.worldgoneweb.com/2011/world-gone-web-hacked/#comments</comments>
		<pubDate>Sat, 08 Jan 2011 09:00:59 +0000</pubDate>
		<dc:creator>shalfon</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Me myself I]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Système]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[hacked]]></category>
		<category><![CDATA[malware]]></category>
		<category><![CDATA[ovh]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[webmaster]]></category>

		<guid isPermaLink="false">http://www.worldgoneweb.com/?p=414</guid>
		<description><![CDATA[On Monday morning, I received an email from Google Webmaster Tools letting me know that my WordPress blog had been hacked and was temporarily blacklisted. Users accessing my blog using Google Chrome or Firefox were advised to stay away for safety. I appreciate Google&#8217;s notification of this problem as well as their concern (and Mozilla&#8217;s) [...]]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter size-medium wp-image-415" title="Firefox Malware Warning" src="http://www.worldgoneweb.com/wp-content/uploads/2011/01/malware-300x143.png" alt="" width="300" height="143" /></p>
<p>On Monday morning, I received an email from Google Webmaster Tools letting me know that my WordPress blog had been hacked and was temporarily blacklisted. Users accessing my blog using Google Chrome or Firefox were advised to stay away for safety. I appreciate Google&#8217;s notification of this problem as well as their concern (and Mozilla&#8217;s) to protect my visitors.</p>
<p>Why was my WordPress blog hacked ? I don&#8217;t believe it was individually targeted, I believe it was hacked because it was vulnerable. Two reasons :</p>
<p>1.  I hadn&#8217;t updated my blog to the latest version of WordPress. As a matter of fact, I was not even running WordPress 3.0 yet.<br />
2. Also, I believe the file permissions I was required to use on the server by my host provider were not safe enough thought I could not change them without breaking the whole blog (Access Denied error). I largely blame my hosting provider architecture for that.<br />
So, what did the malware look like ? It was a php code which was added to every .php file in my main wordpress folder and read something like eval(base64_decode(XXXXXXXXXXX)). Once this was decoded and evaluated, it would check whether the referrer was Bing, Yahoo or Google and if so, redirect my visitor to a malware sharing site of some kind (I didn&#8217;t go to it&#8230;). This hack has been used recently on several GoDaddy hosted wordpress blogs and other CMS. With some help from @fdevillamil and Google, I found information about the problem and started working on it.</p>
<p>Finally, I finally got the problem sorted thanks to several blogs posts I&#8217;d like to point to here.</p>
<p>1. Here is a <a href="http://www.blogtips.org/analysis-of-the-latest-website-hacks/">detailed explanation of the attack</a><br />
2. I downloaded and modified <a href="http://www.blogtips.org/how-to-cure-your-godaddy-wordpress-hacked-blog/">Peter&#8217;s fixfiles.php</a> script in order to clean my PHP code of the malicious PHP script.<br />
3. Sucuri Research offers a <a href="http://blog.sucuri.net/2010/05/simple-cleanup-solution-for-the-latest-wordpress-hack.html">console command</a> (requires SSH access to your server) to clean your WordPress, too. They also detailed how <a href="http://blog.sucuri.net/2010/10/attacks-on-godaddy-sites-insomniaboldinfoorg-com.html">to fix a hacked blog</a> intended for GoDaddy users.<br />
4. Before resubmitting my blog for validation by Google, I made sure everything was okay using <a href="http://sitecheck.sucuri.net/scanner/">Sucuri&#8217;s malware scanner service</a> (free for limited use) . A very useful tool.<br />
5. I quickly searched for <a href="http://thepcsecurity.com/scan-or-check-websites-for-malware-4-free-tools/">similar tools</a> I could use in the future and found the following articles though I didn&#8217;t test these services yet.<br />
6. I moved my blog to another host where I was able to set the permission more restrictively<br />
7. I disabled several of my plugins and updated my WordPress hoping to secure my blog from too many security flaws that could lay in third party code<br />
8. Next, I read up about a few ways to fix security holes in WordPress in these posts :</p>
<ul>
<li><a href="http://www.blogtips.org/monitor-maliciousfile-changes-wordpress-blog/">Monitor Malicious File Changes in WordPress Blog</a></li>
<li><a href="http://www.blogtips.org/secure-wordpress-blog/">Secure a WordPress Blog</a></li>
<li><a href="http://serverfault.com/questions/6895/whats-the-best-way-of-handling-permissions-for-apache2s-user-www-data-in-var-w">The best way to handle file permissions for Apache www-data</a> (ServerFault discussion)</li>
<li><a href="http://www.blogtips.org/avoid-users-uploading-malware/">Avoid users uploading malware</a></li>
</ul>
<p>9. Finally, I updated my blog which was no luxury. It can quickly be done in<a href="http://minimalite.com/2011/01/wordpress-hacks/how-to-update-manually-to-wordpress-3-0-4/"> a few steps</a> which are detailed right here</p>
<p>Hope this helps out someone else in a similar situation and that Google reconsiders my website soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.worldgoneweb.com/2011/world-gone-web-hacked/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:thumbnail url="http://www.worldgoneweb.com/wp-content/uploads/2011/01/malware-150x150.png" />
		<media:content url="http://www.worldgoneweb.com/wp-content/uploads/2011/01/malware.png" medium="image">
			<media:title type="html">Firefox Malware Warning</media:title>
			<media:thumbnail url="http://www.worldgoneweb.com/wp-content/uploads/2011/01/malware-150x150.png" />
		</media:content>
	</item>
		<item>
		<title>Chive, alternative to PHPMyAdmin</title>
		<link>http://www.worldgoneweb.com/2010/chive-alternative-to-phpmyadmin/</link>
		<comments>http://www.worldgoneweb.com/2010/chive-alternative-to-phpmyadmin/#comments</comments>
		<pubDate>Mon, 05 Apr 2010 16:33:11 +0000</pubDate>
		<dc:creator>shalfon</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[chive]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[phpmyadmin]]></category>
		<category><![CDATA[sql browser]]></category>
		<category><![CDATA[yii]]></category>

		<guid isPermaLink="false">http://www.samanthahalfon.net/worldgoneweb/?p=348</guid>
		<description><![CDATA[I don&#8217;t remember how I&#8217;ve heard about Chive, a young alternative to PhpMyAdmin (version 0.3 was released less than a week ago). I believe it was a link on twitter. There seem to be two policies when it comes to a MySQL browser for web developers: the desktop app or the web app. A lot [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.samanthahalfon.net/worldgoneweb/wp-content/uploads/2010/04/Screen-shot-2010-04-05-at-6.24.13-PM.png"><img src="http://www.samanthahalfon.net/worldgoneweb/wp-content/uploads/2010/04/Screen-shot-2010-04-05-at-6.24.13-PM.png" alt="" title="Screen shot 2010-04-05 at 6.24.13 PM" width="350" height="200" class="aligncenter size-full wp-image-349" /></a></p>
<p>I don&#8217;t remember how I&#8217;ve heard about <a href="http://www.chive-project.com/">Chive</a>, a young alternative to PhpMyAdmin (version 0.3 was released less than a week ago). I believe it was a link on twitter.<br />
There seem to be two policies when it comes to a MySQL browser for web developers: the desktop app or the web app. A lot of people seem to use PHPMyAdmin though I gave it up several years ago. First for the MySQL QueryBrowser, later on for SequelPro (OS X).  SequelPro does everything I need, connect via socket, tcp or ssh which is extremly useful. Still, sometimes, to install a PHPMyAdmin (or something similar) on a remote server or a dev server can be handy. So I tried Chive. </p>
<p>The installation couldnt be easier. Just unrar the package, place it in your document root somewhere and it works. Chive runs on the Yii PHP framework and, as far as I can tell, it&#8217;s pretty fast. The interface is less cluttered than PHPMyAdmin. Of course, you have to get some work done with a tool like that to judge of its efficiency but it looks like a nice alternative to PHPMyAdmin to me. Actually, the <a href="http://www.chive-project.com/Features">feature list comparaison</a> on the Chive website is impressive (considering the age of the project). I will definitely recommend it to developers I work with because I hate using PHPMyAdmin when pairing with them. </p>
<p>If you have any use for a web based MySQL Browserm check Chive out:</p>
<li><a href="http://www.chive-project.com/">Chive homepage</a></li>
<li><a href="https://launchpad.net/chive">Chive&#8217;s source code on launchpad</a></li>
]]></content:encoded>
			<wfw:commentRss>http://www.worldgoneweb.com/2010/chive-alternative-to-phpmyadmin/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:thumbnail url="http://www.worldgoneweb.com/wp-content/uploads/2010/04/Screen-shot-2010-04-05-at-6.24.13-PM-150x150.png" />
		<media:content url="http://www.worldgoneweb.com/wp-content/uploads/2010/04/Screen-shot-2010-04-05-at-6.24.13-PM.png" medium="image">
			<media:title type="html">Screen shot 2010-04-05 at 6.24.13 PM</media:title>
			<media:thumbnail url="http://www.worldgoneweb.com/wp-content/uploads/2010/04/Screen-shot-2010-04-05-at-6.24.13-PM-150x150.png" />
		</media:content>
	</item>
		<item>
		<title>Linking to Twitter and Facebook from a website</title>
		<link>http://www.worldgoneweb.com/2010/linking-to-twitter-and-facebook-from-a-website/</link>
		<comments>http://www.worldgoneweb.com/2010/linking-to-twitter-and-facebook-from-a-website/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 22:07:48 +0000</pubDate>
		<dc:creator>shalfon</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Teeorama]]></category>
		<category><![CDATA[bitly]]></category>
		<category><![CDATA[colorbox]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[lightbox]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.samanthahalfon.net/worldgoneweb/?p=313</guid>
		<description><![CDATA[This week I&#8217;ve worked on a social lightbox for Teeorama allowing our visitors to tweet or write on their Facebook walls from our tee-shirt shop.The lightbox itself is built using ColorBox, a powerful and customizable lightbox library built on JQuery (MIT License). The Twitter tool is fairly easy to setup, I used bit.ly to generate [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.samanthahalfon.net/worldgoneweb/wp-content/uploads/2010/02/Screen-shot-2010-02-24-at-10.40.48-PM.png" alt="" title="Teeorama Social Lightbox" width="400" height="240" class="aligncenter size-full wp-image-314" /></p>
<p><img src="http://www.samanthahalfon.net/worldgoneweb/wp-content/uploads/2010/02/Screen-shot-2010-02-24-at-10.41.05-PM.png" alt="" title="Share on Facebook/Twitter" width="53" height="218" class="alignleft size-full wp-image-315" />This week I&#8217;ve worked on a social lightbox for <a href="http://teeorama.com/">Teeorama</a> allowing our visitors to <a href="http://www.twitter.com/">tweet</a> or write on their <a href="http://www.facebook.com/">Facebook</a> walls from <a href="http://teeorama.com/">our tee-shirt shop</a>.The lightbox itself is built using <a href="http://colorpowered.com/colorbox/">ColorBox</a>, a powerful and customizable lightbox library built on <a href="http://jquery.com/">JQuery</a> (MIT License). The <a href="http://www.twitter.com/">Twitter</a> tool is fairly easy to setup, I used <a href="http://bit.ly/">bit.ly</a> to generate the shortened URL of the current page and placed it, along with a default content, in the text box. When the user clicks on submit, he or she is redirected to twitter. The update box contains what was typed in the teeorama box and one click on the update button is enough to validate the tweet.The follow button is even simpler, it is nothing but a link to <a href="https://twitter.com/teeorama">teeorama&#8217;s twitter account</a>.<a href="http://www.facebook.com/">Facebook</a> is both more powerful (you can publish to your wall without leaving the teeorama page) and a bit trickier to setup.First, you need to head over to developers.facebook.com/setup.php to register your site as a Connect enabled website. Upload the <em>xd_receiver.htm</em> file to your server and validate. You now have access to your <a href="http://www.facebook.com/developers/apps.php">Facebook Connect</a> Tools, API documentation and sandbox as well as to a gallery of widgets or code samples you can use. I chose to use the <em>Comment Box</em>.</p>
<p><img src="http://www.samanthahalfon.net/worldgoneweb/wp-content/uploads/2010/02/Screen-shot-2010-02-24-at-10.39.40-PM.png" alt="" title="Facebook Connect Tools" width="400" height="194" class="alignleft size-full wp-image-317" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.worldgoneweb.com/2010/linking-to-twitter-and-facebook-from-a-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:thumbnail url="http://www.worldgoneweb.com/wp-content/uploads/2010/02/Screen-shot-2010-02-24-at-10.40.48-PM-150x150.png" />
		<media:content url="http://www.worldgoneweb.com/wp-content/uploads/2010/02/Screen-shot-2010-02-24-at-10.40.48-PM.png" medium="image">
			<media:title type="html">Teeorama Social Lightbox</media:title>
			<media:thumbnail url="http://www.worldgoneweb.com/wp-content/uploads/2010/02/Screen-shot-2010-02-24-at-10.40.48-PM-150x150.png" />
		</media:content>
		<media:content url="http://www.worldgoneweb.com/wp-content/uploads/2010/02/Screen-shot-2010-02-24-at-10.41.05-PM.png" medium="image">
			<media:title type="html">Share on Facebook/Twitter</media:title>
			<media:thumbnail url="http://www.worldgoneweb.com/wp-content/uploads/2010/02/Screen-shot-2010-02-24-at-10.41.05-PM-53x150.png" />
		</media:content>
		<media:content url="http://www.worldgoneweb.com/wp-content/uploads/2010/02/Screen-shot-2010-02-24-at-10.39.40-PM.png" medium="image">
			<media:title type="html">Facebook Connect Tools</media:title>
			<media:thumbnail url="http://www.worldgoneweb.com/wp-content/uploads/2010/02/Screen-shot-2010-02-24-at-10.39.40-PM-150x150.png" />
		</media:content>
	</item>
		<item>
		<title>Where are your users from, part 2</title>
		<link>http://www.worldgoneweb.com/2010/where-are-your-users-from-part-2/</link>
		<comments>http://www.worldgoneweb.com/2010/where-are-your-users-from-part-2/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 17:51:39 +0000</pubDate>
		<dc:creator>shalfon</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[GeoIP]]></category>

		<guid isPermaLink="false">http://www.samanthahalfon.net/worldgoneweb/?p=309</guid>
		<description><![CDATA[Recently, I wrote about geolocalisation of your users/visitors based on the IP to Country table. After using it for a couple of months, I found it painful to have to regularly update the table (even if some people came up with an automatic work around based on PERL scripts for example). So, I decided to find another [...]]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter size-full wp-image-310" title="the_world" src="http://www.samanthahalfon.net/worldgoneweb/wp-content/uploads/2010/02/the_world.jpg" alt="" width="300" height="139" /></p>
<p>Recently, I wrote about geolocalisation of your users/visitors based on the IP to Country table. After using it for a couple of months, I found it painful to have to regularly update the table (even if some people came up with an <a title="IP to Country" href="http://www.celtnet.org.uk/info/IP-to-country-converter.php" target="_blank">automatic work around based on PERL scripts</a> for example).</p>
<p>So, I decided to find another way to solve the problem and gave the <a href="http://www.maxmind.com/app/mod_geoip" target="_blank">GeoIP Apache module by MaxMind</a> a try. The installation is as simple as can be:</p>
<div class="codecolorer-container bash dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:678px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> libapache2-mod-geoip<br />
a2enmod geoip<br />
<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 restart</div></td></tr></tbody></table></div>
<p>Once the module is setup, you can use the following PHP code to obtain the Country Code (2 letters)</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:678px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$countryCode</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;GEOIP_COUNTRY_CODE&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>Finally, here is a <a href="http://www.worldatlas.com/aatlas/ctycodes.htm" target="_blank">list of country codes and the associated country names</a>.</p>
<p>If yo</p>
<p>That&#8217;s it, quick and simple.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.worldgoneweb.com/2010/where-are-your-users-from-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:thumbnail url="http://www.worldgoneweb.com/wp-content/uploads/2010/02/the_world-150x139.jpg" />
		<media:content url="http://www.worldgoneweb.com/wp-content/uploads/2010/02/the_world.jpg" medium="image">
			<media:title type="html">the_world</media:title>
			<media:thumbnail url="http://www.worldgoneweb.com/wp-content/uploads/2010/02/the_world-150x139.jpg" />
		</media:content>
	</item>
		<item>
		<title>Setting up Code Igniter</title>
		<link>http://www.worldgoneweb.com/2010/setting-up-code-igniter/</link>
		<comments>http://www.worldgoneweb.com/2010/setting-up-code-igniter/#comments</comments>
		<pubDate>Sat, 13 Feb 2010 08:40:33 +0000</pubDate>
		<dc:creator>shalfon</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[virtual host]]></category>

		<guid isPermaLink="false">http://www.samanthahalfon.net/worldgoneweb/?p=286</guid>
		<description><![CDATA[A few months ago, we jumped into Teeorama, a PHP based online tee-shirt store front end for Spreadshirt. We finally completed the project and we&#8217;re planning on opening it to the public tomorrow. By the way, if you feel you could use a new Geek shirt, please head over to teeorama.com before reading on&#8230; When [...]]]></description>
			<content:encoded><![CDATA[<p>A few months ago, we jumped into <a href="http://www.teeorama.com" target="_blank">Teeorama</a>, a PHP based online tee-shirt store front end for <a href="http://www.spreadshirt.net" target="_blank">Spreadshirt</a>. We finally completed the project and we&#8217;re planning on opening it to the public tomorrow. By the way, if you feel you could use a new Geek shirt, please head over to <a href="http://www.teeorama.com" target="_blank">teeorama.com</a> before reading on&#8230;</p>
<p style="text-align: center;"><a href="http://www.teeorama.com"><img class="aligncenter size-full wp-image-289" title="Teeorama" src="http://www.samanthahalfon.net/worldgoneweb/wp-content/uploads/2010/02/Screen-shot-2010-02-13-at-9.45.31-AM.png" alt="" width="413" height="215" /></a></p>
<p>When I started the development, I decided to use both a PHP and a Javascript framework I didn&#8217;t know. I had two reasons for doing that:</p>
<ul>
<li>It&#8217;s always interesting to play with new code. You get to see how other people/framework solved common problems, how some libraries make this or that easier  to use for the developer. You also sometimes realize some other things are carried out better in the framework you are used to. Either way, it is a good learning experience.</li>
<li>Also, I wanted to stay away from the stack we use at work to not be tempted and not be able to just copy over bits of our blueKiwi framework into my code</li>
</ul>
<p>So, I picked <a href="http://codeigniter.com/" target="_blank">CodeIgniter</a> and <a href="http://jquery.com/" target="_blank">jQuery</a> to build my website. In the end, I am very pleased with the experience of working with these two tools. CodeIgniter is exactly what it claims to be: a very light but powerful framework that does not try to command the way you work. Of course, jQuery is just as powerful as its reputation. It&#8217;s incredibly easy to get used to and I haven&#8217;t found anything it couldn&#8217;t do.</p>
<p style="text-align: center;"><a href="http://www.codeigniter.com"><img class="aligncenter size-full wp-image-288" title="Screen shot 2010-02-13 at 9.44.03 AM" src="http://www.samanthahalfon.net/worldgoneweb/wp-content/uploads/2010/02/Screen-shot-2010-02-13-at-9.44.03-AM.png" alt="" width="438" height="118" /></a></p>
<p>Anyway, this post is about setting up Code Igniter. There is a Code Igniter <a href="http://codeigniter.com/downloads/" target="_blank">user_guide</a> (included in the downloaded zip file) to do just that and it would take you about two seconds to get going. The thing is, I did not like the way Code Igniter was laid out in my folder. I wanted to be able to place the framework in a library folder within my application folder and make my web folder (containing the images, javascript and css files) the document root therefore keeping my application folder out of exposure to the Web.</p>
<p>This is also possible though it does involve some minor tweaking of CodeIgniter base code.</p>
<p>First, here is my chosen folder layout</p>
<p style="text-align: center;"><img class="aligncenter" style="max-width: 800px;" src="http://www.samanthahalfon.net/worldgoneweb/wp-content/uploads/2010/02/Screen-shot-2010-02-13-at-9.25.18-AM.png" alt="" width="348" height="603" /></p>
<p>Second, as I said, I made the web folder the target of my Apache virtual host.<br />
Here is my virtual host for this application</p>
<div class="codecolorer-container apache dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:678px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="apache codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #00007f;">ServerAdmin</span> your_email<br />
<span style="color: #00007f;">ServerName</span> project_domain<br />
<span style="color: #00007f;">AddDefaultCharset</span> UTF-<span style="color: #ff0000;">8</span><br />
<span style="color: #00007f;">DocumentRoot</span> /var/www/project/web<br />
<br />
<span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">On</span><br />
<span style="color: #00007f;">RewriteCond</span> $<span style="color: #ff0000;">1</span> !^/?(index\.php|test|images|web|js|css)<br />
<span style="color: #00007f;">RewriteRule</span> ^(.*)$ /index.php/$<span style="color: #ff0000;">1</span> [L]</div></td></tr></tbody></table></div>
<p>Finally, in order for all this to work, you need to tweak a couple of CodeIgniter files</p>
<p>define the system and application folders paths as follow in index.php:</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:678px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$docRootPath</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/dirname"><span style="color: #990000;">dirname</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DOCUMENT_ROOT'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$system_folder</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$docRootPath</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/application/libraries/codeigniter&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$application_folder</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$docRootPath</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/application&quot;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>Also, modify the CodeIgniter.php file at the bottom of index.php to:</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:678px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #b1b100;">require_once</span> BASEPATH<span style="color: #339933;">.</span><span style="color: #0000ff;">'CodeIgniter'</span><span style="color: #339933;">.</span>EXT<span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>Finally, edit CodeIgniter.php in order to replace all occurrences of &#8220;codeigniter/&#8221; by &#8220;&#8221; (nothing)</p>
<p>You should be setup. Happy coding!</p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=7b05c7fd-fca7-88bc-bd59-fc928be8bb46" alt="" /></div>
]]></content:encoded>
			<wfw:commentRss>http://www.worldgoneweb.com/2010/setting-up-code-igniter/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:thumbnail url="http://www.worldgoneweb.com/wp-content/uploads/2010/02/Screen-shot-2010-02-13-at-9.45.31-AM-150x150.png" />
		<media:content url="http://www.worldgoneweb.com/wp-content/uploads/2010/02/Screen-shot-2010-02-13-at-9.45.31-AM.png" medium="image">
			<media:title type="html">Teeorama</media:title>
			<media:thumbnail url="http://www.worldgoneweb.com/wp-content/uploads/2010/02/Screen-shot-2010-02-13-at-9.45.31-AM-150x150.png" />
		</media:content>
		<media:content url="http://www.worldgoneweb.com/wp-content/uploads/2010/02/Screen-shot-2010-02-13-at-9.44.03-AM.png" medium="image">
			<media:title type="html">Screen shot 2010-02-13 at 9.44.03 AM</media:title>
			<media:thumbnail url="http://www.worldgoneweb.com/wp-content/uploads/2010/02/Screen-shot-2010-02-13-at-9.44.03-AM-150x150.png" />
		</media:content>
		<media:content url="http://www.samanthahalfon.net/worldgoneweb/wp-content/uploads/2010/02/Screen-shot-2010-02-13-at-9.25.18-AM.png" medium="image" />
		<media:content url="http://img.zemanta.com/pixy.gif?x-id=7b05c7fd-fca7-88bc-bd59-fc928be8bb46" medium="image" />
	</item>
	</channel>
</rss>

