Panel/modules/config_games/server_config_parser.php
copilot-swe-agent[bot] 898018d204 Complete license header replacement with file purpose descriptions (675 files)
Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
2025-09-05 22:46:27 +00:00

46 lines
1.1 KiB
PHP

<?php
/*
* Component of the config_games module
*/
define("SERVER_CONFIG_LOCATION","modules/config_games/server_configs/");
define("XML_SCHEMA","modules/config_games/schema_server_config.xml");
/// \return FALSE in case of failure in parsing.
/// \return array containing the elements on success.
function read_server_config( $filename )
{
$dom = new DOMDocument();
if ( $dom->load($filename) === FALSE )
{
print_failure(get_lang_f('unable_to_load_xml',$filename));
return FALSE;
}
if ( $dom->schemaValidate(XML_SCHEMA) != TRUE )
{
print_failure(get_lang_f('xml_file_not_valid',$filename,XML_SCHEMA));
return FALSE;
}
$xml = simplexml_load_file($filename);
if($xml !== false){
$xml->addChild('home_cfg_file',basename($filename));
return $xml;
}
return false;
}
function xml_get_mod( $server_xml, $mod_key )
{
foreach ( $server_xml->mods->mod as $xml_mod_tmp )
{
if ($xml_mod_tmp['key'] == $mod_key)
{
return $xml_mod_tmp;
}
}
return FALSE;
}
?>