<?php
//
// +---------------------------------------------------------------------------+
// | Nitro :: Base :: Index |
// +---------------------------------------------------------------------------+
// | Copyright (c) 2006 June Systems BV |
// +---------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or modify it |
// | under the terms of the GNU Lesser General Public License as published by |
// | the Free Software Foundation; either version 2.1 of the License, or (at |
// | your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, but |
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser |
// | General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public License |
// | along with this library; if not, write to the Free Software Foundation, |
// | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
// +---------------------------------------------------------------------------+
// | Authors: Siggi Oskarsson <hide@address.com> |
// | Jesper Avot <hide@address.com |
// +---------------------------------------------------------------------------+
//
// $Id: index.php 229 2008-04-17 09:20:31Z oli $
//
// Nitro's index script
//
/**
* TODO : Place Nitro default CSS/JS in Nitro dir, not in Site dir.
* Site dir must be filled with index.php, NitroBaseConfig.inc.php
* GetObject.php and xml.php only!
*/
/**
* Include NitroBaseConfig file
*/
include_once "NitroBaseConfig.inc.php";
/**
* Start timer
*/
$NitroPageStartTime = NitroGetMicroTime();
/**
* Check if the config is loaded correctly.
*/
if ($__NitroConf->isLoaded) {
/**
* Include Nitro Page class
*/
include_once "Nitro/Page.inc.php";
Debug("index.php", "IndexFile", "Creating Nitro page", __FILE__, __LINE__);
// Check for IndexPage cache
$IndexPageCacheFile = NitroGetTmpCacheDir(Array('IndexPages/')).md5($_SERVER['REQUEST_URI']).'_L'.NitroGetUserLanguage().'.html';
if (NitroGetConfig('Settings/IndexPageCache') && @file_exists($IndexPageCacheFile) && @filemtime($IndexPageCacheFile) > (time() - (60*NitroGetConfig('Settings/IndexPageCache')))) {
Debug("index.php", "IndexFile", "Using IndexPage cache", __FILE__, __LINE__);
include_once $IndexPageCacheFile;
} else {
$Page = new NitroPage();
$Page->PageCachingAllowed = TRUE;
if ($_GET["P"]) {
$Page->InitPageFromString($_GET["P"]);
} else {
$Page->InitPageFromSystemString($__NitroConf->CONF["Default"]["Page"]);
}
/**
* Draw the requested or default page on the screen.
*/
echo $PageContent = $Page->Draw();
/**
* Creating IndexPage cache when allowed
*/
if (!strlen($Page->Error) && $Page->PageCachingAllowed && !$Page->noPageCache && NitroGetConfig('Settings/IndexPageCache')) {
Debug("index.php", "IndexFile", "Creating cache of IndexPage", __FILE__, __LINE__, DEBUG_APPL_OK);
if ($fp = @fopen($IndexPageCacheFile, 'w')) {
fwrite($fp, $PageContent);
fclose($fp);
}
}
}
/**
* Page is drawn, close the session for writing. (reduces frame load!)
*/
session_write_close();
} else {
/**
* No NitroBaseConfig file found, error time!
*/
echo "Configuration File could not be loaded.<br /><br />" . $__NitroConf->Error;
exit;
}
/**
* Nitro Debug stuff
*/
if (NITRO_DEBUG) {
Debug("index.php", "IndexFile", "Index done, closing", __FILE__, __LINE__);
DebugCloseGroup(); // Why ?? There is no Group!
$_DEBUG->StopDebug();
echo $_DEBUG->DrawJScript();
} else {
echo "<script language='javascript' type='text/javascript'>window.status = \"Page parse time: " . sprintf("%0.5f", (NitroGetMicroTime() - $NitroPageStartTime)) . "\";</script>";
}
?>