Source for file Settings.php
Documentation is available at Settings.php
* LICENSE: This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
* @author Hector Ortiz (FreeNAC Core Team)
* @copyright 2007 FreeNAC
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License Version 2
* @link http://www.freenac.net
* Define the Settings class which is a Singleton
* used to hold global variables stored in the configuration files and running script.
private static $instance;
* Set our internal array to contain all variabled defined in the config table
private function __construct()
$query=
"select * from config"; # Query
while ($result=
mysql_fetch_array($res, MYSQL_ASSOC)) # Iterate over all information found
switch ($result['type']) # Now doing casts according to the field 'type'
{ # And store them in an internal array
case 'integer':
$temp[$result['name']]=(integer)
$result['value'];
$temp[$result['name']]=(boolean)
true;
$temp[$result['name']]=(boolean)
false;
case 'float':
$temp[$result['name']]=(float)
$result['value'];
case 'double':
$temp[$result['name']]=(double)
$result['value'];
case 'string':
$temp[$result['name']]=(string)
$result['value'];
case 'array':
$temp[$result['name']][]=
$result['value'];
$this->props=
$temp; # Et voila, copy it to our internal array
return; # Nothing to return
* Get instance of this class
* @return object Current instance
if (empty(self::$instance)) # Is there an instance of this class?
self::$instance=
new Settings(); # No, then create it
return self::$instance; # Yes, return it
* Get the value of one property if it exists
* @param mixed $key Property to lookup
* @return mixed The value of the wanted property, or false if such a property doesn't exist
public function __get($key) # Get the value of one var
if (isset
($this->props[$key]))
return $this->props[$key];
* Return all properties defined. This method is here only for debugging purposes, please delete it after
* @return array All properties present
Documentation generated on Mon, 17 Nov 2008 01:10:47 +0100 by phpDocumentor 1.4.0