Source for file glconfig.php
Documentation is available at glconfig.php
* GloryLands Configuration Core
* GloryLands, a Web-Based, Massive Multiplayer Online RPG/Strategy Game
* Copyright (C) 2008-09 John Haralampidis <jïhnys2[at]gmail.cïm>
* 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, either version 3 of the License, or
* (at your option) any later version.
* This program 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 General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* For any help/suggestions or troubleshooting you can see the
* project community website at <http://www.glorylands.gr>
* @license GNU/GPLv3 GNU General Public License version 3
* @author John Haralampidis <jïhnys2[at]gmail.cïm>
* @copyright Copyright (C) 2007-2009, John Haralampidis
* This class provides a simple way to store and covert
* absolute disk paths into relative URLs and vice-versa.
* If you want to create a dynamic path, that can be quicly translated into URL, path, or
* anything else, you can use this class. For a sample usage, see the example.
* @example dynpath.php How to use Dynamic Path
* Dynamic URL Constructor
* @param string $dir_file The absolute or relative (to the site root) location of the file on disk
if (substr($dir_file,0,1) == '/') $dir_file = ((string) GLConfig::$root). $dir_file;
$this->url = str_replace(GLConfig::$root, '', $dir_file);
public function url($sub= '') {
if (substr($sub,0,1) != '/') $sub= '/'. $sub;
public function file($sub= '') {
if (substr($sub,0,1) != '/') $sub= '/'. $sub;
public function path($sub= '') {
if (substr($sub,0,1) != '/') $sub= '/'. $sub;
public function proxy($sub= '') {
* Configuration file access
* This class provides read/write access to the database access
* The filename that hols the config
* The data structure extracted from the config file
* Flags if the file is changed
if (!$this->changed) return;
// If file does not exists and we have a default file,
// import the default for the config.
$default = $path['dirname']. '/'. $path['filename']. '.default.'. $path['extension'];
$this->data = include($default);
$this->data = include($this->file);
public function __get($var) {
if (!isset ($this->data[$var])) {
return $this->data[$var];
public function __set($var, $value) {
$this->data[$var] = $value;
return isset ($this->data[$var]);
unset ($this->data[$var]);
* Glorylands Configuration Wrapper
* This class provides access to the global configuration
GLConfig::$root = new GLDynamicPath($root);
GLConfig::$resources = new GLDynamicPath('/resources');
GLConfig::$modules = new GLDynamicPath('/modules');
GLConfig::$engine = new GLDynamicPath('/engine');
GLConfig::$general = new GLConfigFile(self::$engine->file('config/general.php'));
|