Open LEN-studios opened 7 years ago
Hi,
First, what's the IP you're trying to ping?
Then try adding this on top of the script (right after <?php
):
error_reporting(E_ALL);
ini_set('display_errors', true);
And re-run your script. If an error is shown, please give it me back.
If not, try this in another file:
<?php
echo 'They are both required to be true: ';
var_dump(function_exists('fsockopen'));
var_dump(is_resource(fsockopen("play.onecraft.fr", 25565, $errNo, $errStr, 3)));
And tell me what you got.
Hi,
I respond to the place of LEN-studios because I have the same problem.
error_reporting(E_ALL);
ini_set('display_errors', true);
It doesn't show anything special.
echo 'They are both required to be true: ';
var_dump(function_exists('fsockopen'));
var_dump(is_resource(fsockopen("play.onecraft.fr", 25565, $errNo, $errStr, 3)));
I receive : True, True.
In "query" function :
// Send handshake
$data = self::queryWriteData($socket, 0x09);
var_dump($data);
I receive : false, every time.
What is your PHP version? Which server are you trying to query? Where is your script hosted?
Try to change queryWriteData function:
private static function queryWriteData($socket, $command, $append = '')
{
$command = pack('c*', 0xFE, 0xFD, $command, 0x01, 0x02, 0x03, 0x04) . $append;
$length = strlen($command);
$writeLength = fwrite($socket, $command, $length);
if ($length !== $writeLength) {
var_dump('Wrong length, got:', $writeLength, ', expected:', $length);
return false;
}
$data = fread($socket, 4096);
if ($data === false or strlen($data) < 5 or $data[0] != $command[2]) {
if ($data === false) {
var_dump('Data was false');
} else if (strlen($data) < 5) {
var_dump('Unexpected data length: ', strlen($data));
} else if ($data[0] != $command[2]) {
var_dump('data[0] ≠ command[2], data was:', $data[0], ', command was:', $command[2]);
}
return false;
}
return substr($data, 5);
}
It should print where it failed.
I am getting false results on a server that I tried pinging. The webpage just returns false. It is the Example.php code that I changed the server adress in. Please help.