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

<channel>
	<title>Superdit.com &#187; PHP</title>
	<atom:link href="http://superdit.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://superdit.com</link>
	<description>blogging, design, tech, and web</description>
	<lastBuildDate>Sat, 31 Mar 2012 20:40:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>PHP Tutorial Collection: Build Your Own PHP Framework</title>
		<link>http://superdit.com/2011/10/01/php-tutorial-collection-build-your-own-php-framework/</link>
		<comments>http://superdit.com/2011/10/01/php-tutorial-collection-build-your-own-php-framework/#comments</comments>
		<pubDate>Fri, 30 Sep 2011 23:42:33 +0000</pubDate>
		<dc:creator>aditia rahman</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[framework]]></category>

		<guid isPermaLink="false">http://superdit.com/?p=9033</guid>
		<description><![CDATA[In today world of web development, we cannot escape the term of a framework, whether in server side or client side scripting, PHP framework are the most common used in today application, but there are so many choices of PHP Framework that can a developer confuse what to choose, especially for the beginner. Here a collection<a href="http://superdit.com/2011/10/01/php-tutorial-collection-build-your-own-php-framework/" class="read-more">Continue Reading</a>]]></description>
			<content:encoded><![CDATA[<p>In today world of web development, we cannot escape the term of a framework, whether in server side or client side scripting, PHP framework are the most common used in today application, but there are so <a title="Big List of PHP Framework" href="http://superdit.com/2009/07/22/big-list-of-php-framework/" target="_blank">many choices of PHP Framework</a> that can a developer confuse what to choose, especially for the beginner.</p>
<p><a title="PHP Tutorial Collection: Build Your Own PHP Framework" href="http://superdit.com/2011/10/01/php-tutorial-collection-build-your-own-php-framework/"><img class="alignnone size-full wp-image-9076" title="php framework tutorial" src="http://superdit.com/wp-content/uploads/2011/10/php-framework-tutorial-thumbs1.jpg" alt="php framework tutorial" width="550" height="160" /></a></p>
<p>Here a collection of tutorial of creating your own PHP framework in case you don&#8217;t satisfied enough of the available framework or maybe you have more time to create your own, these tutorial might help you to get started.<span id="more-9033"></span></p>
<h5>Write Your Own PHP MVC Framework</h5>
<p><a href="http://anantgarg.com/2009/03/13/write-your-own-php-mvc-framework-part-1/" target="_blank">Part 1</a> - <a href="http://anantgarg.com/2009/03/30/write-your-own-php-mvc-framework-part-2/ " target="_blank">Part 2</a></p>
<p><a href="http://anantgarg.com/2009/03/13/write-your-own-php-mvc-framework-part-1/" target="_blank"><img class="alignnone size-full wp-image-9041" title="Write your own PHP MVC Framework" src="http://superdit.com/wp-content/uploads/2011/09/01-Write-your-own-PHP-MVC-Framework-Part-1-anant-garg.jpg" alt="Write your own PHP MVC Framework" width="550" height="190" /></a></p>
<hr class="hr-5" />
<h5>Creating A PHP5 Framework</h5>
<p><a href="http://net.tutsplus.com/tutorials/php/creating-a-php5-framework-part-1/" target="_blank">Part 1</a> - <a href="http://net.tutsplus.com/tutorials/php/create-a-php5-framework-part-2/" target="_blank">Part 2</a> - <a href="http://net.tutsplus.com/tutorials/php/create-a-php5-framework-part-3/" target="_blank">Part 3</a></p>
<p><a href="http://net.tutsplus.com/tutorials/php/creating-a-php5-framework-part-1/" target="_blank"><img class="alignnone size-full wp-image-9044" title="Creating a PHP5 Framework - Nettuts+" src="http://superdit.com/wp-content/uploads/2011/09/02-Creating-a-PHP5-Framework-–-Part-1-Nettuts+.jpg" alt="Creating a PHP5 Framework - Nettuts+" width="550" height="190" /></a></p>
<hr class="hr-5" />
<h5>PHP Frameworks? Just Roll Your Own</h5>
<p><a href="http://fuelyourcoding.com/php-frameworks-just-roll-your-own-part-1/" target="_blank">Part 1</a> - <a href="http://fuelyourcoding.com/roll-your-own-php-framework-part-ii/" target="_blank">Part 2</a> - <a href="http://fuelyourcoding.com/roll-your-own-php-framework-part-iii/" target="_blank">Part 3</a></p>
<p><a href="http://fuelyourcoding.com/php-frameworks-just-roll-your-own-part-1/" target="_blank"><img class="alignnone size-full wp-image-9046" title="PHP Frameworks - Just roll your own! - Fuel Your Coding" src="http://superdit.com/wp-content/uploads/2011/09/03-PHP-Frameworks-Just-roll-your-own-–-PART-1-Fuel-Your-Coding.jpg" alt="PHP Frameworks - Just roll your own! - Fuel Your Coding" width="550" height="190" /></a></p>
<hr class="hr-5" />
<h5>Build A PHP MVC Framework in an Hour</h5>
<p><a href="http://johnsquibb.com/tutorials" target="_blank">Intro</a> - <a href="http://johnsquibb.com/tutorials/mvc-framework-in-1-hour-part-one" target="_blank">Part 1</a> - <a href="http://johnsquibb.com/tutorials/mvc-framework-in-1-hour-part-two" target="_blank">Part 2</a> - <a href="http://johnsquibb.com/tutorials/mvc-framework-in-1-hour-part-three" target="_blank">Part 3</a></p>
<p><a href="http://johnsquibb.com/tutorials" target="_blank"><img class="alignnone size-full wp-image-9048" title="Build Your Own PHP MVC Framework, Method Chaining, Chainable Interfaces" src="http://superdit.com/wp-content/uploads/2011/09/04-Tutorials-Build-Your-Own-PHP-MVC-Framework-Method-Chaining-Chainable-Interfaces-www.johnsquibb.com_.jpg" alt="Build Your Own PHP MVC Framework, Method Chaining, Chainable Interfaces - www.johnsquibb.com" width="550" height="190" /></a></p>
<hr class="hr-5" />
<h5>Create Your Own Lightweight PHP MVC Framework</h5>
<p><a href="http://www.markisgood.com/blog/php/create-your-own-lightweight-php-mvc-framework" target="_blank">One Part</a></p>
<p><a href="http://www.markisgood.com/blog/php/create-your-own-lightweight-php-mvc-framework" target="_blank"><img class="alignnone size-full wp-image-9049" title="Create Your Own lightweight PHP MVC Framework" src="http://superdit.com/wp-content/uploads/2011/09/05-web-development-blog-»-Create-Your-Own-lightweight-PHP-MVC-Framework.jpg" alt="Create Your Own lightweight PHP MVC Framework" width="550" height="190" /></a></p>
<hr class="hr-5" />
<h5>How To Learn To Build Your Own PHP Framework</h5>
<p><a href="http://www.slideshare.net/pcdinh/how-to-learn-to-build-your-own-php-framework-presentation" target="_blank">Slide Presentation</a></p>
<p><a href="http://www.slideshare.net/pcdinh/how-to-learn-to-build-your-own-php-framework-presentation" target="_blank"><img class="alignnone size-full wp-image-9052" title="How to learn to build your own PHP framework" src="http://superdit.com/wp-content/uploads/2011/09/06-How-to-learn-to-build-your-own-PHP-framework.jpg" alt="How to learn to build your own PHP framework" width="550" height="190" /></a></p>
<hr class="hr-5" />
<h5>Create Your First Tiny MVC Boilerplate With PHP (Video)</h5>
<p><a href="http://net.tutsplus.com/tutorials/php/create-your-first-tiny-mvc-boilerplate-with-php/" target="_blank">One Video</a></p>
<p><a href="http://net.tutsplus.com/tutorials/php/create-your-first-tiny-mvc-boilerplate-with-php/" target="_blank"><img class="alignnone size-full wp-image-9054" title="Create your First Tiny MVC Boilerplate with PHP" src="http://superdit.com/wp-content/uploads/2011/09/07-Untitled.jpg" alt="Create your First Tiny MVC Boilerplate with PHP" width="550" height="322" /></a></p>
<hr class="hr-5" />
<h5>PHP: Create Your Own MVC (Video)</h5>
<p><a href="http://www.youtube.com/watch?v=Aw28-krO7ZM" target="_blank">Part 1</a> - <a href="http://www.youtube.com/watch?v=bQxvYs9yO7Y" target="_blank">Part 2</a> - <a href="http://www.youtube.com/watch?v=2Eu0Nkpo6vM" target="_blank">Part 3</a> - <a href="http://www.youtube.com/watch?v=4hh2IXrdT4g" target="_blank">Part 4</a> - <a href="http://www.youtube.com/watch?v=4gDLBMs_9ng" target="_blank">Part 5</a></p>
<p><a href="http://www.youtube.com/watch?v=Aw28-krO7ZM" target="_blank"><img class="alignnone size-full wp-image-9055" title="PHP: Create Your Own MVC" src="http://superdit.com/wp-content/uploads/2011/09/08-Untitled.jpg" alt="PHP: Create Your Own MVC" width="550" height="190" /></a></p>
<hr class="hr-5" />
<h5>Building A Simple MVC Based Framework in PHP5</h5>
<p><a href="http://www.devshed.com/c/a/PHP/Building-a-Simple-MVCbased-Framework-in-PHP-5/" target="_blank">Part 1</a> - <a href="http://www.devshed.com/c/a/PHP/Building-a-Simple-MVCbased-Framework-in-PHP-5/1/" target="_blank">Part 2</a> - <a href="http://www.devshed.com/c/a/PHP/Building-a-Simple-MVCbased-Framework-in-PHP-5/2/" target="_blank">Part 3</a> - <a href="http://www.devshed.com/c/a/PHP/Building-a-Simple-MVCbased-Framework-in-PHP-5/3/" target="_blank">Part 4</a></p>
<p><a href="http://www.devshed.com/c/a/PHP/Building-a-Simple-MVCbased-Framework-in-PHP-5/" target="_blank"><img class="alignnone size-full wp-image-9057" title="Building a Simple MVC-based Framework in PHP 5" src="http://superdit.com/wp-content/uploads/2011/09/09-Building-a-Simple-MVC-based-Framework-in-PHP-5-PHP.jpg" alt="Building a Simple MVC-based Framework in PHP 5" width="550" height="190" /></a></p>
<hr class="hr-5" />
<h5>Creating An MVC Framework (Video)</h5>
<p><a href="http://www.youtube.com/watch?v=zmhzTbHF0Qc" target="_blank">Part 1</a> - <a href="http://www.youtube.com/watch?v=EGAIHTn1wp8" target="_blank">Part 2</a></p>
<p><a href="http://www.youtube.com/watch?v=zmhzTbHF0Qc" target="_blank"><img class="alignnone size-full wp-image-9059" title="Creating An MVC Framework" src="http://superdit.com/wp-content/uploads/2011/09/10-Untitled.jpg" alt="Creating An MVC Framework" width="550" height="190" /></a></p>
<hr class="hr-5" />
<h5>How To Create A Simple MVC Framework in PHP</h5>
<p><a href="http://www.henriquebarroso.com/how-to-create-a-simple-mvc-framework-in-php/" target="_blank">One Part</a></p>
<p><a href="http://www.henriquebarroso.com/how-to-create-a-simple-mvc-framework-in-php/" target="_blank"><img class="alignnone size-full wp-image-9060" title="How to create a simple MVC framework in PHP" src="http://superdit.com/wp-content/uploads/2011/09/11-How-to-create-a-simple-MVC-framework-in-PHP-Henrique-Barroso-Web-developer-freelancer.jpg" alt="How to create a simple MVC framework in PHP - Henrique Barroso - Web developer freelancer" width="550" height="190" /></a></p>
<hr class="hr-5" />
<h5>PHP Basic MVC Framework (Video)</h5>
<p><a href="http://www.youtube.com/watch?v=O3ogaH5AOOw" target="_blank">Part 1</a> - <a href="http://www.youtube.com/watch?v=9MXHlxcPb8Q" target="_blank">Part 2</a> - <a href="http://www.youtube.com/watch?v=-Vkl3spgDUM" target="_blank">Part 3</a> - <a href="http://www.youtube.com/watch?v=3QAZSo96_ow" target="_blank">Part 4</a> - <a href="http://www.youtube.com/watch?v=NSp_WU-gBTk" target="_blank">Part 5</a> - <a href="http://www.youtube.com/watch?v=ZrwgDxIGimY" target="_blank">Part 6</a> - <a href="http://www.youtube.com/watch?v=v6c_DGM6U7s" target="_blank">Part 7</a></p>
<p><a href="http://www.youtube.com/watch?v=O3ogaH5AOOw" target="_blank"><img class="alignnone size-full wp-image-9062" title="PHP Basic MVC Framework" src="http://superdit.com/wp-content/uploads/2011/09/12-Untitled.jpg" alt="PHP Basic MVC Framework" width="550" height="190" /></a></p>
<hr class="hr-5" />
<h5>Create An MVC Framework In PHP (Video)</h5>
<p><a href="http://www.youtube.com/watch?v=kLrmIr0obYk" target="_blank">Part 1</a> - <a href="http://www.youtube.com/watch?v=9pFSPO1gazE" target="_blank">Part 2</a> - <a href="http://www.youtube.com/watch?v=opMQeko86Ms " target="_blank">Part 3</a></p>
<p><a href="http://www.youtube.com/watch?v=kLrmIr0obYk" target="_blank"><img class="alignnone size-full wp-image-9064" title="Create An MVC Framework" src="http://superdit.com/wp-content/uploads/2011/09/13-Untitled.jpg" alt="Create An MVC Framework" width="550" height="190" /></a></p>
<hr class="hr-5" />
<h5>Write Your Own PHP5 MVC Framework</h5>
<p><a href="http://ndungi.kenya.or.ke/?p=38" target="_blank">One Part</a></p>
<p><a href="http://ndungi.kenya.or.ke/?p=38" target="_blank"><img class="alignnone size-full wp-image-9065" title="Write your own PHP5 MVC framework" src="http://superdit.com/wp-content/uploads/2011/09/14-Write-your-own-PHP5-MVC-framework-«-ndungi-kyalo’s-blog.jpg" alt="Write your own PHP5 MVC framework" width="550" height="190" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://superdit.com/2011/10/01/php-tutorial-collection-build-your-own-php-framework/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Prevent Login With Same ID</title>
		<link>http://superdit.com/2011/06/06/prevent-login-with-same-id/</link>
		<comments>http://superdit.com/2011/06/06/prevent-login-with-same-id/#comments</comments>
		<pubDate>Mon, 06 Jun 2011 13:07:51 +0000</pubDate>
		<dc:creator>aditia rahman</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[login]]></category>

		<guid isPermaLink="false">http://superdit.com/?p=5657</guid>
		<description><![CDATA[Today post I want to share a little idea to avoiding two or more different user login using the same user ID or username in one application, this feature might be implemented in some specific application that have many restriction and tracking of logged user action in the system. In this post I am not<a href="http://superdit.com/2011/06/06/prevent-login-with-same-id/" class="read-more">Continue Reading</a>]]></description>
			<content:encoded><![CDATA[<p>Today post I want to share a little idea to avoiding two or more different user login using the same user ID or username in one application, this feature might be implemented in some specific application that have many restriction and tracking of logged user action in the system. In this post I am not showing any full code to test, just my simple thought.</p>
<h6>Users Table</h6>
<p>The users table is most commonly used name in application, and the typical column name are <em>id</em>, <em>username</em>, <em>password</em>, <em>first_name</em>, <em>last_name</em>, etc. My idea is to adding one more field in users table that flagging if the user logged in or not. The simple SQL query might be something like this code below.</p>
<pre class="brush: sql; title: ; notranslate">
CREATE TABLE IF NOT EXISTS `users` (
  `id` int(11) NOT NULL,
  `username` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `is_logged_id` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
</pre>
<p>The flag column in this example is <em>is_logged_id </em>field set to INT type with one length, this will only consist the value between 1 (user logged in) or 0 (user not logged in).<span id="more-5657"></span></p>
<h6>Login Application</h6>
<p>I will use a little PHP code to illustrated this section. Most login application form use <a href="http://en.wikipedia.org/wiki/POST_(HTTP)" target="_blank">http post method</a> to  sent two common variable (username and password), in PHP we can access these variable using <em>$_POST['var_name'], </em>and you can use this step</p>
<p>1. Check whether user exist in database, and check whether user is logged in</p>
<pre class="brush: php; title: ; notranslate">
$sql = &quot;SELECT * FROM users WHERE username = '&quot;.$_POST['username'].&quot;'
		AND password = '&quot;.$_POST['password'].&quot;'
		AND is_logged_id = 0&quot;;
</pre>
<p>2. If a result found typically user id and username are registered is session variable using <em>$_SESSION</em><em>, </em>and to preventing login with the same ID you have to update <em>is_logged_in </em>field</p>
<pre class="brush: php; title: ; notranslate">
// register a variable to session
$_SESSION['username'] = $_POST['username'];
// update is_logged_in field
$sql = &quot;UPDATE users SET is_logged_in = 1 WHERE
        username = '&quot;.$_POST['username'].&quot;' AND
        password = '&quot;.$_POST['password'].&quot;'&quot;;
</pre>
<p>That is all, really simple you can customize to login error dialog and giving a message for example <em>&#8220;someone already login using this account&#8221; </em>or maybe a more advance feature like break the current session and force logged in. After user loggout make the <em>is_logged_in </em>field value back to zero.</p>
<h6>Session Timeout</h6>
<p>There is a possible condition that the user may forgot to click the logout link in your system, which mean make the <em>is_logged_in </em>field still have 1 value, so to protecting a restricted page make sure you check the session first before, checking the database.</p>
]]></content:encoded>
			<wfw:commentRss>http://superdit.com/2011/06/06/prevent-login-with-same-id/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>5 Free PHP Scripts To Start Video Sharing Site</title>
		<link>http://superdit.com/2011/05/03/5-free-php-scripts-to-start-video-sharing-site/</link>
		<comments>http://superdit.com/2011/05/03/5-free-php-scripts-to-start-video-sharing-site/#comments</comments>
		<pubDate>Tue, 03 May 2011 12:00:23 +0000</pubDate>
		<dc:creator>aditia rahman</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[Freebies]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[community]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://superdit.com/?p=5320</guid>
		<description><![CDATA[Few months ago I collecting some free PHP scripts to create social networking site, yes maybe with common social networking feature the video sharing must be included there, but all this scripts that I mention from the start focusing just for video sharing site. Vimp The community edition of Vimp available for free download and<a href="http://superdit.com/2011/05/03/5-free-php-scripts-to-start-video-sharing-site/" class="read-more">Continue Reading</a>]]></description>
			<content:encoded><![CDATA[<p>Few months ago I collecting some free <a title="Free PHP Social Network Script Collection" href="http://superdit.com/2011/02/14/free-php-social-network-script-collection/" target="_blank">PHP scripts to create social networking site</a>, yes maybe with common social networking feature the video sharing must be included there, but all this scripts that I mention from the start focusing just for video sharing site.</p>
<h5>Vimp</h5>
<p>The community edition of Vimp available for free download and free just for personal and non-commercial use. The ViMP flash player can also be integrated into other webpages without the slightest effort, due to the automatically generated embed code</p>
<p><a title="Vimp" href="http://www.vimp.com/" target="_blank"><img title="vimp" src="http://superdit.com/wp-content/uploads/2011/05/vimp.png" alt="vimp" width="540" height="260" /></a><span id="more-5320"></span></p>
<p><a title="visit vimp" href="http://www.vimp.com" target="_blank">visit</a></p>
<h5>Clip Bucket</h5>
<p>Clip bucket is one of the most popular video sharing script based on PHP, you can see on the <a title="clip bucket showcase" href="http://clip-bucket.com/showcases" target="_blank">clipbucket showcase</a> page to see many live sites running on clipbucket.</p>
<p><a title="Clip Bucket" href="http://clip-bucket.com/" target="_blank"><img class="alignnone size-full wp-image-6414" title="clipbucket" src="http://superdit.com/wp-content/uploads/2011/05/clipbucket.png" alt="clipbucket" width="540" height="261" /></a></p>
<p><a title="visit clip bucket" href="http://clip-bucket.com/" target="_blank">visit</a> | <a title="clip bucket demo" href="http://clipbucket.net/v2/" target="_blank">demo</a></p>
<h5>PHPmotion</h5>
<p>PHPmotion start as video sharing script, but when I see the features, there are more features that can be used as common social network like image gallery, blogs, audio,</p>
<p><a title="PHPmotion" href="http://www.phpmotion.com/" target="_blank"><img class="alignnone size-full wp-image-6415" title="phpmotion" src="http://superdit.com/wp-content/uploads/2011/05/phpmotion.png" alt="phpmotion" width="540" height="260" /></a></p>
<p><a title="visit phpmotion" href="http://www.phpmotion.com/" target="_blank">visit</a> | <a title="phpmotion demo" href="http://demo.phpmotiontemplates.com/default/" target="_blank">demo</a></p>
<h5>VidiScript</h5>
<p>VidiScript is a video sharing site that is packed with features that you  can only find on major media sharing  communities like YouTube, Meta  Cafe, Daily Motion and Break.</p>
<p><a title="vidiscript" href="http://www.vidiscript.co.uk/" target="_blank"><img class="alignnone size-full wp-image-6416" title="vidiscript" src="http://superdit.com/wp-content/uploads/2011/05/vidscript.png" alt="vidiscript" width="540" height="261" /></a></p>
<p><a title="visit vidiscript" href="http://www.vidiscript.co.uk" target="_blank">visit</a> | <a title="vidiscript demo" href="http://www.vidiscript.co.uk/vidiscript-support/vidiscript-demo" target="_blank">demo</a></p>
<h5>Dentro Video</h5>
<p>Dentro Video is a joomla CMS plugin, so you need joomla running to install this script.</p>
<p><a title="dentrovideo" href="http://www.dentrovideo.com/" target="_blank"><img class="alignnone size-full wp-image-6418" title="dentrovideo" src="http://superdit.com/wp-content/uploads/2011/05/dentrovideo.png" alt="dentrovideo" width="540" height="260" /></a></p>
<p><a title="dentrovideo" href="http://www.dentrovideo.com" target="_blank">visit</a> | <a title="dentro video demo" href="http://www.dentrovideo.com/demo/en.html" target="_blank">demo</a></p>
]]></content:encoded>
			<wfw:commentRss>http://superdit.com/2011/05/03/5-free-php-scripts-to-start-video-sharing-site/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Getting Started With Doctrine 2: Database Abstraction Layer</title>
		<link>http://superdit.com/2011/03/07/getting-started-with-doctrine-2-database-abstraction-layer/</link>
		<comments>http://superdit.com/2011/03/07/getting-started-with-doctrine-2-database-abstraction-layer/#comments</comments>
		<pubDate>Mon, 07 Mar 2011 05:44:48 +0000</pubDate>
		<dc:creator>aditia rahman</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[dbal]]></category>
		<category><![CDATA[doctrine]]></category>

		<guid isPermaLink="false">http://superdit.com/?p=5550</guid>
		<description><![CDATA[Doctrine Project is a set of PHP libraries that focused on providing persistence services and related functionality. The projects are a Object Relational Mapper and the Database Abstraction Layer. I want to discuss a little about using Doctrine 2 Database Abstraction Layer (DBAL), this is an important thing if we want to learn doctrine from<a href="http://superdit.com/2011/03/07/getting-started-with-doctrine-2-database-abstraction-layer/" class="read-more">Continue Reading</a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://superdit.com/2011/03/07/getting-started-with-doctrine-2-database-abstraction-layer/" target="_blank"><img class="alignleft size-full wp-image-5576" title="doctrine logo" src="http://superdit.com/wp-content/uploads/2011/03/doctrine-logo.png" alt="doctrine logo" width="75" height="95" /></a><a title="Doctrine Project" href="http://www.doctrine-project.org/" target="_blank">Doctrine Project</a> is a set of PHP libraries that focused on providing persistence services and related functionality. The   projects are a Object Relational Mapper and the Database Abstraction Layer. I want to discuss a little about using Doctrine 2 Database Abstraction Layer (DBAL), this is an important thing if we want to learn doctrine from the basic, before we move further to ORM, a Database Abstraction Layer is something that PDO handle in PHP, and what make me interested about doctrine is because their <a title="Doctrine 2 - Not The Same Old Php Orm" href="http://www.slideshare.net/jwage/doctrine-2-not-the-same-old-php-orm" target="_blank">presentation</a> statement, which it said the insert performance is better than raw php code that using <em>mysql_query</em> function.<span id="more-5550"></span></p>
<p>First download the <a title="Doctrine DBAL Project" href="http://www.doctrine-project.org/projects/dbal/download" target="_blank">Doctrine DBAL Project</a>, but you download the ORM project it already included the DBAL Project, and extract in your project library folder, for example <em>&#8220;lib&#8221;</em> folder. I using all the code based on official <a title="Doctrine DBAL Reference" href="http://www.doctrine-project.org/projects/dbal/2.0/docs/reference/en" target="_blank">doctrine DBAL reference</a>.</p>
<p><strong>Configuring ClassLoader</strong></p>
<pre class="brush: php; title: ; notranslate">
require 'lib/Doctrine/Common/ClassLoader.php';
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine', 'lib');
$classLoader-&gt;register();
</pre>
<p>Code above is the main class of doctrine that will be needed wheter for both DBAL and ORM use<strong>.<br />
</strong></p>
<p><strong>Configuring Connection</strong></p>
<pre class="brush: php; title: ; notranslate">
$connParams = array(
    'dbname'    =&gt; 'my_doctrine',
    'user'      =&gt; 'root',
    'password'  =&gt; 'rootpassword',
    'host'      =&gt; 'localhost',
    'driver'    =&gt; 'pdo_mysql'
);

$conn = \Doctrine\DBAL\DriverManager::getConnection($connParams);
</pre>
<p>The connection configuration above is using MySQL, based on the documentation doctrine currently support other database such as Oracle, PostgreSQL, and SQLite.</p>
<p><strong>Retrieving and Manipulating</strong></p>
<pre class="brush: php; title: ; notranslate">
$conn = \Doctrine\DBAL\DriverManager::getConnection($connParams);

// execure a query
$sql = &quot;SELECT * FROM articles&quot;;
$stmt = $conn-&gt;query($sql);

// retrieve data
while ($row = $stmt-&gt;fetch()) {
    echo $row['title'];
}

// insert new user, username = 'guest'
$conn-&gt;insert('user', array('username' =&gt; 'guest'));

// update user, username = 'guest' where id = 1
$conn-&gt;update('user', array('username' =&gt; 'guest'), array('id' =&gt; 1));

// delete user, where id = 1
$conn-&gt;delete('user', array('id' =&gt; 1));
</pre>
<p>After knowing these we must be know how to use it in simple CRUD application, but doctrine has more to offer for more expert use in data retrieve and manipulation, you can <a title="Doctrine DBAL Data Retrieval And Manipulation" href="http://www.doctrine-project.org/docs/dbal/2.0/en/reference/data-retrieval-and-manipulation.html" target="_blank">refer this page</a>.</p>
<p><strong>Schema Manager</strong></p>
<pre class="brush: php; title: ; notranslate">
$sm = $conn-&gt;getSchemaManager();

// Retrieve an array of databases on the configured connection:
$tables = $sm-&gt;listTables();
foreach ($tables as $table) {
    echo $table-&gt;getName() . &quot; columns:\n\n&quot;;
    foreach ($table-&gt;getColumns() as $column) {
        echo ' - ' . $column-&gt;getName() . &quot;\n&quot;;
    }
}

// Retrieve an array of Doctrine\DBAL\Schema\Column instances that exist for the given table
$columns = $sm-&gt;listTableColumns('articles');
foreach ($columns as $column) {
    echo $column-&gt;getName() . ': ' . $column-&gt;getType() . &quot;\n&quot;;
}
</pre>
<p>A Schema Manager help to show information contain in database such as Tables, Columns, Foreign Key, Indexes.</p>
<p><strong>Schema Representation</strong></p>
<pre class="brush: php; title: ; notranslate">
$platform = $conn-&gt;getDatabasePlatform();

$schema = new \Doctrine\DBAL\Schema\Schema();
$myTable = $schema-&gt;createTable(&quot;my_table&quot;);
$myTable-&gt;addColumn(&quot;id&quot;, &quot;integer&quot;, array(&quot;unsigned&quot; =&gt; true));
$myTable-&gt;addColumn(&quot;username&quot;, &quot;string&quot;, array(&quot;length&quot; =&gt; 32));
$myTable-&gt;setPrimaryKey(array(&quot;id&quot;));

$sql = $schema-&gt;toSql($platform);
</pre>
<p>This feature can be used to generate SQL statement, so we can execute to the existing connection, and there are more examples from the reference, like generating foreign key, and create sequence, just visit <a title="Doctrine DBAL Reference" href="http://www.doctrine-project.org/docs/dbal/2.0/en/" target="_blank">Doctrine DBAL Reference</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://superdit.com/2011/03/07/getting-started-with-doctrine-2-database-abstraction-layer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Free PHP Social Network Script Collection</title>
		<link>http://superdit.com/2011/02/14/free-php-social-network-script-collection/</link>
		<comments>http://superdit.com/2011/02/14/free-php-social-network-script-collection/#comments</comments>
		<pubDate>Mon, 14 Feb 2011 15:06:24 +0000</pubDate>
		<dc:creator>aditia rahman</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[Freebies]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[community]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[social]]></category>

		<guid isPermaLink="false">http://superdit.com/?p=5136</guid>
		<description><![CDATA[Have you ever thinking to starting your own online community, it becoming easier these day, there are so much available free CMS to download, maybe this list can be use as a consideration for everyone who want to start online community but don&#8217;t want to start from scratch, but still there are always some learning<a href="http://superdit.com/2011/02/14/free-php-social-network-script-collection/" class="read-more">Continue Reading</a>]]></description>
			<content:encoded><![CDATA[<p><span style="font-weight: normal;">Have you ever thinking to starting your own online community, it becoming easier these day, there are so much available free CMS to download, maybe this list can be use as a consideration for everyone who want to start online community but don&#8217;t want to start from scratch, but still there are always some learning curve to take to mastering of each CMS.</span></p>
<h6><a title="Dolphin - Smart Community Builder" href="http://www.boonex.com/dolphin/" target="_blank">Dolphin</a></h6>
<p>Created by <a title="BoonEx" href="http://www.boonex.com" target="_blank">BoonEx</a>, Dolphin is CMS focus on social community feature, it been on the this field for quite some time, it have many features such as video, chat, mailbox, forum, photos, blogs, store, events, and many more, and some features for admin section like membership and access levels, customizable database field and form, etc, also have hundred extensions from the <a href="http://www.boonex.com/unity/" target="_blank">community</a></p>
<p><em>Example site: [ <a title="Apostolic Singles Network" href="http://apostolicsinglesnetwork.com/network/" target="_blank">Apostolic Singles Network</a>, <a title="Jam 2 Gether" href="http://beta.jam2gether.de/" target="_blank">Jam2gether</a> ]</em></p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-5158" title="boonex-dolphin" src="http://superdit.com/wp-content/uploads/2011/02/boonex-dolphin.png" alt="boonex-dolphin" width="540" height="391" /></p>
<h6><span id="more-5136"></span><a title="Elgg" href="http://www.elgg.org/" target="_blank">Elgg</a></h6>
<p>Created by <a title="Curerider" href="http://www.curverider.co.uk/" target="_blank">Curverider</a>, Elgg is one of the open source social networking that available, it has been used in wide range of social environment, from campus, shcool, college and some commercial or non-commercial organization. It have these several basic features such as powerful data model, activity streams, plugin API, user management, access controls, and web services API.</p>
<p><em>Example Site: [ <a title="Oxfam" href="http://www.oxfam.org/" target="_blank">Oxfam</a>, <a title="Willey Publishing" href="http://wiley.com" target="_blank">Wiley Publishing</a> ] </em></p>
<p style="text-align: center;"><img title="elgg" src="http://superdit.com/wp-content/uploads/2011/02/elgg_org.png" alt="elgg" width="540" height="460" /></p>
<h6><a title="BuddyPress" href="http://buddypress.org" target="_blank">BuddyPress</a></h6>
<p>Created by <a href="http://wordpress.org" target="_blank">WordPress</a>, built to be integrated with our first choice blog platform, wordpress. Beside so many extension available on the site, it have several default feature like activity streams, extended profiles, friend connections, private messaging, extensible groups, discussion forums, and of course wordpress blogging.</p>
<p><em>Example site: [ <a title="GigaOm Pro" href="http://pro.gigaom.com/" target="_blank">GigaOm Pro</a>, <a title="Unstructure" href="http://unstructure.org/" target="_blank">Unstructure</a>, <a title="Tasty Kitchen" href="http://thepioneerwoman.com/tasty-kitchen/" target="_blank">Tasty Kitchen</a> ]</em></p>
<p><em><img class="aligncenter size-full wp-image-5175" title="buddypress" src="http://superdit.com/wp-content/uploads/2011/02/buddypress_org.png" alt="buddypress" width="540" height="237" /><br />
</em></p>
<h6><a title="NetworrX by SocialABC" href="http://www.socialabc.com/" target="_blank">NetworX</a><strong> </strong></h6>
<p>Created by <a title="SocialABC" href="http://www.socialabc.com/" target="_blank">SocialABC</a>, NetworX<strong> </strong>is PHP-based open source interactive social networking platform, some features that is have such as profiles, commenting, blogs, forums, events, invitations, file sharing, reporting, etc. It can be used for portal community, corporate intranet, online magazine, newspapaer, etc.</p>
<p><em>Example site: [ <a title="NetworX Demo" href="http://www.socialabc.com/demo/" target="_blank">NetworX Demo</a> ]</em></p>
<p><img class="aligncenter size-full wp-image-5168" title="NetworX" src="http://superdit.com/wp-content/uploads/2011/02/www_socialabc_com_demo_index_php_param.png" alt="NetworX" width="540" height="328" /></p>
<h6><a title="Oxwall" href="http://www.oxwall.org/" target="_blank">Oxwall</a></h6>
<p>Created by <a href="http://www.skalfa.com/" target="_blank">Skalfa</a>, Oxwall have common feature to start build online community, like photos, videos, blogs, forums, tagging, etc. There is a <a href="http://www.oxwall.org/store/" target="_blank">store</a> to find the suitable plugins for our need.</p>
<p><em>Example site: [ <a title="wall.fm" href="http://wall.fm/" target="_blank">Wall.fm</a> ]</em></p>
<p><em><img class="aligncenter size-full wp-image-5178" title="Oxwall" src="http://superdit.com/wp-content/uploads/2011/02/www_oxwall_org.png" alt="Oxwall" width="540" height="257" /><br />
</em></p>
<h6><a title="OpenPNE" href="http://sourceforge.net/projects/openpne/" target="_blank">OpenPNE</a></h6>
<p>OpenPNE is a Social Networking Service Engine written in PHP. It has many features(friend control,friend invitation,diary,blog feeds,message box,etc). Look like this project using japanese languange it quite diffucult to explore.</p>
<h6><a title="phpsocial" href="http://phpsocial.net/" target="_blank">PHP Social</a></h6>
<p>I&#8217;m not really paying to much attenion to this script, but I cannot found the download link, maybe need to register first to get the script. But the demo is available.</p>
<h6><a title="Jcow.net" href="http://www.jcow.net/" target="_blank">Jcow</a></h6>
<p><em>Example site: [ <a title="Jcow Demo" href="http://demo.jcow.net/" target="_blank">Jcow Demo</a> ]</em></p>
<h6><strong>Example Using Popular CMS</strong></h6>
<p>All the CMS I mention above look very focusing on the social network feature, but if you already familiar with popular CMS like drupal or joomla you can find some example and module that suit your community needs, and actually so many more cool example of the social community site using these two CMS.</p>
<h6><strong><a href="http://www.joomla.org/" target="_blank">Joomla</a></strong></h6>
<p><em>Example site: [ <a title="Splashrate" href="http://www.splashrate.com/" target="_blank">Splashrate</a>, <a href="http://www.park-shin-hye.com/" target="_blank">Park-Shin-Hye</a> ]</em></p>
<h6><a title="Drupal" href="http://drupal.org/" target="_blank">Drupal</a></h6>
<p><em>Example site: [ <a title="Imbee" href="http://imbee.com/" target="_blank">Imbee</a>, <a title="DrupalSN" href="http://drupalsn.com/" target="_blank">DrupalSN</a> ]</em></p>
]]></content:encoded>
			<wfw:commentRss>http://superdit.com/2011/02/14/free-php-social-network-script-collection/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Basic PHP Image Watermark With GD Library</title>
		<link>http://superdit.com/2011/02/01/basic-php-image-watermark-with-gd-library/</link>
		<comments>http://superdit.com/2011/02/01/basic-php-image-watermark-with-gd-library/#comments</comments>
		<pubDate>Tue, 01 Feb 2011 06:15:45 +0000</pubDate>
		<dc:creator>aditia rahman</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[watermark]]></category>

		<guid isPermaLink="false">http://superdit.com/?p=4766</guid>
		<description><![CDATA[For today just wanna go back to a little PHP code again, I want share to creating a very basic image watermarking in PHP, watermark  feature are already widely used in some popular digital art, and photo websites like istockphotos, deviantart and any other sites, that maybe I don&#8217;t even know. Now here it goes,<a href="http://superdit.com/2011/02/01/basic-php-image-watermark-with-gd-library/" class="read-more">Continue Reading</a>]]></description>
			<content:encoded><![CDATA[<p>For today just wanna go back to a little PHP code again, I want share to creating a very basic image watermarking in PHP, watermark  feature are already widely used in some popular digital art, and photo websites like <a title="istockphotos" href="http://www.istockphoto.com" target="_blank">istockphotos</a>, <a title="Deviant Art" href="http://deviantart.com" target="_blank">deviantart</a> and any other sites, that maybe I don&#8217;t even know. Now here it goes, first make sure you have GD installed with PHP, you can check on your default phpinfo page using <em>&lt;?php phpinfo(); ?&gt;</em>, or you can use this php script</p>
<pre class="brush: php; title: ; notranslate">
if (!function_exists(&quot;gd_info&quot;)) {
	echo &quot;GD not installed&quot;;
} else {
	echo &quot;GD installed&quot;;
}
</pre>
<p><span id="more-4766"></span></p>
<h6>Text Watermark</h6>
<p>Now let&#8217;s get straight to the code, the first way to adding watermarking is by add text which called true type font on the server, you can freely choose the font you want to use and it will be better to include the font file in the server.</p>
<pre class="brush: php; title: ; notranslate">&lt;?php

header(&quot;Content-type: image/jpeg&quot;);

// get image file
$img_name = &quot;batman.jpg&quot;;
$img_src = imagecreatefromjpeg($img_name);
$width_src = imagesx($img_src);
$height_src = imagesy($img_src);

// new image size = old image size
$width_dst = $width_src;
$height_dst = $height_src;
$quality = 80;

// create new image
$img = imagecreatetruecolor($width_src, $height_dst);
imagecopyresampled($img, $img_src, 0, 0, 0, 0, $width_dst, $height_dst, $width_src, $height_src);

// rectangle size for text box
$x1_rect = 0;
$y1_rect = $height_dst - 18;
$x2_rect = $width_dst;
$y2_rect = $height_dst;

$color = imagecolorallocate($img, 0, 0, 0);
$letter_color = imagecolorallocate($img, 255, 255, 255);
$text = &quot;scissormetimbers (http://scissormetimbers.deviantart.com)&quot;;
imagefilledrectangle($img, $x1_rect, $y1_rect, $x2_rect, $y2_rect, $color);
imagettftext($img, 12, 0, $x1_rect+5, $y1_rect+14, $letter_color, &quot;DroidSans.ttf&quot;, $text);

// show in browser
imagejpeg($img, '', $quality);

imagedestroy($img_src);
imagedestroy($img);

?&gt;
</pre>
<h6>Image Watermark</h6>
<p>If in someway you want to adding an image you can add this code, before the image showing in the browser, I think it is better to choose the image with the transparent background, for watermarking.</p>
<pre class="brush: php; title: ; notranslate">
$logo = imagecreatefromgif(&quot;da.gif&quot;);
imagecopymerge($img, $logo, 200, 50, 0, 0, 300, 300, 80);
</pre>
<p>Here are the example result, using both text and image watermark</p>
<p><img class="size-full wp-image-4892 alignnone" title="php watermark sample" src="http://superdit.com/wp-content/uploads/2011/02/sample.png" alt="php watermark sample" width="540" height="451" /></p>
<h6>Saving The File</h6>
<p>To save the modified image modify this line of code</p>
<pre class="brush: php; title: ; notranslate">
imagejpeg($img, '', $quality);
</pre>
<p>to</p>
<pre class="brush: php; title: ; notranslate">
imagejpeg($img, 'new_image_name.jpg', $quality);
</pre>
<h6 style="text-align: center;"><a title="basic php watermark demo" href="http://demo.superdit.com/php_basic_watermark/" target="_blank">View Demo</a> | <a href="http://www.box.net/shared/qxg4p5ee1m" target="_blank">Download Source</a></h6>
<p><em><strong>Credit Image</strong>: <a href="http://scissormetimbers.deviantart.com/art/Batman-77165699" target="_blank">Batman</a></em><br />
<em><strong>Font</strong>: <a href="http://www.fontsquirrel.com/fonts/Droid-Sans" target="_blank">Droid Sans</a></em></p>
]]></content:encoded>
			<wfw:commentRss>http://superdit.com/2011/02/01/basic-php-image-watermark-with-gd-library/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Google Web Seach With ExtJS Grid and PHP</title>
		<link>http://superdit.com/2011/01/24/google-web-seach-with-extjs-grid-and-php/</link>
		<comments>http://superdit.com/2011/01/24/google-web-seach-with-extjs-grid-and-php/#comments</comments>
		<pubDate>Mon, 24 Jan 2011 06:02:31 +0000</pubDate>
		<dc:creator>aditia rahman</dc:creator>
				<category><![CDATA[Extjs]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[grid]]></category>
		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://superdit.com/?p=4138</guid>
		<description><![CDATA[This time I want to make a simple example in displaying google web search result in ExtJS grid, other ExtJS component that can be used to displaying this result is dataview, but grid is more common in displaying data in ExtJS, to use google search API you have to signup to get an API key,<a href="http://superdit.com/2011/01/24/google-web-seach-with-extjs-grid-and-php/" class="read-more">Continue Reading</a>]]></description>
			<content:encoded><![CDATA[<p>This time I want to make a simple example in displaying google web search result in ExtJS grid, other ExtJS component that can be used to displaying this result is dataview, but grid is more common in displaying data in ExtJS, to use google search API you have to <a href="http://code.google.com/apis/loader/signup.html" target="_blank">signup</a> to get an API key, one key is only for one domain.</p>
<p><a title="Google API Key Signup" href="http://code.google.com/apis/loader/signup.html" target="_blank"><img class="aligncenter size-full wp-image-4507" title="Google API Key" src="http://superdit.com/wp-content/uploads/2011/01/api-key.png" alt="Google API Key" width="540" height="210" /><span id="more-4138"></span></a></p>
<p>If you want to know the detail about google search API, you can refer this <a href="http://code.google.com/apis/websearch/docs/reference.html" target="_blank">link</a>.</p>
<h6>The ExtJS Code</h6>
<p>The ExtJS code contains Windows, gridPanel, pagingToolbar, searchField</p>
<pre class="brush: jscript; title: ; notranslate">
Ext.onReady(function() {
    var store = new Ext.data.JsonStore({
        root: 'results',
        totalProperty: 'totalCount',
        remoteSort: true,

        fields: [
            'GsearchResultClass',
            'unescapedUrl',
            'url',
            'visibleUrl',
            'cacheUrl',
            'title',
            'titleNoFormatting',
            'content'
        ],

        proxy: new Ext.data.HttpProxy({
            url: 'search.php'
        })
    });

    function renderResult(value, p, record){
        return String.format(
            '&lt;a class=&quot;link&quot; href=&quot;{1}&quot; target=&quot;_blank&quot;&gt;{0}&lt;/a&gt;',
            record.data.title, record.data.unescapedUrl);
    }

    var grid = new Ext.grid.GridPanel({
        border: false,
        width: 485,
        height: 430,
        store: store,
        loadMask: true,
        columns: [{
            header: 'Results',
            dataIndex: 'title',
            width: 480,
            renderer: renderResult
        }],

        viewConfig: {
            forceFit:true,
            enableRowBody:true,
            showPreview:true,
            getRowClass : function(record, rowIndex, p, store){
                p.body = '&lt;p class=&quot;excerpt&quot;&gt;'+record.data.content+'&lt;/p&gt;';
            }
        },
        tbar: [
            '-&gt;',
            new Ext.ux.form.SearchField({
                store: store,
                width: 200,
                emptyText: 'Google Search'
            })
        ],
        bbar: new Ext.PagingToolbar({
            pageSize: 8,
            store: store,
            displayInfo: true
        })
    });

    var window = new Ext.Window({
        title: 'Google Web Search - ExtJS &amp; PHP',
        width: 500,
        height: 460,
        closable: false,
        resizable: false,
        items: [grid]
    }).show();
});
</pre>
<p><strong>The Search Field</strong> used is from the <em>ExtJS ux</em> you can found it on the example section, and it placed in the gridPanel toolbar, inside the <strong>GridPanel</strong> there is a <em>viewConfig, </em>I&#8217;m following this <a href="http://dev.sencha.com/deploy/dev/examples/grid/paging.html" target="_blank">example</a>, this is for displaying search result content (short description)</p>
<h6>The PHP Code</h6>
<p>The PHP code used to make me easier generating json format so ExtJS can be easily read all the data</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php

$start = isset($_REQUEST['start']) ? $_REQUEST['start'] : 0;
$limit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : 8;

$q = str_replace(&quot; &quot;, &quot;%20&quot;, $_REQUEST['query']);
$key = &quot;insert your key&quot;;

$url = 'https://ajax.googleapis.com/ajax/services/search/web?v=1.0&amp;q='.$q.'&amp;start='.$start.'&amp;rsz='.$limit.'&amp;key='.$key;

$content = file_get_contents($url);
$array = json_decode($content);

$data = array();

foreach ($array-&gt;responseData-&gt;results as $var =&gt; $value)
{
    $data[] = array(
        &quot;GsearchResultClass&quot; =&gt; $value-&gt;GsearchResultClass,
        &quot;unescapedUrl&quot;       =&gt; $value-&gt;unescapedUrl,
        &quot;visibleUrl&quot;         =&gt; $value-&gt;visibleUrl,
        &quot;cacheUrl&quot;           =&gt; $value-&gt;cacheUrl,
        &quot;title&quot;              =&gt; $value-&gt;title,
        &quot;titleNoFormatting&quot;  =&gt; $value-&gt;titleNoFormatting,
        &quot;content&quot;            =&gt; $value-&gt;content
    );
}

$out = array(
    &quot;success&quot; =&gt; true,
    &quot;totalCount&quot; =&gt; $array-&gt;responseData-&gt;cursor-&gt;estimatedResultCount,
    &quot;results&quot; =&gt; $data
);

echo json_encode($out);

?&gt;
</pre>
<h6>The CSS Code</h6>
<p>This is the simple CSS code for customizing the grid row style</p>
<pre class="brush: css; title: ; notranslate">
.link {
    color: #333;
    line-height: 25px;
    text-decoration: none;
    font-size: 13px;
    padding: 5px 10px;
    display: block;
    -webkit-border-radius: 1.0em;
    -moz-border-radius: 1.0em;
    border-radius: 1.0em;
}
.link:hover {
    background: #333;
    color: #f3f3f3;
}
.excerpt {
    padding: 5px 20px;
    color: #999;
}
</pre>
<p>Here is the result</p>
<p style="text-align: center;"><a href="http://demo.superdit.com/ext_php_google/" target="_blank"><img class="aligncenter size-full wp-image-4498" title="Google Web Search With ExtJS &amp; PHP" src="http://superdit.com/wp-content/uploads/2011/01/screenshot.png" alt="Google Web Search With ExtJS &amp; PHP" width="509" height="471" /></a></p>
<h6 style="text-align: center;"><a href="http://demo.superdit.com/ext_php_google/" target="_blank">View Demo</a> | <a href="http://www.box.net/shared/iyf2x8or8h" target="_blank">Download Source</a></h6>
]]></content:encoded>
			<wfw:commentRss>http://superdit.com/2011/01/24/google-web-seach-with-extjs-grid-and-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Digg Like URL Submitter Using JQuery and PHP</title>
		<link>http://superdit.com/2011/01/18/digg-like-url-submitter-using-jquery-and-php/</link>
		<comments>http://superdit.com/2011/01/18/digg-like-url-submitter-using-jquery-and-php/#comments</comments>
		<pubDate>Tue, 18 Jan 2011 13:13:52 +0000</pubDate>
		<dc:creator>aditia rahman</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[digg]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://superdit.com/?p=4168</guid>
		<description><![CDATA[Today I want to create something that fetching the submitted url data, some kind that many social bookmarking have, beside facebook, the other famous one is digg, this image below is something that I share in this post. Not all feature I create, like fetch the url images, auto submit when user paste an url,<a href="http://superdit.com/2011/01/18/digg-like-url-submitter-using-jquery-and-php/" class="read-more">Continue Reading</a>]]></description>
			<content:encoded><![CDATA[<p>Today I want to create something that fetching the submitted url data, some kind that many social bookmarking have, beside facebook, the other famous one is digg, this image below is something that I share in this post.</p>
<p><a title="Digg Like Url Submitter Using JQuery and PHP" href="http://superdit.com/2011/01/18/digg-like-url-submitter-using-jquery-and-php" target="_blank"><img class="aligncenter size-full wp-image-4180" title="digg url submit" src="http://superdit.com/wp-content/uploads/2011/01/localhost_digg_url_submit.png" alt="" width="500" height="194" /></a></p>
<p>Not all feature I create, like fetch the url images, auto submit when user paste an url, etc.  But I make the look and feel like a digg style, digg use very cool blue color combination.<span id="more-4168"></span></p>
<h6 style="text-align: center;"><a href="http://demo.superdit.com/digg_url_submit/" target="_blank">View Demo</a> | <a href="http://www.box.net/shared/8tby60rppe" target="_blank">Download Source</a></h6>
<p><strong>The HTML</strong></p>
<pre class="brush: xml; title: ; notranslate">
&lt;div id=&quot;cont&quot;&gt;
    &lt;div id=&quot;error&quot;&gt;Unable to fetch this url. &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span&gt;x&lt;/span&gt;&lt;/div&gt;
    &lt;div&gt;
        &lt;button id=&quot;btsubmit&quot;&gt;Fetch &amp;darr;&lt;/button&gt;
        &lt;input type=&quot;text&quot; id=&quot;text_url&quot; name=&quot;url&quot; /&gt;
    &lt;/div&gt;
    &lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
    &lt;div id=&quot;hidden&quot;&gt;
        &lt;div id=&quot;detail&quot; class=&quot;clear&quot;&gt;
            &lt;div id=&quot;title&quot;&gt;&lt;/div&gt;
            &lt;div id=&quot;description&quot;&gt;&lt;/div&gt;
            &lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
        &lt;/div&gt;
        &lt;div class=&quot;clear&quot;&gt;
            &lt;a href=&quot;&quot; id=&quot;btcancel&quot;&gt;Cancel&lt;/a&gt;
            &lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;
</pre>
<p>The main html is this example is the text field url, it will become widen when focus event is triggered, there are two hidden div element, one for error messages and one for displaying when the server success fetching the url title and description, all of this html element event will be defined by jquery code below.</p>
<p><strong>The JQuery</strong></p>
<pre class="brush: jscript; title: ; notranslate">
$(function() {
    $(&quot;#text_url&quot;).val(&quot;Submit a link&quot;);

    $(&quot;#text_url&quot;).focusin(function() {
        if ($(this).val() == &quot;Submit a link&quot;) {
            $(&quot;#text_url&quot;).val(&quot;&quot;);
        }

        $(this).css(&quot;color&quot;, &quot;#666&quot;);
        $(this).animate({
            width: 500
        }, 300);
    });

    $(&quot;#text_url&quot;).focusout(function() {
        urlFocusOut();
    });

    function urlFocusOut() {
        $(&quot;#text_url&quot;).css(&quot;color&quot;, &quot;#80a1c1&quot;);

        if ($(&quot;#text_url&quot;).val() == &quot;&quot;) {
            $(&quot;#text_url&quot;).val(&quot;Submit a link&quot;);
            $(&quot;#text_url&quot;).animate({
                width: 200
            }, 300);
        }
    }

    function fetchUrl() {
        var url = $(&quot;#text_url&quot;).val();
        var valid = false;

        if(/^([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&amp;'\(\)\*\+,;=]|:)*@)?((\[(|(v[\da-f]{1,}\.(([a-z]|\d|-|\.|_|~)|[!\$&amp;'\(\)\*\+,;=]|:)+))\])|((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&amp;'\(\)\*\+,;=])*)(:\d*)?)(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&amp;'\(\)\*\+,;=]|:|@)*)*|(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&amp;'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&amp;'\(\)\*\+,;=]|:|@)*)*)?)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&amp;'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&amp;'\(\)\*\+,;=]|:|@)*)*)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&amp;'\(\)\*\+,;=]|:|@)){0})(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&amp;'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&amp;'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(url)) {
            valid = true;
        } else {
            valid = false;
        }

        if (url != &quot;&quot; &amp;&amp; url != &quot;Submit a link&quot; &amp;&amp; valid) {
            $(&quot;#btsubmit&quot;).attr(&quot;disabled&quot;, &quot;disabled&quot;);
            $(&quot;#btsubmit&quot;).css(&quot;color&quot;, &quot;#999&quot;);
            $(&quot;#btsubmit&quot;).css(&quot;border-color&quot;, &quot;#999&quot;);
            $(&quot;#error&quot;).fadeOut('slow');

            $.ajax({
                type: &quot;POST&quot;,
                url: &quot;fetch_url.php&quot;,
                data: &quot;url=&quot;+$(&quot;#text_url&quot;).val(),
                success: function(msg) {
                    var obj = jQuery.parseJSON(msg);

                    if (!obj.title &amp;&amp; obj.description == null) {
                        $(&quot;#error&quot;).fadeIn('slow');
                    } else {
                        $('#hidden').slideDown('slow', function() {
                            $(&quot;#title&quot;).html(obj.title);
                            $(&quot;#description&quot;).html(obj.description);
                        });
                    }
                }
            });
        } else {
            $(&quot;#error&quot;).fadeIn('slow');
        }
    }

    $(&quot;#btcancel&quot;).click(function() {
        $(&quot;#btsubmit&quot;).removeAttr(&quot;disabled&quot;);
        $(&quot;#btsubmit&quot;).css(&quot;color&quot;, &quot;#1b5790&quot;);
        $(&quot;#btsubmit&quot;).css(&quot;border-color&quot;, &quot;#1b5790&quot;);
        $('#hidden').slideUp('slow');
        $(&quot;#text_url&quot;).val(&quot;&quot;);
        urlFocusOut();
        return false;
    });

    $(&quot;#btsubmit&quot;).click(function() {
        fetchUrl();
    });

    $(&quot;#error&quot;).click(function() {
        $(this).fadeOut('slow');
    });
});
</pre>
<p>I&#8217;m use the <em>focusin</em> and <em>focusout</em> event to make resizing the textfield, and before submitting the url there is a url validation, I&#8217;m not write this validation my self, I get this from <a href="http://stackoverflow.com/questions/2723140/validating-url-with-jquery-without-the-validate-plugin" target="_blank">stackoverflow</a>, well but not really perfect I need to do another validation for data callback from the server.</p>
<p><strong>The PHP</strong></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php

function getMetaTitle($content){
  $pattern = &quot;|&lt;[\s]*title[\s]*&gt;([^&lt;]+)&lt;[\s]*/[\s]*title[\s]*&gt;|Ui&quot;;
  if(preg_match($pattern, $content, $match))
	return $match[1];
  else
	return false;
}

$url = $_POST['url'];

$data = array();

// get url title
$content = @file_get_contents($url);
$data['title'] = getMetaTitle($content);

// get url description from meta tag
$tags = @get_meta_tags($url);
$data['description'] = $tags['description'];

echo json_encode($data);

?&gt;
</pre>
<p>And yes for fetching the title I get the code from <a href="http://www.tildemark.com/programming/php/getting-website-title-and-description.html" target="_blank">tildemark</a>, and we can simply use <em>get_meta_tags()</em> function in PHP to get common meta tags used in a web page, and this script giving back data to the client as a json format, another way maybe you can use the  <em>curl()</em> function to fetch the url content, it is up to you.</p>
<p><strong>The CSS</strong></p>
<pre class="brush: css; title: ; notranslate">
* {
    font-family: Arial, &quot;Free Sans&quot;;
}
#cont {
    padding: 10px;
    width: 600px;
    background: #e5ecf3;
    margin: 0 auto;
}
#btsubmit {
    width: 70px;
    float: right;
    border: 1px solid #1b5790;
    font-size: 14px;
    font-weight: bold;
    color: #105cd2;
    margin-left: 10px;
    padding: 5px;
    position: relative;
    top: 1px;
    -webkit-border-radius: .3em;
    -moz-border-radius: .3em;
    border-radius: .3em;
    cursor: pointer;
}

#btsubmit:active {
    -moz-box-shadow: inset 0 0 5px #666;
    -webkit-box-shadow: inset 0 0 5px #666;
    box-shadow: inset 0 0 5px #666;
}

#text_url {
    float: right;
    width: 200px;
    border: 1px solid #80a1c1;
    color: #80a1c1;
    font-size: 16px;
    padding: 5px;
}

.clear {
    clear: both;
}

#hidden {
    background:#e5ecf3;
    display: none;
}

#detail {
    background:#e5ecf3;
    margin-top: 10px;
    width: 510px;
    float: right;
}

#title, #description {
    -webkit-border-radius: .3em;
    -moz-border-radius: .3em;
    border-radius: .3em;
    background: #fff;
}

#title {
    width: 360px;
    padding: 10px;
    color: #356190;
    font-weight: bold;
    font-size: 16px;
    float: right;
}

#description {
    width: 360px;
    padding: 10px;
    color: #80a1c1;
    font-size: 14px;
    margin-top: 10px;
    float: right;
}

#btcancel {
    margin-top: 10px;
    color: #356190;
    font-size: 14px;
    text-decoration: none;
    float:right;
}
#btcancel:hover {
    text-decoration: underline;
}

#error {
    padding: 7px 5px;
    background: #a12a2a;
    font-size: 11px;
    font-weight: bold;
    color: #fff;
    -webkit-border-radius: .5em;
    -moz-border-radius: .5em;
    border-radius: .5em;
    position: absolute;
    width: 154px;
    opacity:0.8;
    filter: alpha(opacity=80);
    top: 2px;
    cursor: pointer;
    display: none;
}

#error span {
    -webkit-border-radius: .3em;
    -moz-border-radius: .3em;
    border-radius: .3em;
    color: #a12a2a;
    position: relative;
    top: -1px;
    padding: 0 4px 1px 4px;
    background: #fff;
}
</pre>
<p>There are some CSS3 feature used in this digg style example, like box shadow, rounded corner, so in current available IE maybe look a bit ugly, well that&#8217;s all, here are the online demo and the download link.</p>
<h6 style="text-align: center;"><a href="http://demo.superdit.com/digg_url_submit/" target="_blank">View Demo</a> | <a href="http://www.box.net/shared/8tby60rppe" target="_blank">Download Source</a></h6>
<p>To make it perfect I think it could add the image fetch from the url, and this reference maybe help <a href="http://stackoverflow.com/questions/1513418/get-all-images-url-from-string" target="_blank">Stackoverflow get all images url from string</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://superdit.com/2011/01/18/digg-like-url-submitter-using-jquery-and-php/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Simple Guest Book With Sencha Touch and PHP</title>
		<link>http://superdit.com/2011/01/07/simple-guest-book-with-sencha-touch-and-php/</link>
		<comments>http://superdit.com/2011/01/07/simple-guest-book-with-sencha-touch-and-php/#comments</comments>
		<pubDate>Fri, 07 Jan 2011 10:29:02 +0000</pubDate>
		<dc:creator>aditia rahman</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Sencha Touch]]></category>
		<category><![CDATA[guestbook]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://superdit.com/?p=3822</guid>
		<description><![CDATA[A Guest Book application is one of the oldest tutorial in programming, I remember when I first learning PHP, guestbook simple guestbook application give me a good example to show how the the PHP script communicating with the html interface including the javascript. Now I want port it in Sencha Touch interface, this example will<a href="http://superdit.com/2011/01/07/simple-guest-book-with-sencha-touch-and-php/" class="read-more">Continue Reading</a>]]></description>
			<content:encoded><![CDATA[<p>A Guest Book application is one of the oldest tutorial in programming, I remember when I first learning PHP, guestbook simple guestbook application give me a good example to show how the the PHP script communicating with the html interface including the javascript. Now I want port it in Sencha Touch interface, this example will be very simple there no validation, only insert data and show existing data.</p>
<p style="text-align: center;"><a title="Simple Guest Book With Sencha Touch and PHP" href="http://superdit.com/2011/01/07/simple-guest-book-with-sencha-touch-and-php/" target="_self"><img class="aligncenter size-full wp-image-3853" src="http://superdit.com/wp-content/uploads/2011/01/thumb.png" alt="" width="500" height="212" /></a><span id="more-3822"></span></p>
<h6 style="text-align: center;"><a title="Sencha Touch Guest Book Download Source" href="http://www.2shared.com/file/ETGu2pB9/Simple_Guest_Book_With_Sencha_.html" target="_blank">Download Source</a></h6>
<p>Here is the table that I prepared for this example</p>
<pre class="brush: sql; title: ; notranslate">
CREATE TABLE IF NOT EXISTS `messages` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) NOT NULL,
  `email` varchar(50) NOT NULL,
  `url` varchar(100) NOT NULL,
  `message` varchar(255) NOT NULL,
  `date_entry` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
</pre>
<p>Main html code for the layout, this html is inside the body, sure you must include the sencha touch files by yourself</p>
<pre class="brush: xml; title: ; notranslate">
&lt;div id=&quot;guests&quot; class=&quot;x-hidden-display&quot;&gt;
    &lt;tpl for=&quot;.&quot;&gt;
        &lt;div class=&quot;detail&quot;&gt;
            &lt;div class=&quot;clear&quot;&quot;&gt;
                &lt;label class=&quot;label2 topleft&quot;&gt;Sender&lt;/label&gt;
                &lt;span class=&quot;span2 topright&quot;&gt;{name}&lt;/span&gt;
            &lt;/div&gt;
            &lt;div class=&quot;clear&quot;&quot;&gt;
                &lt;label class=&quot;label2&quot;&gt;Url&lt;/label&gt;
                &lt;span class=&quot;span2&quot;&gt;{url}&lt;/span&gt;
            &lt;/div&gt;
            &lt;div class=&quot;clear&quot;&quot;&gt;
                &lt;label class=&quot;label2 bottomleft&quot;&gt;Message&lt;/label&gt;
                &lt;span class=&quot;span2 bottomright&quot;&gt;{message}&lt;/span&gt;
            &lt;/div&gt;
            &lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
        &lt;/div&gt;
    &lt;/tpl&gt;
&lt;/div&gt;
</pre>
<p>The main sencha touch component used in this example is TabPanel, there two tab, first is the form and second for displaying data, you can see above there is a <em>&lt;tpl&gt;</em> tag, this is where the existing data will be displayed,, so the component will use XTemplate, now here is the sencha touch code, that I always create separately</p>
<pre class="brush: jscript; title: ; notranslate">
Ext.setup({
    glossOnIcon: false,
    onReady: function() {

        var tpl = Ext.XTemplate.from('guests');

		Ext.regModel('User', {
            fields: [
                { name: 'id',       type: 'string' },
                { name: 'name',     type: 'string' },
                { name: 'email',    type: 'string' },
                { name: 'url',      type: 'string' },
                { name: 'message',  type: 'string' }
            ]
        });

		var formBase =  new Ext.form.FormPanel({
            scroll: 'vertical',
            url   : 'server.php',
            standardSubmit : false,
            title: 'Guestbook',
            items: [{
                xtype: 'fieldset',
                title: '',
                instructions: 'Please complete the information.',
                defaults: {
                    labelAlign: 'left',
                    labelWidth: '40%'
                },
                items: [
                    {
                    xtype: 'textfield',
                    name : 'name',
                    label: 'Name',
                    useClearIcon: true,
                    autoCapitalize : false
                }, {
                    xtype: 'emailfield',
                    name : 'email',
                    label: 'Email',
                    placeHolder: 'me@yurl.com',
                    useClearIcon: true
                }, {
                    xtype: 'urlfield',
                    name : 'url',
                    label: 'Url',
                    placeHolder: 'http://yurl.com',
                    useClearIcon: true
                }, {
                    xtype: 'textareafield',
                    name : 'message',
                    label: 'Message',
                    maxLength: 50,
                    maxRows: 5,
                    height: 120
                }]
            }],

            dockedItems: [{
                xtype: 'toolbar',
                dock: 'bottom',
                items: [{
                    xtype: 'spacer'
                }, {
                    text: 'Reset',
                    handler: function() {
                        formBase.reset();
                    }
                }, {
                    text: 'Save',
                    ui: 'confirm',
                    handler: function() {
                        formBase.submit({
                            waitMsg: {
                                message:'Submitting',
                                cls : 'demos-loading'
                            },
                            success: function(e) {
                                showCenteredOverlay();
                                formBase.reset();
                            }
                        });
                    }
                }]
            }]
        });

        var overlayTb = new Ext.Toolbar({
            dock: 'top'
        });

        var overlay = new Ext.Panel({
            floating: true,
            modal: true,
            centered: true,
            width: Ext.is.Phone ? 260 : 400,
            height: 60,
            dockedItems: overlayTb
        });

        var showCenteredOverlay = function() {
            overlayTb.setTitle('Data Inserted');
            overlay.show();
        };

        function showRecent() {
            Ext.Ajax.request({
                url: 'server.php?action=get',
                success: function(e) {
                    var obj = Ext.util.JSON.decode(e.responseText);
                    var guests = obj.guests;
                    if (guests) {
                        var html = tpl.applyTemplate(guests);
                        Ext.getCmp('recentTab').update(html);
                    }
                }
            });
        }

        new Ext.TabPanel({
            fullscreen: true,
            type: 'dark',
            sortable: true,
            items: [formBase, {
                id: 'recentTab',
                title: 'Recent Guests',
                html: '2',
                scroll: 'vertical',
                cls: 'recent',
                listeners: {
                    'beforeshow': showRecent
                }
            }]
        });
    }
});
</pre>
<p>Well that really simple, after user submitted the form, all the form field back to it&#8217;s default value, and the panel I used in here as overlay as the message box, working with form submit, the ajax request, server callback in sencha touch is very similar from extjs. And the beforeshow event binded to the second tab, it will load the data from the server, and to viewing data I only use Xtemplate which mean the data displaying in plain html format.</p>
<p>The PHP code, using the PDO</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php

$dsn = 'mysql:dbname=senchatouch_guestbook;host=127.0.0.1';
$user = 'root';
$password = '';
try {
    $dbh = new PDO($dsn, $user, $password);

    if (isset($_GET['action']) &amp;&amp; $_GET['action'] == &quot;get&quot;) {
        $sql = &quot;SELECT * FROM messages&quot;;
        $guests = array();
        foreach ($dbh-&gt;query($sql) as $row)
        {
            $guests[] = array(
                'id' =&gt; $row['id'],
                'name' =&gt; $row['name'],
                'email' =&gt; $row['email'],
                'url' =&gt; $row['url'],
                'message' =&gt; $row['message'],
                'date' =&gt; $row['date_entry']
            );
        }
        echo json_encode(array('success' =&gt; true, 'guests' =&gt; $guests));
    } else {
        $dbh-&gt;exec(&quot;INSERT INTO messages VALUES ('', '&quot;.$_POST['name'].&quot;',
            '&quot;.$_POST['email'].&quot;', '&quot;.$_POST['url'].&quot;', '&quot;.$_POST['message'].&quot;',
            '&quot;.date(&quot;Y-m-d H:i:s&quot;).&quot;')&quot;);

        echo '{&quot;success&quot;:true, &quot;msg&quot;:'.json_encode('Data Inserted').'}';
    }
} catch (PDOException $e) {
    echo 'Connection failed: ' . $e-&gt;getMessage();
}

?&gt;
</pre>
<p>See there is no validation or something in PHP code, I just want to make it fast, and lastly the CSS code</p>
<pre class="brush: css; title: ; notranslate">
.recent {
    color: #333;
}
.detail {
    background: #d3d3d3;
    border-bottom: 1px solid #c3c3c3;
    padding: 5px;
    font-size: 14px;
    font-weight: bold;
}
.label2 {
    background: #f3f3f3;
    display: block;
    padding: 10px;
    width: 100px;
    float: left;
    border-bottom: 2px solid #f3f3f3;
}
.span2 {
    display: block;
    padding: 10px;
    background: #666;
    color: #fff;
    float: left;
    width: 210px;
    border-bottom: 2px solid #f3f3f3;
}
.bottomleft {
    -webkit-border-bottom-left-radius: .5em;
}
.bottomright {
    -webkit-border-bottom-right-radius: .5em;
}
.topright {
    -webkit-border-top-right-radius: .5em;
}
.topleft {
    -webkit-border-top-left-radius: .5em;
}
.clear {
    clear: both;
}
</pre>
<p>And here the download link and what the screen capture look like, I tested on Android SDK version 2.1</p>
<h6 style="text-align: center;"><a title="Sencha Touch Guest Book Download Source" href="http://www.box.net/shared/az67arcsjt" target="_blank">Download Source</a></h6>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-3847" title="Sencha Touch Guest Book Data Submitted" src="http://superdit.com/wp-content/uploads/2011/01/submitted.png" alt="" width="329" height="489" /></p>
<p style="text-align: center;"><em>Sencha Touch Guest Book Data Submitted Capture</em></p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-3848" title="Sencha Touch Guest Book View Data" src="http://superdit.com/wp-content/uploads/2011/01/recent-guest.png" alt="" width="329" height="488" /></p>
<p style="text-align: center;"><em>Sencha Touch Guest Book View Data Capture</em></p>
]]></content:encoded>
			<wfw:commentRss>http://superdit.com/2011/01/07/simple-guest-book-with-sencha-touch-and-php/feed/</wfw:commentRss>
		<slash:comments>39</slash:comments>
		</item>
		<item>
		<title>Building RSS Reader With Sencha Touch and PHP</title>
		<link>http://superdit.com/2010/12/18/building-rss-reader-with-sencha-touch-and-php/</link>
		<comments>http://superdit.com/2010/12/18/building-rss-reader-with-sencha-touch-and-php/#comments</comments>
		<pubDate>Sat, 18 Dec 2010 14:49:38 +0000</pubDate>
		<dc:creator>aditia rahman</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Sencha Touch]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[sencha]]></category>

		<guid isPermaLink="false">http://superdit.com/?p=3164</guid>
		<description><![CDATA[Sencha Touch is one of the mobile web appication framework available that we can download for free, it targeted for iPhone, Android or Tablet devices, if you have some experience with ExtJS, I believe you have one advantage in learning Sencha Touch, most of the component, code structure built similar with ExtJS.  This is my<a href="http://superdit.com/2010/12/18/building-rss-reader-with-sencha-touch-and-php/" class="read-more">Continue Reading</a>]]></description>
			<content:encoded><![CDATA[<p><a title="Sencha Touch" href="http://www.sencha.com/products/touch/" target="_blank">Sencha Touch</a> is one of the mobile web appication framework available that we can download for free, it targeted for iPhone, Android or Tablet devices, if you have some experience with ExtJS, I believe you have one advantage in learning Sencha Touch, most of the component, code structure built similar with ExtJS.  This is my first bite, tasting sencha touch I have created RSS reader that read from FeedBurner .</p>
<p>Ok lets get our finger dirty, first I created the main html file, this will include the sencha touch files (javascript and css) and my custom script for creating this application, this main html file I called <em>rss-list.html</em></p>
<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
	&lt;title&gt;RSS List&lt;/title&gt;
	&lt;link rel=&quot;stylesheet&quot; href=&quot;sencha-touch/resources/css/sencha-touch.css&quot;/&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;sencha-touch/sencha-touch-debug.js&quot;&gt;&lt;/script&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;apps.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p><span id="more-3164"></span></p>
<p>As you can see on the code above I separate sencha touch files on the <em>sencha-touch </em>folder and the <em>apps.js </em>is located in the same folder as <em>rss-list.html</em>, this file contain all the implementation of sencha touch component, and here what it look like (filename: <em>apps.js</em>)</p>
<pre class="brush: jscript; title: ; notranslate">
Ext.setup({
    onReady: function() {
        Ext.regModel('ListItem', {
            fields: [
                { name: 'text', type: 'string' },
                { name: 'url', type: 'string' }
            ]
        });

        var store = new Ext.data.TreeStore({
            model: 'ListItem',
            proxy: {
                type: 'ajax',
                url: 'blogname.json',
                reader: {
                    type: 'tree',
                    root: 'items'
                }
            }
        });

        var topToolbar = new Ext.Toolbar({
            dock : 'top',
            ui: 'dark',
            title: 'Top Blog Feed'
        });

        var nestedList = new Ext.NestedList({
            fullscreen: true,
            style: 'font-weight:bold',
            dockedItems: [topToolbar],
            modal: true,
            toolbar: {
                dock: 'bottom',
                id: 'tb1',
                layout: {
                    pack : 'center'
                },
                items: [{
                    text: 'Home',
                    handler: function() {
                        store.setProxy({
                            type: 'ajax',
                            url: 'blogname.json',
                            reader: {
                                type: 'tree',
                                root: 'items'
                            }
                        });
                        store.load();
                        topToolbar.setTitle(&quot;Top Blog Feed&quot;);
                    }
                }]
            },
            displayField: 'text',
            store: store
        });

        nestedList.on('leafitemtap', function(subList, subIdx, el, e,
            detailCard) {
            var ds = subList.getStore(),
                r  = ds.getAt(subIdx);

            store.setProxy({
                type: 'ajax',
                url: 'getFeed.php?blogid=' + subIdx,
                reader: {
                    type: 'tree',
                    root: 'items'
                }
            });
            store.load();
            topToolbar.setTitle(r.get('text'));

            nestedList.on('leafitemtap', function(subList, subIdx, el, e,
                detailCard) {
                var ds = subList.getStore(),
                    r  = ds.getAt(subIdx);

                window.location = r.get('url');
            });

        });

    }
});
</pre>
<p>This example using <em>NestedList</em> for the main component, it will need data that can be retrieve by <em>TreeStore</em> component, I&#8217;m thinking it like ExtJS dataStore, we can change the data by reconfiguring the proxy component  as much as we like, therefore this example not using the tree child to opening each title of the rss article, but just reloading the NestedList.</p>
<p>Data that store will read is json format and this is the basic blog name that we will fetch, I&#8217;m using my favorite blog name to show this example, you can change with other if you want to, filename <em>blogname.json</em></p>
<pre class="brush: jscript; title: ; notranslate">
{
	&quot;items&quot;: [{
		&quot;text&quot;: &quot;Hongkiat&quot;,
		&quot;leaf&quot;: true
	}, {
		&quot;text&quot;: &quot;1stWebDesigner&quot;,
		&quot;leaf&quot;: true
	}, {
		&quot;text&quot;: &quot;Speckyboy&quot;,
		&quot;leaf&quot;: true
	}]
}
</pre>
<p>The last file is to getting the latest article from every blog that choosed, I modify this php script from <a title="Reading a FeedBurner Feed with PHP and cURL" href="http://www.vancelucas.com/blog/reading-a-feedburner-feed-with-php-and-curl/" target="_blank">this source</a> (filename: <em>getFeed.php) </em></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php

if ($_GET['blogid'] == '0') {
	$blogname = 'hongkiat';
} elseif ($_GET['blogid'] == '1') {
	$blogname = '1stwebdesigner';
} elseif ($_GET['blogid'] == '2') {
	$blogname = 'speckboy-design-magazine';
}

// URL location of your feed
$feedUrl = &quot;http://feeds.feedburner.com/&quot;.$blogname;
$feedContent = &quot;&quot;;

// Fetch feed from URL
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $feedUrl);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);

// FeedBurner requires a proper USER-AGENT...
curl_setopt($curl, CURL_HTTP_VERSION_1_1, true);
curl_setopt($curl, CURLOPT_ENCODING, &quot;gzip, deflate&quot;);
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);

$feedContent = curl_exec($curl);
curl_close($curl);

if($feedContent &amp;&amp; !empty($feedContent)) {
	$feedXml = simplexml_load_string($feedContent);

	$data = array();

	if($feedXml) {
		foreach($feedXml-&gt;channel-&gt;item as $item) {
			$data[] = array(
				'text' =&gt; &quot;&quot;.$item-&gt;title,
				'leaf' =&gt; true,
				'url' =&gt; &quot;&quot;.$item-&gt;link
			);
		}
	}

}

echo json_encode(array('items' =&gt; $data));
?&gt;
</pre>
<p>Yep that&#8217;s all, but I know this is not enough yet, some feature that I haven&#8217;t found are adding an icon in each list, create this example using TreeStore that have children, loading message or masking the list while loading and displaying the article content in a mobile web format (this example just redirecting to original url), if you know better way to do this, you can let know, and by the way here are the screenshot that I have tested on Android Emulator, and the download link.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-3458" title="Sencha Touch RSS Reader" src="http://superdit.com/wp-content/uploads/2010/12/Screenshot1.png" alt="" width="500" height="373" /></p>
<p style="text-align: center;"><a title="Sencha Touch RSS Reader" href="http://www.box.net/shared/ixp571nz7q" target="_blank">Download Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://superdit.com/2010/12/18/building-rss-reader-with-sencha-touch-and-php/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

