Added the agent and website folders

This commit is contained in:
Frank Harris 2025-09-05 08:41:50 -04:00
parent 0e5a131bfb
commit 85ec5836a5
778 changed files with 104105 additions and 9 deletions

View file

@ -0,0 +1,36 @@
<?php
require_once('../../includes/lib_remote.php');
require_once('../../modules/config_games/server_config_parser.php');
require_once('../../includes/functions.php');
// Get parameters from GET
$home_id = isset($_GET['home_id']) ? $_GET['home_id'] : null;
$mod_id = isset($_GET['mod_id']) ? $_GET['mod_id'] : null;
if (!$home_id || !$mod_id) {
echo "<pre>No home_id or mod_id provided.</pre>";
exit;
}
// You may need to adjust this to match your DB access
$db = getOGPDBInstance(); // Replace with your DB instance
$home_info = $db->getGameHome($home_id);
$server_xml = read_server_config(SERVER_CONFIG_LOCATION."/".$home_info['home_cfg_file']);
$remote = new OGPRemoteLibrary($home_info['agent_ip'],$home_info['agent_port'],$home_info['encryption_key'],$home_info['timeout']);
$home_log = "";
if( isset( $server_xml->console_log ) ) {
$log_path = preg_replace("/%mod%/i", $home_info['mods'][$mod_id]['mod_key'], $server_xml->console_log);
$log_retval = $remote->remote_readfile( $home_info['home_path'].'/'.$log_path, $home_log );
} else {
$log_retval = $remote->get_log(OGP_SCREEN_TYPE_HOME, $home_info['home_id'], clean_path($home_info['home_path']."/".$server_xml->exe_location), $home_log);
}
$lines = explode("\n", $home_log);
$home_log = implode("\n", array_slice($lines, -40));
if ($log_retval > 0) {
echo "<pre style='background:black;color:white;'>".htmlspecialchars($home_log)."</pre>";
} else {
echo "<pre style='background:black;color:white;'>Unable to get log: $log_retval</pre>";
}
?>

View file

@ -155,18 +155,22 @@ function exec_ogp_module()
$home_log = getLastLines($home_log, 40);
// Replace hardcoded log output with AJAX container
if ($log_retval > 0)
{
if ( $log_retval == 2 )
print_failure(get_lang('server_not_running_log_found'));
//echo "<pre style='background:black;color:white;'>".$home_log."</pre>";
if ($log_retval == 2)
return;
}
else
{
print_failure(get_lang_f('unable_to_get_log',$log_retval));
echo "<div id='server-log-output'><pre style='background:black;color:white;'>".htmlspecialchars($home_log)."</pre></div>";
} else {
echo "<div id='server-log-output'><pre style='background:black;color:white;'>Unable to get log: $log_retval</pre></div>";
}
// Add AJAX refresh script
?>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
setInterval(function() {
$('#server-log-output').load('modules/gamemanager/get_server_log.php?home_id=<?php echo $home_id; ?>&mod_id=<?php echo $mod_id; ?>');
}, 2000);
</script>
<?php
// If game is not supported by lgsl we skip the lgsl checks and
// assume successfull start.