fetch(PDO::FETCH_ASSOC)) { if ($row['fixedip'] === '') { $row['fixedip'] = Property::getServerIp(); $defPrio = 2000; } else { $defPrio = 1000; } $ip = $row['fixedip'] ? $row['fixedip'] : $row['clientip']; // See if this server is meant for the client at all if (!is_null($row['locationid']) && !isset($locationsAssoc[$row['locationid']])) { $fallback[$ip] = true; continue; } // Server allowed for client if ($defPrio === 1000 && is_null($row['locationid'])) { // Server is not assigned to this location, try to guess it by its IP address $serverLoc = Location::getFromIp($ip); if ($serverLoc !== false) { $row['locationid'] = $serverLoc; } } $old = isset($servers[$ip]) ? $servers[$ip] : $defPrio; if (is_null($row['locationid']) || !isset($locationsAssoc[$row['locationid']])) { $servers[$ip] = min($defPrio . '.' . mt_rand(), $old); } else { $servers[$ip] = min($locationsAssoc[$row['locationid']] . '.' . mt_rand(), $old); } } foreach ($servers as $k => $v) { unset($fallback[$k]); } asort($servers, SORT_NUMERIC | SORT_ASC); ConfigHolder::add('SLX_DNBD3_SERVERS', implode(' ', array_keys($servers))); ConfigHolder::add('SLX_DNBD3_FALLBACK', implode(' ', array_keys($fallback))); ConfigHolder::add('SLX_VM_DNBD3', 'yes');