43 lines
938 B
PHP
43 lines
938 B
PHP
<?php
|
|
|
|
define('OK', 'ok');
|
|
define('ERR', 'err');
|
|
define('HOST_DEV', 'http://127.0.0.1:8080');
|
|
|
|
$env = 'prod';
|
|
if (getenv('ENV') !== false && in_array(getenv('ENV'), ['prod', 'dev']))
|
|
$env = getenv('ENV');
|
|
define('ENV', $env);
|
|
|
|
|
|
# load locales
|
|
$lang = 'es';
|
|
$lang_file = '/src/locales/'.$lang.'.json';
|
|
$locales = (object)[];
|
|
if (file_exists($lang_file))
|
|
$locales = json_decode(file_get_contents($lang_file), true);
|
|
|
|
function l($key, $default='') { echo lr($key, $default); }
|
|
function lr($key, $default='') {
|
|
global $locales;
|
|
$parts = explode('.', $key);
|
|
if (isset($locales[$parts[0]][$parts[1]]))
|
|
return $locales[$parts[0]][$parts[1]];
|
|
return $default;
|
|
}
|
|
|
|
# read config
|
|
$config = [];
|
|
if (file_exists('/config/config.php')) {
|
|
require_once '/config/config.php';
|
|
}
|
|
|
|
function conf($key, $default='') {
|
|
global $config;
|
|
if (isset($config[$key]))
|
|
return $config[$key];
|
|
return $default;
|
|
}
|
|
|
|
require_once '/src/base.methods.php';
|