diff --git a/Panel/modules/gamemanager/ajax_log.php b/Panel/modules/gamemanager/ajax_log.php new file mode 100644 index 00000000..932dcd9b --- /dev/null +++ b/Panel/modules/gamemanager/ajax_log.php @@ -0,0 +1,113 @@ +isAdmin($user_id); +$home_info = $isAdmin ? $db->getGameHome($home_id) : $db->getUserGameHome($user_id, $home_id); +if ($home_info === FALSE) { + http_response_code(403); + exit; +} + +if ($ip !== '' && $port > 0) { + $hasMatchingIpPort = false; + foreach ((array)$home_info['ipports'] as $home_ip_port) { + if (isset($home_ip_port['ip']) && isset($home_ip_port['port']) && $home_ip_port['ip'] == $ip && (int)$home_ip_port['port'] == $port) { + $hasMatchingIpPort = true; + break; + } + } + if (!$hasMatchingIpPort) { + http_response_code(403); + exit; + } +} + +$server_xml = read_server_config(SERVER_CONFIG_LOCATION . "/" . $home_info['home_cfg_file']); +if (!$server_xml) { + http_response_code(404); + exit; +} + +$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, + $home_info['home_id'], + clean_path($home_info['home_path']), + $home_log, + 100, + (string)$server_xml->console_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 + ); +} + +if ($log_retval == 1 || $log_retval == 2) { + if (hasValue($home_log) && !mb_check_encoding($home_log, 'UTF-8')) { + if (function_exists('mb_convert_encoding')) { + $home_log = mb_convert_encoding($home_log, 'UTF-8', 'ISO-8859-1'); + } elseif (function_exists('iconv')) { + $converted_log = iconv('ISO-8859-1', 'UTF-8//IGNORE', $home_log); + if ($converted_log !== false) { + $home_log = $converted_log; + } + } + } + echo $home_log; + exit; +} + +http_response_code(204); +exit; diff --git a/Panel/modules/gamemanager/log.php b/Panel/modules/gamemanager/log.php index b41b0d04..28a74050 100644 --- a/Panel/modules/gamemanager/log.php +++ b/Panel/modules/gamemanager/log.php @@ -73,81 +73,143 @@ $home_log = utf8_encode($home_log); } - // Using the refreshed class - if( isset($_GET['refreshed']) ) + echo "
".htmlentities($home_log).""; - } - else - { - echo "
" . htmlentities($home_log) . ""; - print_failure( get_lang("server_not_running") ); + $height = "500px"; + $size_control = "+"; } - echo create_back_button( $_GET['m'], 'game_monitor&home_id-mod_id-ip-port='.$_GET['home_id-mod_id-ip-port'] ); + + $intervals = array( "1s" => "1000", + "2s" => "2000", + "4s" => "4000", + "8s" => "8000", + "30s" => "30000", + "2m" => "120000", + "5m" => "300000" ); + $allowed_intervals = array_map('intval', array_values($intervals)); + $minimum_interval = (int)min($allowed_intervals); + $setInterval = isset($_GET['setInterval']) ? (int)$_GET['setInterval'] : 4000; + if( !in_array($setInterval, $allowed_intervals, true) ) + { + $setInterval = 4000; + } + + $intSel = get_lang("refresh_interval") . ':"; + + $ajax_home_id = isset($home_id) ? (int)$home_id : 0; + $ajax_mod_id = isset($mod_id) ? (int)$mod_id : 0; + $ajax_ip = isset($ip) ? rawurlencode($ip) : ""; + $ajax_port = isset($port) ? rawurlencode($port) : ""; + $ajax_log_url = "modules/gamemanager/ajax_log.php?home_id=".$ajax_home_id."&mod_id=".$ajax_mod_id."&ip=".$ajax_ip."&port=".$ajax_port; + + $is_collapsed = $height == "500px" ? "1" : "0"; + echo "
| $intSel |
".htmlentities($home_log).""; + ?> + + 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'); + } + else + { + echo "
" . htmlentities($home_log) . ""; + print_failure( get_lang("server_not_running") ); } + echo create_back_button( $_GET['m'], 'game_monitor&home_id-mod_id-ip-port='.$_GET['home_id-mod_id-ip-port'] ); } else {