<?php
//
// +---------------------------------------------------------------------------+
// | Nitro :: Config |
// +---------------------------------------------------------------------------+
// | Copyright (c) 2003 June Systems BV |
// +---------------------------------------------------------------------------+
// | This source file is copyrighted by June Systems BV, the Netherlands |
// | If you would like to use this file in your projects, please contact |
// | hide@address.com |
// +---------------------------------------------------------------------------+
// | Authors: Siggi Oskarsson <hide@address.com> |
// +---------------------------------------------------------------------------+
//
// $Id: Config.inc.php 229 2008-04-17 09:20:31Z oli $
//
// This file contains the config loader for Nitro
//
/**
* This file contains the configuration class of Nitro
*
* @package Nitro
* @subpackage Base
* @author Siggi Oskarsson
* @version $Revision: 1.6 $
* @copyright 2004 June Systems BV
*/
/**
* NitroConfig class
*
* @package Nitro
* @subpackage Base
*/
class NitroConfig {
var $ConfigFile;
var $CONF;
var $isLoaded;
function NitroConfig($ConfigFile) {
DebugGroup("Config", "Init", "Init config file", __FILE__, __LINE__, DEBUG_APPL_OK);
// Determine whether ini file exists and load it if it does
if (file_exists($ConfigFile)) {
$this->ConfigFile = $ConfigFile;
$this->LoadConfigFile();
//if ($this->CONF["Debug"]["debug_level"]) define("NITRO_DEBUG", $this->CONF["Debug"]["debug_level"]);
//else define("NITRO_DEBUG", 0);
} else {
$this->Error = "Config file does not exist";
$this->ConfigFile = FALSE;
}
DebugCloseGroup(DEBUG_APPL_OK);
}
function LoadConfigFile() {
DebugGroup("Config", "LoadConfigFile", "Load and parse config file", __FILE__, __LINE__, DEBUG_APPL_OK);
if ($this->ConfigFile) {
$ConfigStat = stat($this->ConfigFile);
if ($_SESSION["NitroCacheConfig"][$this->ConfigFile]["Stat"] == $ConfigStat[9]) {
// config not changed, using session cache
$this->CONF = $_SESSION["NitroCacheConfig"][$this->ConfigFile]["CONF"];
$this->isLoaded = TRUE;
Debug("Config", "LoadConfigFile", "Config cache found and used", __FILE__, __LINE__, DEBUG_APPL_OK);
} else {
if ($this->CONF = parse_ini_file($this->ConfigFile, TRUE)) {
$_SESSION["NitroCacheConfig"][$this->ConfigFile]["Stat"] = $ConfigStat[9];
$_SESSION["NitroCacheConfig"][$this->ConfigFile]["CONF"] = $this->CONF;
$this->isLoaded = TRUE;
Debug("Config", "LoadConfigFile", "Config cache not up2date, loaded new", __FILE__, __LINE__, DEBUG_APPL_OK);
} else {
unset($_SESSION["NitroCacheConfig"][$this->ConfigFile]);
$this->Error = "Failed parsing ini file";
$this->isLoaded = FALSE;
Debug("Config", "LoadConfigFile", "Config file not found", __FILE__, __LINE__, DEBUG_APPL_ERR);
}
}
} else {
$this->Error = "Config file does not exist";
}
DebugCloseGroup(DEBUG_APPL_OK);
}
function GetErrorFile() {
if ($this->CONF["Paths"]["ErrorFile"]) {
return $this->CONF["Paths"]["ErrorFile"];
} else {
return FALSE;
}
}
function GetValue ($Directive) {
}
}
?>