SRCDS Steam group


remote console php?
#1
is it possible to have a <textbox></textbox> where is shown the activity of the src server and also act as a remote console?, with typing in commands and the server execs them?

thx
Linux IsiX 64 Generic Desktop ValHalla 2.6.33.4 x86_64
Intel Core 2 Duo T8400 4Gb Ram 40G SSD Intel
[Image: b_460x42_C000000-454234-696149-FFFFFF-FFF468-FFF468.png]
DoD 31 Comunity DoD 31 Spanish Comunity
Erste SS Panzer Grendier Division [DOD Clan]
Reply
#2
get Wrote:is it possible to have a <textbox></textbox> where is shown the activity of the src server and also act as a remote console?, with typing in commands and the server execs them?

thx

Couldn't find one that shows output of what is happening on server through console (although have seen this before elsewhere), but came across this:

http://fremnet.net/article/199/source-rcon-class
Reply
#3
You need a plugin on the srcds to send console info to another application/website/etc
Join the Source Dedicated Server Support Group on Steam Community!
Source Dedicated Server (SRCDS)
Free to join, Live support! (When available)

http://forums.srcds.com/viewtopic/5114
Reply
#4
yep i already using the source rcon class but,
i guess it is what drocona means a plugin to send the activity to a web aplication, but, is this aplication only one way?

EX: srcds server --> website
or in both ways?
srcds server --> website, website input ---> srcds server

that should be a great goal in programming remote management panels

regards

PD: sending log with logadress_add $IP:$PORT, how to handle the submitted log on $IP and show it on the <textbox></textbox> ?
any good manual tutorial for this using php ?
Linux IsiX 64 Generic Desktop ValHalla 2.6.33.4 x86_64
Intel Core 2 Duo T8400 4Gb Ram 40G SSD Intel
[Image: b_460x42_C000000-454234-696149-FFFFFF-FFF468-FFF468.png]
DoD 31 Comunity DoD 31 Spanish Comunity
Erste SS Panzer Grendier Division [DOD Clan]
Reply
#5
guys thx for the help
just forking and fooling arround with a test server, i added my linuxbox's ip to the server by logaddress_add myip:port

and on my pc i run netcat listening in udp mode all packets who comes in in verbose mode: and look out:
Code:
����RL 10/11/2007 - 17:52:07: server_cvar: "mp_timelimit" "10"
����RL 10/11/2007 - 17:52:11: server_cvar: "mp_timelimit" "30"
����RL 10/11/2007 - 17:52:59: server_cvar: "sv_password" "***PROTECTED***"

now i just need to handle this with php and wipe out all useless stuff and let php show the output as a tail -f in the textbox ^^
Linux IsiX 64 Generic Desktop ValHalla 2.6.33.4 x86_64
Intel Core 2 Duo T8400 4Gb Ram 40G SSD Intel
[Image: b_460x42_C000000-454234-696149-FFFFFF-FFF468-FFF468.png]
DoD 31 Comunity DoD 31 Spanish Comunity
Erste SS Panzer Grendier Division [DOD Clan]
Reply
#6
Totally forgot about the logaddress_add command!
Join the Source Dedicated Server Support Group on Steam Community!
Source Dedicated Server (SRCDS)
Free to join, Live support! (When available)

http://forums.srcds.com/viewtopic/5114
Reply
#7
so here is a sample code:

rcon.php
Code:
<?php
if(isset($_POST['command'])){
include_once("rcon.class.php");

$r = new rcon($_POST['ip'],$_POST['port'],$_POST['rcon']);
$r->Auth();

echo "<pre>";

var_dump($r->rconCommand($_POST['command']));
echo "</pre>
<br>
<form method='post' action={$_SERVER['PHP_SELF']}>
    <input type=submit value='« back'>
</form>
<br>
<img src='http://www.game-monitor.com/server-stat-image/{$_POST['ip']}:{$_POST['port']}.png'>
";

}else{
echo "
<form method='post' action={$_SERVER['PHP_SELF']}>
IP: <input type='text' name='ip'></input>:<input type='text' name='port'></input><br>
Rcon Password: <input type='text' name='rcon'></input><br>
Command: <input type='text' name='command'></input>
<input type=submit value='enviar consulta'>
</form>
<br>


";

}

?>

rcon.class.php
Code:
<?php
/*
    Basic CS:S Rcon class by Freman.  (V1.00)
    ----------------------------------------------
    Ok, it's a completely working class now with with multi-packet responses

    Contact: printf("%s%s%s%s%s%s%s%s%s%d%s%s%s","rc","on",chr(46),"cl","ass",chr(64),"pri","ya",chr(46),2,"y",chr(46),"net")

    Behaviour I've noticed:
    rcon is not returning the packet id.
*/

define("SERVERDATA_EXECCOMMAND",2);
define("SERVERDATA_AUTH",3);

class RCon {
    var $Password;
    var $Host;
    var $Port = 27015;
    var $_Sock = null;
    var $_Id = 0;

    function RCon ($Host,$Port,$Password) {
    $this->Password = $Password;
    $this->Host = $Host;
    $this->Port = $Port;
    $this->_Sock = @fsockopen($this->Host,$this->Port, $errno, $errstr, 30) or
        die("Unable to open socket: $errstr ($errno)\n");
    $this->_Set_Timeout($this->_Sock,2,500);
    }
    
    function Auth () {
    $PackID = $this->_Write(SERVERDATA_AUTH,$this->Password);
    
    // Real response (id: -1 = failure)
    $ret = $this->_PacketRead();
    if ($ret[1]['id'] == -1) {
        die("Authentication Failure\n");
    }
    }

    function _Set_Timeout(&$res,$s,$m=0) {
    if (version_compare(phpversion(),'4.3.0','<')) {
        return socket_set_timeout($res,$s,$m);
    }
    return stream_set_timeout($res,$s,$m);
    }

    function _Write($cmd, $s1='', $s2='') {
    // Get and increment the packet id
    $id = ++$this->_Id;

    // Put our packet together
    $data = pack("VV",$id,$cmd).$s1.chr(0).$s2.chr(0);

    // Prefix the packet size
    $data = pack("V",strlen($data)).$data;

    // Send packet
    fwrite($this->_Sock,$data,strlen($data));

    // In case we want it later we'll return the packet id
    return $id;
    }

    function _PacketRead() {
    //Declare the return array
    $retarray = array();
    //Fetch the packet size
    while ($size = @fread($this->_Sock,4)) {
        $size = unpack('V1Size',$size);
        //Work around valve breaking the protocol
        if ($size["Size"] > 4096) {
        //pad with 8 nulls
        $packet = "\x00\x00\x00\x00\x00\x00\x00\x00".fread($this->_Sock,4096);
        } else {
        //Read the packet back
        $packet = fread($this->_Sock,$size["Size"]);
        }
        array_push($retarray,unpack("V1ID/V1Response/a*S1/a*S2",$packet));
    }
    return $retarray;
    }

    function Read() {
    $Packets = $this->_PacketRead();
    
    foreach($Packets as $pack) {
        if (isset($ret[$pack['ID']])) {
        $ret[$pack['ID']]['S1'] .= $pack['S1'];
        $ret[$pack['ID']]['S2'] .= $pack['S1'];
        } else {
        $ret[$pack['ID']] = array(
                    'Response' => $pack['Response'],
                    'S1' => $pack['S1'],
                    'S2' =>    $pack['S2'],
                    );
        }
    }
    return $ret;
    }

    function sendCommand($Command) {
    //$Command = '"'.trim(str_replace(' ','" "', $Command)).'"';
    //$Command = trim(str_replace(' ','" "', $Command));
    $this->_Write(SERVERDATA_EXECCOMMAND,$Command,'');
    }

    function rconCommand($Command) {
    $this->sendcommand($Command);

    $ret = $this->Read();

    //ATM: Source servers don't return the request id, but if they fix this the code below should read as
    //return $ret[$this->_Id]['S1'];
    echo $ret[$this->_Id]['S1'];
    //return $ret[0]['S1'];
    }
}
?>

Preview:

[Image: previewna9.png]
Linux IsiX 64 Generic Desktop ValHalla 2.6.33.4 x86_64
Intel Core 2 Duo T8400 4Gb Ram 40G SSD Intel
[Image: b_460x42_C000000-454234-696149-FFFFFF-FFF468-FFF468.png]
DoD 31 Comunity DoD 31 Spanish Comunity
Erste SS Panzer Grendier Division [DOD Clan]
Reply
#8
sweet!
Join the Source Dedicated Server Support Group on Steam Community!
Source Dedicated Server (SRCDS)
Free to join, Live support! (When available)

http://forums.srcds.com/viewtopic/5114
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)