par
leo45vl » 25 mars 2012, 20:02
Merci mais vais reformuler ma question car je suit limité dans le code:
La page a modifier( je croix )
Code : Tout sélectionner
class Minequery {
/**
* Queries a Minequery server.
*
* @static
* @param string $address The address to the Minequery server.
* @param int $port The port of the Minequery server.
* @param int $timeout The time given before the connection attempt gives up.
* @return array|bool An array on success, FALSE on failure.
*/
public static function query($address, $port = 25566, $timeout = 30) {
$query = array();
$beginning_time = microtime(true);
$socket = @fsockopen($address, $port, $errno, $errstr, $timeout);
if (!$socket) {
// Could not establish a connection to the server.
return false;
}
$end_time = microtime(true);
fwrite($socket, "QUERY\n");
$response = "";
while(!feof($socket)) {
$response .= fgets($socket, 1024);
}
$response = explode("\n", $response);
// Server port
$query['serverPort'] = explode(" ", $response[0], 2);
$query['serverPort'] = $query['serverPort'][1];
//Server Version
$query['SVER'] = explode(" ", $response[1], 2);
$query['SVER'] = $query['SVER'][1];
//Client Version
$query['CVER'] = explode(" ", $response[2], 2);
$query['CVER'] = $query['CVER'][1];
// Player count
$query['playerCount'] = explode(" ", $response[3], 2);
$query['playerCount'] = $query['playerCount'][1];
// Max players
$query['maxPlayers'] = explode(" ", $response[4], 2);
$query['maxPlayers'] = $query['maxPlayers'][1];
// Player list
$query['PLAYERWORLDLIST'] = explode(" ", $response[6], 2);
$query['PLAYERWORLDLIST'] = explode(", ", trim($query['PLAYERWORLDLIST'][1], "[]"));
// Player list
$query['playerList'] = explode(" ", $response[5], 2);
$query['playerList'] = explode(", ", trim($query['playerList'][1], "[]"));
// Plugin list
$query['PLUGINNAMELIST'] = explode(" ", $response[7], 2);
$query['PLUGINNAMELIST'] = explode(", ", trim($query['PLUGINNAMELIST'][1], "[]"));
// Plugin version list
$query['PLUGINVERSIONLIST'] = explode(" ", $response[8], 2);
$query['PLUGINVERSIONLIST'] = explode(", ", trim($query['PLUGINVERSIONLIST'][1], "[]"));
$query['latency'] = ($end_time - $beginning_time) * 1000;
return $query;
}
/**
* Queries a Minequery server using JSON.
*
* @static
* @param string $address The address to the Minequery server.
* @param int $port The port of the Minequery server.
* @param int $timeout The time given before the connection attempt gives up.
* @return object|bool A stdClass object on success, FALSE on failure.
*/
public static function query_json($address, $port = 25566, $timeout = 30) {
$beginning_time = microtime(true);
$socket = @fsockopen($address, $port, $errno, $errstr, $timeout);
if (!$socket) {
// Could not establish a connection to the server.
return false;
}
$end_time = microtime(true);
fwrite($socket, "QUERY_JSON\n");
$response = "";
while(!feof($socket)) {
$response .= fgets($socket, 1024);
}
$query = json_decode($response);
$query->latency = ($end_time - $beginning_time) * 1000;
return $query;
}
}
Au début on voit
public static function query($address, $port = 25566, $timeout = 30) {
La seul affaire que je veux modifier est $port = 25566 je voudrais mettre 2 port a véfirier.
Est-ce possible?
Merci beaucoup,
Leo
Merci mais vais reformuler ma question car je suit limité dans le code:
La page a modifier( je croix )
[code]class Minequery {
/**
* Queries a Minequery server.
*
* @static
* @param string $address The address to the Minequery server.
* @param int $port The port of the Minequery server.
* @param int $timeout The time given before the connection attempt gives up.
* @return array|bool An array on success, FALSE on failure.
*/
public static function query($address, $port = 25566, $timeout = 30) {
$query = array();
$beginning_time = microtime(true);
$socket = @fsockopen($address, $port, $errno, $errstr, $timeout);
if (!$socket) {
// Could not establish a connection to the server.
return false;
}
$end_time = microtime(true);
fwrite($socket, "QUERY\n");
$response = "";
while(!feof($socket)) {
$response .= fgets($socket, 1024);
}
$response = explode("\n", $response);
// Server port
$query['serverPort'] = explode(" ", $response[0], 2);
$query['serverPort'] = $query['serverPort'][1];
//Server Version
$query['SVER'] = explode(" ", $response[1], 2);
$query['SVER'] = $query['SVER'][1];
//Client Version
$query['CVER'] = explode(" ", $response[2], 2);
$query['CVER'] = $query['CVER'][1];
// Player count
$query['playerCount'] = explode(" ", $response[3], 2);
$query['playerCount'] = $query['playerCount'][1];
// Max players
$query['maxPlayers'] = explode(" ", $response[4], 2);
$query['maxPlayers'] = $query['maxPlayers'][1];
// Player list
$query['PLAYERWORLDLIST'] = explode(" ", $response[6], 2);
$query['PLAYERWORLDLIST'] = explode(", ", trim($query['PLAYERWORLDLIST'][1], "[]"));
// Player list
$query['playerList'] = explode(" ", $response[5], 2);
$query['playerList'] = explode(", ", trim($query['playerList'][1], "[]"));
// Plugin list
$query['PLUGINNAMELIST'] = explode(" ", $response[7], 2);
$query['PLUGINNAMELIST'] = explode(", ", trim($query['PLUGINNAMELIST'][1], "[]"));
// Plugin version list
$query['PLUGINVERSIONLIST'] = explode(" ", $response[8], 2);
$query['PLUGINVERSIONLIST'] = explode(", ", trim($query['PLUGINVERSIONLIST'][1], "[]"));
$query['latency'] = ($end_time - $beginning_time) * 1000;
return $query;
}
/**
* Queries a Minequery server using JSON.
*
* @static
* @param string $address The address to the Minequery server.
* @param int $port The port of the Minequery server.
* @param int $timeout The time given before the connection attempt gives up.
* @return object|bool A stdClass object on success, FALSE on failure.
*/
public static function query_json($address, $port = 25566, $timeout = 30) {
$beginning_time = microtime(true);
$socket = @fsockopen($address, $port, $errno, $errstr, $timeout);
if (!$socket) {
// Could not establish a connection to the server.
return false;
}
$end_time = microtime(true);
fwrite($socket, "QUERY_JSON\n");
$response = "";
while(!feof($socket)) {
$response .= fgets($socket, 1024);
}
$query = json_decode($response);
$query->latency = ($end_time - $beginning_time) * 1000;
return $query;
}
}[/code]
Au début on voit
public static function query($address, $port = 25566, $timeout = 30) {
La seul affaire que je veux modifier est $port = 25566 je voudrais mettre 2 port a véfirier.
Est-ce possible?
Merci beaucoup,
Leo