Location: PHPKode > projects > CMSmelborp > CMSmelborp/showpage.php
<?php
/*******************************************************************************
License:
	Copyright 2005 Ryan Morehart
	Licensed under the Apache License, Version 2.0 (the "License");
	you may not use this file except in compliance with the License.
	You may obtain a copy of the License at
	
	http://www.apache.org/licenses/LICENSE-2.0
	
	Unless required by applicable law or agreed to in writing, software
	distributed under the License is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	See the License for the specific language governing permissions and
	limitations under the License.
	
Filename: /showpage.php

Purpose: Displays requested page data in the appropriate template.

Processed parameters: (TYPE - NAME - DESCRIPTION - DEFAULT)
	GET - name - name of page to display - Defaults to $default_page in settings.php
	GET - benchmark - displays benchmarking data for the requested page
*******************************************************************************/

require_once 'includes/user_standard.php';

if($lock_external_site === true)
{
	?>
	<html>
	<head>
		<title>Site locked</title>
	</head>
	<body>
		<h1>Site locked</h1>
		<p>This site has been locked by an administrator. Please try again later.</p>
	</body>
	</html>
	<?php
	die();
}

// Ensure that a page was requested
if(!isset($_GET['page']))
{
	// Assume "default" page
	$pageName = $default_page;
}
else
{
	// Save name for easy use
	$pageName = $_GET['page'];
}

// Get page
$page = getPage($connection, $pageName);
if($page === false)
{
	// Try to get error page
	$page = getPage($connection, $error_page);
	if($page === false)
	{
		?>
		<html>
		<head><title>Error retrieving page</title></head>
		<body>
		<p>An error occured while retrieving the page "<?php echo $pageName; ?>." In
		addition to this, the error page could not be retrieved. Please contact the
		<a href="mailto:<?php echo $administrator_email; ?>">administrator</a> with
		any information which may apply.</p>
		</body>
		</html>
		<?php
		die();
	}
}

// Get template
$template = getTemplate($connection, $page['template_name']);
if($template === false)
{
	?>
	<html>
	<head><title>Error retrieving template</title></head>
	<body>
	<p>An error occured while retrieving template <?php echo $page['template_name']; ?>
	for page <?php echo $pageName; ?>. Attempting to display the page content:</p>
	<?php	
	if(is_array($page['content']) && !empty($page['content']))
	{
		foreach($page['content'] as $name => $content)
		{
			?>
			<div style="border: 1px solid #000000; background-color: #EEEEEE; margin: 5px;">
			<h2><?php echo $name; ?></h2>
			<?php
			if(!is_array($content))
			{
				echo "<p>$content</p>";
			}
			else
			{
				foreach($content as $loopInstance)
				{
					?>
					<div style="border: 1px solid #000000; background-color: #CCCCFF; margin: 5px;">
					<?php
					foreach($loopInstance as $name => $content)
					{
						echo "<h2>$name</h2>\n";
						echo "<p>$content</p>\n";
					}
					?>
					</div>
					<?php
				}
			}
			?>
			</div>
			<?php
		}
	}
	?>
	</body>
	</html>
	<?php
	die();
}

// Parse
$output = parseTemplate($connection, $template, $page);

if(!isset($_GET['benchmark']) || !$enable_benchmarking)
{
	// Output
	echo $output;
}
else
{
	// Save end time
	$endTime = microtime();
	
	// Figure out difference in times
	$beginTime = explode(' ', $beginTime);
	$endTime = explode(' ', $endTime);
	$totalTime = ($endTime[1] - $beginTime[1]) + ($endTime[0] - $beginTime[0]);
	
	// Display
	header('Content-type: text/plain');
	echo "The page was completed in $totalTime seconds.\n\n";
	echo "Output:\n$output";
}
?>
Return current item: CMSmelborp