N_DEBUGTYPE_PAGE = 4 = Page debugging N_DEBUGTYPE_CACHE = 8 = Cache handling N_DEBUGTYPE_MENU = 16 = Menu debugging N_DEBUGTYPE_AUTH = 32 = Auth/Login debugging N_DEBUGTYPE_SQL = 64 = SQL debugging N_DEBUGTYPE_ALL = 127 = ALL options */ define('DEBUG_TYPE', 127); define('PAGE_CACHING', true); define('TREE_CACHING', true); // Set this to true if your navigation is actually in the body of each page. // That way, caches are cleared when you make changes to pages to keep your site // consistent. This should probably be set to false on a high traffic site. define('NAV_IN_PAGE', true); // Cache lifetime for files in seconds define('JS_CACHE_LIFETIME', -1); // Backend config is now loaded require_once 'config/config.php'; // To customize which pages cannot be deleted, add their page id's here NConfig::$protectedPages = array(1, 4); // Set the upload handler NUpload::connect(getenv('UPLOAD_HANDLER')); // Sanity check for configuration array_map(function ($env) { if (getenv($env) === false) { error_reporting(0); $error = "{$env} not configured!"; echo $error; throw new Exception($error); } }, array('DB_TYPE', 'DB_SERVER_USERNAME', 'DB_SERVER_PASSWORD', 'DB_SERVER', 'DB_DATABASE'));
function loadConfig($file) { $name = NEnvironment::getName(); if ($file instanceof NConfig) { $config = $file; $file = NULL; } else { if ($file === NULL) { $file = $this->defaultConfigFile; } $file = NEnvironment::expand($file); $config = NConfig::fromFile($file, $name); } if ($config->variable instanceof NConfig) { foreach ($config->variable as $key => $value) { NEnvironment::setVariable($key, $value); } } $iterator = new RecursiveIteratorIterator($config); foreach ($iterator as $key => $value) { $tmp = $iterator->getDepth() ? $iterator->getSubIterator($iterator->getDepth() - 1)->current() : $config; $tmp[$key] = NEnvironment::expand($value); } $runServices = array(); $context = NEnvironment::getContext(); if ($config->service instanceof NConfig) { foreach ($config->service as $key => $value) { $key = strtr($key, '-', '\\'); if (is_string($value)) { $context->removeService($key); $context->addService($key, $value); } else { $factory = $value->factory ? $value->factory : (isset($this->defaultServices[$key]) ? $this->defaultServices[$key] : NULL); if ($factory) { $context->removeService($key); $context->addService($key, $factory, isset($value->singleton) ? $value->singleton : TRUE, (array) $value->option); } else { throw new InvalidStateException("Factory method is not specified for service {$key}."); } if ($value->run) { $runServices[] = $key; } } } } if (!$config->php) { $config->php = $config->set; unset($config->set); } if ($config->php instanceof NConfig) { if (PATH_SEPARATOR !== ';' && isset($config->php->include_path)) { $config->php->include_path = str_replace(';', PATH_SEPARATOR, $config->php->include_path); } foreach (clone $config->php as $key => $value) { if ($value instanceof NConfig) { unset($config->php->{$key}); foreach ($value as $k => $v) { $config->php->{"{$key}.{$k}"} = $v; } } } foreach ($config->php as $key => $value) { $key = strtr($key, '-', '.'); if (!is_scalar($value)) { throw new InvalidStateException("Configuration value for directive '{$key}' is not scalar."); } if ($key === 'date.timezone') { date_default_timezone_set($value); } if (function_exists('ini_set')) { ini_set($key, $value); } else { switch ($key) { case 'include_path': set_include_path($value); break; case 'iconv.internal_encoding': iconv_set_encoding('internal_encoding', $value); break; case 'mbstring.internal_encoding': mb_internal_encoding($value); break; case 'date.timezone': date_default_timezone_set($value); break; case 'error_reporting': error_reporting($value); break; case 'ignore_user_abort': ignore_user_abort($value); break; case 'max_execution_time': set_time_limit($value); break; default: if (ini_get($key) != $value) { throw new NotSupportedException('Required function ini_set() is disabled.'); } } } } } if ($config->const instanceof NConfig) { foreach ($config->const as $key => $value) { define($key, $value); } } if (isset($config->mode)) { foreach ($config->mode as $mode => $state) { NEnvironment::setMode($mode, $state); } } foreach ($runServices as $name) { $context->getService($name); } return $config; }