<?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</title>
	<atom:link href="http://codewithdesign.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://codewithdesign.com</link>
	<description>web application development blog by Caleb Jonasson</description>
	<lastBuildDate>Thu, 15 Sep 2011 17:52:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Project: Mobile/Project Update Blog</title>
		<link>http://codewithdesign.com/2011/09/15/project-mobileproject-update-blog/</link>
		<comments>http://codewithdesign.com/2011/09/15/project-mobileproject-update-blog/#comments</comments>
		<pubDate>Thu, 15 Sep 2011 13:50:15 +0000</pubDate>
		<dc:creator>Caleb Jonasson</dc:creator>
				<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://codewithdesign.com/?p=587</guid>
		<description><![CDATA[I have been moving my attention towards mobile development recently but I will still be doing the standard web development stuff here. I would like to split up the two and make this site more focussed towards tutorials and articles pertaining to code, design (not graphics) and all that fun stuff. If you would like [...]


Related posts:<ol><li><a href='http://codewithdesign.com/2009/11/13/stop-spammers-from-attacking-your-wp-blog/' rel='bookmark' title='Permanent Link: Stop Spammers From Attacking Your WP Blog'>Stop Spammers From Attacking Your WP Blog</a></li>
<li><a href='http://codewithdesign.com/2010/02/26/pre-planning-websites/' rel='bookmark' title='Permanent Link: Pre planning websites'>Pre planning websites</a></li>
<li><a href='http://codewithdesign.com/2009/09/29/178-web-icons/' rel='bookmark' title='Permanent Link: 178 Web Icons'>178 Web Icons</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<g:plusone size="tall" href="http://codewithdesign.com/2011/09/15/project-mobileproject-update-blog/"></g:plusone><p>I have been moving my attention towards mobile development recently but I will still be doing the standard web development stuff here. I would like to split up the two and make this site more focussed towards tutorials and articles pertaining to code, design (not graphics) and all that fun stuff.</p>
<p>If you would like to check out some of the stuff going on at the other website you can visit it here. http://cjonasson.com</p>
<img src="http://codewithdesign.com/?ak_action=api_record_view&id=587&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://codewithdesign.com/2009/11/13/stop-spammers-from-attacking-your-wp-blog/' rel='bookmark' title='Permanent Link: Stop Spammers From Attacking Your WP Blog'>Stop Spammers From Attacking Your WP Blog</a></li>
<li><a href='http://codewithdesign.com/2010/02/26/pre-planning-websites/' rel='bookmark' title='Permanent Link: Pre planning websites'>Pre planning websites</a></li>
<li><a href='http://codewithdesign.com/2009/09/29/178-web-icons/' rel='bookmark' title='Permanent Link: 178 Web Icons'>178 Web Icons</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://codewithdesign.com/2011/09/15/project-mobileproject-update-blog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dream In Code User Widget</title>
		<link>http://codewithdesign.com/2011/08/17/dream-in-code-user-widget/</link>
		<comments>http://codewithdesign.com/2011/08/17/dream-in-code-user-widget/#comments</comments>
		<pubDate>Thu, 18 Aug 2011 04:35:08 +0000</pubDate>
		<dc:creator>Caleb Jonasson</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[dreamincode]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://codewithdesign.com/?p=578</guid>
		<description><![CDATA[Recently I pulled an all nighter and coded a user widget using the Dream In Code API. The project is currently unfinished but it is very usable. The idea of the project is to allow the users of dream in code to show off their reputation, posts and group on their website, blog, etc. It [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<g:plusone size="tall" href="http://codewithdesign.com/2011/08/17/dream-in-code-user-widget/"></g:plusone><p>Recently I pulled an all nighter and coded a user widget using the Dream In Code API. The project is currently unfinished but it is very usable. The idea of the project is to allow the users of dream in code to show off their reputation, posts and group on their website, blog, etc. It also gives users the ability to support and promote Dream In Code and the community behind it.</p>
<p>The code for the user widget is as follows:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;iframe
    scrolling=&quot;no&quot;
    style=&quot;width: 282px;
        height: 76px;
        border: none;&quot;
    src=&quot;http://atomicbucket.com/dreamincode/?id=175017&quot;
&gt;&lt;/iframe&gt;</pre></td></tr></table></div>

<p>Once the code has been added to a website it will look as follows:<br />
<img src="http://atomicbucket.com/dreamincode/example.png" alt="Dream In Code User Widget" /><br />
In order to get your own widget you must:<br />
A) become a member of dream in code.<br />
B) Take the id in your user profile and insert it into the id that is within the embed code&#8217;s url.</p>
<p><strong>Note:</strong> There will be additions to this project regarding options for sizes that the widget can come in.</p>
<img src="http://codewithdesign.com/?ak_action=api_record_view&id=578&type=feed" alt="" />

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://codewithdesign.com/2011/08/17/dream-in-code-user-widget/feed/</wfw:commentRss>
		<slash:comments>1</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[Introduction 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/2011/05/30/redundant-data-class-in-php-theory/' rel='bookmark' title='Permanent Link: Redundant Data Class in PHP {Theory}'>Redundant Data Class in PHP {Theory}</a></li>
<li><a href='http://codewithdesign.com/2011/07/02/password-recovery-theory/' rel='bookmark' title='Permanent Link: Password Recovery {Theory}'>Password Recovery {Theory}</a></li>
<li><a href='http://codewithdesign.com/2009/10/04/creating-a-single-page-login-%e2%80%93-design-view/' rel='bookmark' title='Permanent Link: Creating a Single Page login – Design View'>Creating a Single Page login – Design View</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<g:plusone size="tall" href="http://codewithdesign.com/2011/08/04/statistics-simple-logging-design/"></g:plusone><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/2011/05/30/redundant-data-class-in-php-theory/' rel='bookmark' title='Permanent Link: Redundant Data Class in PHP {Theory}'>Redundant Data Class in PHP {Theory}</a></li>
<li><a href='http://codewithdesign.com/2011/07/02/password-recovery-theory/' rel='bookmark' title='Permanent Link: Password Recovery {Theory}'>Password Recovery {Theory}</a></li>
<li><a href='http://codewithdesign.com/2009/10/04/creating-a-single-page-login-%e2%80%93-design-view/' rel='bookmark' title='Permanent Link: 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[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 [...]


Related posts:<ol><li><a href='http://codewithdesign.com/2011/05/30/redundant-data-class-in-php-theory/' rel='bookmark' title='Permanent Link: Redundant Data Class in PHP {Theory}'>Redundant Data Class in PHP {Theory}</a></li>
<li><a href='http://codewithdesign.com/2010/05/23/sql-%e2%80%93-an-introduction-to-keys/' rel='bookmark' title='Permanent Link: SQL – An introduction to Keys'>SQL – An introduction to Keys</a></li>
<li><a href='http://codewithdesign.com/2011/04/12/password-protecting-your-directory-with-htaccess-htpasswd/' rel='bookmark' title='Permanent Link: Password Protecting Your Directory With .htaccess &#038; .htpasswd'>Password Protecting Your Directory With .htaccess &#038; .htpasswd</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<g:plusone size="tall" href="http://codewithdesign.com/2011/07/02/password-recovery-theory/"></g:plusone><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='Permanent Link: Redundant Data Class in PHP {Theory}'>Redundant Data Class in PHP {Theory}</a></li>
<li><a href='http://codewithdesign.com/2010/05/23/sql-%e2%80%93-an-introduction-to-keys/' rel='bookmark' title='Permanent Link: SQL – An introduction to Keys'>SQL – An introduction to Keys</a></li>
<li><a href='http://codewithdesign.com/2011/04/12/password-protecting-your-directory-with-htaccess-htpasswd/' rel='bookmark' title='Permanent Link: Password Protecting Your Directory With .htaccess &#038; .htpasswd'>Password Protecting Your Directory With .htaccess &#038; .htpasswd</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[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 [...]


Related posts:<ol><li><a href='http://codewithdesign.com/2010/09/23/adding-the-like-button-to-wordpress/' rel='bookmark' title='Permanent Link: 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='Permanent Link: Creating a top button'>Creating a top button</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<g:plusone size="tall" href="http://codewithdesign.com/2011/06/29/googles-plus-1-button-integration-and-options/"></g:plusone><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='Permanent Link: 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='Permanent Link: 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>11</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[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 [...]


Related posts:<ol><li><a href='http://codewithdesign.com/2011/07/02/password-recovery-theory/' rel='bookmark' title='Permanent Link: Password Recovery {Theory}'>Password Recovery {Theory}</a></li>
<li><a href='http://codewithdesign.com/2010/09/24/check-email-function-php/' rel='bookmark' title='Permanent Link: Check Email Function PHP'>Check Email Function PHP</a></li>
<li><a href='http://codewithdesign.com/2011/05/03/htaccess-handling-bad-server-requests/' rel='bookmark' title='Permanent Link: .htaccess Handling Bad Server Requests'>.htaccess Handling Bad Server Requests</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<g:plusone size="tall" href="http://codewithdesign.com/2011/06/21/url-authentication-a-new-approach/"></g:plusone><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/2011/07/02/password-recovery-theory/' rel='bookmark' title='Permanent Link: Password Recovery {Theory}'>Password Recovery {Theory}</a></li>
<li><a href='http://codewithdesign.com/2010/09/24/check-email-function-php/' rel='bookmark' title='Permanent Link: Check Email Function PHP'>Check Email Function PHP</a></li>
<li><a href='http://codewithdesign.com/2011/05/03/htaccess-handling-bad-server-requests/' rel='bookmark' title='Permanent Link: .htaccess Handling Bad Server Requests'>.htaccess Handling Bad Server Requests</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>Zend Studio Shift Tab Fix</title>
		<link>http://codewithdesign.com/2011/06/10/zend-studio-shift-tab-fix/</link>
		<comments>http://codewithdesign.com/2011/06/10/zend-studio-shift-tab-fix/#comments</comments>
		<pubDate>Fri, 10 Jun 2011 23:22:34 +0000</pubDate>
		<dc:creator>Caleb Jonasson</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[shift tab]]></category>
		<category><![CDATA[Zend Studio 8]]></category>

		<guid isPermaLink="false">http://codewithdesign.com/?p=555</guid>
		<description><![CDATA[When switching over to Zend Studio at work I discovered that there was poor support for shift + tab. Whenever using this keyboard short-cut I could only go back as far as I had previously tabbed from which means that any imported code from another IDE would not shift back so many spaces. The Fix By going [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<g:plusone size="tall" href="http://codewithdesign.com/2011/06/10/zend-studio-shift-tab-fix/"></g:plusone><p>When switching over to Zend Studio at work I discovered that there was poor support for shift + tab. Whenever using this keyboard short-cut I could only go back as far as I had previously tabbed from which means that any imported code from another IDE would not shift back so many spaces.</p>
<h2>The Fix</h2>
<p>By going to &#8216;Window&#8217; =&gt; &#8216;Preferences&#8217; =&gt; &#8216;PHP&#8217; =&gt; &#8216;Code Style&#8217; =&gt; &#8216;Formatter&#8217; you can create a new profile. In this profile you can keep everything as the default but rather than keeping the tab key set to tabbing you can change it to spaces and then select the amount of spacing that you would like. Now save your profile, make sure that it is selected and press &#8216;OK.&#8217;</p>
<img src="http://codewithdesign.com/?ak_action=api_record_view&id=555&type=feed" alt="" />

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://codewithdesign.com/2011/06/10/zend-studio-shift-tab-fix/feed/</wfw:commentRss>
		<slash:comments>1</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[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 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='Permanent Link: 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='Permanent Link: 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='Permanent Link: Redundant Data Class in PHP {Theory}'>Redundant Data Class in PHP {Theory}</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<g:plusone size="tall" href="http://codewithdesign.com/2011/06/08/flex-data-service-debugging-software/"></g:plusone><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='Permanent Link: 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='Permanent Link: 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='Permanent Link: 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[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 [...]


Related posts:<ol><li><a href='http://codewithdesign.com/2011/07/02/password-recovery-theory/' rel='bookmark' title='Permanent Link: Password Recovery {Theory}'>Password Recovery {Theory}</a></li>
<li><a href='http://codewithdesign.com/2011/04/07/create-your-own-phpamf-data-service-for-flex/' rel='bookmark' title='Permanent Link: 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/08/04/statistics-simple-logging-design/' rel='bookmark' title='Permanent Link: Statistics &#8211; Simple Logging Design'>Statistics &#8211; Simple Logging Design</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<g:plusone size="tall" href="http://codewithdesign.com/2011/05/30/redundant-data-class-in-php-theory/"></g:plusone><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='Permanent Link: Password Recovery {Theory}'>Password Recovery {Theory}</a></li>
<li><a href='http://codewithdesign.com/2011/04/07/create-your-own-phpamf-data-service-for-flex/' rel='bookmark' title='Permanent Link: 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/08/04/statistics-simple-logging-design/' rel='bookmark' title='Permanent Link: Statistics &#8211; Simple Logging Design'>Statistics &#8211; Simple Logging Design</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[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. In [...]


Related posts:<ol><li><a href='http://codewithdesign.com/2010/12/28/stop-direct-page-access-with-php/' rel='bookmark' title='Permanent Link: Stop Direct Page Access With PHP'>Stop Direct Page Access With PHP</a></li>
<li><a href='http://codewithdesign.com/2010/03/30/php-increasing-a-scripts-runtime/' rel='bookmark' title='Permanent Link: PHP: Increasing a scripts runtime'>PHP: Increasing a scripts runtime</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<g:plusone size="tall" href="http://codewithdesign.com/2011/05/26/curl-403-error-returning/"></g:plusone><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/2010/12/28/stop-direct-page-access-with-php/' rel='bookmark' title='Permanent Link: Stop Direct Page Access With PHP'>Stop Direct Page Access With PHP</a></li>
<li><a href='http://codewithdesign.com/2010/03/30/php-increasing-a-scripts-runtime/' rel='bookmark' title='Permanent Link: PHP: Increasing a scripts runtime'>PHP: Increasing a scripts runtime</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>
	</channel>
</rss>

