Помогите Проблеммы с Rcon

  • Автор темы Автор темы vinipyx7
  • Дата начала Дата начала

vinipyx7

Старожил
Пользователь
Баллы
103
Имя в Minecraft
vinipyx7
Я вроде всё правильно настроил но немогу подключится к серверу через Rcon панель, и как видите всегда показывает что сервер онфлай хотя он онлайн.
Подскажите мне что я не так мог сделать или где то ошибка есть?
Вот в лаунчере пишет офлайн:
ae55c22ba9f9.png
Вот что в консоле пишет :
4bc047138387.png
Вот server properties:
#Minecraft server properties
#Tue Feb 05 15:49:12 CAT 2013
generator-settings=
allow-nether=true
level-name=world
enable-query=false
allow-flight=false
rcon.password=12345
server-port=26565
level-type=DEFAULT
enable-rcon=true
level-seed=
server-ip=91.209.54.24
max-build-height=256
spawn-npcs=true
white-list=false
debug=false
spawn-animals=true
texture-pack=
hardcore=false
snooper-enabled=true
online-mode=true
pvp=true
difficulty=3
server-name=Unknown Server
gamemode=0
max-players=50
rcon.port=25560
spawn-monsters=true
view-distance=10
generate-structures=true
spawn-protection=16
motd=Island RPG
Вот bd_con.php:
Параметры авторизации RCON (состояние сервера \ админ панель)

*/

$game_server = "91.209.54.24"; // адрес вашего Bukkit\официального сервера, используется при подключении
$game_server_str = "Island RPG"; // строка выводимая в статусе сервера

$rcon_server_stat = true; //использовать RCON вместо Query для получения состояния сервера [true] RCON [false] Query
$query_port = 25565; //порт для Query, если активен

$rcon_port = 25560; //порт для RCON, если активен
$rcon_pass = "12345";
 
Вот rcon.class.php:

<?php

class MinecraftRconException extends Exception
{
// Exception thrown by MinecraftRcon class
}

class MinecraftRcon
{
/*
* Class written by xPaw
*
* Website: http://xpaw.ru
* GitHub: https://github.com/xPaw/PHP-Minecraft-Query
*
* Protocol: https://developer.valvesoftware.com/wiki/Source_RCON_Protocol
*/

// Sending
const SERVERDATA_EXECCOMMAND = 2;
const SERVERDATA_AUTH = 3;

// Receiving
const SERVERDATA_RESPONSE_VALUE = 0;
const SERVERDATA_AUTH_RESPONSE = 2;

private $Socket;
private $RequestId;

public function __destruct( )
{
$this->Disconnect( );
}

public function Connect( $Ip , $Port = 25560, $Password, $Timeout = 3 )
{
$this->RequestId = 0;

if( $this->Socket = @FSockOpen( $Ip, (int)$Port, $errno, $errstr, $Timeout ) )
{
Socket_Set_TimeOut( $this->Socket, $Timeout );

if( !$this->Auth( $Password ) )
{
$this->Disconnect( );

throw new MinecraftRconException( "Authorization failed." );
}
}
else
{
throw new MinecraftRconException( "Server offline" );
}
}

public function Disconnect( )
{
if( $this->Socket )
{
FClose( $this->Socket );

$this->Socket = null;
}
}

public function Command( $String )
{
if( !$this->WriteData( self :: SERVERDATA_EXECCOMMAND, $String ) )
{
return false;
}

$Data = $this->ReadData( );

if( $Data[ 'RequestId' ] < 1 || $Data[ 'Response' ] != self :: SERVERDATA_RESPONSE_VALUE )
{
return false;
}

return $Data[ 'String' ];
}

private function Auth( $Password )
{
if( !$this->WriteData( self :: SERVERDATA_AUTH, $Password ) )
{
return false;
}

$Data = $this->ReadData( );

return $Data[ 'RequestId' ] > -1 && $Data[ 'Response' ] == self :: SERVERDATA_AUTH_RESPONSE;
}

private function ReadData( )
{
$Packet = Array( );

$Size = FRead( $this->Socket, 4 );
$Size = UnPack( 'V1Size', $Size );
$Size = $Size[ 'Size' ];

// TODO: Add multiple packets (Source)

$Packet = FRead( $this->Socket, $Size );
$Packet = UnPack( 'V1RequestId/V1Response/a*String/a*String2', $Packet );

return $Packet;
}

private function WriteData( $Command, $String = "" )
{
// Pack the packet together
$Data = Pack( 'VV', $this->RequestId++, $Command ) . $String . chr(0).''.chr(0);

// Prepend packet length
$Data = Pack( 'V', StrLen( $Data ) ) . $Data;

$Length = StrLen( $Data );

return $Length === FWrite( $this->Socket, $Data, $Length );
}
}

?>
 
Вот mcraft.rcon.php:

<?php
require_once('rcon.class.php');
require_once("../system.php");


/*

HTML version of GetUserList

*/

function GetUserListHTML($result) {

$str = trim($result);
$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]=='') unset($names);

if (empty($names)) return array('<p>Сервер пуст</p>','');

$html = '';
$script = '';

for($i=0;$i<sizeof($names);$i++) {

$script .= 'parent.addNickButton("'.$names[$i].'",'.$i.');';
$html .= '<p><a href="#" id="nickButton'.$i.'">'.$names[$i].'</a></p>';

}


return array($html,$script);
}

if (empty($user) or $user->lvl < 15) exit;
if (empty($game_server)) exit('<script>parent.showResult("rcon unconfigured");</script>');
if (empty($_POST['command']) and empty($_POST['userlist'])) exit('<script>parent.showResult("command is empty");</script>');

try
{
$rcon = new MinecraftRcon;
$rcon->Connect( $game_server, $rcon_port, $rcon_pass);

if (!empty($_POST['userlist'])) {

$page = GetUserListHTML($rcon->Command('list'));
exit("<script>parent.document.getElementById('users_online').innerHTML = '".$page[0]."'; ".$page[1]."</script>");

}

$command = trim($_POST['command']);
$command = str_replace(array("\r\n", "\n", "\r"),'', $command);
$command = preg_replace('| +|', ' ', $command);


$str = trim(htmlspecialchars($rcon->Command($command), ENT_QUOTES ));

$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);

$str = str_replace(array(chr(167)), '', $str);

echo '<script>parent.showResult("'.$str.'");</script>';

}
catch( MinecraftRconException $e )
{
echo '<script>parent.showResult("'.$e->getMessage( ).'");</script>';
}

$rcon->Disconnect( );


?>
 
Вот index.php:
<?php
header('Content-Type: text/html;charset=UTF-8');

require_once("../../system.php"); if (empty($user) or $user->lvl < 15) exit; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Minecraft RCON v1.0b by NC22</title>

<style>
* {margin: 0px; padding: 0px;}

body {
background: #fff url(bg0.png) repeat top left;
font-size: 16px;
font-family: Cambria, Palatino, "Palatino Linotype", "Palatino LT STD", Georgia, serif;
-webkit-font-smoothing: antialiased;
-moz-font-smoothing: antialiased;
font-smoothing: antialiased;
}

* html body {height: 100%;}

a{
color: #eaf0f6;
text-decoration: none;
}

.console_holder{
margin: 0 auto;
margin-top: 20px;
padding: none;
height: auto;
width: 80%;
}

.help_block {

display: block;
clear: both;
float:right;
margin-left: 8px;
text-align: left;
color:#e9e9e9;
background: #929292;
width: 250px;
max-height: 600px;
overflow:auto;
border: 2px dashed #747474;
}

.main_left_block{

background: #929292;
color: #e5e5e5;
text-align: center;
border: 2px dashed #747474;
padding: 4px;
margin-bottom: 10px;

}

.main_left_block #console_log {

text-align: left;
height: 300px;
font-size: 14px;
overflow:auto;
background:#676767;
}

</style>

<!--[if IE]>
<style>
.console_holder{
position:absolute;
left:10%;
}

.main_left_block{
margin-right:260px;
}

</style>
<![endif]-->

</head>

<body>
<script type='text/javascript'>
var sendBeasy = false;

function _getTime() {
var currentTime = new Date();
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();

if (minutes < 10){
minutes = "0" + minutes;
}
return hours + ":" + minutes;
}

function showResult(result) {
document.getElementById('console_log').innerHTML += '<p>[' + _getTime() + '] ' + result + '</p>'
}

function addNickButton(name,id) {

var tmp = document.getElementById('nickButton'+id)
if (tmp != null) tmp.onclick = function(){

document.command_form.command.value += ' '+name

return false
}

}

function cType(com) {

document.command_form.command.value += com + ' '

return false

}

function cShow(m) {

if (m==1) {
document.getElementById('help_buttons').innerHTML = '<b>Игроки</b> | <a href="#" onclick="cShow(2)">Команды</a>'
document.getElementById('commands-list').style.display = 'none'
document.getElementById('users-list').style.display = 'block'
} else if (m==2) {
document.getElementById('help_buttons').innerHTML = '<a href="#" onclick="cShow(1)">Игроки</a> | <b>Команды</b>'
document.getElementById('commands-list').style.display = 'block'
document.getElementById('users-list').style.display = 'none'
}

return false
}

window.onload = function () {
var tmp = document.getElementById('command_send')
if (tmp != null) tmp.onclick = function(){

if (sendBeasy) return false

if (document.command_form.command.value.length == 0) return false

var log = document.getElementById("console_log")
log.innerHTML += '<p>[' + _getTime() + '] ' + document.command_form.command.value + '</p>'
log.scrollTop = log.scrollHeight

document.command_form.submit();
document.command_form.command.value = ''

sendBeasy = true

document.getElementById('systemFrame01').onload = function(){

sendBeasy = false
var log = document.getElementById("console_log")
log.scrollTop = log.scrollHeight
 
Вот index.php:
}
}
}
</script>

<h1 style="color: #e5e5e5;"> Minecraft RCON session </h1>

<div class="console_holder">

<div class="help_block">
<div style="background:#747474; text-align:center; padding:2px;" id="help_buttons"><a href="#" onclick="cShow(1)">Игроки</a> | <b>Команды</b></div>

<div style="text-align:center; display: none;" id="users-list">
<div><input type="button" value="Обновить" id="users_online_refresh" /></div>
<div id="users_online"></div>
</div>
<div style="text-align:left;" id="commands-list">
<p>Список комманд</p>

<p><a href="#" onclick="cType('tell')">tell [playername] [message]</a></p>
<p><a href="#" onclick="cType('me')">me [actiontext]</a></p>
<p><a href="#" onclick="cType('kill')">kill</a></p>
<p><a href="#" onclick="cType('ban')">ban [playername]</a></p>
<p><a href="#" onclick="cType('ban-ip')">ban-ip [ip-address]</a></p>
<p><a href="#" onclick="cType('banlist')">banlist</a></p>
<p><a href="#" onclick="cType('deop')">deop [playername]</a></p>
<p><a href="#" onclick="cType('gamemode')">gamemode [playername] 0/1</a></p>
<p><a href="#" onclick="cType('give')">give [player] [item] [amount]</a></p>
<p><a href="#" onclick="cType('help')">help</a></p>
<p><a href="#" onclick="cType('kick')">kick [playername]</a></p>
<p><a href="#" onclick="cType('list')">list</a></p>
<p><a href="#" onclick="cType('op')">op [playername]</a></p>
<p><a href="#" onclick="cType('pardon')">pardon [playername]</a></p>
<p><a href="#" onclick="cType('pardon-ip')">pardon-ip [ip-address]</a></p>
<p><a href="#" onclick="cType('save-all')">save-all</a></p>
<p><a href="#" onclick="cType('save-off')">save-off</a></p>
<p><a href="#" onclick="cType('save-on')">save-on</a></p>
<p><a href="#" onclick="cType('say')">say [message]</a></p>
<p><a href="#" onclick="cType('stop')">stop</a></p>
<p><a href="#" onclick="cType('time')">time [set|add] [number]</a></p>
<p><a href="#" onclick="cType('toggledownfall')">toggledownfall</a></p>
<p><a href="#" onclick="cType('tp')">tp [playername] [targetplayer]</a></p>
<p><a href="#" onclick="cType('whitelist')">whitelist</a></p>
<p><a href="#" onclick="cType('whitelist reload')">whitelist reload</a></p>
<p><a href="#" onclick="cType('xp')">xp [playername] [amount]</a></p>
<p><a href="#" onclick="cType('defaultgamemode')">defaultgamemode [2/1/0]</a></p>

</div>
</div>

<div style="overflow: hidden;">


<div class="main_left_block">

<div style="background:#747474; text-align:center;"> Лог консоли</div>

<div id="console_log">


</div>
<div style="background:#747474; text-align:center;">Ввод команды</div>

<div style="background:#818181; text-align:center; padding: 5px;">
<form action="../mcraft.rcon.php" method="POST" name="command_form" target="systemFrame">

<p><input name="command" type="text" style="width: 80%;">&nbsp;<a href="#" id="command_send" style="border: 2px solid #363636;">SEND</a></p>

</form>

</div>


</div>


</div>



</div>

<iframe name="systemFrame" id="systemFrame01" src="" style="display: none;"></iframe>

<form action="../mcraft.rcon.php" method="POST" name="userlist_form" target="systemFrame" style="display: none;">
<input type="hidden" name="userlist" value="1" />
</form>

</body>

</html>
 
Назад
Верх