Warlock client uses wrong server address
Currently using $_SERVER['SERVER_NAME']
which it would appear only covers about 90% of situations. For instance, in Apache if the ServerName
configuration attribute is set to www.example.com
and there is an alias of warlock.example.com
, the application will be available at both addresses. The URL generating will also generate addresses using the appropriate server address as it should.
However, if you go to http://warlock.example.com
then Warlock will still attempt to connect to ws://www.example.com
even though the requested address is different. This is because the server configuration in $_SERVER['SERVER_NAME']
reports the server name as www.example.com
. We need to instead use $_SERVER['HTTP_HOST']
however this can include a port number. I have come up with a nice bit of code that maintains the existing functionality should HTTP_HOST not be available, but if it is, uses it AND strips the port number if needed.
$server = ake(explode(':', $_SERVER['HTTP_HOST']), 0, $_SERVER['SERVER_NAME']);