Fonction pour trouver le numéro de port dans le fichier de configuration :

function pChatGetPort($room) {
	
	$content = file_get_contents(dirname(__FILE__).'/'.$room.'/paintchat.infos');


	if (preg_match('/Connection_Port_PaintChat=(\d+)/', $content, $m)) {
		return (int) $m[1];
	}

	return false;
}

Fonction pour obtenir les participants :

function pChatGetUsersList($room) {

	// all rooms closed if return false here
	// return false;

	
	$host = $_SERVER['HTTP_HOST'];
	$port = pChatGetPort($room);
	
	if (false === $port) {
		die('missing port');
	}
	
	$content = '';
	
	$fp = @fsockopen($host, $port, $errno, $errstr, 10);
	if (!$fp) {
		return false;
	   die("$errstr ($errno)\n");
	} else {
	
	    fwrite($fp, '<paintchat type="paintchat.infomation" request="userlist" />'."\0");
	    while (!feof($fp)) {
	        $content .= fgets($fp, 128);
	    }
	    
	    fclose($fp); 
	}
	
	if (empty($content)) {
		return false;
	}
	
	if (preg_match_all('/<in id="(\d+)">([^<]+)<\/in>/', $content, $m)) {
		$users = array();
		foreach($m[1] as $key => $id_user) {
			$users[$id_user] = $m[2][$key];
		}
		
		return $users;
	}


	return array();
}