<?php
// Name: Onefile PHP Script
// Description: One PHP file can host multiple pages with this script.
// Usage: index.php?page=1
// Original script: Andy @ http://abyssunderground.co.uk
// This script modified by Stephen Lance
switch ($_GET['page']) {
case 0:
defaultPage();
break;
case 1:
page1();
break;
case 2:
page2();
break;
case 3:
page3();
break;
default:
defaultPage();
}
function defaultPage() {
echo "<HTML><HEAD><TITLE>Default Page</TITLE></HEAD><BODY>";
echo "Here's the HTML for the default page.";
echo "<P>Links:<BR><BR>";
echo "<a href=\"http://{$_SERVER[HTTP_HOST]}{$_SERVER[PHP_SELF]}\">Default Page</a><BR>";
echo "<a href=\"http://{$_SERVER[HTTP_HOST]}{$_SERVER[PHP_SELF]}?page=1\">Page 1</a><BR>";
echo "<a href=\"http://{$_SERVER[HTTP_HOST]}{$_SERVER[PHP_SELF]}?page=2\">Page 2</a><BR>";
echo "<a href=\"http://{$_SERVER[HTTP_HOST]}{$_SERVER[PHP_SELF]}?page=3\">Page 3</a><BR>";
}
function page1() {
echo "<HTML><HEAD><TITLE>Page 1</TITLE></HEAD><BODY>";
echo "Here's the HTML for the page 1.";
}
function page2() {
?>
<HTML>
<HEAD>
<TITLE>
</TITLE>
</HEAD>
<BODY>
<P>Here is the HTML. Don't need to worry about PHP here because we're outside
of the PHP tag. Then before this function ends, we're back in PHP.</P>
<P>Any static content might as well be outside the PHP tags.</P>
<P>To go back inside, just do this: (look at the source code)</P>
<PRE>Page ID: <?php echo $_GET['page']; ?></PRE>
<?php
}
function page3() {
header("Content-type: text/plain");
echo "This is just plain text.";
}
?>