<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <id>tag:refactormycode.com,2007:users37</id>
  <link type="application/atom+xml" href="http://refactormycode.com/users/37" rel="self"/>
  <title>ody.myopenid.com/</title>
  <updated>Thu Oct 04 23:54:30 +0000 2007</updated>
  <entry>
    <id>tag:refactormycode.com,2007:Refactor290</id>
    <published>2007-10-04T23:54:30+00:00</published>
    <title>[PHP] On PHP Get</title>
    <content type="html">&lt;p&gt;The above shows an example of how to check that 'page' is set in GET and how we can use a simple array to verify that the page is allowed to be accessed.  You should check out the Suhosin-Patch which provides stricter access to files by allowing you to set which directories PHP can access.&lt;/p&gt;

&lt;pre&gt;&amp;lt;?php

$pages = array('default', 'page1', 'page2');

if(isset($_GET['page']))
{
	$page = $_GET['page'];
}
else
{
	$page = 'default';
}

if(in_array($page, $pages))
{
	if(file_exists(&amp;quot;$page.php&amp;quot;))
	{
		include(&amp;quot;$page.php&amp;quot;);
	}
	else
	{
		header( 'Location: http://www.example.com/index.php?page=main' );
	}
}&lt;/pre&gt;</content>
    <author>
      <name>ody.myopenid.com/</name>
      <email></email>
    </author>
    <link type="text/html" href="http://refactormycode.com/codes/60-php-get/refactors/290" rel="alternate"/>
  </entry>
</feed>
