<?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>Ross Tanner</title>
	<atom:link href="http://rosstanner.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://rosstanner.co.uk</link>
	<description>Web Developer Gloucestershire</description>
	<lastBuildDate>Tue, 14 Feb 2012 12:00:44 +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>Google UK Easter Egg &#8211; Hello to Jason Isaacs</title>
		<link>http://rosstanner.co.uk/2012/02/google-uk-easter-egg-hello-to-jason-isaacs/</link>
		<comments>http://rosstanner.co.uk/2012/02/google-uk-easter-egg-hello-to-jason-isaacs/#comments</comments>
		<pubDate>Tue, 14 Feb 2012 11:42:04 +0000</pubDate>
		<dc:creator>Ross Tanner</dc:creator>
				<category><![CDATA[Search Engines]]></category>
		<category><![CDATA[bbc]]></category>
		<category><![CDATA[daniel radcliffe]]></category>
		<category><![CDATA[danny dyer]]></category>
		<category><![CDATA[david tennant]]></category>
		<category><![CDATA[easter egg]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[harry potter]]></category>
		<category><![CDATA[jason isaacs]]></category>
		<category><![CDATA[matt kermode]]></category>
		<category><![CDATA[michael sheen]]></category>
		<category><![CDATA[radio 5 live]]></category>
		<category><![CDATA[simon mayo]]></category>

		<guid isPermaLink="false">http://rosstanner.co.uk/?p=364</guid>
		<description><![CDATA[<p>Anyone who has performed a search for &#8220;<a title="Hello to Jason Isaacs" href="http://www.google.co.uk/?q=jason+isaacs#hl=en&#38;output=search&#38;sclient=psy-ab&#38;q=jason+isaacs&#38;pbx=1&#38;oq=&#38;aq=&#38;aqi=&#38;aql=&#38;gs_sm=&#38;gs_upl=&#38;bav=on.2,or.r_gc.r_pw.r_qf.,cf.osb&#38;fp=28b479b56846d329&#38;biw=1680&#38;bih=935" target="_blank">Jason Isaacs</a>&#8221; on <a title="Google UK - Hello to Jason Isaacs" href="http://www.google.co.uk/?q=jason+isaacs" target="_blank">Google.co.uk</a> will have already seen this. Those who haven&#8217;t heard <a title="BBC Radio 5 Live - Film Review Show" href="http://www.bbc.co.uk/programmes/b00lvdrj" target="_blank">BBC Radio 5 Live&#8217;s Film Review Show</a> in a while [...]]]></description>
			<content:encoded><![CDATA[<p>Anyone who has performed a search for &#8220;<a title="Hello to Jason Isaacs" href="http://www.google.co.uk/?q=jason+isaacs#hl=en&amp;output=search&amp;sclient=psy-ab&amp;q=jason+isaacs&amp;pbx=1&amp;oq=&amp;aq=&amp;aqi=&amp;aql=&amp;gs_sm=&amp;gs_upl=&amp;bav=on.2,or.r_gc.r_pw.r_qf.,cf.osb&amp;fp=28b479b56846d329&amp;biw=1680&amp;bih=935" target="_blank">Jason Isaacs</a>&#8221; on <a title="Google UK - Hello to Jason Isaacs" href="http://www.google.co.uk/?q=jason+isaacs" target="_blank">Google.co.uk</a> will have already seen this. Those who haven&#8217;t heard <a title="BBC Radio 5 Live - Film Review Show" href="http://www.bbc.co.uk/programmes/b00lvdrj" target="_blank">BBC Radio 5 Live&#8217;s Film Review Show</a> in a while probably won&#8217;t understand what this actually means. Have a quick search using the link above then come back to read what this means or just check out the screen grab below.</p>
<div id="attachment_368" class="wp-caption aligncenter" style="width: 600px"><a href="http://rosstanner.co.uk/wp-content/uploads/2012/02/hello-to-jason-isaacs.jpg"><img class="size-full wp-image-368" title="Hello to Jason Isaacs" src="http://rosstanner.co.uk/wp-content/uploads/2012/02/hello-to-jason-isaacs.jpg" alt="Hello to Jason Isaacs" width="590" height="368" /></a><p class="wp-caption-text">Hello to Jason Isaacs - Google UK search</p></div>
<p>The story is that on one day live on air <a title="Simon Mayo" href="http://en.wikipedia.org/wiki/Simon_Mayo" target="_blank">Simon Mayo</a> (radio presenter) and <a title="Matt Kermode" href="http://en.wikipedia.org/wiki/Mark_Kermode" target="_blank">Matt Kermode</a> (film critic) decided to say &#8220;Hello&#8221; to one of Mark&#8217;s school friends, <a href="http://en.wikipedia.org/wiki/Jason_Isaacs" target="_blank">Jason Isaacs</a> (Harry Pitter film actor &#8211; Lucius Malfoy), live on their <a title="Matt Kermods and Simon Mayo's Film Review Show" href="http://en.wikipedia.org/wiki/Kermode_and_Mayo%27s_Film_Reviews" target="_blank">film review show</a>. Since then the duo have said &#8220;Hello&#8221; to a number of film actors such as <a title="Michael Sheen" href="http://en.wikipedia.org/wiki/Michael_Sheen" target="_blank">Michael Sheen</a>, <a title="David Tennant" href="http://en.wikipedia.org/wiki/David_tennant" target="_blank">David Tennant</a> and <a title="Danny Dyer" href="http://en.wikipedia.org/wiki/Danny_Dyer" target="_blank">Danny Dyer</a>. The simple yet effective slogan is shouted out whether Isaacs is on the show or not and has became a hit with many listeners. Jason has said himself that he replies with &#8220;Hello boys!&#8221; wherever he is in the world.</p>
<p>On the most recent show <a title="Harry Potter" href="http://en.wikipedia.org/wiki/Harry_Potter" target="_blank">Harry Potter</a> actor <a title="Daniel Radcliffe" href="http://en.wikipedia.org/wiki/Daniel_Radcliffe" target="_blank">Daniel Radcliffe</a> said &#8220;Hello to Jason Isaacs&#8221; and threw in a couple of personal comments for good measure, some not so good. To say it was slightly awkward was an understatement. However, the comedic side of the conversation has helped boost the hit and has spread very quickly across social media platforms.</p>
<p>There has even been a website created for it (<a title="Hello to Jason Isaacs" href="http://www.hellotojasonisaacs.com/">http://www.hellotojasonisaacs.com/</a>), you can buy numerous novelty items around the internet and of course Google has, as ever, joined in with a good sense of humour. It&#8217;s good to see these kind of easter eggs thrown in by Google, especially on St. Valentine&#8217;s Day. I wonder if the programmer who added this result into the search page actually had it signed off? Who knows (nobody probably). This only works on Google UK though, so check you aren&#8217;t on Google.com when looking for it.</p>
]]></content:encoded>
			<wfw:commentRss>http://rosstanner.co.uk/2012/02/google-uk-easter-egg-hello-to-jason-isaacs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &amp; SEO &#8211; Permanent redirect using PHP header &#8211; HTTP 301</title>
		<link>http://rosstanner.co.uk/2012/01/php-seo-permanent-redirect-php-header/</link>
		<comments>http://rosstanner.co.uk/2012/01/php-seo-permanent-redirect-php-header/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 11:16:54 +0000</pubDate>
		<dc:creator>Ross Tanner</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[googlebot]]></category>
		<category><![CDATA[http 301]]></category>
		<category><![CDATA[permanent redirect]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[redirect]]></category>
		<category><![CDATA[rosstanner]]></category>
		<category><![CDATA[search engine optimisation]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[seo friendly]]></category>
		<category><![CDATA[web development gloucestershire]]></category>

		<guid isPermaLink="false">http://rosstanner.co.uk/?p=355</guid>
		<description><![CDATA[<p>Permanent redirects are an important tool not only for general PHP development but also for Search Engine Optimisation. To a general user the browser simply forwards on to the new URL, probably without you even noticing. To search engine crawlers they are also forwarded but provided extra information that the page they are visiting has [...]]]></description>
			<content:encoded><![CDATA[<p>Permanent redirects are an important tool not only for general PHP development but also for Search Engine Optimisation. To a general user the browser simply forwards on to the new URL, probably without you even noticing. To search engine crawlers they are also forwarded but provided extra information that the page they are visiting has permanently moved to the new address. If this was Google for example, Googlebot would notice the change and drop the old URL from it&#8217;s index and begin indexing the new one.</p>
<p>So, what&#8217;s the point in a 301 permanent redirect and how does it differ to a standard redirect? If you needed to change the way a URL is structured from, for example, index.php?page=1 (very non-SEO friendly) to /web-development-gloucestershire/ (SEO friendly) then you can inform search engines of the change. Without the permanent redirect the first page will either fail and produce a &#8217;404 Not Found&#8217; or be identical to the new page &#8211; thus causing duplicate content issues.</p>
<p>The permanent redirect differs from a standard redirect because of the way it is informing search engines of the change. Without this it would become a temporary redirect or standard redirect. This means that search engines will keep the original page in it&#8217;s index because it is expecting the redirect to be removed at some point soon.</p>
<p>To create a 301 permanent redirect in PHP you use the following two lines of code, it&#8217;s really that easy.</p>
<pre name="code" class="php">&lt;?php
    header('HTTP/1.1 301 Moved Permanently');
    header('http://rosstanner.co.uk/');
?&gt;</pre>
<p>Remember, this must be placed at the very top of the script. More specifically, before any HTML content or output is produced. This is because PHP uses the headers, which are called before any output, in order to complete the redirect.</p>
<p><strong>Is there a limit on how many 301 redirects I can use on my website?</strong></p>
<p>In short the answer is no, there isn&#8217;t a limit. However there is a limit on &#8216;chained redirects&#8217; as Matt Cutts from Google explains.</p>
<hr />
<center><iframe width="560" height="315" src="http://www.youtube.com/embed/r1lVPrYoBkA" frameborder="0" allowfullscreen></iframe></center></p>
<hr />
<p>If you are running an Apache server you can achieve this using .htaccess too. If you don&#8217;t have access to edit this file within your online files then consult your webmaster.</p>
]]></content:encoded>
			<wfw:commentRss>http://rosstanner.co.uk/2012/01/php-seo-permanent-redirect-php-header/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The &#8216;Your SIM card has a name&#8217; Facebook trick</title>
		<link>http://rosstanner.co.uk/2012/01/the-your-sim-card-has-a-name-facebook-trick/</link>
		<comments>http://rosstanner.co.uk/2012/01/the-your-sim-card-has-a-name-facebook-trick/#comments</comments>
		<pubDate>Sat, 14 Jan 2012 11:52:19 +0000</pubDate>
		<dc:creator>Ross Tanner</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Social Media]]></category>
		<category><![CDATA[cell phone]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[facebook scams]]></category>
		<category><![CDATA[facebook trick]]></category>

		<guid isPermaLink="false">http://rosstanner.co.uk/?p=345</guid>
		<description><![CDATA[<p>You may have recently seen on Facebook a lot of people posting a &#8216;trick&#8217; that they have discovered/seen whereby posting a short snippet of code reveals the &#8216;name&#8217; of your cell phone or SIM card based on the last three digits of your phone number. Whilst this does produce a name it is totally unrelated [...]]]></description>
			<content:encoded><![CDATA[<p>You may have recently seen on Facebook a lot of people posting a &#8216;trick&#8217; that they have discovered/seen whereby posting a short snippet of code reveals the &#8216;name&#8217; of your cell phone or SIM card based on the last three digits of your phone number. Whilst this does produce a name it is totally unrelated to your mobile number.</p>
<p>Here is the trick that you would have seen and probably tried since you are here reading about it.</p>
<hr />
<code>Every SIM CARD has a name. Try this:</p>
<p>1st step : from your mobile number number, take the last 3 numbers. Example-07800 969684, take "684"only</p>
<p>2nd step: Write this @*[684:0] in the comment box below, replacing the 3 numbers with your own.</p>
<p>3rd step: remove the * sign and press enter in the comment box</code></p>
<hr />
Due to the way telephone numbers are generated, more than one person can have the same last 3 digits. Therefore claiming your unique phone number has it&#8217;s own name is nonsense.</p>
<p>So how is this happening? Basically the number you provide corresponds to an actual user&#8217;s ID on Facebook. It is not limited to three characters either. The code you enter into the comment box is a Facebook short-hand code that converts an ID number into it&#8217;s corresponding name. If you were to enter the code <code>@[4:0]</code> then this will present back &#8216;Mark Zuckerberg&#8217; since he was the first ID to use the website (1-3 were used for testing I believe). By using just three digits you are picking a random Harvard student who were the first users of the social networking site. You can even check this by going to the following URL and replacing <strong>123</strong> with the number that you are using.</p>
<p>http://www.facebook.com/profile.php?id=<strong>123</strong></p>
<p>Although the code works and is perhaps fun to use it is in no way related to a cell phone, mobile phone, SIM card or anything similar. It isn&#8217;t dangerous either (virus or spyware) so use it to your heart&#8217;s content.</p>
]]></content:encoded>
			<wfw:commentRss>http://rosstanner.co.uk/2012/01/the-your-sim-card-has-a-name-facebook-trick/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>PHP Tutorial &#8211; Get your Twitter statuses</title>
		<link>http://rosstanner.co.uk/2012/01/php-tutorial-twitter-statuses/</link>
		<comments>http://rosstanner.co.uk/2012/01/php-tutorial-twitter-statuses/#comments</comments>
		<pubDate>Wed, 11 Jan 2012 00:01:01 +0000</pubDate>
		<dc:creator>Ross Tanner</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[hash tags]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[REST API]]></category>
		<category><![CDATA[social media]]></category>
		<category><![CDATA[social networking]]></category>
		<category><![CDATA[trends]]></category>
		<category><![CDATA[tweet]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://rosstanner.co.uk/?p=320</guid>
		<description><![CDATA[<p><a href="http://twitter.com/" target="_blank">Twitter</a> has fast become one of the most powerful social media platforms along with it&#8217;s great rival <a href="http://www.facebook.com/" target="_blank">Facebook</a> and the newcomer to the scene &#8211; <a href="http://plus.google.com" target="_blank">Google+</a>. Twitter is easily the best platform for companies and people &#8220;looking to be found&#8221; due to it&#8217;s potential reach. The hash tags, trends [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://twitter.com/" target="_blank">Twitter</a> has fast become one of the most powerful social media platforms along with it&#8217;s great rival <a href="http://www.facebook.com/" target="_blank">Facebook</a> and the newcomer to the scene &#8211; <a href="http://plus.google.com" target="_blank">Google+</a>. Twitter is easily the best platform for companies and people &#8220;looking to be found&#8221; due to it&#8217;s potential reach. The hash tags, trends and search functionality makes it possible for one person in England to see the tweets of someone in Venezuela (most random country I could think of!). This wouldn&#8217;t be possible with Facebook due to it&#8217;s networking &#8220;restrictions&#8221; and also you may have to be friends with that person first. Facebook also exposes A LOT more personal information making Twitter by far the better platform for promoting blog posts, discussing trends and communicating with other people in your niche market.</p>
<p>Having a section on your website with your tweets or even tweets from every employee in your company is becoming a very popular choice amongst web builders and agencies. It aids with the promotion of your Twitter accounts and opens an extra contact avenue for potential clients. It is much easier to build than many people think too &#8211; a simple call to the <a href="https://dev.twitter.com/docs" target="_blank">Twitter API</a> and you can even bypass database interaction if this is something that would make you have doubts.</p>
<p>I strongly suggest using a database though and run a &#8220;tweet loader&#8221; in the background &#8211; perhaps on a scheduled task &#8211; then display the tweets on the page to the user directly from the database. From this you could even cache the results to prevent heavy load on your own and Twitter&#8217;s servers. This not only increases load time of your web pages but you could take things a step further and implement a bad word / swear word filter and alter the accounts displayed on-the-fly.</p>
<p>The first step is to decide which Twitter accounts that you want to get the tweets for. I suggest starting with just one account and expaning how and when you wish at a later date. For the sake of this tutorial I will use just one account although adapting this for multiple accounts should be pretty obvious to you once we are done here. A simple line of code to start the procedure can be seen below where I just define the username that I want to query for. Always leave out the &#8220;@&#8221; symbol at the front of the username.</p>
<pre name="code" class="php">
&lt;?php

    // define the account username
    $account = "rossytzoltan";

?&gt;
</pre>
<p>The next step would be to set up the Twitter API integration. We will query Twitter&#8217;s REST API for statuses for this username by sending the request to a specified URL with the parameters attached. The Twitter API can be accessed at the following location:</p>
<p><code></p>
<p>http://api.twitter.com/</p>
<p></code></p>
<p>To start the integration we will define the path to the REST API and then the request that we wish to send. I have split this into two variables although you are within your rights to merge this into one. For simplicity I have split them into <em>$path</em> and <em>$request</em> as they essentially indicate two seperate things.</p>
<pre name="code" class="php">
&lt;?php

// define the path to the feed of tweets
$path = "http://api.twitter.com/1/statuses/user_timeline.xml";

// set the request for the API
$request = "?include_rts=true&#038;screen_name=".$account."&#038;count=5";

?&gt;
</pre>
<p>There are many more options that can be used in the <em>$request</em> but I have just used the ones needed which are:</p>
<ul>
<li><strong>include_rts</strong> &#8211; boolean &#8211; whether or not to display retweets in the status list.
<li><strong>screen_name</strong> &#8211; string &#8211; the Twitter account.
<li><strong>count</strong> &#8211; integer &#8211; the amount of tweets to grab.
</ul>
<p>Now that we have defined our path and request we can merge these together into one URL and query the API. As the response from the API will be in <a href="http://www.w3.org/XML/" title="XML" target="_blank">XML (eXtensible Markup Language)</a> we will use <a href="http://php.net/manual/en/book.simplexml.php" title="SimpleXML" target="_blank">SimpleXML</a> to format this response into an object ready to use. Here is how this is achieved:</p>
<pre name="code" class="php">
&lt;?php

// get the response from the API as an object
$tweet_list = simplexml_load_file($path.$request);

?&gt;
</pre>
<p>If you were to <em>print_r()</em> the <em>$tweet_list</em> variable then you will see exactly what is contained in the data. At the time of writing this article (11th January 2012) there are only three nodes in each tweet that we are going to need in order to set this up which are the actual tweet text, the time and date of which the tweet was submitted and the profile image for the user who tweeted. By using just these three items we can display our latest tweets on our website without cluttering it up. In order to get these three items though we need to loop through the tweets contained in the object then pull them out ready for use.</p>
<pre name="code" class="php">
&lt;?php

// check for Twitter posts
if ( count ( $tweet_list ) > 0 ) {

    // define the array of tweets
    $tweets = array();

    // loop through each Twitter post
    foreach ( $tweet_list as $tweet ) {

        // add the tweet to the array of tweets
        $tweets[] = array (
            'tweet'    =>    (string) $tweet->text,
            'posted'   =>    (string) $tweet->created_at,
            'image'    =>    (string) $tweet->user->profile_image_url
        );

    }

    // output how many tweets were loaded
    echo count($tweets)." were found.";

} else {

    // output a message to show no tweets found
    echo "No tweets were found.";

}

?&gt;
</pre>
<p>That&#8217;s it you have successfully queried the Twitter API, retrieved the tweets and stored them into the <em>$tweets</em> array ready to be used. If you wanted to take it a step further and display them then here is the full code with @username and link replacing plus a bit of styling thrown in for good measure.</p>
<pre name="code" class="php">
&lt;?php

	// define the account username
    $account = &quot;rossytzoltan&quot;;  

	// define the path to the feed of tweets
	$path = &quot;http://api.twitter.com/1/statuses/user_timeline.xml&quot;;  

	// set the request for the API
	$request = &quot;?include_rts=true&amp;screen_name=&quot;.$account.&quot;&amp;count=5&quot;;  

	// get the response from the API as an object
	$tweet_list = simplexml_load_file($path.$request);  

	// check for Twitter posts
	if ( count ( $tweet_list ) &gt; 0 ) {  

		// define the array of tweets
		$tweets = array();  

		// loop through each Twitter post
		foreach ( $tweet_list as $tweet ) {  

			// format links to a clickable link
			$tweet-&gt;text = preg_replace(&quot;/http:\/\/([^ ]+)/i&quot;, &quot;&lt;a href=\&quot;http://$1\&quot;&gt;http://$1&lt;/a&gt;&quot;, $tweet-&gt;text);

			// format @USERNAME into a link
			$tweet-&gt;text = preg_replace(&quot;/@([^ ]+)/&quot;, &quot;&lt;a href=\&quot;http://twitter.com/$1\&quot; target=\&quot;_blank\&quot;&gt;@$1&lt;/a&gt;&quot;, $tweet-&gt;text);

			// add the tweet to the array of tweets
			$tweets[] = array (
				'tweet'    =&gt;    (string) $tweet-&gt;text,
				'posted'   =&gt;    (string) $tweet-&gt;created_at,
				'image'    =&gt;    (string) $tweet-&gt;user-&gt;profile_image_url
			);  

		}  

		// output how many tweets were loaded
		$amount_tweets = count($tweets);  

	} else {  

		// output a message to show no tweets found
		$amount_tweets = 0;

	}  

?&gt;&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
	&lt;title&gt;Load Tweets&lt;/title&gt;
    &lt;style&gt;
		ul li{list-style:none;clear:both;overflow:auto;margin-bottom:10px;}
		ul li span.img{float:left;width:48px;height:48px;background:green;}
		ul li span.tweet{float:left;margin:5px 0 0 10px;}
		ul li span.tweet span{color:#999;}
	&lt;/style&gt;
&lt;/head&gt;

&lt;body&gt;
	&lt;p&gt;&lt;strong&gt;&lt;?php echo $amount_tweets; ?&gt; tweets from &lt;a href=&quot;http://twitter.com/&lt;?php echo $account; ?&gt;&quot; target=&quot;_blank&quot;&gt;@&lt;?php echo $account; ?&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
    &lt;ul&gt;
&lt;?php 

	// loop through each available tweet
	foreach ( $tweets as $tweet ) { 

?&gt;
    	&lt;li&gt;
        	&lt;span class=&quot;img&quot;&gt;&lt;img src=&quot;&lt;?php echo $tweet['image']; ?&gt;&quot; /&gt;&lt;/span&gt;
            &lt;span class=&quot;tweet&quot;&gt;&lt;?php echo $tweet['tweet']; ?&gt;&lt;br /&gt;&lt;span&gt;&lt;?php echo $tweet['posted']; ?&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;/li&gt;
        &lt;?php } ?&gt;
    &lt;/ul&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>If you liked this tutorial and found is useful please do tweet about it or follow me <a href="http://twitter.com/rossytzoltan" target="_blank">@rossytzoltan</a> for more of the same. There is also a comments section below in case you have any praise or comments that you would like to add.</p>
]]></content:encoded>
			<wfw:commentRss>http://rosstanner.co.uk/2012/01/php-tutorial-twitter-statuses/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &amp; MySQL &#8211; Preventing MySQL Injection</title>
		<link>http://rosstanner.co.uk/2012/01/php-mysql-preventing-mysql-injection/</link>
		<comments>http://rosstanner.co.uk/2012/01/php-mysql-preventing-mysql-injection/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 00:40:39 +0000</pubDate>
		<dc:creator>Ross Tanner</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[hacker]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysql injection]]></category>
		<category><![CDATA[mysql real escape string]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://rosstanner.co.uk/?p=307</guid>
		<description><![CDATA[<p>In this tutorial I am going to explain what MySQL injection is and how important it is to prevent this attack on your database(s). It is vital that all security measures are in place before you make your website live because the effects can be devastating especially if you store sensitive data. Lets start with [...]]]></description>
			<content:encoded><![CDATA[<p>In this tutorial I am going to explain what MySQL injection is and how important it is to prevent this attack on your database(s). It is vital that all security measures are in place before you make your website live because the effects can be devastating especially if you store sensitive data. Lets start with the basics and learn what MySQL injection is.</p>
<p><strong>What is MySQL injection?</strong></p>
<p>&#8220;MySQL injection is an attack technique used to exploit applications that construct SQL statements from user-supplied input.&#8221; [<a title="SQL Injection Protection" href="http://www.cyferweb.com/blog/sql-injection-protection/" target="_blank">Cyferweb.com</a>] This statement for me sums it up perfectly. It is a way of exploiting the background SQL statement by entering specific logic to a form (or other means of user input) and then sending their own commands to control your database. This could be as simple as gaining access to an admin/user area to even deleting an entire database. When sensitive data is stored it becomes even more vital to prevent this attack else you risk losing this information into the wrong hands.</p>
<p><strong>How often does this attack occur?</strong></p>
<p>It is diffult to estimate just how many websites are suffering from these attacks but it is really dependant on the level of coding. Poor coders who don&#8217;t consider the risks of MySQL injection run the risk of losing their entire database or more importantly &#8211; a client&#8217;s database. PHP developers that put the effort it to prevent such attacks are those considered much more advanced and in the long run saving lots of important data.</p>
<p><strong>Can you show me an example of MySQL injection?</strong></p>
<p>MySQL injection is really very easy and anyone can do it. Take the following example: a user supplies a username and password to enter the administration section of a website. A poorly written login script will query the database directly for either the username, password or both without stripping/escaping each string first. Check out the code below:</p>
<pre name="code" class="php">
&lt;?php
$query = mysql_query("SELECT id FROM users WHERE username = '".$username."' AND password = '".$password."'");
?&gt;
</pre>
<p>As you can see the database is queried for a record matching the username AND the password. Now, if I was to enter my password as <strong>&#8216; OR 1=1&#8242;</strong> then this would cause the query to match 1 to 1, which is of course true &#8211; 1 does equal 1. This will result in a positive login and the hacker gaining access to a restricted area of the website. This is a very simple example of how MySQL injection can occur.</p>
<p><strong>How do I prevent MySQL injection?</strong></p>
<p>All you need to do to prevent these attacks is to ensure that you escape each item being passed into the query. Normally you wouldn&#8217;t query the users table for both the username and password but for the sake of this tutorial I will keep the query the same. The best way of going around it would be to query for the username (escaped) whilst returning the password from the table, then matching the string passed through the form with the password that is returned. That way you can match hash/salts for encrypted passwords.</p>
<p>I normally always use <strong>mysql_real_escape_string()</strong> to escape my user-inputted data because it escapes any special characters (such as <strong>&#8216; </strong>and <strong>&#8220;</strong> which are the prime cause of MySQL injection). Therefore your new query would look like this:</p>
<pre name="code" class="php">
&lt;?php
$query = mysql_query("SELECT id FROM users WHERE username = '".mysql_real_escape_string($username)."' AND password = '".mysql_real_escape_string($password)."'");
?&gt;
</pre>
<p>The password is now escaped meaning that if that same injection string was to be passed through the form, it would actually look for a password matching that instead of manipulating the query. The hacker would have no way (using MySQL injection anyway) of altering or even deleting your database.</p>
]]></content:encoded>
			<wfw:commentRss>http://rosstanner.co.uk/2012/01/php-mysql-preventing-mysql-injection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Tutorial &#8211; Connect to multiple databases with PHP and MySQL</title>
		<link>http://rosstanner.co.uk/2012/01/php-tutorial-connect-multiple-databases-php-mysql/</link>
		<comments>http://rosstanner.co.uk/2012/01/php-tutorial-connect-multiple-databases-php-mysql/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 20:39:30 +0000</pubDate>
		<dc:creator>Ross Tanner</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[connect]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[multiple databases]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysql connect]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php tutorial]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://rosstanner.co.uk/?p=302</guid>
		<description><![CDATA[<p>A nice and simple PHP tutorial today where I will show you how to connect to multiple MySQL databases at once using PHP. I&#8217;m sure when you first considered the option of multiple connections you thought it wasn&#8217;t possible, difficult to do or there is a long winded way of doing it (such as disconnecting [...]]]></description>
			<content:encoded><![CDATA[<p>A nice and simple PHP tutorial today where I will show you how to connect to multiple MySQL databases at once using PHP. I&#8217;m sure when you first considered the option of multiple connections you thought it wasn&#8217;t possible, difficult to do or there is a long winded way of doing it (such as disconnecting and re-connecting each time you want to make a query). This is untrue. All that you need to do is define a new connection and save it as a seperate resource. So, a simple one-database connection would look like this:</p>
<pre class="php">&lt;?php

    // connect to the database server
    $conn = mysql_connect("HOST", "USERNAME", "PASSWORD");

    // select the database to connect to
    mysql_select_db("DATABASE", $conn);

    // query the database
    $query = mysql_query("SELECT * FROM users", $conn);

    // close the database connection
    mysql_close($conn);

?&gt;</pre>
<p>Now if you were to have a second connection, instead of disconnecting from <strong>$conn</strong> and re-connecting as a seperate connection, you can keep the first one alive and create a second. Just like follows:</p>
<pre class="php">&lt;?php

    // connect to the database server
    $conn = mysql_connect("HOST", "USERNAME", "PASSWORD");

    // select the database to connect to
    mysql_select_db("DATABASE", $conn);

    // connect to the second database server
    $conn2 = mysql_connect("HOST", "USERNAME", "PASSWORD");

    // select the database to connect to
    mysql_select_db("DATABASE", $conn2);

    // query the first database
    $query = mysql_query("SELECT * FROM users", $conn);

    // query the second database
    $query = mysql_query("SELECT * FROM articles", $conn2);

    // close the database connections
    mysql_close($conn);
    mysql_close($conn2);

?&gt;</pre>
<p>As you can see I have two open connections and I am interacting with both databases. At the end I simply close both connections. It is as simple as that. Any questions please don&#8217;t hesitate to ask in the comments section below. Alternatively ping me a message or a tweet on Twitter &#8211; <a href="http://twitter.com/rossytzoltan" target="_blank">@rossytzoltan</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://rosstanner.co.uk/2012/01/php-tutorial-connect-multiple-databases-php-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Tutorial &#8211; Download Your Online Fifa 12 Results [PS3]</title>
		<link>http://rosstanner.co.uk/2011/12/download-your-online-fifa-12-results-playstation-3-php-tutorial/</link>
		<comments>http://rosstanner.co.uk/2011/12/download-your-online-fifa-12-results-playstation-3-php-tutorial/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 23:25:18 +0000</pubDate>
		<dc:creator>Ross Tanner</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[download fifa 12 results]]></category>
		<category><![CDATA[ea]]></category>
		<category><![CDATA[ea sports]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[fifa]]></category>
		<category><![CDATA[fifa 12]]></category>
		<category><![CDATA[imap]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php tutorial]]></category>
		<category><![CDATA[playstation]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://rosstanner.co.uk/?p=273</guid>
		<description><![CDATA[<p>Welcome to my newest tutorial &#8211; using PHP to get your latest online Fifa results which you could post on your social networking sites, put on your website (like I have at the top of my sidebar) or even create online friendship leader boards and such like.</p> <p>So, how did I achieve this? I can [...]]]></description>
			<content:encoded><![CDATA[<p>Welcome to my newest tutorial &#8211; using PHP to get your latest online Fifa results which you could post on your social networking sites, put on your website (like I have at the top of my sidebar) or even create online friendship leader boards and such like.</p>
<p>So, how did I achieve this? I can tell you first off that it requires no direct interaction with the EA or PS3 servers, but uses something much more simple.</p>
<p>Before we do anything you first need to check that the relevant PHP modules are installed on your server. If you use XAMPP as a local testing server then the most recent version (1.7.7 at time of writing) comes with everyone installed as default. The PHP module that you need is IMAP (http://www.php.net/manual/en/book.imap.php). You can check your installation details by loading up a PHP file containing the function <strong>phpinfo();</strong> like so:</p>
<pre name="code" class="php">
&lt;?php phpinfo(); ?&gt;
</pre>
<p></p>
<p>If the module is indeed installed then you should see something somewhat similar to this:</p>
<p><a href="http://rosstanner.co.uk/wp-content/uploads/2011/12/imap.jpg"><img src="http://rosstanner.co.uk/wp-content/uploads/2011/12/imap-300x60.jpg" alt="" title="IMAP PHP" width="300" height="60" class="alignleft size-medium wp-image-275" /></a></p>
<p>If you don&#8217;t see the IMAP module then you don&#8217;t have it installed. Read through the <a href="http://www.php.net/manual/en/imap.installation.php" target="_blank">installation guide on the PHP manual website</a> for instructions.</p>
<p>The next step is to go into your online settings on your Fifa 12 game. Unfortunately I only have a Playstation 3 since my Xbox had the red ring of death twice so I can only give instructions for this console. I&#8217;m sure the Xbox 360 version is fairly similar though. On the PS3 if you boot up the game then go to <strong>Online Modes</strong> > <strong>My Fifa 12 Online</strong> > <strong>Online Settings</strong> > <strong>Match Reports</strong> then ensure that <strong>Forward End-of-Game Stats</strong> is set to <strong>Yes</strong>. You will now receive match reports by email after every online game you play. We will use PHP to read your emails and then extract the match statistics ready to use. Cool, right?</p>
<p>Now comes the fun part, the development side of things. Open up a blank PHP file in the code editor of your choice. Personally I prefer <a href="http://www.adobe.com/products/dreamweaver.html" title="Adobe Dreamweaver" target="_blank">Adobe Dreamweaver</a> but that&#8217;s because I learnt using it and it&#8217;s just been perfect for my needs. Call this file something like <strong>read_mail.php</strong> because this is the script that will do all the leg-work.</p>
<p>It really depends what you want to do with the data which dictates how the script will be laid out. If we assume that the data will be inserted into a database then we can use it freely and at any time we like. With this in mind here is an example table structure:</p>
<pre name="code" class="sql">
CREATE TABLE IF NOT EXISTS `fifa` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `email_id` varchar(50) NOT NULL,
  `timestamp` int(10) NOT NULL,
  `venue` enum('Home','Away') NOT NULL,
  `opponent` varchar(30) NOT NULL,
  `result` enum('W','D','L') NOT NULL,
  `home_team` varchar(40) NOT NULL,
  `away_team` varchar(40) NOT NULL,
  `home_score` smallint(2) NOT NULL,
  `away_score` smallint(2) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 ;
</pre>
<p>The first line would of course then be the database connection. Anyone who regularly develops using this scripting language will know exactly how to do this and will know the code inside out so I&#8217;m not going into considerable detail but here is the basic way of doing it:</p>
<pre name="code" class="php">
&lt;?php

// FIFA settings
$fifa_username = "YOUR_PSN_HANDLE";

// MySQL database settings - change to suit your settings
$database = array (
"host" => "DATABASE_HOST",
"user" => "DATABASE_USERNAME",
"pass" => "DATABASE_PASSWORD",
"database" => "DATABASE_NAME"
);

// email account settings - change to suit your details
$email = array (
"host" => "EMAIL_HOST",
"user" => "EMAIL_ADDRESS",
"pass" => "EMAIL_PASSWORD",
);

// connect to the MySQL server using the settings provided
$db = mysql_connect ( $database['host'], $database['user'], $database['pass'] );

// select the database to connect to
mysql_select_db ( $database['database'] );

// array of club words (for later matching strings to club names) - add clubs as required
$club_words = array ( "Arsenal", "Chelsea", "Manchester", "United", "City", "Liverpool", "Tottenham", "PSG", "Olympique", "Lyon", "Marseille", "Milan", "AC", "Fiorentina", "Juventus", "Lazio", "Roma", "Ajax", "PSV", "Porto", "SL", "Benfica", "Celtic", "Rangers", "Real", "Madrid", "FC", "CF", "Barcelona", "Valencia", "Inter", "Bayern", "Munich", "Munchen", "München", "Argentina", "Spain", "England", "France", "Holland", "Netherlands", "Germany", "Italy", "Brazil", "Uruguay", "Portugal" );

?&gt;
</pre>
<p>
The code above simply sets the settings which we will use in the script then connects to the database. You will need to change the bits in capital letters to suit the settings of your database and email account. Again, it is very basic and doesn&#8217;t contain any error checking or connection errors. I&#8217;m not going into huge detail i&#8217;m just aiming to show you how it&#8217;s done. You will also see an array of club names. This is used because later on we split the body of the email by each word and some clubs contain two words, such as Real Madrid, FC Barcelona, Manchester United, etc.</p>
<p>The next step is to connect to our email account using the email settings provided into the array. We will also sort the emails that are found in the inbox and count them up ready for use. We do this in the following way:</p>
<pre name="code" class="php">
&lt;?php

// connect to the email account using the settings provided
$mbox = imap_open ( "{" . $email['host'] . ":143/novalidate-cert}INBOX", $email['user'], $email['pass']);

// sort the inbox list of emails by retrieval date - reversed
$sorted_mbox = imap_sort ( $mbox, SORTDATE, 1 );

// get the total amount of email messages in the inbox
$totalrows = imap_num_msg ( $mbox );

?&gt;
</pre>
<p></p>
<p>OK, so we have managed to connect to our database and our email account. Let&#8217;s not forgot to close those two connections at the end of the script otherwise we could potentially end up with lots of open connections waiting to be used. Not only will this form an eventually large queue, it could cause slowness, downtime and even affect other websites if using a shared server. Let&#8217;s not do that if we can help it. To close the connections stick the following to lines <strong>at the end of the script</strong>, bearing in mind we are about to add more code before this.</p>
<pre name="code" class="php">
&lt;?php

// close the email connection
imap_close ( $mbox );

// close the database connection
mysql_close ( $db );

?&gt;
</pre>
<p></p>
<p>The next lot of code is in a big block because we will begin looping the email messages in our inbox. We will use a simple <em>for</em> loop to do this for each item in the inbox. I have commented each line to walk you through the process but be aware this bit is quite complex due to the pattern matching and string replacing. The basics of the code below is:</p>
<ol>
<li>Loop through each email message in the inbox folder.</li>
<li>Get the email headers so that we have an ID, correct email to open (we only want the EA ones) and also a timestamp of when the email was received.</li>
<li>Check that the message contains an ID.</li>
<li>Get that ID found and save it into a variable (<em>$id</em>).</li>
<li>Pattern match against the subject to see if it contains &#8220;now see the stats!&#8221; &#8211; the generic EA match report subject.</li>
<li>Get the body content, strip tags and split it down into an easy, manageable block of text.</li>
<li>Split the list into an array of words from the string.</li>
<li>Get the timestamp that the email was received on.</li>
<li>Check whether the game was played at home or away.</li>
<li>Get the home team&#8217;s name and the opponent&#8217;s username.</li>
<li>Get the away team&#8217;s name.</li>
<li>Find out the final score of the match.</li>
<li>Query if this email record already exists in the database.</li>
<li>If it doesn&#8217;t, insert the record.</li>
</ol>
<pre name="code" class="php">
&lt;?php

// loop through each email message
for ( $i = 0; $i <= $totalrows; $i++ ) {

    // get the message headers
    $headers = @imap_fetchheader ( $mbox, $sorted_mbox[$i] );

    // check that the email message contains an ID (for unique matching)
    if ( preg_match ( "/id ([A-z0-9\-]+)/i", $headers, $matches ) ) {

        // retrieve the id that was matched in the expression
        $id = $matches[1];

	// search for an email sent with the subject required (from EA)
        if ( preg_match ( '/Subject: (.*)/m', $headers, $matches ) &#038;&#038; preg_match ( '/now see the stats!/', $matches[1] ) ) {

            // get the body of the email message and strip any HTML tags to leave us with plain text
            $body = strip_tags(imap_body ( $mbox, $sorted_mbox[$i] ));

            // split the string so that we only have a block that we can work on
            $body = substr ( $body, stripos ( $body, "H=" ), stripos ( $body, "&copy;" ) );

            // remove any new line characters
            $body = str_replace ( "\n", "", $body );

            // remove any spaces with a pipe symbol so that we can explode the string by each seperate word
            $body = preg_replace ( "/\s+/", "|", $body );

            // remove the funny characters in the string
            $body = str_replace ( "=|", "", str_replace ( "=20", "", $body ) );

            // get an array of words by exploding by the pipe - also remove blank array elements
            $items = array_filter ( explode ( "|", $body ) );

            // set the array for stats collection
            $stats = array();

            /* BEGIN DATA COLLECTION */

            // pattern match for a timestamp (when the email was received)
            preg_match ( "/t=([0-9]+)/", $headers, $matches );
	    $timestamp = $matches[1];

            // get the venue (home or away) by searching for the whereabouts of the username
            if ( $items[0] == "HOME" &#038;&#038; ( $items[2] == $fifa_username || $items[3] == $fifa_username ) ) { $stats['venue'] = "Home"; }
            else if ( ( $items[6] == "AWAY" || $items[7] == "AWAY" ) &#038;&#038; ( $items[7] == $fifa_username || $items[8] == $fifa_username || $items[9] == $fifa_username || $items[10] == $fifa_username ) ) { $stats['venue'] = "Away";	}

            // get the opponent played against
            $stats['home']['team'] = $items[1];

            // if the venue is away - get the opponent from the home side of the stats
            if ( $stats['venue'] == 'Away' ) { $stats['opponent'] = $items[2]; }

            // check if the word following the club name is also a club word (for clubs with 2 words, like FC Barcelona or Real Madrid)
            if ( in_array ( $items[2], $club_words ) ) {

                // append the second word to the club name
                $stats['home']['team'] .= ' '.$items[2];

                // check the venue is away - set the opponent as the next array element because the club name is multiple words
                if ( $stats['venue'] == 'Away' ) { $stats['opponent'] = $items[3]; }

	    }

            // loop through each array element - getting the key and the value pair
            foreach ( $items as $key => $item ) {

                // check if the current item in the loop is the away team marker
                if ( $item == 'AWAY' ) {

                    // the name of the away team must be the next element after the away team marker
                    $stats['away']['team'] = $items[($key+1)];

                    // check for the location of the venue - the opponent must be 2 (or possibly 3) items further on because the team name was after the marker
                    if ( $stats['venue'] == 'Home' ) { $stats['opponent'] = $items[($key+2)]; }

                    // check if the element following on from the club name is also part of the name (like Manchester UNITED or Inter MILAN)
                    if ( in_array ( $items[($key+2)], $club_words ) ) {

                        // if it was also part of the name, append this onto the end of the club name
                        $stats['away']['team'] .= ' '.$items[($key+2)];

                        // check the location of the venue for the opponent's username
                        if ( $stats['venue'] == 'Home' ) { $stats['opponent'] = $items[($key+3)]; }

                    }

                }

                // look for the score marker (the hyphen between 1-0, 1-2, 6-0, etc)
		if ( $item == '-' ) {

                    // the home team's score must be to the left of this marker - the away team's to the right
                    $stats['home']['score'] = (int) trim($items[($key-1)]);
                    $stats['away']['score'] = (int) trim($items[($key+1)]);

		}

                // define the result based on the score line
                if ( ( $stats['venue'] == 'Home' &#038;&#038; ( $stats['home']['score'] > $stats['away']['score'] ) ) || ( $stats['venue'] == 'Away' &#038;&#038; ( $stats['home']['score'] < $stats['away']['score'] ) ) ) { $stats['result'] = 'W'; } 

                // check for a draw?
                else if ($stats['home']['score'] == $stats['away']['score'] ) {
                    $stats['result'] = 'D';
                } 

                // else the result must have been a loss
                else { $stats['result'] = 'L'; }

	    }

            /* END DATA COLLECTION */

            /* BEGIN DATABASE INTERACTION */

            // query for this ID in the FIFA database table
            $query = mysql_query ( "SELECT id FROM fifa WHERE email_id = '".$id."' LIMIT 1", $db );

            // check if a record already exists in this table
            if ( mysql_num_rows ( $query ) < 1 ) {

                // insert the database record
                mysql_query ( "INSERT INTO fifa ( email_id, timestamp, venue, opponent, result, home_team, away_team, home_score, away_score ) VALUES ( '".$id."', ".$timestamp.", '".$stats['venue']."', '".$stats['opponent']."', '".$stats['result']."', '".$stats['home']['team']."', '".$stats['away']['team']."', '".$stats['home']['score']."', '".$stats['away']['score']."' )", $db );

            }

            /* END DATABASE INTERACTION */

        }

    }

} // end loop
?&gt;
</pre>
<p></p>
<p>The code above can be quite confusing and difficult to follow which is why I have split it down into steps above. The full, final script can be seen below:</p>
<pre name="code" class="php">
&lt;?php

// FIFA settings
$fifa_username = "YOUR_PSN_HANDLE";

// MySQL database settings - change to suit your settings
$database = array (
"host" => "DATABASE_HOST",
"user" => "DATABASE_USERNAME",
"pass" => "DATABASE_PASSWORD",
"database" => "DATABASE_NAME"
);

// email account settings - change to suit your details
$email = array (
"host" => "EMAIL_HOST",
"user" => "EMAIL_ADDRESS",
"pass" => "EMAIL_PASSWORD",
);

// connect to the MySQL server using the settings provided
$db = mysql_connect ( $database['host'], $database['user'], $database['pass'] );

// select the database to connect to
mysql_select_db ( $database['database'] );

// array of club words (for later matching strings to club names) - add clubs as required
$club_words = array ( "Arsenal", "Chelsea", "Manchester", "United", "City", "Liverpool", "Tottenham", "PSG", "Olympique", "Lyon", "Marseille", "Milan", "AC", "Fiorentina", "Juventus", "Lazio", "Roma", "Ajax", "PSV", "Porto", "SL", "Benfica", "Celtic", "Rangers", "Real", "Madrid", "FC", "CF", "Barcelona", "Valencia", "Inter", "Bayern", "Munich", "Munchen", "München", "Argentina", "Spain", "England", "France", "Holland", "Netherlands", "Germany", "Italy", "Brazil", "Uruguay", "Portugal" );

// connect to the email account using the settings provided
$mbox = imap_open ( "{" . $email['host'] . ":143/novalidate-cert}INBOX", $email['user'], $email['pass']);

// sort the inbox list of emails by retrieval date - reversed
$sorted_mbox = imap_sort ( $mbox, SORTDATE, 1 );

// get the total amount of email messages in the inbox
$totalrows = imap_num_msg ( $mbox );

// loop through each email message
for ( $i = 0; $i <= $totalrows; $i++ ) {

    // get the message headers
    $headers = @imap_fetchheader ( $mbox, $sorted_mbox[$i] );

    // check that the email message contains an ID (for unique matching)
    if ( preg_match ( "/id ([A-z0-9\-]+)/i", $headers, $matches ) ) {

        // retrieve the id that was matched in the expression
        $id = $matches[1];

	// search for an email sent with the subject required (from EA)
        if ( preg_match ( '/Subject: (.*)/m', $headers, $matches ) &#038;&#038; preg_match ( '/now see the stats!/', $matches[1] ) ) {

            // get the body of the email message and strip any HTML tags to leave us with plain text
            $body = strip_tags(imap_body ( $mbox, $sorted_mbox[$i] ));

            // split the string so that we only have a block that we can work on
            $body = substr ( $body, stripos ( $body, "H=" ), stripos ( $body, "&copy;" ) );

            // remove any new line characters
            $body = str_replace ( "\n", "", $body );

            // remove any spaces with a pipe symbol so that we can explode the string by each seperate word
            $body = preg_replace ( "/\s+/", "|", $body );

            // remove the funny characters in the string
            $body = str_replace ( "=|", "", str_replace ( "=20", "", $body ) );

            // get an array of words by exploding by the pipe - also remove blank array elements
            $items = array_filter ( explode ( "|", $body ) );

            // set the array for stats collection
            $stats = array();

            /* BEGIN DATA COLLECTION */

            // pattern match for a timestamp (when the email was received)
            preg_match ( "/t=([0-9]+)/", $headers, $matches );
	    $timestamp = $matches[1];

            // get the venue (home or away) by searching for the whereabouts of the username
            if ( $items[0] == "HOME" &#038;&#038; ( $items[2] == $fifa_username || $items[3] == $fifa_username ) ) { $stats['venue'] = "Home"; }
            else if ( ( $items[6] == "AWAY" || $items[7] == "AWAY" ) &#038;&#038; ( $items[7] == $fifa_username || $items[8] == $fifa_username || $items[9] == $fifa_username || $items[10] == $fifa_username ) ) { $stats['venue'] = "Away";	}

            // get the opponent played against
            $stats['home']['team'] = $items[1];

            // if the venue is away - get the opponent from the home side of the stats
            if ( $stats['venue'] == 'Away' ) { $stats['opponent'] = $items[2]; }

            // check if the word following the club name is also a club word (for clubs with 2 words, like FC Barcelona or Real Madrid)
            if ( in_array ( $items[2], $club_words ) ) {

                // append the second word to the club name
                $stats['home']['team'] .= ' '.$items[2];

                // check the venue is away - set the opponent as the next array element because the club name is multiple words
                if ( $stats['venue'] == 'Away' ) { $stats['opponent'] = $items[3]; }

	    }

            // loop through each array element - getting the key and the value pair
            foreach ( $items as $key => $item ) {

                // check if the current item in the loop is the away team marker
                if ( $item == 'AWAY' ) {

                    // the name of the away team must be the next element after the away team marker
                    $stats['away']['team'] = $items[($key+1)];

                    // check for the location of the venue - the opponent must be 2 (or possibly 3) items further on because the team name was after the marker
                    if ( $stats['venue'] == 'Home' ) { $stats['opponent'] = $items[($key+2)]; }

                    // check if the element following on from the club name is also part of the name (like Manchester UNITED or Inter MILAN)
                    if ( in_array ( $items[($key+2)], $club_words ) ) {

                        // if it was also part of the name, append this onto the end of the club name
                        $stats['away']['team'] .= ' '.$items[($key+2)];

                        // check the location of the venue for the opponent's username
                        if ( $stats['venue'] == 'Home' ) { $stats['opponent'] = $items[($key+3)]; }

                    }

                }

                // look for the score marker (the hyphen between 1-0, 1-2, 6-0, etc)
		if ( $item == '-' ) {

                    // the home team's score must be to the left of this marker - the away team's to the right
                    $stats['home']['score'] = (int) trim($items[($key-1)]);
                    $stats['away']['score'] = (int) trim($items[($key+1)]);

		}

                // define the result based on the score line
                if ( ( $stats['venue'] == 'Home' &#038;&#038; ( $stats['home']['score'] > $stats['away']['score'] ) ) || ( $stats['venue'] == 'Away' &#038;&#038; ( $stats['home']['score'] < $stats['away']['score'] ) ) ) { $stats['result'] = 'W'; } 

                // check for a draw?
                else if ($stats['home']['score'] == $stats['away']['score'] ) {
                    $stats['result'] = 'D';
                } 

                // else the result must have been a loss
                else { $stats['result'] = 'L'; }

	    }

            /* END DATA COLLECTION */

            /* BEGIN DATABASE INTERACTION */

            // query for this ID in the FIFA database table
            $query = mysql_query ( "SELECT id FROM fifa WHERE email_id = '".$id."' LIMIT 1", $db );

            // check if a record already exists in this table
            if ( mysql_num_rows ( $query ) < 1 ) {

                // insert the database record
                mysql_query ( "INSERT INTO fifa ( email_id, timestamp, venue, opponent, result, home_team, away_team, home_score, away_score ) VALUES ( '".$id."', ".$timestamp.", '".$stats['venue']."', '".$stats['opponent']."', '".$stats['result']."', '".$stats['home']['team']."', '".$stats['away']['team']."', '".$stats['home']['score']."', '".$stats['away']['score']."' )", $db );

            }

            /* END DATABASE INTERACTION */

        }

    }

} // end loop

// close the email connection
imap_close ( $mbox );

// close the database connection
mysql_close ( $db );

?&gt;
</pre>
<p></p>
<p>Believe it or not this is actually only pulling the basic information such as home team, away team, venue, opponent, the score and the result. The script I use is even more complex and pulls the possession percentages for each team, passing accuracy, tackling, shots (on and off target), cards (reds and yellows) and lots more.</p>
<p>You can also <a href="http://rosstanner.co.uk/wp-content/uploads/2011/12/fifa.zip" target="_blanK">download the final code here</a>. I hope this was readable enough and any problems, questions or nags you have can be posted below in the comments section.</p>
]]></content:encoded>
			<wfw:commentRss>http://rosstanner.co.uk/2011/12/download-your-online-fifa-12-results-playstation-3-php-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I&#8217;m on Skype</title>
		<link>http://rosstanner.co.uk/2011/12/im-on-skype/</link>
		<comments>http://rosstanner.co.uk/2011/12/im-on-skype/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 19:46:24 +0000</pubDate>
		<dc:creator>Ross Tanner</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[apple iPad]]></category>
		<category><![CDATA[freelance web developer]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[Skype]]></category>

		<guid isPermaLink="false">http://rosstanner.co.uk/2011/12/im-on-skype/</guid>
		<description><![CDATA[<p>As you can quite easily guess from the title of this post, I have joined Skype. I decided to expand my range of social networks by being able to join friends and networks on Skype and also for the obvious video and audio calls. I can now take part in conference calls with clients much [...]]]></description>
			<content:encoded><![CDATA[<p>As you can quite easily guess from the title of this post, I have joined Skype. I decided to expand my range of social networks by being able to join friends and networks on Skype and also for the obvious video and audio calls. I can now take part in conference calls with clients much easier than before.</p>
<p>I felt as though it was time to follow suit with the rest of the freelance web developer community who already use this service by being part of it too. I have used it in the past for personal use but I think it now suits me better to sign up from a business perspective.</p>
<p>Anyone who wants to add me you can using the username <strong>rossztanner</strong>. Skype away!</p>
]]></content:encoded>
			<wfw:commentRss>http://rosstanner.co.uk/2011/12/im-on-skype/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fifa 12</title>
		<link>http://rosstanner.co.uk/2011/12/fifa-12/</link>
		<comments>http://rosstanner.co.uk/2011/12/fifa-12/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 23:22:37 +0000</pubDate>
		<dc:creator>Ross Tanner</dc:creator>
				<category><![CDATA[Football]]></category>
		<category><![CDATA[fifa 12]]></category>
		<category><![CDATA[football]]></category>
		<category><![CDATA[playstation network]]></category>
		<category><![CDATA[playstation online]]></category>
		<category><![CDATA[results]]></category>
		<category><![CDATA[spain]]></category>

		<guid isPermaLink="false">http://rosstanner.co.uk/?p=259</guid>
		<description><![CDATA[<p>You can now check out my latest Fifa 12 results online on the PlayStation Network. Just look over to the right at the top of the sidebar for my recent form. I managed to finally finish off my awesome script which reads in my most recent results and posts them on my website. :-)</p> <p>Please bear in [...]]]></description>
			<content:encoded><![CDATA[<p>You can now check out my latest Fifa 12 results online on the PlayStation Network. Just look over to the right at the top of the sidebar for my recent form. I managed to finally finish off my awesome script which reads in my most recent results and posts them on my website. :-)</p>
<p><img class="size-full wp-image-261 alignleft" style="border-style: initial; border-color: initial;" title="Fifa 12 Bad Result" src="http://rosstanner.co.uk/wp-content/uploads/2011/12/badday.jpg" alt="Fifa 12 Bad Result" width="310" height="202" />Please bear in mind I&#8217;m not the best at the game so expect to see many &#8220;LOSS&#8221;&#8216;s next to them and you will notice a trend with Spain. They are quality on the game. I do have some very bad days at the office though as you can see. Probably my worst defensive performance to date and that is also reflected in the form since those wins.</p>
<p>My best ever result must be one of my recent ones which ended 6-5 in my favour. As you can see from the images below I was 5-1 down after just 31 minutes!! I could have quit like most people seem to do but what&#8217;s the point? Anything is possible on this game as I&#8217;ve just proved. His all-out-attack style of play just killed my</p>
<p><img class="size-full wp-image-264 alignright" style="border-style: initial; border-color: initial; color: #0000ee; text-decoration: underline;" title="6-5win" src="http://rosstanner.co.uk/wp-content/uploads/2011/12/6-5win.jpg" alt="" width="350" height="393" /></p>
<p>defence who stood and watched in shock. I was on an incredibly bad run of form losing 4 on the trot and that includes the 8-4 trouncing</p>
<p>at the hands of Real Madrid. However, I managed to turn it around incredibly scoring five second goals which turned him very quickly from being a cocky player using every skill in the book to a very nervous inch-perfect passer. He even made 3 substitutions just after I equalised but it made no difference. Great game and my favourite by a mile. I even stood up and celebrated like a pro!</p>
<p>To the right are the match stats. Incredibly he only had 2 shots in the second half, one of which was on target, where as I had only had 3. He totally annalated me first half but it was a totally different story in the second. &#8220;A game of two halfs&#8221; &#8211; as the famous quote says.</p>
<p>Below are the times of the goalscorers just for the fun of it.</p>
<p style="text-align: left;"> <a href="http://rosstanner.co.uk/wp-content/uploads/2011/12/photo.jpg"><img class="alignleft size-full wp-image-267" title="photo" src="http://rosstanner.co.uk/wp-content/uploads/2011/12/photo.jpg" alt="" width="350" height="261" /></a></p>
<p>If anyone wants a game on Fifa 12 online then you can add me on the PlayStation Network, my username is <strong>RZT17</strong>. Go easy on me and I may just give you a head start like the guy above ;-)</p>
]]></content:encoded>
			<wfw:commentRss>http://rosstanner.co.uk/2011/12/fifa-12/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The role of video in the future of online searching</title>
		<link>http://rosstanner.co.uk/2011/11/role-video-future-online-searching/</link>
		<comments>http://rosstanner.co.uk/2011/11/role-video-future-online-searching/#comments</comments>
		<pubDate>Fri, 25 Nov 2011 19:50:41 +0000</pubDate>
		<dc:creator>Ross Tanner</dc:creator>
				<category><![CDATA[SEO]]></category>
		<category><![CDATA[online video]]></category>
		<category><![CDATA[online video company]]></category>
		<category><![CDATA[search engine optimisation]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[video seo]]></category>
		<category><![CDATA[vimeo]]></category>
		<category><![CDATA[youtube]]></category>

		<guid isPermaLink="false">http://rosstanner.co.uk/?p=251</guid>
		<description><![CDATA[<p>The future of the web is always something many developers and marketeers try to predict. The truth is we never really know what is going to happen, but you can be certain that with change comes new avenues and possibilities. One thing which I have certainly noticed of late (I say &#8220;late&#8221;, it&#8217;s more over [...]]]></description>
			<content:encoded><![CDATA[<p>The future of the web is always something many developers and marketeers try to predict. The truth is we never really know what is going to happen, but you can be certain that with change comes new avenues and possibilities. One thing which I have certainly noticed of late (I say &#8220;late&#8221;, it&#8217;s more over the past year or so) is the ever growing presence of video and the positive effects on SEO. Search engines have been banging on for ages about using videos from the likes of YouTube and Vimeo to increase the content level of the websites that use them. Despite this, there weren&#8217;t any outstanding movers in the market&#8230; until now.</p>
<p>Check out <a href="http://www.online-video-company.co.uk/" target="_blank">The Online Video Company</a> a fantastic video editing company from Gloucestershire with an outstanding online presence. The OVC really push across to potential customers the benefits of online video. The stats really do speak for themselves with a report suggesting that videos which are submitted correctly are &#8220;a staggering 53 times more likely to generate a first page Google ranking than traditional SEO techniques&#8221;.</p>
<p>Just think, next time you perform a search, how often do you see video results popping up even if they are totally useless &#8211; most of the time. Regardless of whether they are relevant they are at the top of the results and millions of potential customers are seeing your video presence. Tech Crunch put together a nice little write-up in March 2010 about the <a href="http://techcrunch.com/2010/03/10/video-seo-top-google-search/" target="_blank">benefits of video on your SEO ranking</a>, with examples. I think it is vital that larger businesses (the majority already are) create online video content for their key search terms if they aim to beat off any competitors.</p>
<p>Check out The Online Video Company&#8217;s <a href="http://www.youtube.com/OnlineVideoCompany" target="_blank">YouTube</a> and <a href="http://vimeo.com/theovc" target="_blank">Vimeo</a> channels for their portfolio and also regular video SEO techniques and handy tips. Their <a href="http://www.online-video-company.co.uk/blog/" target="_blank">blog</a> is always a decent read for the best videos laying around on the net too.</p>
]]></content:encoded>
			<wfw:commentRss>http://rosstanner.co.uk/2011/11/role-video-future-online-searching/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

