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

<channel>
	<title>Code With Design &#187; Web Development</title>
	<atom:link href="http://codewithdesign.com/cat/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://codewithdesign.com</link>
	<description>web application development blog by Caleb Jonasson</description>
	<lastBuildDate>Fri, 11 May 2012 12:28:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Javascript Arrays</title>
		<link>http://codewithdesign.com/2012/05/11/javascript-arrays/</link>
		<comments>http://codewithdesign.com/2012/05/11/javascript-arrays/#comments</comments>
		<pubDate>Fri, 11 May 2012 12:28:18 +0000</pubDate>
		<dc:creator>Caleb Jonasson</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[objects]]></category>

		<guid isPermaLink="false">http://codewithdesign.com/?p=623</guid>
		<description><![CDATA[TweetIntroductions An array is simply a list of variables that are the same type. An example of an array would be an array of ages containing 0, 1, 2, 3 etc. The array doesn’t have to be integers, it can be an array of strings, objects or even arrays. 1 2 3 4 5 6 [...]
Related posts:<ol>
<li><a href='http://codewithdesign.com/2012/05/09/javascript-canvas-basic-game-logic-and-movement/' rel='bookmark' title='Javascript Canvas: Basic Game Logic and Movement'>Javascript Canvas: Basic Game Logic and Movement</a></li>
<li><a href='http://codewithdesign.com/2009/10/08/javascript-hoirzontal-menu/' rel='bookmark' title='Javascript Hoirzontal Menu'>Javascript Hoirzontal Menu</a></li>
<li><a href='http://codewithdesign.com/2010/03/29/java-tutorial-about-arrays-vs-static-arrays/' rel='bookmark' title='Java: Tutorial about Arrays vs Static Arrays'>Java: Tutorial about Arrays vs Static Arrays</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div style = 'float:left; margin-right:5px;'>            <a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical" data-text="Javascript Arrays" data-via="" data-url="http://codewithdesign.com/2012/05/11/javascript-arrays/" en>Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div class="plus-one-wrap"><g:plusone size="tall" href="http://codewithdesign.com/2012/05/11/javascript-arrays/"></g:plusone></div><h2 dir="ltr">Introductions</h2>
<p>An array is simply a list of variables that are the same type. An example of an array would be an array of ages containing 0, 1, 2, 3 etc. The array doesn’t have to be integers, it can be an array of strings, objects or even arrays.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Create an array</span>
<span style="color: #003366; font-weight: bold;">var</span> ages <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span><span style="color: #CC0000;">99</span><span style="color: #339933;">,</span><span style="color: #CC0000;">54</span><span style="color: #339933;">,</span><span style="color: #CC0000;">23</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Create another array</span>
<span style="color: #003366; font-weight: bold;">var</span> names <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span>“bill”<span style="color: #339933;">,</span> “bob”<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Create a literal array</span>
<span style="color: #003366; font-weight: bold;">var</span> games <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>“minecraft”<span style="color: #339933;">,</span>”half life”<span style="color: #339933;">,</span>”freecell”<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Add values to an empty array</span>
<span style="color: #003366; font-weight: bold;">var</span> ages <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
ages<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
ages<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">;</span>
ages<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">9</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>It is important to know that the array is actually an object that contains values. Because this type is actually an object there are properties that can be called to help handle the information inside of the array.</p>
<h2 dir="ltr">Helper Functions And Properties</h2>
<p>In javascript, along with many other languages, there are functions built around arrays that will allow you, the developer, to better use them and be more efficient in your coding. The length property is one of the most commonly used properties when going through an array.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Going through the items in an array.</span>
<span style="color: #006600; font-style: italic;">// Create the array</span>
<span style="color: #003366; font-weight: bold;">var</span> ages <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span><span style="color: #CC0000;">3</span><span style="color: #339933;">,</span><span style="color: #CC0000;">5</span><span style="color: #339933;">,</span><span style="color: #CC0000;">7</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Loop through using the length property</span>
<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> x <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> x <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> ages.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> x<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">// Print out the items one by one with an alert.</span>
<span style="color: #339933;">&lt;</span>p dir<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;ltr&quot;</span><span style="color: #339933;">&gt;</span>alert<span style="color: #009900;">&#40;</span>ages<span style="color: #009900;">&#91;</span>x<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;&lt;/</span>p<span style="color: #339933;">&gt;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Array push and pop are commonly used to add items to the array without having to get the position of where the item will be added yourself.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Create an array with one item</span>
<span style="color: #003366; font-weight: bold;">var</span> names <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>“bob”<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// push an item onto the array.</span>
names.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span>“caleb”<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// the resulting array will now be the same as it would be if you created it like this.</span>
<span style="color: #003366; font-weight: bold;">var</span> names <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>“bob”<span style="color: #339933;">,</span>”caleb”<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Now we are going to pop an element off of the end of the array and return the item. This call not only returns the value but it will alter the array in memory changing the values within it.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// create a new array of names that we will play with</span>
<span style="color: #003366; font-weight: bold;">var</span> names <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>“chewbacca”<span style="color: #339933;">,</span>”yoda”<span style="color: #339933;">,</span>”skywalker”<span style="color: #339933;">,</span>”ben”<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> poppedValue <span style="color: #339933;">=</span> names.<span style="color: #660066;">pop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// As a result the names array will no longer have “ben” in it and the poppedValue will contain the string “ben”;</span></pre></td></tr></table></div>

<h2 dir="ltr">Two Dimensional Array</h2>
<p>The concept of a 2D array can seem a little intimidating at first until you realize that you need to look at the data as columns and rows. Here is an example of what a 2D array would look like.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Creating a 2D array</span>
<span style="color: #003366; font-weight: bold;">var</span> x <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
x<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
x<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>In order to access a property within the second array you will just need to fetch the value using the key.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Display the item that is in the first column of the first row.</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>x<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Another way to create an array like this is to loop through the items upon creation.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//Create the array container</span>
<span style="color: #003366; font-weight: bold;">var</span> names <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> x <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> x <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">;</span> x<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
names<span style="color: #009900;">&#91;</span>x<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// Go through the second dimension and set the values.</span>
<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> y <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> y <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">;</span> y<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">// Assign the value of the item to bob.</span>
names<span style="color: #009900;">&#91;</span>x<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>y<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> “bob”<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<img src="http://codewithdesign.com/?ak_action=api_record_view&id=623&type=feed" alt="" /><p>Related posts:<ol>
<li><a href='http://codewithdesign.com/2012/05/09/javascript-canvas-basic-game-logic-and-movement/' rel='bookmark' title='Javascript Canvas: Basic Game Logic and Movement'>Javascript Canvas: Basic Game Logic and Movement</a></li>
<li><a href='http://codewithdesign.com/2009/10/08/javascript-hoirzontal-menu/' rel='bookmark' title='Javascript Hoirzontal Menu'>Javascript Hoirzontal Menu</a></li>
<li><a href='http://codewithdesign.com/2010/03/29/java-tutorial-about-arrays-vs-static-arrays/' rel='bookmark' title='Java: Tutorial about Arrays vs Static Arrays'>Java: Tutorial about Arrays vs Static Arrays</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://codewithdesign.com/2012/05/11/javascript-arrays/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Drive API</title>
		<link>http://codewithdesign.com/2012/05/10/google-drive-api/</link>
		<comments>http://codewithdesign.com/2012/05/10/google-drive-api/#comments</comments>
		<pubDate>Thu, 10 May 2012 16:09:59 +0000</pubDate>
		<dc:creator>Caleb Jonasson</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[drive]]></category>
		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://codewithdesign.com/?p=619</guid>
		<description><![CDATA[TweetIntroduction Google Drive is out! Yes that’s right, Google’s Drive project which allows users to store content onto a Google server and pull it from any device is now available. This product offers 5GB free to google users with additional packages for extra money. This is a pretty cool thing and not just because Google [...]
Related posts:<ol>
<li><a href='http://codewithdesign.com/2011/06/29/googles-plus-1-button-integration-and-options/' rel='bookmark' title='Google&#8217;s Plus 1 Button Integration And Options'>Google&#8217;s Plus 1 Button Integration And Options</a></li>
<li><a href='http://codewithdesign.com/2012/05/01/decrease-javascript-load-times-and-increase-script-speed/' rel='bookmark' title='Decrease Javascript Load Times and Increase Script Speed'>Decrease Javascript Load Times and Increase Script Speed</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div style = 'float:left; margin-right:5px;'>            <a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical" data-text="Google Drive API" data-via="" data-url="http://codewithdesign.com/2012/05/10/google-drive-api/" en>Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div class="plus-one-wrap"><g:plusone size="tall" href="http://codewithdesign.com/2012/05/10/google-drive-api/"></g:plusone></div><h2 dir="ltr">Introduction</h2>
<p><a title="Google Drive" href="https://drive.google.com/start#home" target="_blank">Google Drive is out!</a> Yes that’s right, Google’s Drive project which allows users to store content onto a Google server and pull it from any device is now available. This product offers 5GB free to google users with additional packages for extra money.<strong><strong></strong></strong></p>
<p>This is a pretty cool thing and not just because Google is doing drop box properly but more so because they are doing drop box across the Google platforms and offering an API to those of us that are interested in developing for it.</p>
<h2 dir="ltr">My plans</h2>
<p>My plan over the next couple of days is to create a way to store server logs and general statistics for my server to the Google Drive. This will allow me to easily check on how things are going from my mobile device.</p>
<h2 dir="ltr">Google Drive API</h2>
<p>If you are interested in working with Google Drive than I suggest that you take a look at the API that Google has provided us. <a href="https://developers.google.com/drive/v1/reference/">https://developers.google.com/drive/v1/reference/</a></p>
<p>If you are going to work with the API that is available you will have to register your own app. <a href="https://developers.google.com/drive/register">https://developers.google.com/drive/register</a></p>
<h3 dir="ltr">Performance</h3>
<p>The API has some interesting features for performance. When performing an update you can receive a partial response. This response type will only return the specific fields that you ask for rather than the entire object. The API also supports a header type of gzip to allow for speedier and smaller sent and received packets of information.</p>
<p>For more information on Google Drive API performance: <a href="https://developers.google.com/drive/performance">https://developers.google.com/drive/performance</a></p>
<img src="http://codewithdesign.com/?ak_action=api_record_view&id=619&type=feed" alt="" /><p>Related posts:<ol>
<li><a href='http://codewithdesign.com/2011/06/29/googles-plus-1-button-integration-and-options/' rel='bookmark' title='Google&#8217;s Plus 1 Button Integration And Options'>Google&#8217;s Plus 1 Button Integration And Options</a></li>
<li><a href='http://codewithdesign.com/2012/05/01/decrease-javascript-load-times-and-increase-script-speed/' rel='bookmark' title='Decrease Javascript Load Times and Increase Script Speed'>Decrease Javascript Load Times and Increase Script Speed</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://codewithdesign.com/2012/05/10/google-drive-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Statistics &#8211; Simple Logging Design</title>
		<link>http://codewithdesign.com/2011/08/04/statistics-simple-logging-design/</link>
		<comments>http://codewithdesign.com/2011/08/04/statistics-simple-logging-design/#comments</comments>
		<pubDate>Fri, 05 Aug 2011 02:49:50 +0000</pubDate>
		<dc:creator>Caleb Jonasson</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[application design]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[samples]]></category>
		<category><![CDATA[statistics]]></category>

		<guid isPermaLink="false">http://codewithdesign.com/?p=574</guid>
		<description><![CDATA[TweetIntroduction This article is the first in a series focussed on Statistics, Logging and Graphing web application events and information When creating a web application it is important to keep track of everything a user does. Some people may think that this is a little over the top but the more information we can gather [...]
Related posts:<ol>
<li><a href='http://codewithdesign.com/2009/10/15/htaccess-simple-protection/' rel='bookmark' title='.htaccess Simple Protection'>.htaccess Simple Protection</a></li>
<li><a href='http://codewithdesign.com/2009/10/04/creating-a-single-page-login-%e2%80%93-design-view/' rel='bookmark' title='Creating a Single Page login – Design View'>Creating a Single Page login – Design View</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div style = 'float:left; margin-right:5px;'>            <a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical" data-text="Statistics &#8211; Simple Logging Design" data-via="" data-url="http://codewithdesign.com/2011/08/04/statistics-simple-logging-design/" en>Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div class="plus-one-wrap"><g:plusone size="tall" href="http://codewithdesign.com/2011/08/04/statistics-simple-logging-design/"></g:plusone></div><h2>Introduction</h2>
<p>This article is the first in a series focussed on Statistics, Logging and Graphing web application events and information</p>
<p>When creating a web application it is important to keep track of everything a user does. Some people may think that this is a little over the top but the more information we can gather within a web application the better. It also allows simple and easy moderation practices for those that are moderators within the application.</p>
<h2>Pre-Planning</h2>
<p>This is by far the most important stage in development. During this stage you are going to need to create proper data structures that in theory will not have to be change (although this is extremely rare.) This means that you are going to create the general database that will handle most of the current up to date information and another section that will be used for logging.</p>
<p>Within the main database we are going to have simple things like a user table, a user settings table, a user profile table and a user information table. On tables that hold general information it is important to add a time stamp column that holds the value of last modified. The user should have a column that tells us when the users profile was created. These values aren’t going to really help us when gathering information for a single user simply because the sample of data that we can compare it to is so small. Fortunately these simple values are excellent when we need to pull up values quickly in our system to display user information.</p>
<h2>Single User Sample</h2>
<p>The logging database is going to help us create a large sample of a single user. This is where we are going to constantly insert information and never delete or modify the records. In one of these tables we can store required values that will tell us when a user has had one of their comments deleted by a moderator. Within this table we are going to log the moderator’s id, the user’s id, the time stamp that this action was performed on. and a numeric value that reflects on the reason that the comment was removed. With this data we can then count the comments that are still alive and well and count the comments that were deleted. With this information we can divide the comments that are still alive and well by the comments that were deleted thus giving us a ratio that we can work with.</p>
<p><strong>Note:</strong> It is a good idea to keep track of numbers like this as well and when the ratio was calculated. This will allow us to track user behaviour.</p>
<h2>Multiple User Sample</h2>
<p>Given that we could have a ratio of how well the user follows rules when it comes to commenting on things and taking part in discussion we filter out the users that are not contributing to the community/application. We can also sort users by this ratio and from there bury into their statistics, activities and logs.</p>
<p>Because we have logged all of the individual comments from this user we can closely examine the user interactions by graphing comments, removed comment, comments removed for x</p>
<img src="http://codewithdesign.com/?ak_action=api_record_view&id=574&type=feed" alt="" /><p>Related posts:<ol>
<li><a href='http://codewithdesign.com/2009/10/15/htaccess-simple-protection/' rel='bookmark' title='.htaccess Simple Protection'>.htaccess Simple Protection</a></li>
<li><a href='http://codewithdesign.com/2009/10/04/creating-a-single-page-login-%e2%80%93-design-view/' rel='bookmark' title='Creating a Single Page login – Design View'>Creating a Single Page login – Design View</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://codewithdesign.com/2011/08/04/statistics-simple-logging-design/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Password Recovery {Theory}</title>
		<link>http://codewithdesign.com/2011/07/02/password-recovery-theory/</link>
		<comments>http://codewithdesign.com/2011/07/02/password-recovery-theory/#comments</comments>
		<pubDate>Sun, 03 Jul 2011 04:02:16 +0000</pubDate>
		<dc:creator>Caleb Jonasson</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[password recovery]]></category>
		<category><![CDATA[password reset]]></category>
		<category><![CDATA[theory]]></category>

		<guid isPermaLink="false">http://codewithdesign.com/?p=567</guid>
		<description><![CDATA[TweetPassword Recovery is a must have in any web application and you as a software engineer need to make sure that you handle this process properly. There are two methods that I like to use but in this article I will only be using one of them. Before you start programming it is a good [...]
Related posts:<ol>
<li><a href='http://codewithdesign.com/2011/05/30/redundant-data-class-in-php-theory/' rel='bookmark' title='Redundant Data Class in PHP {Theory}'>Redundant Data Class in PHP {Theory}</a></li>
<li><a href='http://codewithdesign.com/2011/04/12/password-protecting-your-directory-with-htaccess-htpasswd/' rel='bookmark' title='Password Protecting Your Directory With .htaccess &amp; .htpasswd'>Password Protecting Your Directory With .htaccess &#038; .htpasswd</a></li>
<li><a href='http://codewithdesign.com/2010/09/24/check-email-function-php/' rel='bookmark' title='Check Email Function PHP'>Check Email Function PHP</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div style = 'float:left; margin-right:5px;'>            <a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical" data-text="Password Recovery {Theory}" data-via="" data-url="http://codewithdesign.com/2011/07/02/password-recovery-theory/" en>Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div class="plus-one-wrap"><g:plusone size="tall" href="http://codewithdesign.com/2011/07/02/password-recovery-theory/"></g:plusone></div><p>Password Recovery is a must have in any web application and you as a software engineer need to make sure that you handle this process properly. There are two methods that I like to use but in this article I will only be using one of them. Before you start programming it is a good idea to go through some of the larger web applications to see what they are doing. You may want to modify your process.</p>
<p>Before we begin I should probably make sure that you know just what you are in for before trying this. You are going to need to have knowledge of a server side language, the ability to send mail on your server, store Cookies and Sessions, along with having a running database with access to user emails as a unique field in the database.</p>
<h2>Stage 1</h2>
<p>The password recovery system is going to first require the user to input their email and submit it for checking. On this processing step we will do the following.<br />
1. Check that the email follows proper formatting and there are no bad characters.<br />
2. Check the email against the database to make sure that the user does exist and they have an active account.<br />
3. Check the password recovery table to make sure that the user has not had their password reset in the last 15 minutes.</p>
<p>Now that we have checked and bypassed anything that will put a large hold on the password recovery process we can move on to actually storing the information and content that is required to reset the users password.</p>
<p>Because we are going to be resetting the users password we need to make sure that the user supplied us with a proper email. Even if they did not we are going to show a success screen saying that an email has been sent. This way a bot that is entering in randomness to get emails will not be able to find them this way since everything will return true.</p>
<p>Note: Brute Force should be check for on all forum submissions and thus a lock out system should be added but that is a whole other article.</p>
<p>We now need to generate the items that are going to be stored. Because we will be storing information in a cookie and inside of a session. I know guys that store two keys but I just store a time stamp in the database, break it up into segments, add alpahnumeric characters and hash the information. This way I can keep a time stamp in the database and keep the information secretly stored in a session specific to the user.</p>
<p>Note: When storing time only use the generating function once and store the value into a variable so we have the same time when committing to the database.</p>
<p>Now that we have the information set into the appropriate variables we can store the information via insert to a table that holds the user id, key and time stamp. This way we can track our two keys and a time stamp of when they tried to reset their password. If we wish to lock the user out of the system for a certain amount of time we can simply change the key to null and check for this. If the (current time &#8211; date stored) < (15 * 60) and there is no key then we can just display an error message.</p>
<p>When everything is properly stored into the database we can send the user an email. This email will contain a link to the password recovery page along with a key which will be the one saved in the cookie. This way we can pass two keys back and know that the only way for this user to be the wrong user is if they have the email account as well.</p>
<h2>Stage 2</h2>
<p>This page is going to check for a key that is alphanumeric and of a certain length. With this key we are going to check to make sure it is the same as the cookie and that it is in the database. If the user is in the database we can pull the rest of the information including their email from the other table to make sure that we are able to regenerate one of their keys assuming that we used it.</p>
<p>Finally we need to make sure that the generated key matches the one that is stored inside of the session and the date is within the allotted time. From here we need to first delete the record in the database, generate a random password, hash it and store it into the system, and send them a copy of this new password via email.</p>
<p>During this last portion you need to handle the case that the page was accessed with improper values or missing values. eg: if the user does not have the cookie set or the time is out of range we need to handle the case and remove the key from the database so we know that that user won&#8217;t be able to try and reset their password for another 15 minutes. You can also bump up the time that is stored in the database depending on what was missing in case of a bad attempt which will allow you to easily lock a user out.</p>
<img src="http://codewithdesign.com/?ak_action=api_record_view&id=567&type=feed" alt="" /><p>Related posts:<ol>
<li><a href='http://codewithdesign.com/2011/05/30/redundant-data-class-in-php-theory/' rel='bookmark' title='Redundant Data Class in PHP {Theory}'>Redundant Data Class in PHP {Theory}</a></li>
<li><a href='http://codewithdesign.com/2011/04/12/password-protecting-your-directory-with-htaccess-htpasswd/' rel='bookmark' title='Password Protecting Your Directory With .htaccess &amp; .htpasswd'>Password Protecting Your Directory With .htaccess &#038; .htpasswd</a></li>
<li><a href='http://codewithdesign.com/2010/09/24/check-email-function-php/' rel='bookmark' title='Check Email Function PHP'>Check Email Function PHP</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://codewithdesign.com/2011/07/02/password-recovery-theory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google&#8217;s Plus 1 Button Integration And Options</title>
		<link>http://codewithdesign.com/2011/06/29/googles-plus-1-button-integration-and-options/</link>
		<comments>http://codewithdesign.com/2011/06/29/googles-plus-1-button-integration-and-options/#comments</comments>
		<pubDate>Thu, 30 Jun 2011 06:15:47 +0000</pubDate>
		<dc:creator>Caleb Jonasson</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Plus 1]]></category>
		<category><![CDATA[Plus One]]></category>

		<guid isPermaLink="false">http://codewithdesign.com/?p=562</guid>
		<description><![CDATA[TweetGoogle has recently changed it&#8217;s theme, search method, oh and it has created a social networking site that will rival that of Facebook. The software giant has also rolled out the +1 button (plus 1 button) which is in direct competition with the Facebook like button. The plus 1 button has not only already been [...]
Related posts:<ol>
<li><a href='http://codewithdesign.com/2010/09/23/adding-the-like-button-to-wordpress/' rel='bookmark' title='Adding The &#8216;Like&#8217; Button to WordPress'>Adding The &#8216;Like&#8217; Button to WordPress</a></li>
<li><a href='http://codewithdesign.com/2009/12/30/creating-a-top-button/' rel='bookmark' title='Creating a top button'>Creating a top button</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div style = 'float:left; margin-right:5px;'>            <a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical" data-text="Google&#8217;s Plus 1 Button Integration And Options" data-via="" data-url="http://codewithdesign.com/2011/06/29/googles-plus-1-button-integration-and-options/" en>Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div class="plus-one-wrap"><g:plusone size="tall" href="http://codewithdesign.com/2011/06/29/googles-plus-1-button-integration-and-options/"></g:plusone></div><p>Google has recently changed it&#8217;s theme, search method, oh and it has created a social networking site that will rival that of Facebook. The software giant has also rolled out the +1 button (plus 1 button) which is in direct competition with the Facebook like button. The plus 1 button has not only already been integrated into a lot of personal sites and blogs but it has been put into Google&#8217;s search results which is going to change the way we find content on the web and how this content is shared with friends, family and co-workers.</p>
<h2>The Plus 1 Button Code</h2>
<p>The button is also just as simple as the Facebook option when it comes to developer integration. The button only requires two lines of code, one in the header or body and the other where you would like the button to be placed.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot; src=&quot;http://apis.google.com/js/plusone.js&quot;&gt;&lt;/script&gt;
&lt;g:plusone&gt;&lt;/g:plusone&gt;</pre></td></tr></table></div>

<h2>Plus 1 Button Size Options</h2>
<p>There some options as far as customization of the button goes. The first thing to take into consideration is the size and how it will appear. You can choose between small(height: 15px), medium(height: 20px), tall(height: 60px) and leaving it blank. If you leave it blank it will appear to look the same as the medium option but it will be 24px rather than the 20px that medium is.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;!-- example of a small plus 1 button --&gt;
&lt;g:plusone size=&quot;small&quot;&gt;&lt;/g:plusone&gt;</pre></td></tr></table></div>

<h2>Force A URL Through The Plus 1 Button</h2>
<p>You can also force a URL into the button that the plus one will be applied to. This is simply done with an href tag and then the url.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;!-- example of fixed url being set --&gt;
&lt;g:plusone href=&quot;http://codewithdesign.com&quot;&gt;&lt;/g:plusone&gt;</pre></td></tr></table></div>

<img src="http://codewithdesign.com/?ak_action=api_record_view&id=562&type=feed" alt="" /><p>Related posts:<ol>
<li><a href='http://codewithdesign.com/2010/09/23/adding-the-like-button-to-wordpress/' rel='bookmark' title='Adding The &#8216;Like&#8217; Button to WordPress'>Adding The &#8216;Like&#8217; Button to WordPress</a></li>
<li><a href='http://codewithdesign.com/2009/12/30/creating-a-top-button/' rel='bookmark' title='Creating a top button'>Creating a top button</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://codewithdesign.com/2011/06/29/googles-plus-1-button-integration-and-options/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>URL Authentication &#8211; A New Approach</title>
		<link>http://codewithdesign.com/2011/06/21/url-authentication-a-new-approach/</link>
		<comments>http://codewithdesign.com/2011/06/21/url-authentication-a-new-approach/#comments</comments>
		<pubDate>Tue, 21 Jun 2011 14:58:27 +0000</pubDate>
		<dc:creator>Caleb Jonasson</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[url]]></category>
		<category><![CDATA[url changes]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://codewithdesign.com/?p=557</guid>
		<description><![CDATA[TweetIt is time for web developers and software engineers to make a new approach when checking the validity of URLs and emails that are provided by users. Icann has decided that it is going to allow new suffix&#8217; and the ability to host a website on a domain that has no suffix ie: &#8216;http://codewithdesign/index.php&#8217;. With [...]
Related posts:<ol>
<li><a href='http://codewithdesign.com/2010/09/24/check-email-function-php/' rel='bookmark' title='Check Email Function PHP'>Check Email Function PHP</a></li>
<li><a href='http://codewithdesign.com/2011/07/02/password-recovery-theory/' rel='bookmark' title='Password Recovery {Theory}'>Password Recovery {Theory}</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div style = 'float:left; margin-right:5px;'>            <a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical" data-text="URL Authentication &#8211; A New Approach" data-via="" data-url="http://codewithdesign.com/2011/06/21/url-authentication-a-new-approach/" en>Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div class="plus-one-wrap"><g:plusone size="tall" href="http://codewithdesign.com/2011/06/21/url-authentication-a-new-approach/"></g:plusone></div><p>It is time for web developers and software engineers to make a new approach when checking the validity of URLs and emails that are provided by users. Icann has decided that it is going to allow new suffix&#8217; and the ability to host a website on a domain that has no suffix ie: &#8216;http://codewithdesign/index.php&#8217;. With this change in URLs means that all regular expressions are going to have to not force a suffix or that last decimal as a root URL.</p>
<h2>How Will The New Domains Affect Me?</h2>
<p>The new domain scheme is going to change how your website validates proper emails and URLs which can be a rather large change on websites that do not have formatting called from one place. Because of this change you will have to overhaul your website/blog/app to support new URLs and emails.</p>
<h2>How Should I Go About Making The Change</h2>
<p>If you haven&#8217;t done so already it is a good idea to make sure that your formatting and checking is coming from one place and will be able to handle the errors accordingly. The first thing that is required is either a functions file or a class file that will support multiple formats of input. This way when something like this changes you only need to update the code once.</p>
<h2>Ways To Check URLs And Emails</h2>
<p>When working with a URL you can change your regular expression to just check for proper characters and the presence of &#8216;http://&#8217; or &#8216;https://&#8217;, but there is a much more fun way to check for the new format as well. You should still be using a filter or a regular expression but make sure that your version of PHP is high enough if you are going to use a filter.</p>
<h2>Check For An Existing Email</h2>
<p>Because of the new URL scheme we are going to need to handle the case that the user is from a website such as &#8216;http://bearattacksarenotgood/&#8217; This will require us to check for an existing email without the checking of a proper suffix in the email since a user can have the email &#8216;calebjonasson@bearattacksarenotgood&#8217;.</p>
<p>We can easily check for an existing email by using a function called &#8216;checkdnsrr&#8217; but first we need to split the email name from the URL which will give us &#8216;calebjonasson&#8217; and &#8216;bearattacksarenotgood&#8217; which we can accomplish by using the list function will will break apart a string by finding a character.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">//load a variable with an email.</span>
<span style="color: #000088;">$emailAddress</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'calebjonasson@bearattacksarenotgood'</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//split the email by the user name and domain name</span>
<span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$userName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$domainName</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">split</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'@'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$emailAddress</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//use checkdnsrr to validate the domain names existence.</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">checkdnsrr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$domainName</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'MX'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">//return value on success.</span>
    <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">//return value on failure.</span>
    <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h2>Pinging A Server</h2>
<p>It is possible to ping a server through PHP and it is also possible to just use a cURL to request the page information and check and the response headers. The first thing I will show you is how to send a request which will allow you to check for ping of the data server in question.</p>
<p>My prefered method of doing so is to install net ping onto the server. This is the best solution that I have found on the web to this day and is very simple to use. Here is a tutorial from <a title="Code Diesel" href="http://www.codediesel.com/php/ping-a-server-using-php/" target="_blank">Code Diesel</a>.</p>
<img src="http://codewithdesign.com/?ak_action=api_record_view&id=557&type=feed" alt="" /><p>Related posts:<ol>
<li><a href='http://codewithdesign.com/2010/09/24/check-email-function-php/' rel='bookmark' title='Check Email Function PHP'>Check Email Function PHP</a></li>
<li><a href='http://codewithdesign.com/2011/07/02/password-recovery-theory/' rel='bookmark' title='Password Recovery {Theory}'>Password Recovery {Theory}</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://codewithdesign.com/2011/06/21/url-authentication-a-new-approach/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex Data Service Debugging Software</title>
		<link>http://codewithdesign.com/2011/06/08/flex-data-service-debugging-software/</link>
		<comments>http://codewithdesign.com/2011/06/08/flex-data-service-debugging-software/#comments</comments>
		<pubDate>Wed, 08 Jun 2011 13:49:14 +0000</pubDate>
		<dc:creator>Caleb Jonasson</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Charles]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[proxy]]></category>

		<guid isPermaLink="false">http://codewithdesign.com/?p=550</guid>
		<description><![CDATA[TweetI wanted to share an exceptional piece of software that I was recommended to use at work as an excellent debugging tool. The software is called Charles and comes with an excellent demo version that closes every thirty minutes and will give you a little window telling you that you are using a demo from [...]
Related posts:<ol>
<li><a href='http://codewithdesign.com/2011/04/07/create-your-own-phpamf-data-service-for-flex/' rel='bookmark' title='Create Your Own PHP/AMF Data Service For Flex'>Create Your Own PHP/AMF Data Service For Flex</a></li>
<li><a href='http://codewithdesign.com/2011/05/25/web-browsers-for-web-developers/' rel='bookmark' title='Web Browsers for Web Developers'>Web Browsers for Web Developers</a></li>
<li><a href='http://codewithdesign.com/2011/05/30/redundant-data-class-in-php-theory/' rel='bookmark' title='Redundant Data Class in PHP {Theory}'>Redundant Data Class in PHP {Theory}</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div style = 'float:left; margin-right:5px;'>            <a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical" data-text="Flex Data Service Debugging Software" data-via="" data-url="http://codewithdesign.com/2011/06/08/flex-data-service-debugging-software/" en>Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div class="plus-one-wrap"><g:plusone size="tall" href="http://codewithdesign.com/2011/06/08/flex-data-service-debugging-software/"></g:plusone></div><p>I wanted to share an exceptional piece of software that I was recommended to use at work as an excellent debugging tool. The software is called <a href="http://www.charlesproxy.com/">Charles </a>and comes with an excellent demo version that closes every thirty minutes and will give you a little window telling you that you are using a <a href="http://www.charlesproxy.com/download/">demo </a>from time to time but aside from those two draw backs they haven&#8217;t left a whole lot out.</p>
<p>I needed some software after being unable to figure out why we were unable to connect to a data service with Flex. This software upon launch quickly showed us the response that we were not being displayed through Flex and allowed us to quickly sort out our gateway issues. Even though we used this software to help debug flex we have also been using for a lot of http requests and all other browser based debugging that involves sending and retrieving data.</p>
<p>If you aren&#8217;t convinced as to download the free copy yet I should probably mention that the software only costs about $30 for a full license and comes in better packages based on how many copies of the software you purchase. It also comes with the ability to throttle your own bandwidth and latency to test in slow conditions which is great when testing against a local server.  The software also allows you to change and resend requests to test back end services which is a huge benefit as a server guy.</p>
<p>The software package comes available and fully supported for Linux, Mac, and of course Windows.</p>
<p><a href="http://codewithdesign.com/wp-content/uploads/2011/06/temp.png" rel="lightbox[550]"><img class="alignnone size-medium wp-image-551" title="Charles Debugging" src="http://codewithdesign.com/wp-content/uploads/2011/06/temp-600x276.png" alt="" width="600" height="276" /></a></p>
<p>I&#8217;m not a software review nor am I paid to voice my opinions but I would advise that any company that wants to save some serious time on debugging should buy this software. It is great for everything web.</p>
<img src="http://codewithdesign.com/?ak_action=api_record_view&id=550&type=feed" alt="" /><p>Related posts:<ol>
<li><a href='http://codewithdesign.com/2011/04/07/create-your-own-phpamf-data-service-for-flex/' rel='bookmark' title='Create Your Own PHP/AMF Data Service For Flex'>Create Your Own PHP/AMF Data Service For Flex</a></li>
<li><a href='http://codewithdesign.com/2011/05/25/web-browsers-for-web-developers/' rel='bookmark' title='Web Browsers for Web Developers'>Web Browsers for Web Developers</a></li>
<li><a href='http://codewithdesign.com/2011/05/30/redundant-data-class-in-php-theory/' rel='bookmark' title='Redundant Data Class in PHP {Theory}'>Redundant Data Class in PHP {Theory}</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://codewithdesign.com/2011/06/08/flex-data-service-debugging-software/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Redundant Data Class in PHP {Theory}</title>
		<link>http://codewithdesign.com/2011/05/30/redundant-data-class-in-php-theory/</link>
		<comments>http://codewithdesign.com/2011/05/30/redundant-data-class-in-php-theory/#comments</comments>
		<pubDate>Tue, 31 May 2011 06:51:50 +0000</pubDate>
		<dc:creator>Caleb Jonasson</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[data class]]></category>

		<guid isPermaLink="false">http://codewithdesign.com/?p=548</guid>
		<description><![CDATA[TweetAs a server side programmer you are going to be spending a lot of time working with data that is pulled from the database and in order to make sure that you do not have any loose ends it is a good idea to handle this situation with a class. This article is not going [...]
Related posts:<ol>
<li><a href='http://codewithdesign.com/2011/07/02/password-recovery-theory/' rel='bookmark' title='Password Recovery {Theory}'>Password Recovery {Theory}</a></li>
<li><a href='http://codewithdesign.com/2011/08/04/statistics-simple-logging-design/' rel='bookmark' title='Statistics &#8211; Simple Logging Design'>Statistics &#8211; Simple Logging Design</a></li>
<li><a href='http://codewithdesign.com/2010/09/22/sql-one-to-many-using-inner-join/' rel='bookmark' title='SQL: One To Many Using Inner Join'>SQL: One To Many Using Inner Join</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div style = 'float:left; margin-right:5px;'>            <a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical" data-text="Redundant Data Class in PHP {Theory}" data-via="" data-url="http://codewithdesign.com/2011/05/30/redundant-data-class-in-php-theory/" en>Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div class="plus-one-wrap"><g:plusone size="tall" href="http://codewithdesign.com/2011/05/30/redundant-data-class-in-php-theory/"></g:plusone></div><p>As a server side programmer you are going to be spending a lot of time working with data that is pulled from the database and in order to make sure that you do not have any loose ends it is a good idea to handle this situation with a class. This article is not going to cover how to code a data class nor is it going to help you create a specific data class. This article is here to show you how to make your data redundant and error proof.</p>
<h2>Pulling all of your information</h2>
<p>When pulling the information off the get go you are going to want to do one thing and one thing only: query all of the data that you can use in the class. The query is going to take place inside of a function and will most likely be used every time that you are in need of the data in the database. Once the query to obtain this information has taken place then you are going to either have results or no results and the easy way to check is simply by checking the number of rows returned.</p>
<p>Say we were trying to access user information for a user page. It would be a good idea to query and make sure that all of the information is available. In this query we are most likely going to be joining up to multiple tables because having all of the user information stored in one table would create a fair amount of overhead and would increase the time it took to go through the table. For this reason we break things apart.</p>
<h2>An Example Of Database Tables</h2>
<p>A well structured database table is going to be pulling from an auto incrementing ID. This auto incrementing id is going to be found on every table but since we can not just assume that if we insert a record into tbl_user and tbl_user_profile at the same time we are going to get ID&#8217;s that match properly. Because this is a flawed way of looking at the table set up we are going to use the auto incremental ID from the tbl_user and plug this into a new column on the other user tables. This way we can simply join the tbl_user.user_id to tbl_user_profile.user_nid. Now that we have a relationship in the database that will work and is pretty redundant in theory we are still going to have to deal with the situation of a table not being created properly upon user registration and thus we are lead to&#8230;</p>
<h2>Enforcing Existing Tables</h2>
<p>Remember back up at the top when I was talking about the query all function either working or not working? Well this function upon returning zero rows will tell us one of two things. (Assuming the SQL was written properly.) The first thing that it will tell us is that this user does not exist, and the second thing is that the user is missing a table. This could mean that something was deleted, or maybe the table was recovered in backup at a later date and there was a record missing. Either way we know that by checking the user table for the users existence we are able to confirm that we are dealing with missing data and this is where the checking functions come into place.</p>
<p>In a well written data handling class there will be functions that exist to pull results from each of the individual tables. These functions are excellent for checking that a user does exist in the following table and are a great way to quickly and easily pull sections of content based on the user which are handy when loading content on an interval via AJAX. But now we are getting a little off topic. Creating a function that can pull information and return a number as a status and creating another function that will insert defaults into the table is an excellent way to make sure that you do not lose data and that all of the data is being pulled properly.</p>
<h2>Recap</h2>
<p>When using the class you are most likely just going to need to get the information which means that you will be using a function that behaves like the queryAll that I was talking about. If the user does not exist then you can simply return false.</p>
<p>The next step is to create functions that will check individual tables based on that original tbl_user.user_id (or whatever yours is) starting with the initial tbl_user which the rest of the tables are based on. This will tell you if it was created in the first place or not.</p>
<p>If we have gotten far enough to know that the user does exist and the user simply doesn&#8217;t have a record in one of the tables then we can query each of the tables and find out where the record is missing. Now that we know the table we can simply insert blank data into the table and maybe send a notification to the user that they may need to update a certain part of their profile.</p>
<h2>Knowing when we have an error in table creation</h2>
<p>Through this data class it is just a matter of adding in an error log message to let the administrators tell if the application has a bug in it but this shouldn&#8217;t be a problem if you are handling proper inserts and updates through SQL and checking for an affected row upon creation.</p>
<img src="http://codewithdesign.com/?ak_action=api_record_view&id=548&type=feed" alt="" /><p>Related posts:<ol>
<li><a href='http://codewithdesign.com/2011/07/02/password-recovery-theory/' rel='bookmark' title='Password Recovery {Theory}'>Password Recovery {Theory}</a></li>
<li><a href='http://codewithdesign.com/2011/08/04/statistics-simple-logging-design/' rel='bookmark' title='Statistics &#8211; Simple Logging Design'>Statistics &#8211; Simple Logging Design</a></li>
<li><a href='http://codewithdesign.com/2010/09/22/sql-one-to-many-using-inner-join/' rel='bookmark' title='SQL: One To Many Using Inner Join'>SQL: One To Many Using Inner Join</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://codewithdesign.com/2011/05/30/redundant-data-class-in-php-theory/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>cURL 403 Error Returning</title>
		<link>http://codewithdesign.com/2011/05/26/curl-403-error-returning/</link>
		<comments>http://codewithdesign.com/2011/05/26/curl-403-error-returning/#comments</comments>
		<pubDate>Thu, 26 May 2011 13:40:12 +0000</pubDate>
		<dc:creator>Caleb Jonasson</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[cURL]]></category>
		<category><![CDATA[cURL returns 403]]></category>
		<category><![CDATA[http status 403 return]]></category>

		<guid isPermaLink="false">http://codewithdesign.com/?p=539</guid>
		<description><![CDATA[TweetThe other day at work we ran into an issue where the server would return a 403 error page when retrieving page information from a cURL call. After searching around the web for a while thinking that we had a server permission issue on our hands it ended up just being a PHP problem. In [...]
Related posts:<ol>
<li><a href='http://codewithdesign.com/2011/06/21/url-authentication-a-new-approach/' rel='bookmark' title='URL Authentication &#8211; A New Approach'>URL Authentication &#8211; A New Approach</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div style = 'float:left; margin-right:5px;'>            <a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical" data-text="cURL 403 Error Returning" data-via="" data-url="http://codewithdesign.com/2011/05/26/curl-403-error-returning/" en>Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div class="plus-one-wrap"><g:plusone size="tall" href="http://codewithdesign.com/2011/05/26/curl-403-error-returning/"></g:plusone></div><p>The other day at work we ran into an issue where the server would return a 403 error page when retrieving page information from a cURL call. After searching around the web for a while thinking that we had a server permission issue on our hands it ended up just being a PHP problem.</p>
<p>In order to make a cURL request from your own server you must first <strong>make sure that the session has been destroyed prior to and cURL commands.</strong> This is because your server cannot have two pages that can access sessions up at the same time and the primary file that you are working from is going to lock the secondary file that you are trying to bring in.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">session_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//authentication code.</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//destroy session first.</span>
<span style="color: #990000;">session_destroy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//cURL code.</span>
<span style="color: #000088;">$ch_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_POST<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_POSTFIELDS<span style="color: #339933;">,</span> <span style="color: #000088;">$fields_string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span>
<span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//now we can start the session again</span>
<span style="color: #990000;">session_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//do some other stuff...</span></pre></td></tr></table></div>

<p>My only guess as to why PHP does this is to protect itself from breaking sessions with multiple page access which is a pretty good security issue to have in place. Better error reporting would have been nice though.</p>
<img src="http://codewithdesign.com/?ak_action=api_record_view&id=539&type=feed" alt="" /><p>Related posts:<ol>
<li><a href='http://codewithdesign.com/2011/06/21/url-authentication-a-new-approach/' rel='bookmark' title='URL Authentication &#8211; A New Approach'>URL Authentication &#8211; A New Approach</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://codewithdesign.com/2011/05/26/curl-403-error-returning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP: Array Of Bad Words</title>
		<link>http://codewithdesign.com/2011/05/20/php-array-of-bad-words/</link>
		<comments>http://codewithdesign.com/2011/05/20/php-array-of-bad-words/#comments</comments>
		<pubDate>Fri, 20 May 2011 13:16:08 +0000</pubDate>
		<dc:creator>Caleb Jonasson</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[bad words]]></category>
		<category><![CDATA[curse words]]></category>
		<category><![CDATA[racial slurs]]></category>
		<category><![CDATA[word filter]]></category>

		<guid isPermaLink="false">http://codewithdesign.com/?p=534</guid>
		<description><![CDATA[TweetWhen creating applications that are going to be used by hundreds of thousands; it is important to make sure that you have the proper facilities in place to handle curse words that are entered in by users. This can be done by checking an array of bad words. The code is simply&#8230; 1 2 3 [...]
Related posts:<ol>
<li><a href='http://codewithdesign.com/2009/12/05/looping-with-an-array/' rel='bookmark' title='Looping with an array'>Looping with an array</a></li>
<li><a href='http://codewithdesign.com/2011/04/07/create-your-own-phpamf-data-service-for-flex/' rel='bookmark' title='Create Your Own PHP/AMF Data Service For Flex'>Create Your Own PHP/AMF Data Service For Flex</a></li>
<li><a href='http://codewithdesign.com/2011/05/03/htaccess-handling-bad-server-requests/' rel='bookmark' title='.htaccess Handling Bad Server Requests'>.htaccess Handling Bad Server Requests</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div style = 'float:left; margin-right:5px;'>            <a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical" data-text="PHP: Array Of Bad Words" data-via="" data-url="http://codewithdesign.com/2011/05/20/php-array-of-bad-words/" en>Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div class="plus-one-wrap"><g:plusone size="tall" href="http://codewithdesign.com/2011/05/20/php-array-of-bad-words/"></g:plusone></div><p>When creating applications that are going to be used by hundreds of thousands; it is important to make sure that you have the proper facilities in place to handle curse words that are entered in by users. This can be done by checking an array of bad words.</p>
<p>The code is simply&#8230;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">//foul language array</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">badWords</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'word1'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'word2'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'word3'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//Now you just need to go through your string and make comparisons.</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Rather then posting the code directly onto the blog I would rather have a site that is safe for all readers and not be indexed with foul language and racial slurs and thus is why I am offering the array via <a href='http://codewithdesign.com/wp-content/uploads/2011/05/bad-words-php-array.zip'>a text file within a compressed zip</a>.</p>
<img src="http://codewithdesign.com/?ak_action=api_record_view&id=534&type=feed" alt="" /><p>Related posts:<ol>
<li><a href='http://codewithdesign.com/2009/12/05/looping-with-an-array/' rel='bookmark' title='Looping with an array'>Looping with an array</a></li>
<li><a href='http://codewithdesign.com/2011/04/07/create-your-own-phpamf-data-service-for-flex/' rel='bookmark' title='Create Your Own PHP/AMF Data Service For Flex'>Create Your Own PHP/AMF Data Service For Flex</a></li>
<li><a href='http://codewithdesign.com/2011/05/03/htaccess-handling-bad-server-requests/' rel='bookmark' title='.htaccess Handling Bad Server Requests'>.htaccess Handling Bad Server Requests</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://codewithdesign.com/2011/05/20/php-array-of-bad-words/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

