Posts: 16
Threads: 3
Joined: Jun 2008
Reputation:
0
01-05-2010, 11:14 PM
(This post was last modified: 01-06-2010, 01:15 AM by Iseult.)
Hi,
I'm looking for a PHP class in order to check if a user is really the owner of a serveur
please, this is kind of 'urgent' I only find on the Web a PHP Class for Source Game. If you have this in your pocket please let me know
Thanks
Posts: 737
Threads: 26
Joined: Jan 2009
Reputation:
6
01-05-2010, 11:16 PM
(This post was last modified: 01-05-2010, 11:16 PM by Nisd.)
Sure you can't use the once for source? If i remember right it should work?
Also you might wanna use a remote query instead.
Posts: 16
Threads: 3
Joined: Jun 2008
Reputation:
0
yeah, it won't work it's not the same protocols with 1.6 and SRCDS games
(and yeah i want to use a remote query )
Posts: 737
Threads: 26
Joined: Jan 2009
Reputation:
6
Posts: 7,778
Threads: 176
Joined: May 2008
Reputation:
83
What do you mean of "checking" the rcon of a player?
Do you want to send a rcon command?
Posts: 737
Threads: 26
Joined: Jan 2009
Reputation:
6
(01-06-2010, 12:24 AM)realchamp Wrote: What do you mean of "checking" the rcon of a player?
He means
(01-05-2010, 11:43 PM)Iseult Wrote: (and yeah i want to use a remote query )
And should use
(01-05-2010, 11:58 PM)Nisd Wrote: http://gameq.sourceforge.net/
Posts: 16
Threads: 3
Joined: Jun 2008
Reputation:
0
i mean, user enter an IP + PORT + RCON
and it query the serveur
resond 1 >> good RCON
respond 0 >> wrong password
thx for the link i'll check that right now
Posts: 737
Threads: 26
Joined: Jan 2009
Reputation:
6
Wow you are confusing...... Well never mind, that link i wrote, cause it is to query a server, no Rcon.
Posts: 7,778
Threads: 176
Joined: May 2008
Reputation:
83
The query to get players, map and users does not require rcon and the one of the Source Engine works for HL1 games too.
To send a rcon command; in fact I believe the source one will work.
Posts: 16
Threads: 3
Joined: Jun 2008
Reputation:
0
01-06-2010, 01:11 AM
(This post was last modified: 01-06-2010, 01:28 AM by Iseult.)
noooo, Gameq doesn't have a RCON system. ='(
yeah i need the RCON verification why do i want this ?
because on my website, you can enter only if you have a server, so to check that, you enter an IP + PORT + your RCON
='(
(on my website, i've already a working version for SRCDS games, i tested it with a CS1.6 server and it says that it's the wrong RCON so no, SRCDS scripts does not support Half Life engine games.)
i updated my first post changing : I'm looking for a PHP class in order to check if a user is really the owner of a server to avoid confusions !
i'll post the rcon CLASS i use,please tell me if you can get this working with cs1.6
Code:
<?php
define('PACKET_SIZE', '1400');
define('SERVERQUERY_INFO', "\xFF\xFF\xFF\xFFTSource Engine Query");
define ('REPLY_INFO', "\x49");
define('SERVERQUERY_GETCHALLENGE', "\xFF\xFF\xFF\xFF\x57");
define ('REPLY_GETCHALLENGE', "\x41");
define('SERVERDATA_AUTH', 3) ;
define ('SERVERDATA_EXECCOMMAND', 2) ;
class srcds_rcon
{
function getLong(&$string)
{
$data = substr($string, 0, 4);
$string = substr($string, 4);
$data = unpack('Vvalue', $data);
return $data['value'];
}
function rcon_command($ip, $port, $password)
{
$ip = $_POST["ip"];
$port = $_POST["port"];
$password = $_POST["rcon"];
$requestId = 1;
$s2 = '';
$socket = @fsockopen ('tcp://'.$ip, $port, $errno, $errstr, 15);
if (!$socket)
return 0;
$data = pack("VV", $requestId, SERVERDATA_AUTH).$password.chr(0).$s2.chr(0);
$data = pack("V",strlen($data)).$data;
fwrite ($socket, $data, strlen($data));
$requestId++ ;
$junk = fread ($socket, PACKET_SIZE);
$string = fread ($socket, PACKET_SIZE);
$size = $this->getLong($string);
$id = $this->getLong($string) ;
if ($id == -1)
{
return 0;
}
else
{
return 1; //if good rcon then return 1, else return 0
}
}
}
Posts: 7,778
Threads: 176
Joined: May 2008
Reputation:
83
PHP Code:
// rcon.php 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)).'"'; $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']; return $ret[0]['S1']; } } ?>
PHP Code:
<?php // Another file // include the rcon.php file: include("rcon.php"); $r = new rcon("127.0.0.1",27015,"testme"); $r->Auth(); echo "Authenticated\n"; //Send a request var_dump($r->rconCommand("cvarlist")); ?>
Posts: 16
Threads: 3
Joined: Jun 2008
Reputation:
0
01-06-2010, 01:44 AM
(This post was last modified: 01-06-2010, 03:34 AM by Iseult.)
thank you so much, i'm testing it right now !
Posts: 16
Threads: 3
Joined: Jun 2008
Reputation:
0
it doesn't work
i copy past the exaclty same as you but it says :
Unable to open socket: Connection refused (111)
Code:
<?php
$r = new rcon("94.23.26.185",27175,"gamer-certified");
$r->Auth();
echo "Authenticated\n";
//Send a request
var_dump($r->rconCommand("cvarlist"));
?>
The server is UP and running !
(yeah i know i did post the rcon_password... it's a 2slot test server based in Europe, so you won't go far with it )
you can see the message : HERE
Posts: 7,778
Threads: 176
Joined: May 2008
Reputation:
83
Change "var $Port = 27015;" to "var $Port = 27175";
Posts: 16
Threads: 3
Joined: Jun 2008
Reputation:
0
ok, to be hosnest, i didn't try, i found an alternative, (but little bit heavy than your system)
(called phprcon)
Thx anyway for your help realchamp
|