📂 File Browser

/serversdashboard/serversdashboard/api
🌙 Dark Mode
🎯 Quick Launch:

📁 Directories

📄 Files

🐘 clientid.php
▶ Open 📄 View Source
🐘 command.php
▶ Open 📄 View Source
🐘 console.php
▶ Open 📄 View Source
🐘 disable.php
▶ Open 📄 View Source
🐘 enable.php
▶ Open 📄 View Source
🐘 inventory.php
▶ Open 📄 View Source
🐘 login.php
▶ Open 📄 View Source
🐘 logout.php
▶ Open 📄 View Source
🐘 players.php
▶ Open 📄 View Source
🐘 restart.php
▶ Open 📄 View Source
🐘 start.php
▶ Open 📄 View Source
🐘 status.php
▶ Open 📄 View Source
🐘 stop.php
▶ Open 📄 View Source
🐘 users.php
▶ Open 📄 View Source
🐘 whoami.php
▶ Open 📄 View Source

📄 Source: command.php

<?php
require_once __DIR__ . '/../auth.php';
require_once __DIR__ . '/../lib/tmux.php';
require_once __DIR__ . '/../lib/servers.php';
require_auth_json();

$CFG = $GLOBALS['__CFG'];
$name = $_POST['server'] ?? '';
$cmd  = $_POST['command'] ?? '';

if ($name === '' || strpos($name, '/') !== false || strpos($name, '..') !== false) {
    http_response_code(400);
    echo json_encode(['ok' => false, 'error' => 'Invalid server name']);
    exit;
}
if ($cmd === '') {
    http_response_code(400);
    echo json_encode(['ok' => false, 'error' => 'Empty command']);
    exit;
}

$session = tmux_session_name($CFG['tmux_template'] ?? '%s', $name);
if (!tmux_has_session($session)) {
    header('Content-Type: application/json');
    echo json_encode(['ok' => false, 'error' => 'Server not running (no tmux session)']);
    exit;
}

$ok = tmux_send_command($session, $cmd);
header('Content-Type: application/json');
echo json_encode(['ok' => $ok, 'message' => $ok ? 'Sent' : 'Failed to send']);
← Back