<?php
#################################################
#Content Management System - CurrentArticles for
#The Honolulu Advertiser - v 1.0 beta 2
#Author - Chris Kanemura
#Copyright 2001 - The Honolulu Advertiser
#################################################
//Get execution time
//function exec_time()
//	{
//	$mtime = explode( " ", microtime());
//	$msec = (double)$mtime[0];
//	$sec = (double)$mtime[1];
//	return $sec + $msec;
//	}

//Start timing here
//$starttime = exec_time();

// ****** Define variables ******
$url 		= $REQUEST_URI; // Get the requested URI(address of file)
$domain 	= $SERVER_NAME;
$dir_zero 	= '';
$engine		= ''; // This file
$section	= ''; // Section
$feature	= ''; // Feature
$firstslash	= ''; // No current funcion
$copyyear 	= date("Y"); //Date info
// ******************************

// Rip requested URI apart via a slash as diliminator
list($dir_zero,$engine,$section,$feature,$firstslash) = explode ("/", $url); // Convert to an array

//Create variables for file access to clean up code a bit
$pe_url 		= $section.'/'.$feature;
$article_file 	= '/www/today/'.$section.'/'.$feature.'.html';
$php_file 		= '/www/today/'.$section.'/'.$feature.'.php';
$quiz_file 		= '/www/contest/'.$feature.'.php';
$contest_file 	= '/www/contest/'.$feature.'.php';
$quiz_parser 	= '/www/contest/quiz.php';
$tgifcal_file 	= '/www/today/il/tgifcal.html';
$index 			= '/www/today/'.$section.'.html';
$filedir 		= '/www/engine';
$include_path 	= '/www/cms/site_includes';

switch ($domain) {

 	case "the.honoluluadvertiser.com":
 		$header 	= $include_path.'/header.php';
		$footer 	= $include_path.'/footer.php';
		$displayidx = "on";
		$homepage 	= "http://www.honoluluadvertiser.com";
		$copyright 	= "";
 		break;
 	case "news.hawaii.com":
 		$header 	= "/www/cb/hdcheader.php";
		$footer 	= "/www/cb/hdcfooter.php";
		$displayidx = "off";
		$homepage 	= "http://www.hawaii.com";
		$copyright 	= " and hawaii.com";
 		break;
 	case "www.news.hawaii.com":
 		$header 	= "/www/cb/hdcheader.php";
		$footer 	= "/www/cb/hdcfooter.php";
		$displayidx = "off";
		$homepage 	= "http://www.hawaii.com";
		$copyright 	= " and hawaii.com";
 		break;
 	default:
 		$header 	= "/www/advinc/header.php";
		$footer 	= "/www/advinc/footer.php";
		$displayidx = "on";
		$homepage 	= "http://www.honoluluadvertiser.com";
		$copyright 	= "";
} // end switch

//Check for hacking stuff for email this page but let em print I guess
if(!$section) {

	$_404Message = @file_get_contents('/www/cms/site_includes/404errorMessage.html');
	$err = "404";
	require($header);
	if( strlen($_404Message)>0 ) {
		echo $_404Message;
	} else {
		print("404 - The page you are looking for is unavailable.");
	}
	require($footer);
	exit();

} elseif( $email == "on" && file_exists($article_file) ) {

	//Select which template to build
	//Email Version
	$show = "no";
	require($header);
	require("/www/engine/email.php");
	require($footer);

} elseif($print == "on" && file_exists($article_file))	{

	//Print Version
	print("<html><head><meta name=\"robots\" content=\"noindex,nofollow\"><title>Print version - &copy; COPYRIGHT $copyyear The Honolulu Advertiser, a division of Gannett Co. Inc.</title></head><body>");
	print("<p><center><a href=\"http://www.honoluluadvertiser.com\"><img src=\"http://the.honoluluadvertiser.com/inc/pix/halogoprnt.jpg\" width=\"283\" height=\"60\" border=\"0\"></a>");
	print("<!--<H1>Printable Version</H1>--></center></p>");
	require("$filedir/print.php");
	include("$filedir/printfooter.php");

} elseif($section == "quiz" && file_exists($quiz_file)) {

	//Display contest and quizes
	$show = "no";
	$form = "yes";
	$email = "kill";
	$quiz_form = "/www/contest/quizform.php";
	require($quiz_file);
	require($header);
	require($quiz_parser);
	require($footer);

} elseif($section == "contest" && file_exists($contest_file)) {
	
	$show = "no";
	$form = "yes";
	$email = "kill";
	$quiz_form = "/www/contest/contestform.php";
	require($contest_file);
	require($header);
	require($quiz_parser);
	require($footer);

} elseif($section && file_exists($article_file)) {

	//Display Article
	require($header);
	include($article_file);
	require($footer);

} elseif($section && file_exists($php_file)) {

	//Display Movie or articles that include php code
	$show = "no";
	$form = "yes";
	$email = "kill";
	require($header);
	require($php_file);
	require($footer);

} else	{

	//None of the above, too bad 404 a'ohe page, strip email and print version options - why in the world would you want to print this page anyway
	$err = "404";
	require($header);
	print("Sorry, the story you are looking for is not here or is no longer available. <br><br>Click <a href=\"http://www.honoluluadvertiser.com/\">here</a> to return to our homepage.");
	require($footer);

}

//Exit out
//$endtime = exec_time();
//$finaltime = $endtime - $starttime;
//print("<p>It has taken $finaltime seconds to parse this page");

?> 

