Example #1
0
<?php

//file_put_contents('log.txt',print_r($_GET,true),FILE_APPEND);
$bcv_hosts = array();
$bcv_hosts[@gethostbyname('wos.lv')] = 'wos';
$bcv_hosts[@gethostbyname('direct.8d.lv')] = '8d';
if (in_array($_SERVER['REMOTE_ADDR'], array_keys($bcv_hosts))) {
    if (isset($_GET['user']) and !empty($_GET['user'])) {
        $target = $bcv_hosts[$_SERVER['REMOTE_ADDR']];
        $username = $_GET['user'];
        if (!defined('IN_APP')) {
            define('IN_APP', 1);
            include './includes/boot.php';
            include ROOT . '/includes/config.php';
        }
        try {
            $Rcon = new MinecraftRcon();
            $Rcon->Connect($config['rcon.ip'], $config['rcon.port'], $config['rcon.password'], 15);
        } catch (MinecraftRconException $e) {
            $rcon_connection_failed = true;
        }
        if (!isset($credits)) {
            $credits = $config['links'][$target]['credits'];
        }
        include ROOT . '/includes/bonus.php';
    }
}
<?php

define('MQ_SERVER_ADDR', 'localhost');
define('MQ_SERVER_PORT', 25575);
define('MQ_SERVER_PASS', 'lolrcontest');
define('MQ_TIMEOUT', 2);
require __DIR__ . '/MinecraftRcon.class.php';
echo "<pre>";
try {
    $Rcon = new MinecraftRcon();
    $Rcon->Connect(MQ_SERVER_ADDR, MQ_SERVER_PORT, MQ_SERVER_PASS, MQ_TIMEOUT);
    $Data = $Rcon->Command("say Hello from xPaw's minecraft rcon implementation.");
    if ($Data === false) {
        throw new MinecraftRconException("Failed to get command result.");
    } else {
        if (StrLen($Data) == 0) {
            throw new MinecraftRconException("Got command result, but it's empty.");
        }
    }
    echo HTMLSpecialChars($Data);
} catch (MinecraftRconException $e) {
    echo $e->getMessage();
}
$Rcon->Disconnect();
Example #3
0
    $rcon_port = (int) sqlConfigGet('rcon-port');
}
$rcon_pass = Filter::input('pass');
if (empty($rcon_pass)) {
    $rcon_pass = sqlConfigGet('rcon-pass');
}
/* Sync or drop config */
if (Filter::input('save', 'post', 'bool')) {
    sqlConfigSet('rcon-serv', $game_server);
    sqlConfigSet('rcon-pass', $rcon_pass);
    sqlConfigSet('rcon-port', $rcon_port);
} else {
    sqlConfigSet('rcon-serv', 0);
}
try {
    $rcon = new MinecraftRcon();
    $rcon->Connect($game_server, $rcon_port, $rcon_pass);
    if ($userlist) {
        $page = GetUserListHTML($rcon->Command('list'));
        exit("<script>'.{$token}.'parent.GetById('users_online').innerHTML = '" . $page[0] . "'; " . $page[1] . "</script>");
    }
    $command = str_replace(array("\r\n", "\n", "\r"), '', $command);
    $command = preg_replace('| +|', ' ', $command);
    $str = trim(TextBase::HTMLDestruct($rcon->Command($command)));
    $str = str_replace(array("\r\n", "\n", "\r"), '', $str);
    if (!strncmp($command, 'say', 3) and strlen($str) > 2) {
        $str = substr($str, 2);
    }
    if (!strncmp(substr($str, 2), 'Usage', 5)) {
        $str = substr($str, 2);
    }
Example #4
0
 public function UpdateState($extra = false)
 {
     global $config;
     if (!$extra and !$this->IsTimeToUpdate() or !$this->Exist()) {
         return;
     }
     $this->online = false;
     $users_list = NULL;
     if (empty($this->address)) {
         getDB()->ask("UPDATE `" . $this->db . "` SET `online`='0',`last_update`=NOW() WHERE `id`='" . $this->id . "'");
         return;
     }
     getDB()->ask("UPDATE `" . $this->db . "` SET `last_update`=NOW() WHERE `id`='" . $this->id . "'");
     switch ($this->method) {
         case 2:
             // RCON Connect
             loadTool('rcon.class.php');
             try {
                 $rcon = new MinecraftRcon();
                 $rcon->Connect($this->address, $this->port, $this->rcon);
                 $str = $rcon->Command('list');
             } catch (MinecraftRconException $e) {
                 if ($e->getMessage() == 'Server offline') {
                     getDB()->ask("UPDATE `" . $this->db . "` SET `online`='0' WHERE `id`='" . $this->id . "'");
                     return;
                 }
             }
             $str = str_replace(array("\r\n", "\n", "\r"), '', $str);
             $names = explode(', ', substr($str, 19));
             if (!empty($names)) {
                 for ($i = 0; $i < sizeof($names); $i++) {
                     trim($names[$i]);
                 }
             }
             if (!$names[0] == '') {
                 $users_list = $names;
             }
             break;
         case 3:
             // json-api
             loadTool('json_api.php', 'bukkit/');
             $salt = sqlConfigGet('json-verification-salt');
             if (!$salt) {
                 $salt = md5(rand(1000000000, 2147483647) . rand(1000000000, 2147483647));
                 sqlConfigSet('json-verification-salt', $salt);
             }
             if (!extension_loaded("cURL")) {
                 vtxtlog('[monitoring.class.php] cURL module is required');
                 return;
             }
             $api = new JSONAPI($this->address, $this->port, $this->s_user, $this->rcon, $salt);
             // ToDo rewrite / delete . curl is custom module
             $apiresult = $api->call(array("getPlayerLimit", "getPlayerCount"), array(NULL, NULL));
             if (!$apiresult) {
                 getDB()->ask("UPDATE `" . $this->db . "` SET `online`='0' WHERE `id`='" . $this->id . "'");
                 return;
             }
             $full_state = array('numpl' => $apiresult["success"][1]["success"], 'maxplayers' => $apiresult["success"][0]["success"]);
             break;
         default:
             // query, simple query
             loadTool('query.function.php');
             $full_state = $this->method == 1 ? mcraftQuery($this->address, $this->port) : mcraftQuery_SE($this->address, $this->port);
             if (empty($full_state) or isset($full_state['too_many'])) {
                 getDB()->ask("UPDATE `" . $this->db . "` " . "SET `online`='" . (isset($full_state['too_many']) ? '1' : '0') . "' " . "WHERE `id`='" . $this->id . "'");
                 $this->online = isset($full_state['too_many']) ? true : false;
                 return;
             } elseif (!empty($full_state['players'])) {
                 $users_list = $full_state['players'];
             }
             break;
     }
     $this->online = true;
     $system_users = '';
     $numpl = !empty($full_state['numpl']) ? $full_state['numpl'] : 0;
     if ($users_list) {
         $numpl = sizeof($users_list);
         if ($numpl == 1) {
             $system_users = $users_list[0];
         } else {
             for ($i = 0; $i < $numpl; $i++) {
                 $system_users .= $i == 0 ? $users_list[$i] : ',' . $users_list[$i];
             }
         }
     }
     $this->slots = !empty($full_state) ? $full_state['maxplayers'] : -1;
     $this->numpl = $numpl;
     if (!empty($full_state)) {
         $sql = "UPDATE `" . $this->db . "` SET `numpl`=:numpl, slots=:slots, players=:players, online='1' " . "WHERE `id`='" . $this->id . "'";
         getDB()->ask($sql, array('numpl' => $this->numpl, 'slots' => $this->slots, 'players' => $system_users));
     } else {
         $sql = "UPDATE `" . $this->db . "` SET `numpl`=:numpl, slots='-1', players=:players, online='1' " . "WHERE `id`='{$this->id}'";
         getDB()->ask($sql, array('numpl' => $this->numpl, 'players' => $system_users));
     }
 }
Example #5
0
	</form>
  </td>
 </tr>
</table>
<?php 
if (isset($_POST['remote_send_rcon_command'])) {
    $rconCommand = $_POST['rcon_command'];
    if (isset($server_xml->control_protocol_type)) {
        $control_type = $server_xml->control_protocol_type;
    } else {
        $control_type = "";
    }
    if (isset($server_xml->gameq_query_name) and $server_xml->gameq_query_name == "minecraft" and !isset($server_xml->control_protocol)) {
        include_once "MinecraftRcon.class.php";
        $rcon_port = $port + 10;
        $rcon = new MinecraftRcon();
        if ($rcon->Connect($ip, $rcon_port, $home_info['control_password'])) {
            $return = $rcon->Command($rconCommand);
            if ($return) {
            }
            echo "<div class='bloc' ><h4>" . get_lang('rcon_command_title') . ": [" . $rconCommand . "] " . get_lang('has_sent_to') . " " . $home_info['home_name'] . "</h4><xmp style='overflow:scroll;' >{$return}</xmp></div>";
            $rcon->Disconnect();
        } else {
            echo "" . get_lang('need_set_remote_pass') . " " . $home_info['home_name'] . " " . get_lang('before_sending_rcon_com') . "<br>";
        }
    } elseif (isset($server_xml->lgsl_query_name) and $server_xml->lgsl_query_name == "7dtd") {
        $query_port = $port + 1;
        $return = $remote->exec('exec 3<>/dev/tcp/' . $ip . '/' . $query_port . ' && echo -en "' . $rconCommand . '\\nexit\\n" >&3 && cat <&3');
        if (preg_match("/Connected with 7DTD server/", $return)) {
            echo "<div class='bloc' ><h4>" . get_lang('rcon_command_title') . ": [" . $rconCommand . "] " . get_lang('has_sent_to') . " " . $home_info['home_name'] . "</h4><xmp style='overflow:scroll;' >{$return}</xmp></div>";
        }
     query_basic("UPDATE `voucher` SET `amount`='" . $amount . "' WHERE `id` = '" . $voucher['id'] . "'");
 } else {
     notifications('Ten kod jest błędny lub został już wykorzystany!', 'danger');
     unset($error);
     header("Location: product.php?id=" . $id . "&payment=" . $payment . "");
     die;
 }
 ###
 define('MQ_SERVER_ADDR', $config['ip']);
 define('MQ_SERVER_PORT', $config['port_rcon']);
 define('MQ_SERVER_PASS', $config['password_rcon']);
 define('MQ_TIMEOUT', 2);
 ###
 include INCLUDES_DIR . "rcon.php";
 ###
 $Rcon = new MinecraftRcon();
 $Rcon->Connect(MQ_SERVER_ADDR, MQ_SERVER_PORT, MQ_SERVER_PASS, MQ_TIMEOUT);
 $offerts = mysql_query("SELECT * FROM `offerts` WHERE `id` = '" . $id . "'");
 while ($rowsOfferts = @mysql_fetch_assoc($offerts)) {
     $commends = explode(",", $rowsOfferts['commends']);
     $output = count($commends);
     ###
     for ($i = 0; $i < $output; $i++) {
         $by = array("{NICK}");
         $after = array($nick);
         ###
         $commends[$i] = str_replace($by, $after, $commends[$i]);
         $data = $Rcon->Command($commends[$i]);
     }
 }
 $Rcon->Disconnect();