public static function get($key = null, $subkey = null) { $config = Config::getInstance()->config['database']; // If 'use_db_settings' = true, get settings from Database if ($config['use_db'] === true && $config['use_db_settings'] === true) { $db = new Database(); $settings = $db->select("SELECT data FROM {$config['table_db_settings']} WHERE 1"); // Add settings to the global config Config::getInstance()->combineSettings(array('settings' => json_decode($settings[0]['data'], true))); } foreach (Config::getInstance()->config['settings']['modules'] as $module) { if (is_file('App/' . $module . '/config/config.php')) { $config = (require 'App/' . $module . '/config/config.php'); Config::getInstance()->combineSettings(array('settings' => $config)); } } if ($key) { if (array_key_exists($key, Config::getInstance()->config)) { if ($subkey) { if (array_key_exists($subkey, Config::getInstance()->config[$key])) { return Config::getInstance()->config[$key][$subkey]; } else { return false; } } else { return Config::getInstance()->config[$key]; } } else { return null; } } else { return Config::getInstance()->config; } }
public static function readSessionFromDb($key = null) { $config = Config::get('session'); if (!$key) { $key = $config['cookie_default_key']; } if ($config['session_use_db'] === true) { $session_key = !is_null(self::getSession($key)) ? self::getSession($key) : self::getCookie($key); if ($session_key) { $db = new Database(); $result = $db->select("SELECT user_data FROM {$config['session_db_table']} WHERE session_key='{$session_key}'"); if (!empty($result)) { $user_data = unserialize($result[0]['user_data']); return $user_data; } else { return false; } } else { return false; } } return null; }