<?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>WebDevelopmentBits</title>
	<atom:link href="http://www.webdevelopmentbits.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.webdevelopmentbits.com</link>
	<description>Web Development &#124; PHP Development &#124; Zend Development &#124; Flex Development &#124; Air Development</description>
	<lastBuildDate>Mon, 26 Jul 2010 11:47:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Scrape the First Paragraph &amp; Image from a Wikipedia Entry</title>
		<link>http://www.webdevelopmentbits.com/scrape-the-first-paragraph-image-from-a-wikipedia-entry</link>
		<comments>http://www.webdevelopmentbits.com/scrape-the-first-paragraph-image-from-a-wikipedia-entry#comments</comments>
		<pubDate>Mon, 26 Jul 2010 08:40:40 +0000</pubDate>
		<dc:creator>cary</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Wikipedia]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=652</guid>
		<description><![CDATA[Automate fetching Wikipedia descriptions and images for webpage content. Render content dynamically based on specific keywords.]]></description>
			<content:encoded><![CDATA[<p>by Kannan Ramakrishnan</p>
<p>One day, while you&#8217;re organizing the content for your latest and greatest website, you may find yourself wishing for an automated way to fetch a description for some of that content.  Perhaps an image, too, to pull into a header or elsewhere on your page.  And since you’ve got 100 other things on your plate, you’d like this content to be implemented automatically, dynamically appearing on certain pages based on a few keywords.  For novice Web developers, this sounds impossible, I know.  But… it’s totally doable.</p>
<p>So off you go in search of good, usable, public content.  Before long you’ll probably realize it yourself, but I’ll save you an hour of digging with this quick pro tip: Wikipedia is your friend. The bottomless content at Wikipedia is a perfect match for what we want to do.  The caveat, though, is it’s so vast we might scrape the wrong content.  And especially if you’re automating a task like this, constantly looking over your shoulder to confirm the content would defeat the entire purpose.  So relying <em>soley </em>on the Wiki gremlins is not the best way to go.</p>
<p><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2010/07/250px-Red_Apple3.jpg"><img class="aligncenter size-full wp-image-663" title="250px-Red_Apple" src="http://www.webdevelopmentbits.com/wp-content/uploads/2010/07/250px-Red_Apple3.jpg" alt="" width="252" height="229" /></a></p>
<p>Let’s take for example a Wiki search for a popular technology company, say, <a href="http://www.apple.com">Apple</a>.  For a Web-savvy person like yourself, a Wiki search for ‘Apple’ turns up what you probably expect: the entry for <a href="http://en.wikipedia.org/wiki/Apple">a scrumptious kind of fruit</a>.  And as Web developers, we <em>should </em>be more astute in our search terms, but sometimes yes, well, there are those gremlins.</p>
<p>So&#8230; to cut the risk of unwanted fruit creeping onto your page, we’re going to combine a Wiki search with a Google search.</p>
<p>Following is the code for scraping the first paragraph and image of the entry from a page in Wikipedia.  As long as your keywords aren’t really crazy, this should get the job done!</p>
<p>Finally, make sure you don&#8217;t forget to credit Wikipedia on your page&#8230; and if you have any questions, <a href="mailto:webdevelopmentbits@sourcebits.com">drop us a line here</a> any time!!</p>
<p>Here&#8217;s the code:</p>
<pre>require  'hpricot'
require 'open-uri'

def fetch_description(query_item)
    page_title, uri_title = get_wiki_name(query_item)
    return get_wiki_description(page_title, uri_title)
end

def upload_photo(wiki_photo)
    begin
      base_uri = URI.parse(wiki_photo)
      uploaded_data = open(base_uri)
      def uploaded_data.original_filename; base_uri.path.split('/').last; end
      return uploaded_data.original_filename.blank? ? nil : uploaded_data
    rescue
      return nil
    end
end

#Method to fetch wiki page and strip first two

 Tags
def get_wiki_description(page_title, uri_title)
    url =  uri_title
    final_content = ""
    if url.size &gt; 10
      buffer = Hpricot(open(url, "UserAgent" =&gt; "reader"+rand(10000).to_s).read)
      #Capture first two paragraphs of text
      content = buffer.search("//div[@id='content']").search("//div[@id='bodyContent']").search("//p")[0..2]

      #Remove the extra spaces and strip html tags from the fetched content
      content.each do |c|
        final_content+=c.inner_html.gsub(/&lt; \/?[^&gt;]*&gt;/, '').gsub(/&amp;#\d+;/,'').gsub(/\([^\)]+\)/,'').gsub(/\[[^\]]+\]/,'').gsub(/ +/,' ')+"\n"
      end
    end
    return final_content
end

#Method to get the link for wikipedia from google search results
def get_wiki_name(query_item)
    search_keywords = query_item.strip.gsub(/\s+/,'+')
    url = "http://www.google.com/search?q=#{search_keywords}+site%3Aen.wikipedia.org"
    begin
      doc = Hpricot(open(url, "UserAgent" =&gt; "reader"+rand(10000).to_s).read)
      result = doc.search("//div[@id='ires']").search("//li[@class='g']").first.search("//a").first unless doc
    rescue
      return '',''
    end
    if result
      return result.inner_html.gsub(/&lt; \/?[^&gt;]*&gt;/,"").gsub(/./,""),result.attributes["href"]
    else
      return '',''
    end
end

wiki_description, wiki_photo = fetch_description("Apple")
upload_photo(wiki_photo)</pre>
<p>And this is how it looks implemented live, in context:</p>
<p><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2010/07/smallerScreen-shot-2010-07-26-at-4.50.03-PM.png"><img class="aligncenter size-full wp-image-666" title="smallerScreen shot 2010-07-26 at 4.50.03 PM" src="http://www.webdevelopmentbits.com/wp-content/uploads/2010/07/smallerScreen-shot-2010-07-26-at-4.50.03-PM.png" alt="" width="500" height="245" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/scrape-the-first-paragraph-image-from-a-wikipedia-entry/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blogger Template Wizardry</title>
		<link>http://www.webdevelopmentbits.com/blogger-template-wizardry</link>
		<comments>http://www.webdevelopmentbits.com/blogger-template-wizardry#comments</comments>
		<pubDate>Thu, 03 Jun 2010 22:16:49 +0000</pubDate>
		<dc:creator>Chinmay Chiranjeeb</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[blogger]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[customizing]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=599</guid>
		<description><![CDATA[Google’s Blogger is the eighth most popular site on the entire Web today, and by far the most popular free blogging site.  According to Google, Blogger now hosts over 300 million blogs and publishes 388 million words per day – simply staggering figures.  Let’s look at some of the more compelling reasons for Blogger’s popularity.]]></description>
			<content:encoded><![CDATA[<p>Google’s Blogger is the eighth most popular site on the entire Web today, and by far the most popular free blogging site.  According to Google, Blogger now hosts over 300 million blogs and publishes 388 million words per day – simply staggering figures.  Let’s look at some of the more compelling reasons for Blogger’s popularity.</p>
<ul>
<li>Google’s services are ubiquitous, and you’ve probably already got an account for say, Gmail, Docs, YouTube or Calendar.  So when you land on the Blogger homepage, all you need to do is enter your login info and off you go!  No registration required.</li>
<li>It’s powered by Google, so there’s a better chance of placing high on search engine rankings.  From an SEO/SEM (search engine optimization / search engine marketing) point of view, that’s quite the big deal.</li>
<li>Users can create multiple blogs.  For Web developers or designers with diverse portfolios it’s easier than ever to start your own blogging network.</li>
<li>Blogger has a limited but respectable directory of templates with plenty of options for customization.  Inveterate tweakers should clear the afternoon.</li>
<li>Users can create and configure their own templates for upload, or download an existing template, customize it, then re-upload and use it.</li>
<li>Rather than keeping the off-the-shelf yourname.blogspot.com domain, users can register their own custom domain and point their Blogger page to that.</li>
</ul>
<p>Sure enough, there are plenty of good reasons Blogger’s gained traction the past few years, but it’s become a hell of a crowded field and for anyone looking to grow their audience it’s increasingly hard to stand out.</p>
<p>The fact is, even if you’re posting killer, must-read content you’ve lost the lion’s share of readers before their first click with a page designed from a yawn-inducing Blogger template.</p>
<p>So besides great content, you’re going to want a template with distinctive design. Read on to follow this basic tutorial and create your own fresh Blogger template.</p>
<h2>Create an HTML Template for Your Blog</h2>
<p>Go to the <a href="http://www.blogger.com/">Blogger homepage</a> and log in with your Google info to create a new blog.  With or without a Google account the signup is pretty painless.</p>
<p><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2010/06/1.png"><img class="aligncenter size-full wp-image-602" title="1" src="http://www.webdevelopmentbits.com/wp-content/uploads/2010/06/1.png" alt="" width="531" height="178" /></a></p>
<p>If you&#8217;re an existing user, you&#8217;ll also get the status of your current blogs.</p>
<p><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2010/06/22.png"><img class="aligncenter size-full wp-image-618" title="2" src="http://www.webdevelopmentbits.com/wp-content/uploads/2010/06/22.png" alt="" width="531" height="115" /></a></p>
<h2>Head to Layout and then Edit HTML</h2>
<p><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2010/06/3.png"><img class="aligncenter size-full wp-image-604" title="3" src="http://www.webdevelopmentbits.com/wp-content/uploads/2010/06/3.png" alt="" width="531" height="115" /></a></p>
<p>Developers love code, but sometimes even laymen want a peek under the hood.  If you&#8217;re up for it, just scroll down and click View Classic Template.</p>
<p>Keep in mind that Blogger can only use XML-formatted templates, so you’ll need to create a blank XML file on your hard drive as &lt;Your Template name&gt;.xml.</p>
<p>Now add the following code to your XML document:</p>
<pre>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//ES" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</a>"&gt;
&lt;html xmlns='<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>' xmlns:b='<a href="http://www.google.com/2005/gml/b">http://www.google.com/2005/gml/b</a>' xmlns:data='<a href="http://www.google.com/2005/gml/data">http://www.google.com/2005/gml/data</a>' xmlns:expr='<a href="http://www.google.com/2005/gml/expr">http://www.google.com/2005/gml/expr</a>'&gt;
&lt;head&gt;</pre>
<h2>Let’s start with the Blogger code to add a header element.</h2>
<p>Generally, Blogger code starts with &lt;b:</p>
<pre>&lt;b:include data='blog' name='all-head-content'/&gt;</pre>
<h2>Now we’ll add the title of the blog and post:</h2>
<pre>&lt;title&gt;&lt;data:blog.pageTitle/&gt;&lt;/title&gt;</pre>
<h2>Referencing the blog skin:</h2>
<pre>&lt;b:skin&gt;</pre>
<h2>And template details:</h2>
<pre>&lt;![CDATA[/*
/* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Name: MacDevelopmentBits
Blogger template by Sourcebits Technologies
Author: Sourcebits Technologies
Author URL: <a href="http://www.sourcebits.com/">http://www.sourcebits.com</a>
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- */</pre>
<h2>Now let’s hide the default navigation bar.</h2>
<p><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2010/06/5.png"><img class="aligncenter size-full wp-image-606" title="5" src="http://www.webdevelopmentbits.com/wp-content/uploads/2010/06/5.png" alt="" width="531" height="31" /></a></p>
<pre>/*-- (Hiding the navbar) --*/
#navbar-iframe {
height:0px;
visibility:hidden;
display:none;
}</pre>
<h2>And add some custom CSS to stylize the blog.</h2>
<pre>/*-- (CSS for Blog ) --*/
body{
font-family:Georgia, "Times New Roman", Times, serif;
font-size:12px;
color:#000000;
margin:0px;
padding:0px;
background:#dedede;
}

:focus {
outline: 0;
}

.clr{
clear:both;
}

.wrap{
margin:0 auto;
padding:0px;
min-width:1200px;
}

.head{
background:#cde3e4 url(your path to header image) repeat-x;
margin-top:-1px;
}

]]&gt;&lt;/b:skin&gt;</pre>
<p>If you don&#8217;t have a domain to host images then you can use Picasa, Flickr or any other image hosting services.  Just make sure that image viewing permissions are set to public.</p>
<h2>To generate feeds and archives for your blog:</h2>
<pre>&lt;script type='text/javascript'&gt;

function rp(json){ document.write(&amp;#39;&amp;lt;ul&amp;gt;&amp;#39;);for(var i=0;i&amp;lt;numposts;i++){document.write(&amp;#39;&amp;lt;li&amp;gt;&amp;#39;);var entry=json.feed.entry[i];var posttitle=entry.title.$t;var posturl;if(i==json.feed.entry.length)break;for(var k=0;k&amp;lt;entry.link.length;k++){if(entry.link[k].rel==&amp;#39;alternate&amp;#39;){posturl=entry.link[k].href;break}}posttitle=posttitle.link(posturl);var readmorelink=&amp;quot;(more)&amp;quot;;readmorelink=readmorelink.link(posturl);var postdate=entry.published.$t;var cdyear=postdate.substring(0,4);var cdmonth=postdate.substring(5,7);var cdday=postdate.substring(8,10);var monthnames=new Array();monthnames[1]=&amp;quot;Jan&amp;quot;;monthnames[2]=&amp;quot;Feb&amp;quot;;monthnames[3]=&amp;quot;Mar&amp;quot;;monthnames[4]=&amp;quot;Apr&amp;quot;;monthnames[5]=&amp;quot;May&amp;quot;;monthnames[6]=&amp;quot;Jun&amp;quot;;monthnames[7]=&amp;quot;Jul&amp;quot;;monthnames[8]=&amp;quot;Aug&amp;quot;;monthnames[9]=&amp;quot;Sep&amp;quot;;monthnames[10]=&amp;quot;Oct&amp;quot;;monthnames[11]=&amp;quot;Nov&amp;quot;;monthnames[12]=&amp;quot;Dec&amp;quot;;if(&amp;quot;content&amp;quot;in entry){var postcontent=entry.content.$t}else if(&amp;quot;summary&amp;quot;in entry){var postcontent=entry.summary.$t}else var postcontent=&amp;quot;&amp;quot;;var re=/&amp;lt;\S[^&amp;gt;]*&amp;gt;/g;postcontent=postcontent.replace(re,&amp;quot;&amp;quot;);document.write(posttitle);if(showpostdate==true)document.write(&amp;#39; - &amp;#39;+monthnames[parseInt(cdmonth,10)]+&amp;#39; &amp;#39;+cdday);if(showpostsummary==true){if(postcontent.length&amp;lt;numchars){document.write(postcontent)}else{postcontent=postcontent.substring(0,numchars);var quoteEnd=postcontent.lastIndexOf(&amp;quot; &amp;quot;);postcontent=postcontent.substring(0,quoteEnd);document.write(postcontent+&amp;#39;...&amp;#39;+readmorelink)}}document.write(&amp;#39;&amp;lt;/li&amp;gt;&amp;#39;)}document.write(&amp;#39;&amp;lt;/ul&amp;gt;&amp;#39;)}

var numposts = 5;
var showpostdate = false;
var showpostsummary = false;
var numchars = 40;

&lt;/script&gt;</pre>
<h2>You can also insert external JavaScript files:</h2>
<pre>&lt;script language='javascript' src='<a href="http://code.jquery.com/jquery-1.4.2.min.js">http://code.jquery.com/jquery-1.4.2.min.js</a>' type='text/javascript'/&gt;
&lt;script type='text/javascript'&gt;
//your code here
&lt;/script&gt;</pre>
<h2>Now let’s replace the default Blogger favicon with a custom jobbie that suits our taste.</h2>
<pre>&lt;link href='path to favicon' rel='shortcut icon' type='favicon'/&gt;
&lt;/head&gt;
&lt;body&gt;</pre>
<h2>Include your HTML code from the blog template created earlier and let’s add a widget to your header.</h2>
<pre>&lt;b:section id='top35' maxwidgets='1' showaddelement='no'&gt;
&lt;b:widget id='Header1' locked='true' title='MacDevelopmentBits (Header)' type='Header'&gt;

&lt;b:includable id='title'&gt;
&lt;A expr:href='data:blog.homepageUrl'&gt;&lt;div class='logo'&gt;&lt;data:title/&gt;&lt;/div&gt;&lt;/A&gt;
&lt;/b:includable&gt;

&lt;b:includable id='description'&gt;
&lt;h1 class='slogan'&gt;&lt;data:description/&gt;&lt;/h1&gt; &lt;!-- It fetches the description from basic settings page. --&gt;
&lt;/b:includable&gt;

&lt;b:includable id='main'&gt;
&lt;div class='slogan1'&gt;
&lt;b:include name='title'/&gt;
&lt;/div&gt;
&lt;b:include name='description'/&gt;
&lt;/b:includable&gt;

&lt;/b:widget&gt;
&lt;/b:section&gt;</pre>
<p>Note that you can use multiple widgets in the template but they should have unique id= &#8216;Your Unique ID&#8217; and maxwidgets=&#8217;No of widgets&#8217;</p>
<h2>Now add navigation:</h2>
<pre>&lt;b:include name='nextprev'/&gt;</pre>
<p>And the conditional statement to show/hide navigation is:</p>
<pre>&lt;b:if cond='data:newerPageUrl'&gt;

&lt;span id='blog-pager-newer-link'&gt;
&lt;a class='blog-pager-newer-link' expr:href='data:newerPageUrl' expr:id='data:widget.instanceId + &amp;quot;_blog-pager-newer-link&amp;quot;' expr:title='data:newerPageTitle'&gt;&lt;data:newerPageTitle/&gt;&lt;/a&gt;
&lt;/span&gt;

&lt;/b:if&gt;
&lt;b:if cond='data:olderPageUrl'&gt;
&lt;span id='blog-pager-older-link'&gt;
&lt;a class='blog-pager-older-link' expr:href='data:olderPageUrl' expr:id='data:widget.instanceId + &amp;quot;_blog-pager-older-link&amp;quot;' expr:title='data:olderPageTitle'&gt;&lt;data:olderPageTitle/&gt;&lt;/a&gt;
&lt;/span&gt;

&lt;/b:if&gt;</pre>
<h2>And include feed links:</h2>
<pre>&lt;b:include name='feedLinks'/&gt;</pre>
<h2>To display content only on the main and archive pages, include this tag with your content:</h2>
<pre>&lt;MainOrArchivePage&gt;
&lt;1-- Your Content for Home and Archive Page--&gt;
&lt;/MainOrArchivePage&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h2>Phew!  Almost there.  Now after saving the XML file, it’s time to upload to Blogger.</h2>
<p>Back on the Layout tab, under Edit HTML, you’ll find:</p>
<p><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2010/06/6.png"><img class="aligncenter size-full wp-image-607" title="6" src="http://www.webdevelopmentbits.com/wp-content/uploads/2010/06/6.png" alt="" width="533" height="33" /></a></p>
<p>After uploading, save the template so now you can edit the file online and preview changes as you go.</p>
<p><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2010/06/7.png"><img class="aligncenter size-full wp-image-608" title="7" src="http://www.webdevelopmentbits.com/wp-content/uploads/2010/06/7.png" alt="" width="533" height="45" /></a></p>
<p>And feel free to experiment!  You can always hit the <strong>Clear Edits</strong> button to revert to the last saved version.</p>
<p>Let&#8217;s take a look at an outline of the page elements used in the template:</p>
<p><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2010/06/8.png"><img class="aligncenter size-full wp-image-609" title="8" src="http://www.webdevelopmentbits.com/wp-content/uploads/2010/06/8.png" alt="" width="531" height="115" /></a></p>
<p>We can also place widgets with just a few clicks.</p>
<p><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2010/06/4.png"><img class="aligncenter size-full wp-image-605" title="4" src="http://www.webdevelopmentbits.com/wp-content/uploads/2010/06/4.png" alt="" width="531" height="178" /></a></p>
<p>Clicking one of the Add a Gadget links drops you into a vast pool of Blogger and third party gadgets. Pick a gadget and add it by clicking the +, however many suit your needs.</p>
<p><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2010/06/9.png"><img class="aligncenter size-full wp-image-610" title="9" src="http://www.webdevelopmentbits.com/wp-content/uploads/2010/06/9.png" alt="" width="533" height="180" /></a></p>
<p>And&#8230; VOILA!</p>
<p>Here’s a sample template we did up awhile ago with a basic but unique design, just FYI.</p>
<p style="text-align: center;"><a href="http://macdevelopmentbits.blogspot.com/"><img class="aligncenter size-full wp-image-611" title="10" src="http://www.webdevelopmentbits.com/wp-content/uploads/2010/06/10.png" alt="" width="531" height="178" /></a></p>
<p><a href="http://macdevelopmentbits.blogspot.com/">http://macdevelopmentbits.blogspot.com/</a></p>
<p>Feel free to drop us a line with any of your Blogger templating issues.  We&#8217;re happy to lend a hand. For that matter, we&#8217;re keen to discuss any Web development projects you&#8217;re interested in.  <a href="http://www.webdevelopmentbits.com/contact">Get in touch</a> any time!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/blogger-template-wizardry/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML Email Compatibility Across Mail Clients</title>
		<link>http://www.webdevelopmentbits.com/html-email-compatibility-across-mail-clients</link>
		<comments>http://www.webdevelopmentbits.com/html-email-compatibility-across-mail-clients#comments</comments>
		<pubDate>Mon, 17 May 2010 00:29:25 +0000</pubDate>
		<dc:creator>Prakash Mohanty</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Mail]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS Table]]></category>
		<category><![CDATA[HTML mail]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=573</guid>
		<description><![CDATA[<p style="text-align: center;"><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2010/05/Screen-shot-2010-05-17-at-9.20.44-PM.png"><img class="size-full wp-image-578  aligncenter" title="Screen shot 2010-05-17 at 9.20.44 PM" src="http://www.webdevelopmentbits.com/wp-content/uploads/2010/05/Screen-shot-2010-05-17-at-9.20.44-PM.png" alt="" width="530" height="181" /></a></p>
<p>Lots of compatibility issues occur when HTML developers deal with HTML-formatted emails generated using server side languages like PHP, PERL, JAVA, etc. in their projects.</p>
<p>From time to time you’ll find the odd gobbledygooked message in your&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2010/05/Screen-shot-2010-05-17-at-9.20.44-PM.png"><img class="size-full wp-image-578  aligncenter" title="Screen shot 2010-05-17 at 9.20.44 PM" src="http://www.webdevelopmentbits.com/wp-content/uploads/2010/05/Screen-shot-2010-05-17-at-9.20.44-PM.png" alt="" width="530" height="181" /></a></p>
<p>Lots of compatibility issues occur when HTML developers deal with HTML-formatted emails generated using server side languages like PHP, PERL, JAVA, etc. in their projects.</p>
<p>From time to time you’ll find the odd gobbledygooked message in your Web-based email app, but generally speaking HTML-formatted messages render flawlessly on the Web.  On the other hand, desktop mail clients such as Outlook on Windows, Mail.app on OS X, and the rainbow flavors of desktop Linux (Ubuntu, Centos, and so on) routinely have rendering issues with HTML-based email.</p>
<p>Despite the incredible advances in modern software, why does this continue to happen?</p>
<p>The answer is quite simple: certain mail clients ignore certain HTML tags.  Now there’s no universal rule as to which ignores what, but the more you code the more you’ll learn, so for now let’s take a look at one case with Outlook.</p>
<p>For many users, email ‘stationery’ conjures up late 90s memories of <a href="http://www.incredimail.com/english/splash.aspx">Incredimail</a> and a general, unsavory n00bishness.  But for marketing purposes a well-designed mail template, consisting of a stylish background image, thoughtful font selection, layout and copy equates to sales.  Perhaps thousands of people – from prospective clients to the media – will view mail on this template and associate it with your corporate brand, so perfection is key.</p>
<p style="text-align: center;"><img class="size-medium wp-image-579   aligncenter" title="Ye Gods!!  Incredimail!!! " src="http://www.webdevelopmentbits.com/wp-content/uploads/2010/05/back1-300x240.gif" alt="" width="248" height="199" /></p>
<p style="text-align: left;">Now let’s focus on the background image.  Many HTML developers will begin by putting CSS styles in the header of the HTML email directly, or when that fails try working around the problem using div tags and inline CSS.  But either way the results are borked.  Why?  Because Outlook ignores the CSS property “background-image”.</p>
<p style="text-align: left;">After so much trial and error, the solution we finally decided on was a pure table-based layout with inline CSS – with the CSS being restricted to each individual table cell since Outlook does not ignore those.  We’ve found this not only renders properly in Outlook, but all the other major desktop and Web clients, too.</p>
<p>And here&#8217;s how good it can look.</p>
<p style="text-align: center;"><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2010/05/Image-xbox.png"><img class="size-full wp-image-580  aligncenter" title="Image-xbox" src="http://www.webdevelopmentbits.com/wp-content/uploads/2010/05/Image-xbox.png" alt="" width="539" height="746" /></a></p>
<p>For your reference, here are few examples of HTML tags that are compatible with almost all desktop and Web-based mail clients.</p>
<pre>&lt;table cellspacing="0" cellpadding="0" bgcolor="#6b6f7a"&gt;
    &lt;tr&gt;
        &lt;td width="55" height="53" valign="top"&gt;
            &lt;img src="http://domainname/media/mail/header_01.jpg" alt="" width="78" height="53" /&gt;
        &lt;/td&gt;
        &lt;td style="font-family: Arial,sans-serif;" width="546" bgcolor="#ffffff"&gt;&lt;/td&gt;
        &lt;td style="border-bottom: 1px solid #ffffff; padding: 0pt 15px; background-color: #b6d354; color: #ffffff; text-transform: uppercase; height: 43px; vertical-align: middle; font-size: 12px;"&gt;&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;</pre>
<p>CSS style property -</p>
<pre>word-wrap: break-all;</pre>
<p>With the absence of a background tag, images can be used inside the</p>
<pre>&lt;table&gt;</pre>
<p>and</p>
<pre>&lt;td&gt;</pre>
<p>tags.</p>
<p>Happy HTML email  coding!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/html-email-compatibility-across-mail-clients/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Facebook Connect for your web application</title>
		<link>http://www.webdevelopmentbits.com/using-facebook-connect-for-your-web-application</link>
		<comments>http://www.webdevelopmentbits.com/using-facebook-connect-for-your-web-application#comments</comments>
		<pubDate>Wed, 13 Jan 2010 17:53:11 +0000</pubDate>
		<dc:creator>Kishore Nallan</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[facebook-connect]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=546</guid>
		<description><![CDATA[<p>With the exponential growth of Facebook over the past few years, it&#8217;s safe to say that quite a large number of active web users today own and use a Facebook account regularly. Facebook connect, which Facebook launched late 2008, is&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>With the exponential growth of Facebook over the past few years, it&#8217;s safe to say that quite a large number of active web users today own and use a Facebook account regularly. Facebook connect, which Facebook launched late 2008, is a set of APIs which allow you to integrate your users&#8217; Facebook profile into your web application. Apart from allowing your visitors to login to your site using their Facebook identity (hence negating the registration process), it also allows you to leverage on the various social features of Facebook. Let&#8217;s take a overview of Facebook Connect, and how we can integrate it into our web application.</p>
<p><strong>Facebook APIs</strong></p>
<p>Facebook provides both RESTFUL and Javascript APIs. A <a href="http://wiki.developers.facebook.com/index.php/User:Client_Libraries">great number of client libraries</a> are available for creating your web application, though Facebook provides official support for only a handful of them. We will be using Facebook&#8217;s official <a href="http://wiki.developers.facebook.com/index.php/PHP">PHP 5 client</a> and <a href="http://wiki.developers.facebook.com/index.php/JavaScript_Client_Library">Javascript</a> libraries.</p>
<p><strong>FQL and XFBML </strong></p>
<p>Before we look delve deeper into Facebook connect integration, let&#8217;s look at FQL and XFBML &#8211; the two essential components of the Facebook connect platform.</p>
<p><a href="http://wiki.developers.facebook.com/index.php/FQL">FQL</a> (yes, Facebook Query Language!) allows you to query data from Facebook easily using a SQL like syntax. This can be a substitute to invoking specific API methods using the client library. As a quick example, if we want to retrieve the name of a particular user, we could do:</p>
<pre>SELECT name FROM user WHERE uid=12345</pre>
<p>Simple isn&#8217;t it?  It&#8217;s important to note here that though FQL is very similar to SQL, it doesn&#8217;t fully conform to all aspects of SQL that you might come to expect. Take a look at the <a href="http://wiki.developers.facebook.com/index.php/FQL">FQL documentation</a> to find out about syntax support, and the <a href="http://wiki.developers.facebook.com/index.php/FQL_Tables">various tables</a> provided by FQL.</p>
<p><a href="http://wiki.developers.facebook.com/index.php/XFBML">XFBML</a> is a markup language provided by Facebook which allows you to embed Facebook based widgets and information into your page. By using XFBML tags, it&#8217;s much easier to embed information into the page, than having to query for it first (using FQL or an API call) and then displaying it in the application. For example, to display the user&#8217;s name, we do that simply by using the tag:</p>
<pre>&lt;fb:name uid="12345" /&gt;</pre>
<p>With the basics out of the way, let&#8217;s get started on building a simple Facebook connect application using PHP.</p>
<p><strong>Getting the API key</strong></p>
<p>The very first thing you need to do when you are looking to make use of Facebook Connect is to apply for an API key. To get that, you need to sign in to the <a href="http://www.facebook.com/developers/">Facebook Developer app</a> and create a profile for your web application.</p>
<p><img src="http://www.webdevelopmentbits.com/demo/facebook-login/fb1.gif" alt="screenshot 1" /></p>
<p>Once you have chosen a name for your Facebook Connect application, and create the application, a profile will be created for your connect application within the Facebook Developer app. You can edit this profile to add in additional information about your application. Also, note that Facebook provides you with an <strong>API Key</strong> and a <strong>Secret</strong>, both of which you need to use while calling any FB Connect API method (for authenticating your request).</p>
<p><img src="http://www.webdevelopmentbits.com/demo/facebook-login/fb2.gif" alt="screenshot 2" /></p>
<p>Although there are many fields, options and settions, you just  need to provide Facebook with the URL of your Facebook Connect application, and you can get your application up and running! This can be done by clicking on the &#8220;Connect&#8221; link and filling in the &#8220;Connect URL&#8221; field:</p>
<p><img src="http://www.webdevelopmentbits.com/demo/facebook-login/fb3.gif" alt="screenshot 3" /></p>
<p>When you are testing your application, it&#8217;s a good idea to place it under a sandbox such that only the developers have access to it. You can do that by going to &#8220;Advanced&#8221; tab and enabling the sandbox mode:</p>
<p><img src="http://www.webdevelopmentbits.com/demo/facebook-login/fb4.gif" alt="screenshot 4" /></p>
<p>That&#8217;s it, we are ready to use Facebook Connect!</p>
<p><strong>Creating the web app</strong></p>
<p>Our sample Facebook Connect application will be really simple. Here&#8217;s the <a href="http://www.webdevelopmentbits.com/demo/facebook-login/">link to the demo</a> (login using you FB account).</p>
<p>When the user visits the web app, we detect whether the user is already signed into Facebook. Facebook uses a single-on system &#8211; which means that if the user is alreadt signed into his Facebook account, we can detect that in our web application, and we can directly send the user along to the internal pages. In case the user is not logged in onto Facebook, we will give an overview of what our web application is about, and ask the user to login using Facebook Connect. Once the user is logged in, we will just display a list of his friends.</p>
<p>There are various ways of achieving this, but we will be using a mixture of XFBML, FQL and API calls to illustrate those concepts.</p>
<p>In our <strong>index.php</strong>, what we first need to do is to include the the official PHP client library for the REST API provided by Facebook. If you have not already download the PHP library, <a href="http://svn.facebook.com/svnroot/platform/clients/packages/facebook-platform.tar.gz">download it right here</a>.</p>
<pre>require_once 'facebook-platform/php/facebook.php';</pre>
<p>The file <strong>facebook.php</strong> contains a class that we will be using to make all our Facebook API calls. As I have already mentioned, the API Key, and the Secret (which we obtained during the application registration above) are compulsory parameters for all API requests. So, for convenience, we can store this information on a <strong>config.php</strong> file, which we can include from all our application pages.</p>
<pre>// config.php
// enter your application's API key and secret here:

$ApiKey = '12345667890';
$AppSecret = 'ABCDEFGHIJKLMNOPQRST';</pre>
<p>Ok, with that out of the way, our next step is to initialise the Facebook class:</p>
<pre>$facebook = new Facebook($ApiKey, $AppSecret);</pre>
<p>If your $ApiKey and $AppSecret credentials match, we will subsequently be able to make calls to the Facebook API invoking the methods of the $facebook object. As we have discussed, we need to first check if the user is already logged into Facebook. We do that by checking the &#8216;user&#8217; property of the $facebook object is set. If the user is logged in,  $facebook-&gt;user will contain the logged in user&#8217;s Facebook ID.</p>
<pre>if( !$facebook-&gt;user )
{
   // the user does NOT have a valid Facebook session
   // (i.e. not logged onto Facebook)
   // we will show some information about our app and ask the user
   // to login using FB connect:

   echo '&lt;h2&gt;Hey, this application will list all your friends on Facebook!
                But, you need to login using your Facebook account
                to continue!';
   echo '&lt;fb:login-button onlogin="javascript:location.reload(true)"&gt;
           &lt;/fb:login-button&gt;';
}
else {
   // show the user's list of friends (let's use FQL for this):

   $fqlQuery = "SELECT name FROM user WHERE uid IN (SELECT uid2 FROM
                       friend WHERE uid1 = $facebook-&gt;user)";
   $fbFriends = $facebook-&gt;api_client-&gt;fql_query($fqlQuery);

   if( $fbFriends == NULL )
   {
     echo "&lt;p&gt;Oh no, you don't have any friends on Facebook! &lt;/p&gt;";
   }
   else {
     echo "&lt;h3&gt;Your friends are: &lt;/h3&gt;";
     foreach ($fbFriends as $fbFriend)
     {
       echo $fbFriend['name'] . "&lt;br /&gt;";
     }
   }
}</pre>
<p>The above code block encompasses most of our simple application logic! It also goes to show how straightforward Facebook Connect really is, once you get the hang of it. We have used both FQL and XFBML in the code snippet. Let&#8217;s break it down and see what each code segment does.</p>
<pre>echo '&lt;fb:login-button onlogin="javascript:location.reload(true)"&gt;
               &lt;/fb:login-button&gt;';</pre>
<p>We are using XFBML above to render a Facebook connect login button for users who are not presently logged in. This button, when clicked, will open a pop-up window, which will allow the users to enter their Facebook credentials and log in.</p>
<p><img src="http://www.webdevelopmentbits.com/demo/facebook-login/fb5.gif" alt="screenshot 5" /></p>
<p>Once they login, the current page will automatically refresh, and since the user has a valid Facebook session this time, <strong>$facebook-&gt;user</strong> will return the user&#8217;s Facebook ID. To enable XFBML, we need to include two Javascript snippets to be embedded onto the page:</p>
<pre>&lt;script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/
                            FeatureLoader.js.php" type="text/javascript"&gt;
&lt;/script&gt;</pre>
<p><a href="http://wiki.developers.facebook.com/index.php/FeatureLoader.js.php">FeatureLoader.js.php</a> is a lightweight file that helps bootstrap the rest of the Connect library. It&#8217;s required for any XFBML functionality, and must be placed before any other  Facebook Connect scripts or API calls. We can either place it in the HEAD tag, or right after the BODY tag.</p>
<p>The other Javascript snippet that&#8217;s needed is:</p>
<pre>&lt;script type="text/javascript"&gt;
 FB_RequireFeatures(["XFBML"], function(){
 FB.Facebook.init("YOUR_API_KEY", "xd_receiver.htm");
 });
 &lt;/script&gt;</pre>
<p>This code snippet can be placed anywhere after the <strong>FeatureLoader.js.php</strong>. The snippet enables the use of XFBML. The file<strong> xd_receiver.htm</strong> creates a Cross Domain Communication Channel between third-party Web pages and Facebook pages. We need to create a xd_receiver.htm page with the following contents, and place it in the same directory as the main<strong> index.php</strong> file:</p>
<pre>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" &gt;
&lt;head&gt;
    &lt;title&gt;Cross-Domain Receiver Page&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;script src="http://static.ak.connect.facebook.com
                   /js/api_lib/v0.4/XdCommReceiver.js?2"
              type="text/javascript"&gt;
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>For logged-in users, we use FQL to retrieve the user&#8217;s friends.</p>
<pre>$fqlQuery = "SELECT name FROM user WHERE uid IN (SELECT uid2 FROM
                         friend WHERE uid1 = $user)";
$fbFriends = $facebook-&gt;api_client-&gt;fql_query($fqlQuery);</pre>
<p>$fbFriends will return a NULL, if no result is found. If the query produces results, an array of resulting users is returned. We can traverse this associative array and retrieve the various properies which we have queried for. In our case we have only queried for &#8216;name&#8217;, so we can print the names as:</p>
<pre>foreach ($fbFriends as $fbFriend)
{
    echo $fbFriend['name'] . "&lt;br /&gt;";
}</pre>
<p>Of course, we can retrieve lots of other details about the users (including a URL to a profile picture).</p>
<p>With that, we come to the end of our quick Facebook connect tutorial. Although our sample application is ridiculously simple in functionality, and we only scratched the basics of the Facebook Connect platform, Facebook Connect does allow developers to harness the full power of Facebook&#8217;s social features right from our application. You should check out the <a href="http://wiki.developers.facebook.com/index.php/Main_Page">Facebook API documentation</a>, and follow their <a href="http://developers.facebook.com/news.php">development blog</a> if you are serious about going for deeper levels of integration with Facebook.</p>
<p>You can download our demo files <a href="http://www.webdevelopmentbits.com/demo/facebook-login/fbconnect_sample.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/using-facebook-connect-for-your-web-application/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Writing web applications with CodeIgniter – Part 3</title>
		<link>http://www.webdevelopmentbits.com/writing-web-applications-with-codeigniter-part-3</link>
		<comments>http://www.webdevelopmentbits.com/writing-web-applications-with-codeigniter-part-3#comments</comments>
		<pubDate>Mon, 26 Oct 2009 05:06:29 +0000</pubDate>
		<dc:creator>Kishore Nallan</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[kohana]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=539</guid>
		<description><![CDATA[<p>We built a simple to-do list application <a href="http://www.webdevelopmentbits.com/writing-web-applications-with-codeigniter-part-2">last week</a> by implementing the CI basics we learnt in <a href="http://www.webdevelopmentbits.com/writing-web-applications-with-codeigniter-part-1">first part</a> of this tutorial. Today, let&#8217;s go over some of the things that will allow you to customise and extend&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>We built a simple to-do list application <a href="http://www.webdevelopmentbits.com/writing-web-applications-with-codeigniter-part-2">last week</a> by implementing the CI basics we learnt in <a href="http://www.webdevelopmentbits.com/writing-web-applications-with-codeigniter-part-1">first part</a> of this tutorial. Today, let&#8217;s go over some of the things that will allow you to customise and extend the CI framework for your specific needs. </p>
<p><strong> Changing the default URL routing</strong></p>
<p>As we have already seen, CI parses the URLs in the following format:</p>
<pre>example.com/className/functionName/variable1/variable2</pre>
<p>While this suits most of the times, sometimes we might want to tweak CI to handle things different. With a reference to the blog example we saw in the first part, say, we want to display the entries of a blog by accessing a URL along the lines of &quot;example.com/post/postID&quot;. Here, we actually want the &quot;postID&quot; to be parsed as a variable rather than a function name. </p>
<p>CI allows us to make such tweaks by allowing us to write our own routing rules. These rules are defined in <strong>application/config/routes.php</strong> file in an associative array called <strong>$route</strong> . The key of the associative array will define the URI to be matched, and its corresponding value will be the destination URI to which the request to be routed to. Apart from providing two wildcard types &quot;:num&quot; (matches only number) and &quot;:any&quot; (matches any character), CI also allows you to use regular expressions to define the URI to be matched. </p>
<p>For example, to achieve the routing we discussed above, we simply do:</p>
<pre>$route['post/(:num)'] = &quot;post/show_post/$1&quot;;</pre>
<p>The above rule routes any request to the URL &quot;post/postID&quot; (where postID is a number), to the standard CI URL &quot;post/show_post/$1&quot; where show_post is a function of the post controller class.</p>
<p><strong>Graceful error handling</strong></p>
<p>CodeIgniter allows you to generate custom error messages, which calls specific error templates. </p>
<p>CodeIgniter automatically shows a 404 error message for a missing controller. But, for generating a custom 404 error message for a missing page internally, we can do that by calling:</p>
<pre>show_404('path_to_missing_page');</pre>
<p>One place where you might be needing this is when you are serving images via a controller that parses the image ID passed as a paramter and fetches it from a secure storage to display it. The template for the 404 error page is found in <strong>application/errors/error_404.php</strong> file. </p>
<p>If you want a more generic error message, you can use the <strong>show_error</strong> function for that. We can specify both the error message, and the HTTP status code when we call this function. For example,</p>
<pre>show_error('Hey, this is a 500 error message!', 500);&nbsp;</pre>
<p>The template for this error message is found in <strong>application/errors/error_general.php</strong> file.  </p>
<p><strong>Managing multiple applications</strong></p>
<p>Although so far, we have used CI to handle just a single application, we can indeed have multiple applications using the same CI installation. To do this, we need to create a folder for each of our applications &#8211; currently our application resides within the &quot;application&quot; folder. So, say we have two applications called &quot;app1&quot; and &quot;app2&quot;, we can structure the folders this way:</p>
<pre>path_to_codeigniter/app1/
path_to_codeigniter/app2/ </pre>
<p>Copy the contents of the &quot;application&quot; folder (containing the views, controller, etc.) to these new folders. In addition, each of our application will need an &quot;index.php&quot; file that defines the path to the system and the application folders. So, we have to copy the &quot;index.php&quot; file from CI&#8217;s root folder to the app1 and app2 folders, and change the $system_folder and $application_folder variables to:</p>
<pre>$system_folder = &quot;../system&quot;; 
$application_folder = &quot;../app1&quot;;    // (use &quot;../app2&quot; for app2)</pre>
<p><strong>Caching</strong></p>
<p>To achieve better performance, it&#8217;s important we use caching effectively. This is especially true for high traffic, content oriented websites. To reduce the strain on our server, CI allows us to serve a static version of a page. Caching can be enabled on a per-page basis. Once we have enabled caching for a page, the first time the page is loaded, a static version of the file will be stored in <strong>system/cache</strong> folder. On subsequent page refreshes, this static version of the page will be served. </p>
<p>To enable caching of a particular page, we simply call this function from a controller:</p>
<pre>$this-&gt;output-&gt;cache($num_minutes); </pre>
<p>$num_minutes defines how long (in minutes) we want the cached page to be served. The function can be called from anywhere within your controller. One the $num_minutes has expired, a new version of the cached page will be written to the cache. </p>
<p><strong>Benchmarking your application</strong></p>
<p>If you are interested in measuring the performance of various parts of your application, CI&#8217;s benchmarking class will be handy. The benchmarking class is automatically loaded by CI. To calculate the elapsed time between two points, we simply do:</p>
<pre>$this-&gt;benchmark-&gt;mark('time_start');  // start timing   

 //...all the code goes here... 

$this-&gt;benchmark-&gt;mark('time_end'); // end timing
echo $this-&gt;benchmark-&gt;elapsed_time('time_start', 'time_end'); </pre>
<p>To find out the total elapsed time, we can use the same elapsed_time function without any parameters: </p>
<pre>echo $this-&gt;benchmark-&gt;elapsed_time();</pre>
<p><strong>Extending CI&#8217;s helper classes</strong></p>
<p>CodeIgniter provides various helper classes, some of which we used in our to-do list application. To extend (redefining existing methods or adding new methods) a helper class, we have to create a file in the <strong>application/helpers</strong> folder with the exact name of the existing helper class (in the system/helpers folder), but prefixing it with a &quot;MY_&quot;. So for e.g., if we want to extend the URL helper class (which is named url_helper.php), we have to create a file named &quot;MY_url_helper.php&quot; in the application/helpers folder. </p>
<p>Once we have done that, we can add either new methods to the file, or redefine an existing method (by using the same function name and parameters), which will then over-ride the default method defined in the helper class. </p>
<p><strong>Beyond CodeIgniter</strong> <strong>- Kohana framework</strong> </p>
<p>Although CodeIgniter is an extremely agile and light-weighted framework, CI&#8217;s support for PHP 4 means that quite a few &quot;hacks&quot; were used to make it work in PHP4. With the emergence of PHP5, many of these hacks (such as for auto loading of classes), have become unnecessary as PHP5 supports them cleanly, out of the box.  <a href="http://www.kohanaphp.com/">Kohana</a>, which began as a fork of CodeIgniter, is a PHP framework built exclusively for PHP5. It is also an entirely community driver project (unlike CodeIgniter, which is managed by EllisLab). If you don&#8217;t need support for PHP4, you really should take a look at <a href="http://www.kohanaphp.com/">Kohana</a>. It&#8217;s very similar to CodeIgniter, and you should not have too much trouble finding your feet in it. </p>
<p>With that, we come to the end of our three part series on CodeIgniter. If there is something I have left out, or was unclear about, please do mention them in the comments. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/writing-web-applications-with-codeigniter-part-3/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Writing web applications with CodeIgniter &#8211; Part 2</title>
		<link>http://www.webdevelopmentbits.com/writing-web-applications-with-codeigniter-part-2</link>
		<comments>http://www.webdevelopmentbits.com/writing-web-applications-with-codeigniter-part-2#comments</comments>
		<pubDate>Mon, 12 Oct 2009 11:01:45 +0000</pubDate>
		<dc:creator>Kishore Nallan</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[todo]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=525</guid>
		<description><![CDATA[<p>Last week, we covered the basic structure of a CodeIgniter application. Let&#8217;s now jump right into developing a simple todo list application using CodeIgniter. We will be keeping the actual functionality of the application itself simple here, as the goal&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Last week, we covered the basic structure of a CodeIgniter application. Let&#8217;s now jump right into developing a simple todo list application using CodeIgniter. We will be keeping the actual functionality of the application itself simple here, as the goal here is to give a good overview on what it takes to build a CI application from scratch.</p>
<p>Okay, the first thing you have to do is to download and extract the <a href="http://codeigniter.com/download.php">latest build</a> of <a href="http://codeigniter.com/">CodeIgniter</a>. Next, download the controllers, models and views that I have used in this <a href="http://download.sourcebits.com/web/todoapp_files.zip">sample todo list application</a>. You should refer to these files as you read the tutorial. Here is the <a href="http://todo.publishy.com/">demo</a> of the sample application (use &#8220;demo&#8221; as username and password). </p>
<p><strong>Directory structure</strong></p>
<p>All the files related to our application will be placed in the <strong>&quot;system/application&quot;</strong> folder:</p>
<p><img src="http://www.webdevelopmentbits.com/wp-content/uploads/2009/10/dirStructure.png" align="CI directory structure" /></p>
<p>As you can see, we have to place our controllers, views and models in their correspondng /controllers, /views and /models directories. Initially, we will have a sample controller (Welcome) in the /controllers directory, and its corresponding Welcome view in the /views directory. The model directory will be empty. </p>
<p>The /config directory consists of various files which will help us fine-tune the CI framework to our development environment. We will ignore the other directories in the /application directory for the time being. </p>
<p><strong>Some basic configuration first</strong></p>
<p>We need to modify some of the configuration files in the /config folder to set up the framework: </p>
<ul>
<li><strong>database.php</strong> &#8211; this is where we will be filling up our database connectivity details. The file has ample comments to help you  fill in all the necessary details correctly! </li>
<li><strong>config.php</strong> &#8211; we have to fill in the path to our CI root folder here in the variable: <em>$config['base_url']</em></li>
<li><strong>autoload.php</strong> &#8211; this file allows us to autoload any libraries or helpers that CodeIgniter provides us so that they are available across the entire system. We will be using the session library and the url helper class, so initialise the <em>$autoload['libraries']</em> and <em>$autoload['helper']</em> variables to:<br />
    </p>
<ul>
<li><strong>$autoload['libraries'] = array(&#8216;database&#8217;,'session&#8217;);</strong></li>
<li><strong>$autoload['helper'] = array(&#8216;url&#8217;); </strong></li>
</ul>
</li>
</ul>
<p>By default, all CI URLs will have a &quot;.index.php&quot; included in them. E.g. <strong>example.com/index.php/blog/edit</strong></p>
<p>To remove this, we can optionally place a<strong> .htaccess</strong> file in your CI root folder with the following content:</p>
<pre>RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|scripts|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L] </pre>
<p>With the above rule in place, all requests other than those for index.php, images, css, scripts and robots.txt are treated as  a request for your index.php file.</p>
<p><strong>CodeIgniter session class </strong></p>
<p>Before we go further, let&#8217;s have a brief review of CodeIgniter&#8217;s sessions class, which will be using in this application to keep track of the user&#8217;s session. CI&#8217;s session class can handle user session data stored using either cookies or in a database. CodeIgniter&#8217;s session class does not utilize native PHP sessions. To make use of the session class in our application, we must either initialize it in a controller&#8217;s constructor, or we have to auto-load it so that it will run in the background, and will be available for us across the entire system. To load the session class manually in the controller&#8217;s constructor, we do that by calling:</p>
<pre>$this-&gt;load-&gt;library('session');</pre>
<p>To auto-load the session class, we have to open the file <strong>&quot;application/config/autoload.php</strong>&quot; and add the item to the &quot;autoload&quot; array as I have mentioned in configuration step above. </p>
<p>Reading and writing data to the session class is a breeze! To write data to a user&#8217;s session, we simply do:</p>
<pre>$this-&gt;session-&gt;set_userdata('some_variable', 'some_value'); </pre>
<p>And, to retrieve the data again, we just call:</p>
<pre>$item = $this-&gt;session-&gt;userdata('item');</pre>
<p>Apart from that, CI&#8217;s session class by default, provides us with the following information:</p>
<ul>
<li>user&#8217;s unique Session ID</li>
<li>user&#8217;s IP Address</li>
<li>user&#8217;s User Agent data (the first 50 characters of the browser data string)</li>
<li>user&#8217;s &quot;last activity&quot;  time stamp </li>
</ul>
<p><strong>Our application features: </strong></p>
<p>With that, out of the way, let&#8217;s get started. Our to-do-list application will have the following &quot;features&quot;:</p>
<ul>
<li>a simple user sign up and login system</li>
<li>session management using CI&#8217;s session class </li>
<li>a single to-do list which allows multiple users to add and delete items using AJAX</li>
</ul>
<p><strong>Database schema</strong></p>
<p>Given the rather simple nature of our application, it&#8217;s not too difficult to identify what database tables we will be needing upfront. We will need two tables:</p>
<ul>
<li><strong>users</strong> : stores the user id, username and the hashed password.</li>
<li><strong>items</strong> : stores the to-do list items and their attributes like item_id, user_id (ID of the user who created it)</li>
</ul>
<pre>CREATE TABLE IF NOT EXISTS `items` (
 `item_id` bigint(20) NOT NULL auto_increment,
 `user_id` bigint(20) NOT NULL,
 `item_text` varchar(255) NOT NULL, `is_done` int(11) NOT NULL,
 PRIMARY KEY  (`item_id`)
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1; 

CREATE TABLE IF NOT EXISTS `users` (
 `user_id` bigint(20) NOT NULL auto_increment,
 `username` varchar(100) NOT NULL,
 `password` varchar(100) NOT NULL,
 PRIMARY KEY  (`user_id`)
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
</pre>
<p>Setting up the above tables in the database which you have mentioned in your database.php configuration file above. </p>
<p>Here is a breakdown of all the controllers, views and model we will be needing for this application. I will explain the purpose of each of them, as we go about tackling them. </p>
<p><img src="http://www.webdevelopmentbits.com/wp-content/uploads/2009/10/file_overview.png" alt="Overview of all the CI files" />&nbsp;</p>
<p><strong>The login controller</strong></p>
<p>The login controller first checks whether the user is already logged in &#8211; in which case, we simply redirect him to the dashboard. This, we do by checking whether the &quot;logged_in&quot; field exists in the user&#8217;s session data. We are using CI&#8217;s session class for this: </p>
<pre>if( $this-&gt;session-&gt;userdata('logged_in') )	// user already logged in
{
	header(&quot;Location: &quot; . base_url() . &quot;index.php&quot; );
	die();
}</pre>
<p>The login controller serves two needs:</p>
<ul>
<li>render the login form initially for a user who wants to sign in to the system </li>
<li>when the user submits the login form, authenticate the user and either redirect him to the dashboard or show an error message</li>
</ul>
<p>When the controller is called, we can find out whether we should render the login form, or treat the request as a login form submission by checking for the POST variable &#8216;login&#8217;, which is the name of the &quot;login&quot; submit button in the login form. </p>
<pre>if( $this-&gt;input-&gt;post('login') )
{
	// treat this as a login form submission
}

else {
	// render the login form
}
</pre>
<p>If it&#8217;s NOT a login form submission, we simply load the <strong>login_view</strong> defined in <strong>application/views/login_view.php. </strong>This file will render the login form. </p>
<p>On the other hand, if its is a login form submission, we first retrieve the username and password variable from the POST request. We then load the Users_model class, and use its validate() function to authenticate the user. If the user&#8217;s username and password match, his user_id field from the database is returned. Else, a -1 is returned. For a valid user, we initialise his session by:</p>
<pre>$newdata = array(
 'user_id'  =&gt; $user_id,
 'username'  =&gt; $username,
 'logged_in' =&gt; TRUE
 );

 $this-&gt;session-&gt;set_userdata($newdata);</pre>
<p>We then redirect him to the dashboard. If the username and password provided do not match, we load the <strong>login_view</strong> by passing a variable &#8216;$message&#8217; that contains the error to be displayed.</p>
<p><strong>The Dashboard </strong></p>
<p>The welcome controller is the default controller for CodeIgniter. It will already be found in the /application/controllers directory, and this is the controller that will be called when you access our application&#8217;s URL directly without using any URL segments, as discussed in the previous article. Let us just make use of this controller for our application&#8217;s dashboard. Assuming the user has already logged in successfully, let&#8217;s build our application&#8217;s dashboard &#8211; the page the visitor first sees after logging in. In our case, it will be a page which will display a set of to-do items, and in addition, provide a way to enter a new to-do item or modify the done/not-done status of any existing item using AJAX. Here is the index() function of the welcome controller. </p>
<pre>function index()
{

	if( !$this-&gt;session-&gt;userdata('logged_in') )	// user NOT logged in
	{
		header(&quot;Location: &quot; . base_url() . &quot;index.php/login&quot; );
		die();
	} 

 	$this-&gt;load-&gt;model('items_model','items');
        $data['all_items'] =
$this-&gt;items-&gt;fetch_all_items($this-&gt;session-&gt;userdata('user_id'));
 	$this-&gt;load-&gt;view('dashboard_view',$data);
 }</pre>
<p>The welcome controller will check whether the user is logged in (using the session data set earlier in the login controller).  If the user is not logged in, or his session has expired, we will redirect him to the login page.  The <strong>base_url()</strong> function belongs to the URL helper that we autoloaded in our configuration, and it returns the base URL of our application (including the &quot;/&quot; at the end of the URL). Otherwise, we will load the Items_model class which will be used to interact with the items table in the database. The fetch_all_items() function of the item_model class will fetch all the todo items of this particular logged in user from the &quot;items&quot; table. The only other thing to note here is that we are using the session class to retrieve the user id of the user that we have stored as session data when the user successfully logs in to the system.  </p>
<pre>function fetch_all_items($user_id)
{
  // fetch the to-do items of the user identified by $user_id:
  $query = $this-&gt;db-&gt;query(&quot;SELECT * FROM items WHERE user_id = $user_id&quot;);
  return $query-&gt;result();
} </pre>
<p> The index() function of the Welcome controller then loads the view &quot;<strong>dashboard_view</strong>&quot;, defined in &quot;dashboard_view.php&quot; in the <strong>system/application/views</strong> directory. When the view is loaded, we are passing to it the todo items we fetched from the database using the Items_model class. The view then renders all the to-do items on the page. </p>
<p><strong>dashboard_view.php</strong> links to an external stylesheet (todoapp.css) and a JavaScript file (todoapp.js). The AJAX functionality is defined in the JavaScript file. In our application, we are using AJAX to add a new todo item to the list, and also update the done/not-done status of any of the todo items. The function addNewItem() in the JavaScript file is bound to the click event of the &quot;Add&quot; button. </p>
<p>The addNewItem() function, when fired, makes an AJAX POST request to the &quot;<strong>add</strong>&quot; controller which will handle the addition of a new todo item. The add controller will return the ID field of the newly added todo item in the database. If the operation is a success (if the ID returned in not -1), we simply append the new todo item (along with a checkbox) to the bottom of the existing items. We also clear the text in the textfield. </p>
<p>The updateItem() function is bound to the click event on each of the checkboxes. When fired, it checks whether the checkbox that the user clicked is selected or not, and it sends this information to the &quot;<strong>update</strong>&quot; controller. </p>
<p><strong> The add controller</strong></p>
<p>In all the controllers, we will have to first check if the user is logged in, before we carry out any action. For a valid user, we retrieve the text of the new todo item to be added (from the POST variable sent to the script) using: </p>
<pre>$this-&gt;input-&gt;post('item_text',TRUE)</pre>
<p>The second parameter is set &#8216;TRUE&#8217; to indicate that the input must be filtered to negate XSS (cross site scripting) attempts. XSS is a major problem faced by many web applications, and as a golden rule, any input which might potentially get rendered on the front end must be passed through an XSS filter that escapes/strips out the dangerous elements. As an added precaution we also check whether the todo item&#8217;s text is not empty, and if all is clear, we load the &quot;Items_model&quot; class once again, and call the add_item() function to add the todo item to the database. The add_item() function uses another handy function that CI provides, to escape the data by adding single quotes around the data: </p>
<pre>$item_text = $this-&gt;db-&gt;escape($item_text);</pre>
<p><strong>The update controller</strong></p>
<p>What the update controller does is similar to the add controller and also fairly straight forward. It simply retrieves the POST variables sent to it (the ID of the item which is to be updated, and its updated status). The update controller then loads the Items_model and invokes the update_item() function to peform the update. </p>
<p><strong>The logout controller</strong></p>
<p>The logout controller destroys the session data of the user, and then redirects him to the login page once again.</p>
<pre>$this-&gt;session-&gt;sess_destroy();
header(&quot;Location: &quot; . base_url() . &quot;index.php/login&quot; );</pre>
<p><strong>User registration</strong></p>
<p>Finally, let&#8217;s get to the user registration, which is handled by The Register controller. First off, I should mention here that for the sake of simplicity, I have implemented a very simple registration form, with absolutely no spam control! </p>
<p>The Register controller is similar to the Login controller in that &#8211; it again serves both the purposes of rendering the registration form, and as well as handling the form submission. The register_view simply asks the user to pick a username and password. The &lt;form&gt;&#8217;s action attribute points to the URL of the register controller. </p>
<p>When the form is submitted, the Register controller first checks to see that both the username and password fields are not empty. It then loads the &quot;Users_model&quot; which handles all database operations concerned with the &quot;Users&quot; table. We will invoke the is_valid_username() of the Users_model to see whether the username that the user has chosen already exists (the function returns a -1 if no such username is found on the system). If it a username is indeed found (in which case the function will return the ID of the user), we will initialise a $message variable with the text &quot;That username already exists.&quot; and load the register view again, by passing the $message variable for rendering. </p>
<pre>if( $this-&gt;users-&gt;is_valid_username($this-&gt;db-&gt;escape($username)) != -1 )
{
	// username already exists
	$data['message'] = &quot;That username already exists.&quot;;
}
...
$this-&gt;load-&gt;view('register_view', $data); </pre>
<p>If the user has chosen a non-existing username, then we go ahead and add the user to the database by calling the Users_model&#8217;s add_user() function, by passing the username and his hashed password. We are simply using a plain SHA1 hash here to store the password (which is again considered not secure enough without <a href="http://en.wikipedia.org/wiki/Salt_(cryptography)">salting</a>, but enough for our simple application). Once the user is added to the MySQL database, we use the nifty &quot;<strong><a href="http://in.php.net/mysql_insert_id">mysql_insert_id()</a></strong>&quot; PHP function to retrieve the auto increment ID field of the user row just added to the &quot;users&quot; table. After a successful account creation, we initialise the user&#8217;s session and redirect him to the dashboard, so the user can start using the application right away.</p>
<p>With that, we come to the end of this second part of CodeIgniter tutorial. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/writing-web-applications-with-codeigniter-part-2/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Writing web applications with CodeIgniter: Part 1</title>
		<link>http://www.webdevelopmentbits.com/writing-web-applications-with-codeigniter-part-1</link>
		<comments>http://www.webdevelopmentbits.com/writing-web-applications-with-codeigniter-part-1#comments</comments>
		<pubDate>Tue, 29 Sep 2009 15:20:42 +0000</pubDate>
		<dc:creator>Kishore Nallan</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=519</guid>
		<description><![CDATA[<p>CodeIgniter is a PHP framework that makes writing secure web applications a breeze. Being extremely light weighted, it&#8217;s an impressive toolkit which promotes the Model-View-Controller (MVC) approach to software development. CodeIgniter&#8217;s incredibly useful libraries, helpers and simplicity give you a&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>CodeIgniter is a PHP framework that makes writing secure web applications a breeze. Being extremely light weighted, it&#8217;s an impressive toolkit which promotes the Model-View-Controller (MVC) approach to software development. CodeIgniter&#8217;s incredibly useful libraries, helpers and simplicity give you a sound foundation to quickly build your web apps on. This will be the first part of a series of tutorials focusing on CodeIgniter. Today, let&#8217;s get started with the basics of CodeIgniter and familiarize ourselves with the structure and semantics of a CI application. </p>
<p>I am assuming that you are already familiar with the <a href="http://en.wikipedia.org/wiki/Model&ndash;view&ndash;controller">MVC pattern</a>, so let&#8217;s briefly see how it applies to a typical CI application.</p>
<p><strong>View</strong> &#8211; A view is simply the content which a user sees rendered on a any page. It can be either a full web page, or even code snippets like the header or the footer of a web page. The view&#8217;s primary aim is to render data on the screen, which will be passed to it by a controller. </p>
<p><strong>Controller</strong> &#8211;  A controller handles the actual application logic. It acts as an intermediate between the View (front end) and the Model (the data). The controller, typically fetches records from a database via a model class, and then passes it to a view for rendering. </p>
<p><strong>Model</strong> &#8211; A model is concerned with reading and writing data to and from a data souce &#8211; in our case, a database. It essentially consists of functions which help you isolate database operations from your core application logic. In CodeIgniter, a model is not necessary, should you wish to manipulate the database from a controller itself.</p>
<p><strong>The URL structure</strong></p>
<p>One great thing about CodeIgniter is that it generates URLs which is search engine friedly and also extremely logical for programmers. Instead of using query strings (like <em>index.php?action=display&amp;id=223</em>) to pass variables, it uses a very semantic segment based URL structure. By default, the CI URLs are parsed this way: </p>
<p><em>example.com/controller_class_name/function_name/ID1/ID2</em></p>
<p>As we can see, the first segment of the URL refers to the name of the controller class, the second part referring to the function in the controller that should be invoked, and the subsequent parts representing  various parameter values that can be passed to the function. Having understood that, it&#8217;s a good time to see the structure of a controller class. </p>
<p>Let&#8217;s take a simple example of a blog. Let us say we want a page where we want to show the entries of a blog, we can have a controller &quot;show&quot; which will be defined this way: </p>
<pre>class Show extends Controller {

	function index()
	{
		// access a model class to fetch all the blog posts
			...
		// invoke a view and pass to it the blog posts to render
	}
}
</pre>
<p>There are a couple of things to note here:</p>
<ul>
<li>all controller classes begin with a capital letter in CI &#8211; i.e <strong>S</strong>how</li>
<li>we will be saving the above file as &quot;show.php&quot; &#8211; the file name is essentially the same as the class name, except that the class name&#8217;s first character has to be in capital case. </li>
<li>the index() function will be the default function of the class &#8211; much like your main() function in a C program!</li>
<li>you will access the above controller with the following URL: example.com/show/index or just example.com/show</li>
</ul>
<p>Remember that the first segment refers to the controller name and the second segment refers to the function name. Since the index function is the default function for the controller, we can leave it out from the URL. We can add another function to the class, called <strong>entry</strong> &#8211; which will display a specific blog entry identified by an identifier: </p>
<pre>function entry($entry_id)
{
	// access a model class to fetch the blog post with ID $entry_id
		...
	// invoke a view and pass to it the blog post to render
} </pre>
<p>Now, to display a particular blog entry, we access the URL: example.com/show/entry/123 , where the &quot;123&quot; is (say) the ID of the blog entry to be rendered. Pretty easy, right ? </p>
<p>Now, let&#8217;s define a CI model class. Continuing with the same blog example, let&#8217;s say that the name of the model class which will handle our blog entries is &quot;Entry_model&quot;:</p>
<pre>class Entry_model extends Model {

	function Entry_mode()
	{
		parent:Model();
	}

	function fetch_post($entry_id)
	{
		// do your database query and return the record...
	}
}</pre>
<p>Now, to invoke the method fetch_post() from the controller, we do: </p>
<pre>$this-&gt;load-&gt;model(Entry_model');
$blog_entry = $this-&gt;Entry_model-&gt;fetch_post($entry_id); </pre>
<p>Again, it&#8217;s very intuitive. We load the model class, and then, invoke a method from the model class which will return the blog entry record. The naming convention for the model class is the same as that for a controller &#8211; the class name should start with a capital letter. Thus, the above model class is called &quot;Entry_model&quot; and it will be defined in the file &quot;entry_model.php&quot;. </p>
<p>Finally, let&#8217;s get to how CodeIgniter handles the View. As I have already stated above, CI is very flexible in how you want to define a view. A view can be a whole page, or page fragments like header, footer, navigation, sidebar etc. It&#8217;s always a good practise to logically break down the layout of a web page into a number of components, as it  promotes code reusabilty. </p>
<p>As for now, for simplicity, let&#8217;s just say that our blog entry will be rendered using a single view. So, we will basically have a .php file that contains the structure (design) of the blog and which will display the blog entry that is passed to it from the controller through the form of variables. Let&#8217;s say our view (which display a blog entry) is called &quot;entry_view.php&quot;: </p>
<pre>&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Showing a blog entry&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;?php
	echo &quot;&lt;h1&gt;$entry_title&lt;/h1&gt;&quot;;
	echo $entry_text;
?&gt;

&lt;/body&gt;
&lt;/html&gt;</pre>
<p>When we invoke the view from the controller, we will pass in the variables $entry_title and $entry_text. Here is how we invoke the view we have defined above from a controller:</p>
<pre>$data['entry_title'] = &quot;A blog post title&quot;;$data['entry_text'] = &quot;Lorem ipsum dolor sit amet...&quot;;$this-&gt;load-&gt;view('entry_view', $data); </pre>
<p>I have shown a very simple example of how data is passed from the controller to a view above. The variables that will be used in the view are defined as elements of an associative array. To load a view, we call it by its filename &#8211; we don&#8217;t have to use &quot;.php&quot; extension unless we are using some other extension for the view files.</p>
<p>With that, I have covered the basic skeleton of a CI application. Stay tuned for the next article, in which I will walk you through on how to build a simple application using CodeIgniter, and also cover some more advanced concepts along the way! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/writing-web-applications-with-codeigniter-part-1/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating an inline contact form</title>
		<link>http://www.webdevelopmentbits.com/creating-an-inline-contact-form</link>
		<comments>http://www.webdevelopmentbits.com/creating-an-inline-contact-form#comments</comments>
		<pubDate>Mon, 07 Sep 2009 10:41:50 +0000</pubDate>
		<dc:creator>Kishore Nallan</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=507</guid>
		<description><![CDATA[<p>Customer feedback is arguably one of the most critical factors determining the success of a product over a period of time. Hence, it&#8217;s not surprising that many websites have some form of contact form or another to encourage users to&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Customer feedback is arguably one of the most critical factors determining the success of a product over a period of time. Hence, it&#8217;s not surprising that many websites have some form of contact form or another to encourage users to write back to them. Most of these &#8220;contact&#8221; pages tend to be on a separate page which is usually part of the navigation or is linked to with phrases like &#8220;we encourage your feedback&#8221; or &#8220;do get in touch with us&#8221;, etc.</p>
<p>However, I have often noticed that many people (unless they genuinely needed help), either back away from submitting their  comments (when they are confronted by a large  textarea on the contact page), or simply move away from the site as the contact page loads.</p>
<p>Today, let&#8217;s spice things up a bit by using jQuery to load a lightweight inline contact form. So, instead of loading a separate contact form page when the &#8220;contact us&#8221; link is clicked, we will just have a small textarea opens up dynamically right next to  the link &#8211; so that the user can type his feedback and it can be  submitted rightaway using AJAX. Our main aim here is to encourage more users to provide feedback and although I don&#8217;t have actual data to prove whether an inline form will be any more helpful, I have used it in a  couple of places, and it did appear to bring in more casual feedback  about the site, features etc. Ok, let&#8217;s get started. Here is the <strong><a href="http://www.webdevelopmentbits.com/temp/inline_form_demo.html">demo</a></strong> of how it will all look in the end.</p>
<p>Okay, first let&#8217;s have a hypothetical page in which we want to make use of the inline contact form. The call of action, is obviously the &#8220;We would love to hear your feedback&#8221; link, which has the id &#8220;a_inline_form&#8221;. Initially, this hyperlink will simply point to the default contact form page. We will have the inline form in a DIV with id &#8220;inline_form&#8221;, which will be hidden initially.</p>
<pre>#inline_form {
		/* keep the inline form hidden initially */
		display: none;

		position: relative;
		padding: 10px;
		width: 260px;
	}</pre>
<p>We will now use jQuery to &#8220;hijack&#8221; this link and fire our inline contact form into action:</p>
<pre> // toggle visibility of inline form when link is clicked
$("#a_inline_form").click( function() {

	$("#inline_form").toggle(200);

	$("#inline_form").css( "left", $("#a_inline_form").position().left +
                                                $("#a_inline_form").width() );

	$("#inline_form").css("top", "-40px");

	// get cursor to texarea, ready to receive keystrokes!
	$("#inlinecmt").focus();	

	// return false to prevent default link behaviour
	return false;
});</pre>
<p>The above code is fairly self explanatory &#8211; I just want to describe how we are positioning the inline form. jQuery allows us to very easily retrieve the left offset position of an element (even when it&#8217;s not absolutely or relatively positioned!) using &#8220;$(elem).position().left&#8221; property.</p>
<p>In this example, I wanted to place the inline form right next to the comment link. To do that, we can simply set the &#8220;left&#8221; CSS property of the inline form to a value that&#8217;s the sum of the left offset of the feedback link and the width of the comment link &#8211; this will of course place the inline form right next to the feedback link. In addition, we also set the cursor focus to the inline form so that the textarea is ready to receive input right away.</p>
<p>We have a simple &#8220;ok&#8221; button underneath the textarea which will be used to submit the form. We will once again &#8220;hijack&#8221; the form submit event using jQuery and perform the form submission using AJAX. I have omitted the actual form submission and processing here.</p>
<pre>$("#inline_form").submit( function() {

	// make your ajax POST call here...

	$("#a_inline_form").after('&lt;span class="msg"&gt;Thanks for the comment!' +
                               '&lt;/span&gt;');
	$("#inline_form").hide(200);

	setTimeout( '$(".msg").hide()', 2000);

	// return false to prevent default form submission behavior
	return false;
});</pre>
<p>Now, once the AJAX call is successful, we need to notify that to the user and thank him for the feedback. I have chosen to do that by inserting a message right after the feedback link and hiding it (using setTimeout() ) after 2 seconds. Don&#8217;t forget to hide the inline form too. With that, our inline form is up and ready to go!</p>
<p>This is by no means a replacement for the traditional contact form, but it will be handy in places where one requires casual feedback from users. And as you would have already noticed, we have used JavaScript here unobtrusively &#8211; so in case the user has JavaScript disabled, the feedback link merely loads the <a href="http://www.webdevelopmentbits.com/temp/inline_form_contact.html">default contact page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/creating-an-inline-contact-form/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Avoiding long polling</title>
		<link>http://www.webdevelopmentbits.com/avoiding-long-polling</link>
		<comments>http://www.webdevelopmentbits.com/avoiding-long-polling#comments</comments>
		<pubDate>Sun, 26 Jul 2009 15:04:02 +0000</pubDate>
		<dc:creator>Kishore Nallan</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[COMET]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[long polling]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[polling]]></category>
		<category><![CDATA[real time]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=500</guid>
		<description><![CDATA[Right from Twitter to Google Wave, real time information streaming via the browser seems to be the most "happening" thing on the web arena currently. However, feeding real time information as and when it is available to an user using your web application is not as straight forward as it is on a desktop environment. ]]></description>
			<content:encoded><![CDATA[<p>Right from Twitter to Google Wave, real time information streaming via the browser seems to be the most &quot;happening&quot; thing on the web arena currently. However, feeding real time information as and when it is available to an user using your web application is not as straight forward as it is on a desktop environment. HTTP is a stateless protocol which does not currently support a two way communication link between the server and the user&#8217;s computer via the browser. </p>
<p>The simplest way to simulate  real time streaming of information is to poll the server every N seconds, and to display the information (if any). The number N will determine how real time the resulting stream of updates will look to a viewer. This model is simply called, polling. Now, polling is bad because it repeatedly connects and disconnects to the server, which when scaled across thousands of users, cause severe strain on your server. This problem becomes even more apparent in cases when the poller returns with empty data most of the times. </p>
<p>The jQuery snippet below polls the server every 3 seconds for new information and displays it in a simple alert box.</p>
<pre>
function callComplete(response) {
	alert("Response received is: "+response);
};

function connect() {
	// when the call completes, callComplete() will be called along with
	// the response returned
	$.post('/path/to/script.php', {}, callComplete, 'json');
};

$(document).ready( function() {
	setInterval(connect,3000);
}
</pre>
</p>
<p><strong>Long polling</strong></p>
<p>This technique is an optimisation of the traditional polling method. In long polling, once the client makes a connection with the server (via JavaScript), the server waits for the data requested by the client to become available. If it&#8217;s not immediately available, the server (being a PHP script for example) loops and sleeps. When the data is available, the server returns the data to the client and the connection closes. When this happens, the client again reconnects with the server (in the callback function of your original AJAX request). </p>
<p>This method is definitely an improvement over mindless polling, as we will avoid repeatedly opening and closing connections when data is not available for long periods of time. However, it is important to be aware of the server side technical limitations of long polling. Since connections might be kept alive for long durations of time, your web server must be capable of handling such large numbers of simultaneous connections. We talked about how certain light weight webservers outperformed Apache in this particular area in the last article. </p>
<p>Let&#8217;s look at a very simple jQuery/PHP long polling example: </p>
<pre>function callComplete(response) {
	alert("Response received is: "+response);
	// reconnect to the server
	connect();
};

function connect() {
	// when the call completes, callComplete() will be called along with
	// the response returned
	$.post('/path/to/script.php', {}, callComplete, 'json');
};

$(document).ready( function() {
	connect();
}
</pre>
</p>
<p>In the PHP end, we do:</p>
<pre>
while(1) {

	$data = &quot;some data fetched from the DB&quot;;

	// if we have new data, return it to the client
	if(!empty($data)) {
		echo json_encode($data);
		break;
	}

	sleep(3000);	// we sleep for 3s and check again for data
}
</pre>
<p><strong>COMET streaming </strong></p>
<p>COMET is a generic term that refers to the use a persistent HTTP connection for the web server to &quot;push&quot; data to the client as and when it arrives. If you have ever wondered how Gmail is able to notify you of a new email message seconds after it is sent, this is what they use to push the new email notifications to the front end. </p>
<p>However, as often is the case with JavaScript, the cross browser compatibility issues mean that a host of methods (targeting different browsers) are used to implement such an interaction. The upside is that these methods rely purely on JavaScript, and hence not dependent on any specific client side plugin. A detailed exploration of these different methods and their caveats is beyond the scope of this article, but let&#8217;s get a quick overview of these methods.</p>
<p><strong>Hidden iframe technique:</strong> A hidden iframe html element is embedded onto the page, which points to the URL on the server which handles the persistent connection. The server will then push the data as it arrives to the iframe, using &lt;script&gt; tags. This content is then channeled to the parent window using JavaScript. This method is based on the fact that many browsers evaluate JavaScript chunks as they are received, even if the complete page has not finished loading yet. However this method is prone to cause the &quot;loading&quot; icon or status bar message to appear all the time (since we are using a persistent HTTP connection, the browsers tend to believe that the page is yet to finish loading fully). </p>
<p><strong>XMLHttpRequest using Interactive readyState:</strong> This method is targetted towards Firefox, Safari and Chrome, which support the interactive readyState property of the XHR object, and fires events every time a chunk of data is received from the server. </p>
<p><strong>Server-Sent events: </strong>This is a feature (from the <a href="http://whatwg.org">WHATWG</a> Web Applications 1.0 specification) supported by Opera since v9, using which we can push events from the server directly to the visitor&#8217;s browser. Refer to <a href="http://my.opera.com/WebApplications/blog/show.dml/438711">this article</a> on how it&#8217;s used. </p>
<p>As you can see, it&#8217;s quite a mouthful, and hence implementing COMET streaming which works uniformly across all major browsers is not a task for the faint hearted (not forgetting that the webserver must also be able to handle a large number of persistent connection). The good news is that quite a lot of the hard work has already been done for you. There are various opensource COMET servers and client libraries which you can use to deploy a COMET application pretty safely. Here are a few of them for your exploration: </p>
<p><strong><a href="http://orbited.org">Orbited</a>:</strong> &quot;Orbited is an HTTP daemon that is optimized for long-lasting comet  connections. Orbited allows you to write real-time web  applications, such as a chat room or instant messaging client, without  using any external plugins like Flash or Java. &quot;</p>
<p><a href="http://cometdproject.dojotoolkit.org/"><strong>Cometd:</strong></a> &quot;Cometd is a scalable HTTP-based event routing bus that uses a Ajax Push technology pattern known as Comet.&quot; </p>
<p><strong><a href="http://meteorserver.org/">Meteor</a>:</strong> &quot;Meteor is an open source HTTP server, designed to offer developers a simple means of integrating streaming data into web applications without the need for page refreshes.&quot;</p>
<p><a href="http://pi.kodfabrik.com/documentation/plugin/pi.comet/"><strong>Comet Pi:</strong></a> This is a standalone JavaScript library which you can use to handle the various cross browser issues that COMET causes. You can use pi.comet with any serverside language. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/avoiding-long-polling/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Light weight alternatives to Apache</title>
		<link>http://www.webdevelopmentbits.com/light-weight-alternatives-to-apache</link>
		<comments>http://www.webdevelopmentbits.com/light-weight-alternatives-to-apache#comments</comments>
		<pubDate>Sun, 14 Jun 2009 18:12:44 +0000</pubDate>
		<dc:creator>Kishore Nallan</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[web-server]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=487</guid>
		<description><![CDATA[When it comes to choosing a Linux web server, Apache, as we all know, is almost a de facto standard. There is even a chance that your web host does not even offer (or worse, know of) an alternative web server. So, it's not a big surprise that many developers don't know too much about what other alternatives are available to them.]]></description>
			<content:encoded><![CDATA[<p>When it comes to choosing a Linux web  server, Apache, as we all know, is almost a de facto standard. There is even a chance  that your web host does not even offer (or worse, know of) an alternative web  server. So, it&#8217;s not a big surprise that many developers don&#8217;t know too much  about what other alternatives are available to them.</p>
<p>There is of course no denying that Apache  is indeed an old war horse, and an extremely robust and mature one at that. But,  even as stable as Apache is, it has one main drawback &#8211; it occupies a large  memory footprint due to its request-per-process model, and is therefore mediocre  at handling multiple concurrent requests when you have a limited RAM. This can  be a problem when you are starting out small, with a rented 256 MB VPS for your  application. Even if you are a big player, light weight Apache alternatives can  help increase the throughput of your servers. Youtube, for instance, was using  Lighttpd, a light-weight web server to serve millions of videos everyday (prior  to their acquisition by Google).</p>
<p>Ok enough digressing, let’s now take a look  at some of the open source alternatives to Apache.</p>
<p><strong>Lighttpd</strong></p>
<p><a href="http://www.lighttpd.net/">Lighttpd</a>, pronounced as Lighty, is a single  threaded web server optimized for a large number of keep-alive connections,  which is often a requirement for high traffic web applications. It was  originally developed by the German programmer Jan Kneschke to solve the  <a href="http://www.kegel.com/c10k.html">C10k problem</a> (handle 10,000 parallel  connections using a single server). Apart from Youtube as I have already  mentioned, Wikipedia, Meebo and Sourceforge all use Lighttpd. Lighttpd is rich  with features, and offers mod_rewrite (URL rewriting), FastCGI support, HTTP  compression, amongst many other features. I was able to install and configure  Lighttpd in a few minutes, and it is extremely light-weight (less than 1MB). I  was able to get PHP/MySQL running in a couple of minutes, using the FastCGI  interface.</p>
<p>One drawback, which I have seen repeatedly  mentioned in many forums and blogs on the web (I could not verify these claims  with my own tests), is that Lighttpd seems to suffer from memory leaks &#8211;  which often required scheduled server restarts.</p>
<p><strong>Nginx</strong></p>
<p><a href="http://nginx.net/">Nginx</a>, pronounced as Engine-X, is a web  server originating from Russia, and is written by <a href="http://sysoev.ru/en/">Igor  Sysoev</a>. Unlike Lighttpd, Nginx is not a single  threaded webserver (it instead uses a single master process which delegates  work to a small number of worker processes), but is another popular light  weight web server alternative. It is supported by more than 20% of Russian  virtual hosts, and is gaining lots of attention these days in other parts of  the world too.</p>
<p>Nginx is excellent at serving static files  and also supports reverse proxying. Like Lighttpd, I was able to get Nginx up  and running in a few minutes. However, it does not come up with default FastCGI  support &#8211; so getting PHP/MySQL working was a little tricky. It involves  spawning a FastCGI process manually. I found <a href="http://bc-dev.net/2008/05/07/mysql-nginx-and-php-on-ubuntu-804/">this tutorial helpful</a>.</p>
<p><strong>Erlang based alternatives</strong></p>
<p>Erlang is a concurrent programming language  designed by Ericsson to support distributed, soft real time applications, which  has been opensourced since 1998. I definitely want to write more about how  scalable Erlang is, but this is not the article for that. So, let’s just say  that Erlang is tailor-made for high demand applications which need to handle  multiple concurrent connections &#8211; like a web server.</p>
<p><a href="http://yaws.hyber.org/">YAWS</a> (Yet Another Web Server) and <a href="http://code.google.com/p/mochiweb/">Mochiweb</a> are two Erlang based  web servers which I found to be highly scalable and light-weight.</p>
<p>A load test conducted matching Yaws against  Apache found that Apache failed at 4,000 concurrent connections, while Yaws  continued functioning with over 80,000 concurrent connections (<a href="http://www.sics.se/~joe/apachevsyaws.html">source</a>). I did have some trouble installing  and configuring YAWS though. The documentation is scarce, to say the least.</p>
<p>Mochiweb is actually an Erlang library for  building your own light-weight HTTP server. Don&#8217;t be put off by that statement!  A simple server can be built with just a few lines of code. I installed and  tested Mochiweb too, and I found it pretty easy. If you are interested, here is  <a href="http://beebole.com/en/blog/erlang/how-to-quickly-set-up-ubuntu-804-loaded-with-erlang-mochiweb-and-nginx/">a tutorial which I found helpful</a>.</p>
<p><strong> So should you ditch Apache?</strong></p>
<p>This decision depends on a number of  factors. Like I have already stated, if you want to make the best out of the  limited resources you have, then a light-weight web server is definitely  advantageous. However, from my experience with playing with the above  alternatives, if you do decide to go with one of them, you should be prepared to  roughen it out. Poor documentation and support (the mailing lists and forums  are generally helpful, but you can never completely rely on them when you are  suddenly facing an issue in a production environment) could end up making  things difficult for you. Don&#8217;t get me wrong, I am not saying that these servers are not  production-ready yet (they <em>are</em> pretty  stable), but there is always an off-chance you might just hit upon some snag.  In that case, you probably have to roughen it out.</p>
<p>A reasonable choice would be to front  Apache with one of these light weight web servers. In effect, you can use them  for load balancing. Using reverse-proxying, you can handle the static files  (like CSS and images) using a light weight web server, and route the dynamic  requests to Apache.</p>
<p>So, in future, I hope you will consider an  Apache alternative, should your needs be better satisfied by a light-er web  server. If you have experience using any of the above alternatives, do share  your views in the comments!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/light-weight-alternatives-to-apache/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dual form processing</title>
		<link>http://www.webdevelopmentbits.com/dual-form-processing</link>
		<comments>http://www.webdevelopmentbits.com/dual-form-processing#comments</comments>
		<pubDate>Tue, 14 Apr 2009 14:18:39 +0000</pubDate>
		<dc:creator>Kishore Nallan</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=477</guid>
		<description><![CDATA[<p>Recently, a client of mine wanted a single web form, residing on the localhost to submit the form contents to a database in the localhost, and as well as to a web server simultaneously. Although this sounds like an unnecessary&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Recently, a client of mine wanted a single web form, residing on the localhost to submit the form contents to a database in the localhost, and as well as to a web server simultaneously. Although this sounds like an unnecessary duplication of data, my client wanted some of the form data to be stored on the localhost for the intranet applications to use. Achieving this functionality <em>would have</em> been a piece of cake, if we were not handicapped by the unavailability of cross-domain AJAX. For those of us familiar with AJAX, we know that we cannot send an AJAX request to a remote server due to security reasons &#8211; atleast not in a reliable, hack-less way.</p>
<p>So, instead of looking for a pure AJAX solution, I decided to implement this functionality by using a combination of AJAX (for the localhost) and a traditional PHP POST request (for the web server). The trick here is to execute the AJAX call before the form is submitted &#8211; by catching the form submission event using JavaScript. Once the AJAX call is successful, we allow the default form submission to take place. In case there is an error with our AJAX call, we should stop the propogation of the traditional form submission too.</p>
<p>Ok, so let&#8217;s start off with a simple example &#8211; a no-frills form with a few fields.</p>
<pre>

&lt;form method="post" id="webform" action="http://www.example.com/path/to/PHPscript.php"&gt;

&lt;label for="firstname"&gt;first name:&lt;/label&gt;
&lt;input type="text" name="firstname" id="firstname" value="" /&gt;

&lt;label for="lastname"&gt;last name:&lt;/label&gt;
&lt;input type="text" name="lastname" id="lastname" value="" /&gt;

&lt;label for="email" id="l_email"&gt;email address:&lt;/label&gt;
&lt;input type="text" name="email" id="email" value="" /&gt;

&lt;input type="submit" name="Submit" id="submit_butt" value="Submit" /&gt;
&lt;input type="reset" /&gt;

&lt;/form&gt;
</pre>
<p>When the above form is submitted as it is, the form contents will be sent to the PHP script in the webserver. As I mentioned earlier, what we need to do now is &#8220;catch&#8221; this form submission event and insert our AJAX call before that. Let&#8217;s see how we can do that now. We will be using jQuery for our JavaScript needs.</p>
<pre>

$(document).ready(function(){
$("#webform").submit( function()
{
var success = -1;

$.post("localScript.php",
{
firstname: $("#firstname").val(),
lastname: $("#lastname").val(),
email: $("#email").val()
},

function(response){

if(response.status == "0")
success = false;
else
success = true;

}, "json");

var d = new Date();
var t = d.getSeconds();

while(success==-1)
{
var d = new Date();
if(d.getSeconds() - t &gt; 4)
{
success = false;
break;
}
}

return success;
});
});
</pre>
<p>We set-up an event handler using jQuery, which fires whenever the form is submitted. We then make an AJAX call to the localhost to submit the form contents. We have a callback function which checks the status of the AJAX call. In case, any error occurs on the localhost, an error code can be returned (in our case, the status value will be 0) and we have to stop the form submission by returning &#8220;false&#8221; from the event handler function. This will stop the default action of the submit button, i.e. it will prevent the HTTP form submission.</p>
<p>This is achieved using a hack. Since the script will not wait for the callback function to return, the next statement, i.e. the &#8220;return&#8221; statement will be executed immediately after the $.post() call is made to the server. However, we cannot return from the function without knowing whether the operation on the backend succeeded or not. Since, JavaScript does not natively have any sleep()-like function, we have to force our script to get into a blocked state using a while() loop. We then manually terminate the while loop if we did not hear back from the server within a &#8220;few&#8221; seconds. In our example we have defined the timeout to be 4 seconds. In case we don&#8217;t hear from the server within this time, we will terminate the form submission by returning a &#8220;false&#8221;. This elaborate hack is required to ensure that we do not proceed to the next stage without knowing what happened to the data we submitted to the localhost.</p>
<p>If everything goes well in the localhost, the contents of the form will be processed and stored in the localhost database by the PHP script we have called using AJAX. The submit event handler will then return &#8220;true&#8221;. This would in turn cause the form to be submitted to the PHP script on the remote server, as defined in the action attribute of the &lt;form&gt; tag. Once the form is submitted, the browser requests, and loads this PHP script. The PHP scripts recieves the form contents as POST variables and saves them (by perhaps, storing them in a database).</p>
<p>We are not done yet, though. We still have to send the user back to a page on the localhost once the PHP script has finished processing and storing the form contents. We do that by:</p>
<pre>
</pre>
<pre>$redirect_url = "http://localhost/path/to/some/page";
header( 'Location: ' . $redirect_url );
exit;</pre>
<p>It is important that the header() is called <em>before</em> any actual output is sent to the browser. For example, you should not have any echo statement, or raw HTML output before calling the header().</p>
<p>That&#8217;s about it! Now we are really done! In most cases, you will notice that this entire process is so slick that your user would hardly notice the redirection from the page on the webserver to the page on the localhost! I have put together a barebones HTML page containing the code fragments above, which you can download for your reference and use from <a href="http://labs.sourcebits.com/wdb/dual_form_processing_demo.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/dual-form-processing/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FLOW3 is arriving</title>
		<link>http://www.webdevelopmentbits.com/flow3-is-arriving</link>
		<comments>http://www.webdevelopmentbits.com/flow3-is-arriving#comments</comments>
		<pubDate>Fri, 03 Apr 2009 12:01:45 +0000</pubDate>
		<dc:creator>Ramses Paiva</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=464</guid>
		<description><![CDATA[<p>Not yet released, FLOW3 starts making noises on the mass: what&#8217;s TYPO3 up to?</p>
<p>As a result of the already proven TYPO3 CMS, the upcoming 5th version of the system is bringing a solid PHP framework, which can be used&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Not yet released, FLOW3 starts making noises on the mass: what&#8217;s TYPO3 up to?</p>
<p>As a result of the already proven TYPO3 CMS, the upcoming 5th version of the system is bringing a solid PHP framework, which can be used apart from the whole system for developing applications of any kind.</p>
<p>The FLOW3 subsite stats, against what&#8217;s commonly seen out there, FLOW3 is not a pick&#8217;n'mix store of motley components. It&#8217;s a framework which helps you with the infrastructure of your application. Object Lifecycle Management, Package Management, Resource Management and Security are on his home field. Real business logic is left over to third-party packages.</p>
<p>All the most common features we can find in other PHP frameworks are going to be provided by FLOW3, like MVC architecture, Validation, Filters, Persistence Object Manager and much more.</p>
<p>Next week, I&#8217;ll post a getting started with a simple application and provide my personal review of this framework, which &#8211; OMHO &#8211; is going to rock!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/flow3-is-arriving/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>No IE6 support on new W3C website?</title>
		<link>http://www.webdevelopmentbits.com/no-ie6-support-on-new-w3c-website</link>
		<comments>http://www.webdevelopmentbits.com/no-ie6-support-on-new-w3c-website#comments</comments>
		<pubDate>Fri, 27 Mar 2009 14:00:59 +0000</pubDate>
		<dc:creator>Dilip Shukla</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[IE6]]></category>
		<category><![CDATA[W3]]></category>
		<category><![CDATA[Web Standards]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=445</guid>
		<description><![CDATA[<p><a title="World Wide Web Consortium" href="http://www.w3.org" target="_blank">W3.org</a> is overhauling its website in order to make it more user-friendly and quiet people who used to wonder (including me) why the administrator body of web have such dull, flat, unorganized and old fashioned website?</p>
<p>The new website looks&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p><a title="World Wide Web Consortium" href="http://www.w3.org" target="_blank">W3.org</a> is overhauling its website in order to make it more user-friendly and quiet people who used to wonder (including me) why the administrator body of web have such dull, flat, unorganized and old fashioned website?</p>
<p>The new website looks more attractive and organized. 10 minutes tour of new website <a title="10 Minutes Tour of http://beta.w3.org/" href="http://dotsub.com/view/41e149bd-8b98-4103-a9f8-c96787497211" target="_blank">can be found here</a>. In contrast with the previous version, this new website uses rich content presentation, including JavaScript.</p>
<p>The website uses <a title="Download jQuery 1.3.2 from Google Code" href="http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.3.2.min.js" target="_blank">jQuery 1.3.2</a>, a very known and popular JavaScript library, instead of pure JavaScript. This is very good news and a big leap towards streamlining the use of JavaScript frameworks, specially in case of jQuery. In addition of core jQuery framework, <a title="Beta World Wide Web Consortium" href="http://beta.w3.org" target="_blank">beta.w3.org</a> also uses jQuery plugins (e.g.: <a title="jQuery Cycle Plugin" href="http://malsup.com/jquery/cycle/" target="_blank">http://malsup.com/jquery/cycle/</a>), to enhance the user experience.</p>
<p>The biggest news of the day is w3.org beta website doesn&#8217;t render correctly in IE6. It&#8217;s supposed to be a strong argument for web developers in order to inspire and take initiative towards to stop exclusive coding to render their websites correctly in IE6.</p>
<p style="text-align: center;"><img class="size-full wp-image-451 aligncenter" src="http://www.webdevelopmentbits.com/wp-content/uploads/2009/03/ie6.jpg" alt="" width="500" height="428" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/no-ie6-support-on-new-w3c-website/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Framework &#8211; Sourcebits Contribution Team</title>
		<link>http://www.webdevelopmentbits.com/zend-framework-sourcebits-contribution-team</link>
		<comments>http://www.webdevelopmentbits.com/zend-framework-sourcebits-contribution-team#comments</comments>
		<pubDate>Tue, 24 Mar 2009 11:35:09 +0000</pubDate>
		<dc:creator>Ramses Paiva</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[Contributors]]></category>
		<category><![CDATA[Sourcebits]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=89</guid>
		<description><![CDATA[<p>Sourcebits is investing efforts for making one of the best PHP frameworks even better. With a whole team of talented and skilled developers, we&#8217;re contributing to the framework using the best proven components we have developed based on our experience&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Sourcebits is investing efforts for making one of the best PHP frameworks even better. With a whole team of talented and skilled developers, we&#8217;re contributing to the framework using the best proven components we have developed based on our experience using the Zend Framework on our projects.</p>
<p>You can check out the proposals we have already submmitted for review here:<br />
* <a href="http://framework.zend.com/wiki/display/ZFPROP/Zend_Calendar+-+Ramses+Paiva">Zend Calendar</a>.<br />
* <a href="http://framework.zend.com/wiki/display/ZFPROP/Zend_Template+-+Ramses+Paiva">Zend Template</a>.</p>
<p>Hope you&#8217;ll enjoy! <img src='http://www.webdevelopmentbits.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/zend-framework-sourcebits-contribution-team/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using the keyword &#8220;this&#8221; in PHP</title>
		<link>http://www.webdevelopmentbits.com/using-this-in-php</link>
		<comments>http://www.webdevelopmentbits.com/using-this-in-php#comments</comments>
		<pubDate>Thu, 08 Jan 2009 16:09:39 +0000</pubDate>
		<dc:creator>Prakash Mohanty</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[object-oriented basics]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=345</guid>
		<description><![CDATA[You may come across number of functions, variables inside a class, you
call each one them as object of the class.

The keyword “this” is used in a class in php , to call and use these objects as
shown in the example below.]]></description>
			<content:encoded><![CDATA[<p>You may have come across number of functions and variables inside a class and perhaps you don&#8217;t even know how they&#8217;re called or invoked. These functions and variables that belong to a class are called as properties and methods, or simply members, of this class.</p>
<p>In PHP, the keyword &#8220;<code>$this</code>&#8221; is used as a self reference of a class and you can use it for calling and using these properties and methods as shown in the example bellow.</p>
<p>Create a file ClassOne.php with code bellow:<br />
<code>&lt;?php</code></p>
<pre>
class ClassOne
{
    // this is a property of this class
    public $propertyOne;

    // When the ClassOne is instantiated, the first method called is
    // its constructor, which also is a method of the class
    public function __construct($argumentOne)
    {
        // this key word used here to assign
        // the argument to the class
        $this->propertyOne = $argumentOne;
    }

    // this is a method of the class
    function methodOne()
    {
        //this keyword also used here to use  the value of variable $var1
        return 'Method one print value for its '
             . ' property $propertyOne: ' . $this->propertyOne;
    }
}
</pre>
<p>In this class, we are also using the visibility declarations (public), which means whether the members are accessible on a subclass &#8211; we will discuss it later &#8211; or instance.<br />
Another thing you must be curious about is the use of &#8216;->&#8217;. This is an object pointer and, on PHP, it&#8217;s used for accessing members inside an object.</p>
<p>Now, let&#8217;s test your class! Create another file, called use.php with the following code:<br />
<code>&lt;?php</code></p>
<pre>
// include your class file
require_once 'ClassOne.php';

// Create an instance of your class
$classOneInstance = new ClassOne('Hello');

// And test it
print $classOneInstance->propertyOne . '&lt;br /&gt;';
print $classOneInstance->methodOne();
</pre>
<p>- Note that in both files we&#8217;re not using the enclosing PHP tags (?&gt;). Once they have only PHP code, it&#8217;s not needed and it&#8217;s also a good practice to avoid them on pure PHP files.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/using-this-in-php/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>HTTP Request without CURL</title>
		<link>http://www.webdevelopmentbits.com/http-request-without-curl</link>
		<comments>http://www.webdevelopmentbits.com/http-request-without-curl#comments</comments>
		<pubDate>Thu, 08 Jan 2009 09:46:37 +0000</pubDate>
		<dc:creator>Prakash Mohanty</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[HTTP Request]]></category>
		<category><![CDATA[no CURL]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=340</guid>
		<description><![CDATA[<p>A short tutorial on how to make a simple object for HTTP request without the need of using CURL.<br />
The way to accomplish that is using the function <code>stream_context_create</code> to prepare the string, and then you use <code>fopen</code> and&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>A short tutorial on how to make a simple object for HTTP request without the need of using CURL.<br />
The way to accomplish that is using the function <code>stream_context_create</code> to prepare the string, and then you use <code>fopen</code> and <code>stream_get_contents</code> to get the response.</p>
<p><code>&lt;?php</code></p>
<pre>
class Custom_Http_Request
{
    private $_url;
    private $_body;
    private $_method = 'POST';
    private $_headers = array();
    private $_response;
    private $_stream;

    public function __construct($url, $body)
    {
        if (empty($url) || empty($body)) {
            throw new Exception('Both URL and BODY are required '
                              . 'for fetching the request.');
        }

        $this->_url  = $url;
        $this->_body = $body;
    }

    public function setMethod($method)
    {
        if ('POST' == $method || 'GET' == $method) {
            $this->_method = $method;
            return $this;
        }

        throw new Exception('Invalid method set.');
    }

    public function addHeader(array $header)
    {
        if (!empty($header)) {
            $this->_headers[] = $header;
            return $this;
        }

        throw new Exception('The headers are empty.');
    }

    public function getMethod()
    {
        return $this->_method;
    }

    public function getBody()
    {
        return $this->_body;
    }

    public function getHeaders()
    {
        return $this->_headers;
    }

    public function getResponse()
    {
        if (is_null($this->_stream)) {
            $this->_openStream();
        }

        if (is_null($this->_response)) {
            $this->_response = @stream_get_contents($this->_stream);

            if (false === $this->_response) {
                throw new Exception('It is not possible to '
                                  . 'read from the response.');
            }
        }

        return $this->_response;
    }

    private function _assemble()
    {
        $params = array(
        	'http' => array(
        		'method'  => $this->_method,
        		'content' => $this->_body
            )
        );

        if (!empty($this->_headers)) {
            $params['http']['header'] = $this->_headers;
        }

        return stream_context_create($params);
    }

    private function _openStream()
    {
        $this->_stream = <code>@fopen</code>($this->_url, 'rb', false, $this->_assemble());

        if (!$this->_stream) {
            throw new Exception('It was not possible to '
                              . "connect to {$this->_url}.");
        }
    }
}
</pre>
<p>More on this in my next post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/http-request-without-curl/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>See, Yes! Yes! &#8211; GO</title>
		<link>http://www.webdevelopmentbits.com/see-yes-yes-go</link>
		<comments>http://www.webdevelopmentbits.com/see-yes-yes-go#comments</comments>
		<pubDate>Tue, 09 Dec 2008 16:05:10 +0000</pubDate>
		<dc:creator>Dilip Shukla</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Web Standard]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=326</guid>
		<description><![CDATA[Modular CSS needs to be developed and all inherited properties needs to commented within CSS declaration so one don't repeat same CSS again and selectors needs to named by some naming convention (e.g. prefixing every declaration by module).

Modules needs to be devised in such way so it remain plug and play if plugged in different application.]]></description>
			<content:encoded><![CDATA[<p>Hello readers,</p>
<p>Welcome to third and final part of my CSS primer.</p>
<p>Continuing from previous post <a title="CSS Steady" href="http://www.webdevelopmentbits.com/see-yes-yes-steady/">&#8216;CSS Steady&#8217;</a> now I&#8217;ll tell you something about polishing the CSS. Following text will help in decision making during CSS coding.</p>
<p><strong>ID vs Class Vs Tag Vs Pseudo selectors</strong>:</p>
<p>All CSS developers know this fact there are verity of CSS selectors, CSS rules can be applied by using any one or combination of available selectors. We can apply CSS rules by inline CSS as value of style attribute of HTML tags or internal CSS by using style tag, or we can go for external style sheet. Inline CSS is bad and must be avoided. Inline style declarations should be limited to for some run time CSS manipulation only.</p>
<p>In summery using external CSS is preferred way, Its success depends on use of inline or internal CSS, since in effectiveness of application of CSS rules hierarchy, inline CSS is topmost level after that comes internal CSS and external CSS comes bellow them.</p>
<p>Same way &#8216;id&#8217; is above &#8216;class&#8217; in hierarchy of effectiveness of CSS selectors. Id can&#8217;t be used more than once in a page (its preferred to use one id for same element throughout application not only withing page).</p>
<p>Rigid element&#8217;s CSS should be served by using &#8216;id&#8217; CSS selectors, which will be used only once e.g. header, footer etc. Elements with dynamic nature having shared or inherited property with possible multiple occurrence need fetch CSS rules by &#8216;class&#8217; selectors.</p>
<p>Use of &#8216;tag&#8217; selectors can be decided by doing some research on default look and feel of elements of application. psudo CSS selectors can be used if backward compatibility with older browsers not needed.</p>
<p>Inheritance playes a great role in  in this that&#8217;s why planning is uttermost important. we should always keep in mind we are just contributing in development of some application which might have multiple developers hence coding must stick to requirements and standards of application so any one can understand and edit code of each other.</p>
<p>Modular CSS needs to be developed and all inherited properties needs to commented within CSS declaration so one don&#8217;t repeat same CSS again and selectors needs to named by some naming convention (e.g. prefixing every declaration by module).</p>
<p>Modules needs to be devised in such way so it remain plug and play if plugged in different application.</p>
<p><strong>Resources</strong>:</p>
<p>following are some useful resources which might play great role to make a good CSS developer out of you.</p>
<ul>
<li><a href="http://www.smashingmagazine.com/2008/11/12/12-principles-for-keeping-your-code-clean/">Make your markup clean</a></li>
<li><a href="http://www.jquery.com">Don&#8217;t fear to java script RIA is future. Jquery might be good place to start (and possibly end of search).</a></li>
<li><a href="http://www.smashingmagazine.com">Keep a tab on latest, fresh and trust worthy tips, tricks, trends, news etc related to web development.</a></li>
<li><a href="http://code.google.com/p/doctype/">Get benefit and give benefit by being active part of revolution in web development. Join the wiki maintained by web developers for web developer from Google. </a></li>
<li><a href="http://www.alistapart.com/">Know more about standards, stick to them and force them upon you, make web development your passion and web standards your religion. </a></li>
</ul>
<p>Above links are ocean on themselves and they carry more waves within if you want to explore more.</p>
<p>But my point is practice them, Its more important.</p>
<p>Ok guys hope you have enjoyed the article and will take benefit out of it.</p>
<p><strong>Happy Web Development</strong></p>
<p>Cheers <img src='http://www.webdevelopmentbits.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/see-yes-yes-go/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Alert!!! Phishing Net Ahead!</title>
		<link>http://www.webdevelopmentbits.com/phishing-net</link>
		<comments>http://www.webdevelopmentbits.com/phishing-net#comments</comments>
		<pubDate>Thu, 13 Nov 2008 06:36:55 +0000</pubDate>
		<dc:creator>Chinmay Chiranjeeb</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Security]]></category>
		<category><![CDATA[Content Piracy]]></category>
		<category><![CDATA[Domain Swapping]]></category>
		<category><![CDATA[Hacking Alert]]></category>
		<category><![CDATA[Hosting Swapping]]></category>
		<category><![CDATA[Phishing Alert]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=298</guid>
		<description><![CDATA[<p><strong>Phishing</strong> is a scam where Internet fraudsters send spam or pop-up messages to lure personal, financial and Intellectual  information from unsuspecting victims.</p>
<p style="text-align: center;"><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2008/11/phishing.png"><img class="size-medium wp-image-304" title="phishing" src="http://www.webdevelopmentbits.com/wp-content/uploads/2008/11/phishing-225x300.png" alt="" width="225" height="300" /></a></p>
<p><strong>Personal Phishing</strong> ask for the Personal info ie. Address, email Id, Contact No.</p>
<p><strong>Financial Phishing</strong>&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p><strong>Phishing</strong> is a scam where Internet fraudsters send spam or pop-up messages to lure personal, financial and Intellectual  information from unsuspecting victims.</p>
<p style="text-align: center;"><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2008/11/phishing.png"><img class="size-medium wp-image-304" title="phishing" src="http://www.webdevelopmentbits.com/wp-content/uploads/2008/11/phishing-225x300.png" alt="" width="225" height="300" /></a></p>
<p><strong>Personal Phishing</strong> ask for the Personal info ie. Address, email Id, Contact No.</p>
<p><strong>Financial Phishing</strong> asks for Bank Details, Credit Card details and Third Party Money Transfer (Like: Paypal Inc, Yahoo! Wallet. etc) details.</p>
<blockquote><p>Why? That&#8217;s the business. Sell it to advertisers and marketers or use it as E-Cash.</p></blockquote>
<p><strong>Intellectual Property Phishing</strong> is the Advance Phishing technique, which is the hot cakes for Phishermen / Hackers. Most of the people are not acquainted with this Phishing.</p>
<p>This Includes the Domain and Hosting Swap, Software Programs and Programming Codes Copy, Contents Piracy.</p>
<p>Threats:</p>
<ul>
<li>Domain and Hosting Swapping: Advance Hacking method to Control over Domain or Hosting.</li>
<li>Copy the Source codes and Software and sell it as different Brand or Spread Piracy.</li>
<li>Copy the content (Text and 	multimedia) Publish in other sites to move the Web Traffic and Rank High on Search Engine Result Pages (SERP)</li>
</ul>
<p>Process:</p>
<ul>
<li>An email contains URL / 	Scripts, which search for the Log in details/ Account Credentials. Then 	forward the details to another Email and delete it from Outbox / Sent Mail 	Folder. In sort its like Filter Option in Gmail.</li>
<li>Ask to log in to hosting or domain 	Control Panel from Phishing/Malicious website/ Software.</li>
<li>Browser Add on/Scripts/Trojan worms/Spyware Cleaners to 	read the temp files or Cookies from Local machine.</li>
</ul>
<p>Mission:</p>
<ul>
<li>Swap the Domain and Hosting. May use 301 	or 302 Redirects or Publish Unrelated Content.</li>
<li>Rank High on SERP as competitor.</li>
<li>Divert the traffic from one site 	to other(s).</li>
<li>Add Good Ranking / High Traffic Domains to  Auctions or Bids.</li>
<li>Down the server to get loss in 	Online Business.</li>
<li>Get Money by Blackmailing.</li>
<li>Claiming the Original Author of Scripts/Software/Content.</li>
<li>Sells the Scripts/Software with 	other Brands.</li>
</ul>
<p>Remedy:</p>
<ul>
<li>Check WHO IS of Domain<a href="http://www.copyscape.com/"></a>.</li>
<li>Check the Server Log Details.</li>
<li>Check the <a href="http://www.ip2location.com/">Geographical IP Location</a>.</li>
<li>Consult with the Domain or Hosting Provider.</li>
<li>Consult the <a href="http://www.wipo.int/about-wipo/en/">World 	Intellectual Property Organization (WIPO)</a>.</li>
<li>Check for <a href="http://www.copyscape.com/">Content Piracy</a>.</li>
<li>If you have Copyright then Lodge Complain <a href="http://www.copyright.gov/">Copyright US Govt.</a> or <a href="http://www.copyright.gov.in/">Copyright Indian Govt</a>.</li>
<li>Discuss at <a href="http://www.webmasterworld.com/">Webmaster World</a>.</li>
</ul>
<p>Precautions:</p>
<ul>
<li>Change the Log in/ Account details regularly.</li>
<li>Use strong password (case sensitive characters, symbols 	and numbers.)</li>
<li>Avoid the OpenId Log in, as it is most vulnerable to Phishing.</li>
<li>Never use Untrusted password 	manager to manage your passwords.</li>
<li><a href="https://pip.verisignlabs.com/">VeriSign Personal Identity Portal</a> is a secure password manager with browser recognition feature.</li>
<li>Copyright your Important Contents/Codes/Scripts/Logo.</li>
<li>Check for <a href="http://www.copyscape.com/">Content Piracy</a>.</li>
<li>Encrypt the Source Codes/Scripts.</li>
<li>Copying source code may not be good, but it is much much easier than code it. <a href="http://articles.techrepublic.com.com/5100-10878_11-5111586.html">Secure your valuable Applications.</a></li>
<li>Never proceed to Transacts on Expired/Invalid Security Certificate Web Sites.</li>
</ul>
<p><strong>Modern Browser&#8217;s Behavior to Phishing/Malicious Web Site.</strong></p>
<p>Modern Browsers except the Internet Explorer, Safari and Opera are stay neutral where FireFox and Google Chrome React Strongly.</p>
<p>Some Screenshots are here:</p>
<p>Internet Explorer 7:</p>
<p style="text-align: center;"><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2008/11/ie7.png"><img class="size-medium wp-image-301" title="Internet Explorer 7" src="http://www.webdevelopmentbits.com/wp-content/uploads/2008/11/ie7-300x200.png" alt="" width="300" height="200" /></a></p>
<p>Internet Explorer 8:</p>
<p style="text-align: center;"><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2008/11/ie8.png"><img class="size-medium wp-image-301" title="Internet Explorer 8" src="http://www.webdevelopmentbits.com/wp-content/uploads/2008/11/ie8-300x200.png" alt="" width="300" height="200" /></a></p>
<p>Safari 3:</p>
<p style="text-align: center;"><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2008/11/safari.png"><img class="size-medium wp-image-305" title="safari" src="http://www.webdevelopmentbits.com/wp-content/uploads/2008/11/safari-300x200.png" alt="" width="300" height="200" /></a></p>
<p>Opera 9.6:</p>
<p style="text-align: center;"><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2008/11/opera.png"><img class="size-medium wp-image-301" title="Opera 9.6" src="http://www.webdevelopmentbits.com/wp-content/uploads/2008/11/opera-300x200.png" alt="" width="300" height="200" /></a></p>
<p>FireFox 3:</p>
<p style="text-align: center;"><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2008/11/ff.png"><img class="size-medium wp-image-301" title="FireFox 3" src="http://www.webdevelopmentbits.com/wp-content/uploads/2008/11/ff-300x200.png" alt="" width="300" height="200" /></a></p>
<p>Google Chrome:</p>
<p style="text-align: center;"><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2008/11/chrome.png"><img class="size-medium wp-image-301" title="Google Chrome" src="http://www.webdevelopmentbits.com/wp-content/uploads/2008/11/chrome-300x200.png" alt="" width="300" height="200" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/phishing-net/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing with MouseEvent in Flex 3</title>
		<link>http://www.webdevelopmentbits.com/playing-with-mouseevent-in-flex-3</link>
		<comments>http://www.webdevelopmentbits.com/playing-with-mouseevent-in-flex-3#comments</comments>
		<pubDate>Wed, 12 Nov 2008 04:58:12 +0000</pubDate>
		<dc:creator>Amar Shukla</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[AS3 MouseEvent]]></category>
		<category><![CDATA[flex 3]]></category>
		<category><![CDATA[flex 3 tricks]]></category>
		<category><![CDATA[Flex 3 Tutorial]]></category>
		<category><![CDATA[MouseEvent]]></category>
		<category><![CDATA[Playing with Events]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=281</guid>
		<description><![CDATA[<p>I have come across a very interesting problem while developing a flex application where I have a<br />
button control and I want to call two different functions on  click of the button . The interesting part<br />
is that&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>I have come across a very interesting problem while developing a flex application where I have a<br />
button control and I want to call two different functions on  click of the button . The interesting part<br />
is that I want to call two different functions on different events of the same button control, one at<br />
single click and other at double click .<br />
Now what to do in this case as it will always execute the function defined at single click .<br />
So what I am gonna do is to use a Timer using setInterval( ) method and use it to solve this problem.</p>
<p>The code goes here -</p>
<p><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;<br />
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"&gt;<br />
&lt;mx:Script&gt;<br />
&lt;![CDATA[<br />
import mx.controls.Alert;<br />
import flash.utils.clearInterval;<br />
private var timeGap:Number = new Number();<br />
private function doubleClick(event:MouseEvent):void {<br />
clearInterval(timeGap);<br />
//put your code here to be executed on double click<br />
Alert.show("double click");<br />
}<br />
private function singleClick(event:MouseEvent):void {<br />
clearInterval(timeGap);<br />
timeGap = setInterval(otherClick, 250);<br />
}<br />
private function otherClick():void {<br />
//put your code here to be executed on single click<br />
Alert.show("first click");<br />
clearInterval(timeGap);<br />
}<br />
]]&gt;<br />
&lt;/mx:Script&gt;<br />
&lt;mx:Button label="click" x="134" y="94"<br />
click="singleClick(event)"<br />
doubleClickEnabled="true"<br />
doubleClick="doubleClick(event)"/&gt;<br />
&lt;/mx:Application&gt;<br />
</code><br />
Now it&#8217;s the time to explain whats going on inside the code.<br />
On single click and double click events I am invoking two different Alerts to just display a message,<br />
In your case you can  write any code which is to be executed on those click events.</p>
<p>On click, inside the singleClick( ) method, we will reset &amp; initiate the timer which will call the<br />
otherClick( ) method on complete. otherClick( ) method contains actual single Click code.</p>
<p>If doubleClick is not invoked, then the  timer completes and otherClick( ) method is executed.<br />
But if doubleClick is invoked , it will call the doubleClick( ) method, where we will clear the<br />
timer  so the timer will not complete and execute the otherClick( ) method  and thus it will invoke the<br />
doubleClick( ) method.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/playing-with-mouseevent-in-flex-3/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>See, Yes! Yes! &#8211; STEADY</title>
		<link>http://www.webdevelopmentbits.com/see-yes-yes-steady</link>
		<comments>http://www.webdevelopmentbits.com/see-yes-yes-steady#comments</comments>
		<pubDate>Wed, 12 Nov 2008 04:57:58 +0000</pubDate>
		<dc:creator>Dilip Shukla</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Best Practice]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=260</guid>
		<description><![CDATA[Not every validated webpage is accessible or ideal but every invalid web page is bad. So always try to validate. First by validating from validators and then by common sense, because technically a page with thousands of nested DIVs are valid. button stimulated out of div is valid. But question is... Is it really?]]></description>
			<content:encoded><![CDATA[<p>Hello Readers,</p>
<p>Here I am with second part of 3-part CSS primer.</p>
<p>In my previous <a href="http://www.webdevelopmentbits.com/see-yes-yes-ready/">post</a>, I briefly described importance of planning and resetting CSS, some possible &#8216;Do&#8217;s and &#8216;Don&#8217;t&#8217; s. I believe in outlining thing and let your mind fly in free space. My outline for CSS primer can be visualized by connecting following dots.</p>
<p><strong>Object Oriented approach</strong>:</p>
<p>Adopting <a href="http://www.webdevelopmentbits.com/philosophy-of-object-oriented-programming-and-software-design/">object-oriented philosophy</a> is always beneficial for development&#8230;and CSS is no exception. How? I tell you. Object oriented approach in terms of CSS translates as knowing and taking advantage of parent-child relation in DOM and inheriting CSS rules, by designing CSS optimized way, less repeated and multiple times used code indicates more object oriented CSS.</p>
<p><strong>Progressive Enhancement AKA Graceful degradation</strong>:</p>
<p>There is a term <a href="http://www.alistapart.com/articles/understandingprogressiveenhancement">progressive enhancement</a>, that is &#8220;incremental addition of elements&#8221;. Which means we should categorize content and content containers, parametrized by accessibility of content, covering target audience.</p>
<p>We should first care about, any content should not be missing which our target audience must get, by keeping in mind what would be possible access terminal for navigating the web page. e.g. PC, PDA etc. It includes low configured and not up to date browsers. Afterward one can enhance page by adding CSS and Javascript cylinders.</p>
<p><strong>Categorization, flexibility and re-usability</strong>:</p>
<p>By thinking this way we can get mostly auto categorized content. From here we can start implementing re-usability. We can aaply <a href="http://www.alistapart.com/articles/progressiveenhancementwithcss">progressive enhancement with CSS</a> by dividing one big-fat-utf8 CSS into multiple CSS files. e.g. IE specific CSS and print CSS and also CSS responsible for particulars like color and typography css.<strong></strong></p>
<p>If project demands we can keep &#8216;themes&#8217; too in mind. <a href="http://www.csszengarden.com/">CSSZenGarden</a> is extreme example of this. To implement this we should deeply think about DOM structure, basic skeleton X/HTML and naming of class/ids. naming of class/id should be content dependent, not on how its going to render or where its going to positioned.</p>
<p>Always try to minimize the unnecessary  tags. e.g. wrapping everything in a div or adding extra wrappers for display purpose only. I suggest to add extra divs to stylize things by Javascript in run time, e.g. rounded corners, or multiple background images, or its not always required to wrap ul and set of inks or img tags into any box level container like div&#8230;since CSS rules can be applied on any X/HTML element.</p>
<p>Use multiple class and loosely coupled classes massively.  Multiple classes help to increase re-usability.</p>
<p><strong>example:</strong><br />
<code>&lt;span class="block fs20"&gt;Multiple class&lt;/span&gt;</code></p>
<p>use of &#8216;!important&#8217; keyword is very useful in case of using multiple class, where we might need to override few css rules. but &#8216;!important&#8217; should be used carefully. Personally I prefer to use &#8216;!important&#8217; with loosely coupled classes declared against inherited property.<br />
e.g.: following will always work disregarding its position in CSS file against inherited bold property of font.</p>
<p><code>font-weight:normal !important;</code></p>
<p><strong>Code Management:</strong></p>
<p>Organize your code in properly commented grouped sections&#8230;e.g. header, body, navigation, footer etc.</p>
<p>here we know the importance of neutral class names. If naming of CSS classes will be accoring common template not according page wise us its easy to group related CSS.</p>
<p><strong>example:</strong></p>
<p>What if we name common right panel of web page &#8216;homecol&#8217; without thinking too much? either we have to rename it on every page its appearing and duplicating same css to render it identicaly, or we have to use &#8216;homecol&#8217; even in contact page.</p>
<p><strong>After all&#8230;</strong></p>
<p>Always try to understand any rendering issue, before throwing some random code to increase vertical length of your CSS file. Every browser supports CSS (If I am not wrong 90% identically) if application of CSS is pure and CSS rules are plugged in right socket. So think twice before re-searching on Google for some hacks to override something which might fill dirt on your accessible web page. Ya of course there are many of known bugs (e.g. IE6 PNG) but id doesn&#8217;t mean every issue, you are facing is a bug and you can&#8217;t overcome them until import some hack from Venus.</p>
<p>The last word before I end this second post from 3 part series on CSS, I want to say is&#8230;</p>
<p>Not every validated web page is accessible or ideal but every invalid web page is bad. So always try to validate. First by validating from validators and then by common sense, because technically a page with thousands of nested DIVs are valid. button stimulated out of div is valid. But question is&#8230; Is it really?</p>
<p>Think on it, till I am cooking third post <a href="http://www.webdevelopmentbits.com/see-yes-yes-go/">CSS Go</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/see-yes-yes-steady/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SingleTon Pattern in Flex</title>
		<link>http://www.webdevelopmentbits.com/singleton-pattern-in-flex</link>
		<comments>http://www.webdevelopmentbits.com/singleton-pattern-in-flex#comments</comments>
		<pubDate>Tue, 04 Nov 2008 14:11:44 +0000</pubDate>
		<dc:creator>Ponbharathi Bakthaduruvan</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Singleton Pattern]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=236</guid>
		<description><![CDATA[<p><strong>What is singleton pattern?</strong></p>
<p><strong></strong></p>
<p>The singleton pattern is a design pattern that is used to restrict instantiation of a class to one object. If you create the class as a singleton then no way to create more than one&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p><strong>What is singleton pattern?</strong></p>
<p><strong></strong></p>
<p>The singleton pattern is a design pattern that is used to restrict instantiation of a class to one object. If you create the class as a singleton then no way to create more than one instance. But, you can get that single instance in any number of classes. So all the classes will share the same properties and behaviours of that singleton object.</p>
<p><strong>How to implement the singleton pattern?</strong></p>
<p>Implementation of a singleton pattern must satisfy the single instance and global access principles. It requires a mechanism to access the singleton class member without creating a class object and a mechanism to persist the value of class members among class objects. The singleton pattern is implemented by creating a class with a method that creates a new instance of the class if one does not exist. If an instance already exists, it simply returns a reference to that object. To make sure that the object cannot be instantiated any other way, the constructor is made protected (not private, because reuse and unit test could need to access the constructor). Note the distinction between a simple static instance of a class and a singleton: although a singleton can be implemented as a static instance, it can also be lazily constructed, requiring no memory or resources until needed. Another notable difference is that static member classes cannot implement an interface, unless that interface is simply a marker. So if the class has to realize a contract expressed by an interface, it really has to be a singleton.</p>
<p>The singleton pattern must be carefully constructed in multi-threaded applications. If two threads are to execute the creation method at the same time when a singleton does not yet exist, they both must check for an instance of the singleton and then only one should create the new one. If the programming language has concurrent processing capabilities the method should be constructed to execute as a mutually exclusive operation.<br />
The classic solution to this problem is to use mutual exclusion on the class that indicates that the object is being instantiated.</p>
<p><strong>How to implement the singleton pattern in Flex and ActionScript?</strong></p>
<ul>
<li> Can we implement the singleton pattern in ActionScript? Why not? Ofcource we can.</li>
</ul>
<ul>
<li> Is there any keyword named as singleton in Flex?. No.</li>
</ul>
<ul>
<li> Can we declare the constructor as protected in Flex?. No. (ActionScript 3.0 will not support protected constructors)</li>
</ul>
<ul>
<li> Can we declare the constructor as private in Flex?. No. (ActionScript 3.0 will not support private constructors)</li>
</ul>
<ul>
<li> Then how can we implement the singleton pattern in Flex ? See the next line.</li>
</ul>
<p><strong>Steps to  implement the singleton pattern in Flex and ActionScript</strong></p>
<p>Consider the <strong>MySingleTon </strong>class as a singleton class.</p>
<pre>package {
	public class MySingleTon {   

    	// Single Instance of Our MySingleTon
		private static var instance:MySingleTon;

	    //DEFINE YOUR VARIABLES HERE
	    public function MySingleTon (enforcer:SingletonEnforcer)
	    {
	    	if (enforcer == null)
	    	{
                      throw new Error( "You Can Only Have One MySingleTon" );
			}
		}

		// Returns the Single Instance
		public static function getInstance() : MySingleTon
		{
			if (instance == null)
			{
				instance = new MySingleTon ( new SingletonEnforcer );
			}
			return instance;
		}
	}
}

// Utility Class to Deny Access to Constructor
class SingletonEnforcer {}

1). We should create one static variable. It will be called "instance" and it will be of type MySingleTon. This will be the variable where we will store our
one instance of our class.

2). Then we should create one constructor. The constructor takes one argument - "enforcer". You will notice that this "enforcer" has a type of "SingletonEnforcer"
which is defined directly after our class. Here is the logic behind that:</pre>
<ul>
<li>When you put a class in an Actionscript file below the main class, it is only available to that class.</li>
</ul>
<ul>
<li>If the constructor requires this argument &#8211; then only our main class can create an instance of itself, because we do not have access to the &#8220;SingletonEnforcer&#8221; class. Only the main class has this access.</li>
</ul>
<ul>
<li>We will not access our class in the normal way by using the &#8220;new&#8221; statement because we can&#8217;t call the constructor. Once we get inside of the constructor, we have a few lines that make sure things work as planned. The &#8220;if&#8221; statement ensures that we had a valid &#8220;enforcer&#8221; passed in. If there wasn&#8217;t it throws an Error stating that &#8220;You Can Have Only One MySingleTon&#8221;.</li>
</ul>
<p>Then we should create one static function named as getInstance. The &#8220;getInstance&#8221; function is how we will access our MySingleTon from our application. This function simply passes back the &#8220;instance&#8221; of the class. If it doesn&#8217;t exist yet, it creates it. We can now get the MySingleTon by using the following:</p>
<p>var mySingleTone:MySingleTon = MySingleTon.getInstance();. So you can share this single object in any number of classes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/singleton-pattern-in-flex/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Modular Applications</title>
		<link>http://www.webdevelopmentbits.com/modular-applications</link>
		<comments>http://www.webdevelopmentbits.com/modular-applications#comments</comments>
		<pubDate>Tue, 04 Nov 2008 14:10:57 +0000</pubDate>
		<dc:creator>Ponbharathi Bakthaduruvan</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Flex Modules]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=220</guid>
		<description><![CDATA[<p><strong>Modular applications</strong></p>
<p>Sometimes our flex application&#8217;s size becomes very large. Due to this, we are facing many problems such as bandwidth, network traffic and it will take more time to load. We have many ways to solve this problem such&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p><strong>Modular applications</strong></p>
<p>Sometimes our flex application&#8217;s size becomes very large. Due to this, we are facing many problems such as bandwidth, network traffic and it will take more time to load. We have many ways to solve this problem such as </p>
<p>1. Do not embed the assets into the project.<br />
2. Modules.</p>
<p><strong>About Modules</strong></p>
<p>Modules are the swf files which can be loaded and unloaded dynamically by an application. The user cannot run the modules independently in the browser or the flash player. But the user can share the modules in any number of applications.</p>
<p><strong>Benifits of Modules</strong></p>
<ul>
<li>Smaller initial download size of the SWF file.</li>
<li>Shorter load time due to smaller SWF file size.</li>
<li>Better encapsulation of related aspects of an application. For example, a &#8220;reporting&#8221; feature can be separated into a module that you can then work on independently.</li>
<li>Any number of applications can share the modules.</li>
</ul>
<p><strong>Creating the Modules</strong></p>
<p>To create the modules we should create seperate mxml or actionscript class and an application that uses the modules. We can create the modules in two ways, one is by using the mxml and by using the actionscript class.</p>
<p><strong>Creating the modules by using the mxml</strong></p>
<p>An MXML-based module file&#8217;s root tag should be &lt;mx:Module&gt;. Within this tag we can create all our child containers and components.Ofcource we can have our styles and scripts also. We should compile the modules using the mxmlc command-line compiler or the compiler built into Adobe Flex Builder. The swf file will be created after we compile the modules.</p>
<pre>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- modules/MyModule.mxml --&gt;
&lt;mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="300"&gt;
	&lt;mx:Script&gt;
		&lt;![CDATA[
			import mx.collections.ArrayCollection;
	        	[Bindable]
	        	public var expenses:ArrayCollection = new ArrayCollection([
	            		{Month:"Jan", Profit:2000, Expenses:1500},
		            	{Month:"Feb", Profit:1000, Expenses:200},
		           	{Month:"Mar", Profit:1500, Expenses:500},
	        	    	{Month:"April", Profit:2000, Expenses:600},
	            		{Month:"May", Profit:2500, Expenses:700},
		            	{Month:"June", Profit:3000, Expenses:500},
		            	{Month:"July", Profit:4000, Expenses:400}
	        	]);
		]]&gt;
	&lt;/mx:Script&gt;

	&lt;mx:DataGrid dataProvider="{expenses}" &gt;
		&lt;mx:columns&gt;
			&lt;mx:DataGridColumn dataField="Month" headerText="Month" /&gt;
			&lt;mx:DataGridColumn dataField="Profit" headerText="Proft" /&gt;
			&lt;mx:DataGridColumn dataField="Expenses" headerText="Expenses" /&gt;
		&lt;/mx:columns&gt;
	&lt;/mx:DataGrid&gt;
&lt;/mx:Module&gt;</pre>
<p><strong>Creating the modules by using ActionScript</strong></p>
<p>To create a module in ActionScript, we should create a file that extends either the mx.modules.Module class or the mx.modules.ModuleBase class. Extending the Module class is the same as using the &lt;mx:Module&gt; tag in an MXML file. You should extend this class if your module interacts with the framework; this typically means that it adds objects to the display list or otherwise interacts with visible objects.</p>
<pre>package modules{
    import mx.modules.ModuleBase;

    public class ArithmaticModule extends ModuleBase {

        public function ArithmaticModule () {

        }

        public function add(a:Number, b:Number):Number {
            return a + b;
        }

	public function subtract(a:Number, b:Number):Number {
            return a - b;
        }

	public function divide(a:Number, b:Number):Number {
            return a / b;
        }

	public function multiply(a:Number, b:Number):Number {
            return a * b;
        }
    }
}</pre>
<p><strong>Loading the modules</strong></p>
<p>We can load the modules in our applications by using the &lt;mx:ModuleLoader&gt; mxml tag or mx.modules.ModuleLoader and mx.modules.ModuleManager ActionScript classes. Typically, we use one of the following techniques to load MXML-based modules:</p>
<ul>
<li><strong>ModuleLoader </strong> : The ModuleLoader class provides the highest-level API for handling modules.</li>
<li><strong>ModuleManager</strong> : The ModuleManager class provides a lower-level API for handling modules than the ModuleLoader class does.</li>
</ul>
<p><strong>Using the ModuleLoader class to load module</strong>s</p>
<p>We can use the ModuleLoader class to load module in an application or other module. The easiest way to do this in an MXML application is to use the &lt;mx:ModuleLoader&gt; tag. We set the value of the url property to point to the location of the module&#8217;s SWF file. The following example loads the module when the application first starts:</p>
<pre>&lt;?xml version="1.0"?&gt;
&lt;!-- modules/MySimplestModuleLoader.mxml --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"&gt;
    &lt;mx:ModuleLoader url="MyModule.swf"/&gt;
&lt;/mx:Application&gt;</pre>
<p>We can change when the module loads by setting the value of the url property at some other time, such as in response to an event. Setting the target URL of a ModuleLoader triggers a call to the loadModule() method. This occurs when we first create a ModuleLoader with the url property set. It also occurs if we change the value of that property. If we set the value of the url property to an empty string (&#8220;&#8221;), the ModuleLoader unloads the current module.</p>
<p><strong>Using the ModuleManager class to load modules </strong></p>
<p>You can use the ModuleManager class to load the module. This technique is less abstract than using the &lt;mx:ModuleLoader&gt; tag, but it does provide you with greater control over how and when the module is loaded. To use the ModuleManager to load a module in ActionScript, you first get a reference to the module&#8217;s IModuleInfo interface by using the ModuleManager getModule() method. You then call the interface&#8217;s load() method. Finally, you use the factory property of the interface to call the create() method and cast the return value as the module&#8217;s class.</p>
<p>The IModuleInfo class&#8217;s load() method optionally takes an ApplicationDomain and a SecurityDomain as arguments. If you do not specify either of these, then the module is loaded into a new child domain. The following example shell application loads the ColumnChartModule.swf file and then adds it to the display list so that it appears when the application starts:</p>
<pre>&lt;?xml version="1.0"?&gt;
&lt;!-- modules/ModuleLoaderApp.mxml --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initApp()"&gt;
    &lt;mx:Script&gt;
        &lt;![CDATA[
        import mx.events.ModuleEvent;
        import mx.modules.ModuleManager;
        import mx.modules.IModuleInfo;

        public var info:IModuleInfo;

        private function initApp():void {
            info = ModuleManager.getModule("MyModule.swf");
            info.addEventListener(ModuleEvent.READY, modEventHandler);           

            // Load the module into memory. Calling load() makes the
            // IFlexModuleFactory available. You can then get an
            // instance of the class using the factory's create()
            // method.
            info.load();
        }

        private function modEventHandler(e:ModuleEvent):void {
            // Add an instance of the module's class to the
            // display list.
            vb1.addChild(info.factory.create() as ColumnChartModule);
        }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:VBox id="vb1"/&gt;

&lt;/mx:Application&gt;</pre>
<p><strong><em>Note:</em></strong> MXML-based modules can load other modules. Those modules can load other modules, and so on.</p>
<p><strong>Unloading the Modules</strong></p>
<p>We can unload the modelues in two ways:</p>
<p>1. If we set the value of the url property to an empty string (&#8220;&#8221;), the ModuleLoader unloads the current module.</p>
<p>2. Calling the unloadModule() method of the ModuleLoader instance.<br />
public function removeModule(m:ModuleLoader):void {<br />
m.unloadModule();<br />
}</p>
<p><strong>Modular applications best practices</strong></p>
<p>By default, a module is loaded into a child domain of the current application domain. You can specify a different application domain by using the applicationDomain property of the ModuleLoader class. Because a module is loaded into a child domain, it owns class definitions that are not in the main application&#8217;s domain. For example, the first module to load the PopUpManager class becomes the owner of the PopUpManager class for the entire application because it registers the manager with the SingletonManager. If another module later tries to use the PopUpManager, Adobe ® Flash® Player throws an exception.</p>
<p>The solution is to ensure that managers such as PopUpManager and DragManager and any other shared services are defined by the main application (or loaded late into the shell&#8217;s application domain). When you promote one of those classes to the shell, the class can then be used by all modules. Typically, this is done by adding the following to a script block:</p>
<p>import mx.managers.PopUpManager;<br />
import mx.managers.DragManager;<br />
private var popUpManager:PopUpManager;<br />
private var dragManager:DragManager;</p>
<p>This technique also applies to components. The module that first uses the component owns that component&#8217;s class definition in its domain. As a result, if another module tries to use a component that has already been used by another module, its definition will not match the existing definition. To avoid a mismatch of component definitions, create an instance of the component in the main application. The result is that the definition of the component is owned by the main application and can be used by modules in any child domain.</p>
<p>Because a Flex module must be in the same security domain as the application (SWF) that loads it, when you&#8217;re using modules in an AIR application any module SWF must be located in the same directory as the main application SWF or one of its subdirectories, which ensures that like the main application SWF, the module SWF is in the AIR application security sandbox.</p>
<p>One way to verify this is to ensure that a relative URL for the module&#8217;s location doesn&#8217;t require &#8220;../&#8221; (&#8220;up one level&#8221;) notation to navigate outside the application directory or one of its subdirectories.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/modular-applications/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Philosophy of Object Oriented Programming and Software Design</title>
		<link>http://www.webdevelopmentbits.com/philosophy-of-object-oriented-programming-and-software-design</link>
		<comments>http://www.webdevelopmentbits.com/philosophy-of-object-oriented-programming-and-software-design#comments</comments>
		<pubDate>Sat, 01 Nov 2008 14:33:25 +0000</pubDate>
		<dc:creator>Hage Yaapa</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Object-Oriented Programming]]></category>
		<category><![CDATA[philosophy]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=241</guid>
		<description><![CDATA[Now, I am no expert in OOP or software design, but here's a philosophy which might help you make the most of what you know about OOP and software design.]]></description>
			<content:encoded><![CDATA[<p>Now, I am no expert in OOP or software design, but here&#8217;s a philosophy which might help you make the most of what you know about OOP and software design. I have observed and have read reports that people absorb most information when it&#8217;s presented in lists, preferably bulleted. So without any further ramling, I present you my bulleted philosophy of OOP and Software Design.</p>
<ul>
<li>It&#8217;s not how much and what you know; but what you can do with what you know, which&#8217;s important.</li>
</ul>
<ul>
<li>Ability to implement Polymorphism, Inheritance, private, public namespaces, static methods etc is no guarantee you are a good OO developer.</li>
</ul>
<ul>
<li>OOP is useless if you don&#8217;t use it to create good software design (architecture).</li>
</ul>
<ul>
<li>Using packages, classes, etc does not guarantee good software design.</li>
</ul>
<ul>
<li>When designing your software, think of it as an electronic device you are designing.</li>
</ul>
<ul>
<li>Sketch out the &#8216;electronic device&#8217;. Label the different components, list their functionalities.</li>
</ul>
<ul>
<li>Stay hungry, stay foolish.</li>
</ul>
<p>That&#8217;s it for today. I hope you are blessed with more knowledge, and the ability to make the best use of them.  Adios!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/philosophy-of-object-oriented-programming-and-software-design/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>PureMVC</title>
		<link>http://www.webdevelopmentbits.com/puremvc</link>
		<comments>http://www.webdevelopmentbits.com/puremvc#comments</comments>
		<pubDate>Tue, 28 Oct 2008 10:28:42 +0000</pubDate>
		<dc:creator>Ponbharathi Bakthaduruvan</dc:creator>
				<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=193</guid>
		<description><![CDATA[<p>PureMVC is a framework which helps the Flex programmers to create applications in the MVC architecture. It helps the programmers to develop loosely coupled components. It helps to create the resusable codes. Very easy to understand and maintain than other&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>PureMVC is a framework which helps the Flex programmers to create applications in the MVC architecture. It helps the programmers to develop loosely coupled components. It helps to create the resusable codes. Very easy to understand and maintain than other frameworks. Forces the singleton pattern.</p>
<p>We can divide the pureMVC as:</p>
<ul>
<li> Facade &amp; Core</li>
<li> Controller &amp; Commands</li>
<li> Model &amp; Proxies</li>
<li> View &amp; Mediators</li>
<li> Observers &amp; Notifications</li>
</ul>
<p><strong>Steps to follow in PureMVC</strong></p>
<p><strong>1</strong>. Main application should call the facade.startup(this). Here facade is the singletone instance of ApplicationFacade class.</p>
<p><strong>2</strong>. <strong>ApplicationFacade</strong></p>
<ul>
<li> Singleton class.</li>
<li> It extedns the org.puremvc.as3.patterns.facade.Facade.</li>
<li> It implements org.puremvc.as3.interfaces.IFacade .</li>
<li> Should override the initializeController() method.</li>
<li> It defines static constants for Notification names.</li>
<li> Initializes the Commands used to access and notify the Commands, Mediators and Proxies.</li>
</ul>
<p><strong>3.</strong> <strong>MacroCommand(s) </strong></p>
<ul>
<li> It extends the org.puremvc.as3.patterns.command.MacroCommand.</li>
<li> It implements the org.puremvc.as3.interfaces.ICommand.</li>
<li> Should override the initializeMacroCommand() method.</li>
<li> Executes the SimpleCommands and MacroCommands.</li>
<li> User can registerand retrieve the Mediators and Proxies.</li>
</ul>
<p><strong>4</strong>. <strong>SimpleCommand(s)</strong></p>
<ul>
<li> It extends the org.puremvc.as3.patterns.command.SimpleCommand.</li>
<li> It implements org.puremvc.as3.interfaces.ICommand.</li>
<li> Should override the execute( note:INotification ) method.</li>
<li> User can register and retrieve the Mediators and proxies.</li>
</ul>
<p><strong>5</strong>. <strong>Mediator(s)</strong></p>
<ul>
<li> It extends the org.puremvc.as3.patterns.mediator.Mediator.</li>
<li> It implements the org.puremvc.as3.interfaces.IMediator.</li>
<li> Should override the listNotificationInterests() and handleNotification( note:INotification ) methods    to listen to the notifications.</li>
<li> Registers the mediators and proxies.</li>
<li> User can retrieve the Mediators and proxies.</li>
<li> User can register the notifications.</li>
<li> Listens for the notifications from other Mediators, Proxies and commands.</li>
<li> Listens for the events from the component.</li>
<li> Sends the notifications to other mediators.</li>
</ul>
<p><strong>6. Proxy(ies)</strong></p>
<ul>
<li> It extends org.puremvc.as3.patterns.proxy.Proxy.</li>
<li> It implents the interface org.puremvc.as3.interfaces.IProxy.</li>
<li> User can send the notifications.</li>
<li> Used to access the Delegates and datas.</li>
</ul>
<p><strong>7. Component(s)</strong></p>
<ul>
<li> Views of our application.</li>
<li> Every component should have its own Mediator. One Mediator per Component.</li>
<li> Dispatches the event. So the mediator can listen for that events.</li>
</ul>
<p><strong>Observers</strong></p>
<p>PureMVC applications may run in environments without access to Flash’s Event and EventDispatcher classes, so the framework implements an Observer notification scheme for communication between the Core MVC actors and other parts of the system in a loosely-coupled way. No need to create instance for the Observers and notificatios. These are inbuilt things in the pureMVC.</p>
<p><strong>Notifications</strong><br />
PureMVC implements the Observer pattern so that the Core actors and their collaborators can communicate in a loosely-coupled way, and without platform dependency.</p>
<p>Not simply a replacement for Events, Notifications operate in a fundamentally different way, and work synergistically with Events to produce extremely reusable View Components that need not even know that they are coupled to a PureMVC system at all if engineered properly.</p>
<p>Events are dispatched from Flash display objects that implement the IEventDispatcher interface. The Event is ‘bubbled’ up the display hierarchy, allowing the parent object to handle the Event, or the parent’s parent, etc.</p>
<p>Notifications are sent by the Facade and Proxies; listened for and sent by Mediators; mapped to and sent by Commands. It is a publish/subscribe mechanism whereby many Observers may receive and act upon the same Notification.</p>
<p><strong>WorkFlow of the PureMVC framework</strong></p>
<ul>
<li> MainApplication should startup the pureMVC framework by calling the ApplicationFacade(Facade)&#8217;s startup method.</li>
<li> ApplicationFacade Registers the Commands,Mediators and Proxies.</li>
<li> User can retrieve the Mediators and Proxies in the  ApplicationFacade.</li>
<li> Two commands are there: MacroCommand and SimpleCommand.</li>
<li> MacroCommand registers other commands, Mediators and Proxies.</li>
<li> SimpleCommand registers the Mediators and Proxies.</li>
<li> Both the Macro and Simple Commands can be used to retrieve the Mediators and Proxies.</li>
<li> User can send notifications from both the Macro and Simple commands.</li>
<li> Mediators registers the component with the PureMVC.</li>
<li> Mediators will listen for the events and notifications.</li>
<li> Mediators will listen for the events dispatched from the Components.</li>
<li> Mediators will listen for the notifications sent from the other  Mediators, Proxies and Commands.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/puremvc/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>See, Yes! Yes! &#8211; READY</title>
		<link>http://www.webdevelopmentbits.com/see-yes-yes-ready</link>
		<comments>http://www.webdevelopmentbits.com/see-yes-yes-ready#comments</comments>
		<pubDate>Tue, 28 Oct 2008 10:28:08 +0000</pubDate>
		<dc:creator>Dilip Shukla</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Novice]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=184</guid>
		<description><![CDATA[<p><span>In today&#8217;s web arena, CSS has proved its importance in rigid way. Web content is no more targeted to web browsers only, Web content is been served for a verity of media now days. To efficiently handle such situation CSS</span>&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p><span>In today&#8217;s web arena, CSS has proved its importance in rigid way. Web content is no more targeted to web browsers only, Web content is been served for a verity of media now days. To efficiently handle such situation CSS plays a very crucial role.</span></p>
<p><span>In order to extract maximum pulp from CSS fruit there are few things needs to keep in mind. Although rule of thumb is efficiency is directly proportional to experience but I&#8217;ll point out few options 3-part post series <a title="See Yes! Yes! -READY" href="http://www.webdevelopmentbits.com/see-yes-yes-ready/">See, Yes! Yes! &#8211; READY</a>,  <a href="http://www.webdevelopmentbits.com/see-yes-yes-steady/">See, Yes! Yes! &#8211; STEADY</a> and </span><a href="http://www.webdevelopmentbits.com/see-yes-yes-go/"><span>See, Yes! Yes! &#8211; GO</span></a>.<span> which can help novice CSS developers to take right diversions. </span></p>
<p><span>All of following points are optional and one can modify them according to needs and/or simply drop the idea.</span></p>
<h3>Big Picture:</h3>
<p>Planning is a must for mid or big projects&#8230;for small projects one can instantly start coding.</p>
<p>While coding for new design, web designer must analyze the design mock-up and slice the design by keeping in mind the facts which are resultant of observation and guideline of website/blog/web application.</p>
<p><strong>e.g.</strong></p>
<ul>
<li>What portion of design mock can be translated by using CSS rules instead of image?</li>
<li>Whether background is repeating? Design is fixed width or liquid?</li>
<li>What element of design is going to change dimension dynamically?</li>
<li>Re-usability issues needs to be addressed so back-end developer (if any) don&#8217;t face any difficulty to plug reusable components.</li>
<li>Sliced images need to save as optimized for  web, as PNG if element is using alpha transparency and if it uses square shape without tranparency JPG images work better in most cases.</li>
</ul>
<h3>CSS Reset:</h3>
<p>Purpose of using <a title="CSS Reset" href="http://perishablepress.com/press/2007/10/23/a-killer-collection-of-global-css-reset-styles/">CSS Reset</a> is to neutralize default rendering of browser, in order to equalize rendering of web page across different browsers.</p>
<p>Its entirly optional for web developers whether to use one or not. Even if Web Designer is very keen to use one, s/he must consider the big picture where the CSS is going to be used (including some future prediction).</p>
<p>In few cases i prefer not to use CSS reset as in Blogs where content is generated by user and web designer don&#8217;t have exact control over X/HTML tags.<br />
Following is my reset.css. I have cooked this starter dish by borrowing some spices from <a id="yla6" title="here" href="http://perishablepress.com/press/2007/10/23/a-killer-collection-of-global-css-reset-styles/">here</a> and few from experience.</p>
<p><code>/* Common CSS and CSS reset Start */<br />
html, body, div, span, applet, object, iframe, table, caption, tbody, tfoot, thead, tr, th, td,<br />
del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var,<br />
h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code,<br />
dl, dt, dd, ol, ul, li, fieldset, form, label, legend {<br />
vertical-align: baseline;<br />
font-family: inherit;<br />
font-weight: inherit;<br />
font-style: inherit;<br />
font-size: 100%;<br />
outline: 0;<br />
padding: 0;<br />
margin: 0;<br />
border: 0;<br />
}<br />
/* remember to define focus styles! */<br />
:focus {<br />
outline: 0;<br />
}<br />
/*links*/<br />
a{<br />
text-decoration:none;<br />
}<br />
a:hover{<br />
text-decoration:none;<br />
}<br />
/*List*/<br />
ol, ul {<br />
list-style: none;<br />
}<br />
/* tables still need cellspacing="0" in the markup */<br />
table {<br />
border-collapse: separate;<br />
border-spacing: 0;<br />
}<br />
caption, th, td {<br />
font-weight: normal;<br />
text-align: left;<br />
}<br />
/* Common Display Rules*/<br />
.block{<br />
display:block;<br />
}<br />
.none{<br />
display:none;<br />
}<br />
.inline{<br />
display:inline;<br />
}<br />
.clear{<br />
clear:both;<br />
}<br />
.relative{<br />
position:relative;<br />
}<br />
.absolute{<br />
position:absolute;<br />
}<br />
.floatleft{<br />
float:left;<br />
}<br />
.floatright{<br />
float:right;<br />
}<br />
.center_div{<br />
margin:0 auto;<br />
}<br />
.bold{<br />
font-weight:700;<br />
}<br />
.normal{<br />
font-weight:normal !important;<br />
}<br />
.underline, .underline:hover{<br />
text-decoration:underline;<br />
}<br />
/* Headings*/<br />
h1, h2, h3, h4, h5, h6{<br />
font-family:Arial, HelveticaNeue, Helvetica, sans-serif;<br />
font-weight:700;<br />
}<br />
h1{<br />
font-size:18px;<br />
}<br />
h2{<br />
font-size:17px;<br />
}<br />
h3{<br />
font-size:16px;<br />
}<br />
h4{<br />
font-size:14px;<br />
}<br />
h5{<br />
font-size:15px;<br />
}<br />
h6{<br />
font-size:13px;<br />
}<br />
/* Font Size */<br />
.fs8{<br />
font-size:8px;<br />
}<br />
.fs9{<br />
font-size:9px;<br />
}<br />
.fs10{<br />
font-size:10px;<br />
}<br />
.fs11{<br />
font-size:11px;<br />
}<br />
.fs12{<br />
font-size:12px;<br />
}<br />
.fs13{<br />
font-size:13px;<br />
}<br />
.fs14{<br />
font-size:14px;<br />
}<br />
.fs15{<br />
font-size:15px;<br />
}<br />
.fs16{<br />
font-size:16px;<br />
}<br />
.fs17{<br />
font-size:17px;<br />
}<br />
.fs18{<br />
font-size:18px;<br />
}<br />
.fs19{<br />
font-size:19px;<br />
}<br />
.fs20{<br />
font-size:20px;<br />
}<br />
.fs21{<br />
font-size:21px;<br />
}<br />
.fs22{<br />
font-size:22px;<br />
}<br />
.fs23{<br />
font-size:23px;<br />
}<br />
.fs24{<br />
font-size:24px;<br />
}<br />
.fs25{<br />
font-size:25px;<br />
}<br />
.fs26{<br />
font-size:26px;<br />
}<br />
.fs27{<br />
font-size:27px;<br />
}<br />
.fs28{<br />
font-size:28px;<br />
}<br />
.fs29{<br />
font-size:29px;<br />
}<br />
.fs30{<br />
font-size:30px;<br />
}<br />
/* Remove Inherited Style*/<br />
.no_margin{<br />
margin:0 !important;<br />
}<br />
.no_padding{<br />
padding:0 !important;<br />
}<br />
.no_border{<br />
border:none !important;<br />
}<br />
.no_dec{<br />
text-decoration:none !important;<br />
}<br />
/* Common CSS and CSS reset End */</code></p>
<p>Hmm&#8230;I think its a good breakfast.</p>
<p>So guys allow me to take a break&#8230;I&#8217;ll be digging further into CSS mine very soon on my next post <a href="http://www.webdevelopmentbits.com/see-yes-yes-steady/">See, Yes! Yes! &#8211; STEADY</a> .</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/see-yes-yes-ready/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>RIA and Flex</title>
		<link>http://www.webdevelopmentbits.com/ria-and-flex</link>
		<comments>http://www.webdevelopmentbits.com/ria-and-flex#comments</comments>
		<pubDate>Mon, 27 Oct 2008 05:57:46 +0000</pubDate>
		<dc:creator>Ponbharathi Bakthaduruvan</dc:creator>
				<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=103</guid>
		<description><![CDATA[<p><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2008/10/riaic.png"><img class="alignnone size-full wp-image-107" title="riaic" src="http://www.webdevelopmentbits.com/wp-content/uploads/2008/10/riaic.png" alt="" width="102" height="15" /></a></p>
<p style="text-align: center;"><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2008/10/ria.png"><img class="size-medium wp-image-104 aligncenter" title="ria" src="http://www.webdevelopmentbits.com/wp-content/uploads/2008/10/ria-300x300.png" alt="RIA" width="300" height="300" /></a></p>
<ul>
<li> A rich Internet application (RIA) is a Web application designed to deliver the same features and functions normally associated with deskop applications.</li>
</ul>
<ul>
<li>RIAs typically form a stateful client application with a separate</li></ul><p>&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2008/10/riaic.png"><img class="alignnone size-full wp-image-107" title="riaic" src="http://www.webdevelopmentbits.com/wp-content/uploads/2008/10/riaic.png" alt="" width="102" height="15" /></a></p>
<p style="text-align: center;"><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2008/10/ria.png"><img class="size-medium wp-image-104 aligncenter" title="ria" src="http://www.webdevelopmentbits.com/wp-content/uploads/2008/10/ria-300x300.png" alt="RIA" width="300" height="300" /></a></p>
<ul>
<li> A rich Internet application (RIA) is a Web application designed to deliver the same features and functions normally associated with deskop applications.</li>
</ul>
<ul>
<li>RIAs typically form a stateful client application with a separate services layer on the backend.</li>
</ul>
<ul>
<li>Run in a web browser, or do not require software installation</li>
</ul>
<ul>
<li>Run locally in a secure environment called a sandbox</li>
</ul>
<ul>
<li>Installation footprint is smaller &#8212; overhead for updating and distributing the application is trivial, or significantly reduced compared to a desktop or OS native application</li>
</ul>
<ul>
<li>Updates/upgrades to new versions can be automatic or transparent to the end user</li>
</ul>
<ul>
<li>Users can use the application from any computer with an internet connection</li>
</ul>
<ul>
<li>Many tools exist to allow off-line use of applications, such as Adobe AIR, Google Gears, Curl, and other technologies</li>
</ul>
<ul>
<li>Most RIA techologies allow the user experience to be consistent, regardless of what operating system the client uses.</li>
</ul>
<ul>
<li>Web-based applications are generally less prone to viral infection than running an actual executable</li>
</ul>
<p><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2008/10/flexic.png"><img class="alignnone size-medium wp-image-108" title="flexic" src="http://www.webdevelopmentbits.com/wp-content/uploads/2008/10/flexic.png" alt="" width="95" height="16" /></a></p>
<div class="mceTemp mceIEcenter">
<dl id="attachment_105" class="wp-caption aligncenter" style="width: 510px;">
<dt class="wp-caption-dt"><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2008/10/flex.png"><img class="size-full wp-image-105" title="flex" src="http://www.webdevelopmentbits.com/wp-content/uploads/2008/10/flex.png" alt="Flex" width="500" height="83" /></a></dt>
</dl>
</div>
<p style="text-align: center;"><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2008/10/flex-builder.jpg"><img class="size-medium wp-image-106 aligncenter" title="flex-builder" src="http://www.webdevelopmentbits.com/wp-content/uploads/2008/10/flex-builder-300x272.jpg" alt="Flex Builder IDE" width="300" height="272" /></a></p>
<p style="text-align: center;">
<ul>
<li>Open source framework used to develop the RIAs</li>
</ul>
<ul>
<li>Highly productive development</li>
</ul>
<ul>
<li>Created applications run across all browsers and desktops</li>
</ul>
<ul>
<li>Highly maintainable and scalable solutions</li>
</ul>
<ul>
<li>Flex is Flash based</li>
</ul>
<ul>
<li>Flex gives powerful environment for data-driven apps using Actionscript and MXML</li>
</ul>
<ul>
<li>Flex has no timeline</li>
</ul>
<ul>
<li>Flex is 100% code based solution</li>
</ul>
<ul>
<li>Flex can be used in parallel with Flash</li>
</ul>
<ul>
<li>2 languages    ▫ MXML    ▫ ActionScript 3</li>
</ul>
<ul>
<li> Flex    Builder IDE</li>
</ul>
<ul>
<li>Compilers, Debuggers and profilers</li>
</ul>
<ul>
<li>Rich Component Library</li>
</ul>
<ul>
<li>Flex Builder IDE</li>
</ul>
<ul>
<li>Wide range of communication   ▫ HTTPService    ▫ WebService   ▫ RemoteObject</li>
</ul>
<ul>
<li>Web Services Introspection &#8211; Generate code from WSDL and enables code hinting</li>
</ul>
<ul>
<li>Data Wizards &#8211; Generating both server and client code</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/ria-and-flex/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Tableless Table &#8211; Exploring the power of CSS3</title>
		<link>http://www.webdevelopmentbits.com/exploring-the-power-of-css3</link>
		<comments>http://www.webdevelopmentbits.com/exploring-the-power-of-css3#comments</comments>
		<pubDate>Mon, 27 Oct 2008 05:56:55 +0000</pubDate>
		<dc:creator>Chinmay Chiranjeeb</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Beauty of CSS]]></category>
		<category><![CDATA[CSS Table]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[Tableless table]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=138</guid>
		<description><![CDATA[<p>The recent browser versions like Firefox 3, Google Chrome, Internet Explorer 8, Opera 9.5 and Safari 3 are now coming with a great and brand new support: CSS3. Some of the new properties are introduced and here I am going&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>The recent browser versions like Firefox 3, Google Chrome, Internet Explorer 8, Opera 9.5 and Safari 3 are now coming with a great and brand new support: CSS3. Some of the new properties are introduced and here I am going to describe the <code>table</code> value for the <code>display</code> property.</p>
<p>To align data in a tabular structure we can use a common table using the HTML tags &lt;table&gt;, &lt;tr&gt;, &lt;td&gt; nonetheless we all know that by using that we are violating the latest web standards, right?But hold on for a second. I&#8217;m just going to introduce you a hot new way to code it using nothing else than div tags with the great CSS3 and the data will appear just like a table. Believe, that&#8217;s true!</p>
<p><strong>Here is an example:</strong></p>
<p><code><br />
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;<br />
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;<br />
&lt;title&gt;Some Page&lt;/title&gt;<br />
&lt;style type="text/css"&gt;<br />
.table {<br />
display: table;<br />
width:100%;<br />
}<br />
.row {<br />
display: table-row;<br />
width:100%;<br />
}<br />
.cell {<br />
display: table-cell;<br />
border: 1px solid blue;<br />
padding: 1em;<br />
width: 33%;<br />
}<br />
.element1 {<br />
background:#0099FF;<br />
}<br />
.element2 {<br />
background:#00FF99;<br />
}<br />
.element3 {<br />
background:#FFFF99;<br />
}<br />
&lt;/style&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;div class="table"&gt;<br />
&lt;div class="row"&gt;<br />
&lt;div class="cell element1"&gt;<br />
&lt;p&gt;&lt;strong&gt;Web Development &lt;/strong&gt;&lt;/p&gt;<br />
&lt;p&gt;PHP &amp;amp; MySQL&lt;br /&gt;<br />
Ruby on Rails&lt;br /&gt;<br />
ActionScript 3.0 / Flash / Flex / Adobe Integrated Runtime&lt;br /&gt;<br />
Amazon Web Services&lt;br /&gt;<br />
Zend Framework&lt;br /&gt;<br />
JavaScript / AJAX&lt;br /&gt;<br />
XHTML &amp;amp; CSS Scripting&lt;br /&gt;<br />
Content Management System&lt;/p&gt;<br />
&lt;/div&gt;<br />
&lt;div class="cell element2"&gt;</code><code>&lt;p&gt;&lt;strong&gt;Windows Development&lt;/strong&gt;&lt;/p&gt;&lt;/div&gt;<br />
&lt;div class="cell element3"&gt;&lt;p&gt;&lt;strong&gt;Mac &amp;amp; iPhone Development&lt;/strong&gt;&lt;/p&gt;&lt;/div&gt;<br />
&lt;/div&gt;<br />
&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</code></p>
<p><strong>Screen shots:</strong></p>
<p>Firefox 3</p>
<p style="text-align: center;"><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2008/10/ff.png"><img class="alignnone size-medium wp-image-165" title="Firefox3" src="http://www.webdevelopmentbits.com/wp-content/uploads/2008/10/ff-300x181.png" alt="" width="300" height="181" /></a></p>
<p>Google Chrome</p>
<p style="text-align: center;"><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2008/10/google.png"><img class="alignnone size-medium wp-image-166" title="Google Chrome" src="http://www.webdevelopmentbits.com/wp-content/uploads/2008/10/google-300x182.png" alt="" width="300" height="182" /></a></p>
<p>Internet Explorer 8</p>
<p style="text-align: center;"><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2008/10/ie8.png"><img class="alignnone size-medium wp-image-168" title="Internet Explorer 8" src="http://www.webdevelopmentbits.com/wp-content/uploads/2008/10/ie8-300x157.png" alt="" width="300" height="157" /></a></p>
<p>Opera 9.5</p>
<p style="text-align: center;"><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2008/10/opera.png"><img class="alignnone size-medium wp-image-169" title="Opera 9.5" src="http://www.webdevelopmentbits.com/wp-content/uploads/2008/10/opera-300x149.png" alt="" width="300" height="149" /></a></p>
<p>Safari 3</p>
<p style="text-align: center;"><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2008/10/safari.png"><img class="alignnone size-medium wp-image-170" title="Safari 3" src="http://www.webdevelopmentbits.com/wp-content/uploads/2008/10/safari-300x207.png" alt="" width="300" height="207" /></a></p>
<p>Internet Explorer7</p>
<p style="text-align: center;"><a href="http://www.webdevelopmentbits.com/wp-content/uploads/2008/10/ie7.png"><img class="alignnone size-medium wp-image-167" title="Internet Explorer 7" src="http://www.webdevelopmentbits.com/wp-content/uploads/2008/10/ie7-300x204.png" alt="" width="300" height="204" /></a></p>
<p><strong>Working Principle:</strong><br />
The display property specifies a range of table-related values to make elements display and behave as they were table elements.</p>
<p>The new available display values for drawing tables are:<br />
<code>table</code> to make the element behave like a table element<br />
<code>table-row</code> to make the element behave like a table row (tr) element<br />
<code>table-cell</code> to make the element behave like a table cell (td) element<br />
<code>table-row-group</code> to make the element behave like a table body row group (tbody) element<br />
<code>table-header-group</code> to make the element behave like a table header row group (thead) element<br />
<code>table-footer-group</code> to make the element behave like a table footer row group (tfoot) element<br />
<code>table-caption</code> to make the element behave like a table caption element<br />
<code>table-column</code> to make the element behave like a table column (col) element<br />
<code>table-column-group</code> to make the element behave like a table column group (colgroup) element</p>
<p>The table element in HTML is a semantic structure: it describes what data is. Therefore, you should only use the table element if the data you are marking up is tabular &#8211; for example, a table of financial information.</p>
<p>On the other hand, table value of the display property is simply an indication of how something should look in the browser &#8211; it has no semantic meaning. Using a table element for your layout tells the browser, “This data is tabular.”</p>
<p>Also we have to take care of, not to use display: table; property on a bunch of div elements when the data needs to be present in tabular format. Else simply avoid to use this property.</p>
<p><strong>The main advantages on using this new structure are:</strong></p>
<ul>
<li> Place the data in tabular manner without violating the latest web standards.</li>
<li> No need of specify the <code>cellpadding="0" cellspacing="0"</code>.</li>
<li> No need to make the <code>border="0"</code>.</li>
<li> No need to make the <code>margin</code> and <code>padding</code> 0 of table, tr, td.</li>
<li> Print the page in tabular format without wired.</li>
<li>No need to specify the <code>height</code>, as the content added it will automatically adjust the height of the row and columns with specified background.</li>
</ul>
<p><strong>As we&#8217;re not living in Wonderland, we also have some disadvantages, as follow:</strong></p>
<ul>
<li> Only latest browsers support this property.</li>
<li> Mainly IE 7, IE6 are not supporting this property. They show the data in wired manner.</li>
</ul>
<p>The solution would be to use this property only when we are going to develop a website for latest browsers and just ignoring the older versions. But as the statistics shows, most of the users still using IE6 and IE7.</p>
<p>To implement this in realistic world won’t be feasible to use CSS3’s advanced layout features for at least 4 or 5 years, once users need to upgrade themselves from the stone age of Internet to our beautiful high-tech development world.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/exploring-the-power-of-css3/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to hold a more effective code review</title>
		<link>http://www.webdevelopmentbits.com/how-to-hold-a-more-effective-code-review</link>
		<comments>http://www.webdevelopmentbits.com/how-to-hold-a-more-effective-code-review#comments</comments>
		<pubDate>Mon, 27 Oct 2008 05:55:01 +0000</pubDate>
		<dc:creator>Ramses Paiva</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[code review]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=176</guid>
		<description><![CDATA[<p>I found a very interesting article about Code Review that I&#8217;d like to share.</p>
<p>The article was written by Andrew Stellman and you can read it at Head First Labs in the address http://www.oreillynet.com/headfirst/blog/2008/09/how_to_hold_a_more_effective_c.html.</p>
<p>Enjoy!</p>
]]></description>
			<content:encoded><![CDATA[<p>I found a very interesting article about Code Review that I&#8217;d like to share.</p>
<p>The article was written by Andrew Stellman and you can read it at Head First Labs in the address http://www.oreillynet.com/headfirst/blog/2008/09/how_to_hold_a_more_effective_c.html.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/how-to-hold-a-more-effective-code-review/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache SSL &#8211; For Secure online transactions</title>
		<link>http://www.webdevelopmentbits.com/apache-ssl-for-secure-online-transactions</link>
		<comments>http://www.webdevelopmentbits.com/apache-ssl-for-secure-online-transactions#comments</comments>
		<pubDate>Fri, 24 Oct 2008 06:28:51 +0000</pubDate>
		<dc:creator>Sandeep Manne</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=129</guid>
		<description><![CDATA[<p>Hey you are planning to start a e-commerce website, then you must know about SSL without which no one will trust your website as a safe place to use their cards&#8230;</p>
<p><strong>What is SSL?</strong></p>
<p>SSL (Secure Socket Layer) is a&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Hey you are planning to start a e-commerce website, then you must know about SSL without which no one will trust your website as a safe place to use their cards&#8230;</p>
<p><strong>What is SSL?</strong></p>
<p>SSL (Secure Socket Layer) is a protocol used for secure data transfer. This is done by using private keys and certificates. A private key is used to encrypt the data which you are sending and the server can only decrypt this data with the private key available with it, A certificate is used to authentic yourself before proceeding.</p>
<p>So we need two things to make our website secure for online transactions. In this article i will explain how to generate a private key with open-ssl and apache, how to generate a certificate request from CA (Certificate Authority). How to configure your server to respond for ssl requests.</p>
<p>We use Apache 2, Debian Linux, Openssl for this article.</p>
<p>First step is to install Apache:</p>
<p>Go to console mode<br />
<code><br />
aptitude install apache2<br />
</code><br />
next install openssl to generate keys and certificates or certificate requests<br />
<code><br />
aptitude install openssl<br />
</code></p>
<p>next generate certificate request and key using openssl<br />
<code><br />
openssl req -new -nodes -keyout myserver.key -out myserver.csr<br />
</code><br />
Here you want to fill up some details like Country code, State, City, Company name, the most important thing is common name, it must be same as your website name (suppose you website is www.sourcebits.com then the common name must be sourcebits.com)</p>
<p>this will generate two files in your directory one is a private key file (myserver.key) and another one is certificate request file (myserver.csr)</p>
<p>Now you need to get a certificate from some certificate vendors most popular vendors are verisign and comodo.<br />
Comodo is providing a free trail certificate which is valid for 3 months. (<a href="http://www.instantssl.com/ssl-certificate-products/free-ssl-certificate.html">Comodo Free Trail</a>)<br />
After getting the certificates you want to enable ssl module in apache and configure it<br />
<code><br />
a2enmod ssl<br />
vi /etc/apache2/sites-available/default</code></p>
<p>&lt;VirtualHost *:443&gt;<br />
ServerName policeagenda<br />
DocumentRoot /var/www/<br />
SSLEngine On<br />
SSLCertificateFile /etc/apache2/ssl/sourcebits.cert<br />
SSLCertificateKeyFile /etc/apache2/ssl/sourcebits.key</p>
<p>&lt;Directory /&gt;<br />
Options Indexes FollowSymLinks<br />
AllowOverride All<br />
Order deny,allow<br />
Allow from all<br />
&lt;/Directory&gt;<br />
&lt;/VirtualHost&gt;</p>
<p>Then restart your server /etc/init.d/apache2 restart</p>
<p>We all know that a default http request will be sent port 80, in the same way a default https request will be forwarded to 443 so we are configuring the server for 443 port.</p>
<p>You are done now access your website with https://myserver.com</p>
<p>If you face any problems you want to check this things first</p>
<p>Whether the server is hearing port 443 or not to find this type lsof -i tcp:443</p>
<p>Next check whether your port 443 is forwarded or not. If you face any new problems other than this please post a comment and we will try to solve it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/apache-ssl-for-secure-online-transactions/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Build a personal website in just an hour&#8230;</title>
		<link>http://www.webdevelopmentbits.com/build-a-personal-website-in-just-an-hour</link>
		<comments>http://www.webdevelopmentbits.com/build-a-personal-website-in-just-an-hour#comments</comments>
		<pubDate>Fri, 24 Oct 2008 06:27:10 +0000</pubDate>
		<dc:creator>Sandeep Manne</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[domain registration]]></category>
		<category><![CDATA[Hosting]]></category>
		<category><![CDATA[personal website]]></category>
		<category><![CDATA[WYSIWYG Editors]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=37</guid>
		<description><![CDATA[<p>Are you planning to have a personal website for publishing your biography or a wedding website to share your happy moments with the world. Here is the guide to setup a personal website in just an hour&#8230;and it costs you&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Are you planning to have a personal website for publishing your biography or a wedding website to share your happy moments with the world. Here is the guide to setup a personal website in just an hour&#8230;and it costs you less than $25&#8230;</p>
<p>To start a personal website we need following things</p>
<p>1. A Domain Name (A name to represent your website like www.sourcebits.com)</p>
<p>2. A Web Hosting Space (To store your webpages online)</p>
<p>3. Templates (To create a rocking webdesign)</p>
<p>4. A WYSIWYG (<strong>W</strong>hat <strong>Y</strong>ou <strong>S</strong>ee <strong>I</strong>s <strong>W</strong>hat <strong>Y</strong>ou <strong>G</strong>et) editor (To edit your html pages)</p>
<p>So i will tell you how to get all this and how much it cost for you&#8230;</p>
<p><strong>Domain</strong>: You can get a domain from number of sellers and resellers but its better to go with a good company which is recognized and direct seller. Because we need a good and easy domain control panel to maintain it. A domain name will cost you around $10 or less depending on the seller.</p>
<p>I suggest <a href="http://www.name.com" target="_blank">name.com</a> as it is giving for around $7 per year. And you also get google apps configuration with the domains purchased here.(More on Google APPS). Another large domain seller is <a href="http://www.godaddy.com" target="_blank">goDaddy.com</a> which offers different prices for different domains. Check the offers before buying a domain there.</p>
<p>You can get the domain name registered immediately when you done the payment. you can check whether it is registered or not at who.is website.</p>
<p><strong>Hosting: </strong>Hosting is a vast topic to discuss here so we dedicated one post to choose the best hosting for your needs.</p>
<p>But for a personal website i suggest you to go for a linux hosting with cPanel control panel which is very easy to maintain. It costs you around $12 per year if you buy from <a href="http://www.3ix.org/one_dollar_web_hosting.php" target="_blank">3ix.com</a>.</p>
<p>You can also go for a free hosting providers but they are not reliable. One other alternative is Google APPS which is free.</p>
<p>Once you buy the hosting you need to change the DNS in the domain control panel to link your domain name with the space. Your hosting provider will give you the list of name servers to update in the DNS. To avoid this configuration i suggest you to buy both hosting and domain name from same company.</p>
<p><strong>Templates:</strong> A template is nothing but a definition of look and feel of your website. Choosing a good template will attract the users to your website. you can find free templates and premium templates from internet, just choose any one of it depending upon your budget..</p>
<p>You will get some free templates if you buy hosting from 3ix. Also you can find free templates in the following websites</p>
<p>http://www.freetemplatesonline.com</p>
<p>http://templatenavigator.com/template.php</p>
<p><a href="http://www.google.com/search?q=free+personal+website+templates" target="_blank">Free personal templates</a></p>
<p>you can get a large collection of premium templates at http://www.templatemonster.com</p>
<p><strong>HTML Editor:</strong> Once you got the templates you need to customize it. Some templates need photoshop image editor to customize it but its too costly to buy photoshop so go for <a href="http://www.gimp.org/windows/">gimp</a>.</p>
<p>After you customized the templates next step is to edit the content which you are going to put in the website. This needs knowledge of HTML but don`t worry we have number of WYSIWYG editors by using this we can create web pages just like creating a word document in MS-WORD. Of course MS-WORD is also a web page designer but it is not preferred to use MS-WORD as it will insert lost of unnecessary code in your pages and don`t go for Frontpage too, it will do the same thing.</p>
<p>The Best WYSIWYG is Dream-Weaver which you need to purchase from Adobe. It costs you around $399. Which is too costly. So i prefer <a href="http://www.w3.org/Amaya/User/BinDist.html">Amaya</a></p>
<p>Design as many pages as you want and keep it in a folder&#8230;</p>
<p>Next Step is too upload the pages into your hosting space this is done by using FTP. There are number of FTP Clients one of them is core FTP. By using that you can transfer all your files into server and make your website live.</p>
<p>Now invite friends to visit your new website&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/build-a-personal-website-in-just-an-hour/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Web Hosting in Detail (Choose best hosting for your Domain)</title>
		<link>http://www.webdevelopmentbits.com/web-hosting-in-detail-choose-best-hosting-for-your-domain</link>
		<comments>http://www.webdevelopmentbits.com/web-hosting-in-detail-choose-best-hosting-for-your-domain#comments</comments>
		<pubDate>Fri, 24 Oct 2008 06:26:24 +0000</pubDate>
		<dc:creator>Sandeep Manne</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[different types of web hosting]]></category>
		<category><![CDATA[Hosting]]></category>
		<category><![CDATA[webhosting]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=57</guid>
		<description><![CDATA[<p>If you are planning to build a small personal website or big communtiy website you need a hosting account. But these two sites wont fit with a single hosting type.</p>
<p>Generally if you search for a hosting provider you will&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>If you are planning to build a small personal website or big communtiy website you need a hosting account. But these two sites wont fit with a single hosting type.</p>
<p>Generally if you search for a hosting provider you will find different plans starting from $1 per month to $100 per month or even more, single service with different prices.Then</p>
<p><strong>Which Hosting service should i buy?</strong></p>
<p>A big question for a person who is going to start a new website and the answer is also not so simple it involves lots of technical things in it to choose the best one.</p>
<p>But i dont want to confuse you with many technical things i will give a brief introduction to different factors which effect the price of the hosting.</p>
<p>There are different types of web hosting services available in market</p>
<p><strong> Shared hosting: </strong>This is most common hosting used by number of websites. In this type you will get a share a single server hardware resources with others clients. In this type the software maintaince and upgradation is maintained by the hosting provider only. You don&#8217;t have the control over the server but you have full control over your website using some control panel softwares like cPanel or Plex. There are many more factors which decide the price of your shared hosting which is explained in detailes below.</p>
<p>Usefull for Small and Medium Sites and Email domains, Can be used as backup server for your data or main server</p>
<p><strong>Virtual private server hosting: </strong>This is same like a shared hosting but acts like a Dedicated Host, you have control over the server also.</p>
<p>Usefull for<strong> </strong>Websites which needs complete control over server and its resources, To run web applications without adversely affecting other clients or not affected by other clients</p>
<p><strong>Dedicated Hosting: </strong>This is just like taking a computer for lease, you don`t share any resources with any one. This is mainly useful for large web applications with heavy traffic. This hosting server needs some person with knowledge on OS and Remote day to day maintaince of servers. It takes some time to setup also contains setup fee.</p>
<p><strong>Managed Web Hosting: </strong>This is just like a dedicated server but it also provides additional functionalities like reporting and monitoring, load balancing, security, setup, system administration and software updates. Which reduces your server maintainces charge.</p>
<p><strong>Server Co-Location: </strong> This is nothing but building your own server and placing it in the data center of a provider. This requires most efficient persons to maintain your server.</p>
<p>Any Hosting service again have different prices depending upon the following factors</p>
<p><strong>1. Hosting Space: </strong>This is the space provided for you to place your website. Normally this space ranges from 1GB or less to 1TB or more&#8230;</p>
<p>For a normal website 1GB is more than enough as we can store more thousands of pages in 1GB.</p>
<p>Sites containing more photos or videos want to go for more space. Now a days space is not so costly and it wont effect much on the final price.</p>
<p><strong>2. Contract period: </strong>Many Hosting providers will give you a option to buy for 6 months to 5 years. If you buy for more period the cost decreases. But if you are choosing the new service provider dont go for too long contracts as it may be problem if the support is not so good.</p>
<p><strong>3. OS Type: </strong>Mainly you have two OS options one is linux hosting and second one is windows hosting. As windows is not a free OS obviously a server with windows will cost little bit more than linux. For hosting .NET applications it is mandatory to go for windows hosting, Others can choose linux hosting, you dont need much technical knowledge on linux to run a website on linux as it is maintained by your service provider.</p>
<p><strong>4. Monthly Bandwidth: </strong>This is major thing which many people ignore to consider and which will add unforseen costs to your budget. . Many Service providers restrict your monthly data transfer. Some providers will charge you extra as you crossed the limit and some will block your site. Be careful before choosing this to avoid add unforeseen costs to your budget.</p>
<p>Some hosting providers will give you 10GB of space but only 30GB of monthly bandwidth which will make your web space useless</p>
<p><strong>5. Database Support: </strong>You need a database when you are going for a dynamic website with programming, if your are going with a static designer based website you just skip this.</p>
<p>Many service providers will provide MySQL database as it is free and stable. But they limit the number of allowed databases. So check with your developer with this issues.</p>
<p>If you want MSSQL or ORACLE database servers then you want spend some more dollars to get it.</p>
<p><strong>6. Sub-Domains: </strong>subdomain is a domain that is part of a larger domain. Ex: mail.google.com</p>
<p>Some providers will restrict the number of subdomains you can create but this is not a major thing to consider as most provider will provide more than 10, which is more than enough.</p>
<p>Note: Remember sub-domain is differ from addon domain addon domain will give you a chance to host different websites in a single hosting service and share the available resources.</p>
<p><strong>7. Softwares Installed: </strong>This is also a crucial thing to consider before choosing a hosting server because if you are going for a shared hosting you cant install softwares after you brought the hosting account so check once again whether all the required softwares are installed with you service provider. This may effect your cost.</p>
<p>So i think now you can choose a better hosting service provider by analysing the above factors please give comments on different hosting providers so that it is usefull for other in choosing the best hosting in no time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/web-hosting-in-detail-choose-best-hosting-for-your-domain/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yes, I&#8217;m an OOP developer! But Design Patterns?!?</title>
		<link>http://www.webdevelopmentbits.com/yes-im-an-oop-developer-but-design-patterns</link>
		<comments>http://www.webdevelopmentbits.com/yes-im-an-oop-developer-but-design-patterns#comments</comments>
		<pubDate>Wed, 22 Oct 2008 13:16:34 +0000</pubDate>
		<dc:creator>Ramses Paiva</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Design Principles]]></category>
		<category><![CDATA[Object-Oriented Programming]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=39</guid>
		<description><![CDATA[<p><em>&#8220;Well, I went pretty fine on my Object-Oriented experience. I&#8217;ve learned something about polymorphism, inheritance, encapsulation and now I really know how to extend a class! I&#8217;m ready for developing cool object-oriented applications.&#8221;</em></p>
<p>But what about the design? No, no&#8230;&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p><em>&#8220;Well, I went pretty fine on my Object-Oriented experience. I&#8217;ve learned something about polymorphism, inheritance, encapsulation and now I really know how to extend a class! I&#8217;m ready for developing cool object-oriented applications.&#8221;</em></p>
<p>But what about the design? No, no&#8230; I don&#8217;t mean that design where you place the squares and circles in their places, draw lines, beautiful backgrounds and all those kind of stuff. I&#8217;m talking about Software Design. Design in terms of objects. Which objects to use, how and when to use, how the hierarchy would look like, which object should extend which object, when to encapsulate, when not.</p>
<p>It&#8217;s very common for developers to misunderstand Object-Oriented Programming with its basis concept (abstraction, inheritance, encapsulation, polymorphism, interfaces). Only because you know how to extend a class doesn&#8217;t mean that you really understand Object-Oriented Programming. It&#8217;s quite more than this.</p>
<p>First, let&#8217;s start with Design Patterns. Design Patterns are proven reusable solutions to solve a software design problem that other developers already faced before you. It&#8217;s not a kind of pre-cooked cake, where you just need to put in your heater for some time to get it done, but a description or template for how to solve a problem that can be used in many different situations (Yeah! Now, we&#8217;re starting talking about OOP).</p>
<p>To be a great OOP developer, this is the prior thing to know: Design Patterns will take you in another level of development principles, well designed applications and the truly implementation of Object-Oriented Programming. You&#8217;ll be able to understand each property of the OOP concept and how to correctly apply it in a way to improve the quality of your application design and, consequently, of your software. More than that, you&#8217;ll be able to use most of your objects in your future projects, saving time of development.</p>
<p>Once you went through the Design Patterns and you already know all about Design Principles, it&#8217;s time to understand the needs of your customer. What?! Did You think it was just plan a good design, put objects in place and write some code?? No way! How are you going to do that if you don&#8217;t even know what your customer expects from your software? Talking about that, do you even have a customer? Here is where the Object-Oriented Analysis and Design (OOA&amp;D) comes in place! The first thing you need to start developing a software is the customer, even if the customer is yourself! The software starts with your customer&#8217;s great idea! Before getting into design and code, you need to collect their idea and try to deeply comprehend it to make it to become a great software that does exactly what your customer expects it does. To accomplish this, you need to apply some OOA&amp;D techniques.</p>
<p>Ohh! You already have a customer! So, start collecting requirements! A requirements list is one of the most important artifacts on software development. It represents all the expectation of what the software should do and all the requirements are provided by not anybody else than your customer (that person that is going to afford your hours of development). A requirement is a statement that identifies a necessary attribute, capability, characteristic, or quality of a system in order for it to have value and utility to a user <sup>[<a href="#Requirements">1</a>]</sup>.</p>
<p>With your requirements in hands, you can develop all other artifacts to develop your software, like Use Cases, Sequence Diagrams, Class Diagrams, Database Diagrams, define estimates and costs and divide the requirements in tasks to be assigned to everybody involved in the software development.</p>
<p>After having your well-designed software and your code written it&#8217;s time to test! Yes, test it before your customer does it and realizes that some functionality is not working properly (Hmm&#8230; a bug! Or a few of them??). There are some test techniques that can avoid these situations and provide reliable reports that prove that a particular functionality is working fine. One and the most known of them is the Unit Testing. Unit Testing&nbsp;is a method of testing that verifies if individual units of your source code are working properly. The most popular programming languages have Unit Testing frameworks to help you testing your software, standardized by the ANSI/IEEE Std 1008-1987 <sup>[<a href="#UnitTesting">2</a>]</sup>.</p>
<p>Now you have all this powerful knowledge in hands, you can say loud to everyone hears you: &#8220;Yes, I&#8217;m a GREAT OOP Developer!&#8221;</p>
<p>After going through the principles of OOP, Design Patterns and OOA&amp;D, you&#8217;re ready to design, develop and deliver really GREAT software and make your customers happy, providing exactly what they want at the time they want and with a budget that they can afford.</p>
<p>Very good books that can help you to acquire this knowledge are the <em>Head First</em> series <sup>[<a href="#HeadFirst">3</a>]</sup> (<em>Head First Software Development, Head First Object-Oriented Analysis &amp; Design</em> and <em>Head First Design Patterns</em>), the famous <em>Design Patterns &#8211; Elements of Reusable Object-Oriented Software</em> <sup>[<a href="#DesignPatterns">4</a>]</sup> and <em>Effective Requirements Practices</em> <sup>[<a href="#Requirements">1</a>]</sup>.</p>
<div id="Requirements" style="font-size:9px">1. Young, Ralph R. <em>Effective Requirements Practices</em>. Boston: Addison-Wesley, 2001. See also <a class="external text" title="http://www.ralphyoung.net" rel="nofollow" href="http://www.ralphyoung.net/">RalphYoung.net</a>, a website devoted to requirements-related topics.</div>
<div id="UnitTesting" style="font-size:9px">2. IEEE Standards Board, &#8220;<a href="http://iteso.mx/~pgutierrez/calidad/Estandares/IEEE%201008.pdf">IEEE Standard for Software Unit Testing: An American National Standard, ANSI/IEEE Std 1008-1987</a>&#8221; in IEEE Standards: Software Engineering, Volume Two: Process Standards; 1999 Edition; published by The Institute of Electrical and Electronics Engineers, Inc. Software Engineering Technical Committee of the IEEE Computer Society.</div>
<div id="HeadFirst" style="font-size:9px">3. <a href="http://www.headfirstlabs.com/">Head First Labs from O&#8217;Reilly Media, Inc.</a></div>
<div id="DesignPatterns" style="font-size:9px">4. Gamma, Erich; Helm, Richard; Johnson, Ralph; and Vlissides, John (or simply the Gang of Four &#8211; GoF). <em>Design Patterns &#8211; Elements of Reusable Object-Oriented Software</em>. Boston: Addison-Wesley, 1994. See also <a href="http://hillside.net/patterns/DPBook/DPBook.html">Hillside.net</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbits.com/yes-im-an-oop-developer-but-design-patterns/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>


