<?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</title>
	<atom:link href="http://www.nazly.net/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>Thu, 04 Mar 2010 09:08:17 +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>Boom Boom McCullum</title>
		<link>http://www.nazly.net/boom-boom-mccullum/</link>
		<comments>http://www.nazly.net/boom-boom-mccullum/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 09:08:17 +0000</pubDate>
		<dc:creator>Nazly</dc:creator>
				<category><![CDATA[Cricket]]></category>
		<category><![CDATA[Sports]]></category>
		<category><![CDATA[australia]]></category>
		<category><![CDATA[brendon]]></category>
		<category><![CDATA[dilscoop]]></category>
		<category><![CDATA[dilshan]]></category>
		<category><![CDATA[mccullum]]></category>
		<category><![CDATA[newzealand]]></category>
		<category><![CDATA[scoop]]></category>
		<category><![CDATA[t20]]></category>
		<category><![CDATA[tait]]></category>

		<guid isPermaLink="false">http://www.nazly.net/?p=796</guid>
		<description><![CDATA[I have been looking around for the highlights of Brendon McCullum&#8217;s hundred against Australia in the 2nd T20 match in the current ongoing series and have finally found it. When I watched the highlights of this match, I was stunned to see his shot selection against the Aussie pace attack. I was amazed by the [...]]]></description>
			<content:encoded><![CDATA[<p>I have been looking around for the highlights of Brendon McCullum&#8217;s hundred against Australia in the 2nd T20 match in the current ongoing series and have finally found it. When I watched the highlights of this match, I was stunned to see his shot selection against the Aussie pace attack. I was amazed by the number scoops he played over the keepers head against the likes of Shaun Tait who almost bowled the &#8220;fastest ball ever&#8221; in the recent series against Pakistan. The scoops came mostly in the latter part of McCullum&#8217;s innings and the two sixes he scored off the scoops after reaching the century were the best picks. </p>
<p>When Dilshan started to play the scoop against some of the best pacemen during the T20 World Cup, the cricketing world admired his ability and gave the scoop a name and that was the &#8220;Dil-scoop&#8221;. He stands his ground and makes sure that his head is down while playing the scoop to avoid being hit. He is the best in what he does.</p>
<p>The technique McCullum uses is quite different from Dilshan&#8217;s. He completely throws himself away from the line of the ball and plays the shot to make sure that he doesn&#8217;t get hit. Some may call this &#8220;not-Cricket&#8221; but lately we have been seeing a lot of innovative shots being played with the invasion of T20 cricket. Can we call this the McScoop?</p>
<p>McCullum was just the second batsman to score a century in a T20 international. While he was just one run short to beating Gayle&#8217;s highest score, he also missed out on scoring the fastest century. He had only faced a ball more than Gayle when he reached the century.</p>
<p><strong>Enjoy the highlights of McCullum&#8217;s innings</strong><br />
<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/KxdIWIc6KiA&#038;hl=en_US&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/KxdIWIc6KiA&#038;hl=en_US&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nazly.net/boom-boom-mccullum/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Quick trip to Kandy and back</title>
		<link>http://www.nazly.net/quick-trip-to-kandy-and-back/</link>
		<comments>http://www.nazly.net/quick-trip-to-kandy-and-back/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 17:01:45 +0000</pubDate>
		<dc:creator>Nazly</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[elephant]]></category>
		<category><![CDATA[elephants]]></category>
		<category><![CDATA[flickr]]></category>
		<category><![CDATA[kandy]]></category>
		<category><![CDATA[photos]]></category>
		<category><![CDATA[pinnawala]]></category>
		<category><![CDATA[trip]]></category>

		<guid isPermaLink="false">http://www.nazly.net/?p=792</guid>
		<description><![CDATA[It has been a long time since I got into the mode of traveling a bit far for the sake of looking around. I made sure I took my camera with me. I&#8217;m not really into photography, but my point-and-shoot camera does capture the moments I would like to share with others. It was just [...]]]></description>
			<content:encoded><![CDATA[<p>It has been a long time since I got into the mode of traveling a bit far for the sake of looking around. I made sure I took my camera with me. I&#8217;m not really into photography, but my point-and-shoot camera does capture the moments I would like to share with others. It was just a quick round trip to Kandy. Went to Pinnawala on the way, lunch in Kandy, visited few relatives, stayed the night at my dad&#8217;s hometown and a quick run back to Colombo sums up the trip.</p>
<p>The main intention of this post is to share the photos I took during the ride. Most of the photos were taken at the <a href="http://en.wikipedia.org/wiki/Pinnawela_Elephant_Orphanage" target="_blank">Pinnawala Elephant Orphanage</a>. It always amazes me how beautiful this country is. I used to travel a lot those days. But lately I haven&#8217;t. There are lot of places that I still have in mind to visit but only if time permits.</p>
<p>I won&#8217;t waste much of your time. Enjoy the photos.</p>
				<div id="gallery-7c97fd32" class="flickr-gallery tag">
													<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4394516636"><img class="photo" title="View from Kadugannawa" src="http://farm5.static.flickr.com/4060/4394516636_284b80ec27_s.jpg" alt="View from Kadugannawa" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4394548692"><img class="photo" title="Passing Mawanella" src="http://farm3.static.flickr.com/2782/4394548692_6801c2eb9b_s.jpg" alt="Passing Mawanella" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4393754029"><img class="photo" title="View from Kadugannawa" src="http://farm3.static.flickr.com/2739/4393754029_8c01d59797_s.jpg" alt="View from Kadugannawa" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4393727623"><img class="photo" title="View from Kadugannawa" src="http://farm3.static.flickr.com/2766/4393727623_820eed8890_s.jpg" alt="View from Kadugannawa" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4394571118"><img class="photo" title="Kadugannawa" src="http://farm3.static.flickr.com/2728/4394571118_ded5b98183_s.jpg" alt="Kadugannawa" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4393766467"><img class="photo" title="Kadugannawa" src="http://farm5.static.flickr.com/4016/4393766467_7758954f2e_s.jpg" alt="Kadugannawa" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4393736833"><img class="photo" title="Passing Mawanella" src="http://farm5.static.flickr.com/4038/4393736833_0c96933351_s.jpg" alt="Passing Mawanella" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4394605836"><img class="photo" title="Elephants in Pinnawala" src="http://farm3.static.flickr.com/2728/4394605836_9530390531_s.jpg" alt="Elephants in Pinnawala" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4393834391"><img class="photo" title="Elephants in Pinnawala" src="http://farm3.static.flickr.com/2777/4393834391_3379c3403a_s.jpg" alt="Elephants in Pinnawala" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4393800453"><img class="photo" title="Elephant in Pinnawala" src="http://farm5.static.flickr.com/4036/4393800453_6dd53003b6_s.jpg" alt="Elephant in Pinnawala" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4394574972"><img class="photo" title="Pinnawala" src="http://farm5.static.flickr.com/4009/4394574972_78a2441ed9_s.jpg" alt="Pinnawala" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4393796913"><img class="photo" title="Elephants in Pinnawala" src="http://farm5.static.flickr.com/4014/4393796913_7bf70997ec_s.jpg" alt="Elephants in Pinnawala" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4393793735"><img class="photo" title="Elephants in Pinnawala" src="http://farm5.static.flickr.com/4045/4393793735_33d56e060c_s.jpg" alt="Elephants in Pinnawala" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4394552878"><img class="photo" title="Pinnawala" src="http://farm5.static.flickr.com/4005/4394552878_2d202bc19d_s.jpg" alt="Pinnawala" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4394544738"><img class="photo" title="Pinnawala" src="http://farm5.static.flickr.com/4038/4394544738_82a76933c7_s.jpg" alt="Pinnawala" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4394540836"><img class="photo" title="Elephants in Pinnawala" src="http://farm5.static.flickr.com/4043/4394540836_9d7161c9d2_s.jpg" alt="Elephants in Pinnawala" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4394529534"><img class="photo" title="Elephants in Pinnawala" src="http://farm3.static.flickr.com/2721/4394529534_503805d3d5_s.jpg" alt="Elephants in Pinnawala" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4394536796"><img class="photo" title="Elephants in Pinnawala" src="http://farm3.static.flickr.com/2705/4394536796_4bfa0a5a41_s.jpg" alt="Elephants in Pinnawala" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4393745539"><img class="photo" title="Elephants in Pinnawala" src="http://farm3.static.flickr.com/2798/4393745539_e5f52020d0_s.jpg" alt="Elephants in Pinnawala" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4393758629"><img class="photo" title="Elephants in Pinnawala" src="http://farm5.static.flickr.com/4007/4393758629_ab4c4e7627_s.jpg" alt="Elephants in Pinnawala" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4394499568"><img class="photo" title="Elephant in Pinnawala" src="http://farm5.static.flickr.com/4057/4394499568_b6d62710ef_s.jpg" alt="Elephant in Pinnawala" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4393741007"><img class="photo" title="Elephants in Pinnawala" src="http://farm3.static.flickr.com/2570/4393741007_e36d0ebaf1_s.jpg" alt="Elephants in Pinnawala" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4393723665"><img class="photo" title="Elephants in Pinnawala" src="http://farm3.static.flickr.com/2705/4393723665_90e16ece7f_s.jpg" alt="Elephants in Pinnawala" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4393719141"><img class="photo" title="Foreigner feeding elephant" src="http://farm5.static.flickr.com/4030/4393719141_df6038bcbc_s.jpg" alt="Foreigner feeding elephant" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4393708819"><img class="photo" title="Elephants in Pinnawala" src="http://farm5.static.flickr.com/4063/4393708819_de721a2501_s.jpg" alt="Elephants in Pinnawala" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4394480086"><img class="photo" title="Elephants in Pinnawala" src="http://farm3.static.flickr.com/2771/4394480086_fcb0f0efff_s.jpg" alt="Elephants in Pinnawala" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4393659947"><img class="photo" title="Elephants in Pinnawala" src="http://farm3.static.flickr.com/2766/4393659947_820861a903_s.jpg" alt="Elephants in Pinnawala" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4394430506"><img class="photo" title="Elephants in Pinnawala" src="http://farm5.static.flickr.com/4037/4394430506_fe669e0fbb_s.jpg" alt="Elephants in Pinnawala" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4393651209"><img class="photo" title="Pinnawala" src="http://farm3.static.flickr.com/2714/4393651209_bb14d16415_s.jpg" alt="Pinnawala" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4394422364"><img class="photo" title="Elephants in Pinnawala" src="http://farm3.static.flickr.com/2795/4394422364_689e9ed1db_s.jpg" alt="Elephants in Pinnawala" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4394413358"><img class="photo" title="Elephants in Pinnawala" src="http://farm5.static.flickr.com/4010/4394413358_bf8c8b629b_s.jpg" alt="Elephants in Pinnawala" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4393638303"><img class="photo" title="Foreigner feeding elephant" src="http://farm3.static.flickr.com/2772/4393638303_80c75aca8a_s.jpg" alt="Foreigner feeding elephant" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4394409352"><img class="photo" title="Elephants in Pinnawala" src="http://farm5.static.flickr.com/4046/4394409352_8575dc2da2_s.jpg" alt="Elephants in Pinnawala" /></a>
								</div>
												<div class="fg-clear"></div>
				</div>
												<div class="fg-clear"></div>
							<script type="text/javascript">
											jQuery(document).ready(function(){
							jQuery("#gallery-7c97fd32 .flickr-thumb img").flightbox();
						});
										
										//-->
				</script>
			
]]></content:encoded>
			<wfw:commentRss>http://www.nazly.net/quick-trip-to-kandy-and-back/feed/</wfw:commentRss>
		<slash:comments>3</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>Looking for a Nissan March K11?</title>
		<link>http://www.nazly.net/looking-for-a-nissan-march-k11/</link>
		<comments>http://www.nazly.net/looking-for-a-nissan-march-k11/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 10:30:12 +0000</pubDate>
		<dc:creator>Nazly</dc:creator>
				<category><![CDATA[Cars]]></category>
		<category><![CDATA[k11]]></category>
		<category><![CDATA[march]]></category>
		<category><![CDATA[nazly]]></category>
		<category><![CDATA[nissan]]></category>
		<category><![CDATA[sale]]></category>

		<guid isPermaLink="false">http://www.nazly.net/?p=710</guid>
		<description><![CDATA[
I have been using a Nissan March K11 for little over a year now. It has been serving me quite well and its in very good condition at the moment. I always preferred a hatchback as it is very convenient when it comes to driving around in traffic and specially parking around Colombo. Due to [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-medium wp-image-716 alignnone" title="4355995128_53d71116a3" src="http://www.nazly.net/wp-content/uploads/2010/02/4355995128_53d71116a3-300x225.jpg" alt="4355995128_53d71116a3" width="300" height="225" /></p>
<p>I have been using a <strong>Nissan March K11</strong> for little over a year now. It has been serving me quite well and its in very good condition at the moment. I always preferred a hatchback as it is very convenient when it comes to driving around in traffic and specially parking around Colombo. Due to an urgent need I&#8217;m planning to sell it.</p>
<p>I bought this car under <strong><a href="http://en.wikipedia.org/wiki/Islamic_banking#Ijarah" target="_blank">Ijarah</a></strong> Islamic Leasing facility, I would prefer to transfer it to someone who is looking for a Nissan March K11 under the same Leasing Scheme rather than actually sell it. Preferably the person whom I will be transferring the lease should be a <strong>Muslim</strong> since this particular Leasing Scheme doesn&#8217;t involve <strong><a href="http://en.wikipedia.org/wiki/Riba" target="_blank">Riba</a></strong> (charging of interest on loans).</p>
<p><span style="color: #ff0000;"><strong>Update: I double checked with my Leasing Company. The person whom I will be transferring the lease to can be a non-Muslim but will be continuing the lease under Ijarah Islamic Leasing facility. Hope this helps since I got few calls asking whether this is possible. Sorry for the confusion due to lack of communication.</strong></span></p>
<p>So if you are interested call me or send me a text message to my mobile<strong>. </strong>You also can email me requesting further details. When you contact me, I will disclose the amount I need in hand + the installment rate you need to pay to continue with the lease.</p>
<p><strong>My Contact Details</strong><br />
Mobile Number : <strong>077-7487480</strong><br />
Email Address : <strong>nazly.ahmed@gmail.com</strong></p>
<p>Here are some basic details of the car.</p>
<p><strong>Make and Model</strong> :<br />
Nissan March K11 (1000 CC)</p>
<p><strong>Year of Manufacture</strong> :<br />
2000 (Cup Holder Model)</p>
<p><strong>Vehicle Number Series</strong> :<br />
HY-XXXX</p>
<p><strong>Transmission</strong> :<br />
Automatic</p>
<p><strong>Mileage</strong> :<br />
54000 KMs<strong></strong></p>
<p><strong>Average Fuel Consumption</strong> :<br />
8-9 KMs/ltr within Colombo<br />
11-12 KMs/ltr Outstations</p>
<p><strong>Features :</strong><br />
14&#8243; Alloys, New Tires,  A/C, Power Steering, Power Shutters, Retractable Mirrors, Central Locking, ABS, Dual Air Bag, CD Player, 3-Way Rear Speakers, Remote Key, Rear Wiper</p>
				<div id="gallery-3cb28e62" class="flickr-gallery photoset">
													<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4356003442"><img class="photo" title="Nissan March K11" src="http://farm3.static.flickr.com/2679/4356003442_47f805ab90_s.jpg" alt="Nissan March K11" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4356003440"><img class="photo" title="Nissan March K11" src="http://farm5.static.flickr.com/4011/4356003440_f160fcb5a6_s.jpg" alt="Nissan March K11" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4355995140"><img class="photo" title="Nissan March K11" src="http://farm3.static.flickr.com/2764/4355995140_e76ed9b30b_s.jpg" alt="Nissan March K11" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4355995136"><img class="photo" title="Nissan March K11" src="http://farm5.static.flickr.com/4043/4355995136_a16966638f_s.jpg" alt="Nissan March K11" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4355995134"><img class="photo" title="Nissan March K11" src="http://farm3.static.flickr.com/2731/4355995134_48e965a0d9_s.jpg" alt="Nissan March K11" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4355995132"><img class="photo" title="Nissan March K11" src="http://farm5.static.flickr.com/4033/4355995132_a3ff6d605b_s.jpg" alt="Nissan March K11" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4355995128"><img class="photo" title="Nissan March K11" src="http://farm3.static.flickr.com/2758/4355995128_53d71116a3_s.jpg" alt="Nissan March K11" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4355995126"><img class="photo" title="Nissan March K11" src="http://farm5.static.flickr.com/4069/4355995126_24ef532bac_s.jpg" alt="Nissan March K11" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4357865229"><img class="photo" title="Nissan March K11" src="http://farm3.static.flickr.com/2688/4357865229_dfe1ff1cf1_s.jpg" alt="Nissan March K11" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4357865221"><img class="photo" title="Nissan March K11" src="http://farm5.static.flickr.com/4009/4357865221_932d12814d_s.jpg" alt="Nissan March K11" /></a>
								</div>
															<div class="flickr-thumb">
									<a href="http://flickr.com/photo.gne?id=4357865213"><img class="photo" title="Nissan March K11" src="http://farm5.static.flickr.com/4056/4357865213_d1c43ebd76_s.jpg" alt="Nissan March K11" /></a>
								</div>
												<div class="fg-clear"></div>
				</div>
												<div class="fg-clear"></div>
							<script type="text/javascript">
											jQuery(document).ready(function(){
							jQuery("#gallery-3cb28e62 .flickr-thumb img").flightbox();
						});
										
										//-->
				</script>
			
]]></content:encoded>
			<wfw:commentRss>http://www.nazly.net/looking-for-a-nissan-march-k11/feed/</wfw:commentRss>
		<slash:comments>2</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>Revamping lkgeeks.org</title>
		<link>http://www.nazly.net/revamping-lkgeeks-org/</link>
		<comments>http://www.nazly.net/revamping-lkgeeks-org/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 10:34:41 +0000</pubDate>
		<dc:creator>Nazly</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Social Media]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[aggregator]]></category>
		<category><![CDATA[FOSS]]></category>
		<category><![CDATA[geek]]></category>
		<category><![CDATA[geeks]]></category>
		<category><![CDATA[lkgeeks]]></category>
		<category><![CDATA[lkgeeks.org]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.nazly.net/?p=660</guid>
		<description><![CDATA[lkgeeks.org has been up there for a quite a while now but the traffic to the site seems to be declining at a considerable rate. In a nutshell lkgeeks.org is a Blog/Twitter aggregator that will give a quick glance at the posts/Tweets from our Lankan geeks. It was initially a requirement of mine that turned [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.lkgeeks.org" target="_blank">lkgeeks.org</a> has been up there for a quite a while now but the traffic to the site seems to be declining at a considerable rate. In a nutshell lkgeeks.org is a Blog/Twitter aggregator that will give a quick glance at the posts/Tweets from our Lankan geeks. It was initially a requirement of mine that turned into a website that everybody could keep a track of. But it has come to a point where even I don&#8217;t visit the site often which actually makes the site having zero traffic on a given day. Though it gives you the information you need, there is no interactivity in the site. Also it sucks at usability and I have to admit that I used the technology in an appropriate manner.</p>
<p>I think its high time to move on. I&#8217;m planning it to make it a portal for the Sri Lankan geeks. The aggregator will remain but just be a part of the site. I won&#8217;t spoil things up but you will know when it happens. <a href="http://www.nazly.net/lkgeeks-org-a-blog-aggregator-for-sri-lankan-fossgeek-blogs/">When I launched lkgeeks.org</a>, my initial plan was to keep it limited to FOSS Blogs. But with the revamp it may change. So all the geeks who represent Sri Lanka will get equal opportunity to get listed and share their Blog posts and Tweets. Also there would be some sort of filtering that will take place. Non-technical posts/Tweets have to be filtered while @ Replies will be taken off from the Twitter feed. I haven&#8217;t really figured out this process yet but I&#8217;m just trying to plan things out and you will also know what you can expect. Its a mixed thought and I welcome your feedback on this.</p>
<p>Since <a href="http://www.twitter.com" target="_blank">Twitter</a> has introduced the Lists feature, I have created a <a href="http://twitter.com/nazly/lkgeeks-org" target="_blank">List for lkgeeks.org</a> and once the site is revamped, the Twitter aggregator will be based on this list. I made <a href="http://twitter.com/nazly/status/6075976417" target="_blank">a tweet about this</a> sometime back. If you are not listed, send me Direct Message on Twitter to get listed.</p>
<p>Also I will be adding a News/Events section. This way everyone can track events around Sri Lanka. Its something I can&#8217;t do alone so any voluntary help is much appreciated.</p>
<p>The good thing is that I have a lot of ideas but executing them doesn&#8217;t really happen most of the time mainly due to lack of time I get to work on these ideas. You will see changes happening soon. Would love to hear your thoughts as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nazly.net/revamping-lkgeeks-org/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>I keep coming back and this time for real..</title>
		<link>http://www.nazly.net/i-keep-coming-back-and-this-time-for-real/</link>
		<comments>http://www.nazly.net/i-keep-coming-back-and-this-time-for-real/#comments</comments>
		<pubDate>Sat, 21 Nov 2009 04:38:15 +0000</pubDate>
		<dc:creator>Nazly</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[nazly]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.nazly.net/?p=633</guid>
		<description><![CDATA[At the beginning of this year I made a promise that my blog posts will flow and I will update regularly. But unfortunately for several reasons I haven&#8217;t posted anything in my blog since January. Juggling my life between work and family is one of the main reasons. My wife gave birth to a baby [...]]]></description>
			<content:encoded><![CDATA[<p>At the beginning of this year I made a promise that my blog posts will flow and I will update regularly. But unfortunately for several reasons I haven&#8217;t posted anything in my blog since January. Juggling my life between work and family is one of the main reasons. My wife gave birth to a baby boy in January. Since then I have been fascinated by watching him grow. Each day has been a new experience and facing new challenges was exciting. I would have loved to keep posting stuff on my blog but my addiction to <a href="http://www.twitter.com" target="_blank">Twitter</a> was the easy way out since I could do a blog post in 140 characters and in quick time. Yet there were stuff I want to share on my blog but since my blogging engine is something I wrote from scratch in <a href="http://www.php.net" target="_blank">PHP</a> in 2005 it lacked all the new features a blog should have. So actually I was kinda stuck with the basic requirements to keep my blogging hopes alive.</p>
<p>Couple of months back I made the decision to switch to <a href="http://www.wordpress.org" target="_blank">Wordpress</a>. Since then I have been stealing time and migrating my blog to Wordpress. It was not easy but since Wordpress has a tons of features to import it was just like a walk in the park. But that was just for posts. Importing comments was bit tough but I was able to write few custom PHP scripts and MySQL queries to make the transition smooth. Then I had to categorize and tag posts which I did manually. URLs have changed. But I made sure that I do 301 redirects to all the previous URLs to make sure that I don&#8217;t lose my search engine rankings and traffic that has been flowing in. All in all it was fun. I took my own time, and finally its up.</p>
<p>Now I make another promise. My blog posts will continue. Its your support that has kept this blog alive.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nazly.net/i-keep-coming-back-and-this-time-for-real/feed/</wfw:commentRss>
		<slash:comments>7</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>Welcome 2009</title>
		<link>http://www.nazly.net/welcome-2009/</link>
		<comments>http://www.nazly.net/welcome-2009/#comments</comments>
		<pubDate>Thu, 01 Jan 2009 07:46:58 +0000</pubDate>
		<dc:creator>Nazly</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.nazly.net/welcome-2009/</guid>
		<description><![CDATA[&#34;Before the sun sets in this year, before the memories fade, before the networks get jammed, I didn&#039;t wish, because my wishes come with the new sun and new day.I Wish u and ur family Happy Sparkling New Year 2009&#34;
The New Year has dawn and had a tough time going through all the text messages [...]]]></description>
			<content:encoded><![CDATA[<p><i>&quot;Before the sun sets in this year, before the memories fade, before the networks get jammed, I didn&#039;t wish, because my wishes come with the new sun and new day.I Wish u and ur family Happy Sparkling New Year 2009&quot;</i></p>
<p>The New Year has dawn and had a tough time going through all the text messages and trying to reply to them. But I didn&#039;t manage to reply to them all but picked the message above to publish here which was bit different from the standard way of wishing. So a Happy New Year to you all. Let the dawning year bring you Peace and Prosperity.</p>
<p>I just can&#039;t imagine how the last year flew away leaving a lot of good memories, a year that brought lot of new things into my life. I started 2008 by getting married, which was a 180&deg; turn in my life. My life style changed a lot after that but I managed to keep my geekhood alive. If you didn&#039;t see my blog being updated much, now you know why. But I still managed to post in between my busy work schedule. The last few months was more a restructuring period of my life both work and personal, so that&#039;s the reason why my last post it dated back to September. This year I vow that I will do my level best to keep the blog alive with loads of information in time to come. </p>
<p>The tough decision came somewhere in the middle of last year when I had to quit my previous workplace  and take up a new challenge. It was a tough decision but I took it. I was at <a href="http://www.cenango.com" target="_blank">Cenango</a> for almost four years and I do miss all the colleagues I used to work with and the great moments at Cenango. Thanks to all the guys who supported me throughout specially during the tough times and made me what I&#039;m now.</p>
<p>Switching from a two wheel ride to a four wheel drive was the best thing that could happen to me at the end of the year for me. I don&#039;t want to erase my past memories I had with my hoodless ride as I used to call it, specially the days I used to get wet like nothing by the time I get home. <img src="http://www.nazly.net//smiles/icon_biggrin.gif" alt=":D[BigGrin]" /> It served me well for more than three years and still serving for short rides since I have no plans of selling it.</p>
<p>So all and all it has been a great last year and ready to face the challenges that are awaiting this year. I wish you all the very best in what ever you do. </p>
<p>Thanks to all!!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nazly.net/welcome-2009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CHMOD recursively</title>
		<link>http://www.nazly.net/chmod-recursively/</link>
		<comments>http://www.nazly.net/chmod-recursively/#comments</comments>
		<pubDate>Mon, 29 Sep 2008 03:04:58 +0000</pubDate>
		<dc:creator>Nazly</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[chmod]]></category>
		<category><![CDATA[command]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://blog.nazly.net/chmod-recursively/</guid>
		<description><![CDATA[Time to time I come across this problem when I have to move large portions of directories and files from one location to another. Mostly after extracting from tar archives. The directory/file permissions are often messed up depending on the source I copied them or based on the way I copied/archived them. So I used [...]]]></description>
			<content:encoded><![CDATA[<p>Time to time I come across this problem when I have to move large portions of directories and files from one location to another. Mostly after extracting from tar archives. The directory/file permissions are often messed up depending on the source I copied them or based on the way I copied/archived them. So I used to use this technique to CHMOD directories and files recursively. Today when I was using this I thought of blogging it for my own future reference. If there is a better way feel free to comment.</p>
<p><b>CHMOD directories only</b><br />
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">find</span> . <span style="color: #660033;">-type</span> d <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">755</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> \;</pre></div></div>

<p><b>CHMOD files only</b><br />
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">find</span> . <span style="color: #660033;">-type</span> f <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">644</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> \;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.nazly.net/chmod-recursively/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
