Hello all... i have the script below which does not work properly. The idea is that it sends $send_data to the Half-Life server. But the half-life server only recieves the bit upto and including $rconNumber. The rest of the script works fine. when $send_data is echoed to the page it displays fine... its lost in transit i think.
I have successfully written a script to obtain server stats with no problems... but this one has stumped me...
Here's the code
<?
if($rcon!=""){
$send_socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
$result = socket_connect($send_socket, "217.42.110.139", 27015);
if (!$result){
echo "Error connecting to 192.168.0.11:27015<br>";
}
//SEND CHALLENGE
$send_data = chr(255).chr(255).chr(255).chr(255)."challenge rcon".chr(0);
$result = socket_write($send_socket, $send_data);
if(!$result){
echo "Error writing $send_data to socket $send_socket<br>";
}
$data = socket_read($send_socket, 100000);
if(substr($data, 4, 9) == "challenge"){
$split_data = explode(" ", $data);
$rconNumber = $split_data[2];
//SEND RCON COMMAND
$send_data = chr(255).chr(255).chr(255).chr(255)."rcon ".$rconNumber." ".$pass." ".$rcon.chr(0);
echo $send_data."<br>";
$result = socket_write($send_socket, $send_data);
if(!$result){
echo "Error writing $send_data to socket $send_socket<br>";
}
$data = socket_read($send_socket, 100000);
echo $data;
}
}
?>
I appreciate your help 🙂