From 662582823d5a0d9e1949766f0cd6c71e480353a9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 5 Sep 2025 22:00:17 +0000 Subject: [PATCH] Add last startup command display feature Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com> --- includes/database_mysqli.php | 30 ++++++++++++++++++++++++++ lang/English/modules/gamemanager.php | 1 + modules/gamemanager/mini_start.php | 2 ++ modules/gamemanager/module.php | 8 +++++-- modules/gamemanager/server_monitor.php | 9 +++++++- 5 files changed, 47 insertions(+), 3 deletions(-) diff --git a/includes/database_mysqli.php b/includes/database_mysqli.php index 5dc71c49..c2e13114 100644 --- a/includes/database_mysqli.php +++ b/includes/database_mysqli.php @@ -3170,6 +3170,36 @@ class OGPDatabaseMySQL extends OGPDatabase return $result['last_param']; } + public function changeLastStartupCmd($home_id, $command) { + $query = sprintf("UPDATE `%sserver_homes` SET `last_startup_cmd` = '%s' WHERE `home_id` = %d", + $this->table_prefix, + $this->realEscapeSingle($command), + $this->realEscapeSingle($home_id)); + ++$this->queries_; + if ( mysqli_query($this->link,$query) === FALSE ) + return FALSE; + + return TRUE; + } + + public function getLastStartupCmd($home_id) { + if ( !$this->link ) return FALSE; + + $query = sprintf("SELECT `last_startup_cmd` FROM `%sserver_homes` WHERE `home_id` = %d", + $this->table_prefix, + $this->realEscapeSingle($home_id)); + + ++$this->queries_; + $result = mysqli_query($this->link,$query); + + if ( mysqli_num_rows($result) != 1 ) + return FALSE; + + $result = mysqli_fetch_assoc( $result ); + + return $result['last_startup_cmd']; + } + public function saveServerStatusCache($ip_id,$port,$status) { $query = sprintf("SELECT * FROM `%sstatus_cache` WHERE `ip_id` = %s AND `port` = %s;", $this->table_prefix, diff --git a/lang/English/modules/gamemanager.php b/lang/English/modules/gamemanager.php index 3b66f4c5..008d0c07 100644 --- a/lang/English/modules/gamemanager.php +++ b/lang/English/modules/gamemanager.php @@ -207,5 +207,6 @@ define('OGP_LANG_phan', "Phantom"); define('OGP_LANG_sec', "Seconds"); define('OGP_LANG_unknown_rsync_mirror', "You attempted to start an update from a mirror which doesn't exist."); define('OGP_LANG_custom_fields', "Server Settings"); +define('OGP_LANG_last_startup_command', "Last Startup Command"); ?> diff --git a/modules/gamemanager/mini_start.php b/modules/gamemanager/mini_start.php index f6c26768..7864ee15 100644 --- a/modules/gamemanager/mini_start.php +++ b/modules/gamemanager/mini_start.php @@ -582,6 +582,8 @@ elseif($server_home['home_id'] == $_POST['home_id']) } //Save the param used to the database $db->changeLastParam($server_home['home_id'],json_encode($save_param)); + //Save the startup command to the database + $db->changeLastStartupCmd($server_home['home_id'], $start_cmd); echo ""; echo "
". get_lang("ogp_agent_ip") . diff --git a/modules/gamemanager/module.php b/modules/gamemanager/module.php index 376a43b0..7256e893 100644 --- a/modules/gamemanager/module.php +++ b/modules/gamemanager/module.php @@ -24,8 +24,8 @@ // Module general information $module_title = "Game manager"; -$module_version = "1.33"; -$db_version = 9; +$module_version = "1.34"; +$db_version = 10; $module_required = TRUE; $module_menus = array( array( 'subpage' => 'game_monitor', 'name'=>'Game Monitor', 'group'=>'user' ) ); $module_access_rights = array('u' => 'allow_updates', 'p' => 'allow_parameter_usage', 'e' => 'allow_extra_params', 'c' => 'allow_custom_fields'); @@ -117,4 +117,8 @@ $install_queries[9] = array( "ALTER TABLE `".OGP_DB_PREFIX."server_homes` MODIFY COLUMN `home_name` VARCHAR(500);", "ALTER TABLE `".OGP_DB_PREFIX."server_homes` MODIFY COLUMN `control_password` VARCHAR(128);", "ALTER TABLE `".OGP_DB_PREFIX."server_homes` MODIFY COLUMN `ftp_password` VARCHAR(128);"); + +// Add field to store last startup command +$install_queries[10] = array( + "ALTER TABLE `".OGP_DB_PREFIX."server_homes` ADD `last_startup_cmd` LONGTEXT NULL;"); ?> diff --git a/modules/gamemanager/server_monitor.php b/modules/gamemanager/server_monitor.php index 2c6af740..3ee3fa6a 100644 --- a/modules/gamemanager/server_monitor.php +++ b/modules/gamemanager/server_monitor.php @@ -436,6 +436,13 @@ echo "
" . htmlentities($last_startup_cmd) . ""; + } + //End $remote = new OGPRemoteLibrary($server_home['agent_ip'], $server_home['agent_port'], $server_home['encryption_key'], $server_home['timeout']); @@ -555,7 +562,7 @@ echo "
"; - @$second .= ""; + @$second .= ""; $second .= ""; if( $server_xml->protocol != "teamspeak3" OR ($startup_file_exists and $server_xml->protocol == "teamspeak3") OR ($status == "offline" and $server_xml->protocol == "teamspeak3") )
" . $refresh->getdiv($pos,"width:100%;") . "$offlineT" . $refresh->getdiv($pos,"width:100%;") . "$offlineT" . $startup_cmd_display . "$other_owners$groupsus