realfan/src/base.php

43 lines
938 B
PHP
Raw Normal View History

<?php
2021-11-25 18:18:00 +00:00
define('OK', 'ok');
define('ERR', 'err');
define('HOST_DEV', 'http://127.0.0.1:8080');
2021-11-25 15:43:35 +00:00
$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;
}
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;
}
require_once '/src/base.methods.php';