/** * Loads the configuration file or setup form * @param string $key - The projects URL * @param unknown $filename - Path to the config file * @return array - Array with configuration data to access the Database */ function getConfiguration($key, $filename) { $config = loadJSONintoArray($filename); if ($config && isset($config[$key])) { return $config[$key]; } else { return false; } }
function setSystem() { $system = array(); echo "Do the Hard thing ...<br/>"; $system = array_merge($system, loadJSONintoArray("system/defs/settings.json")); // ########## if (isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) == "on") { $protocol = "https"; } else { $protocol = strtolower(substr($_SERVER["SERVER_PROTOCOL"], 0, strpos($_SERVER["SERVER_PROTOCOL"], "/"))); } $basePath = substr($_SERVER["SCRIPT_FILENAME"], 0, strrpos($_SERVER["SCRIPT_FILENAME"], "/")) . "/"; $baseUrl = $protocol . "://" . $_SERVER["HTTP_HOST"] . substr($_SERVER["SCRIPT_NAME"], 0, strrpos($_SERVER["SCRIPT_NAME"], "/")) . "/"; $system["baseUrl"] = $baseUrl; $system["basePath"] = $basePath; $config = getConfiguration($system["baseUrl"], $system["basePath"] . "system/defs/config.json"); if (!$config) { $this->error = "Configuration fault!"; } $config["dbPassword"] = base64_encode($config["dbPassword"]); $system = array_merge($system, $config); return $system; }