From 9a9d236093807c56894102f280b7e81c4f77edf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=A4=AA?= Date: Mon, 2 Feb 2015 23:53:26 +0800 Subject: [PATCH] Only check if an address is already registered by hostname, not by IP When attempting to go on an unregistered server when there is already another registered server sharing the same IP/Port pair (such as in virtual hosting), you get redirected to the registered server, which is undesirable --- crossdomain.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/crossdomain.php b/crossdomain.php index 74fd63fb1..fd75271cc 100644 --- a/crossdomain.php +++ b/crossdomain.php @@ -56,19 +56,14 @@ if (isset($PokemonServers[$config['host']])) { // see if this is actually a registered server if ($config['host'] !== 'localhost') { - $ip = gethostbyname($config['host']); foreach ($PokemonServers as &$server) { - if (!isset($server['ipcache'])) { - $server['ipcache'] = gethostbyname($server['server']); - } - if ($ip === $server['ipcache']) { - if (($config['port'] === $server['port']) || - (isset($server['altport']) && - $config['port'] === $server['altport'])) { - $path = isset($_REQUEST['path']) ? $_REQUEST['path'] : ''; - $config['redirect'] = 'http://' . $server['id'] . '.psim.us/' . rawurlencode($path); - break; - } + if ($config['host'] === $server['server'] && ( + $config['port'] === $server['port'] || + (isset($server['altport']) && $config['port'] === $server['altport']) + )) { + $path = isset($_REQUEST['path']) ? $_REQUEST['path'] : ''; + $config['redirect'] = 'http://' . $server['id'] . '.psim.us/' . rawurlencode($path); + break; } } }