<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Open Source Web</title>
	
	<link>http://www.open-source-web.com</link>
	<description>Your open source for Development and Design</description>
	<lastBuildDate>Sun, 22 Aug 2010 19:08:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/OpenSourceWeb" /><feedburner:info uri="opensourceweb" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Easy CSS compatability</title>
		<link>http://feedproxy.google.com/~r/OpenSourceWeb/~3/BJXRUn4dgW0/</link>
		<comments>http://www.open-source-web.com/css/easy-css-compatability/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 09:26:16 +0000</pubDate>
		<dc:creator>Adi</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[ff]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[star]]></category>
		<category><![CDATA[underscore]]></category>

		<guid isPermaLink="false">http://www.open-source-web.com/?p=175</guid>
		<description><![CDATA[For every web developer / designer the issues in earlier versions of IE can be a real pain. Even simple styling such as margins and padding can make a design look like it&#8217;s upside down. The obvious hacks for CSS involve using a separate style sheet and the old school &#60;!&#8211; if IE&#8211;&#62; but I [...]]]></description>
			<content:encoded><![CDATA[<p>For every web developer / designer the issues in earlier versions of IE can be a real pain. Even simple styling such as margins and padding can make a design look like it&#8217;s upside down.</p>
<p>The obvious hacks for CSS involve using a separate style sheet and the old school &lt;!&#8211; if IE&#8211;&gt; but I always manage to avoid these mainly because I like to keep all the CSS in one file to keep overall page size down and it&#8217;s also more easier to fix other issues when all the CSS rules are in one file.</p>
<p>IE  issues</p>
<p>The easiest way to target issues in IE6 is to use the _property hack.</p>
<p>_margin:20px;  /// this will only be used by IE 6</p>
<p>There is also a hack for IE7 which works in a similor way using the *</p>
<p>*margin:20px;  /// this will only be used by IE 7</p>
<p>Although these may cause CSS problems to validators they are still very valid fixes and I have never seen a drawback to using these.</p>
<img src="http://feeds.feedburner.com/~r/OpenSourceWeb/~4/BJXRUn4dgW0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.open-source-web.com/css/easy-css-compatability/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.open-source-web.com/css/easy-css-compatability/</feedburner:origLink></item>
		<item>
		<title>PHP and dynamic URLs</title>
		<link>http://feedproxy.google.com/~r/OpenSourceWeb/~3/m2TnCli6py8/</link>
		<comments>http://www.open-source-web.com/php/php-and-dynamic-urls/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 22:09:01 +0000</pubDate>
		<dc:creator>Adi</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.open-source-web.com/?p=172</guid>
		<description><![CDATA[Whenever I make a new website now I always think about what the urls will need to be like. Most off the shelf CMS platforms will have a plug in or option to enables similar functionality.  But if your writing the site yourself you will want to be able to convert URL from post Id&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Whenever I make a new website now I always think about what the urls will need to be like. Most off the shelf CMS platforms will have a plug in or option to enables similar functionality.  But if your writing the site yourself you will want to be able to convert URL from post Id&#8217;s to post names to Urls and back again.</p>
<p>I have used many methods to do this in the past but recently I found two really useful built in PHP functions. <strong>urlencode()</strong> and <strong>urldecode()</strong>.</p>
<p>Alternatives to using <strong>urlencode() </strong>would be writing your own function to convert all the url unfriendly symbols, slashes, spaces etc. into HTML entities or just replacing them with hyphens.</p>
<p>Again PHP has an built in function for everyhting.</p>
<img src="http://feeds.feedburner.com/~r/OpenSourceWeb/~4/m2TnCli6py8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.open-source-web.com/php/php-and-dynamic-urls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.open-source-web.com/php/php-and-dynamic-urls/</feedburner:origLink></item>
		<item>
		<title>Free tech ebooks, the definitive free guides</title>
		<link>http://feedproxy.google.com/~r/OpenSourceWeb/~3/dO5ibJ276ug/</link>
		<comments>http://www.open-source-web.com/web-development/free-tech-ebooks-the-definitive-free-guides/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 12:17:31 +0000</pubDate>
		<dc:creator>Adi</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.open-source-web.com/?p=161</guid>
		<description><![CDATA[Learning new programming languages is fun but it can be difficult choosing which references and books to use. Most good text book will cost a small fortune and go out of date within a few months and probably wont cover everything you need. For me the best resource comes straight from the source, for most [...]]]></description>
			<content:encoded><![CDATA[<p>Learning new programming languages is fun but it can be difficult choosing which references and books to use. Most good text book will cost a small fortune and go out of date within a few months and probably wont cover everything you need.</p>
<p>For me the best resource comes straight from the source, for most languages you will be able to find a FREE and complete reference to develop with.</p>
<p><a title="php free ebook" href="http://www.php.net/download-docs.php" target="_blank">PHP Documentation</a> &#8211; Download the complete reference in most spoken languages.</p>
<p><a title="msdn javascript" href="http://msdn.microsoft.com/en-us/library/72bd815a.aspx" target="_blank">MSDN Javascript</a> &#8211; Microsoft have a vast documentation library available on-line.</p>
<p><a title="mozilla javascript" href="https://developer.mozilla.org/en/JavaScript_Language_Resources" target="_blank">Mozilla Javascript Resource</a> &#8211; Not great but it goes into a lot of detail, maybe too much.</p>
<p><a title="mozilla js core 1.5" href="http://devedge-temp.mozilla.org/library/manuals/2000/javascript/1.5/reference/" target="_blank">Core Javascript 1.5 from Mozilla</a> &#8211; Learn by example, much better than the previous Mozilla link</p>
<p><a title="css v1" href="http://www.w3.org/Style/css1-updates/REC-CSS1-19990111.pdf" target="_blank">w3 CSS v1</a> &#8211; Full guide to CSS v1 from 1996 &#8211; 2009 in PDF format.</p>
<p><a title="css 2.1" href="http://www.w3.org/TR/CSS21/" target="_blank">w3 guide to css 2.1</a> &#8211; Full on-line reference to css v2.1</p>
<p><a title="html 3 guide" href="http://www.w3.org/TR/REC-html32" target="_blank">w3 HTML 3 guide</a> -  An awesome guide to HTML, very handy for SEO Tricks,</p>
<p><a title="Flash guide" href="http://livedocs.adobe.com/flash/9.0/main/flash_as3_programming.pdf" target="_blank">Action Script 3</a> &#8211; Official full guide to Action script 3 programming.</p>
<p><a title="cs3 guide" href="http://www.adobe.com/support/documentation/en/flash/" target="_blank">CS3</a> &#8211; The full CS3 shabang from Adobe, I haven&#8217;t found a decent <a title="flash wordpress" href="http://www.open-source-web.com/flash/flashactionscript-wordpress-rss-reader/" target="_self">Flash </a>book yet so this is awesome.</p>
<p><a title="mysql guide" href="http://dev.mysql.com/doc/refman/5.1/en/index.html" target="_blank">Mysql </a>- One of the less helpful guides but it is fairly complete.</p>
<p><a title="wordpress guide" href="http://codex.wordpress.org/Function_Reference" target="_blank">WordPress Functions </a>- The official function list, awesome for any wordpress project</p>
<img src="http://feeds.feedburner.com/~r/OpenSourceWeb/~4/dO5ibJ276ug" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.open-source-web.com/web-development/free-tech-ebooks-the-definitive-free-guides/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.open-source-web.com/web-development/free-tech-ebooks-the-definitive-free-guides/</feedburner:origLink></item>
		<item>
		<title>Best SEO Companies</title>
		<link>http://feedproxy.google.com/~r/OpenSourceWeb/~3/xHLChOhwuMI/</link>
		<comments>http://www.open-source-web.com/seo/best-seo-companies/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 19:42:32 +0000</pubDate>
		<dc:creator>Adi</dc:creator>
				<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://www.open-source-web.com/?p=157</guid>
		<description><![CDATA[Finding a good SEO company can be pretty difficult, most will call you and make promises they can&#8217;t keep like they will get you on the front page of Google in a week for a term nobody will search for. There are a lot of cowboys just like any industry. That&#8217;s why it&#8217;s good to [...]]]></description>
			<content:encoded><![CDATA[<p>Finding a good SEO company can be pretty difficult, most will call you and make promises they can&#8217;t keep like they will get you on the front page of Google in a week for a term nobody will search for. There are a lot of cowboys just like any industry.</p>
<p>That&#8217;s why it&#8217;s good to do some research in your online marketing company.</p>
<ol>
<li>Ask to see success stories of recent clients.</li>
<li>Take a look at the work they do, make sure you can see what you are actually paying for.</li>
<li>Don&#8217;t sign up for a long term contract unless they can perform in the short term.</li>
<li>Ask what they can do that other companies can&#8217;t</li>
<li>Ask for face to face meetings and regular updates on targets</li>
</ol>
<p>Lastly make sure they have good impartial reviews. Recently topseos.com did a comprehensive list of the top SEO companies in the UK. <a title="internet marketing" href="http://theeword.co.uk">theEword</a> was ranked 9th in the top SEO companies list which is great as it proves all the hard work is paying off.</p>
<img src="http://feeds.feedburner.com/~r/OpenSourceWeb/~4/xHLChOhwuMI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.open-source-web.com/seo/best-seo-companies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.open-source-web.com/seo/best-seo-companies/</feedburner:origLink></item>
		<item>
		<title>Javascript click() method</title>
		<link>http://feedproxy.google.com/~r/OpenSourceWeb/~3/YRGg8nqZNCk/</link>
		<comments>http://www.open-source-web.com/javascript/javascript-click-method/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 14:04:44 +0000</pubDate>
		<dc:creator>Adi</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.open-source-web.com/?p=148</guid>
		<description><![CDATA[Javascript has evolved into a great web programming language over the last few years with its compatibility getting much greater then it was and with the versatility of the script. This week I came back to a script I wrote some time ago using a frame work. The script basically allowed the visitor to click [...]]]></description>
			<content:encoded><![CDATA[<p>Javascript has evolved into a great web programming language over the last few years with its compatibility getting much greater then it was and with the versatility of the script.</p>
<p>This week I came back to a script I wrote some time ago using a frame work. The script basically allowed the visitor to click next or previous and scroll through a list element. Although dynamic HTML is pretty awesome it can be hard to maintain.</p>
<p>Due to requirements the scroll er has had to be automated as well as respond to a users click which it wasn&#8217;t built for, At first it may need to be re written from scratch but then I came across the click() method.</p>
<p>Click() basically simulates a users click on a button in javascript. Unfortunately it only works with form button elements and not with elements such as hyperlinks.</p>
<p>If you need to simulate the click of another type of element I would suggest making a button and giving it the style display:none;</p>
<p>example usage</p>
<p>getElementByID(&#8216;someid&#8217;).click();</p>
<img src="http://feeds.feedburner.com/~r/OpenSourceWeb/~4/YRGg8nqZNCk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.open-source-web.com/javascript/javascript-click-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.open-source-web.com/javascript/javascript-click-method/</feedburner:origLink></item>
		<item>
		<title>Twitter PHP and SimpleXML feed</title>
		<link>http://feedproxy.google.com/~r/OpenSourceWeb/~3/LegX3DwdVPQ/</link>
		<comments>http://www.open-source-web.com/apis/twitter-php-and-simplexml-feed/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 20:45:04 +0000</pubDate>
		<dc:creator>Adi</dc:creator>
				<category><![CDATA[API's]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[simpleXML]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.open-source-web.com/?p=136</guid>
		<description><![CDATA[Just like the Google Charts API the Twitter API can be super simple. Twitter uses a few different XML feeds to send and receive data from a given user, some feeds require a user name and password supplied through Curl but a few are publicly available to all. This example will use the built in [...]]]></description>
			<content:encoded><![CDATA[<p>Just like the <a href="http://www.open-source-web.com/php/google-charts-example/">Google Charts API</a> the Twitter API can be super simple. Twitter uses a few different XML feeds to send and receive data from a given user, some feeds require a user name and password supplied through Curl but a few are publicly available to all.</p>
<p>This example will use the built in SimpleXML functions which come with PHP5, this is a much faster and easier way to using alternative readers such as simplePie or anything else you might come across. As far as it goes I don&#8217;t think SimpleXML gets enough coverage so I am happy to put it to some use for this example.</p>
<p>Keeping it basic</p>
<p>$user = &#8216;adi182&#8242;;<br />
echo &#8216;&lt;a href=&#8221;http://www.twitter.com/&#8217;.$user.&#8217;&#8221;&gt;Follow &#8216;.$user.&#8217;&lt;/a&gt;&lt;br /&gt;&#8217;;<br />
$xml = simplexml_load_file(&#8220;http://search.twitter.com/search.atom?q=from:&#8221;.$user.&#8221;&amp;rpp=5&#8243;);<br />
foreach($xml-&gt;entry as $tweet)<br />
{<br />
echo $tweet-&gt;title. &#8220;&lt;br /&gt;&#8221;;<br />
}<br />
?&gt;</p>
<p>So there you have it, the super simple example on putting a Twiter feed on your website.</p>
<img src="http://feeds.feedburner.com/~r/OpenSourceWeb/~4/LegX3DwdVPQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.open-source-web.com/apis/twitter-php-and-simplexml-feed/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.open-source-web.com/apis/twitter-php-and-simplexml-feed/</feedburner:origLink></item>
		<item>
		<title>Javascript get element by id</title>
		<link>http://feedproxy.google.com/~r/OpenSourceWeb/~3/upXWJJU3TJs/</link>
		<comments>http://www.open-source-web.com/javascript/javascript-get-element-by-id/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 21:36:16 +0000</pubDate>
		<dc:creator>Adi</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[getlementbyid]]></category>
		<category><![CDATA[style]]></category>

		<guid isPermaLink="false">http://www.open-source-web.com/?p=132</guid>
		<description><![CDATA[Javascript is probably the most awesome tool a web developer can use to make a website both functional and look nice. Javascript has also evolved over the years with the DOM it has become much easier to develop. One useful piece of code I always end up using when writing Javascript is getElementById, the way [...]]]></description>
			<content:encoded><![CDATA[<p>Javascript is probably the most awesome tool a web developer can use to make a website both functional and look nice. <strong>Javascript </strong>has also evolved over the years with the DOM it has become much easier to develop.</p>
<p>One useful piece of code I always end up using when writing Javascript is <strong>getElementById</strong>, the way Javascript evolved has given it much more compatibility with different browsers and in turn means you need less code to do more.</p>
<p><strong>getElementById</strong> allows you to modify any html element with a given ID. so for example if you have a &lt;div&gt; with the ID jstest it might look like this</p>
<p>&lt;div id=&#8221;jstest&#8221;&gt;howdy&lt;/div&gt;</p>
<p>Using <strong>document.getElementById(&#8216;jstest&#8217;)</strong> we can modify this element dynamically with javascript changing anything from its appearance or position with styling or use it within our javascript code.</p>
<p>using <strong>document.getElementById(&#8216;jstest&#8217;).innerHTML</strong> we could change or get the contents of the div.</p>
<p>Another pretty awesome use for the getElementById method would be to change the style of an element dynamically, maybe you want it to disappear when clicked or have a border when highlighted.</p>
<p>To change the background of an element we could use document.getelementById(&#8216;jstest&#8217;).style.background-color = &#8216;#dedede&#8217;  this will work with any styling you could apply to an element.</p>
<p>If you are like 90% of the old school web developers I know you probably don&#8217;t like using javascript but the modern DOM it is couldn&#8217;t be easier.</p>
<img src="http://feeds.feedburner.com/~r/OpenSourceWeb/~4/upXWJJU3TJs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.open-source-web.com/javascript/javascript-get-element-by-id/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.open-source-web.com/javascript/javascript-get-element-by-id/</feedburner:origLink></item>
		<item>
		<title>Google Charts Example</title>
		<link>http://feedproxy.google.com/~r/OpenSourceWeb/~3/tji317Lj3SM/</link>
		<comments>http://www.open-source-web.com/php/google-charts-example/#comments</comments>
		<pubDate>Sat, 07 Mar 2009 18:14:03 +0000</pubDate>
		<dc:creator>Adi</dc:creator>
				<category><![CDATA[API's]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[chart]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[google]]></category>

		<guid isPermaLink="false">http://www.open-source-web.com/?p=117</guid>
		<description><![CDATA[API&#8217;s are becoming more popular on the web as many of the big online companies such as Google, Yahoo and Facebook offer there own open source code for web developers to use freely and easily. To begin with I am going to go through how to use the Charts Basics API from Google. This is [...]]]></description>
			<content:encoded><![CDATA[<p>API&#8217;s are becoming more popular on the web as many of the big online companies such as Google, Yahoo and Facebook offer there own open source code for web developers to use freely and easily.</p>
<p><img src="http://chart.apis.google.com/chart?chs=250x100&amp;chd=t:10,80,35,10&amp;cht=lc&amp;chl=wk1|wk2|wk3|wk4" alt="Google Charts Basics" /></p>
<p>To begin with I am going to go through how to use the Charts Basics API from Google. This is an extremely easy one to start off with as you don&#8217;t require an API key or to install anything, you don&#8217;t even need a dynamic server side script to get some nice results.</p>
<p>For this example I am going to jazz it up with a bit of PHP using an associative array but you can easily replace this with a database or XML feed.</p>
<p>To call a chart we use the query string linking to the API which will end up looking something like this.</p>
<pre id="line1">&lt;<span class="start-tag">img</span><span class="attribute-name"> src</span>=<span class="attribute-value">"http://chart.apis.google.com/chart?chs=250x100&amp;amp;chd=t:10,80,35,10&amp;amp;cht=lc&amp;amp;chl=wk1|wk2|wk3|wk4"
</span><span class="attribute-name">alt</span>=<span class="attribute-value">"Sample chart" </span><span class="error"><span class="attribute-name">/</span></span>&gt;</pre>
<p>To generate this dynamicaly I used the following code</p>
<pre class="php" name="code">$arr = array();

$arr['Jan']['wk1'] = 10;
$arr['Jan']['wk2'] = 80;
$arr['Jan']['wk3'] = 35;
$arr['Jan']['wk4'] = 10;

$chart= 'http://chart.apis.google.com/chart?';
$chartsize = 'chs=250x100';
$type = "cht=lc";
$vals = 'chd=t:';
$keys = 'chl=';
$alt = "January";

foreach( $arr['Jan'] as $key =&gt; $value){
	$vals .= $value.',';
	$keys .= $key.'|';
	}</pre>
<p>And Lastly to pull all the code together.</p>
<pre class="php" name="code">
&lt;img src="&lt;? echo $chart;?&gt;
&lt;? echo $chartsize;?&gt;
&amp;amp;&lt;? echo substr("$vals", 0, -1);?&gt;
&amp;amp;&lt;? echo $type;?&gt;
&amp;amp;&lt;? echo substr("$keys", 0, -1);?&gt;"
alt="Sample chart" /&gt;
</pre>
<p>To develop this example further use the official documentation available here <a title="Google Chart Basic" rel="nofollow" href="http://code.google.com/apis/chart/" target="_blank">Google Chart Basic</a></p>
<img src="http://feeds.feedburner.com/~r/OpenSourceWeb/~4/tji317Lj3SM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.open-source-web.com/php/google-charts-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.open-source-web.com/php/google-charts-example/</feedburner:origLink></item>
		<item>
		<title>Random Banner with PHP</title>
		<link>http://feedproxy.google.com/~r/OpenSourceWeb/~3/q90aFXpZZhs/</link>
		<comments>http://www.open-source-web.com/php/random-banner-with-php/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 22:26:15 +0000</pubDate>
		<dc:creator>Adi</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[banners]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[random]]></category>

		<guid isPermaLink="false">http://www.open-source-web.com/?p=103</guid>
		<description><![CDATA[This is a quick tutorial which shows how easy it is to make a random banner script with PHP. We will use a PHP array of images which is populated by a given directory and select a random index from the array to be the banner. For this example I have chosen to list the [...]]]></description>
			<content:encoded><![CDATA[<p>This is a quick tutorial which shows how easy it is to make a random banner script with PHP. We will use a PHP array of images which is populated by a given directory and select a random index from the array to be the banner.</p>
<p>For this example I have chosen to list the files from a directory as this will keep the script fairly dynamic without the need of a database. The script could be easily modified to use a database but we can come back to that later on if we need to.</p>
<p>To start off all you will need is a folder with several banners and a page to display them on.</p>
<p>$dir will be the directory you have created to grab the images from, it is important to make sure this folder only contains banners.<br />
$banners will be the array of images found in the given folder.</p>
<pre class="php" name="code">

 $banners = array();
  $dir = 'res/banners/';
  if ($handle = opendir($dir)) {
  while (false !== ($file = readdir($handle))) {
  if($file != &quot;.&quot; &amp;&amp; $file != &quot;..&quot;){
  $banners[] = $file;
  }
  }
  closedir($handle);
  }

  $rand = array_rand($banners,1);
  echo &quot;&lt;img src='&quot;.$dir.$banners[$rand].&quot;' alt='banner'/&gt;&quot;;   
</pre>
<p>The code above uses a few handy built in PHP functions:<br />
opendir()<br />
readdir()<br />
array_rand()<br />
print_r()</p>
<img src="http://feeds.feedburner.com/~r/OpenSourceWeb/~4/q90aFXpZZhs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.open-source-web.com/php/random-banner-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.open-source-web.com/php/random-banner-with-php/</feedburner:origLink></item>
		<item>
		<title>Fix Canonical URL with link rel=”canonical” in PHP</title>
		<link>http://feedproxy.google.com/~r/OpenSourceWeb/~3/5MT0ftbi1SY/</link>
		<comments>http://www.open-source-web.com/seo/fix-canonical-url-with-link-relcanonical-in-php/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 20:32:54 +0000</pubDate>
		<dc:creator>Adi</dc:creator>
				<category><![CDATA[SEO]]></category>
		<category><![CDATA[Canonical]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[tag]]></category>

		<guid isPermaLink="false">http://www.open-source-web.com/?p=83</guid>
		<description><![CDATA[Recently the major search engines have worked together to help fix one of the biggest problems in SEO, The canonical URL. With this quick fix all you need to do is add a tag to the &#60;head&#62; section of the page and search engines will use this as an anchor to index the page. since [...]]]></description>
			<content:encoded><![CDATA[<p>Recently the major search engines have worked together to help fix one of the biggest problems in SEO, The canonical URL. With this quick fix all you need to do is add a tag to the &lt;head&gt; section of the page and search engines will use this as an anchor to index the page.</p>
<p>since it is still fairly new we don&#8217;t know how it will work in the long run and if there are any side effects such as the pagerank not transferring.</p>
<p>The new tag looks like this</p>
<p align="center"><strong><code>&lt;link rel="canonical" href="http://www.open-source-web.com/"&gt;</code></strong></p>
<p>But nothing can be that easy, obviously with a large site you wouldn&#8217;t want to write that out for a million pages so here is the PHP code to make it work.</p>
<pre name="code" class="php">

$thispage = "http://www.";
$thispage .= $_SERVER["SERVER_NAME"];
$thispage .= $_SERVER["PHP_SELF"];
if($_SERVER["QUERY_STRING"]){$thispage .= "?".$_SERVER["QUERY_STRING"];}

&lt;link rel="canonical" href="&lt;? echo $thispage;?&gt;"&gt;
</pre>
<img src="http://feeds.feedburner.com/~r/OpenSourceWeb/~4/5MT0ftbi1SY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.open-source-web.com/seo/fix-canonical-url-with-link-relcanonical-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.open-source-web.com/seo/fix-canonical-url-with-link-relcanonical-in-php/</feedburner:origLink></item>
		<item>
		<title>Shorthand boolean IF with PHP</title>
		<link>http://feedproxy.google.com/~r/OpenSourceWeb/~3/hl9YEhO-ZkA/</link>
		<comments>http://www.open-source-web.com/php/shorthand-boolean-if-with-php/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 19:39:22 +0000</pubDate>
		<dc:creator>Adi</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[if]]></category>
		<category><![CDATA[quick]]></category>

		<guid isPermaLink="false">http://www.open-source-web.com/?p=74</guid>
		<description><![CDATA[This is a good alternative to using a basic IF condition. It basically fits the whole thing on a minimal line of code. It is an  easy way to compare two values and select the right one. There are a few ways to use this but the basic jist of it is to compare two [...]]]></description>
			<content:encoded><![CDATA[<p>This is a good alternative to using a basic IF condition. It basically fits the whole thing on a minimal line of code.</p>
<p>It is an  easy way to compare two values and select the right one. There are a few ways to use this but the basic jist of it is to compare two values and if its is true use the first value after the question mark, or if the condition returns false use the second value.</p>
<pre name="code" class="php">
echo $targetvar =  ($somevar == "thisVar" ? "itIsTrue" : "itIsFalse");
</pre>
<p><span style="font-size: 9pt; font-family: 'Arial','sans-serif';"><br />
In the example above we can set $targetvar with the condition. it will compare the first two variables with whatever you use, more then less then etc and it will choose the correct value from the two after the question mark.<br />
</span></p>
<img src="http://feeds.feedburner.com/~r/OpenSourceWeb/~4/hl9YEhO-ZkA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.open-source-web.com/php/shorthand-boolean-if-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.open-source-web.com/php/shorthand-boolean-if-with-php/</feedburner:origLink></item>
		<item>
		<title>SEO Friendly Redirects with PHP</title>
		<link>http://feedproxy.google.com/~r/OpenSourceWeb/~3/cHz3c54QIo8/</link>
		<comments>http://www.open-source-web.com/php/seo-friendly-redirects-with-php/#comments</comments>
		<pubDate>Sat, 24 Jan 2009 19:32:15 +0000</pubDate>
		<dc:creator>Adi</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[redirect]]></category>

		<guid isPermaLink="false">http://www.open-source-web.com/?p=60</guid>
		<description><![CDATA[With a basic redesign you probably wont have this problem but if you have rebuilt a website even with the same content if the URL&#8217;s have changed this will have a huge effect on your search engine presence as you will be starting from scratch. Your links from internal pages may not work, links from [...]]]></description>
			<content:encoded><![CDATA[<p>With a basic redesign you probably wont have this problem but if you have rebuilt a website even with the same content if the URL&#8217;s have changed this will have a huge effect on your search engine presence as you will be starting from scratch. Your links from internal pages may not work, links from external sites wont work and you will lose your pagerank (if it ever mattered anyway.)</p>
<p>A good way to keep your sites listing after a redevelopment is to use a redirect. If you are using an Apache server you can use the .htaccess file to redirect.</p>
<p><code>Redirect 301 /oldpage.html /newpage.html</code></p>
<p>But some times this isnt the best way if you have to redirect hundreds of pages. The alternative is to use a header redirect in PHP. Most web based languages such as ASP or RUBY will do the same thing but with different code.</p>
<p><code><span class="html"><br />
<span class="default">&lt;?php</span></span></code></p>
<p><code><span class="html"><span class="comment">// make this code the first line<br />
</span><span class="default">header</span><span class="keyword">(</span><span class="string">"Location: /newpage.php"</span><span class="keyword">,</span><span class="default">TRUE</span><span class="keyword">,</span><span class="default">301</span><span class="keyword">);</span><span class="keyword"> </span></span></code><code><span class="html"><span class="default"> </span><span class="comment">// 301 Moved Permanently</span></span></code> to newpage.php<br />
<code><span class="html"><span class="keyword"> </span><span class="default">?&gt;</span></span></code></p>
<img src="http://feeds.feedburner.com/~r/OpenSourceWeb/~4/cHz3c54QIo8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.open-source-web.com/php/seo-friendly-redirects-with-php/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.open-source-web.com/php/seo-friendly-redirects-with-php/</feedburner:origLink></item>
		<item>
		<title>Flash/Actionscript wordpress RSS reader</title>
		<link>http://feedproxy.google.com/~r/OpenSourceWeb/~3/PghArf2tnwI/</link>
		<comments>http://www.open-source-web.com/flash/flashactionscript-wordpress-rss-reader/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 20:16:45 +0000</pubDate>
		<dc:creator>Adi</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[action script]]></category>
		<category><![CDATA[rss]]></category>

		<guid isPermaLink="false">http://www.open-source-web.com/?p=53</guid>
		<description><![CDATA[I might come back and explain the code to this one in the future, but for now it is a basic example of how you can use Flash with dynamic content. Using and XML based RSS feed generated from word press we can use actionscript to import and interprete the tags into something we can [...]]]></description>
			<content:encoded><![CDATA[<p>I might come back and explain the code to this one in the future, but for now it is a basic example of how you can use Flash with dynamic content. Using and XML based RSS feed generated from word press we can use actionscript to import and interprete the tags into something we can use in Flash.</p>
<p>XML is a format used throughout coding languages and especialy popular with web based technology as it is a language all others can use.</p>
</p>
<p><object width="550" height="400" data="http://www.open-source-web.com/wp-content/uploads/2009/01/rssfeed.swf" type="application/x-shockwave-flash"><param name="src" value="http://www.open-source-web.com/wp-content/uploads/2009/01/rssfeed.swf" /></object></p>
<p>I have left this example pretty basic so you can make edits without much knowledge of ActionScript, but if you have any questions leave a comment <img src='http://www.open-source-web.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<pre name="code" class="php">
package {
	import flash.display.*;
	import flash.events.*;
	import flash.text.*;
	import flash.net.*;
	import flash.system.*;

	public class rss extends MovieClip {

		public var xmldata:XML;
		public var titles:Array=new Array;

		public function rss(){ //constructor
			xmlimport();
			}

		public function xmlimport() {   /// the money shot
			xmldata=new XML;   //// create new xml feed
			var xmlURL:URLRequest=new URLRequest("http://www.open-source-web.com/feed/");   // set the url to the feed
			var xmlLoader:URLLoader=new URLLoader(xmlURL);       //// go get it
			xmlLoader.addEventListener(Event.COMPLETE,xmlLoaded);   /// on complete do something
			xmlLoader.addEventListener(IOErrorEvent.IO_ERROR,xmlLoadError);   /// else go here
		}
		public function xmlLoaded(event:Event) {   //// xml is loaded ok whahoo
			xmldata=XML(event.target.data); /// xml loaded ok
			trace("XML loaded successfully.");

			trace("first child - " + xmldata.children().length());   ///// trace the title for debug
			feedtest.text = xmldata.channel.title[0];    /// put title of feed in the box called feedtext

			var ex:int=10;  // position it
			var wi:int=100;

			for(var f:int=0; f < xmldata.channel.item.length(); f++){  // for each item int he feed process it
			trace(xmldata.channel.item[f].title);
			var titlebutton:titlebutt=new titlebutt;   //// make new product mc + add attributes
				titlebutton.x = ex;
				titlebutton.y = wi;
				titlebutton.description = xmldata.channel.item[f].description;
				titlebutton.link = xmldata.channel.item[f].link;
				titlebutton.addEventListener(MouseEvent.CLICK,clicked);   /// set for buttom mc clilcked
				titlebutton.addEventListener(MouseEvent.MOUSE_OVER,over);   //// get description on mouse over
				titlebutton.title.text = xmldata.channel.item[f].title;
				titles.push(titlebutton); /// add to array
				addChild(titlebutton);
				wi=wi+30;
			}
		}

		public function clicked(event:Event){    //// go to the article when clicked
		navigateToURL(new URLRequest(event["currentTarget"].link), "_blank");
	}

	public function over(event:Event){   //// load the description on mouse over
		descriptionbox.text = event["currentTarget"].description;
	}

		public function xmlLoadError(event:IOErrorEvent) {   /// check for error from loading xml file
			trace(event.text);
		}
	}
}
</pre>
<p><a href="http://www.open-source-web.com/wp-content/uploads/2009/01/rssreader.zip">Download the Flash rss reader</a></p>
<img src="http://feeds.feedburner.com/~r/OpenSourceWeb/~4/PghArf2tnwI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.open-source-web.com/flash/flashactionscript-wordpress-rss-reader/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.open-source-web.com/flash/flashactionscript-wordpress-rss-reader/</feedburner:origLink></item>
		<item>
		<title>GTA game character movement in Flash AS3</title>
		<link>http://feedproxy.google.com/~r/OpenSourceWeb/~3/nm-Ovf7INm8/</link>
		<comments>http://www.open-source-web.com/flash/gta-game-character-movement-in-flash-as3/#comments</comments>
		<pubDate>Sat, 17 Jan 2009 10:39:09 +0000</pubDate>
		<dc:creator>Adi</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[gta]]></category>
		<category><![CDATA[source]]></category>

		<guid isPermaLink="false">http://www.open-source-web.com/?p=35</guid>
		<description><![CDATA[This is going to be a quick introduction into game programming in Flash with AS3. The idea of this tutorial will be to emulate the movement the character had in the original Grand Theft Auto game on the play station and PC. Step 1:Make a new movie Open up Flash and click the create new [...]]]></description>
			<content:encoded><![CDATA[<p>This is going to be a quick introduction into game programming in Flash with AS3. The idea of this tutorial will be to emulate the movement the character had in the original Grand Theft Auto game on the play station and PC.</p>
<p><object width="550" height="400" data="http://www.open-source-web.com/wp-content/uploads/2009/01/gtamovement.swf" type="application/x-shockwave-flash"><param name="src" value="http://www.open-source-web.com/wp-content/uploads/2009/01/gtamovement.swf" /></object></p>
<p>Step 1:Make a new movie</p>
<p>Open up Flash and click the create new icon on the top left. at the moment it doesn&#8217;t matter what size it is.</p>
<p><img class="alignnone size-full wp-image-37" title="gta1" src="http://www.open-source-web.com/wp-content/uploads/2009/01/1.jpg" alt="gta1" width="200" height="200" /></p>
<p>Step 2: Make your sprite</p>
<p>Look for the Library in Flash, right click the and go down to &#8220;New Symbol&#8221;. This will be our main character, I have called it &#8220;hero&#8221; for now. This is partly as I reuse Action script from game to game so having as generic name helps to import code.</p>
<p><img class="alignnone size-full wp-image-38" title="gta2" src="http://www.open-source-web.com/wp-content/uploads/2009/01/2.jpg" alt="gta2" width="400" height="400" /></p>
<p>Make sure the symbol type is set to movie clip and for Linkage select &#8220;Export for action script&#8221; as we may need this later on for further development. Then Click &#8220;OK&#8221; to create the hero sprite.</p>
<p><img class="alignnone size-full wp-image-39" title="gta3" src="http://www.open-source-web.com/wp-content/uploads/2009/01/3.jpg" alt="gta3" width="420" height="500" /></p>
<p>Step 3: Draw your sprite</p>
<p>The window will change slightly, check you are drawing on the hero movie clip.</p>
<p><img class="alignnone size-full wp-image-40" title="gta4" src="http://www.open-source-web.com/wp-content/uploads/2009/01/4.jpg" alt="gta4" width="400" height="200" /></p>
<p>Make sure you are drawing your character right on the little black cross and use the tools on the left to make a basic overhead view of our hero.</p>
<p>It doesn&#8217;t need to be anything too Flashy at the moment as we can change it later on.</p>
<p><img class="alignnone size-full wp-image-41" title="gta5" src="http://www.open-source-web.com/wp-content/uploads/2009/01/5.jpg" alt="gta5" width="400" height="200" /></p>
<p>Step 4: The ActionScript file</p>
<p>The next step will allow us to attach an external ActionScript file. you can add the code to the current Flash movie but I find it easier to keep them separate.</p>
<p>go to File &gt; New</p>
<p>Select Actionscript file from the menu and click OK. Once it has opened click File save as and save it to the same directory as your original flash movie.</p>
<p><img class="alignnone size-full wp-image-42" title="gta6" src="http://www.open-source-web.com/wp-content/uploads/2009/01/6.jpg" alt="gta6" width="650" height="430" /></p>
<p>Step 5: Attach the movie and the Actionscript file together.</p>
<p>To make Flash compile the actionscript file with the movie we need to attach the newly created file to movie. Select the Flash movie tab in Flash and look for the following box on the bottom right and enter the name of the actionscript file without the .as.</p>
<p><img class="alignnone size-full wp-image-44" title="gta8" src="http://www.open-source-web.com/wp-content/uploads/2009/01/8.jpg" alt="gta8" width="400" height="200" /></p>
<p>Step 6: On to the code</p>
<p>On to the fun bit. Select the ActionScript file tab in the Flash window. It will look differant to the Flash window as we are just writing code in this one.</p>
<p><img class="alignnone size-full wp-image-43" title="gta7" src="http://www.open-source-web.com/wp-content/uploads/2009/01/7.jpg" alt="gta7" width="400" height="300" /></p>
<p>To start the code off we need to add common actionscript packages and create the game class.</p>
<pre name="code" class="php">package {
	import flash.display.*;
	import flash.events.*;
	import flash.text.*;
	import flash.geom.*;
	import flash.net.*;
	import flash.system.*;

	public class gtamovement extends MovieClip {

	}
</pre>
<p><img class="alignnone size-full wp-image-45" title="gta9" src="http://www.open-source-web.com/wp-content/uploads/2009/01/9.jpg" alt="gta9" width="450" height="300" /></p>
<p>Step 7: Global variables<br />
Add these variables just below the class definition. The top group are to check if a key is down or up and the secont group are charactor vairables.</p>
<pre name="code" class="php">		///// key listeners vars
		public var arrowLeft:Boolean=false;
		public var arrowRight:Boolean=false;
		public var arrowUp:Boolean=false;
		public var arrowDown:Boolean=false;
		public var space:Boolean=false;

		public var Hero:hero=new hero;
		public var speed:Number = 5.5;
		public var dir:int = 0;
		public var piover180:Number = Math.PI /180;
		public var sharpness:Number =20;</pre>
<p>Step 8 : The constructor<br />
The constructor is givent the same name as the class and is then run automatically when the class is called. For this game we will set up some event listeners and add the hero to the movie.</p>
<pre name="code" class="php">public function gtamovement() {/// constructor run when program is loaded
			trace('Go!');  // test to see if we got this far.
			/////   Key Listener
			stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownFunction);
			stage.addEventListener(KeyboardEvent.KEY_UP,keyUpFunction);
			stage.addEventListener(Event.ENTER_FRAME,redrawGame);// set game loop

			Hero.x = 100;
			Hero.y = 100;
			addChild(Hero);
		}
</pre>
<p>Step 9: Movie the hero<br />
The next function if probably a bit over complicated but it works fine for what we are after. Basicaly it will only move the hero forward and backward but also reotate it to face any direction.</p>
<pre name="code" class="php">public function movehero() {////////   move hero
			if (arrowLeft) {
				Hero.rotation -= sharpness;
			} else if (arrowRight) {
				Hero.rotation += sharpness;
			} else if (arrowUp) {
				dir = 1;
			} else if (arrowDown) {
				dir = -1;
			} else {
				dir = 0;
			}
			var movex = Math.sin(Hero.rotation*piover180)*speed*dir;
			var movey = Math.cos(Hero.rotation*piover180)*speed*dir;
			Hero.x += Math.sin(Hero.rotation*piover180)*speed*dir;
			Hero.y -= Math.cos(Hero.rotation*piover180)*speed*dir;
		}</pre>
<p>Step 10: Redraw the game<br />
This function is called from the constructor and will loop as long as the game is running. if you wanted to add functionality to pause or move other sprites here is the palce to do it.</p>
<pre name="code" class="php">public function redrawGame(event:Event) {
			movehero();  // Add any other functions you may want looped here.
		}
</pre>
<p>Step 11: The key listeners</p>
<pre name="code" class="php">public function keyDownFunction(event:KeyboardEvent) {
			if (event.keyCode == 37) {
				arrowLeft=true;
			} else if (event.keyCode == 39) {
				arrowRight=true;
			} else if (event.keyCode == 38) {
				arrowUp=true;
			} else if (event.keyCode == 40) {
				arrowDown=true;
			} else if (event.keyCode == 32) {
				space=true;
			} else {
				trace(event.keyCode); // find out which other key was pressed
			}
		}
		public function keyUpFunction(event:KeyboardEvent) {
			if (event.keyCode == 37) {
				arrowLeft=false;
			} else if (event.keyCode == 39) {
				arrowRight=false;
			} else if (event.keyCode == 38) {
				arrowUp=false;
			} else if (event.keyCode == 40) {
				arrowDown=false;
			} else if (event.keyCode == 32) {
				space=false;
			}
		}
</pre>
<p><a href="http://www.open-source-web.com/wp-content/uploads/2009/01/gtamovement.zip">Download gta movement</a></p>
<img src="http://feeds.feedburner.com/~r/OpenSourceWeb/~4/nm-Ovf7INm8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.open-source-web.com/flash/gta-game-character-movement-in-flash-as3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.open-source-web.com/flash/gta-game-character-movement-in-flash-as3/</feedburner:origLink></item>
		<item>
		<title>Tracking visitors with PHP and Predefined variables</title>
		<link>http://feedproxy.google.com/~r/OpenSourceWeb/~3/vA6Z5pIhGlw/</link>
		<comments>http://www.open-source-web.com/php/tracking-visitors-with-php-and-predefined-variables/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 22:37:21 +0000</pubDate>
		<dc:creator>Adi</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[analytics]]></category>
		<category><![CDATA[predefined]]></category>
		<category><![CDATA[tracking]]></category>

		<guid isPermaLink="false">http://www.open-source-web.com/?p=29</guid>
		<description><![CDATA[Although Google analytics can tell us a lot about who is visiting our websites it is still flawed in many ways. Google analytics is a powerful tool but if the user has disabled Javascript or you want to know live stats it can be pretty useless. Developing our own can be much more versatile as [...]]]></description>
			<content:encoded><![CDATA[<p>Although Google analytics can tell us a lot about who is visiting our websites it is still flawed in many ways. Google analytics is a powerful tool but if the user has disabled Javascript or you want to know live stats it can be pretty useless.</p>
<p>Developing our own can be much more versatile as we can gather information straight from the server using PHP&#8217;s Predefined variables.</p>
<p>You can add your own version of with a database and a few lines of PHP code.</p>
<pre class="php" name="code">
$time = mktime();
if (isset($_SERVER['REQUEST_METHOD'])) {   // HTTP-method
   $method = $_SERVER['REQUEST_METHOD'];
} else {
   $method = "";
}
if (isset($_SERVER['REMOTE_ADDR'])) {      // IP-adress
   $ip_adress = $_SERVER['REMOTE_ADDR'];
} else {
   $ip_adress = "";
}
if (isset($_SERVER['HTTP_USER_AGENT'])) {  // Browser
   $browser = $_SERVER['HTTP_USER_AGENT'];
} else {
   $browser = "";
}
if (isset($_SERVER['PHP_SELF'])) {         // Current page
   $page = $_SERVER['PHP_SELF'];
} else {
   $page = "";
}
if (isset($_SERVER['HTTP_REFERER'])) {    // Previous page
   $referer = $_SERVER['HTTP_REFERER'];
} else {
   $referer = "";
}

$sql="INSERT INTO user_log (time, method, page, referer, adress, browser) // Insert into database as new row
					VALUES('$time','$method','$page','$referer','$ip_adress','$browser')";
mysql_query($sql);</pre>
<img src="http://feeds.feedburner.com/~r/OpenSourceWeb/~4/vA6Z5pIhGlw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.open-source-web.com/php/tracking-visitors-with-php-and-predefined-variables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.open-source-web.com/php/tracking-visitors-with-php-and-predefined-variables/</feedburner:origLink></item>
		<item>
		<title>PHP foreach loop through post request</title>
		<link>http://feedproxy.google.com/~r/OpenSourceWeb/~3/4tMmf0bwC8U/</link>
		<comments>http://www.open-source-web.com/php/php-foreach-loop-through-post-request/#comments</comments>
		<pubDate>Wed, 14 Jan 2009 21:48:49 +0000</pubDate>
		<dc:creator>Adi</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[foreach]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[request]]></category>

		<guid isPermaLink="false">http://www.open-source-web.com/?p=22</guid>
		<description><![CDATA[I use a variation of this code on most websites I have coded as it is versitile and full of uses when working with dynamic content. An example might be reusing the same mail() function for differant forms, you could loop through what is posted to it and print it out in the body of [...]]]></description>
			<content:encoded><![CDATA[<p>I use a variation of this code on most websites I have coded as it is versitile and full of uses when working with dynamic content.  An example might be reusing the same mail() function for differant forms, you could loop through what is posted to it and print it out in the body of the mail.</p>
<p>The foreach loop will process each of the requests set to the page. The $_REQUEST can be changed to just $_POST to check only posted form data or any other type of request.</p>
<p>The following loop contains a few examples of what you could do with the request once you have it.</p>
<pre name="code" class="php">
foreach ($_REQUEST as $key =&gt; $value)
{
$value = mysql_real_escape_string( $value );
$value = addslashes($value);
$value = strip_tags($value);
if($value != ""){$requestnumber ++;}
echo $key. ' - '.$value.'&lt;/br&gt;';
}</pre>
<img src="http://feeds.feedburner.com/~r/OpenSourceWeb/~4/4tMmf0bwC8U" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.open-source-web.com/php/php-foreach-loop-through-post-request/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.open-source-web.com/php/php-foreach-loop-through-post-request/</feedburner:origLink></item>
		<item>
		<title>SEO Apache Mod rewrite</title>
		<link>http://feedproxy.google.com/~r/OpenSourceWeb/~3/UMFyRrJnqOk/</link>
		<comments>http://www.open-source-web.com/apache/seo-apache-mod-rewrite/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 21:03:07 +0000</pubDate>
		<dc:creator>Adi</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[redirect]]></category>
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://www.open-source-web.com/?p=18</guid>
		<description><![CDATA[I always tried to avoid using the .htaccess file as it either works really well or will take down the entire site. The code below will work on most sites using apache as long as they have modrewrite turned on and you edit the rules to suit your domain. You may ready be using a [...]]]></description>
			<content:encoded><![CDATA[<p>I always tried to avoid using the .htaccess file as it either works really well or will take down the entire site. The code below will work on most sites using apache as long as they have modrewrite turned on and you edit the rules to suit your domain.<br />
You may ready be using a .htaccess file on your server so double check as it may not show up on all FTP programs.</p>
<p>But why do you need to use one, well the short answer is you don&#8217;t but the long answer is it can help a lot to stop duplicate content being taken off search engines and in turn help improve your SEO.<br />
For example how often do you see urls like www.bbc.com/index.html ?</p>
<p>The code below will redirect any variation on your homepage to just one. it will add the www. to the domain name and remove the index.html or index.php which ever you might be using.</p>
<pre>RewriteEngine On
RewriteCond %{HTTP_HOST} ^somedomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.somedomain.com/$1 [R=301,L]

RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.html(.*)\ HTTP/ [NC]
RewriteRule .* http://www.somedomain.com/ [R=301,L]</pre>
<img src="http://feeds.feedburner.com/~r/OpenSourceWeb/~4/UMFyRrJnqOk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.open-source-web.com/apache/seo-apache-mod-rewrite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.open-source-web.com/apache/seo-apache-mod-rewrite/</feedburner:origLink></item>
		<item>
		<title>JavaScript Input box control</title>
		<link>http://feedproxy.google.com/~r/OpenSourceWeb/~3/A1rkrLFLVpw/</link>
		<comments>http://www.open-source-web.com/javascript/javascript-input-box-control/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 20:50:45 +0000</pubDate>
		<dc:creator>Adi</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[input]]></category>

		<guid isPermaLink="false">http://www.open-source-web.com/?p=5</guid>
		<description><![CDATA[The idea behind this was to aid design and usability by adding a label inside the input box to give an indication of what it was for. It might not be a search box, maybe you want to add labels for name and address boxes who knows. Click the input box below and see how [...]]]></description>
			<content:encoded><![CDATA[<p>The idea behind this was to aid design and usability by adding a label inside the input box to give an indication of what it was for. It might not be a search box, maybe you want to add labels for name and address boxes who knows.</p>
<p>Click the input box below and see how the &#8220;search&#8221; disappears leaving it empty for the user to edit. If the user clicks and clicks off leaving it empty the label will return to &#8220;Search&#8221;</p>
<p><code><br />
<script type="text/javascript">
function out(){
	if(document.getElementById('test').value == ''){
	document.getElementById('test').value = 'Search...';
	}
}
</script></p>
<form>
<input name="test" id="test" value="Search..."onclick="document.getElementById('test').value='';"onblur="out();"/></form>
<p></code></p>
<p>Here is how it works.</p>
<p>A basic Javascript function to control the input box called &#8220;test&#8221;  This function basicaly says. Check if the box is empty, if it is make it&#8217;s value &#8220;Search&#8221;.<br />
The input box also calls Javascript &#8220;onclick&#8221; to clear the input and &#8220;onblur&#8221; to call the function below.</p>
<pre name="code" class="php">
<script type="text/javascript">
function out(){
	if(document.getElementById('test').value == ''){
	document.getElementById('test').value = 'Search...';
	}
}
</script>
<form>
<input name="test" id="test" value="Search..."
onclick="document.getElementById('test').value='';"
onblur="out();"
/>
</form>
</pre>
<img src="http://feeds.feedburner.com/~r/OpenSourceWeb/~4/A1rkrLFLVpw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.open-source-web.com/javascript/javascript-input-box-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.open-source-web.com/javascript/javascript-input-box-control/</feedburner:origLink></item>
	</channel>
</rss>
