<?php
/*
fiemeCP - BETA.
Written by, and managed by xDario.

The script may be altered at wish, but redistributing any part of it, even with credets, is prohibited. Currently, only myself and my website (http://www.dario-ml.com/) along with kryptodev are aloud to host my script.

©2011 xDario (created for Ohai Online)

You must provide a thanks on the page from which this is called, unless you have donated. If I find my class used without copyright, or a mention of appreciation, I will pursude you. Fiesta servers aren't thousands, so you're not hard to spot out.

Page: class.settings.php
Last Change: 11 June 2011
*/

if (!defined('IN_FIEME'))
{
	die("canno't directly access this page");
}

class fieme_settings
{
	public $path;
	
	function __construct()
	{
		$this->server_name = FIEME_SERVERNAME;
	}
	
	function dev_mode()
	{
		$lang_file = $this->path . "\s.global.php";
		
		if(file_exists($lang_file))
		{
			require_once $lang_file;
		}
		
		if (isset($s['dev_mode']))
		{
			return $s['dev_mode'];
		}
		else
		{
			return '0';
		}
		
	}

	//load the appropriate files now, falling back to english if possibl or needed
	function load($section)
	{

		$load_file = $this->path . "s." . $section . ".php";
		
		if(file_exists($load_file))
		{
			require $load_file;
		}
		
		// These shall not be edited!
		$dont_use = array('path');
		
		if(is_array($s))
		{
			foreach($s as $one => $two)
			{
				if((empty($this->$one) || $this->$one != $two) && !in_array($one, $dont_use))
				{
					$this->$one = $two;
					if (FIEME_DEV == 1)
					{
						global $dev_content;
						$dev_content .= "success load setting: $one<br />";
					}
				}
			}
		}
	}
	
	function sprintf($string)
	{
		$arg_list = func_get_args();
		$num_args = count($arg_list);
		
		for($i = 1; $i < $num_args; $i++)
		{
			$string = str_replace('{'.$i.'}', $arg_list[$i], $string);
		}
		
		return $string;
	}
}

