<?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>callumcarolan</title>
	<atom:link href="http://callumcarolan.co.uk/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://callumcarolan.co.uk/blog</link>
	<description>Personal portfolio and blog</description>
	<lastBuildDate>Sat, 04 Sep 2010 19:22:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Lesta Skateboards</title>
		<link>http://callumcarolan.co.uk/blog/?p=81</link>
		<comments>http://callumcarolan.co.uk/blog/?p=81#comments</comments>
		<pubDate>Sat, 04 Sep 2010 19:14:37 +0000</pubDate>
		<dc:creator>Callum</dc:creator>
				<category><![CDATA[Happenings]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[lesta]]></category>
		<category><![CDATA[skate]]></category>
		<category><![CDATA[skateboarding]]></category>
		<category><![CDATA[skateboards]]></category>

		<guid isPermaLink="false">http://callumcarolan.co.uk/blog/?p=81</guid>
		<description><![CDATA[<iframe src="http://www.facebook.com/plugins/like.php?href=%3Fhref%3Dhttp%3A%2F%2Fwww.facebook.com%2Fpages%2FLesta-skateboards%2F156692537680916&#38;layout=standard&#38;show_faces=true&#38;width=450&#38;action=like&#38;font=lucida+grande&#38;colorscheme=light&#38;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></description>
			<content:encoded><![CDATA[<p>Show your support for the soon-to-be-released site!</p>
<p><a href="http://www.facebook.com/pages/Lesta-skateboards/156692537680916">Lesta Skateboards</a><br />
<iframe src="http://www.facebook.com/plugins/like.php?href=%3Fhref%3Dhttp%3A%2F%2Fwww.facebook.com%2Fpages%2FLesta-skateboards%2F156692537680916&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;font=lucida+grande&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://callumcarolan.co.uk/blog/?feed=rss2&amp;p=81</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Birthday pictures</title>
		<link>http://callumcarolan.co.uk/blog/?p=59</link>
		<comments>http://callumcarolan.co.uk/blog/?p=59#comments</comments>
		<pubDate>Tue, 13 Jul 2010 03:38:43 +0000</pubDate>
		<dc:creator>Callum</dc:creator>
				<category><![CDATA[Happenings]]></category>

		<guid isPermaLink="false">http://callumcarolan.co.uk/blog/?p=59</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone" title="Riding a Pinata :D" src="http://sphotos.ak.fbcdn.net/hphotos-ak-snc4/hs033.snc4/33998_425097378856_690318856_4740915_6245968_n.jpg" alt="" width="540" height="720" /><img class="alignnone" title="mmm caek" src="http://sphotos.ak.fbcdn.net/hphotos-ak-snc4/hs038.snc4/34259_425253248856_690318856_4746172_7015344_n.jpg" alt="" width="540" height="720" /></p>
]]></content:encoded>
			<wfw:commentRss>http://callumcarolan.co.uk/blog/?feed=rss2&amp;p=59</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Moved to the USA!</title>
		<link>http://callumcarolan.co.uk/blog/?p=66</link>
		<comments>http://callumcarolan.co.uk/blog/?p=66#comments</comments>
		<pubDate>Mon, 12 Jul 2010 04:02:14 +0000</pubDate>
		<dc:creator>Callum</dc:creator>
				<category><![CDATA[Happenings]]></category>
		<category><![CDATA[america]]></category>
		<category><![CDATA[house]]></category>
		<category><![CDATA[move]]></category>
		<category><![CDATA[usa]]></category>

		<guid isPermaLink="false">http://callumcarolan.co.uk/blog/?p=66</guid>
		<description><![CDATA[I recently moved to America and my pc in on a ship somewhere in some ocean on its way here so I&#8217;m using an old laptop. Tutorials and updates shall be a bit thin on the ground sorry. In other news, Happy birthday me! may upload pictures and things tomorrow.]]></description>
			<content:encoded><![CDATA[<p>I recently moved to America and my pc in on a ship somewhere in some ocean on its way here so I&#8217;m using an old laptop. Tutorials and updates shall be a bit thin on the ground <img src='http://callumcarolan.co.uk/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  sorry.<br />
In other news, Happy birthday me! <img src='http://callumcarolan.co.uk/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  may upload pictures and things tomorrow.</p>
]]></content:encoded>
			<wfw:commentRss>http://callumcarolan.co.uk/blog/?feed=rss2&amp;p=66</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introduction to PHP Custom Functions</title>
		<link>http://callumcarolan.co.uk/blog/?p=60</link>
		<comments>http://callumcarolan.co.uk/blog/?p=60#comments</comments>
		<pubDate>Tue, 06 Jul 2010 14:50:28 +0000</pubDate>
		<dc:creator>Callum</dc:creator>
				<category><![CDATA[PHP / MySQL]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[variable]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://callumcarolan.co.uk/blog/?p=60</guid>
		<description><![CDATA[This tutorial is intended to be a simple easy to understand introduction to the custom functions php allows you to create.

<b>Please note:</b> This function is not intended to be useful nor should it be used. It is solely for learning purposes.]]></description>
			<content:encoded><![CDATA[<p>This tutorial is intended to be a simple easy to understand introduction to the custom functions php allows you to create.</p>
<p><b>Please note:</b> This function is not intended to be useful nor should it be used. It is solely for learning purposes.</p>

<div class="wp_codebox"><table><tr id="p601"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
</pre></td><td class="code" id="p60code1"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
	<span style="color: #000088;">$var</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Hello Im a variable.'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> makeBold<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$text</span> <span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">//The variable inside our makeBold fucntion $text, does not have to be a variable called</span>
				   <span style="color: #666666; font-style: italic;">//$text when we run the function. It is just showing you where a variable or string should</span>
				   <span style="color: #666666; font-style: italic;">//go so that it can be used inside the function.</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$var</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;b&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$text</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/b&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//Here we just set a variable $var inside our function, notice we already</span>
		<span style="color: #666666; font-style: italic;">//have a variable called var in the first line of out code? it will not overwrite it.</span>
		<span style="color: #666666; font-style: italic;">//variables made inside the function are used only inside the function that they were.</span>
		<span style="color: #666666; font-style: italic;">//made in. </span>
&nbsp;
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$var</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//return $var is the last part to this function and will output whatever $var may be to the page</span>
		<span style="color: #666666; font-style: italic;">//once the function has been used within it.</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Here I have a different variable name and I would like the string it carries to be bold'</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
	makeBold<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$string</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Now this is where you may not understand it. When we created our function the variable </span>
			     <span style="color: #666666; font-style: italic;">//inside the brackets said $text and weve just put a variable called $string inside there!</span>
			     <span style="color: #666666; font-style: italic;">//Do not fear this was intentional, I promise. The $text variable in the brackets when we created our</span>
			     <span style="color: #666666; font-style: italic;">//function was only meant to show where the variable or string would be going once we put</span>
			     <span style="color: #666666; font-style: italic;">//our function to use.</span>
&nbsp;
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//dont want out text all bunched up now do we :)</span>
&nbsp;
	makeBold<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'I would like to be bold please'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//you can also enter just a string inside the brackets of our function</span>
						      <span style="color: #666666; font-style: italic;">//the string will replace the variable $text when we created our function</span>
						      <span style="color: #666666; font-style: italic;">//if that helps you understand it better.</span>
&nbsp;
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//dont want out text all bunched up now do we :)</span>
&nbsp;
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$var</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Finally we echo the variable we created before we created the function just to show that </span>
		   <span style="color: #666666; font-style: italic;">//a variable with the same name inside the function will not overwrite it.</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Now if you read all the comments I made within the code you should hopefully have a better grasp of what a function does and how it works. </p>
<h4>conclusion</h4>
<p>A simple function like this would be used to repeat a simple task or piece of code over and over without having to rewrite the code over and over again.<br />
<b>e.g.:</b></p>

<div class="wp_codebox"><table><tr id="p602"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p60code2"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$var</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$var2</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">11</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$var3</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">12</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$var</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$var</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">5</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$var</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$var2</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$var2</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">5</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$var</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$var2</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$var2</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">5</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$var</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>This piece of code requires you to redo the same calculations over and over which makes your code look messy and it is inefficient.</p>

<div class="wp_codebox"><table><tr id="p603"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code" id="p60code3"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">function</span> math<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$var</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$var</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$var</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">5</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$var</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
math<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'10'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
math<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'11'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
math<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'12'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Now on a small scale like this it may not seem like a massive difference but on a large scale it makes a massive difference and greatly reduces your code.</p>
<p>If you liked or found this helpful please comment or if you didn&#8217;t please comment and ask why and maybe I can help <img src='http://callumcarolan.co.uk/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://callumcarolan.co.uk/blog/?feed=rss2&amp;p=60</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Free Photoshop Repeating Pattern</title>
		<link>http://callumcarolan.co.uk/blog/?p=22</link>
		<comments>http://callumcarolan.co.uk/blog/?p=22#comments</comments>
		<pubDate>Mon, 18 Jan 2010 17:03:02 +0000</pubDate>
		<dc:creator>Callum</dc:creator>
				<category><![CDATA[Photoshop]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[pattern]]></category>
		<category><![CDATA[repeat]]></category>
		<category><![CDATA[repeating]]></category>

		<guid isPermaLink="false">http://callumcarolan.co.uk/blog/?p=22</guid>
		<description><![CDATA[i didn&#8217;t personally make this but i found it to be really useful. i hope its useful to you guys too just click the thumbnail :3]]></description>
			<content:encoded><![CDATA[<p>i didn&#8217;t personally make this but i found it to be really useful. i hope its useful to you guys too <img src='http://callumcarolan.co.uk/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  just click the thumbnail :3<div id="attachment_21" class="wp-caption alignright" style="width: 160px"><a href="http://callumcarolan.co.uk/blog/wp-content/uploads/2010/01/repeating_pattern_swatch.jpg"><img src="http://callumcarolan.co.uk/blog/wp-content/uploads/2010/01/repeating_pattern_swatch-150x150.jpg" alt="Stylish repeating pattern" title="Repeating Pattern" width="150" height="150" class="size-thumbnail wp-image-21" /></a><p class="wp-caption-text">This can be hued to get a different colour alternatively you could just use the colour it is.</p></div></p>
]]></content:encoded>
			<wfw:commentRss>http://callumcarolan.co.uk/blog/?feed=rss2&amp;p=22</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Preventing XSS Attacks</title>
		<link>http://callumcarolan.co.uk/blog/?p=10</link>
		<comments>http://callumcarolan.co.uk/blog/?p=10#comments</comments>
		<pubDate>Sun, 17 Jan 2010 19:15:21 +0000</pubDate>
		<dc:creator>Callum</dc:creator>
				<category><![CDATA[Exploits]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[cross]]></category>
		<category><![CDATA[exploit]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[site]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">http://callumcarolan.co.uk/blog/?p=10</guid>
		<description><![CDATA[xss attacks you may have heard of xss before but thought, &#8220;wtf is that&#8221;. xss stands for Cross-Site-Scripting(XSS). you&#8217;re probably thinking: okay&#8230; so what. xss is not as dangerous as most vulnrebilities in website scripts but can still be very serious. examples okay i&#8217;ll show you what exactly happens with an xss attack and why]]></description>
			<content:encoded><![CDATA[<h4>xss attacks</h4>
<p>you may have heard of xss before but thought, &#8220;wtf is that&#8221;. xss stands for Cross-Site-Scripting(XSS). you&#8217;re probably thinking: okay&#8230; so what. xss is not as dangerous as most vulnrebilities in website scripts but can still be very serious.</p>
<h4>examples</h4>
<p>okay i&#8217;ll show you what exactly happens with an xss attack and why its bad.</p>

<div class="wp_codebox"><table><tr id="p106"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code" id="p10code6"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Your name is:&lt;br /&gt;'</span><span style="color: #339933;">.</span>
              <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">else</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Session set as: '</span><span style="color: #339933;">.</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>okay so that looks pretty harmless right? wrong. if i were to send this link to my friend: <a href="http://site.com/page.php" target="_blank">http://site.com/page.php</a><strong>?name=</strong> the part in bold is the script that is being injected into your code. the user would be redirected to an evil site because of your insecure script.this is not however all the xss is. xss can be used for various other malicious things such as cross-site-request-forgery. i wont go into too much detail because it can seem daunting for beginners so if you google CSRF then you can read about it on wikipedia or something.</p>
<h4>how to prevent it</h4>
<p>okay so now you know why its bad and what can happen its time to stop it.</p>

<div class="wp_codebox"><table><tr id="p107"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code" id="p10code7"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> clean <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$string</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$malicious</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'javascript'</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'script&gt;'</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'style&gt;'</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'meta&gt;'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$string</span>    <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$malicious</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span> <span style="color: #339933;">,</span> <span style="color: #000088;">$string</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$string</span>    <span style="color: #339933;">=</span> <a href="http://www.php.net/htmlspecialchars"><span style="color: #990000;">htmlspecialchars</span></a><span style="color: #009900;">&#40;</span> <a href="http://www.php.net/mysql_real_escape_string"><span style="color: #990000;">mysql_real_escape_string</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$string</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$string</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Your name is:&lt;br /&gt;'</span><span style="color: #339933;">.</span>
              <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">else</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> clean<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Session set as: '</span><span style="color: #339933;">.</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>so in our php code we have created a <a href="http://php.net/function" target="_blank">function</a> called <strong>clean</strong>. this function will take the value of <strong>$string</strong> and use <a href="http://php.net/str_replace" target="_blank">str_replace</a> to remove malicious code parts, use <a href="http://php.net/htmlspecialchars" target="_blank">htmlspecialchars</a> to turn &lt;, &gt;, ; etc.. into hex values so that they can not be used in a malicious way in our script and will just be displayed as text instead of executing code. just for an added measure we use <a href="http://php.net/mysql_real_escape_string" target="_blank">mysql_real_escape_string</a> to stop any <strong>sql injection</strong> even though our script doesn&#8217;t have an sql query its there incase you decide to use this <a href="http://php.net/function" target="_blank">function</a> in the future.  thanks if you read it all it took me a while to write :3</p>
]]></content:encoded>
			<wfw:commentRss>http://callumcarolan.co.uk/blog/?feed=rss2&amp;p=10</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HAY!!!</title>
		<link>http://callumcarolan.co.uk/blog/?p=5</link>
		<comments>http://callumcarolan.co.uk/blog/?p=5#comments</comments>
		<pubDate>Sun, 17 Jan 2010 18:37:57 +0000</pubDate>
		<dc:creator>Callum</dc:creator>
				<category><![CDATA[Happenings]]></category>
		<category><![CDATA[guten tag]]></category>
		<category><![CDATA[hallo]]></category>
		<category><![CDATA[hay]]></category>
		<category><![CDATA[hello]]></category>
		<category><![CDATA[hey]]></category>
		<category><![CDATA[hi]]></category>

		<guid isPermaLink="false">http://callumcarolan.co.uk/blog/?p=5</guid>
		<description><![CDATA[hai there. i finally bothered to set up a blog although not my original plan of writing my own blog script. suppose i&#8217;m just lazy lol. anyway keep checking back and i&#8217;ll have loads of useful stuff for everyone :3]]></description>
			<content:encoded><![CDATA[<p>hai there. i finally bothered to set up a blog although not my original plan of writing my own blog script. suppose i&#8217;m just lazy lol.</p>
<p>anyway keep checking back and i&#8217;ll have loads of useful stuff for everyone :3</p>
]]></content:encoded>
			<wfw:commentRss>http://callumcarolan.co.uk/blog/?feed=rss2&amp;p=5</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
