felixms / arma-rcon-class-php

A lightweight client for sending commands easily to a BattlEye server.
MIT License
46 stars 22 forks source link

remove RCon admin on login #5

Closed nerdalertdk closed 8 years ago

nerdalertdk commented 8 years ago

Hi,

is there any way to remove the RCon admin when open a connection ? I am making an ban controlpanel with extra features and every time i run a command i log in :(

ps. i have multiple server support so have to connect to the server I select when running a command

felixms commented 8 years ago

Well, foreach server you need to create a new object, e.g.:

$server1 = new \Nizarii\ArmaRConClass\ARC("server1 IP", Port, "RCon password");
$server2 = new \Nizarii\ArmaRConClass\ARC("server2 IP", Port, "RCon password");

When you run a command(), RCon Admin shouldn't be in the message. get_answer() should filter this:

    private function get_answer()
    {
        $get = function() { return substr(fread($this->socket, 102400), strlen($this->head)); };
        $output = '';
        do {
            $answer = $get();

            // If 'Rcon admin' is in the message, read again
            while ( strpos($answer,'RCon admin') !== false ) $answer = $get();

            $output .= $answer;
        } while ( $answer != '' );
        return $output;
    }
nerdalertdk commented 8 years ago

yeah, $server1, $server2 would not work since its more of an admin portal :) see bans, players, admin login system.

I dont get the Rcon admin in my answer but do get it ingame

I have a status page, where it would display if rcon is online, the first version check the pass every time so had a lot Rcon admin ingame, fixed that by checking the password when adding the server, if it was correct it sets a flag in the DB and if ARC trows an exception its sets the flag to false