Esempio n. 1
0
function minecraftGetStatus($service_id)
{
    global $config;
    //get the identifier
    $id = stripAlphaNumeric(getServiceParam($service_id, "id"));
    if ($id === false) {
        return array('status' => "ERROR: failed to find bot identifier", 'err' => array(), 'color' => 'red');
    }
    //read last lines of the log file and scan for interesting things
    $lines = minecraftGetLog($service_id, 1000);
    if (empty($lines)) {
        return array('status' => "Failed to read log file", 'err' => array(), 'color' => 'red');
    }
    $lastline = $lines[count($lines) - 1];
    $errors = array();
    $status = "Up, no activity";
    $color = "orange";
    //scan lines for interesting things
    foreach ($lines as $line) {
        # check if user has joined game recently
        if (strpos($line, 'joined') !== false) {
            $status = "Good";
            $color = "green";
        }
    }
    # check last line to see if the bot is still running
    $firstSpace = strpos($lastline, ' ');
    if ($firstSpace !== false) {
        $secondSpace = strpos($lastline, ' ', $firstSpace + 1);
        if ($secondSpace !== false) {
            $strTime = substr($lastline, 0, $secondSpace);
            $time = strtotime($strTime . " UTC");
            if (time() - $time > 1200) {
                $status = "Down";
                $errors[] = "Does not appear to be running!";
                $color = "red";
            }
        }
    }
    return array('status' => $status, 'err' => $errors, 'color' => $color);
}
Esempio n. 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'])) {
    $message = "";
    if (isset($_POST['command'])) {
        $result = minecraftCommand($_REQUEST['id'], $_POST['command']);
        if ($result !== true) {
            $message = $result;
        } else {
            $message = "Command sent successfully!";
        }
    }
    $log = minecraftGetLog($_REQUEST['id']);
    get_page("log", "minecraft", array('service_id' => $_REQUEST['id'], 'log' => $log, 'message' => $message));
} else {
    header("Location: ../panel/");
}