<?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>Nazly's BLOG &#187; PHP</title>
	<atom:link href="http://www.nazly.net/category/technology/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nazly.net</link>
	<description>Personal Weblog of Nazly Ahmed : Web Developer. PHP Addict. Wordpress Hacker. FOSS Enthusiast. (Micro)Blogger. Cricket Fanatic. Husband. Dad.</description>
	<lastBuildDate>Sat, 19 Jun 2010 07:26:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PHP date() function usage and examples</title>
		<link>http://www.nazly.net/php-date-function-usage-and-examples/</link>
		<comments>http://www.nazly.net/php-date-function-usage-and-examples/#comments</comments>
		<pubDate>Sat, 19 Jun 2010 07:26:55 +0000</pubDate>
		<dc:creator>Nazly</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[calendar]]></category>
		<category><![CDATA[character]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[examples]]></category>
		<category><![CDATA[format]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[manual]]></category>
		<category><![CDATA[time]]></category>
		<category><![CDATA[usage]]></category>
		<category><![CDATA[website]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.nazly.net/?p=942</guid>
		<description><![CDATA[I have been coding PHP like for almost 10 years. The date() function in PHP is a widely used function in most of my apps. The application or website I&#8217;m developing will require to associate with a date at some point. When displaying a date/time it requires to be displayed in a particular format. This [...]]]></description>
			<content:encoded><![CDATA[<p>I have been coding PHP like for almost 10 years. The date() function in PHP is a widely used function in most of my apps. The application or website I&#8217;m developing will require to associate with a date at some point. When displaying a date/time it requires to be displayed in a particular format. This will be different from one app to another. So remembering each format character is quite difficult even thought I have 10 years of experience on my back. So each an every time I head to the <a href="http://php.net/manual/en/function.date.php" target="_blank">PHP: date() Manual</a> to find out the format character. I have had cheat sheet wallpapers as my desktop wallpaper but I still felt the PHP Manual served me better. But finally I decided to build my own reference with commonly used character combinations with their respective output to make my life much easier (not that it was difficult before) so that other PHP developers will benefit out of this as well.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">#The two example outputs are based on this time
</span><span style="color: #666666; font-style: italic;">#eg1: 2010-06-19 15:09:35
</span><span style="color: #666666; font-style: italic;">#eg2: 2010-06-19 08:30:59
</span>
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Y-m-d&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">#Output eg1: 2010-06-19
</span><span style="color: #666666; font-style: italic;">#Output eg2: 2010-06-19
</span>
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;n/j/y&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">#Output eg1: 6/19/10
</span><span style="color: #666666; font-style: italic;">#Output eg2: 6/19/10
</span>
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Y-m-d H:i:s&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">#Output eg1: 2010-06-19 15:09:35
</span><span style="color: #666666; font-style: italic;">#Output eg2: 2010-06-19 08:30:59
</span>
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;l, jS F Y h:i a&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">#Output eg1: Saturday, 19th June 2010 03:09 pm
</span><span style="color: #666666; font-style: italic;">#Output eg2: Saturday, 19th June 2010 08:30 am
</span>
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;jS M y g:i A&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">#Output eg1: 19th Jun 10 3:09 PM
</span><span style="color: #666666; font-style: italic;">#Output eg2: 19th Jun 10 8:30 AM
</span>
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;D, j M Y G:i:s&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">#Output eg1: Sat, 19 Jun 2010 15:09:35
</span><span style="color: #666666; font-style: italic;">#Output eg2: Sat, 19 Jun 2010 8:30:59
</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.nazly.net/php-date-function-usage-and-examples/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress 3.0 &#8220;Thelonious&#8221; released</title>
		<link>http://www.nazly.net/wordpress-3-0-thelonious-released/</link>
		<comments>http://www.nazly.net/wordpress-3-0-thelonious-released/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 05:48:07 +0000</pubDate>
		<dc:creator>Nazly</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[matt]]></category>
		<category><![CDATA[mullenweg]]></category>
		<category><![CDATA[thelonious]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress3]]></category>
		<category><![CDATA[wp]]></category>
		<category><![CDATA[wp3]]></category>

		<guid isPermaLink="false">http://www.nazly.net/?p=934</guid>
		<description><![CDATA[It&#8217;s the moment that most of the Wordpress enthusiasts were waiting for. The release of Wordpress 3.0 bring lots of new features and updates that makes Wordpress a powerful CMS to build complex and powerful websites.
Arm your vuvuzelas: WordPress 3.0, the thirteenth major release of WordPress and the culmination of half a year of work [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s the moment that most of the Wordpress enthusiasts were waiting for. The release of Wordpress 3.0 bring lots of new features and updates that makes Wordpress a powerful CMS to build complex and powerful websites.</p>
<p><span style="color: #666666;"><em>Arm your vuvuzelas: WordPress 3.0, the thirteenth major release of WordPress and the culmination of half a year of work by 218 contributors, is <a href="http://wordpress.org/download/" target="_blank">now available for download</a> (or <a href="http://codex.wordpress.org/Dashboard_Updates_SubPanel" target="_blank">upgrade within your dashboard</a>). Major new features in this release include a sexy <strong>new default theme called Twenty Ten</strong>. Theme developers have new APIs that allow them to easily implement custom backgrounds, headers, shortlinks, <a href="http://codex.wordpress.org/Appearance_Menus_SubPanel" target="_blank">menus</a> (no more file editing), <a href="http://codex.wordpress.org/Custom_Post_Types" target="_blank">post types</a>, and <a href="http://codex.wordpress.org/Custom_Taxonomies" target="_blank">taxonomies</a>. (Twenty Ten theme shows all of that off.) Developers and network admins will appreciate the long-awaited <strong>merge of MU and WordPress</strong>, creating the new multi-site functionality which makes it possible to run one blog or ten million from the same installation. As a user, you will love the new <strong>lighter interface</strong>, the contextual help on every screen, the <strong>1,217 bug fixes and feature enhancements</strong>, bulk updates so you can upgrade 15 plugins at once with a single click, and blah blah blah just watch the video:) (In HD, if you can, so you can catch the Easter eggs.)</em></span></p>
<p><span style="color: #444444;"><em>Source : <a href="http://wordpress.org/development/2010/06/thelonious/" target="_blank">http://wordpress.org/development/2010/06/thelonious/</a></em></span></p>
<p><embed src="http://v.wordpress.com/wp-content/plugins/video/flvplayer.swf?ver=1.21" type="application/x-shockwave-flash" width="584" height="330" wmode="transparent" seamlesstabbing="true" allowfullscreen="true" allowscriptaccess="always" overstretch="true" flashvars="guid=BQtfIEY1&amp;width=584&amp;height=330&amp;locksize=no&amp;dynamicseek=false&amp;qc_publisherId=p-18-mFEk4J448M" title="Introducing WordPress 3.0 &quot;Thelonious&quot;"></embed></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nazly.net/wordpress-3-0-thelonious-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Protect your website against SQL injection</title>
		<link>http://www.nazly.net/protect-your-website-against-sql-injection/</link>
		<comments>http://www.nazly.net/protect-your-website-against-sql-injection/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 12:07:35 +0000</pubDate>
		<dc:creator>Nazly</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[db]]></category>
		<category><![CDATA[injection]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[website]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wp]]></category>

		<guid isPermaLink="false">http://www.nazly.net/?p=752</guid>
		<description><![CDATA[SQL injection is one of the deadliest techniques attackers use to exploit the weakness in your database code of your website. Regardless of the technology/scripting language you must make sure your code is 100% perfect against SQL injection.
Here I will use PHP and MySQL examples for its wide usage and also I&#8217;m much more comfortable [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/SQL_injection" target="_blank"><strong>SQL injection</strong></a> is one of the deadliest techniques attackers use to exploit the weakness in your database code of your website. Regardless of the technology/scripting language you must make sure your code is 100% perfect against SQL injection.</p>
<p>Here I will use <a href="http://www.php.net" target="_blank"><strong>PHP</strong></a> and <a href="http://www.mysql.com" target="_blank"><strong>MySQL</strong></a> examples for its wide usage and also I&#8217;m much more comfortable with it. </p>
<p>Here is a basic PHP code that most developers will come up with to access the MySQL DB and get the record of a particular username submitted from a form in our website.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;"># Get posted username value
</span><span style="color: #000088;">$userName</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;usname&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;"># MySQL query string to get the record of the user
</span><span style="color: #000088;">$queryStr</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT * FROM users WHERE usname = '<span style="color: #006699; font-weight: bold;">$userName</span>'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;"># Output the string for debugging
</span><span style="color: #b1b100;">echo</span> <span style="color: #000088;">$queryStr</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;"># Execute the MySQL query
</span><span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$queryStr</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>For example if the username that was submitted is <b>nazly</b> the code will output the following query and execute it.</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">SELECT</span> <span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">FROM</span> users <span style="color: #990099; font-weight: bold;">WHERE</span> usname <span style="color: #CC0099;">=</span> <span style="color: #008000;">'nazly'</span></pre></div></div>

<p>While the query works perfectly and returns the record of that particular user, a attacker can exploit this code by injecting SQL using the submission form. </p>
<p>For example if the attacker submits <b>&#8216; OR &#8216;t&#8217;='t</b> instead of the username the query will be formed like this.</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">SELECT</span> <span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">FROM</span> users <span style="color: #990099; font-weight: bold;">WHERE</span> usname <span style="color: #CC0099;">=</span> <span style="color: #008000;">''</span> <span style="color: #CC0099; font-weight: bold;">OR</span> <span style="color: #008000;">'t'</span><span style="color: #CC0099;">=</span><span style="color: #008000;">'t'</span></pre></div></div>

<p>When this query is executed, it will return all the records in the database since t=t will be TRUE always. The impact it will have on the website will be depend on the code after executing the query. <strong>But the important thing is someone can make the query behave differently than what we actually expected from it</strong>.</p>
<p>It can become deadlier than that if someone submits the following instead of the username<br />
<b>a&#8217;;DROP TABLE users; SELECT * FROM userinfo WHERE &#8216;t&#8217; = &#8216;t</b><br />
The query for the above value will look like this</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">SELECT</span> <span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">FROM</span> users <span style="color: #990099; font-weight: bold;">WHERE</span> usname <span style="color: #CC0099;">=</span> <span style="color: #008000;">'a'</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">DROP</span> <span style="color: #990099; font-weight: bold;">TABLE</span> users<span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">SELECT</span> <span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">FROM</span> userinfo <span style="color: #990099; font-weight: bold;">WHERE</span> <span style="color: #008000;">'t'</span> <span style="color: #CC0099;">=</span> <span style="color: #008000;">'t'</span></pre></div></div>

<p>If the above query is executed, it will delete the whole users table. Similarly an attacker can inject any type of SQL code to modify/delete your tables in the database.</p>
<p>It is a huge security flaw in your code but newbies and even some experienced developers don&#8217;t understand the depth of problem. So developers should make sure to take precautionary measures against it.</p>
<p>In PHP you can use the <a href="http://www.php.net/mysql_real_escape_string" target="_blank"><strong>mysql_real_escape_string()</strong></a> function for this task. This function will escape any special characters in the string to be used in a SQL statement.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;"># Get posted username value by escaping special characters
</span><span style="color: #000088;">$userName</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_real_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;usname&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;"># MySQL query string to get the record of the user
</span><span style="color: #000088;">$queryStr</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT * FROM users WHERE usname = '<span style="color: #006699; font-weight: bold;">$userName</span>'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;"># Output the string for debugging
</span><span style="color: #b1b100;">echo</span> <span style="color: #000088;">$queryStr</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;"># Execute the MySQL query
</span><span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$queryStr</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>If you try to inject SQL to this example, it will have no affect to the Database since the use of this function</p>
<p>If you are a developing a <a href="http://www.wordpress.org"><strong>Wordpress</strong></a> plugin for your website, you must make sure to protect the site against SQL injection as well. Since Wordpress has its own class for database manipulation you should use the methods available in Wordpress.</p>
<p>The escape() function in the <a href="http://codex.wordpress.org/Function_Reference/wpdb_Class" target="_blank"><strong>WPDB</strong></a> class is much similar to using the standard mysql_real_escape_string() function.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">function</span> myWpPluginFunc<span style="color: #009900;">&#40;</span><span style="color: #000088;">$usName</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$u</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">escape</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$usName</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT * FROM users WHERE usname = '<span style="color: #006699; font-weight: bold;">$u</span>'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>But there is a better option available in Wordpress. Rather than escaping individual values you can format the SQL statement and then use the prepare() function in the WPDB class to escape the special characters. The syntax is similar to using sprintf(). Using the prepare() function, the developer is sure that all values are escaped. So less chance for errors.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">function</span> myWpPluginFunc<span style="color: #009900;">&#40;</span><span style="color: #000088;">$usName</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$qstr</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">prepare</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT * FROM users WHERE usname = <span style="color: #009933; font-weight: bold;">%s</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$usName</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$qstr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>For more check out <a href="http://codex.wordpress.org/Data_Validation#Database" target="_blank"><strong>Data Validation in Wordpress</strong></a>.</p>
<p>I wish MySQL functions in PHP had a similar function like WordPress&#8217;s prepare()</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nazly.net/protect-your-website-against-sql-injection/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>PHPMailer for the rescue</title>
		<link>http://www.nazly.net/phpmailer-for-the-rescue/</link>
		<comments>http://www.nazly.net/phpmailer-for-the-rescue/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 09:15:47 +0000</pubDate>
		<dc:creator>Nazly</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[inline]]></category>
		<category><![CDATA[phpmailer]]></category>

		<guid isPermaLink="false">http://www.nazly.net/?p=729</guid>
		<description><![CDATA[When we start building a dynamic website or a Web Application using PHP, sending out Emails to the users is always on top of the To-Dos list. In most cases it will require sending the email in a specific template to maintain the branding of the website/application. In this situation the developer has to send [...]]]></description>
			<content:encoded><![CDATA[<p>When we start building a dynamic website or a Web Application using PHP, sending out Emails to the users is always on top of the To-Dos list. In most cases it will require sending the email in a specific template to maintain the branding of the website/application. In this situation the developer has to send out the emails in HTML Format.</p>
<p>When you use PHP&#8217;s built-in mail() function with the basic parameters, the email is sent out in plain-text.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">mail</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;user@mydomain.com&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;This is the Subject&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Hello World&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>To send out HTML Emails using the built-in mail() function, you will require to add another parameter where you can specify the headers of the email. Here I will add some additional headers to send out a proper a Email with a from address as well. The additional headers should be separated with a <a href="http://en.wikipedia.org/wiki/Newline" target="_blank">CRLF (\r\n)</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">#Specify a From Address
</span><span style="color: #000088;">$addHeaders</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;From: webmaster@ourwebsite.com&quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Set the content-type to send out the email in HTML format
</span><span style="color: #000088;">$addHeaders</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;MIME-Version: 1.0&quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$addHeaders</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;Content-type:text/html;charset=iso-8859-1&quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Mail Body consists HTML tags
</span><span style="color: #000088;">$mailBody</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;h1&gt;Hello World&lt;/h1&gt;
                 &lt;strong&gt;Example: &lt;/strong&gt;How to send a HTML Email&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">mail</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;user@mydomain.com&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;This is the Subject&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$mailBody</span><span style="color: #339933;">,</span> <span style="color: #000088;">$addHeaders</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>In most of the cases there will be a requirement to embed images into HTML since the particular Email template will consists logos, photos etc.</p>
<p>There are actually two ways to do this.</p>
<ol>
<li>You can specify absolute paths to the images on your site.</li>
<li>You can attach images into the message and link it with a special URI.</li>
</ol>
<p>For the first method I will use the built-in mail() function itself.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">#Specify a From Address
</span><span style="color: #000088;">$addHeaders</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;From: webmaster@ourwebsite.com&quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Set the content-type to send out the email in HTML
</span><span style="color: #000088;">$addHeaders</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;MIME-Version: 1.0&quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$addHeaders</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;Content-type:text/html;charset=iso-8859-1&quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Mail Body consists Images with an absolute URI
</span><span style="color: #000088;">$mailBody</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;h1&gt;Hello World&lt;/h1&gt;
                 &lt;strong&gt;Example: &lt;/strong&gt;How to send a HTML Email with images
                 &lt;img src=<span style="color: #000099; font-weight: bold;">\&quot;</span>http://www.mydomain.com/images/photo.jpg<span style="color: #000099; font-weight: bold;">\&quot;</span> /&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">mail</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;user@mydomain.com&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;This is the Subject&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$mailBody</span><span style="color: #339933;">,</span> <span style="color: #000088;">$addHeaders</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>But this method has few drawbacks. Most of the Email clients do not allow displaying images from absolute URLS coz someone can track the people who will be opening this Email. Its a privacy issue, and you can enable to display images from absolute URLS in your Email client. But you can&#8217;t expect every user who will be checking this email to have this option enabled. So the best option is to use the second method.</p>
<p>Using the built-in mail() function to attach images and link it with a special URI can be a painful process in my opinion. It is possible but maintaining that code can be a real pain if the Email templates have to be modified over and over again.</p>
<p><b><a href="http://phpmailer.worxware.com/index.php" target="_blank">PHPMailer</a></b> is a life saver when it comes to sending Emails using PHP. Though the built-in mail() function fulfills  most of our requirements, special cases like SMTP authentication, attaching files, embedding images can be done effectively and easily with PHPMailer without doing any modification to the Server settings.</p>
<p>You need to download the PHPMailer library files from <a href="http://sourceforge.net/projects/phpmailer/" target="_blank">here</a> first.<br />
The following code explains how you can send Emails with inline images. I added the code for SMTP authentication as well.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'class.phpmailer.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;class.smtp.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #000088;">$mail</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PHPMailer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Follwing code segment uses a SMTP server to send email
</span><span style="color: #666666; font-style: italic;"># Comment this segment if you don't wish to use a SMTP server
</span><span style="color: #666666; font-style: italic;"># Use a SMTP Server
</span><span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">IsSMTP</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;"># SMTP Server address                  
</span><span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Host</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;smtp.mydomain.com&quot;</span><span style="color: #339933;">;</span> 
<span style="color: #666666; font-style: italic;"># SMTP Port
</span><span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Port</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">25</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;"># Enable debug for SMTP (Only for testing purposes)
</span><span style="color: #666666; font-style: italic;"># 1 = errors and messages
</span><span style="color: #666666; font-style: italic;"># 2 = messages only
</span><span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">SMTPDebug</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>              
&nbsp;
<span style="color: #666666; font-style: italic;"># From address and Name                                            
</span><span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">SetFrom</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;user@mydomain.com&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;User Display Name&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Message Subject
</span><span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Subject</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Message Subject&quot;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;"># Enable HTML Email
</span><span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">IsHTML</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;"># Embed Images into the Email Body
</span><span style="color: #666666; font-style: italic;"># Attach file logo.jpg and give it an identifier name 'logo'
</span><span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">AddEmbeddedImage</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'logo.jpg'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'logo'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'logo.jpg'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #666666; font-style: italic;"># Attach file photo.jpg and and give it an identifier name 'photo'
</span><span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">AddEmbeddedImage</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'photo.jpg'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'photo'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'photo.jpg'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;"># Use the identifier in the special URI format to link with the attached image
</span><span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Body</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;h1&gt;Hello World&lt;/h1&gt;
                &lt;img src=<span style="color: #000099; font-weight: bold;">\&quot;</span>cid:logo<span style="color: #000099; font-weight: bold;">\&quot;</span> /&gt;
                   &lt;img src=<span style="color: #000099; font-weight: bold;">\&quot;</span>cid:photo<span style="color: #000099; font-weight: bold;">\&quot;</span> /&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># alternate text if the Email client doesn't support HTML
</span><span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">AltBody</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;This is text only alternative body.&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Add recipients of the email
</span><span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">AddAddress</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;you@yoursite.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">AddAddress</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;you@anothersite.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Send out the email 
</span><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Send</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>  
    <span style="color: #666666; font-style: italic;">#if Email failed to send
</span>    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Email not sent&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">#Debug purposes only
</span>    <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ErrorInfo</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;"># If Email was successfully sent out
</span>    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Email sent&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.nazly.net/phpmailer-for-the-rescue/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Extremely Useful PHP Tools</title>
		<link>http://www.nazly.net/extremely-useful-php-tools/</link>
		<comments>http://www.nazly.net/extremely-useful-php-tools/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 23:21:14 +0000</pubDate>
		<dc:creator>Nazly</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.nazly.net/extremely-useful-php-tools/</guid>
		<description><![CDATA[Just came across the 50 Extremely Useful PHP Tools posted at Smashing Magazine which immediately caught my attention. It lists all the great tools around PHP which makes it more easier and fun to code.
I have started to write an article series on PHP which will be featured in an online magazine which is scheduled [...]]]></description>
			<content:encoded><![CDATA[<p>Just came across the <a href="http://www.smashingmagazine.com/2009/01/20/50-extremely-useful-php-tools/" target="_blank">50 Extremely Useful PHP Tools</a> posted at <a href="http://www.smashingmagazine.com/" target="_blank">Smashing Magazine</a> which immediately caught my attention. It lists all the great tools around PHP which makes it more easier and fun to code.</p>
<p>I have started to write an article series on PHP which will be featured in an online magazine which is scheduled to be launched soon. I will post more details about it soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nazly.net/extremely-useful-php-tools/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PHP Projects u need to know</title>
		<link>http://www.nazly.net/php-projects-u-need-to-know/</link>
		<comments>http://www.nazly.net/php-projects-u-need-to-know/#comments</comments>
		<pubDate>Fri, 07 Mar 2008 06:36:13 +0000</pubDate>
		<dc:creator>Nazly</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[projects]]></category>

		<guid isPermaLink="false">http://blog.nazly.net/php-projects-u-need-to-know/</guid>
		<description><![CDATA[Here is list of PHP/Javascript Projects that I have been either using, keeping in track of or got to know recently. Doesn&#039;t matter if you are new to PHP or an expert in PHP, its a worthier try if you haven&#039;t got hold of them yet.
PHPMailer
Even though PHP&#039;s mail() function has been the No.1 choice [...]]]></description>
			<content:encoded><![CDATA[<p>Here is list of PHP/Javascript Projects that I have been either using, keeping in track of or got to know recently. Doesn&#039;t matter if you are new to PHP or an expert in PHP, its a worthier try if you haven&#039;t got hold of them yet.</p>
<p><b>PHPMailer</b><br />
<br />Even though PHP&#039;s mail() function has been the No.1 choice for me to send an email, but <a href="http://phpmailer.codeworxtech.com/" target="_blank">PHPMailer</a> is the ideal choice when I have to attach a file or send an email through a SMTP server with authentication.</p>
<p><b>php user class</b><br />
<br />This is a new addition to my list of classes. I haven&#039;t played around it yet, but <a href="http://phpuserclass.com/" target="_blank">php user class</a> seems to be a cool class to manipulate users (login, logout, register, etc.) in web applications.</p>
<p><b>Magpie RSS</b><br />
<br /><a href="http://magpierss.sourceforge.net/" target="_blank">Magpie RSS</a> can be used to parse RSS feeds.</p>
<p><b>htmlSQL class</b><br />
<br />This is one of the classes I came across recently. Its really cool. Using the <a href="http://www.jonasjohn.de/lab/htmlsql.htm" target="_blank">htmlSQL</a> class we can access HTML values by an SQL like syntax. Amazing ha? <img src="http://www.nazly.net//smiles/icon_smile.gif" alt=":)[Smile]" /></p>
<p><b>Smarty</b><br />
<br /><a href="http://smarty.php.net" target="_blank">Smarty</a> has always been my choice for a Template Engine.</p>
<p><b>StringParser_BBcode</b><br />
<br />BBcode is the best way to allow users to add bit of spice to their posts in forums, blogs etc. As a developer converting the BBcode to HTML can be bit of a tough job but <a href="http://christian-seiler.de/projekte/php/bbcode/index_en.html" target="_blank">StringParser_BBcode</a> can do that for you.</p>
<p><b>easyFormProc</b><br />
<br /><a href="http://nazly.net/easyformproc/" target="_blank">easyFormProc</a> is a class that I developed that will create and handle all the process of the elements in a form. The processes include form posting, validation and retrieving the posted values. I have added few common validation functions. Custom functions can also be added.</p>
<p><b>jQuery</b><br />
<br /><a href="http://jquery.com/" target="_blank">jQuery</a> is a JavaScript Library that simplifies the way we write JavaScript. Handling events, performing animations, and adding Ajax interactions to web pages never been easier. This is a new addition to my list and I&#039;m loving each an every moment of it.</p>
<p><b>tinyMCE</b><br />
<br /><a href="http://tinymce.moxiecode.com/" target="_blank">tinyMCE</a> is a platform independent web based Javascript HTML WYSIWYG editor. It is a real life saver when it comes to developing CMS Applications that requires average users to update content. </p>
<p>These OpenSource projects really help a great deal in our developments. Specially when it comes to PHP, there will be always a solution already written by someone for our problem. So no need to re-invent the wheel. I would like to hear from you on PHP/Javascript projects that you have used/tried/heard during your development so it allows us to share what we know <img src="http://www.nazly.net//smiles/icon_wink.gif" alt="[Wink]" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nazly.net/php-projects-u-need-to-know/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Installing FFMPEG and FFMPEG-PHP on CentOS</title>
		<link>http://www.nazly.net/installing-ffmpeg-and-ffmpeg-php-on-centos/</link>
		<comments>http://www.nazly.net/installing-ffmpeg-and-ffmpeg-php-on-centos/#comments</comments>
		<pubDate>Thu, 30 Aug 2007 04:01:15 +0000</pubDate>
		<dc:creator>Nazly</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[ffmpeg]]></category>
		<category><![CDATA[ffmpeg-php]]></category>
		<category><![CDATA[flv]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[youtube]]></category>

		<guid isPermaLink="false">http://blog.nazly.net/installing-ffmpeg-and-ffmpeg-php-on-centos/</guid>
		<description><![CDATA[Last few weeks couple of my colleagues were working on a website that required converting videos to FLV format which is much similar to what youtube does. Inorder to do this they were using ffmpeg which does all the video conversion. He also used ffmpeg-php which is an extension for PHP that allows to retrieve [...]]]></description>
			<content:encoded><![CDATA[<p>Last few weeks couple of my colleagues were working on a website that required converting videos to FLV format which is much similar to what youtube does. Inorder to do this they were using ffmpeg which does all the video conversion. He also used ffmpeg-php which is an extension for PHP that allows to retrieve information regarding a video file. So I had to get a local development environment working for this particular project. I had an Ubuntu 7.04 box and found <a href="http://linux.justinhartman.com/FFmpeg,_FFmpeg-PHP,_Lame,_Libogg,_Libvorbis,_FLVtool2,_Mplayer,_Mencoder,_AMR_Installation" target="_blank">this tutorial</a> for installing ffmpeg and ffmpeg-php. I was successfully able to get it working and my colleagues built the site and it was working very smoothly.</p>
<p>Now when we got to the stage of launching the site, I had to repeat all the installation on a live server as they don&#039;t come with ffmpeg or ffmpeg-php pre installed. Hosting Companies seem to charge big bucks to get these installed in their servers. So we went for a Virtual Dedicated Server which had root access. It was a Cent OS 4 box and this is how I was able to get ffmpeg and ffmpeg-php installed on it.</p>
<p><b>Switch to working directory</b><br />
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</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>src</pre></div></div>

<p><b>Download the source files needed</b><br />
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #000000; font-weight: bold;">&lt;</span>a <span style="color: #007800;">href</span>=<span style="color: #ff0000;">&quot;http://www3.mplayerhq.hu/MPlayer/releases/codecs/essential-20061022.tar.bz2&quot;</span> <span style="color: #007800;">target</span>=<span style="color: #ff0000;">&quot;_blank&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>http:<span style="color: #000000; font-weight: bold;">//</span>www3.mplayerhq.hu<span style="color: #000000; font-weight: bold;">/</span>MPlayer<span style="color: #000000; font-weight: bold;">/</span>releases<span style="color: #000000; font-weight: bold;">/</span>codecs<span style="color: #000000; font-weight: bold;">/</span>essential-20061022.tar.bz2<span style="color: #000000; font-weight: bold;">&lt;/</span>a<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #000000; font-weight: bold;">&lt;</span>a <span style="color: #007800;">href</span>=<span style="color: #ff0000;">&quot;http://rubyforge.org/frs/download.php/9225/flvtool2_1.0.5_rc6.tgz&quot;</span> <span style="color: #007800;">target</span>=<span style="color: #ff0000;">&quot;_blank&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>http:<span style="color: #000000; font-weight: bold;">//</span>rubyforge.org<span style="color: #000000; font-weight: bold;">/</span>frs<span style="color: #000000; font-weight: bold;">/</span>download.php<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">9225</span><span style="color: #000000; font-weight: bold;">/</span>flvtool2_1.0.5_rc6.tgz<span style="color: #000000; font-weight: bold;">&lt;/</span>a<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #000000; font-weight: bold;">&lt;</span>a <span style="color: #007800;">href</span>=<span style="color: #ff0000;">&quot;http://easynews.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz&quot;</span> <span style="color: #007800;">target</span>=<span style="color: #ff0000;">&quot;_blank&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>http:<span style="color: #000000; font-weight: bold;">//</span>easynews.dl.sourceforge.net<span style="color: #000000; font-weight: bold;">/</span>sourceforge<span style="color: #000000; font-weight: bold;">/</span>lame<span style="color: #000000; font-weight: bold;">/</span>lame-3.97.tar.gz<span style="color: #000000; font-weight: bold;">&lt;/</span>a<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #000000; font-weight: bold;">&lt;</span>a <span style="color: #007800;">href</span>=<span style="color: #ff0000;">&quot;http://superb-west.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.5.0.tbz2&quot;</span> <span style="color: #007800;">target</span>=<span style="color: #ff0000;">&quot;_blank&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>http:<span style="color: #000000; font-weight: bold;">//</span>superb-west.dl.sourceforge.net<span style="color: #000000; font-weight: bold;">/</span>sourceforge<span style="color: #000000; font-weight: bold;">/</span>ffmpeg-php<span style="color: #000000; font-weight: bold;">/</span>ffmpeg-php-0.5.0.tbz2<span style="color: #000000; font-weight: bold;">&lt;/</span>a<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #000000; font-weight: bold;">&lt;</span>a <span style="color: #007800;">href</span>=<span style="color: #ff0000;">&quot;http://downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz&quot;</span> <span style="color: #007800;">target</span>=<span style="color: #ff0000;">&quot;_blank&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>http:<span style="color: #000000; font-weight: bold;">//</span>downloads.xiph.org<span style="color: #000000; font-weight: bold;">/</span>releases<span style="color: #000000; font-weight: bold;">/</span>ogg<span style="color: #000000; font-weight: bold;">/</span>libogg-1.1.3.tar.gz<span style="color: #000000; font-weight: bold;">&lt;/</span>a<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #000000; font-weight: bold;">&lt;</span>a <span style="color: #007800;">href</span>=<span style="color: #ff0000;">&quot;http://downloads.xiph.org/releases/vorbis/libvorbis-1.1.2.tar.gz&quot;</span> <span style="color: #007800;">target</span>=<span style="color: #ff0000;">&quot;_blank&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>http:<span style="color: #000000; font-weight: bold;">//</span>downloads.xiph.org<span style="color: #000000; font-weight: bold;">/</span>releases<span style="color: #000000; font-weight: bold;">/</span>vorbis<span style="color: #000000; font-weight: bold;">/</span>libvorbis-1.1.2.tar.gz<span style="color: #000000; font-weight: bold;">&lt;/</span>a<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p><b>Extract the Source files</b><br />
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">bunzip2</span> essential-20061022.tar.bz2; <span style="color: #c20cb9; font-weight: bold;">tar</span> xvf essential-20061022.tar
<span style="color: #c20cb9; font-weight: bold;">tar</span> zxvf flvtool2_1.0.5_rc6.tgz
<span style="color: #c20cb9; font-weight: bold;">tar</span> zxvf lame-3.97.tar.gz
<span style="color: #c20cb9; font-weight: bold;">bunzip2</span> ffmpeg-php-0.5.0.tbz2; <span style="color: #c20cb9; font-weight: bold;">tar</span> xvf ffmpeg-php-0.5.0.tar
<span style="color: #c20cb9; font-weight: bold;">tar</span> zxvf libogg-1.1.3.tar.gz
<span style="color: #c20cb9; font-weight: bold;">tar</span> zxvf libvorbis-1.1.2.tar.gz</pre></div></div>

<p><b>Create a directory for codecs &amp; import them</b><br />
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</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>lib<span style="color: #000000; font-weight: bold;">/</span>codecs<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> essential-<span style="color: #000000;">20061022</span><span style="color: #000000; font-weight: bold;">/*</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>lib<span style="color: #000000; font-weight: bold;">/</span>codecs<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #660033;">-R</span> <span style="color: #000000;">755</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>lib<span style="color: #000000; font-weight: bold;">/</span>codecs<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p><b>Install SVN/Ruby</b><br />
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">yum <span style="color: #c20cb9; font-weight: bold;">install</span> subversion
yum <span style="color: #c20cb9; font-weight: bold;">install</span> ruby
yum <span style="color: #c20cb9; font-weight: bold;">install</span> ncurses-devel</pre></div></div>

<p><b>Get the latest FFMPEG/MPlayer from the subversion</b><br />
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">svn</span> checkout <span style="color: #c20cb9; font-weight: bold;">svn</span>:<span style="color: #000000; font-weight: bold;">//</span>svn.mplayerhq.hu<span style="color: #000000; font-weight: bold;">/</span>ffmpeg<span style="color: #000000; font-weight: bold;">/</span>trunk <span style="color: #c20cb9; font-weight: bold;">ffmpeg</span>
<span style="color: #c20cb9; font-weight: bold;">svn</span> checkout <span style="color: #c20cb9; font-weight: bold;">svn</span>:<span style="color: #000000; font-weight: bold;">//</span>svn.mplayerhq.hu<span style="color: #000000; font-weight: bold;">/</span>mplayer<span style="color: #000000; font-weight: bold;">/</span>trunk <span style="color: #c20cb9; font-weight: bold;">mplayer</span></pre></div></div>

<p><b>Fix few Lib issues for next steps</b><br />
<br />Add this line in /etc/ld.so.conf<br />
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><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>lib</pre></div></div>

<p>then run<br />
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ldconfig <span style="color: #660033;">-v</span></pre></div></div>

<p><b>Compile LAME</b><br />
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</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>src<span style="color: #000000; font-weight: bold;">/</span>lame-<span style="color: #000000;">3.97</span>
.<span style="color: #000000; font-weight: bold;">/</span>configure
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p><b>Compile libOGG</b><br />
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</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>src<span style="color: #000000; font-weight: bold;">/</span>libogg-1.1.3
.<span style="color: #000000; font-weight: bold;">/</span>configure
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p><b>Compile libVorbis</b><br />
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</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>src<span style="color: #000000; font-weight: bold;">/</span>libvorbis-1.1.2
.<span style="color: #000000; font-weight: bold;">/</span>configure
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p><b>Compile flvtool2</b><br />
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</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>src<span style="color: #000000; font-weight: bold;">/</span>flvtool2_1.0.5_rc6
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p><b>Compile MPlayer</b><br />
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</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>src<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">mplayer</span>
.<span style="color: #000000; font-weight: bold;">/</span>configure
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p><b>Compile FFMPEG</b><br />
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</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>src<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">ffmpeg</span>
.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--enable-libmp3lame</span> <span style="color: #660033;">--enable-libogg</span> <span style="color: #660033;">--enable-libvorbis</span> <span style="color: #660033;">--disable-mmx</span> <span style="color: #660033;">--enable-shared</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'#define HAVE_LRINTF 1'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> config.h
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p><b>Finalize the codec setups</b><br />
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</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>lib<span style="color: #000000; font-weight: bold;">/</span>libavformat.so.50 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>libavformat.so.50
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</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>lib<span style="color: #000000; font-weight: bold;">/</span>libavcodec.so.51 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>libavcodec.so.51
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</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>lib<span style="color: #000000; font-weight: bold;">/</span>libavutil.so.49 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>libavutil.so.49
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</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>lib<span style="color: #000000; font-weight: bold;">/</span>libmp3lame.so.0 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>libmp3lame.so.0
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</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>lib<span style="color: #000000; font-weight: bold;">/</span>libavformat.so.51 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>libavformat.so.51</pre></div></div>

<p><b>Few tasks before compiling FFMPEG-PHP</b><br />
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">yum <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">automake</span>
yum <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">autoconf</span>
yum <span style="color: #c20cb9; font-weight: bold;">install</span> libtool</pre></div></div>

<p><b>Compile FFMPEG-PHP</b><br />
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</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>src<span style="color: #000000; font-weight: bold;">/</span>ffmpeg-php-0.5.0
phpize
.<span style="color: #000000; font-weight: bold;">/</span>configure
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p><b>Add FFMPEG-PHP as an extension of PHP</b><br />
<br />Add this line to your php.ini file (Check the correct path of php.ini)<br />
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">extension</span>=ffmpeg.so</pre></div></div>

<p><b>Restart Apache to load FFMPEG-PHP</b><br />
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">service httpd restart</pre></div></div>

<p><b>Check if FFMPEG-PHP is loaded correctly</b><br />
<br />Create a file called phpinfo.php in your webroot and add the following code<br />
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">phpinfo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Run this page using your browser and if you see a section on ffmpeg then everything is installed and working.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nazly.net/installing-ffmpeg-and-ffmpeg-php-on-centos/feed/</wfw:commentRss>
		<slash:comments>54</slash:comments>
		</item>
		<item>
		<title>CakePHP</title>
		<link>http://www.nazly.net/cakephp/</link>
		<comments>http://www.nazly.net/cakephp/#comments</comments>
		<pubDate>Fri, 18 May 2007 03:56:48 +0000</pubDate>
		<dc:creator>Nazly</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[cake]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[framework]]></category>

		<guid isPermaLink="false">http://blog.nazly.net/cakephp/</guid>
		<description><![CDATA[In the recent poll results of the International PHP Magazine, CakePHP has ranked on top with 56.1% votes as the most favorite PHP Framework. I&#039;m not really a Framework fan but have been digging lately a bit on CakePHP. I personally don&#039;t use a particular Framework but have been building lot of classes and functions [...]]]></description>
			<content:encoded><![CDATA[<p>In the <a href="http://www.php-mag.net/magphpde/magphpde_news/psecom,id,27224,nodeid,5.html" target="_blank">recent poll results</a> of the <a href="http://www.php-mag.net" target="_blank">International PHP Magazine</a>, <a href="http://www.cakephp.org" target="_blank">CakePHP</a> has ranked on top with 56.1% votes as the most favorite PHP Framework. I&#039;m not really a Framework fan but have been digging lately a bit on CakePHP. I personally don&#039;t use a particular Framework but have been building lot of classes and functions that help me in increasing the speed of my development.</p>
<p><b><i>What is Cake?</i></b><br />
<br /><i>Cake is a rapid development framework for PHP which uses commonly known design patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility.</i></p>
<p>Initially it looked too complicated but once I sat down and read through the manual I was good to go. After reading couple of tutorials I was more on track and started doing little little stuff on my local machine.<br />
<br />Here are couple of tutorials that helped me to get going with CakePHP.<br />
<br /><a href="http://manual.cakephp.org/appendix/blog_tutorial" target="_blank">The Cake Blog Tutorial</a><br />
<br /><a href="http://www-128.ibm.com/developerworks/edu/os-dw-os-php-cake1.html" target="_blank">Cook up Web sites fast with CakePHP</a></p>
<p>After developing few sample applications I figured out the advantages of using a Framework. Here are some of the features I love in CakePHP. I&#039;m still in the early stages so it will be a very short list of what I have gained so far.</p>
<p><b>MVC Pattern</b><br />
<br />The MVC pattern is heavily implemented in Cake. It lets us separate our Model, Controller and View. So our application can be broken down and the code becomes more maintainable.<br />
<br /><a href="http://manual.cakephp.org/chapter/basic_concepts" target="_blank">Read More about MVC Pattern</a></p>
<p><b>Scaffolding</b><br />
<br />I really like the scaffolding feature in Cake. It quickly lets us build CRUD operations of our application with very minimal amount of coding based on the design of the database. When I say minimal amount I meant it only required me to declare the variable called $scaffold in my controller. Thats it. Of course there is very less amount of flexibility using Scaffolding but its really a handy way to get a prototype model going.</p>
<p><b>Bake Script</b><br />
<br />Bake is a command line PHP script that will auto magically generate a model, controller and views based on the design of the database. After running the bake script, files are generated and written to the file system. Then we can start doing modification to those files which can be a handy method for starters.</p>
<p>I will post more on this topic when I get familiarized with it. Your comments on CakePHP will help me a great deal in learning more about this framework.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nazly.net/cakephp/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>easyFormProc v1.1.0</title>
		<link>http://www.nazly.net/easyformproc-v1-1-0/</link>
		<comments>http://www.nazly.net/easyformproc-v1-1-0/#comments</comments>
		<pubDate>Thu, 14 Dec 2006 01:46:05 +0000</pubDate>
		<dc:creator>Nazly</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[easyformproc]]></category>
		<category><![CDATA[phpclass]]></category>
		<category><![CDATA[phplib]]></category>

		<guid isPermaLink="false">http://blog.nazly.net/easyformproc-v1-1-0/</guid>
		<description><![CDATA[A more stable version easyFormProc v1.1.0 has been released with minor bug fixes and updates. easyFormProc is a PHP class that I wrote which can easily handle  Forms in PHP scripts. I had lot of suggestion flowing in regarding the script. But didn&#039;t get a time off to release a major update, but I [...]]]></description>
			<content:encoded><![CDATA[<p>A more stable version <a href="http://www.nazly.net/easyformproc" target="_blank">easyFormProc v1.1.0</a> has been released with minor bug fixes and updates. easyFormProc is a PHP class that I wrote which can easily handle  Forms in PHP scripts. I had lot of suggestion flowing in regarding the script. But didn&#039;t get a time off to release a major update, but I do have them in mind. I will keep posted when updates are released.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nazly.net/easyformproc-v1-1-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The PAVISE of Security</title>
		<link>http://www.nazly.net/the-pavise-of-security/</link>
		<comments>http://www.nazly.net/the-pavise-of-security/#comments</comments>
		<pubDate>Mon, 31 Jul 2006 00:39:30 +0000</pubDate>
		<dc:creator>Nazly</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[codewalkers]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.nazly.net/the-pavise-of-security/</guid>
		<description><![CDATA[notepad of Codewalkers.com has posted a tutorial on &#039;The PAVISE of Security&#039;. This tutorial is mainly focused on PHP related security issues which is a much needed topic that needs to be taken into consideration when developing Web Applications. Its a great tutorial for PHP programmers to learn the best practices and techniques.
]]></description>
			<content:encoded><![CDATA[<p>notepad of <a href="http://www.codewalkers.com" target="_blank">Codewalkers.com</a> has posted a tutorial on &#039;<a href="http://codewalkers.com/tutorials/97/1.html" target="_blank">The PAVISE of Security</a>&#039;. This tutorial is mainly focused on PHP related security issues which is a much needed topic that needs to be taken into consideration when developing Web Applications. Its a great tutorial for PHP programmers to learn the best practices and techniques.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nazly.net/the-pavise-of-security/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
