Skip to main content
The plugin system in GamePanelX V3 allows you to extend the control panel’s functionality by hooking into predefined action points throughout the interface. Plugins can add custom content, modify behavior, and integrate third-party services.

Plugin Structure

Each plugin requires a specific directory structure within the plugins/ folder:
plugins/
└── my_plugin_name/
    ├── my_plugin_name.php    # Main plugin file
    └── plugin.json.txt       # Plugin metadata

Plugin Metadata

The plugin.json.txt file contains basic information about your plugin:
{
    "name": "My Plugin Name",
    "intname": "my_plugin_name",
    "description": "This plugin adds custom functionality to GamePanelX"
}
The intname must match the directory name and the main PHP file name.

Creating a Plugin

1

Create plugin directory

Create a new directory in plugins/ with your plugin’s internal name:
mkdir plugins/my_custom_plugin
2

Create metadata file

Create plugin.json.txt with your plugin information:
{
    "name": "My Custom Plugin",
    "intname": "my_custom_plugin",
    "description": "Adds custom features to the home page"
}
3

Create main plugin file

Create my_custom_plugin.php with your plugin code:
<?php
// Define your function
function my_custom_function()
{
    echo "Custom content displayed on the home page!";
}

// Hook into an action point
$this->set_action('home_top', 'my_custom_function');
?>
4

Activate plugin

Enable your plugin through the GamePanelX admin interface under Settings > Plugins.

Action Hooks

GamePanelX provides multiple action points where plugins can inject content:

Available Actions

Action NameLocationDescription
index_initPage initializationRuns before any page content
index_headHTML head sectionAdd CSS/JavaScript to <head>
index_bodyBody tagModify body tag or add content after opening
index_body_endBefore closing bodyAdd content before </body>
index_endPage endRuns after all page content
home_topHome page topContent above server icons
home_bottomHome page bottomContent below server icons
settings_topSettings page topAbove settings form
settings_tableSettings tableInside settings table
games_topGames page topAbove games list
games_tableGames tableInside games table
games_bottomGames page bottomBelow games list
servers_topServers page topAbove servers list
servers_tableServers tableInside servers table
servers_bottomServers page bottomBelow servers list
users_topUsers page topAbove users list
users_tableUsers tableInside users table
users_bottomUsers page bottomBelow users list

Plugin API

set_action()

Register a function to run at a specific action point.
$this->set_action(string $action_name, string $function_name);
Parameters:
  • $action_name - The action hook to attach to
  • $function_name - The name of your function to execute
Example:
function display_welcome_message()
{
    echo '<div class="welcome">Welcome to our game server panel!</div>';
}

$this->set_action('home_top', 'display_welcome_message');

Example Plugins

Home Page Banner

Display a custom banner on the home page:
<?php
function custom_banner()
{
    echo '<div style="padding: 10px; background: #f0f0f0; margin: 10px 0;">';
    echo '<h3>Server Status</h3>';
    echo '<p>All systems operational!</p>';
    echo '</div>';
}

$this->set_action('home_top', 'custom_banner');
?>

Custom CSS Injection

Add custom styles to all pages:
<?php
function inject_custom_css()
{
    echo '<style>';
    echo '.custom-highlight { background-color: #ffffcc; }';
    echo '.important-notice { color: red; font-weight: bold; }';
    echo '</style>';
}

$this->set_action('index_head', 'inject_custom_css');
?>

Server Statistics Widget

Display custom server statistics:
<?php
function server_stats_widget()
{
    // Query your database or external API
    $total_servers = 25;
    $online_servers = 18;
    
    echo '<div class="stats-widget">';
    echo '<h4>Server Statistics</h4>';
    echo '<p>Total Servers: ' . $total_servers . '</p>';
    echo '<p>Online: ' . $online_servers . '</p>';
    echo '</div>';
}

$this->set_action('home_bottom', 'server_stats_widget');
?>

User Login Logger

Log user logins (runs on every page):
<?php
function log_user_activity()
{
    if (isset($_SESSION['gpx_username'])) {
        $username = $_SESSION['gpx_username'];
        $timestamp = date('Y-m-d H:i:s');
        
        // Log to file or database
        error_log("User $username active at $timestamp");
    }
}

$this->set_action('index_init', 'log_user_activity');
?>

Best Practices

For plugins with complex HTML or database queries:
function complex_plugin_output()
{
    ob_start();
    
    // Your complex code here
    $data = fetch_some_data();
    ?>
    <div class="custom-content">
        <?php foreach($data as $item): ?>
            <p><?php echo $item; ?></p>
        <?php endforeach; ?>
    </div>
    <?php
    
    return ob_get_clean();
}
Always validate data and handle potential errors:
function safe_plugin_function()
{
    try {
        // Your plugin code
        if (!function_exists('required_function')) {
            throw new Exception('Required function not available');
        }
        
        // Process data
        echo 'Plugin content';
        
    } catch (Exception $e) {
        if (GPXDEBUG) {
            echo 'Plugin Error: ' . $e->getMessage();
        }
    }
}
Don’t use echo statements outside of functions:
<?php
// ❌ WRONG - This will not be displayed
echo "This is stray output that won't appear!";

// ✅ CORRECT - Use functions
function my_output()
{
    echo "This output will be displayed correctly!";
}

$this->set_action('home_top', 'my_output');
?>
Prefix your functions to avoid conflicts:
// ✅ Good - Prefixed with plugin name
function myplugin_display_header() { }
function myplugin_get_data() { }

// ❌ Bad - Generic names may conflict
function display_header() { }
function get_data() { }

Debugging Plugins

Enable debug mode in configuration.php to see plugin execution details:
define('GPXDEBUG', true);
When enabled, GamePanelX will display:
  • Which actions are being executed
  • Which functions are being called
  • Any plugin errors or missing files
Check the plugin execution by viewing the page source. Debug messages will appear as HTML comments when GPXDEBUG is enabled.

Security Considerations

Plugins have full access to the GamePanelX environment. Only install plugins from trusted sources.
  • Always sanitize user input: strip_tags(), htmlspecialchars()
  • Validate data before database queries
  • Use prepared statements for SQL queries
  • Never output sensitive information (passwords, API keys)
  • Restrict file system access to necessary directories only

Plugin Lifecycle

  1. Page Load - User accesses a GamePanelX page
  2. Plugin Setup - setup_actions() includes all active plugin files
  3. Registration - Plugins call set_action() to register their functions
  4. Execution - When do_action() is called, registered functions execute
  5. Output - Plugin output is displayed at the appropriate location

Troubleshooting

  • Verify directory and file names match exactly
  • Check that plugin.json.txt exists and is valid JSON
  • Ensure plugin is activated in admin settings
  • Verify function names don’t conflict with PHP reserved words
  • Make sure you’re using set_action() correctly
  • Verify the action hook name is valid
  • Check that your function uses echo to output content
  • Enable GPXDEBUG to see execution details
  • Check PHP error logs for syntax errors
  • Verify all required functions and classes exist
  • Ensure proper PHP tags (<?php and ?>)
  • Validate that sessions are available if accessing $_SESSION

Advanced Usage

Accessing GamePanelX Classes

Plugins can interact with GamePanelX core classes:
<?php
function advanced_server_plugin()
{
    // Include necessary classes
    require_once(DOCROOT . '/includes/classes/servers.php');
    
    $Servers = new Servers();
    $server_list = $Servers->getall();
    
    echo '<div class="server-count">';
    echo 'Total Servers: ' . count($server_list);
    echo '</div>';
}

$this->set_action('home_top', 'advanced_server_plugin');
?>

Multiple Action Hooks

A single plugin can use multiple hooks:
<?php
function add_css() {
    echo '<style>.custom { color: blue; }</style>';
}

function add_header() {
    echo '<h2>Custom Header</h2>';
}

function add_footer() {
    echo '<p>Custom Footer</p>';
}

$this->set_action('index_head', 'add_css');
$this->set_action('home_top', 'add_header');
$this->set_action('home_bottom', 'add_footer');
?>

Build docs developers (and LLMs) love