<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Pr0gr4mm3r &#187; PHP</title>
	<atom:link href="http://pr0gr4mm3r.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://pr0gr4mm3r.com</link>
	<description>Free tools and information maintained by an online entrepreneur.</description>
	<lastBuildDate>Sat, 05 Jun 2010 14:24:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Several mod_rewrite Tricks for a Better Web Application</title>
		<link>http://pr0gr4mm3r.com/php/several-htaccess-mod_rewrite-tricks-to-better-web-application/</link>
		<comments>http://pr0gr4mm3r.com/php/several-htaccess-mod_rewrite-tricks-to-better-web-application/#comments</comments>
		<pubDate>Mon, 21 Jul 2008 12:42:51 +0000</pubDate>
		<dc:creator>exporter</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://wp.pr0gr4mm3r.com/?p=148</guid>
		<description><![CDATA[Apache&#8217;s .htaccess file options makes it easy to have clean URLs, smart redirects, and even control SSL connections.  In this post, I am going to give you several tips on how you make your web applications smarter.  Note that your server must support mod_rewrite in order to use these tips. Make Sure Everyone is on [...]]]></description>
			<content:encoded><![CDATA[<p>Apache&#8217;s .htaccess file options makes it easy to have clean URLs, smart redirects, and even control SSL connections.  In this post, I am going to give you several tips on how you make your web applications smarter.  Note that your server must support mod_rewrite in order to use these tips.</p>
<p><strong>Make Sure Everyone is on the Same Domain</strong></p>
<p>Even if you don&#8217;t have multiple domains pointing to your site, it&#8217;s possible that www.example.com <strong>and</strong> just example.com will work.  If that&#8217;s the case, Google and other search engines could be crawling your site twice and the website could take a ranking hit for duplicate content.  The following example shows how we can redirect visitors from two domains down to one.</p>
<blockquote><p>RewriteCond %{HTTP_HOST} ^www.example.net$ [NC,OR]<br />
RewriteCond %{HTTP_HOST} ^example.net$ [NC,OR]<br />
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]<br />
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]</p></blockquote>
<p><strong>Force SSL on Specific Site Directories</strong></p>
<p>I use SSL on a couple of my sites, but it doesn&#8217;t need to be enabled (or forced) on the entire site, so we use .htaccess mod_rewrite rules to enforce SSL where we need it.  The following peice of code will force SSL on all requests in the directory named &#8216;secure&#8217;.</p>
<blockquote><p>RewriteCond %{HTTPS} off<br />
RewriteRule ^secure/.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]</p></blockquote>
<p>Both of these lines need to be copied if we need to enforce more than one directory, so if we need the directory &#8216;secure&#8217; and the the directory &#8216;users&#8217; secured, we would use this code.</p>
<blockquote><p>RewriteCond %{HTTPS} off<br />
RewriteRule ^secure/.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]</p>
<p>RewriteCond %{HTTPS} off<br />
RewriteRule ^users/.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]</p></blockquote>
<p>For the rest of the site, we don&#8217;t need SSL, so use something like this if we have the &#8216;secure&#8217; and &#8216;users&#8217; directory with SSL enabled.</p>
<blockquote><p>RewriteCond %{HTTPS} on<br />
RewriteCond %{REQUEST_URI} !secure/.*$<br />
RewriteCond %{REQUEST_URI} !users/.*$<br />
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]</p></blockquote>
<p><strong>Force SSL on a Domain or Sub-Domain</strong></p>
<p>Similar to the need above, we can force SSL on an entire domain if we need to.</p>
<blockquote><p>RewriteCond %{HTTPS} off<br />
RewriteCond %{HTTP_HOST} ^wells-it.com$ [NC]<br />
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]</p></blockquote>
<p><strong>Take a Website Offline</strong></p>
<p>If a website needs to go down for maintenance or whatever, that can be done with a simple few lines of code.  Just remember to change the page&#8217;s path in both lines where you see not-up.htm, or you could create a redirect loop.</p>
<blockquote><p>RewriteCond %{REMOTE_HOST} !^123\.214\.71\.126<br />
RewriteCond %{REQUEST_URI} !/static/not-up\.htm$<br />
RewriteRule .* /static/not-up.htm [R=302,L]</p></blockquote>
<p><strong>Remove &#8216;index.php&#8217; From the URL</strong></p>
<p>This is one that will come in handy if you use CodeIgniter or any other framework that sends all requests through index.php.  Basically, this code checks to see if the URL request exists as a static file or directory.  If does, it would be a picture, style sheet, javascript include, etc.  If it is not found, then it assumes that it must be for the framework to handle, and it sends it to the index.php file.</p>
<blockquote><p>RewriteCond %{REQUEST_FILENAME} !-f<br />
RewriteCond %{REQUEST_FILENAME} !-d<br />
RewriteRule ^(.*)$ /index.php/$1 [L]</p></blockquote>
<p><strong>Keep Visitors Off the Stage</strong></p>
<p>On my large sites, I have both a production copy and a stage copy.  The stage copy is where I do all my developing and testing.  When I am satisfied with the changes, I push the changes to my live site.  The problem is that I don&#8217;t want site visitors seeing my stage copy, so I use some mod_rewrite code to keep them off.  You need to know your IP address for this one, and if you have a dynamic IP, you will have to change the file every time you get a new one.</p>
<blockquote><p>RewriteCond %{REMOTE_HOST} !^56\.51\.98\.126<br />
RewriteCond %{HTTP_HOST} ^stage.wells-it.com$ [NC]<br />
RewriteRule ^(.*)$ http://wells-it.com/$1 [R=301,L]</p></blockquote>
<p>If you have multiple IP address that you want access to the stage, you can just add another condition.</p>
<blockquote><p>RewriteCond %{REMOTE_HOST} !^56\.51\.98\.126<br />
RewriteCond %{REMOTE_HOST} !^74\.65\.95\.128<br />
RewriteCond %{HTTP_HOST} ^stage.wells-it.com$ [NC]<br />
RewriteRule ^(.*)$ http://wells-it.com/$1 [R=301,L]</p></blockquote>
<p><strong>Turn .htaccess Into a Web Application Firewall</strong></p>
<p>I didn&#8217;t write this one, so I can&#8217;t take credit for it, but you can <a href="http://www.0x000000.com/?i=558" target="_blank">find the code here</a>.  It contains some very slick code to keep malicious page requests from getting through to your web applications.</p>
<p><strong>Final Notes</strong></p>
<p>Since some of these URL rewrites actually redirect the browser, it&#8217;s possible to get into a redirect loop where you will never satisfy the rules you have in place, and the browser will redirect forever&#8230;until it detects a loop and stops with an error.  If this happenes, try to see where the loop is or post a comment if you&#8217;re stuck.</p>
]]></content:encoded>
			<wfw:commentRss>http://pr0gr4mm3r.com/php/several-htaccess-mod_rewrite-tricks-to-better-web-application/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Support for PHP 4 Ends &#8211; Plan Ahead for PHP 6</title>
		<link>http://pr0gr4mm3r.com/php/support-for-php-4-ends-plan-ahead-for-php-6/</link>
		<comments>http://pr0gr4mm3r.com/php/support-for-php-4-ends-plan-ahead-for-php-6/#comments</comments>
		<pubDate>Wed, 15 Aug 2007 17:19:18 +0000</pubDate>
		<dc:creator>exporter</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://wp.pr0gr4mm3r.com/php/support-for-php-4-ends-plan-ahead-for-php-6/</guid>
		<description><![CDATA[Unfortunately for all of you that are to lazy to check and modify your code for PHP 5, your procrastinating days are drawing to a close. Support for PHP 4 ends on December 31, 2007. Ever since the PHP5 official release on July 13, 2004, the PHP group has been supporting both versions 4 and [...]]]></description>
			<content:encoded><![CDATA[<p>Unfortunately for all of you that are to lazy to check and modify your code for PHP 5, your procrastinating days are drawing to a close.  Support for PHP 4 ends on December 31, 2007.   Ever since the PHP5 official release on July 13, 2004, the PHP group has been supporting both versions 4 and 5 together, allowing plenty of time for the developers to check and tweak their code.</p>
<p>Now to review, the fact that they say they are not supporting it on their website does not mean that you won&#8217;t be able to use it.  It just means that you shouldn&#8217;t expect any more updates.  According to PHP&#8217;s website, they won&#8217;t be releasing any major updates to PHP 4.4 after this year, and they will be releasing critical updates on a case-by-case basis only until August 08, 2008.</p>
<p>I upgraded my commercial web server to run PHP 5 this last summer (&#8217;06) after running it on my development server several months before that.  If you are behind me and still have yet to check your code for PHP 5, you might as well check for possible changes that are going to be made in PHP 6.</p>
<p>First, head on over to PHP&#8217;s guide to <a href="http://www.php.net/manual/en/migration5.php">Migrating from PHP 4 to PHP 5</a>.  Once you clear your code to PHP 5 standards, put in the extra effort now to make sure you are ready for PHP 6 by not using any of the functions below as they will be removed.</p>
<ul>
<li><a href="http://us3.php.net/register_globals">register_globals</a> will be no more.  This feature was disabled by default in PHP 5 to encourage developers to merge away from it, but in PHP 6, it&#8217;s gone for good.</li>
<li><a href="http://us3.php.net/magic_quotes">magic_quotes</a> will be no more.  This feature escaped all incoming data with in my opinion was annoying, so I disabled it on my websites and only escaped the data that needed to be.</li>
<li><a href="http://us3.php.net/safe_mode">safe_mode</a> will be no more.</li>
<li>HTTP_*_VARS are gone.  Use _POST, _GET, _COOKIE, _SESSION instead.</li>
<li><a href="http://us3.php.net/manual/en/language.references.return.php">Returning reference</a> will be removed.</li>
</ul>
<p>See phpmysqldev.blogspot.com for more information on PHP 6.</p>
]]></content:encoded>
			<wfw:commentRss>http://pr0gr4mm3r.com/php/support-for-php-4-ends-plan-ahead-for-php-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RSS &amp; Atom Feeds Made Easy for Developers</title>
		<link>http://pr0gr4mm3r.com/php/rss-atom-feeds-made-easy-for-developers/</link>
		<comments>http://pr0gr4mm3r.com/php/rss-atom-feeds-made-easy-for-developers/#comments</comments>
		<pubDate>Mon, 25 Jun 2007 15:23:00 +0000</pubDate>
		<dc:creator>exporter</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://wp.old.pr0gr4mm3r.com/2007/06/25/rss-atom-feeds-made-easy-for-developers/</guid>
		<description><![CDATA[In this entry you will find 2 feed templates ready to work on your TinyButStrong website. All you need to to is include these templates, set some variables, and merge the data block. The following templates are ready to go after including it in the TBS class. If you require more help or even implementation [...]]]></description>
			<content:encoded><![CDATA[<p>In this entry you will find 2 feed templates ready to work on your <a href="http://www.tinybutstrong.com/">TinyButStrong</a> website.  All you need to to is include these templates, set some variables, and merge the data block.</p>
<p>The following templates are ready to go after including it in the <span class="caps">TBS</span> class.  If you require more help or even implementation code, scroll down beyond the template code.</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
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;[var.info.charset]&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rss</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;2.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;channel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>[var.info.title]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>[var.info.link]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/link<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>[var.info.description]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;language<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>[var.info.language]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/language<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;managingEditor<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>[var.info.email]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/managingEditor<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;copyright<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Copyright [var.info.year]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/copyright<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;generator<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>[var.info.generator]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/generator<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pubDate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>[var.info.pub_date]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pubDate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ttl<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>60<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ttl<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;image<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>[var.info.link]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/link<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>[var.info.img_title]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>[var.info.img_url]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/image<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
      [blkItems;block=begin]
&nbsp;
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>[blkItems.title]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>[blkItems.link]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/link<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;comments<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>[blkItems.comments]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/comments<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #339933;">&lt;![CDATA[ [blkItems.description] ]]&gt;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;guid</span> <span style="color: #000066;">isPermaLink</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>[blkItems.guid]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/guid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;category<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>[blkItems.category]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/category<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pubDate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>[blkItems.pub_date]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pubDate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
      [blkItems;block=end]
&nbsp;
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/channel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/rss<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>


<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
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;[var.info.charset]&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;feed</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2005/Atom&quot;</span> <span style="color: #000066;">xml:lang</span>=<span style="color: #ff0000;">&quot;[var.info.lang]&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>[var.info.title]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;subtitle<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>[var.info.description]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/subtitle<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">&quot;alternate&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/html&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;[var.info.link]&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">&quot;self&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;application/atom+xml&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;[var.info.atom_link]&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;updated<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>[var.info.updated]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/updated<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>[var.info.author_name]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;uri<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>[var.info.link]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/uri<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;email<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>[var.info.email]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/email<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>[var.info.link]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rights<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Copyright (c) [var.info.year], [var.info.author_name]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/rights<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
   [blkItems;block=begin]
&nbsp;
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;entry<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>[blkItems.title]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">&quot;alternate&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/html&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;[blkItems.link]&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;updated<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>[blkItems.updated]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/updated<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;published<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>[blkItems.pub_date]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/published<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>[blkItems.link]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;summary</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>[blkItems.summery]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/summary<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;content</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;html&quot;</span> <span style="color: #000066;">xml:lang</span>=<span style="color: #ff0000;">&quot;[blkItems.lang]&quot;</span> <span style="color: #000066;">xml:base</span>=<span style="color: #ff0000;">&quot;[blkItems.link]&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #339933;">&lt;![CDATA[</span>
<span style="color: #339933;">                [blkItems.content]</span>
<span style="color: #339933;">      ]]&gt;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/content<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>[blkItems.author]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/entry<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
   [blkItems;block=end]
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/feed<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Please note that in my examples, I don’t include classes before I define them because I make use if PHP’s <a href="http://us2.php.net/manual/en/language.oop5.autoload.php">__autoload()</a> function. Since you probably don’t, insert the necessary include statement(s) before any object declaration statements. Most of the variables are self-explanatory in this file. Lines 12-23 define fields that are for the general feed, and data that does not pertain the the individual elements. Lines 30-48 take care of the feed items. In my example, I run a MySQL query, and feed that data into a complex array. You can populate that array any way you want as long as you keep those element names the same and keep that MergeBlock function alone online 48.</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
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
51
52
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
   <span style="color: #666666; font-style: italic;">/* make sure that we are sending the correct header */</span>
   <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Content-type: application/rss+xml'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">/* create template object */</span>
   <span style="color: #000088;">$tbs</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> clsTinyButStrong<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">/* set main template */</span>
   <span style="color: #000088;">$tbs</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">LoadTemplate</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'rss_2_0.xml'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">/* define information fields */</span>
   <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'charset'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'utf-8'</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'link'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'description'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'language'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'en'</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'email'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'year'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'generator'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'pub_date'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'r'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'img_link'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'img_title'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'img_url'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
   <span style="color: #666666; font-style: italic;">/* for this section, you can include your entries through a query (if your column names 
      match up with the fields), or a data array */</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">/* I'm going to use a data array from a MySQL table.  The following is an example on how to do the data block  */</span>
   <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT * FROM Fields ORDER BY date DESC&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #666666; font-style: italic;">/* code to process your MySQL query */</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #990000;">mysql_num_rows</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#123;</span>
      <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;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #000088;">$blkItems</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                           <span style="color: #0000ff;">'title'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
                           <span style="color: #0000ff;">'link'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
                           <span style="color: #0000ff;">'comments'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
                           <span style="color: #0000ff;">'description'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
                           <span style="color: #0000ff;">'guid'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'@'</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'http://your.site.here'</span><span style="color: #339933;">,</span>
                           <span style="color: #0000ff;">'category'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
                           <span style="color: #0000ff;">'pub_date'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'r'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#41;</span>
                        <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #000088;">$tbs</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">MergeBlock</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'blkItems'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$blkItems</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">/* show output, but don't stop the script */</span>
   <span style="color: #000088;">$tbs</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Show</span><span style="color: #009900;">&#40;</span>TBS_OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Please note that in my examples, I don’t include classes before I define them because I make use if PHP’s <a href="http://us2.php.net/manual/en/language.oop5.autoload.php">__autoload()</a> function. Since you probably don’t, insert the necessary include statement(s) before any object declaration statements. Most of the variables are self-explanatory in this file.<br />
Lines 12-23 define fields that are for the general feed. Lines 30-50 take care of the feed items. In my example, I run a MySQL query, and feed that data into a complex array. You can populate that array any way you want as long as you keep those element names the same and keep that MergeBlock function alone online 52.</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
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
51
52
53
54
55
56
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
   <span style="color: #666666; font-style: italic;">/* make sure that we are sending the correct header */</span>
   <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Content-type: application/atom+xml'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">/* create template object */</span>
   <span style="color: #000088;">$tbs</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> clsTinyButStrong<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">/* set main template */</span>
   <span style="color: #000088;">$tbs</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">LoadTemplate</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'atom.xml'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">/* define information fields */</span>
   <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'lang'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'en-US'</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'charset'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'utf-8'</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'description'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'author_name'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'link'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'email'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'tag'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'pub_date'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'updated'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'c'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'year'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'atom_link'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_HOST'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_URI'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
   <span style="color: #666666; font-style: italic;">/* for this section, you can include your entries through a query (if your column names 
      match up with the fields), or a data array */</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">/* I'm going to use a data array from a MySQL table.  The following is an example on how to do the data block  */</span>
   <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT * FROM Fields ORDER BY date DESC&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #666666; font-style: italic;">/* code to process your MySQL query */</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #990000;">mysql_num_rows</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#123;</span>
      <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;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #000088;">$blkItems</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                           <span style="color: #0000ff;">'lang'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'en-US'</span><span style="color: #339933;">,</span>
                           <span style="color: #0000ff;">'author'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Andrew Wells'</span><span style="color: #339933;">,</span>
                           <span style="color: #0000ff;">'title'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">htmlspecialchars</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                           <span style="color: #0000ff;">'link'</span> <span style="color: #339933;">=&gt;</span> PATH_WEB_HOME <span style="color: #339933;">.</span> <span style="color: #0000ff;">'fields/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'slug'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/'</span><span style="color: #339933;">,</span>
                           <span style="color: #0000ff;">'comments'</span> <span style="color: #339933;">=&gt;</span> PATH_WEB_HOME <span style="color: #339933;">.</span> <span style="color: #0000ff;">'fields/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'slug'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/'</span><span style="color: #339933;">,</span>
                           <span style="color: #0000ff;">'summery'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'intro'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
                           <span style="color: #0000ff;">'content'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'intro'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
                           <span style="color: #0000ff;">'guid'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'field_id'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'@'</span> <span style="color: #339933;">.</span> PATH_WEB_HOME<span style="color: #339933;">,</span>
                           <span style="color: #0000ff;">'category'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Fields'</span><span style="color: #339933;">,</span>
                           <span style="color: #0000ff;">'updated'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'c'</span><span style="color: #339933;">,</span> <span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'updated'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                           <span style="color: #0000ff;">'pub_date'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'c'</span><span style="color: #339933;">,</span> <span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'added'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                        <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #000088;">$tbs</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">MergeBlock</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'blkItems'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$blkItems</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">/* show output, but don't stop the script */</span>
   <span style="color: #000088;">$tbs</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Show</span><span style="color: #009900;">&#40;</span>TBS_OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://pr0gr4mm3r.com/php/rss-atom-feeds-made-easy-for-developers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Stop Spam on a phpBB 2.x.x Board</title>
		<link>http://pr0gr4mm3r.com/php/how-to-stop-spam-on-a-phpbb-2xx-board/</link>
		<comments>http://pr0gr4mm3r.com/php/how-to-stop-spam-on-a-phpbb-2xx-board/#comments</comments>
		<pubDate>Tue, 10 Apr 2007 22:39:00 +0000</pubDate>
		<dc:creator>Andrew Wells</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://wp.old.pr0gr4mm3r.com/2007/04/10/how-to-stop-spam-on-a-phpbb-2xx-board/</guid>
		<description><![CDATA[Is your phpBB board being overridden by spam? Most people may recommend that you go to their support forums and install a couple modifications, but what if they don’t work? The answer to that question is simple. All common solutions will not work. If someone puts out a common solution, the spam bots will adapt [...]]]></description>
			<content:encoded><![CDATA[<p>Is your phpBB board being overridden by spam?  Most people may recommend that you go to their support forums and install a couple modifications, but what if they don’t work?  The answer to that question is simple.  All common solutions will not work.  If someone puts out a common solution, the spam bots will adapt to it.  Spam bots have adapted to captacha images, email verification, and other common defenses.  Fortunately, the answer is simple, all you have to do is <strong>be unique</strong>.  I will give you one tip on how you can do that and keep the spam bots at bay.</p>
<p>It is my best guess that the image verifications are the hardest to crack, so in theory, if you tweak that, the bots will not be able to adapt to it.</p>
<ol>
<li>Make sure you have the latest version of phpBB installed (given)</li>
<li>Enable image verification, and user activation</li>
<li>Open up phpbb/includes/usercp_confirm.php</li>
<li>Find tweakable values.  Some examples are $total_width, $total_height, $img_width, $img_height, $width, (you get the idea)</li>
<li>Preview as you tweak to make sure the images are still readable, yet make sure you are making noticeable changes.</li>
</ol>
<p>I tweaked the $width variable on line 87 to the point where some of the letters were getting squished together and getting cut off by a few pixels, and that was enough for me.</p>
<p>I tried this method on a board that was getting 10-15 spam registrations a <strong>day</strong>.  It’s been spam free for almost a month now.</p>
<p>If you find a method that woks, post it, but generalize it.  If you get too many people start copying you exactly, it will make it work the spammer’s time to adapt to it.  Remember, the key is to make your board different from all the others.</p>
]]></content:encoded>
			<wfw:commentRss>http://pr0gr4mm3r.com/php/how-to-stop-spam-on-a-phpbb-2xx-board/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>GeSHI Snippet for Pivot</title>
		<link>http://pr0gr4mm3r.com/php/geshi-snippet-for-pivot/</link>
		<comments>http://pr0gr4mm3r.com/php/geshi-snippet-for-pivot/#comments</comments>
		<pubDate>Fri, 09 Mar 2007 20:50:00 +0000</pubDate>
		<dc:creator>Andrew Wells</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://wp.old.pr0gr4mm3r.com/2007/03/09/geshi-snippet-for-pivot/</guid>
		<description><![CDATA[This is one of the snippets that that I designed for Pivot. 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 [...]]]></description>
			<content:encoded><![CDATA[<p>This is one of the snippets that that I designed for <a href="http://www.pivotlog.net" target="_blank">Pivot</a>.</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
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
51
52
53
54
55
56
57
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">/*
	*	snippet_geshi.php: inserts formatted code into the Pivot blog entries
	*	Copyright (C) 2007  Andrew Wells &lt;contact@pr0gr4mm3r.com&gt;
	*	
	*	This program is free software; you can redistribute it and/or
	*	modify it under the terms of the GNU General Public License
	*	as published by the Free Software Foundation; either version 2
	*	of the License, or (at your option) any later version.
	*	
	*	This program is distributed in the hope that it will be useful,
	*	but WITHOUT ANY WARRANTY; without even the implied warranty of
	*	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	*	GNU General Public License for more details.
	*	
	*	You should have received a copy of the GNU General Public License
	*	along with this program; if not, write to the Free Software
	*	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
	*	
	*	Assuming a php code file called 'code.txt' in the DOC_ROOT/pivot/code directory, call like this:
	*	[[geshi:code.txt:php]]
	*/</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> snippet_geshi<span style="color: #009900;">&#40;</span><span style="color: #000088;">$code_loc</span><span style="color: #339933;">,</span> <span style="color: #000088;">$code_lang</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	   <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$Paths</span><span style="color: #339933;">;</span>
&nbsp;
	   <span style="color: #000088;">$code</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DOCUMENT_ROOT'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/pivot/code/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$code_loc</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	   <span style="color: #000088;">$code</span> <span style="color: #339933;">=</span> <span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$code</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	   <span style="color: #000088;">$code_lines</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DOCUMENT_ROOT'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/pivot/code/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$code_loc</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$code_lines</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">11</span><span style="color: #009900;">&#41;</span>
	   <span style="color: #009900;">&#123;</span>
	   	<span style="color: #000088;">$height</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$code_lines</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">40</span><span style="color: #339933;">;</span>
	   <span style="color: #009900;">&#125;</span>
	   <span style="color: #b1b100;">else</span>
	   <span style="color: #009900;">&#123;</span>
	   	<span style="color: #000088;">$height</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">300</span><span style="color: #339933;">;</span>
	   <span style="color: #009900;">&#125;</span>
&nbsp;
	   <span style="color: #666666; font-style: italic;">// Create a GeSHi object</span>
	   <span style="color: #000088;">$geshi</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000000; font-weight: bold;">new</span> GeSHi<span style="color: #009900;">&#40;</span><span style="color: #000088;">$code</span><span style="color: #339933;">,</span> <span style="color: #000088;">$code_lang</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	   <span style="color: #000088;">$geshi</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">enable_line_numbers</span><span style="color: #009900;">&#40;</span>GESHI_FANCY_LINE_NUMBERS<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	   <span style="color: #000088;">$parsed</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$geshi</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parse_code</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$download_info</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;div style=&quot;color: #7F7F7F; font-size: 8pt; margin: 0 auto; margin-bottom: 15px; overflow: auto; width: 90%; &quot;&gt;
			The above code is not formatted for copying.  &lt;a href=&quot;'</span> <span style="color: #339933;">.</span> PATH_WEB_HOME <span style="color: #339933;">.</span> <span style="color: #0000ff;">'code_download.php?loc='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$code_loc</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;&gt;
			Click here&lt;/a&gt; for the code in plain text.&lt;/div&gt;'</span><span style="color: #339933;">;</span>
	   <span style="color: #000088;">$start</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;div style=&quot;background-color: #F8F6F6; border-color: #000000; border-style: solid; border-width: 1px; height: '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$height</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'px; margin: 0 auto; margin-bottom: 2px; margin-top: 20px; overflow: auto; width: 90%;&quot;&gt;'</span><span style="color: #339933;">;</span>
	   <span style="color: #000088;">$end</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;/div&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
	   <span style="color: #000088;">$finished_code</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$start</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;n&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$parsed</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;n&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$end</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$download_info</span><span style="color: #339933;">;</span>
&nbsp;
	   <span style="color: #666666; font-style: italic;">#echo $finished_code;
</span>	   <span style="color: #b1b100;">return</span> <span style="color: #000088;">$finished_code</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>This snippet reads a code file and displays in an entry using the GeSHi script.  The above code is what you need to show code in your blog entries.  There are, however, a few changes that will probably need to be made.</p>
<ul>
<li>See lines 28 &amp; 30.  If your code folder is in a different location, please change these paths. (You will have to create the code folder)</li>
<li>See lines 46-48 &amp; 52.  If you do not decide to include a link to download the code (see second hunk of code in this entry), you will need to remove lines 46-48 and edit line 52 accordingly.</li>
<li>Change &#8220;PATH_WEB_HOME&#8221; on line 47 to your site&#8217;s home path (for example &#8220;http://www.yoursite.com/&#8221;)</li>
<li>Please note that the GeSHi object is declared on line 42, but the GeSHi class file is never included.  That&#8217;s because I use PHP&#8217;s <a href="http://us3.php.net/manual/en/language.oop5.autoload.php" target="_blank">autoload()</a> function.  You are responsible for installing the <a href="http://qbnz.com/highlighter/" target="_blank">GeSHi</a> script and including it where necessary.</li>
</ul>
<p>That should be it!  See the code below to allow users to download the code for easier copying.</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
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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
	<span style="color: #666666; font-style: italic;">/*
	*	code_download.php: code_download.php is designed to work with the GeSHI snippet for Pivot
	*	Copyright (C) 2007  Andrew Wells &lt;contact@pr0gr4mm3r.com&gt;
	*	
	*	This program is free software; you can redistribute it and/or
	*	modify it under the terms of the GNU General Public License
	*	as published by the Free Software Foundation; either version 2
	*	of the License, or (at your option) any later version.
	*	
	*	This program is distributed in the hope that it will be useful,
	*	but WITHOUT ANY WARRANTY; without even the implied warranty of
	*	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	*	GNU General Public License for more details.
	*	
	*	You should have received a copy of the GNU General Public License
	*	along with this program; if not, write to the Free Software
	*	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
	*/</span>
&nbsp;
	<span style="color: #000088;">$filename</span> <span style="color: #339933;">=</span> <span style="color: #990000;">urldecode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'loc'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">/* this should only be a filename, take out any directory references */</span>
	<span style="color: #000088;">$filename</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'..'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$filename</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$filename</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$filename</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Content-type: application/txt'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Content-Disposition: attachment; filename=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$filename</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DOCUMENT_ROOT'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/pivot/code/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$filename</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$dump</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DOCUMENT_ROOT'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/pivot/code/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$filename</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">echo</span> <span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dump</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;File not found.&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>The only thing you may have to edit here is the path to the code files if you changed them from the default.  Find all instances of &#8216;$_SERVER['DOCUMENT_ROOT'] . &#8220;/pivot/code/&#8221;&#8216; and edit accordingly.</p>
]]></content:encoded>
			<wfw:commentRss>http://pr0gr4mm3r.com/php/geshi-snippet-for-pivot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PayPal IPN and GoDaddy Hosting</title>
		<link>http://pr0gr4mm3r.com/php/paypal-ipn-and-godaddy-hosting/</link>
		<comments>http://pr0gr4mm3r.com/php/paypal-ipn-and-godaddy-hosting/#comments</comments>
		<pubDate>Thu, 21 Dec 2006 00:37:00 +0000</pubDate>
		<dc:creator>Andrew Wells</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://wp.old.pr0gr4mm3r.com/2006/12/20/paypal-ipn-and-godaddy-hosting/</guid>
		<description><![CDATA[This took over 4 hours of debugging for me to figure out. Hopefully, this will save you time. Basically, the problem I was having was that I wasn&#8217;t getting the responses necessary from PayPal when I sent the requests from GoDaddy servers. This script made it much easier to get the job done. [sourcecode language="php" [...]]]></description>
			<content:encoded><![CDATA[<p>This took over 4 hours of debugging for me to figure out.  Hopefully, this will save you time.  Basically, the problem I was having was that I wasn&#8217;t getting the responses necessary from PayPal when I sent the requests from GoDaddy servers.  This script made it much easier to get the job done.</p>
<p>[sourcecode language="php" collapse="true"]<br />
&lt;?php<br />
	/* This code created by Andrew Wells (www.pr0gr4mm3r.com) */<br />
	/* Your comments or questions are welcome: contact@pr0gr4mm3r.com */</p>
<p>	include(&quot;includes/Snoopy.php&quot;);</p>
<p>	/* first, reform the variables to post them back */<br />
	$post_vars['cmd'] = &#8216;_notify-validate&#8217;;<br />
	$post_vars['ipn_test'] = 1;</p>
<p>	foreach ($_POST as $key =&gt; $value)<br />
	{<br />
		$post_vars[$key] = $value;<br />
	}</p>
<p>	/* now send the data back */<br />
	$snoopy = new Snoopy;<br />
	$submit_url = &#8216;http://www.sandbox.paypal.com/cgi-bin/webscr&#8217;;</p>
<p>	/* uncomment these lines if you use GoDaddy.com as your host */<br />
	/* $snoopy-&gt;proxy_host = &quot;proxy.shr.secureserver.net&quot;;<br />
	$snoopy-&gt;proxy_port = &quot;3128&quot;; */</p>
<p>	$result = $snoopy-&gt;submit($submit_url, $post_vars);</p>
<p>	if ($result)<br />
	{<br />
		$headers = implode(&quot;\n&quot;, $snoopy-&gt;headers);<br />
		$content = $snoopy-&gt;results;</p>
<p>		if (strpos(&#8216;VERIFIED&#8217;, $content) !== FALSE)<br />
		{<br />
			/* information checks out, but be sure to verify payment information and amount */</p>
<p>		}<br />
		else if (strpos(&#8216;INVALID&#8217;, $content) !== FALSE)<br />
		{<br />
			/* information is invalid; possible spoofing */</p>
<p>		}<br />
	}<br />
	else<br />
	{<br />
		/* connection failed */</p>
<p>	}<br />
?&gt;[/sourcecode]<br />
The above code is what I now use to test and post-back my PayPal Instant Payment Notifications.  It does make use of the <a href="http://snoopy.sourceforge.net/" target="_blank">Snoopy</a> script, so be sure to download yourself a copy <a href="http://snoopy.sourceforge.net/" target="_blank">here</a> if you don&#8217;t have it.  This is much better than PayPal&#8217;s sample because 1) it works, and 2) it is neater code because it uses the Snoopy class.</p>
<p>Points to address:</p>
<ul>
<li>This script is meant to post to the PayPal Sandbox.  When implementing this script for real, comment out line 9, and take out &#8216;sandbox.&#8217; on line 18.</li>
<li>Uncomment lines 21-22 if your host if GoDaddy.</li>
<li>Line 34 is where you put the code for a successful verification*.</li>
<li>Line 39 is where you put the code for an unsuccessful verification (possible spoofing).</li>
<li>Line 44 is where you put the code to handle a connection failure.</li>
</ul>
<p>*A successful validation does not mean all the information is correct, especially if you aren&#8217;t using encrypted PayPal buttons.  You still want to verify all payment information.</p>
]]></content:encoded>
			<wfw:commentRss>http://pr0gr4mm3r.com/php/paypal-ipn-and-godaddy-hosting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
