mirror of
https://github.com/slawkens/myaac.git
synced 2026-04-23 10:53:32 +02:00
[WIP] Loading of config .toml's
Deprecate load_config_lua, use MyAAC\Server\Lua\Loader::load instead
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
use MyAAC\Server\Lua\Loader;
|
||||
|
||||
class Validator extends \MyAAC\Validator {}
|
||||
|
||||
function check_name($name, &$errors = '') {
|
||||
@@ -128,3 +130,23 @@ function Mount_parseNode($node): array
|
||||
$type = $node->getAttribute('type');
|
||||
return array('id' => $id, 'clientid' => $clientid, 'name' => $name, 'speed' => $speed, 'premium' => $premium, 'type' => $type);
|
||||
}
|
||||
|
||||
function load_config_lua(string $file): array
|
||||
{
|
||||
$result = Loader::load($file);
|
||||
if ($result === false) {
|
||||
log_append('error.log', '[load_config_file] Fatal error: Cannot load config.lua (' . $file . ').');
|
||||
throw new \RuntimeException('ERROR: Cannot find ' . $file . ' file.');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function configLua($key) {
|
||||
global $config;
|
||||
if (is_array($key)) {
|
||||
return $config['lua'][$key[0]] = $key[1];
|
||||
}
|
||||
|
||||
return @$config['lua'][$key];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user