feat: getConfigLua added into engine/general

This commit is contained in:
Gabriel Pedro 2016-05-14 14:47:40 -04:00
parent 42195da9dc
commit 1cc404faaa
2 changed files with 27 additions and 19 deletions

View File

@ -40,6 +40,23 @@ function data_dump($print = false, $var = false, $title = false) {
echo '</pre><br>'; echo '</pre><br>';
} }
function getConfigLua() {
$filename = config('server_path') . '/config.lua';
if (!file_exists($filename)) {
return;
}
$contents = file_get_contents($filename);
$array = explode("\n", $contents);
$output = [];
foreach ($array as $arr) {
if (strpos($arr, '--') !== 0) {
$output[] = $arr;
}
}
$ini = implode("\n", $output);
return parse_ini_string($ini);
}
function accountAccess($accountId, $TFS) { function accountAccess($accountId, $TFS) {
$accountId = (int)$accountId; $accountId = (int)$accountId;
$access = 0; $access = 0;

View File

@ -5,23 +5,14 @@ Here you will find all basic information about <?php echo '<b>'.$config['site_ti
<?php <?php
// Check if PATH is correct // Check if PATH is correct
if (file_exists($config['server_path'].'/config.lua')) { $lua_path = getConfigLua();
// Checks OS from config.php ($config['os']) if ($lua_path && is_array($lua_path)) {
if ($config['os'] == 'LINUX') { if (!file_exists($config['server_path'].'/data/XML/stages.xml')) {
if (file_exists($config['server_path'].'/data/XML/stages.xml')) {
$stages_path = simplexml_load_file($config['server_path'].'/data/XML/stages.xml');
} else {
echo 'Couldn\'t locate stages.xml'; echo 'Couldn\'t locate stages.xml';
} return;
} else {
if (file_exists($config['server_path'].'/data/XML/stages.xml')) {
$stages_path = simplexml_load_file($config['server_path'].'/data/XML/stages.xml');
} else {
echo 'Couldn\'t locate stages.xml';
}
} }
$lua_path = parse_ini_file($config['server_path'].'/config.lua'); $stages_path = simplexml_load_file($config['server_path'].'/data/XML/stages.xml');
echo '<h2>Server rates</h2>'; echo '<h2>Server rates</h2>';
if ($stages_path->config['enabled'] != 0) { if ($stages_path->config['enabled'] != 0) {
// Stages are beeing used // Stages are beeing used
@ -73,7 +64,7 @@ if (file_exists($config['server_path'].'/config.lua')) {
echo '</ul>'; echo '</ul>';
} else { } else {
echo '<h1>Invliad PATH, please check your config file</h1>'; echo '<h1>Cannot find the file <strong>config.lua</strong></h1>';
} }
include 'layout/overall/footer.php'; ?> include 'layout/overall/footer.php'; ?>