I have a site using GMap and Keys that is available at 2 domains. I've set up 2 different api keys, one for each domain, and set the appropriate rules. However, the key for the "first" domain is always returned causing an error ("This web site needs a different Google Maps API key. A new key can be generated at...") when I try to view the map on the "second" domain.

The problem is that keys_get_domain() uses $_SERVER['SERVER_NAME'] on line 307, which always returns the same domain. My understanding is that HTTP_HOST is derived from the incoming HTTP request, and SERVER_NAME is the given name of the server, derived from the server config file.

If I change line 307 from:
$domain = $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':'. $_SERVER['SERVER_PORT']);

to:
$domain = $_SERVER['HTTP_HOST'] . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':'. $_SERVER['SERVER_PORT']);

then I get the expected keys and the gmap works on both domains.