Updated the config class. JSON support has been removed and a PHP config file writer has been implemented.
This commit is contained in:
parent
1e5ec4297a
commit
9edf81085a
|
@ -1 +0,0 @@
|
|||
{"type":"","host":"","database":"","username":"","password":"","prefix":""}
|
|
@ -0,0 +1,8 @@
|
|||
<?php return array (
|
||||
'type' => '',
|
||||
'host' => '',
|
||||
'database' => '',
|
||||
'username' => '',
|
||||
'password' => '',
|
||||
'prefix' => '',
|
||||
) ;
|
|
@ -1 +0,0 @@
|
|||
{"debug":false,"error_reporting":true}
|
|
@ -0,0 +1,4 @@
|
|||
<?php return array (
|
||||
'debug' => false,
|
||||
'error_reporting' => true,
|
||||
) ;
|
|
@ -1,26 +1,12 @@
|
|||
<?php
|
||||
return array(
|
||||
|
||||
# Sendmail Settings
|
||||
'sendmail_enabled' => true,
|
||||
|
||||
# SMTP Settings
|
||||
'smtp_enabled' => false,
|
||||
'smtp_host' => '',
|
||||
'smtp_port' => 25,
|
||||
'smtp_auth' => false,
|
||||
'smtp_username' => '',
|
||||
'smtp_password' => '',
|
||||
/**
|
||||
* 0 = off
|
||||
* 1 = client messages
|
||||
* 2 = client and server messages
|
||||
*/
|
||||
'smtp_debug_level' => 0,
|
||||
|
||||
# Common sender information
|
||||
'sender_name' => '',
|
||||
'sender_mail' => '',
|
||||
);
|
||||
|
||||
?>
|
||||
<?php return array (
|
||||
'sendmail_enabled' => true,
|
||||
'smtp_enabled' => false,
|
||||
'smtp_host' => '',
|
||||
'smtp_port' => 25,
|
||||
'smtp_auth' => false,
|
||||
'smtp_username' => '',
|
||||
'smtp_password' => '',
|
||||
'smtp_debug_level' => 0,
|
||||
'sender_name' => '',
|
||||
'sender_mail' => '',
|
||||
) ;
|
|
@ -1 +0,0 @@
|
|||
{"SITE_URL":"","SITE_DOMAIN":"","SERVER_NAME":"","administrator_mail":"","default_controller":"standard","default_function":"index"}
|
|
@ -0,0 +1,8 @@
|
|||
<?php return array (
|
||||
'SITE_URL' => '',
|
||||
'SITE_DOMAIN' => '',
|
||||
'SERVER_NAME' => '',
|
||||
'administrator_mail' => '',
|
||||
'default_controller' => 'standard',
|
||||
'default_function' => 'index',
|
||||
) ;
|
|
@ -1 +0,0 @@
|
|||
{"cookie_name":"","urlSelector":""}
|
|
@ -0,0 +1,4 @@
|
|||
<?php return array (
|
||||
'cookie_name' => '',
|
||||
'urlSelector' => '',
|
||||
) ;
|
|
@ -13,14 +13,10 @@ class Config extends Bus{
|
|||
public function loadConfigFile($name, $directory = null) {
|
||||
$dir = (isset($directory) ? $directory : FUZEPATH . "Application//config/");
|
||||
$file = $dir . 'config.' . strtolower($name).".php";
|
||||
$file2 = $dir . 'config.' . strtolower($name).".enc.cfg";
|
||||
|
||||
if (file_exists($file)) {
|
||||
$DECODED = (object) require($file);
|
||||
return $DECODED;
|
||||
} elseif (file_exists($file2)) {
|
||||
$data = file_get_contents($file2);
|
||||
return json_decode($data);
|
||||
} else {
|
||||
$this->core->loadMod('database');
|
||||
if ($this->dbActive) {
|
||||
|
@ -53,6 +49,40 @@ class Config extends Bus{
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change a value in the config, wherever this is saved
|
||||
* @access public
|
||||
* @param String filename
|
||||
* @param String config key
|
||||
* @param String config value
|
||||
* @param String directory, default is Application/Config
|
||||
*/
|
||||
public function set($name, $key, $value, $directory = null) {
|
||||
$dir = (isset($directory) ? $directory : FUZEPATH . "Application//config/");
|
||||
$file = $dir . 'config.' . strtolower($name).".php";
|
||||
$file2 = $dir . 'config.' . strtolower($name).".enc.cfg";
|
||||
if (file_exists($file)) {
|
||||
$DECODED = require($file);
|
||||
if (is_null($value)) {
|
||||
unset($DECODED[$key]);
|
||||
} else {
|
||||
$DECODED[$key] = $value;
|
||||
}
|
||||
|
||||
if (is_writable($file)) {
|
||||
$config = var_export($DECODED, true);
|
||||
file_put_contents($file, "<?php return $config ;");
|
||||
}
|
||||
} else {
|
||||
throw new Exception("Config file '".strtolower($name)."' was not found", 1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private function write_config($file, $contents) {
|
||||
$DECODED = (object) require($file);
|
||||
}
|
||||
|
||||
public function __get($name) {
|
||||
return $this->loadConfigFile($name);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue