<?php

/**
 * Vvveb
 *
 * Copyright (C) 2020  Ziadin Givan
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 */

namespace Vvveb;

/*phpinfo();
die();*/

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

//define('DEBUG', 'false');

if (! defined('DIR_ROOT')) {
	define('DIR_ROOT', __DIR__ . '/');
}
define('DIR_CONFIG', DIR_ROOT . '/config/');
define('DIR_SYSTEM', DIR_ROOT . '/system/');

define('SQL_CHECK', true);
define('VIEW_TEMPLATE_ENGINE','psttt');

define('ID_HOST', '');
//Service
define('SERVICE_CACHE_FLAG_REGENERATE', -2); //wait for cache generation

if (! defined('SERVICE_CACHE_FLAG_LOCK')) {
	define('SERVICE_CACHE_FLAG_LOCK', -1);
} //lock set

//time
define('SERVICE_CACHE_EXPIRE_DELAY', 5); //real expiration time +5 seconds
define('SERVICE_CACHE_WAIT', 3); //wait for cache generation
define('SERVICE_CACHE_MAX_WAIT_RETRY', 3); //wait for cache generation
define('SERVICE_CACHE_LOCK_EXPIRE', 20); //lock can not be set more than SERVICE_CACHE_LOCK_EXPIRE seconds
define('COMPONENT_CACHE_EXPIRE', 20);

if (is_file(DIR_ROOT . 'config/db.php')) {
	define('APP', 'app');
} else {
	$app = 'install';
	define('APP', 'install');
	header('Location: install');
}

require_once DIR_SYSTEM . 'startup.php';

//Engine\start();
System\start();

$var        = config('db.default', 'default');
$connection = config('db.connections.' . $var,  []);
