realfan/src/base.php

36 lines
750 B
PHP
Raw Normal View History

<?php
$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='') {
global $locales;
$parts = explode('.', $key);
if (isset($locales[$parts[0]][$parts[1]]))
echo $locales[$parts[0]][$parts[1]];
else echo $default;
}
2021-11-25 13:33:49 +00:00
# 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;
}