<?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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>12ohms.com</title>
	
	<link>http://12ohms.com</link>
	<description>technology, programming, electronics</description>
	<pubDate>Thu, 02 Oct 2008 18:49:53 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/12ohms" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>C++ Templates solved: How to split the class declaration and implementation into separate files</title>
		<link>http://feedproxy.google.com/~r/12ohms/~3/V0oAyz2CWEs/</link>
		<comments>http://12ohms.com/2008/10/c-templates-multiple-files/#comments</comments>
		<pubDate>Thu, 02 Oct 2008 18:31:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[C]]></category>

		<category><![CDATA[C++]]></category>

		<category><![CDATA[programming]]></category>

		<category><![CDATA[cstdlib]]></category>

		<category><![CDATA[macros]]></category>

		<category><![CDATA[templates]]></category>

		<guid isPermaLink="false">http://12ohms.com/?p=69</guid>
		<description><![CDATA[Templates Background
Templating is one of the major enhancements added to the C++ programming language, extending the capabilities of the original C programming language.  In order to best understand their power, considder the following situation:

Assume that we&#8217;re making a sorting function, using the bubblesort function.

1
2
3
bool bubbleSort&#40;int&#38; array&#41;&#123;
...
&#125;

Ignoring the implementation of the function for now, take a [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Templates Background</strong></p>
<p>Templating is one of the major enhancements added to the C++ programming language, extending the capabilities of the original C programming language.  In order to best understand their power, considder the following situation:</p>
<p><span id="more-69"></span></p>
<p>Assume that we&#8217;re making a sorting function, using the bubblesort function.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="cpp cpp" style="font-family:monospace;"><span style="color: #0000ff;">bool</span> bubbleSort<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span><span style="color: #000040;">&amp;</span> array<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
...
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Ignoring the implementation of the function for now, take a look at the declaration.  Now this function will work perfectly if we want to only sort data of type Integer, but what if we want to say sort chars?</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="cpp cpp" style="font-family:monospace;"><span style="color: #0000ff;">bool</span> bubbleSort_int<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span><span style="color: #000040;">&amp;</span> array<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
...
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">bool</span> bubbleSort_char<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">char</span><span style="color: #000040;">&amp;</span> array<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
...
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>The problem here is excess code.  Having two identical implementations of the same algorithm, with the only difference being teh data type is very redundant.  A better solution would be for us to be able to supply the type we want to use at runtime.  This is the power of templates.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="cpp cpp" style="font-family:monospace;"><span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">typename</span> T<span style="color: #000080;">&gt;</span>
<span style="color: #0000ff;">bool</span> bubbleSort<span style="color: #008000;">&#40;</span>T<span style="color: #000040;">&amp;</span> array<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
...
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>In the code above, we specify the variable T to be a type, that we can then define the type to use in the function call simply as follows:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="cpp cpp" style="font-family:monospace;">bubbleSort<span style="color: #000080;">&lt;</span><span style="color: #0000ff;">int</span><span style="color: #000080;">&gt;</span><span style="color: #008000;">&#40;</span>foo<span style="color: #008000;">&#41;</span>;</pre></td></tr></table></div>

<p>Thus the problem is then fully solved.</p>
<p><strong>Multiple Files</strong></p>
<p>Traditionally when using C++, we keep a class definition in the .h/.hpp file and the class implementation in the .c/.cpp file.  This causes a problem when using class templates.  A template strictly speaking is not a class or a function, it is a design pattern.  due to this, it needs to be all in one place.  If you try to separate the definition and implementation, a linker error will follow.</p>
<p>This creates a problem , as in an application, we will have normal classes with their implementations and declarations split, then any templated classes in a single file.  There are several ways around this problem.</p>
<p>The first is simple, provide a prototype for each templated function with each embedded type as follows:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="cpp cpp" style="font-family:monospace;"><span style="color: #0000ff;">template</span> <span style="color: #000080;">&lt;</span><span style="color: #0000ff;">int</span><span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">void</span> foo<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>;</pre></td></tr></table></div>

<p>This is very cumbersome to say the least, clearly a more generic solution is needed.</p>
<p><strong>Solution 1 : Export Keyword</strong></p>
<p>The C++ &#8220;export&#8221; keyword was designed to solve this problem.  However due to politics, it is seldom implemented by any of the main compillers, and thus is almost useless.  The only compiller i could find that implements it was <a href="http://www.comeaucomputing.com/4.0/docs/userman/export.html">Comeau C++</a>.</p>
<p>Although not often implemented, it provides simple usage, by simply placing the following line in the .c/c.pp implementation file as follows:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="cpp cpp" style="font-family:monospace;">export <span style="color: #0000ff;">template</span> ....</pre></td></tr></table></div>

<p><strong>Solution 2 : Preprocessor Macros</strong></p>
<p>Clearly the best way to solve the problem is to use preprocessor macros.  However we will also add in support for the export keyword if it is avaliable with the compiller we are using.</p>
<p>First in out declaration (h/.hpp file) we will place the following directives:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="cpp cpp" style="font-family:monospace;"><span style="color: #339900;">#ifndef COMPILER_SUPPORTS_EXPORT</span>
<span style="color: #339900;">#define FROM_MYCLASS_H</span>
<span style="color: #339900;">#include &quot;myclass.cpp&quot;</span>
<span style="color: #339900;">#endif</span></pre></td></tr></table></div>

<p>We will use the constant COMPILER_SUPPORTS_EXPORT to define whether the compiler currently being used supports the export keyword.  By default, it is not defined, and so we use a preprocessor directoves method.  However if we using a compiler that does implement it, we can simply add</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="cpp cpp" style="font-family:monospace;"><span style="color: #339900;">#define COMPILER_SUPPORTS_EXPORT</span></pre></td></tr></table></div>

<p>somewhere in a global position.</p>
<p>The code (previous) does two jobs.  Firstly it checks to see if export is enabled.  If not it defines a constant specific to the file, called FROM_MYCLASS_H.  We will use this later in the implementation (.c/.cpp file).  Finally it includes the implementation file.  This will remove all linker error messages.</p>
<p>The next problem is one of redeclaration.  If we leave the code as it is, we&#8217;re likely to get compiller errors for redeclaration of methods in our class.  To solve this, we can add preprocessor directoves in our implementation (.cpp / .c) file.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="cpp cpp" style="font-family:monospace;"><span style="color: #339900;">#ifdef COMPILER_SUPPORTS_EXPORT</span>
<span style="color: #339900;">#define FROM_MYCLASS_H</span>
<span style="color: #339900;">#endif</span>
&nbsp;
<span style="color: #339900;">#ifdef FROM_MYCLASS_H</span>
&nbsp;
<span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">typename</span> T<span style="color: #000080;">&gt;</span>myclass<span style="color: #008080;">::</span><span style="color: #007788;">mymethod</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
....
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #339900;">#undef FROM_MYCLASS_H</span>
<span style="color: #339900;">#endif</span>
<span style="color: #339900;">#ifdef COMPILER_SUPPORTS_EXPORT</span>
export <span style="color: #0000ff;">template</span>.....
<span style="color: #339900;">#endif</span></pre></td></tr></table></div>

<p>In order to understand this, lets start with line #9.  This means that all of our implementation code will ONLY be visable if FROM_MYCLASS_H is defined.  Now, if we have come from the include statement in the header file, this will already be defined as normal, and will work perfectly, and we are done.  The only thing to add is line #15.  Here we undefine our constant, so that the code will not be included for anything else including it in the future.</p>
<p>Now we have to examine the case whereby the compiller does support export, and thus COMPILER_SUPPORTS_EXPORT is defined.  In this case, the source file will not be included by the header file, as we specified earlier.  However we need the .cpp file to show its code, and thus FROM_MYCLASS_H must therefore be defined.  To solve this problem, we put the code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="cpp cpp" style="font-family:monospace;"><span style="color: #339900;">#ifdef COMPILER_SUPPORTS_EXPORT</span>
<span style="color: #339900;">#define FROM_MYCLASS_H</span>
<span style="color: #339900;">#endif</span></pre></td></tr></table></div>

<p>If the compmiller supports export, we define FROM_MYCLASS_H so that the compiller can see the sourcode when compilling the source (.c/.cpp file) directly, and then remove the constant afterwards as normal.</p>
<p>This gives us final code of:</p>
<p><em>Header (.h) file:</em></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="cpp cpp" style="font-family:monospace;"><span style="color: #339900;">#ifndef MYCLASS_H</span>
<span style="color: #339900;">#define MYCLASS_H</span>
&nbsp;
<span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">typename</span> T<span style="color: #000080;">&gt;</span>
<span style="color: #0000ff;">class</span> myclass<span style="color: #008000;">&#123;</span>
...
<span style="color: #008000;">&#125;</span>;
&nbsp;
<span style="color: #339900;">#ifndef COMPILER_SUPPORTS_EXPORT</span>
<span style="color: #339900;">#define FROM_MYCLASS_H</span>
<span style="color: #339900;">#include &quot;myclass.cpp&quot;</span>
<span style="color: #339900;">#endif</span>
&nbsp;
<span style="color: #339900;">#endif</span></pre></td></tr></table></div>

<p><em>Source (.cpp) file:</em></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="cpp cpp" style="font-family:monospace;"><span style="color: #339900;">#ifdef COMPILER_SUPPORTS_EXPORT</span>
<span style="color: #339900;">#define FROM_MYCLASS_H</span>
<span style="color: #339900;">#endif</span>
&nbsp;
<span style="color: #339900;">#ifdef FROM_MYCLASS_H</span>
&nbsp;
<span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">typename</span> T<span style="color: #000080;">&gt;</span>myclass<span style="color: #008080;">::</span><span style="color: #007788;">mymethod</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span><span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #339900;">#undef FROM_MYCLASS_H</span>
<span style="color: #339900;">#endif</span>
<span style="color: #339900;">#ifdef COMPILER_SUPPORTS_EXPORT</span>
export <span style="color: #0000ff;">template</span>...
<span style="color: #339900;">#endif</span></pre></td></tr></table></div>

<p>Happy Coding <img src='http://12ohms.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
<img src="http://feeds.feedburner.com/~r/12ohms/~4/V0oAyz2CWEs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://12ohms.com/2008/10/c-templates-multiple-files/feed/</wfw:commentRss>
		<feedburner:origLink>http://12ohms.com/2008/10/c-templates-multiple-files/</feedburner:origLink></item>
		<item>
		<title>On the espresso</title>
		<link>http://feedproxy.google.com/~r/12ohms/~3/2xS5gEse284/</link>
		<comments>http://12ohms.com/2008/08/on-the-espresso/#comments</comments>
		<pubDate>Tue, 12 Aug 2008 22:28:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[C]]></category>

		<category><![CDATA[C++]]></category>

		<category><![CDATA[Game Dev]]></category>

		<category><![CDATA[Misc]]></category>

		<category><![CDATA[OpenGL]]></category>

		<category><![CDATA[programming]]></category>

		<category><![CDATA[DirectX]]></category>

		<guid isPermaLink="false">http://12ohms.com/?p=28</guid>
		<description><![CDATA[Game development has always been one of those areas of programming that i&#8217;ve found really interesting, albeit one of the hardest.  Though as the summer has gone on, my boredom has grew exponentially, and i decided that its about time to start a project to remove some it for now at least.

There are a [...]]]></description>
			<content:encoded><![CDATA[<p>Game development has always been one of those areas of programming that i&#8217;ve found really interesting, albeit one of the hardest.  Though as the summer has gone on, my boredom has grew exponentially, and i decided that its about time to start a project to remove some it for now at least.</p>
<p><span id="more-28"></span></p>
<p>There are a lot of good open source graphics engine, that offer near commercial quality.  I&#8217;ve experimented with a lot of these in the past, and the results have been mixed.  I found that the best open source ones out there are currently Crystal Space (<a href="http://www.crystalspace3d.org">http://www.crystalspace3d.org</a>) and Ogre (<a href="http://www.ogre3d.org">http://www.ogre3d.org/</a>).</p>
<p>This is a screenshot of Decals running in CS.</p>
<div class="wp-caption aligncenter" style="width: 190px"><img title="Decals" src="http://www.crystalspace3d.org/mediawiki/images/thumb/a/ad/Showcase_1_1_Decals.jpg/180px-Showcase_1_1_Decals.jpg" alt="" width="180" height="139" /><p class="wp-caption-text">Decals</p></div>
<p>In comparison, MotorM4X running in Ogre&#8230;</p>
<div class="wp-caption aligncenter" style="width: 160px"><img title="MotorM4X" src="http://www.ogre3d.org/gallery/albums/album59/mb_06_1024.highlight.jpg" alt="MotorM4X" width="150" height="113" /><p class="wp-caption-text">MotorM4X</p></div>
<p>After playing with both of them a couple of years ago, i managed to get bored with the simplicity of the coding these APIs allow to create a game, with even a complete newbie being able to create something good in a few days.</p>
<p>Thus, espresso was born.  Its my (and adam&#8217;s) first attempt to build my own graphics engine from scratch and is definately going to be an interesting project.  It not only means exposing all of the crazy vector calculus of creating a 3d computer world, but also the endless physics, algorithms and rendering techniques with OpenGL / DirectX.  thanks to the good people at google, we have a subversion repository along with project management tools hosted with google code (<a href="http://code.google.com/p/espressoengine/">http://code.google.com/p/espressoengine/</a>).  Its also being released under the MIT licence, so anyone is free to download it and use it as they wish.</p>
<p>Check back every once in a while, and i&#8217;ll add some articles of the endless fun, and psycotic moments while attempting to implement it <img src='http://12ohms.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
<img src="http://feeds.feedburner.com/~r/12ohms/~4/2xS5gEse284" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://12ohms.com/2008/08/on-the-espresso/feed/</wfw:commentRss>
		<feedburner:origLink>http://12ohms.com/2008/08/on-the-espresso/</feedburner:origLink></item>
		<item>
		<title>AJAX - A simple Introduction</title>
		<link>http://feedproxy.google.com/~r/12ohms/~3/NNHx8cuvs9Y/</link>
		<comments>http://12ohms.com/2008/07/ajax-a-simple-introduction/#comments</comments>
		<pubDate>Thu, 24 Jul 2008 20:41:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[mySQL]]></category>

		<category><![CDATA[programming]]></category>

		<category><![CDATA[security]]></category>

		<category><![CDATA[web dev]]></category>

		<guid isPermaLink="false">http://12ohms.com/?p=8</guid>
		<description><![CDATA[AJAX has became the new buzz word of the internet, but what is it? and what does it actually do?
Introduction
Suppose we have a webpage, displaying news.
Now, for the user to switch from one news story is pretty unefficient.
The only part of the webpage that changes is the news content area, though the whole page (graphics [...]]]></description>
			<content:encoded><![CDATA[<p>AJAX has became the new buzz word of the internet, but what is it? and what does it actually do?</p>
<p><strong><span style="color: darkred;">Introduction</span></strong></p>
<p>Suppose we have a webpage, displaying news.</p>
<p>Now, for the user to switch from one news story is pretty unefficient.<br />
The only part of the webpage that changes is the news content area, though the whole page (graphics and all) is reloaded from the webserver. Wouldnt is be great if there is some way we could only change part of the html?</p>
<p><span id="more-8"></span></p>
<p><strong><span style="color: blue;">this is what AJAX allows us to do.</span></strong></p>
<p><strong></strong><span style="color: blue;"><span style="color: black;">AJAX stands for </span></span><span>Asynchronous JavaScript and XML.  The basic idea is this.</span></p>
<ul>
<li><span> In the case of our example, the user clicks on a link to view a different news story. This click action is picked up with javascript , rather than a normal &lt;a href=&#8221;"&gt; style tag pointing to a different URL. </span></li>
</ul>
<ul>
<li><span>The javascript function then sends a HTTP request to the webserver for the information (i.e. the new news story). The webserver then sends back the news story to the web browser , generally in XML format. </span></li>
</ul>
<ul>
<li><span>The javascript then parses this javascript, and places the text of the story into the correct places. All the time through, the whole page is not reloaded, but instead only the news content area is changed by javascript. </span></li>
</ul>
<p><span><br />
This allows for far more eficiency, less bandwidth consumption, and also a far quicker loading time.</span></p>
<p><strong><span style="color: darkred;">Example</span></strong></p>
<p><span style="color: darkred;"><span style="color: black;">Now, lets create a quick basic example, showing the power of AJAX.<br />
<span style="color: green;"><strong></strong></span></span></span></p>
<p><strong></strong><span style="color: black;">In order to save us alot of time, we will not write a whole set of functions in javascript to get and send information to the webserver, instead we will use a AJAX libary called Prototype (<a href="http://www.prototypejs.org/" target="_blank">www.prototypejs.org</a>).  This simplifies the task greatly.</span></p>
<p>The first step is to explain the setup we will use for this example.</p>
<ul>
<li><span><span style="color: darkred;"><span style="color: black;"><span style="color: green;"><span style="color: black;">We will start by having a HTML page, to display anews article (as above).</span></span></span></span></span></li>
</ul>
<ul>
<li><span><span style="color: darkred;"><span style="color: black;"><span style="color: green;"><span style="color: black;">This will include some javascript to handle all AJAX functions.</span></span></span></span></span></li>
</ul>
<ul>
<li><span><span style="color: darkred;"><span style="color: black;"><span style="color: green;"><span style="color: black;">Lastly we will have a PHP file to send the news articles to the client.</span></span></span></span></span></li>
</ul>
<p><strong><span style="color: sienna;">Step 1 : PHP File</span></strong></p>
<p><strong></strong><span style="color: sienna;"><span style="color: black;">First up is to create a PHP file to grab news files from our Mysql Database.</span></span></p>
<p>I&#8217;ll design a simple database table like this:</p>
<div>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="sql sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`news`</span> <span style="color: #66cc66;">&#40;</span>
<span style="color: #ff0000;">`news_guid`</span> int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">`news_title`</span> varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">`news_tagline`</span> varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">`news_body`</span> varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">`news_author`</span> varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">`news_date`</span> varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
<span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span>  <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`news_guid`</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span> ENGINE<span style="color: #66cc66;">=</span>MyISAM <span style="color: #993333; font-weight: bold;">DEFAULT</span> CHARSET<span style="color: #66cc66;">=</span>latin1 <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #66cc66;">=</span><span style="color: #cc66cc;">4</span> ;</pre></td></tr></table></div>

</div>
<p>255 character strings wont normally suffice for a real application, but are set this way to keep the sample application small.</p>
<p>Now with that created, we create a simple PHP script, to first loadup the database, and to query the database for the correct story.</p>
<p>We will place the story id as apart of the GET variables.. so we can have for example:</p>
<div style="margin: 5px 20px 20px;">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">ourfile.php?storyid=1</pre></td></tr></table></div>

</div>
<div style="margin: 5px 20px 20px;">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// loadup db</span>
<span style="color: #000088;">$hDatabase</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span><span style="">'your_host'</span><span style="color: #339933;">,</span> <span style="">'your_usrn'</span><span style="color: #339933;">,</span><span style="">'your_pass'</span><span style="color: #009900;">&#41;</span>;
<span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="">'your_db_name'</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">// lets assume that no hacker will be trying</span>
<span style="color: #666666; font-style: italic;">// to break into our site, as this is just an example</span>
<span style="color: #666666; font-style: italic;">// so i will not bother checking that the data input is</span>
<span style="color: #666666; font-style: italic;">// a sql injection etc (see php security mistakes article)</span>
<span style="color: #000088;">$news_story_id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="">'storyid'</span><span style="color: #009900;">&#93;</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">//query the database</span>
<span style="color: #000088;">$dataset</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT * FROM news WHERE news_guid = '$news_story_id'&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$hDatabase</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">//check valid story number</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_num_rows</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dataset</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//just show the first story</span>
<span style="color: #000088;">$dataset</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT * FROM news WHERE news_guid = '1'&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$hDatabase</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_assoc</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dataset</span><span style="color: #009900;">&#41;</span>;</pre></td></tr></table></div>

</div>
<p>This is all pretty simple, but what we want is the data to be output in XML format, for the javascript. Again, to save time, i have created an XML class to do this. (see included zip file for sourcecode).</p>
<p>If you havent met XML before, i suggest <a href="http://www.w3schools.com/xml/default.asp" target="_blank">reading this</a> as some basic background first.</p>
<p>we will now add in this code, to initialise and include the class:</p>
<div style="margin: 5px 20px 20px;">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #b1b100;">require</span><span style="color: #009900;">&#40;</span><span style="">'xmlcreator.php'</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">// create XML object (see cmlcreator.php)</span>
<span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> XML_CREATOR<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;</pre></td></tr></table></div>

</div>
<p>With this class we will create a &#8220;Main News Element&#8221;, with attributes for the content, author, date etc. so eventually it will look like this:</p>
<div style="margin: 5px 20px 20px;">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="xml xml" style="font-family:monospace;">The tagline goes here
&nbsp;
The actual story goes here
&nbsp;
the author goes here
the date goes here</pre></td></tr></table></div>

</div>
<p>Now, we will create this using the class by:</p>
<ul>
<li>Running the begin() function</li>
<li>Creating the Main News Tag</li>
<li>Adding the body, author etc. attributes</li>
<li>Closing the News tag</li>
<li>running the end() function</li>
</ul>
<div style="margin: 5px 20px 20px;">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//now, lets create the XML</span>
<span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">begin</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addElement</span><span style="color: #009900;">&#40;</span><span style="">'news'</span><span style="color: #339933;">,</span> <span style="">''</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addAttribute</span><span style="color: #009900;">&#40;</span><span style="">'title'</span><span style="color: #339933;">,</span> <span style="">''</span><span style="color: #339933;">,</span>   <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="">'news_title'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span>;
<span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addAttribute</span><span style="color: #009900;">&#40;</span><span style="">'tagline'</span><span style="color: #339933;">,</span> <span style="">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="">'news_tagline'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addAttribute</span><span style="color: #009900;">&#40;</span><span style="">'body'</span><span style="color: #339933;">,</span> <span style="">''</span><span style="color: #339933;">,</span>    <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="">'news_body'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addAttribute</span><span style="color: #009900;">&#40;</span><span style="">'author'</span><span style="color: #339933;">,</span> <span style="">''</span><span style="color: #339933;">,</span>  <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="">'news_author'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addAttribute</span><span style="color: #009900;">&#40;</span><span style="">'date'</span><span style="color: #339933;">,</span> <span style="">''</span><span style="color: #339933;">,</span>    <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="">'news_date'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">closeElement</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">end</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;</pre></td></tr></table></div>

</div>
<p>Finally, we want the php page to output this xml:</p>
<div style="margin: 5px 20px 20px;">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//output XML</span>
<span style="color: #990000;">echo</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&amp;</span>gt;getXml<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;</pre></td></tr></table></div>

</div>
<p><span style="color: sienna;"><span style="color: black;"><strong><span style="color: sienna;">Step 2  HTML &amp; Javascript</span></strong></span></span></p>
<p><strong></strong><span style="color: sienna;"><span style="color: black;">Now its time to create our html page design.</span></span></p>
<p><span style="color: sienna;"><span style="color: black;"> For the way the javascript is wrote in this example.. make sure that:</span></span></p>
<ol style="list-style-type: decimal;">
<li><span style="color: sienna;"><span style="color: black;">Area where title goes is a <span style="color: black;">&lt;p&gt; tag</span> with id <strong><span style="color: blue;">title</span></strong></span></span></li>
<li><span style="color: sienna;"><span style="color: black;">Area where taglines goes is a &lt;p&gt; tag with id <strong><span style="color: blue;">tagline</span></strong></span></span></li>
<li><span style="color: sienna;"><span style="color: black;">Area where date goes is a &lt;p&gt; tag with id <strong><span style="color: blue;">date</span></strong></span></span></li>
<li><span style="color: sienna;"><span style="color: black;">Area where story goes is a &lt;p&gt; tag with id <span style="color: blue;"><strong>body</strong></span></span></span></li>
<li><span style="color: sienna;"><span style="color: black;">Area where autho goes is a &lt;p&gt; tag with id <span style="color: blue;"><strong>author</strong></span></span></span></li>
</ol>
<p><strong><span style="color: seagreen;">With this created, lets now make the javascript</span></strong></p>
<p><strong></strong><span style="color: seagreen;"><span style="color: black;">As i said before, we&#8217;ll use the prototype libary for this&#8230;<br />
For more information about its use, and to download it, visit their website:</span></span><span><span style="color: darkred;"><span style="color: black;"><span style="color: green;"><span style="color: black;">(<a href="http://www.prototypejs.org/" target="_blank">www.prototypejs.org</a>).</span></span></span></span></span></p>
<p>We will first craete a file called index.js.<br />
This will have a function called getstory whcih will simply run the code<br />
to get the story from the php script, and then put it into the html</p>
<p>This will be run when the view story 1 etc. buttons are clicked</p>
<p>we&#8217;ll create a file index.js with the contents:</p>
<div style="margin: 5px 20px 20px;">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> getstory<span style="color: #009900;">&#40;</span>form<span style="color: #339933;">,</span> id<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> param <span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span>;
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> ParseFunc <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>t<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> xmlDoc <span style="color: #339933;">=</span> t.<span style="color: #660066;">responseXML</span>.<span style="color: #660066;">documentElement</span>;
&nbsp;
document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'author'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> xmlDoc.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'author'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">firstChild</span>.<span style="color: #660066;">data</span>;
document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'date'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> xmlDoc.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'date'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">firstChild</span>.<span style="color: #660066;">data</span>;
document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'title'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> xmlDoc.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'title'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">firstChild</span>.<span style="color: #660066;">data</span>;
document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'tagline'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> xmlDoc.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'tagline'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">firstChild</span>.<span style="color: #660066;">data</span>;
document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> xmlDoc.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">firstChild</span>.<span style="color: #660066;">data</span>;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> Error <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>t<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Error 404: location &quot;'</span> <span style="color: #339933;">+</span> t.<span style="color: #660066;">statusText</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot; was not found.'</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">new</span> Ajax.<span style="color: #660066;">Request</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'getnews.php?storyid='</span><span style="color: #339933;">+</span>id<span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>onSuccess<span style="color: #339933;">:</span>ParseFunc<span style="color: #339933;">,</span> on404<span style="color: #339933;">:</span>Error<span style="color: #339933;">,</span> onFailure<span style="color: #339933;">:</span>Error<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

</div>
<p>Lets look at this in closer detail&#8230;</p>
<p>The getstory fiunction is defined as:</p>
<div style="margin: 5px 20px 20px;">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> getstory<span style="color: #009900;">&#40;</span>form<span style="color: #339933;">,</span> id<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></pre></td></tr></table></div>

</div>
<p>and then several variables are defined&#8230;&#8230;</p>
<div style="margin: 5px 20px 20px;">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> param <span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span>;
<span style="color: #003366; font-weight: bold;">var</span> ParseFunc <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>t<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>......<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">var</span> Error <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>t<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>.......<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

</div>
<p>The param var is to hold any etra parameters for the AJAX function (again see prototype website for more info).</p>
<p>The parsefunc variable is a function, that parses the XML into our HTML page. looking at its definition:</p>
<div style="margin: 5px 20px 20px;">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> ParseFunc <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>t<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></pre></td></tr></table></div>

</div>
<p>The variable T is the XML data</p>
<p>The parsing ofXML and inserting into html here is created using a javascript feature called DOM please <a href="http://www.howtocreate.co.uk/tutorials/javascript/dombasics" target="_blank">read this</a> if you have not met it before.</p>
<p>The Error variable holdsa function that is run if the Ajax function does not run properly. Here, it just creates a popup menu.The finalpart of the code is the call to the AJAX function:</p>
<div style="margin: 5px 20px 20px;">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript javascript" style="font-family:monospace;"> <span style="color: #003366; font-weight: bold;">new</span> Ajax.<span style="color: #660066;">Request</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'getnews.php?storyid='</span><span style="color: #339933;">+</span>id<span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>onSuccess<span style="color: #339933;">:</span>ParseFunc<span style="color: #339933;">,</span> on404<span style="color: #339933;">:</span>Error<span style="color: #339933;">,</span> onFailure<span style="color: #339933;">:</span>Error<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</pre></td></tr></table></div>

</div>
<p>This simply gets the data from the url given to it, note that we&#8217;ve also included the story id as the variable id.</p>
<p><span style="color: sienna;"><strong>Putting it all together</strong></span></p>
<p><strong></strong><span style="color: black;">The last step is to connect this javascript function to our html.</span></p>
<p>This is done by creating tags in the html , linking to other stories:</p>
<div style="margin: 5px 20px 20px;">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;a onclick=&quot;getstory(this,1);&quot; href=&quot;#&quot;&gt;Load Story 1&lt;/a&gt;
&lt;a onclick=&quot;getstory(this,2);&quot; href=&quot;#&quot;&gt;Load Story 2&lt;/a&gt;
&lt;a onclick=&quot;getstory(this,3);&quot; href=&quot;#&quot;&gt;Load Story 3&lt;/a&gt;</pre></td></tr></table></div>

</div>
<p>And now were complete <img src='http://12ohms.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<span><strong><span style="color: darkred;"><br />
</span></strong></span></p>
<img src="http://feeds.feedburner.com/~r/12ohms/~4/NNHx8cuvs9Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://12ohms.com/2008/07/ajax-a-simple-introduction/feed/</wfw:commentRss>
		<feedburner:origLink>http://12ohms.com/2008/07/ajax-a-simple-introduction/</feedburner:origLink></item>
		<item>
		<title>Writing Secure PHP scripts</title>
		<link>http://feedproxy.google.com/~r/12ohms/~3/HPEYTvHRQrM/</link>
		<comments>http://12ohms.com/2008/07/writing-secure-php-scripts/#comments</comments>
		<pubDate>Thu, 24 Jul 2008 20:31:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[mySQL]]></category>

		<category><![CDATA[programming]]></category>

		<category><![CDATA[security]]></category>

		<category><![CDATA[web dev]]></category>

		<guid isPermaLink="false">http://12ohms.com/?p=5</guid>
		<description><![CDATA[One of the most overlooked things in Web Development - especially in PHP - is making sure that your scripts are secure. Here&#8217;s some details of some basic mistakes people make when programming websites in PHP, and how these little mistakes can be used by any malicious user to gain access to the website. This [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most overlooked things in Web Development - especially in PHP - is making sure that your scripts are secure. Here&#8217;s some details of some basic mistakes people make when programming websites in PHP, and how these little mistakes can be used by any malicious user to gain access to the website. This is by no means a full article, but it covers the basic errors, and how to remove them from your code.</p>
<p>Ultimately, a &#8216;hacker&#8217; wants to gain access to a website for a variety of reasons. Maybe to steal users details, bank account information etc, or even just to simply deface it. Either way, as programmers, we have to be aware of the methods they use so that we can write code that is secure.<br />
This article will cover 4 basic areas:</p>
<ul>
<li>Register Globals</li>
<li>XSS ( Cross Site Scripting ) attacks</li>
<li>Session Id Stealing</li>
<li>SQL Injections<span id="more-5"></span></li>
</ul>
<p><strong>Register Globals</strong><br />
Register globals is perhaps the oldest vulnerability in PHP. and also the simplest for hackers to exploit.</p>
<p><strong><em>What is Register Globals? </em></strong><br />
Register globals is a simple feature added to PHP to make data input handling easier. Say we have a form input page, with a textbox called &#8216;username&#8217; box:</p>
<div style="margin: 5px 20px 20px;">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #990000;">echo</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="">'username'</span><span style="color: #009900;">&#93;</span>;     <span style="color: #666666; font-style: italic;">// conventional method</span>
<span style="color: #990000;">echo</span> <span style="color: #000088;">$username</span>;</pre></td></tr></table></div>

</div>
<p>Instead of having to get the value from the $_POST array, register globals automatically creates a variable $username, and assigns it the value from the form. This works for both vales sent by GET and POST methods.</p>
<p><em><strong> Example</strong></em><br />
Suppose we have a members only webpage, and in order to check if the user is a valid member, we check for a cookie on the users system, that would be set when the person logged in.</p>
<div style="margin: 5px 20px 20px;">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_COOKIE</span><span style="color: #009900;">&#91;</span><span style="">'secret_site'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$auth</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span>;
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$auth</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;You are not allowed in&quot;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #990000;">echo</span> <span style="color: #0000ff;">&quot;Welcome to the secret admin area&quot;</span>;
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

</div>
<p>This is a very basic script, but it illustrates the problem of register globals well. At a a glance, this script looks fin, and is we try to run it,<br />
we can see that we are not allowed access.</p>
<p>However, now lets try loading the script, but adding a GET value to the query string.</p>
<p><span style="color: #ff0000;"><em>register_globals.php?auth=1</em></span></p>
<p>We still dont have the cookie, but register globals means a hacker doesnt need it. Sending a variable called auth with a value 1 in the GET values, a variable $auth is craeted with the value of 1. So, even though we do not have the cookie:</p>
<div style="margin: 5px 20px 20px;">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$auth</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;You are not allowed in&quot;</span><span style="color: #009900;">&#41;</span>;        <span style="color: #666666; font-style: italic;">// register_globals sets $auth to 1 so we dont enter this if statement</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #990000;">echo</span> <span style="color: #0000ff;">&quot;Welcome to the secret admin area&quot;</span>;    <span style="color: #666666; font-style: italic;">// we enter here, without the cookie!</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

</div>
<p><strong><em>Solution</em></strong></p>
<p><strong><em></em></strong> The solution to this is very simple, make sure register_globals is turned off.<br />
This can be completed by editing the php config file (php.ini) or can also be set using code using the <a href="http://uk.php.net/ini_set" target="_blank">ini_set()</a>function.</p>
<p>Note that latter versions of php have register_globals turned off as default so the sample script may not work. Remember to check your hosts configuration to protect your site.</p>
<p><strong>XSS Attacks</strong></p>
<p>Cross site scripting is probably the most common exploit used by hackers at the moment, so we have to be very aware of it when we are writing code. It all stems from the problem that programmers forget to validate and sanitize data that users have input.</p>
<p><strong><em>example<br />
</em></strong><br />
Suppose we have a blog like site we have made in php, with a part at the bottom where users can leave comments.</p>
<p>Also suppose that the users details are stores in a cookie when they login, as many websites do dor security.</p>
<p>I have simulated this here by just issuing a cookie for a user &#8220;steve&#8221; with a password &#8220;secret_pass&#8221;</p>
<div style="margin: 5px 20px 20px;">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code"><pre class="php php" style="font-family:monospace;">&nbsp;
<span style="color: #990000;">setcookie</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;mysite&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="">'username'</span><span style="color: #339933;">=&amp;</span>gt;<span style="">'steve'</span><span style="color: #339933;">,</span><span style="">'password'</span><span style="color: #339933;">=&amp;</span>gt;<span style="">'secret_pass'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="">'|||'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="">'message'</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>
&nbsp;
<span style="color: #990000;">echo</span> <span style="">'
&lt;h1&gt;Please Enter your Comment&lt;/h1&gt;
&lt;form style=&quot;color: #0000ff;&quot; action=&quot;&amp;lt;span&quot;&gt;&quot;./xss_hack.php&quot;&lt;/form&gt;method=&lt;span style=&quot;color: #0000ff;&quot;&gt;&quot;post&quot;&lt;/span&gt;&amp;gt;
&lt;span style=&quot;color: #ff8000;&quot;&gt;&lt;textarea style=&quot;color: #0000ff;&quot; name=&quot;&amp;lt;span&quot;&gt;&quot;message&quot;&amp;lt;/span&amp;gt; &amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span style=&quot;color: #ff8000;&quot; mce_style=&quot;color: #ff8000;&quot;&amp;gt;&lt;/textarea&gt;&lt;/span&gt;
&nbsp;
&lt;input style=&quot;color: #0000ff;&quot; type=&quot;&amp;lt;span&quot; /&gt;&quot;submit&quot; value=&lt;span style=&quot;color: #0000ff;&quot;&gt;&quot;Submit&quot;&lt;/span&gt;&amp;gt;
&nbsp;
'</span>;
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #990000;">echo</span> <span style="">'
&lt;h1&gt;This was Your Comment&lt;/h1&gt;
'</span><span style="color: #339933;">.</span><span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="">'message'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="">'
&nbsp;
'</span>;
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

</div>
<p>Now this looks very innoscent, and its not obvious atall what is wrong with it.<br />
But now try this, enter this as your message:</p>
<div style="margin: 5px 20px 20px;">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
 alert(document.cookie);
// --&gt;&lt;/script&gt;</pre></td></tr></table></div>

</div>
<p>What happens here is that we have entered some html as the message. This html is a script tag, containing soem javascript. The javascript pops up a message box with the contents of the cookie. Again, you might think, so what? but what if instead of being javascript code to popup a box, it instead sent this cookie information to the hacker?<br />
Any user that is logged in and loads that comments page will have their username and password stolen without even knowing. This is the power of XSS.</p>
<p><em><strong>XSS With Sessions </strong></em><br />
So the first thought is, ok, i&#8217;ll use sessions to store the users details, instead of  a cookie.  Bad idea.<br />
Sessions have a unique session ID that is stored either in a cookie, or in the GET variables query string, i.e.</p>
<p><span style="color: #ff0000;"><em>xss_hack.php?session_id=g4n48474g4746gdjf89495</em></span></p>
<p>Either way, this is easy pickings for the hacker.<br />
If the session id is stored in a cookie, the hacker just uses the same injected html as before, and creates a cookie on his computer with teh same value, and he/she has access to your user account. Or if the session is stored in the string, the hacker simply modifies the javascript to take this, and then they simply point their browser to the same page, with your session id added on.</p>
<p><em><strong>Solutions</strong></em><br />
Ultimately, the solution is pretty simple.  Whenever inputing data from users to your website/database,<br />
sanatize it! Make sure you strip out all html characters.</p>
<p><strong>SQL Injections </strong><br />
The final method we will look at is SQL injections. These are a very cute and clevor way of a hacker gaining access to your website. They are called SQL injections as inadvertantly, extra data is added into the SQL query.</p>
<p><strong><em>Example</em></strong><br />
Lets suppose we have a standard login page, with a username and password box.<br />
We also have a database, containing the users username/password.</p>
<div style="margin: 5px 20px 20px;">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
</pre></td><td class="code"><pre class="php php" style="font-family:monospace;">&nbsp;
<span style="color: #000088;">$db_handle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span><span style="">'localhost'</span><span style="color: #339933;">,</span> <span style="">'root'</span><span style="color: #339933;">,</span> <span style="">'your_password'</span><span style="color: #009900;">&#41;</span>;
<span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="">'security_tutorial'</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="">'username'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> || <span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="">'password'</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>
&nbsp;
<span style="color: #990000;">echo</span> <span style="">'
&lt;h1&gt;Please Enter your username and password to proceed&lt;/h1&gt;
&lt;form style=&quot;color: #0000ff;&quot; action=&quot;&amp;lt;span&quot;&gt;&quot;./sql_injection.php&quot; method=&lt;span style=&quot;color: #0000ff;&quot;&gt;&quot;post&quot;&lt;/span&gt;&amp;gt;
Username:
&nbsp;
&lt;input style=&quot;color: #0000ff;&quot; type=&quot;&amp;lt;span&quot; /&gt;&quot;text&quot; name=&lt;span style=&quot;color: #0000ff;&quot;&gt;&quot;username&quot;&lt;/span&gt; /&amp;gt;
&nbsp;
Password:
&nbsp;
&lt;input style=&quot;color: #0000ff;&quot; type=&quot;&amp;lt;span&quot; /&gt;&quot;password&quot; name=&lt;span style=&quot;color: #0000ff;&quot;&gt;&quot;password&quot;&lt;/span&gt; /&amp;gt;
&nbsp;
&lt;input style=&quot;color: #0000ff;&quot; type=&quot;&amp;lt;span&quot; /&gt;&quot;submit&quot; value=&lt;span style=&quot;color: #0000ff;&quot;&gt;&quot;Submit&quot;&lt;/span&gt;&amp;gt;
&nbsp;
&lt;/form&gt;'</span>;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//entered details</span>
<span style="color: #000088;">$entered_username</span> <span style="color: #339933;">=</span> <span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="">'username'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000088;">$entered_password</span> <span style="color: #339933;">=</span> <span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="">'password'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #990000;">echo</span> <span style="color: #0000ff;">&quot;SELECT * FROM users WHERE users_username='$entered_username' AND users_password='$entered_password'&quot;</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">//get users details</span>
<span style="color: #000088;">$resultset</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT * FROM users WHERE users_username='$entered_username' AND users_password='$entered_password'&quot;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">//if record found, grant access</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_num_rows</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$resultset</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="">'Invalid Username/Password'</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//else proceed</span>
&nbsp;
<span style="color: #000088;">$sUsername</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_result</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$resultset</span><span style="color: #339933;">,</span><span style="color:#800080;">0</span><span style="color: #339933;">,</span><span style="">'users_username'</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">//selcome user, and exit</span>
<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Welcome to the members only area &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$sUsername</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

</div>
<p>Try running this on your local computer.</p>
<p>Try logging in, with some random details.<br />
If i tell you the username is &#8217;steve&#8217;, try some random passwords.<br />
It seems to work properly, but there is a problem.<br />
If we look at the line where the database is queried:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//get users details</span>
<span style="color: #000088;">$resultset</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT * FROM users WHERE users_username='$entered_username' AND users_password='$entered_password'&quot;</span><span style="color: #009900;">&#41;</span>;</pre></td></tr></table></div>

<p>The query is ran as shown, with the entered  username and password spliced in.</p>
<p>Lets look at the query closer:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="mysql mysql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> users <span style="color: #993333; font-weight: bold;">WHERE</span> users_username<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'$entered_username'</span> <span style="color: #993333; font-weight: bold;">AND</span> users_password<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'$entered_password'</span><span style="color: #ff0000;">&quot;</span></pre></td></tr></table></div>

<p>Now, we know the username is steveso we can enter that.  But Suppose we enter this for the password:</p>
<p>&#8216;OR &#8216;1&#8242; = &#8216;1</p>
<p>See what this makes the query into:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="mysql mysql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> users <span style="color: #993333; font-weight: bold;">WHERE</span> users_username<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'steve'</span> <span style="color: #993333; font-weight: bold;">AND</span> users_password<span style="color: #66cc66;">=</span><span style="color: #ff0000;">''</span><span style="color: #993333; font-weight: bold;">OR</span> <span style="color: #ff0000;">'1'</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'1'</span><span style="color: #ff0000;">&quot;</span></pre></td></tr></table></div>

<p>This is the SQL injection, and it is very clevor.<br />
The WHERE clause of the query says that</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="mysql mysql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">WHERE</span> users_username<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'steve'</span> <span style="color: #993333; font-weight: bold;">AND</span> users_password<span style="color: #66cc66;">=</span><span style="color: #ff0000;">''</span><span style="color: #993333; font-weight: bold;">OR</span> <span style="color: #ff0000;">'1'</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'1'</span><span style="color: #ff0000;">&quot;</span></pre></td></tr></table></div>

<p>Now, the password will never be null, but it reads OR 1=1, which will always be true.</p>
<p>Therefore, a hacker will be granted access to your website without a password.</p>
<p><strong><em>Solutions</em></strong></p>
<p>Again, same as before, make sure that you filter out all characters and html other than the things you want. In this case it is especially importnat to remove the single and double quote characters (&#8217; and &#8220;).</p>
<p>Thats it for now, hope you found this article interesting.  Ill post another soon.</p>
<img src="http://feeds.feedburner.com/~r/12ohms/~4/HPEYTvHRQrM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://12ohms.com/2008/07/writing-secure-php-scripts/feed/</wfw:commentRss>
		<feedburner:origLink>http://12ohms.com/2008/07/writing-secure-php-scripts/</feedburner:origLink></item>
	</channel>
</rss>
