I’ve just run into a problem with my ISP who it seems refuses to allow me to use fsockopen telling me its a security risk and that I have to find an alternative suggesting that I use perl.
Does anyone have an alternative to fsockopen possibly using perl for the script below?
<?php
// fetches server information from minequery.
function fetch_server_info($ip, $port){
$socket = fsockopen($ip, $port, $errno, $errstr, 0.5);
if($socket === false){
return false;
}
fwrite($socket, "QUERY_JSON\n");
$responce = stream_get_contents($socket);
return json_decode($responce, true);
}
?>
It sounds like you want to get the response from the server into
$responcewithout using any of the socket functions in PHP. If shell_exec() is enabled by your hosting provider, you can run an external program to do this instead. Here’s an example using perl:Or you could use netcat if they have it: