<?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>Full On Design &#187; PHP</title>
	<atom:link href="http://www.fullondesign.co.uk/tag/php/feed" rel="self" type="application/rss+xml" />
	<link>http://www.fullondesign.co.uk</link>
	<description>Design &#38; Web Technologies</description>
	<lastBuildDate>Sun, 30 Oct 2011 21:37:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Shorten URLs using the Google URL Shortener and PHP</title>
		<link>http://www.fullondesign.co.uk/coding/php/1741-shorten-urls-using-the-google-url-shortener-and-php.htm</link>
		<comments>http://www.fullondesign.co.uk/coding/php/1741-shorten-urls-using-the-google-url-shortener-and-php.htm#comments</comments>
		<pubDate>Fri, 01 Oct 2010 00:17:30 +0000</pubDate>
		<dc:creator>Rogem</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[APi]]></category>
		<category><![CDATA[goo.gl]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[Google URL Shortener]]></category>
		<category><![CDATA[Url]]></category>

		<guid isPermaLink="false">http://www.fullondesign.co.uk/?p=1741</guid>
		<description><![CDATA[A few days ago Google opened up their URL shortening service goo.gl to the public. Luckily it is pretty easy to make use of the API and shorten URL&#8217;s in PHP. Here is a function I put together which you can make use of. If you want to read up a bit more about the [...]]]></description>
			<content:encoded><![CDATA[<p>A few days ago Google opened up their URL shortening service <a href="http://goo.gl/">goo.gl</a> to the public. Luckily it is pretty easy to make use of the API and shorten URL&#8217;s in PHP. Here is a function I put together which you can make use of.</p>
<pre class="brush: php; title: ; notranslate">&lt;?php
// Coded by Mike Rogers (http://www.fullondesign.co.uk/) 1st October 2010.

function shorten($url, $qr=NULL){
	if(function_exists('curl_init')){
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_URL, 'http://goo.gl/api/shorten');
		curl_setopt($ch, CURLOPT_POST, TRUE);
		curl_setopt($ch, CURLOPT_POSTFIELDS, 'security_token=null&amp;url='.urlencode($url));

		$results = curl_exec($ch);
		$headerInfo = curl_getinfo($ch);
		curl_close($ch);

		if ($headerInfo['http_code'] === 201){ // HTTP Code 201 = Created
			$results = json_decode($results);
			if(isset($results-&gt;short_url)){
				$qr = !is_null($qr)?'.qr':'';
				return $results-&gt;short_url.$qr;
			}
			return FALSE;
		}
		return FALSE;	

	}
	trigger_error(&quot;cURL required to shorten URLs.&quot;, E_USER_WARNING); // Show the user a neat error.
	return FALSE;
}

// Example: Just the Short URL
echo shorten('http://www.google.com/');

// Example: Give the Short Code URL and image it.
$qrURL = shorten('http://www.google.com/', TRUE);
echo '&lt;img src=&quot;'.$qrURL.'&quot; /&gt;';
?&gt;</pre>
<p>If you want to read up a bit more about the goo.gl shortener, take a look at <a href="http://www.mattcutts.com/blog/goo-gl-url-shortener/">Matt Cutts post on his blog</a>.</p>
<p><em>Edit &#8211; Added QR Support.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fullondesign.co.uk/coding/php/1741-shorten-urls-using-the-google-url-shortener-and-php.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>5 changes I would like to see in 2010</title>
		<link>http://www.fullondesign.co.uk/design/inspiration/1246-4-changes-i-would-like-to-see-in-2010.htm</link>
		<comments>http://www.fullondesign.co.uk/design/inspiration/1246-4-changes-i-would-like-to-see-in-2010.htm#comments</comments>
		<pubDate>Wed, 16 Dec 2009 01:24:17 +0000</pubDate>
		<dc:creator>Rogem</dc:creator>
				<category><![CDATA[Inspiration]]></category>
		<category><![CDATA[Attribute]]></category>
		<category><![CDATA[Chat System]]></category>
		<category><![CDATA[Desktop Application]]></category>
		<category><![CDATA[Developers]]></category>
		<category><![CDATA[Double Edge Sword]]></category>
		<category><![CDATA[Javascript Libraries]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Pop Ups]]></category>
		<category><![CDATA[Screen Readers]]></category>
		<category><![CDATA[Users Experience]]></category>
		<category><![CDATA[Video Stream]]></category>

		<guid isPermaLink="false">http://www.fullondesign.co.uk/?p=1246</guid>
		<description><![CDATA[2009 has been a somewhat interesting year for the internet; it&#8217;s become more mobile &#38; more user friendly. However here are a few ideas I have had over the year, which I would like to see arrive in 2010. Video Stream Caching One of the big annoyances I have with streaming video files (normally on [...]]]></description>
			<content:encoded><![CDATA[<p>2009 has been a somewhat interesting year for the internet; it&#8217;s become more mobile &amp; more user friendly. However here are a few ideas I have had over the year, which I would like to see arrive in 2010.</p>
<h3>Video Stream Caching</h3>
<p>One of the big annoyances I have with streaming video files (normally on websites such as YouTube &amp; Megavideo) is whenever I go to jump to another section of the video I lose what I currently have already loaded. It would be really useful if I could quickly go back to the section I&#8217;ve previously loaded.</p>
<p><a href="http://www.fullondesign.co.uk/wp-content/uploads/2009/12/video_stream_caching.png"><img class="aligncenter size-full wp-image-1254" title="video_stream_caching" src="http://www.fullondesign.co.uk/wp-content/uploads/2009/12/video_stream_caching.png" alt="video_stream_caching" width="500" height="320" /></a><br />
 <em>This is a mock up I done, the video I used is from </em><a href="http://www.youtube.com/watch?v=IKATXdRD4d0">RayWilliamJohnson</a></p>
<p>I&#8217;m quite sure this would need to be implemented by the software, but I can&#8217;t see how it would be difficult to add.</p>
<p><span id="more-1246"></span></p>
<h3>Facebook &#8211; Pop-up chat</h3>
<p>Pop-ups are a double edge sword; on the one hand they have been used incorrectly and become an utter annoyance. But on the other, they also can drastically improve a users experience with a website. For example the Facebook chat system is very inconvenient as I have to be looking at a Facebook page to talk to people. On a big screen this might not be a big issue, but on a small screen this makes it surprisingly difficult to  multi-task.</p>
<p style="text-align: center;"><a href="http://www.fullondesign.co.uk/wp-content/uploads/2009/12/facebook_chat_problem.png"><img class="aligncenter size-full wp-image-1258" title="facebook_chat_problem" src="http://www.fullondesign.co.uk/wp-content/uploads/2009/12/facebook_chat_problem.png" alt="facebook_chat_problem" width="597" height="445" /></a><em>Oh noes! I can&#8217;t see the chat &amp; watch the video</em></p>
<p>However, if Facebook make the chat system as a desktop application or just available in a pop-up I suspect that would solve issue.</p>
<p style="text-align: center;"><a href="http://www.fullondesign.co.uk/wp-content/uploads/2009/12/facebook_chat_popup_mockup.png"><img class="size-full wp-image-1263 alignnone" title="facebook_chat_popup_mockup" src="http://www.fullondesign.co.uk/wp-content/uploads/2009/12/facebook_chat_popup_mockup.png" alt="facebook_chat_popup_mockup" width="251" height="376" /> </a><a href="http://www.fullondesign.co.uk/wp-content/uploads/2009/12/facebook_chat_popup_mockup_button_on_fb.png"><img class="size-full wp-image-1268 alignnone" title="facebook_chat_popup_mockup_button" src="http://www.fullondesign.co.uk/wp-content/uploads/2009/12/facebook_chat_popup_mockup_button_on_fb.png" alt="facebook_chat_popup_mockup_button" width="237" height="315" /></a></p>
<h3>JavaScript Library Integrated into browsers</h3>
<p>It seems silly that I have to keep re-downloading the same file (A Javascript Library) to make a webpage more exciting. I would love to see not just jQuery, but most JavaScript libraries integrated into browsers (maybe as a add-on or something?) to speed up the download times of webpages.</p>
<p>On the other hand, it could be time to consider a new browser based language which is designed to make surfers &amp; developers lives easier. For example adding a new attribute to html forms which allowed for browser specific (so people with screen readers will not be disadvantaged) validation.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;form&gt;
&lt;fieldset&gt;
&lt;label&gt;Phone Number:
&lt;input name=&quot;price&quot; type=&quot;text&quot; value=&quot;090 111 050&quot; /&gt;&lt;/label&gt;
&lt;/fieldset&gt;
&lt;/form&gt;
</pre>
<h3>OpenID/Facebook Connect &#8211; More widely adopted</h3>
<p>I hate having to sign up to websites, especially when I could just as easily use a login details from a single source. It would be really cool if more websites allowed for a &#8220;one click registration&#8221; option.</p>
<h3>Adobe Flash &#8211; Video Player Standardization</h3>
<p>One of my biggest pet hates is going onto a nice website just to find features I expect to find, or actions I believe are normal are just not present on the video players. For example I think it is normal for a click on a video to mean &#8220;pause&#8221; and a double click to go to full screen mode. I think this is just something Web Developers need to consider.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fullondesign.co.uk/design/inspiration/1246-4-changes-i-would-like-to-see-in-2010.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Handling Errors In PHP</title>
		<link>http://www.fullondesign.co.uk/coding/php/736-handling-errors-in-php.htm</link>
		<comments>http://www.fullondesign.co.uk/coding/php/736-handling-errors-in-php.htm#comments</comments>
		<pubDate>Wed, 03 Jun 2009 18:44:14 +0000</pubDate>
		<dc:creator>Rogem</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[error handling]]></category>
		<category><![CDATA[php class]]></category>

		<guid isPermaLink="false">http://www.fullondesign.co.uk/?p=736</guid>
		<description><![CDATA[Handling errors in PHP can be quite a handful at times. Here is a really simple PHP class which I use to manage errors: If you are looking to fully integrate a script similar to the above, there is a really good post regarding the set_error_handler() function on Tinsology ( PHP Error Handling ).]]></description>
			<content:encoded><![CDATA[<p>Handling errors in PHP can be quite a handful at times. Here is a really simple PHP class which I use to manage errors:</p>
<pre class="brush: php; title: ; notranslate">&lt;?php
/*
errors class - Helps management of errors in a script.

@version
	1.0
@author
	Mike Rogers (FullOnDesin.co.uk)
@last updated
	03 June 2009
@usage
	You are free to share, modify and use this code for commercial or non-commercial uses.
	Please give a link back (to http://www.fullondesign.co.uk/ ) if you can, but you don't have you.
	You use this at your own risk.
*/
class errors {
	var $errors_data;

	/*
	Add the error from $new_error into an array of errors.

	@param
		$new_error	string The text related to your error.
	@return:
		True - Error has been Added
	@example
		add_error('Username is Incorrect');
	*/
	public function add_error($new_error){
		$this-&gt;errors_data[] = $new_error;
		return TRUE;
	}

	/*
		Outputs the errors.

	@param
		None
	@return:
		- A div (ID - error) which contains the errors.
		NULL - No errors
	@example
		echo output_errors();
	*/
	public function output_errors(){
		if(is_array($this-&gt;errors_data)){
			// Cycle through the errors.
			foreach($this-&gt;errors_data as $error)	{
				$return .= '&lt;p&gt;'.$error.'&lt;/p&gt;';
			}
		// Add it to the error div
		return '&lt;div id=&quot;error&quot;&gt;'.$return.'&lt;/div&gt;';
		}
		return NULL;
	}
}

// @Example - creating the class:
$errors = new errors;

// @Example - Add an error
$errors-&gt;add_error('Username is incorrect');

// @Example - Return the errors
echo $errors-&gt;output_errors();
?&gt;</pre>
<p>If you are looking to fully integrate a script similar to the above, there is a really good post regarding the <a href="http://uk3.php.net/manual/en/function.set-error-handler.php">set_error_handler()</a> function on <a href="http://tinsology.net/2009/04/php-error-handling/">Tinsology ( PHP Error Handling )</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fullondesign.co.uk/coding/php/736-handling-errors-in-php.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making a simple Facebook Application</title>
		<link>http://www.fullondesign.co.uk/coding/php/311-making-a-simple-facebook-application.htm</link>
		<comments>http://www.fullondesign.co.uk/coding/php/311-making-a-simple-facebook-application.htm#comments</comments>
		<pubDate>Tue, 05 May 2009 16:35:53 +0000</pubDate>
		<dc:creator>Rogem</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[facebook application]]></category>

		<guid isPermaLink="false">http://www.fullondesign.co.uk/?p=311</guid>
		<description><![CDATA[In this quick tutorial I&#8217;m going to show you how to make a simple &#8220;return all&#8221; application for facebook. Before you start take a look at the Facebook Developers page and the Facebook Developers Wiki as it&#8217;s full of useful stuff. The Core Components API &#8211; Lets you talk to the facebook servers. [put picture [...]]]></description>
			<content:encoded><![CDATA[<p>In this quick tutorial I&#8217;m going to show you how to make a simple &#8220;return all&#8221; application for facebook. Before you start take a look at the <a href="http://developers.facebook.com/" target="_blank">Facebook Developers</a> page and the <a href="http://wiki.developers.facebook.com/index.php/Main_Page" target="_blank">Facebook Developers Wiki</a> as it&#8217;s full of useful stuff.</p>
<h3>The Core Components</h3>
<ul>
<li>API &#8211; Lets you talk to the facebook servers. [put picture here explaining in detail]</li>
<li>FBML &#8211; Facebook markup language, it&#8217;s like a cute little html snippet which facebook turns into normal HTML.</li>
<li>XFBML &#8211; A javascript which lets you use FBML in iframes.</li>
<li>FQL &#8211; Lets you run SQL type query&#8217;s.</li>
<li>FBJS &#8211; This changes your javascript so you can only work within a close environment.</li>
<li><a href="http://svn.facebook.com/svnroot/platform/clients/packages/" target="_blank">PHP Client Libraries</a> &#8211; The PHP Facebook provides to communicate with their servers.</li>
</ul>
<p><span id="more-311"></span></p>
<h3>The fun stuff<strong><br />
 </strong></h3>
<p>Assuming you have downloaded the required files, you can now start playing with the facebook API. Here is the basic shell for any Facebook application:</p>
<pre class="brush: php; title: ; notranslate">&lt;?php
# Start by Defining everything the code needs to talk to facebook. Facebook provides these when you sign up.
define(YOUR_API_KEY, '');
define(YOUR_SECRET_CODE, '');

// Include the facebook API PHP classes.
require_once('facebook.php');

// Connect to facebook
$facebook = new Facebook(YOUR_API_KEY,YOUR_SECRET_CODE);

// Return everything facebook has sent to you.
echo '
&lt;pre'.'&gt;Debug:' . print_r($facebook,true) . '&lt;/pre'.'&gt;';
?&gt;
</pre>
<p>As you guessed, that does basically just returns the data sent by facebook. If you want to try this out yourself, take a look at the <a href="http://www.facebook.com/developers/">Facebook Developer App</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fullondesign.co.uk/coding/php/311-making-a-simple-facebook-application.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple PHP Download Counter</title>
		<link>http://www.fullondesign.co.uk/coding/php/770-simple-php-download-counter.htm</link>
		<comments>http://www.fullondesign.co.uk/coding/php/770-simple-php-download-counter.htm#comments</comments>
		<pubDate>Sat, 25 Apr 2009 00:06:04 +0000</pubDate>
		<dc:creator>Rogem</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Download Counter]]></category>

		<guid isPermaLink="false">http://www.fullondesign.co.uk/?p=770</guid>
		<description><![CDATA[Here is a really easy and lightweight way of logging the amount of downloads. You can run this by changing the URL that accesses the file. For example: file.php?ID=0 Feel free to edit and share this code.]]></description>
			<content:encoded><![CDATA[<p>Here is a really easy and lightweight way of logging the amount of downloads.</p>
<pre class="brush: php; title: ; notranslate">&lt;?php # File created on 25th April 2009 by Mike Rogers (http://www.fullondesign.co.uk/). 

## Start defining constants ##
define(LOG_URL, '/home/user/download_logs/'); // Put the location of where you want to put the logs. Make sure this is absolute
# $_GET['ID'] - this is the ID of the file we want. It gets the value from the URL.

## Now set the data you wish to use - this can be moved to an include if you want ##
$file[0] = 'http://www.example.com/file.pdf';

## Define the functions required to update the file.
function update_file($filename, $value){
	if(is_writable($filename) &amp;&amp; is_readable($filename)){
		if(file_put_contents($filename, $value)){
			return TRUE;
		}
	}
	return NULL;
}
function pull_file($filename){
	if(is_writable($filename) &amp;&amp; is_readable($filename)){
		return file_get_contents($filename);
	}
	return NULL;
}
function rebuild_file($filename){
	if(is_writable($filename) &amp;&amp; is_readable($filename)){
		file_put_contents($filename, '1');
	}
}

if(is_numeric($_GET['ID'])){ // Meaning the Data sent is safe.

	// Build log file URL
	$filename = LOG_URL.$_GET['ID'].'.log.txt';
	$value = pull_file($filename);

	header('location:'.$file[$_GET['ID']]);

	// Update logs
	if(is_numeric($value)){
		update_file($filename, ($value+1));
	} else { // Meaning the file does not exist or has been messed with.
		rebuild_file($filename);
	}
} else {
	echo 'Sorry, there was an error.';
}

/* If you want to see how many people have downloaded a file, run something like:
# pull_file(LOG_URL.numberishere.'.log.txt');
/*

You are free to share, modify and use this code for commercial uses. Please give a link back (to http://www.fullondesign.co.uk/ ) if you can, but you don't have you.

I claim no liability for this code, you use it at your own risk.

*/

?&gt;</pre>
<p>You can run this by changing the URL that accesses the file. For example:<br />
<em>file.php?ID=0</em></p>
<p>Feel free to edit and share this code.<br class="spacer_" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fullondesign.co.uk/coding/php/770-simple-php-download-counter.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>5 Tips for Coding Cleaner PHP</title>
		<link>http://www.fullondesign.co.uk/coding/php/616-5-tips-for-coding-cleaner-php.htm</link>
		<comments>http://www.fullondesign.co.uk/coding/php/616-5-tips-for-coding-cleaner-php.htm#comments</comments>
		<pubDate>Mon, 06 Apr 2009 19:20:25 +0000</pubDate>
		<dc:creator>Rogem</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[braces]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[fulgy code]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[tips variables]]></category>
		<category><![CDATA[white space]]></category>

		<guid isPermaLink="false">http://www.fullondesign.co.uk/?p=616</guid>
		<description><![CDATA[PHP is lovely, though if you ever work with other people having good code is important. Here are some tips to improve your code. Comment &#38; Document It’s really important that people understand why you are doing certain things in certain ways. Adding a quick comment above sections of code should be adequate, but documenting [...]]]></description>
			<content:encoded><![CDATA[<p>PHP is lovely, though if you ever work with other people having good code is important. Here are some tips to improve your code.</p>
<h3>Comment &amp; Document</h3>
<p>It’s really important that people understand why you are doing certain things in certain ways. Adding a quick comment above sections of code should be adequate, but documenting classes and functions (Even if it’s in a Wiki) is fantastic.</p>
<h3>Give Variables, Functions and Classes Meaningful names</h3>
<p>Nothing is worse than trying to figure out what a function called &#8220;SIDFE()&#8221; does. Give everything a name that if someone else looked at it, they could figure out what it does. The above is a real example I have come across while adjusting a clients website, if the other programmer had called it something like Scan_Incomming_Data_For_Evil() it would have been a lot more straightforward.</p>
<h3>White space</h3>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-633" title="White Space, Good VS Bad" src="http://www.fullondesign.co.uk/wp-content/uploads/2009/04/whitespace.png" alt="whitespace" width="400" height="300" /><em>As you can see, a little space here and there makes life a lot easier.</em></p>
<p>No one likes to have to search for the start of a function. Make sure you indent your code and keep it easy to read quickly.</p>
<h3>Never Delete &#8211; Comment out</h3>
<p>This one is a little hard to grasp, but imagine you just fixed a bug (say 100 lines of code to fix it) and something else has broken. It makes sense to be able to go back and see the old code without modification of the new code. Also, doing this helps people see where an old bug was (assuming you comment that the section of code is evil) for future reference.</p>
<h3>Use Braces</h3>
<p>Braces are those neat } and { things. If you don’t use them on various functions it’s a pain to figure out where a loop starts and finishes. This is especially important when programming on a large scale because no one likes debugging fugly code. Here is an example of good and bad code:</p>
<pre class="brush: php; title: ; notranslate">&lt;?php
/* Examples of annoying code */
if ( $coder === 'Silly' ) bang_head(); 

while ( $coder === 'Silly' )
    bang_head();

/* Examples of good code*/
if ( $coder !== 'Silly' ){ Drink_Beer(); }

while ( $coder !== 'Silly' ){
    Drink_Beer();
}
?&gt;</pre>
<p><span id="more-616"></span></p>
<h3>Useful Links</h3>
<p><a href="http://tech.forumone.com/archives/46-Tips-to-write-readable-PHP-code.html">PHP coding guidelines</a><br />
<a href="http://www.smashingmagazine.com/2009/03/24/10-useful-php-tips-revisited/">10 Useful PHP Tips Revisited</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fullondesign.co.uk/coding/php/616-5-tips-for-coding-cleaner-php.htm/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Displaying Recent Tweets via Twitter&#8217;s RSS</title>
		<link>http://www.fullondesign.co.uk/coding/php/597-displaying-recent-tweets-via-the-twitter-api.htm</link>
		<comments>http://www.fullondesign.co.uk/coding/php/597-displaying-recent-tweets-via-the-twitter-api.htm#comments</comments>
		<pubDate>Wed, 01 Apr 2009 21:56:29 +0000</pubDate>
		<dc:creator>Rogem</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[recent tweets]]></category>
		<category><![CDATA[twitter api]]></category>

		<guid isPermaLink="false">http://www.fullondesign.co.uk/?p=597</guid>
		<description><![CDATA[Twitter has sprung to fame in the last few months, mostly thanks to its fantastic API. Here is a really quick and easy way to display your recent tweets on your website. Edit: This only works for Twitterers who have privacy settings open (thanks Dan from XDnet.co.uk for the heads up).]]></description>
			<content:encoded><![CDATA[<p>Twitter has sprung to fame in the last few months, mostly thanks to its fantastic API. Here is a really quick and easy way to display your recent tweets on your website.</p>
<pre class="brush: php; title: ; notranslate">&lt;?php # File created on  1st April 2009 by Mike Rogers (http://www.fullondesign.co.uk/).
/*
function - recent_tweets(string $username [, int $limit = 5])
	$username - Your twitter username, such as rogem002
	$limit - Default: 5 - how many tweets you wish to show, must be numeric.
*/

function recent_tweets($username, $limit=5){
	if(!is_numeric($limit)){$limit = 5;}
	$xml = simplexml_load_file('http://search.twitter.com/search.atom?q=from%3A'.urlencode($username));
	$items_count= count($xml-&gt;entry);
	if($items_count &lt; $limit){$limit = $items_count;}
	$i = 0;
	$return .= '
&lt;ul&gt;';
	while($i &lt; $limit){
		$return .= '
&lt;li title=&quot;'.$xml-&gt;entry[$i]-&gt;title.'&quot;&gt;&lt;!-- '.$xml-&gt;entry[$i]-&gt;published.' --&gt;'.$xml-&gt;entry[$i]-&gt;content.'&lt;/li&gt;

';
		$i++;
	}
	$return .=  '&lt;/ul&gt;

';

	return $return;
}

echo recent_tweets('rogem002', 5);

/*
You are free to share, modify and use this code for commercial  uses. Please give a link back (to http://www.fullondesign.co.uk/ ) if you can, but you don't have you.
*/
?&gt;</pre>
<p><em>Edit: This only works for Twitterers who have privacy settings open (thanks Dan from <a href="http://xdnet.co.uk/">XDnet.co.uk</a> for the heads up).</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fullondesign.co.uk/coding/php/597-displaying-recent-tweets-via-the-twitter-api.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Basic PHP Security</title>
		<link>http://www.fullondesign.co.uk/coding/security/571-basic-php-security.htm</link>
		<comments>http://www.fullondesign.co.uk/coding/security/571-basic-php-security.htm#comments</comments>
		<pubDate>Fri, 27 Mar 2009 22:02:59 +0000</pubDate>
		<dc:creator>Rogem</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[preg]]></category>
		<category><![CDATA[sessions]]></category>

		<guid isPermaLink="false">http://www.fullondesign.co.uk/?p=571</guid>
		<description><![CDATA[Saying &#8220;Don&#8217;t trust your users&#8221; would be a little over statement, but in the world of programming it&#8217;s the best mindset. Here are some really basic tips for programming in general (but mostly focusing on PHP). Validate All Input It&#8217;s very important to check all input to your script; a client could accidentally put a [...]]]></description>
			<content:encoded><![CDATA[<p>Saying &#8220;Don&#8217;t trust your users&#8221; would be a little over statement, but in the world of programming it&#8217;s the best mindset. Here are some really basic tips for programming in general (but mostly focusing on PHP).</p>
<h3>Validate All Input</h3>
<p>It&#8217;s very important to check all input to your script; a client could accidentally put a semi-colon in a field and possibly break your code. Always check that the user is posting what you expect. Here are some simple methods to validate input.</p>
<pre class="brush: php; title: ; notranslate">&lt;?php
// Input must be a number
if(is_numeric($input)){
	echo 'Input is a number';
} else {
	echo 'Input is not a number';
}

// Input can only contain numbers and letters.
if(preg_match('/([^A-z0-9])/', $input)){
	echo 'Input does not contain only numbers and letters.';
} else {
	echo 'Input contains only numbers and letters.';
}

// Input must be an email
if(preg_match('/^([a-zA-Z0-9])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/', $input)){
	echo 'Email Is Valid.';
} else {
	echo 'Email Is Invalid.';
}
?&gt;</pre>
<h3>Hash Passwords</h3>
<p><a href="http://www.fullondesign.co.uk/coding/php/490-securing-passwords-in-php.htm">Hashing passwords</a> is mostly important from a privacy view point; if a hacker gets in they could sell your users details.</p>
<h3>Use Sessions, not cookies</h3>
<p>Never set sensitive data in cookies, users could edit them and potentially cause problems on your website. Instead use Sessions; they are a server side solution which is a little more secure.</p>
<pre class="brush: php; title: ; notranslate">&lt;?php
session_start(); // Start the session. Always put this at the top of your html.

// Set some sessions
$_SESSION['name'] = 'Example 1';

// echo session data
echo $_SESSION['name'];
// Would return Example 1
?&gt;</pre>
<p><span id="more-571"></span></p>
<h3>Related Links</h3>
<p><a href="http://www.amazon.co.uk/gp/product/0672329166?ie=UTF8&amp;tag=fulondes-21&amp;linkCode=as2&amp;camp=1634&amp;creative=19450&amp;creativeASIN=0672329166">PHP and MySQL Web Development (Developer&#8217;s Library)</a><br />
 <a href="http://www.webcheatsheet.com/php/regular_expressions.php">Using Regular Expressions with PHP</a><br />
 <a href="http://www.smashingmagazine.com/2008/11/18/10-advanced-php-tips-to-improve-your-progamming/">10 Advanced PHP Tips To Improve Your Programming</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fullondesign.co.uk/coding/security/571-basic-php-security.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Securing Passwords in PHP</title>
		<link>http://www.fullondesign.co.uk/coding/php/490-securing-passwords-in-php.htm</link>
		<comments>http://www.fullondesign.co.uk/coding/php/490-securing-passwords-in-php.htm#comments</comments>
		<pubDate>Tue, 17 Mar 2009 21:59:51 +0000</pubDate>
		<dc:creator>Rogem</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[hashing]]></category>
		<category><![CDATA[md5]]></category>
		<category><![CDATA[privacy]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.fullondesign.co.uk/?p=490</guid>
		<description><![CDATA[Privacy on your website will be paramount to your success. In the world of application development, security can sometimes be overlooked (normally because accessibility is considered more important). Luckily, modern theories in coding mean we now can now be accessible and secure. Hashing is a really simple technique to hide data using a one way [...]]]></description>
			<content:encoded><![CDATA[<p>Privacy on your website will be paramount to your success. In the world of application development, security can sometimes be overlooked (normally because accessibility is considered more important). Luckily, modern theories in coding mean we now can now be accessible and secure.</p>
<p>Hashing is a really simple technique to hide data using a one way encryption. It’s especially necessary when dealing with users passwords (In a recent study, 60% of respondents use a similar passwords). Here is an example of how to hash using the <a href="http://uk2.php.net/manual/en/function.md5.php">MD5</a> function:</p>
<pre class="brush: php; title: ; notranslate">&lt;?php
$password = md5('password');
// $password will now return 5f4dcc3b5aa765d61d8327deb882cf99
?&gt;</pre>
<p>However, we can improve on this code. Many hackers now use <a href="http://en.wikipedia.org/wiki/Rainbow_table">Rainbow tables</a> to reverse the one-way encryption (and thus find out the secret data). Luckily programmers have come up with a new technique to combat this…Adding a pinch of salt to a hash. In programming terms, a salt is essentially an extra piece of information we add to what the user input to make it unusual. Here is an example how to code this:</p>
<pre class="brush: php; title: ; notranslate">&lt;?php
$salt = '%$£Salt_Here*(&amp;^';
$password = md5('password'.$salt);
// $password will now return 5747563a265df7a3250884394c0a05e0
?&gt;</pre>
<h3>Related Posts</h3>
<p><a href="http://phpsec.org/articles/2005/password-hashing.html">PHP Security Consortium: Password Hashing</a><br />
 <a href="http://www.amazon.co.uk/gp/product/059600656X?ie=UTF8&amp;tag=fulondes-21&amp;linkCode=as2&amp;camp=1634&amp;creative=19450&amp;creativeASIN=059600656X">Essential PHP Security</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fullondesign.co.uk/coding/php/490-securing-passwords-in-php.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Securing publicly available folders</title>
		<link>http://www.fullondesign.co.uk/coding/security/304-securing-publicly-available-folders.htm</link>
		<comments>http://www.fullondesign.co.uk/coding/security/304-securing-publicly-available-folders.htm#comments</comments>
		<pubDate>Mon, 23 Feb 2009 20:48:03 +0000</pubDate>
		<dc:creator>Rogem</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[stop hackers]]></category>

		<guid isPermaLink="false">http://www.fullondesign.co.uk/?p=304</guid>
		<description><![CDATA[Anyone who has ever developed a website which allows users to upload files will tell you &#8220;It&#8217;s best to think everyone is out to destroy your server&#8221;, which unfortunately is the best mindset to be in when setting up any website. One of the main methods used to by hackers to breach security on your [...]]]></description>
			<content:encoded><![CDATA[<p>Anyone who has ever developed a website which allows users to upload files will tell you &#8220;It&#8217;s best to think everyone is out to destroy your server&#8221;, which unfortunately is the best mindset to be in when setting up any website. One of the main methods used to by hackers to breach security on your website is to upload a file which allows them to execute code.</p>
<p>Here is a very quick and easy solution to stop potential hackers executing files in certain folders.</p>
<p>Open the .htaccess file in the folder you wish to protect and add the following code:</p>
<p><code>Options -Indexes <br />
 Options -ExecCGI <br />
 AddHandler cgi-script .php .php3 .php4 .phtml .pl .py .jsp .asp .htm .shtml .sh .cgi </code></p>
<p>This will essentially stop the folders returning an index of what is inside them and stop various files from running.</p>
<p><strong>Useful Links</strong></p>
<p><a href="http://www.mysql-apache-php.com/fileupload-security.htm" target="_blank">PHP File Upload Security</a><br />
 <a href="http://httpd.apache.org/docs/2.0/howto/htaccess.html" target="_blank">Apache Tutorial: .htaccess files</a><br />
 <a href="http://www.amazon.co.uk/gp/product/0764549693?ie=UTF8&amp;tag=fulondes-21&amp;linkCode=as2&amp;camp=1634&amp;creative=19450&amp;creativeASIN=0764549693">Apache, MySQL, and PHP Web Development All-in-one Desk Reference for Dummies</a><img style="border:none !important; margin:0px !important;" src="http://www.assoc-amazon.co.uk/e/ir?t=fulondes-21&amp;l=as2&amp;o=2&amp;a=0764549693" border="0" alt="" width="1" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fullondesign.co.uk/coding/security/304-securing-publicly-available-folders.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: basic
Database Caching 1/41 queries in 0.035 seconds using disk: basic
Object Caching 629/750 objects using disk: basic

Served from: www.fullondesign.co.uk @ 2012-02-04 08:14:10 -->
