$mtime = explode(" ",microtime());
$starttime = $mtime[1] + $mtime[0];
// 11-10-07
// changed 404 handler
// 31-10-07
// added the ability to turn off content headings
// 03-10-07
// added jsLoad
// added datePicker
// added cssLoad
// INCLUDE FUNCTION BASE
include 'function.php';
include 'emailer.php';
include 'define.php';
function dl(){
}
// Goes over all content to replace necessary sections before output
function callback($buffer)
{
global $title;
$title = $_SESSION['title'];
// load title
$buffer = str_replace("
".siteTitle."", "".siteTitle." - ".$title."", $buffer);
// Load required CSS
if ($_SESSION['loadCSS']!="")
{
$loadCSS = $_SESSION['loadCSS'];
$loadCSS_HTML="";
foreach( $loadCSS as $cssName => $cssURL)
{
$loadCSS_HTML.="\n".''."\n";
}
$buffer = str_replace('', $loadCSS_HTML.'', $buffer);
}
$_SESSION['loadCSS']="";
// Load required JS
if ($_SESSION['loadJS']!="")
{
$loadJS = $_SESSION['loadJS'];
$loadJS_HTML="";
foreach( $loadJS as $jsName => $jsURL)
{
$loadJS_HTML.="\n".''."\n";
}
$buffer = str_replace('', $loadJS_HTML.'', $buffer);
}
$_SESSION['loadJS']="";
// Load date picker if set
if ($_SESSION['datePicker']!="")
{
$datePickerHTML ="\n".''."\n";
$datePickerHTML.="\n".''."\n";
$buffer = str_replace('', $datePickerHTML.'', $buffer);
}
$_SESSION['datePicker']="";
// Remove content title (h1) if set in session by usually a component
if($_SESSION['hideContentTitle'])
{
$objSite=$_SESSION['objSite'];
$contentID=$objSite->getContentIDFromComponentPath($_REQUEST['component']);
// print_r($contentID);exit;
list($title)=mysql_fetch_row(doSQL("SELECT content_title FROM tableCMS_content WHERE content_PK = '{$contentID}' LIMIT 1"));
$buffer=str_replace("
".$title."
", "", $buffer);
}
unset($_SESSION['hideContentTitle']);
return $buffer;
}
if(stristr($_GET['task'],"404")) { header("HTTP/1.0 404 Not Found"); }
// Automatic object include
include 'autoload.php';
// Start Buffering Text Output
ob_start("callback");
// start session
session_start();
// Database Link
$connection = mysql_connect(mysql_host, mysql_user, mysql_password) or die ("Couldnt Establish Link");
$db = mysql_select_db(mysql_database, $connection) or die ("Couldnt Select Database");
$_SESSION['connection']=$connection;
$objSite=$_SESSION['objSite'];
////////////////////////////////////////////////////////////////////////////////
if(!isset($objSite)){
//echo " !isset-objSite\n";
$objSite = new cSite();
if(!isset($objSite)){
echo "Error loading object Site";
die;
}else{
$_SESSION['objSite']=$objSite;
}
}
if(!isset($_SESSION['userLevel']))
$objSite->init();
// if(isset($objSite)){$_SESSION['debugMsg'].=" objSite is set\n";}
$objSite->processURL();
// End Output Buffer
ob_end_flush();
$mtime = explode(" ",microtime());
$endtime = $mtime[1] + $mtime[0];
$totaltime = ($endtime - $starttime);
echo "This page was created in ".$totaltime." seconds";
unset($_SESSION['connection']);
?>