Codex documentstion created

This commit is contained in:
Frank Harris 2026-06-05 11:07:47 -05:00
parent 3dc017421e
commit b5dcf01a8c
27 changed files with 6648 additions and 1069 deletions

View file

@ -36,6 +36,45 @@ function get_query_port($server_xml, $server_port) {
return $server_port;
}
function get_agent_server_status($remote, $server_xml, $home_id, $server_ip, $server_port, $state_hint = "", $startup_timeout = 180)
{
$query_port = "";
$rcon_port = "";
if (isset($server_xml->protocol) && (string)$server_xml->protocol === "gameq") {
$query_port = get_query_port($server_xml, $server_port);
} elseif (isset($server_xml->protocol) && (string)$server_xml->protocol === "lgsl" && isset($server_xml->lgsl_query_name)) {
require_once('protocol/lgsl/lgsl_protocol.php');
$get_ports = lgsl_port_conversion((string)$server_xml->lgsl_query_name, $server_port, "", "");
$query_port = isset($get_ports['1']) ? $get_ports['1'] : "";
} elseif (isset($server_xml->protocol) && (string)$server_xml->protocol === "teamspeak3") {
$query_port = "10011";
}
if (isset($server_xml->rcon_port) && is_numeric((string)$server_xml->rcon_port)) {
$rcon_port = (string)$server_xml->rcon_port;
}
if (!method_exists($remote, 'remote_server_status')) {
return array('status' => 'UNKNOWN', 'last_error' => 'Panel remote library does not support agent status.');
}
return $remote->remote_server_status($home_id, $server_ip, $server_port, $query_port, $rcon_port, $startup_timeout, $state_hint);
}
function is_agent_status_online($agent_status)
{
return is_array($agent_status) && isset($agent_status['status']) && strtoupper($agent_status['status']) === 'ONLINE';
}
function is_agent_status_active($agent_status)
{
if (!is_array($agent_status) || !isset($agent_status['status'])) {
return false;
}
return in_array(strtoupper($agent_status['status']), array('STARTING', 'ONLINE', 'STOPPING', 'UNRESPONSIVE'));
}
function get_start_cmd($remote,$server_xml,$home_info,$mod_id,$ip,$port,$db)
{
$last_param = json_decode($home_info['last_param'], True);
@ -250,19 +289,23 @@ function exec_operation( $action, $home_id, $mod_id, $ip, $port, $override = fal
}
}
$screen_running = $remote->is_screen_running(OGP_SCREEN_TYPE_HOME,$home_info['home_id']) === 1;
$agent_status = get_agent_server_status($remote, $server_xml, $home_info['home_id'], $ip, $port);
$screen_running = is_agent_status_active($agent_status);
if ( $action == "stop" AND $screen_running )
{
$remote_retval = $remote->remote_stop_server($home_info['home_id'],
$ip, $port, $server_xml->control_protocol,
$home_info['control_password'],$server_xml->control_protocol_type, $home_info['home_path']);
$db->logger(get_lang_f('server_stopped', $home_info['home_name'] ) . "($ip:$port)");
if ( $remote_retval === -1 )
return FALSE;
elseif( $remote_retval === -2 )
return FALSE;
else
$remote_retval = $remote->remote_stop_server($home_info['home_id'],
$ip, $port, $server_xml->control_protocol,
$home_info['control_password'],$server_xml->control_protocol_type, $home_info['home_path']);
$agent_status = get_agent_server_status($remote, $server_xml, $home_info['home_id'], $ip, $port, "STOPPING");
$db->logger(get_lang_f('server_stopped', $home_info['home_name'] ) . "($ip:$port)");
if ( $remote_retval === -1 )
return FALSE;
elseif( $remote_retval === -2 )
return FALSE;
elseif( isset($agent_status['status']) && strtoupper($agent_status['status']) !== "OFFLINE" )
return FALSE;
else
{
$firewall_settings = $db->getFirewallSettings($home_info['remote_server_id']);
if ($firewall_settings['status'] == "enable")

View file

@ -8,25 +8,25 @@ require_once("modules/config_games/server_config_parser.php");
echo "home id = " .$home_id;
$user_id = $_SESSION['user_id'];
$isAdmin = $db->isAdmin( $user_id );
if($isAdmin)
if($isAdmin)
$home_info = $db->getGameHome($home_id);
else
$home_info = $db->getUserGameHome($user_id,$home_id);
$current_mod_info = $home_info['mods'][$mod_id];
$current_mod_info = $home_info['mods'][$mod_id];
$home_cfg_id = $current_mod_info['home_cfg_id'];
$mod_cfg_id = $current_mod_info['mod_cfg_id'];
if($home_cfg_id === null && $mod_cfg_id === null){
$home_cfg_id = 67;
$mod_cfg_id = 68;
//print_failure(get_lang('invalid_game_mod_id'));
//return;
}
if ( $home_info === FALSE )
{
//print_failure( get_lang("no_access_to_home") );
@ -45,7 +45,7 @@ require_once("modules/config_games/server_config_parser.php");
$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_retval = $remote->get_log(OGP_SCREEN_TYPE_HOME,
@ -72,72 +72,50 @@ require_once("modules/config_games/server_config_parser.php");
if(hasValue($home_log)){
$home_log = utf8_encode($home_log);
}
// Using the refreshed class
if( isset($_GET['refreshed']) )
{
echo "<pre class='log'>".htmlentities($home_log)."</pre>";
}
else
{
echo "<h2>".htmlentities($home_info['home_name'])."</h2>";
if($log_retval == 1)
// Using the refreshed class
if( isset($_GET['refreshed']) )
{
require_once("includes/refreshed.php");
$control = '<form method="GET" >
<input type="hidden" name="m" value="gamemanager" />
<input type="hidden" name="p" value="log" />
<input type="hidden" name="home_id-mod_id-ip-port" value="'.$_GET['home_id-mod_id-ip-port'].'" />';
if(isset($_GET['setInterval']))
$control .= "<input type='hidden' name='setInterval' value='" . $_GET['setInterval'] . "' />";
if(isset($_GET['view_player_commands']))
$control .= "<input type='hidden' name='view_player_commands' value='" . $_GET['view_player_commands'] . "' />";
$control .= '<input type="submit" name="size" value="';
if( isset( $_GET['size'] ) and $_GET['size'] == "+" )
{
$height = "100%";
$control .= '-';
}
else
{
$height = "500px";
$control .= '+';
if (!headers_sent()) {
header('Content-Type: text/plain; charset=UTF-8');
}
$control .= '" /></form>';
$intervals = array( "4s" => "4000",
"8s" => "8000",
"30s" => "30000",
"2m" => "120000",
"5m" => "300000" );
$intSel = '<form action="" method="GET" >
<input type="hidden" name="m" value="gamemanager" />
<input type="hidden" name="p" value="log" />
<input type="hidden" name="home_id-mod_id-ip-port" value="'.$_GET['home_id-mod_id-ip-port'].'" />';
if(isset($_GET['size']))
$intSel .= "<input type='hidden' name='size' value='" . $_GET['size'] . "' />";
if(isset($_GET['view_player_commands']))
$intSel .= "<input type='hidden' name='view_player_commands' value='" . $_GET['view_player_commands'] . "' />";
$intSel .= get_lang("refresh_interval") . ':<select name="setInterval" onchange="this.form.submit();">';
foreach ((array)$intervals as $interval => $value )
echo $home_log;
return;
}
else
{
echo "<h2>".htmlentities($home_info['home_name'])."</h2>";
if($log_retval == 1)
{
$selected = "";
if ( isset( $_GET['setInterval'] ) AND $_GET['setInterval'] == $value )
$selected = 'selected="selected"';
$intSel .= '<option value="'.$value.'" '.$selected.' >'.$interval.'</option>';
}
$intSel .= "</select></form>";
$setInterval = isset($_GET['setInterval']) ? $_GET['setInterval'] : 4000;
$refresh = new refreshed();
$pos = $refresh->add("home.php?m=gamemanager&p=log&type=cleared&refreshed&home_id-mod_id-ip-port=". $_GET['home_id-mod_id-ip-port']);
echo $refresh->getdiv($pos,"height:".$height.";overflow:auto;max-width:1600px;");
?><script type="text/javascript">$(document).ready(function(){ <?php echo $refresh->build("$setInterval"); ?>} ); </script><?php
echo "<table class='center' ><tr><td>$intSel</td><td>$control</td></tr></table>";
if( ($server_xml->control_protocol and preg_match("/^r?l?con2?$/", $server_xml->control_protocol)) OR
($server_xml->gameq_query_name and $server_xml->gameq_query_name == "minecraft") OR
$log_url = "home.php?m=gamemanager&p=log&type=cleared&refreshed&home_id-mod_id-ip-port=".rawurlencode($_GET['home_id-mod_id-ip-port']);
echo '<textarea id="live-server-log" class="log" readonly="readonly" style="height:500px;overflow:auto;max-width:1600px;width:100%;box-sizing:border-box;">'.htmlentities($home_log, ENT_QUOTES, "UTF-8").'</textarea>';
?>
<script type="text/javascript">
(function(){
var logBox = document.getElementById('live-server-log');
if (!logBox) return;
function isAtBottom() {
return (logBox.scrollTop + logBox.clientHeight) >= (logBox.scrollHeight - 24);
}
function refreshLog() {
var shouldScroll = isAtBottom();
fetch('<?php echo $log_url; ?>', {cache: 'no-store'})
.then(function(response){ return response.text(); })
.then(function(text){
logBox.value = text;
if (shouldScroll) {
logBox.scrollTop = logBox.scrollHeight;
}
})
.catch(function(){});
}
logBox.scrollTop = logBox.scrollHeight;
window.setInterval(refreshLog, 4000);
})();
</script>
<?php
if( ($server_xml->control_protocol and preg_match("/^r?l?con2?$/", $server_xml->control_protocol)) OR
($server_xml->gameq_query_name and $server_xml->gameq_query_name == "minecraft") OR
($server_xml->lgsl_query_name and $server_xml->lgsl_query_name == "7dtd") )
require('modules/gamemanager/rcon.php');
}

View file

@ -114,77 +114,33 @@ function exec_ogp_module() {
print_failure(get_lang_f('unable_to_get_log',$log_retval));
}
// If game is not supported by lgsl we skip the lgsl checks and
// assume successfull start.
if ( $home_info['use_nat'] == 1 )
$query_ip = $home_info['agent_ip'];
else
$query_ip = $ip;
$running = TRUE;
$startup_timeout = isset($server_xml->startup_timeout) && is_numeric((string)$server_xml->startup_timeout) ? (int)$server_xml->startup_timeout : 180;
$agent_status = get_agent_server_status($remote, $server_xml, $home_id, $ip, $port, "STARTING", $startup_timeout);
$status_name = isset($agent_status['status']) ? strtoupper($agent_status['status']) : "UNKNOWN";
if ( $server_xml->lgsl_query_name )
{
require('protocol/lgsl/lgsl_protocol.php');
$get_q_and_s = lgsl_port_conversion((string)$server_xml->lgsl_query_name, $port, "", "");
//Connection port
$c_port = $get_q_and_s['0'];
//query port
$q_port = $get_q_and_s['1'];
//software port
$s_port = $get_q_and_s['2'];
$data = lgsl_query_live((string)$server_xml->lgsl_query_name, $query_ip, $c_port, $q_port, $s_port, "sa");
if ( $data['b']['status'] == "0" )
{
$running = FALSE;
}
}
elseif ( $server_xml->gameq_query_name )
{
require_once 'protocol/GameQ/Autoloader.php';
$query_port = get_query_port($server_xml, $port);
$servers = array(
array(
'id' => 'server',
'type' => (string)$server_xml->gameq_query_name,
'host' => $query_ip . ":" . $query_port,
)
);
$gq = new \GameQ\GameQ();
$gq->addServers($servers);
$gq->setOption('timeout', 4);
$gq->setOption('debug', FALSE);
$gq->addFilter('normalise');
$game = $gq->process();
if ( ! $game['server']['gq_online'] )
{
$running = FALSE;
}
}
if( ! $running )
if( $status_name !== "ONLINE" )
{
if (!isset($_GET['retry']))
$retry = 0;
else
$retry = $_GET['retry'];
if ($retry >= 5)
if ($status_name === "UNKNOWN")
{
echo "<p>".get_lang('server_running_not_responding')."
<a href=?m=gamemanager&amp;p=stop&amp;home_id=".$home_id.
"&amp;ip=".$ip."&amp;port=".
$port.">".get_lang('already_running_stop_server').".</a></p>";
echo "<table class='center'><tr><td><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=$home_id-$mod_id-$ip-$port'><< ".get_lang('back')."</a></td></tr></table>";
print_failure(get_lang("agent_offline"));
$view->refresh("?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=$home_id-$mod_id-$ip-$port",3);
return;
}
if ($status_name === "UNRESPONSIVE")
{
$message = isset($agent_status['last_error']) && $agent_status['last_error'] !== "" ? $agent_status['last_error'] : "Server process exists but the game port is not ready.";
print_failure(htmlentities($message));
$view->refresh("?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=$home_id-$mod_id-$ip-$port",5);
return;
}
echo "</b>Retry #".$retry.".</b>";
echo "<p class='note'>Server status: ".htmlentities($status_name).". Waiting for the game port to become ready.</p>";
$retry++;
print("<p class='note'>".get_lang('starting_server')."</p>");
$view->refresh("?m=gamemanager&amp;p=start&amp;refresh&amp;ip=$ip&amp;port=$port&amp;home_id=$home_id&amp;mod_id=$mod_id&amp;retry=".$retry,3);
@ -266,12 +222,12 @@ function exec_ogp_module() {
print_failure(get_lang('server_cant_stop'));
$view->refresh("?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=". $home_id . "-". $mod_id . "-" . $ip . "-" . $port,3);
}
else
{
$screen_running = $remote->is_screen_running(OGP_SCREEN_TYPE_HOME,$home_id);
if ( $screen_running == 1 )
else
{
print("<p class='note'>".get_lang('restarting_server')."</p>");
$agent_status = get_agent_server_status($remote, $server_xml, $home_id, $ip, $port, "STARTING");
if ( is_agent_status_active($agent_status) )
{
print("<p class='note'>".get_lang('restarting_server')."</p>");
$view->refresh("?m=gamemanager&amp;p=restart&amp;refresh&amp;ip=$ip&amp;port=$port&amp;home_id=$home_id&amp;mod_id=$mod_id",3);
return;
}

View file

@ -480,13 +480,21 @@ echo "<table id='servermonitor' class='tablesorter' data-sortlist='[[0,0],[3,1]]
$displayIP = checkDisplayPublicIP($server_home['display_public_ip'], $ip);
$address = "";
$screen_running = $remote->is_screen_running(OGP_SCREEN_TYPE_HOME,$server_home['home_id']) === 1;
$agent_status = get_agent_server_status($remote, $server_xml, $server_home['home_id'], $server_home['ip'], $server_home['port']);
$agent_state = isset($agent_status['status']) ? strtoupper($agent_status['status']) : "UNKNOWN";
$screen_running = is_agent_status_active($agent_status);
$update_in_progress = $remote->is_screen_running(OGP_SCREEN_TYPE_UPDATE,$server_home['home_id']) === 1;
if($screen_running)
{
// Check if the screen running the server is running.
$status = "online";
$order = 1 + $j;
if($agent_state !== "ONLINE")
{
$address = "<span class='note'>".htmlentities($agent_state)."</span>";
if(isset($agent_status['last_error']) && $agent_status['last_error'] !== "")
$address .= " <span class='failure'>".htmlentities($agent_status['last_error'])."</span>";
}
if ($server_xml->protocol == "lgsl")
{
$get_q_and_s = lgsl_port_conversion($query_name, $server_home['port'], "", "");
@ -496,14 +504,17 @@ echo "<table id='servermonitor' class='tablesorter' data-sortlist='[[0,0],[3,1]]
$q_port = $get_q_and_s['1'];
//software port
$s_port = $get_q_and_s['2'];
$address = "<a href='" . lgsl_software_link($query_name, $query_ip, $c_port, $q_port, $s_port) . "' >Connect</a>";
if($agent_state === "ONLINE")
$address = "<a href='" . lgsl_software_link($query_name, $query_ip, $c_port, $q_port, $s_port) . "' >Connect</a>";
}
if ($server_xml->protocol == "teamspeak3")
if ($server_xml->protocol == "teamspeak3" && $agent_state === "ONLINE")
$address = "<a href='ts3server://" . $query_ip . ":" . $server_home['port'] . "'>".$displayIP.":".$server_home['port']."</a>";
if($server_xml->protocol == "gameq" and $server_xml->installer == 'steamcmd')
if($server_xml->protocol == "gameq" and $server_xml->installer == 'steamcmd' && $agent_state === "ONLINE")
$address = "<a href='steam://connect/" . $query_ip . ":" . $server_home['port'] . "'>" . $displayIP . ":" . $server_home['port'] . "</a>";
if($agent_state === "ONLINE" && isset($agent_status['query_port']) && $agent_status['query_port'] !== "" && empty($agent_status['query_port_listening']))
$address .= " <span class='note'>Query info unavailable.</span>";
$pos = $refresh->add("home.php?m=gamemanager&p=ref_servermonitor&type=cleared&home_id=". $server_home['home_id'] . "&mod_id=". $server_home['mod_id'] . "&ip=" . $server_home['ip'] . "&port=" . $server_home['port']);
if ($server_xml->protocol == "teamspeak3")

View file

@ -175,79 +175,33 @@ function exec_ogp_module()
</script>
<?php
// If game is not supported by lgsl we skip the lgsl checks and
// assume successfull start.
if ( $home_info['use_nat'] == 1 )
$query_ip = $home_info['agent_ip'];
else
$query_ip = $ip;
$startup_timeout = isset($server_xml->startup_timeout) && is_numeric((string)$server_xml->startup_timeout) ? (int)$server_xml->startup_timeout : 180;
$agent_status = get_agent_server_status($remote, $server_xml, $home_id, $ip, $port, "STARTING", $startup_timeout);
$status_name = isset($agent_status['status']) ? strtoupper($agent_status['status']) : "UNKNOWN";
$running = $remote->is_screen_running(OGP_SCREEN_TYPE_HOME,$home_info['home_id']);
if ( $server_xml->lgsl_query_name )
{
require('protocol/lgsl/lgsl_protocol.php');
$get_q_and_s = lgsl_port_conversion((string)$server_xml->lgsl_query_name, $port, "", "");
//Connection port
$c_port = $get_q_and_s['0'];
//query port
$q_port = $get_q_and_s['1'];
//software port
$s_port = $get_q_and_s['2'];
$data = lgsl_query_live((string)$server_xml->lgsl_query_name, $query_ip, $c_port, $q_port, $s_port, "sa");
if ( $data['b']['status'] == "0" )
{
$running = FALSE;
}
}
elseif ( $server_xml->gameq_query_name )
{
require_once 'protocol/GameQ/Autoloader.php';
$query_port = get_query_port($server_xml, $port);
$servers = array(
array(
'id' => 'server',
'type' => (string)$server_xml->gameq_query_name,
'host' => $query_ip . ":" . $query_port,
)
);
$gq = new \GameQ\GameQ();
$gq->addServers($servers);
$gq->setOption('timeout', 4);
$gq->setOption('debug', FALSE);
$gq->addFilter('normalise');
$game = $gq->process();
if ( ! $game['server']['gq_online'] )
{
$running = FALSE;
}
}
if( ! $running )
if( $status_name !== "ONLINE" )
{
if (!isset($_GET['retry']))
$retry = 0;
else
$retry = $_GET['retry'];
if ($retry > 3)
if ($status_name === "UNKNOWN")
{
//echo "<p>".get_lang('server_running_not_responding').
// "<a href='?m=gamemanager&amp;p=stop&amp;home_id=$home_id&amp;mod_id=$mod_id&amp;ip=$ip&amp;port=$port' >".
// get_lang('already_running_stop_server').".</a></p>".
//"<table class='center'><tr><td><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=$home_id-$mod_id-$ip-$port'><< ".
$view->refresh("?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=$home_id-$mod_id-$ip-$port");
//get_lang('back')."</a></td></tr></table>";
return;
print_failure(get_lang("agent_offline"));
$view->refresh("?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=$home_id-$mod_id-$ip-$port",3);
return;
}
if ($status_name === "UNRESPONSIVE")
{
$message = isset($agent_status['last_error']) && $agent_status['last_error'] !== "" ? $agent_status['last_error'] : "Server process exists but the game port is not ready.";
print_failure(htmlentities($message));
$view->refresh("?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=$home_id-$mod_id-$ip-$port",5);
return;
}
//echo "</b>Retry #".$retry.".</b>";
echo "<p class='note'>Server status: ".htmlentities($status_name).". Waiting for the game port to become ready.</p>";
$retry++;
print("<p class='note'>".get_lang('starting_server')."</p>");
$view->refresh("?m=gamemanager&amp;p=start&amp;refresh&amp;ip=$ip&amp;port=$port&amp;home_id=$home_id&amp;mod_id=$mod_id&amp;retry=".$retry,3);

View file

@ -99,10 +99,14 @@ function exec_ogp_module() {
$query_port = "10011";
}
$remote_retval = $remote->remote_stop_server($home_id,
$ip, $port, $server_xml->control_protocol,
$home_info['control_password'],$control_type, $home_path);
$db->logger(get_lang_f('server_stopped', $home_info['home_name'] ) . "($ip:$port)");
$remote_retval = $remote->remote_stop_server($home_id,
$ip, $port, $server_xml->control_protocol,
$home_info['control_password'],$control_type, $home_path);
$agent_status = get_agent_server_status($remote, $server_xml, $home_id, $ip, $port, "STOPPING");
if ($remote_retval === 1 && isset($agent_status['status']) && strtoupper($agent_status['status']) !== "OFFLINE") {
$remote_retval = -2;
}
$db->logger(get_lang_f('server_stopped', $home_info['home_name'] ) . "($ip:$port)");
$firewall_settings = $db->getFirewallSettings($home_info['remote_server_id']);
if ( $remote_retval === 1 )
{
@ -137,9 +141,13 @@ function exec_ogp_module() {
}
elseif ( $remote_retval === 0 )
{
$remote_retval = $remote->remote_stop_server($home_info['home_id'],
$ip, $port, $server_xml->control_protocol,"",$control_type,$home_path);
if ($remote_retval === 1 )
$remote_retval = $remote->remote_stop_server($home_info['home_id'],
$ip, $port, $server_xml->control_protocol,"",$control_type,$home_path);
$agent_status = get_agent_server_status($remote, $server_xml, $home_id, $ip, $port, "STOPPING");
if ($remote_retval === 1 && isset($agent_status['status']) && strtoupper($agent_status['status']) !== "OFFLINE") {
$remote_retval = -2;
}
if ($remote_retval === 1 )
{
print_success(get_lang_f("server_stopped",htmlentities($home_info['home_name'])));
if ($firewall_settings['status'] == "enable")
@ -176,8 +184,12 @@ function exec_ogp_module() {
if ( $remote_retval === 0 )
print_failure(get_lang("agent_offline"));
elseif ( $remote_retval !== 1 )
print_failure("Error occurred on the remote host.");
elseif ( $remote_retval !== 1 )
{
$status_name = isset($agent_status['status']) ? strtoupper($agent_status['status']) : "UNKNOWN";
$message = isset($agent_status['last_error']) && $agent_status['last_error'] !== "" ? $agent_status['last_error'] : "Remote stop did not verify that the process/session and game port are stopped.";
print_failure("Error occurred on the remote host. Agent status: ".htmlentities($status_name).". ".htmlentities($message));
}
}
$view->refresh("?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=". $home_id . "-". $mod_id . "-" . $ip . "-" . $port,3);
}

View file

@ -33,23 +33,23 @@ function exec_ogp_module()
list($home_id, $mod_id, $ip, $port) = explode("-", $_GET['home_id-mod_id-ip-port']);
$user_id = $_SESSION['user_id'];
$isAdmin = $db->isAdmin( $user_id );
if($isAdmin)
if($isAdmin)
$home_info = $db->getGameHome($home_id);
else
$home_info = $db->getUserGameHome($user_id,$home_id);
$current_mod_info = $home_info['mods'][$mod_id];
$current_mod_info = $home_info['mods'][$mod_id];
$home_cfg_id = $current_mod_info['home_cfg_id'];
$mod_cfg_id = $current_mod_info['mod_cfg_id'];
if($home_cfg_id === null && $mod_cfg_id === null){
print_failure(get_lang('invalid_game_mod_id'));
return;
}
if ( $home_info === FALSE )
{
print_failure( get_lang("no_access_to_home") );
@ -68,7 +68,7 @@ function exec_ogp_module()
$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_retval = $remote->get_log(OGP_SCREEN_TYPE_HOME,
@ -104,72 +104,50 @@ function exec_ogp_module()
}
}
}
// Using the refreshed class
if( isset($_GET['refreshed']) )
{
echo "<pre class='log'>".htmlentities($home_log)."</pre>";
}
else
{
echo "<h2>".htmlentities($home_info['home_name'])."</h2>";
if($log_retval == 1)
// Using the refreshed class
if( isset($_GET['refreshed']) )
{
require_once("includes/refreshed.php");
$control = '<form method="GET" >
<input type="hidden" name="m" value="gamemanager" />
<input type="hidden" name="p" value="log" />
<input type="hidden" name="home_id-mod_id-ip-port" value="'.$_GET['home_id-mod_id-ip-port'].'" />';
if(isset($_GET['setInterval']))
$control .= "<input type='hidden' name='setInterval' value='" . $_GET['setInterval'] . "' />";
if(isset($_GET['view_player_commands']))
$control .= "<input type='hidden' name='view_player_commands' value='" . $_GET['view_player_commands'] . "' />";
$control .= '<input type="submit" name="size" value="';
if( isset( $_GET['size'] ) and $_GET['size'] == "+" )
{
$height = "100%";
$control .= '-';
}
else
{
$height = "500px";
$control .= '+';
if (!headers_sent()) {
header('Content-Type: text/plain; charset=UTF-8');
}
$control .= '" /></form>';
$intervals = array( "4s" => "4000",
"8s" => "8000",
"30s" => "30000",
"2m" => "120000",
"5m" => "300000" );
$intSel = '<form action="" method="GET" >
<input type="hidden" name="m" value="gamemanager" />
<input type="hidden" name="p" value="log" />
<input type="hidden" name="home_id-mod_id-ip-port" value="'.$_GET['home_id-mod_id-ip-port'].'" />';
if(isset($_GET['size']))
$intSel .= "<input type='hidden' name='size' value='" . $_GET['size'] . "' />";
if(isset($_GET['view_player_commands']))
$intSel .= "<input type='hidden' name='view_player_commands' value='" . $_GET['view_player_commands'] . "' />";
$intSel .= get_lang("refresh_interval") . ':<select name="setInterval" onchange="this.form.submit();">';
foreach ((array)$intervals as $interval => $value )
echo $home_log;
return;
}
else
{
echo "<h2>".htmlentities($home_info['home_name'])."</h2>";
if($log_retval == 1)
{
$selected = "";
if ( isset( $_GET['setInterval'] ) AND $_GET['setInterval'] == $value )
$selected = 'selected="selected"';
$intSel .= '<option value="'.$value.'" '.$selected.' >'.$interval.'</option>';
}
$intSel .= "</select></form>";
$setInterval = isset($_GET['setInterval']) ? $_GET['setInterval'] : 4000;
$refresh = new refreshed();
$pos = $refresh->add("home.php?m=gamemanager&p=log&type=cleared&refreshed&home_id-mod_id-ip-port=". $_GET['home_id-mod_id-ip-port']);
echo $refresh->getdiv($pos,"height:".$height.";overflow:auto;max-width:1600px;");
?><script type="text/javascript">$(document).ready(function(){ <?php echo $refresh->build("$setInterval"); ?>} ); </script><?php
echo "<table class='center' ><tr><td>$intSel</td><td>$control</td></tr></table>";
if( ($server_xml->control_protocol and preg_match("/^r?l?con2?$/", $server_xml->control_protocol)) OR
($server_xml->gameq_query_name and $server_xml->gameq_query_name == "minecraft") OR
$log_url = "home.php?m=gamemanager&p=log&type=cleared&refreshed&home_id-mod_id-ip-port=".rawurlencode($_GET['home_id-mod_id-ip-port']);
echo '<textarea id="live-server-log" class="log" readonly="readonly" style="height:500px;overflow:auto;max-width:1600px;width:100%;box-sizing:border-box;">'.htmlentities($home_log, ENT_QUOTES, "UTF-8").'</textarea>';
?>
<script type="text/javascript">
(function(){
var logBox = document.getElementById('live-server-log');
if (!logBox) return;
function isAtBottom() {
return (logBox.scrollTop + logBox.clientHeight) >= (logBox.scrollHeight - 24);
}
function refreshLog() {
var shouldScroll = isAtBottom();
fetch('<?php echo $log_url; ?>', {cache: 'no-store'})
.then(function(response){ return response.text(); })
.then(function(text){
logBox.value = text;
if (shouldScroll) {
logBox.scrollTop = logBox.scrollHeight;
}
})
.catch(function(){});
}
logBox.scrollTop = logBox.scrollHeight;
window.setInterval(refreshLog, 4000);
})();
</script>
<?php
if( ($server_xml->control_protocol and preg_match("/^r?l?con2?$/", $server_xml->control_protocol)) OR
($server_xml->gameq_query_name and $server_xml->gameq_query_name == "minecraft") OR
($server_xml->lgsl_query_name and $server_xml->lgsl_query_name == "7dtd") )
require('modules/gamemanager/rcon.php');
}