Имеется у меня вот такой класс:
Код:
class rcon
{
private $fp, $challenge_number;
public function Connect($host, $port, $pass)
{
$this->host = $host;
$this->port = $port;
$this->pass = $pass;
$this->fp = @fsockopen("udp://".$this->host, $this->port);
return $this->fp ? $this->GetChallengeNumber() : false;
}
public function Disconnect()
{
return fclose($this->fp) ? true : false;
}
public function Command($command)
{
return $this->RconCommand("\xff\xff\xff\xffrcon $this->challenge_number \"$this->pass\" $command");
}
private function GetChallengeNumber()
{
$this->challenge_number = trim($this->RconCommand("\xff\xff\xff\xffchallenge rcon"));
if(empty($this->challenge_number))
return false;
$_challenge = explode(" ", $this->challenge_number);
$this->challenge_number = $_challenge["2"];
return $this->challenge_number;
}
private function RconCommand($command)
{
fputs($this->fp, $command, strlen($command));
$buffer = fread($this->fp, 1);
$status = socket_get_status($this->fp);
$buffer .= fread($this->fp, $status["unread_bytes"]);
$buffer = substr($buffer, 5);
return $buffer;
}
}
Вызывается так:
Код:
if($this->rcon->Connect('ip', 'port', 'rcon_pass')
$result = $this->rcon->Command('команда');
$this->rcon->Disconnect();
echo $result;
Перестал в общем говоря работать, помогите найти ошибку)
Ответ всегда один:
Код:
Bad rcon_password.
\0\0
Пароль сразу говорю верный. Желательно допилить этот класс, не хочу использовать громоздкие.