Merge pull request #327 from kotarou3/virtualhost

Only check if an address is already registered by hostname, not by IP
This commit is contained in:
Guangcong Luo
2015-02-11 13:17:47 -06:00

View File

@@ -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;
}
}
}