Features:

  • Extendable to be used for up to 256 purposes.
  • Is already used on our WinMX Chat List page and is already used in our WinMX Link Handler application.

How to Construct

  1. Format your input data correctly.
  2. Use the inflate algorithm to compress the data.
  3. Base64 encode the resulting data and pin mxlnk: on the front.
The first byte of the input data represents the type of magnet link it is. For chat rooms you must use 0×47, and for the chat room information, it must be separated by null bytes.

PHP Examples for encoding and decoding chat room mxlnks:

// Note: Only the roomname is required for a valid chat room mxlnk.
function encodeMXLnk($roomname, $usercount = "", $userlimit = "", $topic = "", $extra = "")
{
     return base64_encode(gzdeflate(chr(0x47) . $roomname . chr(0) . $usercount . chr(0) . $userlimit . chr(0) . $topic . chr(0) . $extra,9));
}

// Obviously there is no error checking on this function, but if provided a genuine chat room mxlnk, it will perform as designed.
function decodeMXLnk($mxlnk)
{
	// Decode and Uncompress
	$data = explode(chr(0), gzinflate(base64_decode(preg_replace('/(mxlnk:\/\/)|(mxlnk:)/i', '', $mxlnk))));
	
	// Build Result
	$result['roomname'] = substr($data[0],1, (strlen($data[0])-1)); // Ignore First Byte => 0x47 (mxlnk type indicator)
	$result['usercount'] = $data[1];
	$result['userlimit'] = $data[2];
	$result['topic'] = $data[3];
	$result['extra'] = $data[4];
	return $result;
}