示例#1
0
function minecraftCommand($service_id, $command)
{
    if (strlen($command > 1000)) {
        return "Error: the entered command is too long!";
    }
    //get the configuration
    $configuration = minecraftGetConfiguration($service_id, false);
    if (isset($configuration['rcon.password']) && isset($configuration['rcon.port'])) {
        $hostname = "localhost";
        if (!empty($configuration['server-ip'])) {
            $hostname = $configuration['server-ip'];
        }
        require_once includePath() . "/rcon.php";
        try {
            $rcon = new RCon($hostname, $configuration['rcon.port'], $configuration['rcon.password']);
        } catch (Exception $e) {
            return "Error: {$e}";
        }
        if ($rcon->Auth()) {
            //allow execution of multiple commands
            if (is_array($command)) {
                foreach ($command as $str) {
                    $rcon->rconCommand($command);
                }
            } else {
                $rcon->rconCommand($command);
            }
            return true;
        } else {
            return "Error: failed to connect and authenticate with Minecraft server (is it online?).";
        }
    } else {
        return "Error: could not find rcon port and password to use.";
    }
}
示例#2
0
<?php

include "../include/common.php";
include "../config.php";
include "../include/session.php";
include "../include/dbconnect.php";
include "../include/account.php";
include "../include/minecraft.php";
if (isset($_SESSION['account_id']) && isset($_REQUEST['id']) && is_numeric($_REQUEST['id']) && isset($_SESSION['is_' . $_REQUEST['id'] . '_minecraft'])) {
    if (isset($_POST['action']) && $_POST['action'] == "update") {
        //create array of configurations we are updating
        $array = minecraftGetConfigFromRequest($minecraftParameters, $_REQUEST);
        minecraftReconfigure($_REQUEST['id'], $array);
        if (!isset($_SESSION['noredirect'])) {
            header("Location: config_main.php?id=" . $_REQUEST['id']);
            return;
        }
    }
    $mconfig = minecraftGetConfiguration($_REQUEST['id']);
    get_page("config_main", "minecraft", array('service_id' => $_REQUEST['id'], 'mconfig' => $mconfig, 'parameters' => $minecraftParameters));
} else {
    header("Location: ../panel/");
}