code:
<?
// ***** BEGIN LICENSE BLOCK *****
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
//
// The contents of this file are subject to the Mozilla Public License Version
// 1.1 (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
//
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
// for the specific language governing rights and limitations under the
// License.
//
// The Original Code is the Public Suffix List.
//
// The Initial Developer of the Original Code is
// Jo Hermans <jo.hermans@gmail.com>.
// Portions created by the Initial Developer are Copyright (C) 2007
// the Initial Developer. All Rights Reserved.
//
// Contributor(s):
//   Ruben Arakelyan <ruben@wackomenace.co.uk>
//   Gervase Markham <gerv@gerv.net>
//   Pamela Greene <pamg.bugs@gmail.com>
//   David Triendl <david@triendl.name>
//   Jothan Frakes <jothan@gmail.com>
//   The kind representatives of many TLD registries
//
// Alternatively, the contents of this file may be used under the terms of
// either the GNU General Public License Version 2 or later (the "GPL"), or
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
// in which case the provisions of the GPL or the LGPL are applicable instead
// of those above. If you wish to allow use of your version of this file only
// under the terms of either the GPL or the LGPL, and not to allow others to
// use your version of this file under the terms of the MPL, indicate your
// decision by deleting the provisions above and replace them with the notice
// and other provisions required by the GPL or the LGPL. If you do not delete
// the provisions above, a recipient may use your version of this file under
// the terms of any one of the MPL, the GPL or the LGPL.
//
// ***** END LICENSE BLOCK *****

$tldTree = array('ac' => array('com' => array(),
'edu' => array(),
'gov' => array(),
'net' => array(),
'mil' => array(),
'org' => array()),
'ad' => array('nom' => array()),
'ae' => array('co' => array(),
'net' => array(),
'org' => array(),
'sch' => array(),
'ac' => array(),
'gov' => array(),
'mil' => array()),
'aero' => array('accident-investigation' => array(),
'accident-prevention' => array(),
'aerobatic' => array(),
'aeroclub' => array(),
'aerodrome' => array(),
'agents' => array(),
'aircraft' => array(),
'airline' => array(),
'airport' => array(),
'air-surveillance' => array(),
'airtraffic' => array(),
'air-traffic-control' => array(),
'ambulance' => array(),
'amusement' => array(),
'association' => array(),
'author' => array(),
'ballooning' => array(),
'broker' => array(),
'caa' => array(),
'cargo' => array(),
'catering' => array(),
'certification' => array(),
'championship' => array(),
'charter' => array(),
'civilaviation' => array(),
'club' => array(),
'conference' => array(),
'consultant' => array(),
'consulting' => array(),
'control' => array(),
'council' => array(),
'crew' => array(),
'design' => array(),
'dgca' => array(),
'educator' => array(),
'emergency' => array(),
'engine' => array(),
'engineer' => array(),
'entertainment' => array(),
'equipment' => array(),
'exchange' => array(),
'express' => array(),
'federation' => array(),
'flight' => array(),
'freight' => array(),
'fuel' => array(),
'gliding' => array(),
'government' => array(),
'groundhandling' => array(),
'group' => array(),
'hanggliding' => array(),
'homebuilt' => array(),
'insurance' => array(),
'journal' => array(),
'journalist' => array(),
'leasing' => array(),
'logistics' => array(),
'magazine' => array(),
'maintenance' => array(),
'marketplace' => array(),
'media' => array(),
'microlight' => array(),
'modelling' => array(),
'navigation' => array(),
'parachuting' => array(),
'paragliding' => array(),
'passenger-association' => array(),
'pilot' => array(),
'press' => array(),
'production' => array(),
'recreation' => array(),
'repbody' => array(),
'res' => array(),
'research' => array(),
'rotorcraft' => array(),
'safety' => array(),
'scientist' => array(),
'services' => array(),
'show' => array(),
'skydiving' => array(),
'software' => array(),
'student' => array(),
'taxi' => array(),
'trader' => array(),
'trading' => array(),
'trainer' => array(),
'union' => array(),
'workinggroup' => array(),
'works' => array()),
'af' => array('gov' => array(),
'com' => array(),
'org' => array(),
'net' => array(),
'edu' => array()),
'ag' => array('com' => array(),
'org' => array(),
'net' => array(),
'co' => array(),
'nom' => array()),
'ai' => array('off' => array(),
'com' => array(),
'net' => array(),
'org' => array()),
'al' => array('com' => array(),
'edu' => array(),
'gov' => array(),
'mil' => array(),
'net' => array(),
'org' => array()),
'am' => array(),
'an' => array('com' => array(),
'net' => array(),
'org' => array(),
'edu' => array()),
'ao' => array('ed' => array(),
'gv' => array(),
'og' => array(),
'co' => array(),
'pb' => array(),
'it' => array()),
'aq' => array(),
'ar' => array('*' => array(),
'congresodelalengua3' => array('!' => ''),
'educ' => array('!' => ''),
'gobiernoelectronico' => array('!' => ''),
'mecon' => array('!' => ''),
'nacion' => array('!' => ''),
'nic' => array('!' => ''),
'promocion' => array('!' => ''),
'retina' => array('!' => ''),
'uba' => array('!' => '')),
'arpa' => array('e164' => array(),
'in-addr' => array(),
'ip6' => array(),
'iris' => array(),
'uri' => array(),
'urn' => array()),
'as' => array('gov' => array()),
'asia' => array(),
'at' => array('ac' => array(),
'co' => array(),
'gv' => array(),
'or' => array(),
'biz' => array(),
'info' => array(),
'priv' => array()),
'au' => array('*' => array(),
'edu' => array('act' => array(),
'nsw' => array(),
'nt' => array(),
'qld' => array(),
'sa' => array(),
'tas' => array(),
'vic' => array(),
'wa' => array()),
'gov' => array('act' => array(),
'nt' => array(),
'qld' => array(),
'sa' => array(),
'tas' => array(),
'vic' => array(),
'wa' => array()),
'act' => array(),
'nsw' => array(),
'nt' => array(),
'qld' => array(),
'sa' => array(),
'tas' => array(),
'vic' => array(),
'wa' => array()),
'aw' => array('com' => array()),
'ax' => array(),
'az' => array('com' => array(),
'net' => array(),
'int' => array(),
'gov' => array(),
'org' => array(),
'edu' => array(),
'info' => array(),
'pp' => array(),
'mil' => array(),
'name' => array(),
'pro' => array(),
'biz' => array()),
'ba' => array('org' => array(),
'net' => array(),
'edu' => array(),
'gov' => array(),
'mil' => array(),
'unsa' => array(),
'unbi' => array(),
'co' => array(),
'com' => array(),
'rs' => array()),
'bb' => array('biz' => array(),
'com' => array(),
'edu' => array(),
'gov' => array(),
'info' => array(),
'net' => array(),
'org' => array(),
'store' => array()),
'bd' => array('*' => array()),
'be' => array('ac' => array()),
'bf' => array('gov' => array()),
'bg' => array('a' => array(),
'b' => array(),
'c' => array(),
'd' => array(),
'e' => array(),
'f' => array(),
'g' => array(),
'h' => array(),
'i' => array(),
'j' => array(),
'k' => array(),
'l' => array(),
'm' => array(),
'n' => array(),
'o' => array(),
'p' => array(),
'q' => array(),
'r' => array(),
's' => array(),
't' => array(),
'u' => array(),
'v' => array(),
'w' => array(),
'x' => array(),
'y' => array(),
'z' => array(),
'0' => array(),
'1' => array(),
'2' => array(),
'3' => array(),
'4' => array(),
'5' => array(),
'6' => array(),
'7' => array(),
'8' => array(),
'9' => array()),
'bh' => array('com' => array(),
'edu' => array(),
'net' => array(),
'org' => array(),
'gov' => array()),
'bi' => array('co' => array(),
'com' => array(),
'edu' => array(),
'or' => array(),
'org' => array()),
'biz' => array(),
'bj' => array('asso' => array(),
'barreau' => array(),
'gouv' => array()),
'bm' => array('com' => array(),
'edu' => array(),
'gov' => array(),
'net' => array(),
'org' => array()),
'bn' => array('*' => array()),
'bo' => array('com' => array(),
'edu' => array(),
'gov' => array(),
'gob' => array(),
'int' => array(),
'org' => array(),
'net' => array(),
'mil' => array(),
'tv' => array()),
'br' => array('adm' => array(),
'adv' => array(),
'agr' => array(),
'am' => array(),
'arq' => array(),
'art' => array(),
'ato' => array(),
'bio' => array(),
'blog' => array(),
'bmd' => array(),
'can' => array(),
'cim' => array(),
'cng' => array(),
'cnt' => array(),
'com' => array(),
'coop' => array(),
'ecn' => array(),
'edu' => array(),
'eng' => array(),
'esp' => array(),
'etc' => array(),
'eti' => array(),
'far' => array(),
'flog' => array(),
'fm' => array(),
'fnd' => array(),
'fot' => array(),
'fst' => array(),
'g12' => array(),
'ggf' => array(),
'gov' => array(),
'imb' => array(),
'ind' => array(),
'inf' => array(),
'jor' => array(),
'jus' => array(),
'lel' => array(),
'mat' => array(),
'med' => array(),
'mil' => array(),
'mus' => array(),
'net' => array(),
'nom' => array(),
'not' => array(),
'ntr' => array(),
'odo' => array(),
'org' => array(),
'ppg' => array(),
'pro' => array(),
'psc' => array(),
'psi' => array(),
'qsl' => array(),
'rec' => array(),
'slg' => array(),
'srv' => array(),
'tmp' => array(),
'trd' => array(),
'tur' => array(),
'tv' => array(),
'vet' => array(),
'vlog' => array(),
'wiki' => array(),
'zlg' => array()),
'bs' => array('com' => array(),
'net' => array(),
'org' => array(),
'edu' => array(),
'gov' => array()),
'bt' => array('com' => array(),
'edu' => array(),
'gov' => array(),
'net' => array(),
'org' => array()),
'bw' => array('co' => array(),
'org' => array()),
'by' => array('gov' => array(),
'mil' => array(),
'com' => array(),
'of' => array()),
'bz' => array('com' => array(),
'net' => array(),
'org' => array(),
'edu' => array(),
'gov' => array()),
'ca' => array('ab' => array(),
'bc' => array(),
'mb' => array(),
'nb' => array(),
'nf' => array(),
'nl' => array(),
'ns' => array(),
'nt' => array(),
'nu' => array(),
'on' => array(),
'pe' => array(),
'qc' => array(),
'sk' => array(),
'yk' => array(),
'gc' => array()),
'cat' => array(),
'cc' => array(),
'cd' => array('gov' => array()),
'cf' => array(),
'cg' => array(),
'ch' => array(),
'ci' => array('org' => array(),
'or' => array(),
'com' => array(),
'co' => array(),
'edu' => array(),
'ed' => array(),
'ac' => array(),
'net' => array(),
'go' => array(),
'asso' => array(),
'aéroport' => array(),
'int' => array(),
'presse' => array(),
'md' => array(),
'gouv' => array()),
'ck' => array('*' => array()),
'cl' => array('gov' => array(),
'gob' => array()),
'cm' => array('gov' => array()),
'cn' => array('ac' => array(),
'com' => array(),
'edu' => array(),
'gov' => array(),
'net' => array(),
'org' => array(),
'mil' => array(),
'公司' => array(),
'网络' => array(),
'網絡' => array(),
'ah' => array(),
'bj' => array(),
'cq' => array(),
'fj' => array(),
'gd' => array(),
'gs' => array(),
'gz' => array(),
'gx' => array(),
'ha' => array(),
'hb' => array(),
'he' => array(),
'hi' => array(),
'hl' => array(),
'hn' => array(),
'jl' => array(),
'js' => array(),
'jx' => array(),
'ln' => array(),
'nm' => array(),
'nx' => array(),
'qh' => array(),
'sc' => array(),
'sd' => array(),
'sh' => array(),
'sn' => array(),
'sx' => array(),
'tj' => array(),
'xj' => array(),
'xz' => array(),
'yn' => array(),
'zj' => array(),
'hk' => array(),
'mo' => array(),
'tw' => array()),
'co' => array('arts' => array(),
'com' => array(),
'edu' => array(),
'firm' => array(),
'gov' => array(),
'info' => array(),
'int' => array(),
'mil' => array(),
'net' => array(),
'nom' => array(),
'org' => array(),
'rec' => array(),
'web' => array()),
'com' => array('ar' => array(),
'br' => array(),
'cn' => array(),
'de' => array(),
'eu' => array(),
'gb' => array(),
'hu' => array(),
'jpn' => array(),
'kr' => array(),
'no' => array(),
'qc' => array(),
'ru' => array(),
'sa' => array(),
'se' => array(),
'uk' => array(),
'us' => array(),
'uy' => array(),
'za' => array(),
'operaunite' => array(),
'appspot' => array()),
'coop' => array(),
'cr' => array('ac' => array(),
'co' => array(),
'ed' => array(),
'fi' => array(),
'go' => array(),
'or' => array(),
'sa' => array()),
'cu' => array('com' => array(),
'edu' => array(),
'org' => array(),
'net' => array(),
'gov' => array(),
'inf' => array()),
'cv' => array(),
'cx' => array('gov' => array()),
'cy' => array('*' => array()),
'cz' => array(),
'de' => array(),
'dj' => array(),
'dk' => array(),
'dm' => array('com' => array(),
'net' => array(),
'org' => array(),
'edu' => array(),
'gov' => array()),
'do' => array('*' => array()),
'dz' => array('com' => array(),
'org' => array(),
'net' => array(),
'gov' => array(),
'edu' => array(),
'asso' => array(),
'pol' => array(),
'art' => array()),
'ec' => array('com' => array(),
'info' => array(),
'net' => array(),
'fin' => array(),
'k12' => array(),
'med' => array(),
'pro' => array(),
'org' => array(),
'edu' => array(),
'gov' => array(),
'gob' => array(),
'mil' => array()),
'edu' => array(),
'ee' => array('edu' => array(),
'gov' => array(),
'riik' => array(),
'lib' => array(),
'med' => array(),
'com' => array(),
'pri' => array(),
'aip' => array(),
'org' => array(),
'fie' => array()),
'eg' => array('*' => array()),
'er' => array('*' => array()),
'es' => array('com' => array(),
'nom' => array(),
'org' => array(),
'gob' => array(),
'edu' => array()),
'et' => array('*' => array()),
'eu' => array(),
'fi' => array('aland' => array(),
'iki' => array()),
'fj' => array('*' => array()),
'fk' => array('*' => array()),
'fm' => array(),
'fo' => array(),
'fr' => array('com' => array(),
'asso' => array(),
'nom' => array(),
'prd' => array(),
'presse' => array(),
'tm' => array(),
'aeroport' => array(),
'assedic' => array(),
'avocat' => array(),
'avoues' => array(),
'cci' => array(),
'chambagri' => array(),
'chirurgiens-dentistes' => array(),
'experts-comptables' => array(),
'geometre-expert' => array(),
'gouv' => array(),
'greta' => array(),
'huissier-justice' => array(),
'medecin' => array(),
'notaires' => array(),
'pharmacien' => array(),
'port' => array(),
'veterinaire' => array()),
'ga' => array(),
'gd' => array(),
'ge' => array('com' => array(),
'edu' => array(),
'gov' => array(),
'org' => array(),
'mil' => array(),
'net' => array(),
'pvt' => array()),
'gf' => array(),
'gg' => array('co' => array(),
'org' => array(),
'net' => array(),
'sch' => array(),
'gov' => array()),
'gh' => array('com' => array(),
'edu' => array(),
'gov' => array(),
'org' => array(),
'mil' => array()),
'gi' => array('com' => array(),
'ltd' => array(),
'gov' => array(),
'mod' => array(),
'edu' => array(),
'org' => array()),
'gl' => array(),
'gm' => array(),
'gn' => array('ac' => array(),
'com' => array(),
'edu' => array(),
'gov' => array(),
'org' => array(),
'net' => array()),
'gov' => array(),
'gp' => array('com' => array(),
'net' => array(),
'mobi' => array(),
'edu' => array(),
'org' => array(),
'asso' => array()),
'gq' => array(),
'gr' => array('com' => array(),
'edu' => array(),
'net' => array(),
'org' => array(),
'gov' => array()),
'gs' => array(),
'gt' => array('*' => array()),
'gu' => array('*' => array()),
'gw' => array(),
'gy' => array('co' => array(),
'com' => array(),
'net' => array()),
'hk' => array('com' => array(),
'edu' => array(),
'gov' => array(),
'idv' => array(),
'net' => array(),
'org' => array(),
'公司' => array(),
'教育' => array(),
'敎育' => array(),
'政府' => array(),
'個人' => array(),
'个人' => array(),
'箇人' => array(),
'網络' => array(),
'网络' => array(),
'组織' => array(),
'網絡' => array(),
'网絡' => array(),
'组织' => array(),
'組織' => array(),
'組织' => array()),
'hm' => array(),
'hn' => array('com' => array(),
'edu' => array(),
'org' => array(),
'net' => array(),
'mil' => array(),
'gob' => array()),
'hr' => array('iz' => array(),
'from' => array(),
'name' => array(),
'com' => array()),
'ht' => array('com' => array(),
'shop' => array(),
'firm' => array(),
'info' => array(),
'adult' => array(),
'net' => array(),
'pro' => array(),
'org' => array(),
'med' => array(),
'art' => array(),
'coop' => array(),
'pol' => array(),
'asso' => array(),
'edu' => array(),
'rel' => array(),
'gouv' => array(),
'perso' => array()),
'hu' => array('co' => array(),
'info' => array(),
'org' => array(),
'priv' => array(),
'sport' => array(),
'tm' => array(),
'2000' => array(),
'agrar' => array(),
'bolt' => array(),
'casino' => array(),
'city' => array(),
'erotica' => array(),
'erotika' => array(),
'film' => array(),
'forum' => array(),
'games' => array(),
'hotel' => array(),
'ingatlan' => array(),
'jogasz' => array(),
'konyvelo' => array(),
'lakas' => array(),
'media' => array(),
'news' => array(),
'reklam' => array(),
'sex' => array(),
'shop' => array(),
'suli' => array(),
'szex' => array(),
'tozsde' => array(),
'utazas' => array(),
'video' => array()),
'id' => array('ac' => array(),
'co' => array(),
'go' => array(),
'mil' => array(),
'net' => array(),
'or' => array(),
'sch' => array(),
'web' => array()),
'ie' => array('gov' => array()),
'il' => array('*' => array()),
'im' => array('co' => array('ltd' => array(),
'plc' => array()),
'net' => array(),
'gov' => array(),
'org' => array(),
'nic' => array(),
'ac' => array()),
'in' => array('co' => array(),
'firm' => array(),
'net' => array(),
'org' => array(),
'gen' => array(),
'ind' => array(),
'nic' => array(),
'ac' => array(),
'edu' => array(),
'res' => array(),
'gov' => array(),
'mil' => array()),
'info' => array(),
'int' => array('eu' => array()),
'io' => array('com' => array()),
'iq' => array('gov' => array(),
'edu' => array(),
'mil' => array(),
'com' => array(),
'org' => array(),
'net' => array()),
'ir' => array('ac' => array(),
'co' => array(),
'gov' => array(),
'id' => array(),
'net' => array(),
'org' => array(),
'sch' => array(),
'ایران' => array(),
'ايران' => array()),
'is' => array('net' => array(),
'com' => array(),
'edu' => array(),
'gov' => array(),
'org' => array(),
'int' => array()),
'it' => array('gov' => array(),
'edu' => array(),
'agrigento' => array(),
'ag' => array(),
'alessandria' => array(),
'al' => array(),
'ancona' => array(),
'an' => array(),
'aosta' => array(),
'aoste' => array(),
'ao' => array(),
'arezzo' => array(),
'ar' => array(),
'ascoli-piceno' => array(),
'ascolipiceno' => array(),
'ap' => array(),
'asti' => array(),
'at' => array(),
'avellino' => array(),
'av' => array(),
'bari' => array(),
'ba' => array(),
'andria-barletta-trani' => array(),
'andriabarlettatrani' => array(),
'trani-barletta-andria' => array(),
'tranibarlettaandria' => array(),
'barletta-trani-andria' => array(),
'barlettatraniandria' => array(),
'andria-trani-barletta' => array(),
'andriatranibarletta' => array(),
'trani-andria-barletta' => array(),
'traniandriabarletta' => array(),
'bt' => array(),
'belluno' => array(),
'bl' => array(),
'benevento' => array(),
'bn' => array(),
'bergamo' => array(),
'bg' => array(),
'biella' => array(),
'bi' => array(),
'bologna' => array(),
'bo' => array(),
'bolzano' => array(),
'bozen' => array(),
'balsan' => array(),
'alto-adige' => array(),
'altoadige' => array(),
'suedtirol' => array(),
'bz' => array(),
'brescia' => array(),
'bs' => array(),
'brindisi' => array(),
'br' => array(),
'cagliari' => array(),
'ca' => array(),
'caltanissetta' => array(),
'cl' => array(),
'campobasso' => array(),
'cb' => array(),
'carboniaiglesias' => array(),
'carbonia-iglesias' => array(),
'iglesias-carbonia' => array(),
'iglesiascarbonia' => array(),
'ci' => array(),
'caserta' => array(),
'ce' => array(),
'catania' => array(),
'ct' => array(),
'catanzaro' => array(),
'cz' => array(),
'chieti' => array(),
'ch' => array(),
'como' => array(),
'co' => array(),
'cosenza' => array(),
'cs' => array(),
'cremona' => array(),
'cr' => array(),
'crotone' => array(),
'kr' => array(),
'cuneo' => array(),
'cn' => array(),
'dell-ogliastra' => array(),
'dellogliastra' => array(),
'ogliastra' => array(),
'og' => array(),
'enna' => array(),
'en' => array(),
'ferrara' => array(),
'fe' => array(),
'fermo' => array(),
'fm' => array(),
'firenze' => array(),
'florence' => array(),
'fi' => array(),
'foggia' => array(),
'fg' => array(),
'forli-cesena' => array(),
'forlicesena' => array(),
'cesena-forli' => array(),
'cesenaforli' => array(),
'fc' => array(),
'frosinone' => array(),
'fr' => array(),
'genova' => array(),
'genoa' => array(),
'ge' => array(),
'gorizia' => array(),
'go' => array(),
'grosseto' => array(),
'gr' => array(),
'imperia' => array(),
'im' => array(),
'isernia' => array(),
'is' => array(),
'laquila' => array(),
'aquila' => array(),
'aq' => array(),
'la-spezia' => array(),
'laspezia' => array(),
'sp' => array(),
'latina' => array(),
'lt' => array(),
'lecce' => array(),
'le' => array(),
'lecco' => array(),
'lc' => array(),
'livorno' => array(),
'li' => array(),
'lodi' => array(),
'lo' => array(),
'lucca' => array(),
'lu' => array(),
'macerata' => array(),
'mc' => array(),
'mantova' => array(),
'mn' => array(),
'massa-carrara' => array(),
'massacarrara' => array(),
'carrara-massa' => array(),
'carraramassa' => array(),
'ms' => array(),
'matera' => array(),
'mt' => array(),
'medio-campidano' => array(),
'mediocampidano' => array(),
'campidano-medio' => array(),
'campidanomedio' => array(),
'vs' => array(),
'messina' => array(),
'me' => array(),
'milano' => array(),
'milan' => array(),
'mi' => array(),
'modena' => array(),
'mo' => array(),
'monza' => array(),
'monza-brianza' => array(),
'monzabrianza' => array(),
'monzaebrianza' => array(),
'monzaedellabrianza' => array(),
'monza-e-della-brianza' => array(),
'mb' => array(),
'napoli' => array(),
'naples' => array(),
'na' => array(),
'novara' => array(),
'no' => array(),
'nuoro' => array(),
'nu' => array(),
'oristano' => array(),
'or' => array(),
'padova' => array(),
'padua' => array(),
'pd' => array(),
'palermo' => array(),
'pa' => array(),
'parma' => array(),
'pr' => array(),
'pavia' => array(),
'pv' => array(),
'perugia' => array(),
'pg' => array(),
'pescara' => array(),
'pe' => array(),
'pesaro-urbino' => array(),
'pesarourbino' => array(),
'urbino-pesaro' => array(),
'urbinopesaro' => array(),
'pu' => array(),
'piacenza' => array(),
'pc' => array(),
'pisa' => array(),
'pi' => array(),
'pistoia' => array(),
'pt' => array(),
'pordenone' => array(),
'pn' => array(),
'potenza' => array(),
'pz' => array(),
'prato' => array(),
'po' => array(),
'ragusa' => array(),
'rg' => array(),
'ravenna' => array(),
'ra' => array(),
'reggio-calabria' => array(),
'reggiocalabria' => array(),
'rc' => array(),
'reggio-emilia' => array(),
'reggioemilia' => array(),
're' => array(),
'rieti' => array(),
'ri' => array(),
'rimini' => array(),
'rn' => array(),
'roma' => array(),
'rome' => array(),
'rm' => array(),
'rovigo' => array(),
'ro' => array(),
'salerno' => array(),
'sa' => array(),
'sassari' => array(),
'ss' => array(),
'savona' => array(),
'sv' => array(),
'siena' => array(),
'si' => array(),
'siracusa' => array(),
'sr' => array(),
'sondrio' => array(),
'so' => array(),
'taranto' => array(),
'ta' => array(),
'tempio-olbia' => array(),
'tempioolbia' => array(),
'olbia-tempio' => array(),
'olbiatempio' => array(),
'ot' => array(),
'teramo' => array(),
'te' => array(),
'terni' => array(),
'tr' => array(),
'torino' => array(),
'turin' => array(),
'to' => array(),
'trapani' => array(),
'tp' => array(),
'trento' => array(),
'trentino' => array(),
'tn' => array(),
'treviso' => array(),
'tv' => array(),
'trieste' => array(),
'ts' => array(),
'udine' => array(),
'ud' => array(),
'varese' => array(),
'va' => array(),
'venezia' => array(),
'venice' => array(),
've' => array(),
'verbania' => array(),
'vb' => array(),
'vercelli' => array(),
'vc' => array(),
'verona' => array(),
'vr' => array(),
'vibo-valentia' => array(),
'vibovalentia' => array(),
'vv' => array(),
'vicenza' => array(),
'vi' => array(),
'viterbo' => array(),
'vt' => array()),
'je' => array('co' => array(),
'org' => array(),
'net' => array(),
'sch' => array(),
'gov' => array()),
'jm' => array('*' => array()),
'jo' => array('com' => array(),
'org' => array(),
'net' => array(),
'edu' => array(),
'sch' => array(),
'gov' => array(),
'mil' => array(),
'name' => array()),
'jobs' => array(),
'jp' => array('ac' => array(),
'ad' => array(),
'co' => array(),
'ed' => array(),
'go' => array(),
'gr' => array(),
'lg' => array(),
'ne' => array(),
'or' => array(),
'aichi' => array('*' => array(),
'pref' => array('!' => '')),
'akita' => array('*' => array(),
'pref' => array('!' => '')),
'aomori' => array('*' => array(),
'pref' => array('!' => '')),
'chiba' => array('*' => array(),
'pref' => array('!' => ''),
'city' => array('!' => '')),
'ehime' => array('*' => array(),
'pref' => array('!' => '')),
'fukui' => array('*' => array(),
'pref' => array('!' => '')),
'fukuoka' => array('*' => array(),
'pref' => array('!' => ''),
'city' => array('!' => '')),
'fukushima' => array('*' => array(),
'pref' => array('!' => '')),
'gifu' => array('*' => array(),
'pref' => array('!' => '')),
'gunma' => array('*' => array(),
'pref' => array('!' => '')),
'hiroshima' => array('*' => array(),
'pref' => array('!' => ''),
'city' => array('!' => '')),
'hokkaido' => array('*' => array(),
'pref' => array('!' => '')),
'hyogo' => array('*' => array(),
'pref' => array('!' => '')),
'ibaraki' => array('*' => array(),
'pref' => array('!' => '')),
'ishikawa' => array('*' => array(),
'pref' => array('!' => '')),
'iwate' => array('*' => array(),
'pref' => array('!' => '')),
'kagawa' => array('*' => array(),
'pref' => array('!' => '')),
'kagoshima' => array('*' => array(),
'pref' => array('!' => '')),
'kanagawa' => array('*' => array(),
'pref' => array('!' => '')),
'kawasaki' => array('*' => array(),
'city' => array('!' => '')),
'kitakyushu' => array('*' => array(),
'city' => array('!' => '')),
'kobe' => array('*' => array(),
'city' => array('!' => '')),
'kochi' => array('*' => array(),
'pref' => array('!' => '')),
'kumamoto' => array('*' => array(),
'pref' => array('!' => '')),
'kyoto' => array('*' => array(),
'pref' => array('!' => ''),
'city' => array('!' => '')),
'mie' => array('*' => array(),
'pref' => array('!' => '')),
'miyagi' => array('*' => array(),
'pref' => array('!' => '')),
'miyazaki' => array('*' => array(),
'pref' => array('!' => '')),
'nagano' => array('*' => array(),
'pref' => array('!' => '')),
'nagasaki' => array('*' => array(),
'pref' => array('!' => '')),
'nagoya' => array('*' => array(),
'city' => array('!' => '')),
'nara' => array('*' => array(),
'pref' => array('!' => '')),
'niigata' => array('*' => array(),
'pref' => array('!' => ''),
'city' => array('!' => '')),
'oita' => array('*' => array(),
'pref' => array('!' => '')),
'okayama' => array('*' => array(),
'pref' => array('!' => ''),
'city' => array('!' => '')),
'okinawa' => array('*' => array(),
'pref' => array('!' => '')),
'osaka' => array('*' => array(),
'pref' => array('!' => ''),
'city' => array('!' => '')),
'saga' => array('*' => array(),
'pref' => array('!' => '')),
'saitama' => array('*' => array(),
'pref' => array('!' => ''),
'city' => array('!' => '')),
'sapporo' => array('*' => array(),
'city' => array('!' => '')),
'sendai' => array('*' => array(),
'city' => array('!' => '')),
'shiga' => array('*' => array(),
'pref' => array('!' => '')),
'shimane' => array('*' => array(),
'pref' => array('!' => '')),
'shizuoka' => array('*' => array(),
'pref' => array('!' => ''),
'city' => array('!' => '')),
'tochigi' => array('*' => array(),
'pref' => array('!' => '')),
'tokushima' => array('*' => array(),
'pref' => array('!' => '')),
'tokyo' => array('*' => array(),
'metro' => array('!' => '')),
'tottori' => array('*' => array(),
'pref' => array('!' => '')),
'toyama' => array('*' => array(),
'pref' => array('!' => '')),
'wakayama' => array('*' => array(),
'pref' => array('!' => '')),
'yamagata' => array('*' => array(),
'pref' => array('!' => '')),
'yamaguchi' => array('*' => array(),
'pref' => array('!' => '')),
'yamanashi' => array('*' => array(),
'pref' => array('!' => '')),
'yokohama' => array('*' => array(),
'city' => array('!' => ''))),
'ke' => array('*' => array()),
'kg' => array('org' => array(),
'net' => array(),
'com' => array(),
'edu' => array(),
'gov' => array(),
'mil' => array()),
'kh' => array('*' => array()),
'ki' => array('edu' => array(),
'biz' => array(),
'net' => array(),
'org' => array(),
'gov' => array(),
'info' => array(),
'com' => array()),
'km' => array('org' => array(),
'nom' => array(),
'gov' => array(),
'prd' => array(),
'tm' => array(),
'edu' => array(),
'mil' => array(),
'ass' => array(),
'com' => array(),
'coop' => array(),
'asso' => array(),
'presse' => array(),
'medecin' => array(),
'notaires' => array(),
'pharmaciens' => array(),
'veterinaire' => array(),
'gouv' => array()),
'kn' => array('net' => array(),
'org' => array(),
'edu' => array(),
'gov' => array()),
'kp' => array('com' => array(),
'edu' => array(),
'gov' => array(),
'org' => array(),
'rep' => array(),
'tra' => array()),
'kr' => array('ac' => array(),
'co' => array(),
'es' => array(),
'go' => array(),
'hs' => array(),
'kg' => array(),
'mil' => array(),
'ms' => array(),
'ne' => array(),
'or' => array(),
'pe' => array(),
're' => array(),
'sc' => array(),
'busan' => array(),
'chungbuk' => array(),
'chungnam' => array(),
'daegu' => array(),
'daejeon' => array(),
'gangwon' => array(),
'gwangju' => array(),
'gyeongbuk' => array(),
'gyeonggi' => array(),
'gyeongnam' => array(),
'incheon' => array(),
'jeju' => array(),
'jeonbuk' => array(),
'jeonnam' => array(),
'seoul' => array(),
'ulsan' => array()),
'kw' => array('*' => array()),
'ky' => array('edu' => array(),
'gov' => array(),
'com' => array(),
'org' => array(),
'net' => array()),
'kz' => array('org' => array(),
'edu' => array(),
'net' => array(),
'gov' => array(),
'mil' => array(),
'com' => array()),
'la' => array('int' => array(),
'net' => array(),
'info' => array(),
'edu' => array(),
'gov' => array(),
'per' => array(),
'com' => array(),
'org' => array(),
'c' => array()),
'lb' => array('com' => array(),
'edu' => array(),
'gov' => array(),
'net' => array(),
'org' => array()),
'lc' => array('com' => array(),
'net' => array(),
'co' => array(),
'org' => array(),
'edu' => array(),
'gov' => array()),
'li' => array(),
'lk' => array('gov' => array(),
'sch' => array(),
'net' => array(),
'int' => array(),
'com' => array(),
'org' => array(),
'edu' => array(),
'ngo' => array(),
'soc' => array(),
'web' => array(),
'ltd' => array(),
'assn' => array(),
'grp' => array(),
'hotel' => array()),
'local' => array(),
'lr' => array('com' => array(),
'edu' => array(),
'gov' => array(),
'org' => array(),
'net' => array()),
'ls' => array('co' => array(),
'org' => array()),
'lt' => array('gov' => array()),
'lu' => array(),
'lv' => array('com' => array(),
'edu' => array(),
'gov' => array(),
'org' => array(),
'mil' => array(),
'id' => array(),
'net' => array(),
'asn' => array(),
'conf' => array()),
'ly' => array('com' => array(),
'net' => array(),
'gov' => array(),
'plc' => array(),
'edu' => array(),
'sch' => array(),
'med' => array(),
'org' => array(),
'id' => array()),
'ma' => array('co' => array(),
'net' => array(),
'gov' => array(),
'org' => array(),
'ac' => array(),
'press' => array()),
'mc' => array('tm' => array(),
'asso' => array()),
'md' => array(),
'me' => array('co' => array(),
'net' => array(),
'org' => array(),
'edu' => array(),
'ac' => array(),
'gov' => array(),
'its' => array(),
'priv' => array()),
'mg' => array('org' => array(),
'nom' => array(),
'gov' => array(),
'prd' => array(),
'tm' => array(),
'edu' => array(),
'mil' => array(),
'com' => array()),
'mh' => array(),
'mil' => array(),
'mk' => array('com' => array(),
'org' => array(),
'net' => array(),
'edu' => array(),
'gov' => array(),
'inf' => array(),
'name' => array()),
'ml' => array('com' => array(),
'edu' => array(),
'gouv' => array(),
'gov' => array(),
'net' => array(),
'org' => array(),
'presse' => array()),
'mm' => array('*' => array()),
'mn' => array('gov' => array(),
'edu' => array(),
'org' => array()),
'mo' => array('com' => array(),
'net' => array(),
'org' => array(),
'edu' => array(),
'gov' => array()),
'mobi' => array(),
'mp' => array(),
'mq' => array(),
'mr' => array('gov' => array()),
'ms' => array(),
'mt' => array('*' => array()),
'mu' => array('com' => array(),
'net' => array(),
'org' => array(),
'gov' => array(),
'ac' => array(),
'co' => array(),
'or' => array()),
'museum' => array('academy' => array(),
'agriculture' => array(),
'air' => array(),
'airguard' => array(),
'alabama' => array(),
'alaska' => array(),
'amber' => array(),
'ambulance' => array(),
'american' => array(),
'americana' => array(),
'americanantiques' => array(),
'americanart' => array(),
'amsterdam' => array(),
'and' => array(),
'annefrank' => array(),
'anthro' => array(),
'anthropology' => array(),
'antiques' => array(),
'aquarium' => array(),
'arboretum' => array(),
'archaeological' => array(),
'archaeology' => array(),
'architecture' => array(),
'art' => array(),
'artanddesign' => array(),
'artcenter' => array(),
'artdeco' => array(),
'arteducation' => array(),
'artgallery' => array(),
'arts' => array(),
'artsandcrafts' => array(),
'asmatart' => array(),
'assassination' => array(),
'assisi' => array(),
'association' => array(),
'astronomy' => array(),
'atlanta' => array(),
'austin' => array(),
'australia' => array(),
'automotive' => array(),
'aviation' => array(),
'axis' => array(),
'badajoz' => array(),
'baghdad' => array(),
'bahn' => array(),
'bale' => array(),
'baltimore' => array(),
'barcelona' => array(),
'baseball' => array(),
'basel' => array(),
'baths' => array(),
'bauern' => array(),
'beauxarts' => array(),
'beeldengeluid' => array(),
'bellevue' => array(),
'bergbau' => array(),
'berkeley' => array(),
'berlin' => array(),
'bern' => array(),
'bible' => array(),
'bilbao' => array(),
'bill' => array(),
'birdart' => array(),
'birthplace' => array(),
'bonn' => array(),
'boston' => array(),
'botanical' => array(),
'botanicalgarden' => array(),
'botanicgarden' => array(),
'botany' => array(),
'brandywinevalley' => array(),
'brasil' => array(),
'bristol' => array(),
'british' => array(),
'britishcolumbia' => array(),
'broadcast' => array(),
'brunel' => array(),
'brussel' => array(),
'brussels' => array(),
'bruxelles' => array(),
'building' => array(),
'burghof' => array(),
'bus' => array(),
'bushey' => array(),
'cadaques' => array(),
'california' => array(),
'cambridge' => array(),
'can' => array(),
'canada' => array(),
'capebreton' => array(),
'carrier' => array(),
'cartoonart' => array(),
'casadelamoneda' => array(),
'castle' => array(),
'castres' => array(),
'celtic' => array(),
'center' => array(),
'chattanooga' => array(),
'cheltenham' => array(),
'chesapeakebay' => array(),
'chicago' => array(),
'children' => array(),
'childrens' => array(),
'childrensgarden' => array(),
'chiropractic' => array(),
'chocolate' => array(),
'christiansburg' => array(),
'cincinnati' => array(),
'cinema' => array(),
'circus' => array(),
'civilisation' => array(),
'civilization' => array(),
'civilwar' => array(),
'clinton' => array(),
'clock' => array(),
'coal' => array(),
'coastaldefence' => array(),
'cody' => array(),
'coldwar' => array(),
'collection' => array(),
'colonialwilliamsburg' => array(),
'coloradoplateau' => array(),
'columbia' => array(),
'columbus' => array(),
'communication' => array(),
'communications' => array(),
'community' => array(),
'computer' => array(),
'computerhistory' => array(),
'comunicações' => array(),
'contemporary' => array(),
'contemporaryart' => array(),
'convent' => array(),
'copenhagen' => array(),
'corporation' => array(),
'correios-e-telecomunicações' => array(),
'corvette' => array(),
'costume' => array(),
'countryestate' => array(),
'county' => array(),
'crafts' => array(),
'cranbrook' => array(),
'creation' => array(),
'cultural' => array(),
'culturalcenter' => array(),
'culture' => array(),
'cyber' => array(),
'cymru' => array(),
'dali' => array(),
'dallas' => array(),
'database' => array(),
'ddr' => array(),
'decorativearts' => array(),
'delaware' => array(),
'delmenhorst' => array(),
'denmark' => array(),
'depot' => array(),
'design' => array(),
'detroit' => array(),
'dinosaur' => array(),
'discovery' => array(),
'dolls' => array(),
'donostia' => array(),
'durham' => array(),
'eastafrica' => array(),
'eastcoast' => array(),
'education' => array(),
'educational' => array(),
'egyptian' => array(),
'eisenbahn' => array(),
'elburg' => array(),
'elvendrell' => array(),
'embroidery' => array(),
'encyclopedic' => array(),
'england' => array(),
'entomology' => array(),
'environment' => array(),
'environmentalconservation' => array(),
'epilepsy' => array(),
'essex' => array(),
'estate' => array(),
'ethnology' => array(),
'exeter' => array(),
'exhibition' => array(),
'family' => array(),
'farm' => array(),
'farmequipment' => array(),
'farmers' => array(),
'farmstead' => array(),
'field' => array(),
'figueres' => array(),
'filatelia' => array(),
'film' => array(),
'fineart' => array(),
'finearts' => array(),
'finland' => array(),
'flanders' => array(),
'florida' => array(),
'force' => array(),
'fortmissoula' => array(),
'fortworth' => array(),
'foundation' => array(),
'francaise' => array(),
'frankfurt' => array(),
'franziskaner' => array(),
'freemasonry' => array(),
'freiburg' => array(),
'fribourg' => array(),
'frog' => array(),
'fundacio' => array(),
'furniture' => array(),
'gallery' => array(),
'garden' => array(),
'gateway' => array(),
'geelvinck' => array(),
'gemological' => array(),
'geology' => array(),
'georgia' => array(),
'giessen' => array(),
'glas' => array(),
'glass' => array(),
'gorge' => array(),
'grandrapids' => array(),
'graz' => array(),
'guernsey' => array(),
'halloffame' => array(),
'hamburg' => array(),
'handson' => array(),
'harvestcelebration' => array(),
'hawaii' => array(),
'health' => array(),
'heimatunduhren' => array(),
'hellas' => array(),
'helsinki' => array(),
'hembygdsforbund' => array(),
'heritage' => array(),
'histoire' => array(),
'historical' => array(),
'historicalsociety' => array(),
'historichouses' => array(),
'historisch' => array(),
'historisches' => array(),
'history' => array(),
'historyofscience' => array(),
'horology' => array(),
'house' => array(),
'humanities' => array(),
'illustration' => array(),
'imageandsound' => array(),
'indian' => array(),
'indiana' => array(),
'indianapolis' => array(),
'indianmarket' => array(),
'intelligence' => array(),
'interactive' => array(),
'iraq' => array(),
'iron' => array(),
'isleofman' => array(),
'jamison' => array(),
'jefferson' => array(),
'jerusalem' => array(),
'jewelry' => array(),
'jewish' => array(),
'jewishart' => array(),
'jfk' => array(),
'journalism' => array(),
'judaica' => array(),
'judygarland' => array(),
'juedisches' => array(),
'juif' => array(),
'karate' => array(),
'karikatur' => array(),
'kids' => array(),
'koebenhavn' => array(),
'koeln' => array(),
'kunst' => array(),
'kunstsammlung' => array(),
'kunstunddesign' => array(),
'labor' => array(),
'labour' => array(),
'lajolla' => array(),
'lancashire' => array(),
'landes' => array(),
'lans' => array(),
'läns' => array(),
'larsson' => array(),
'lewismiller' => array(),
'lincoln' => array(),
'linz' => array(),
'living' => array(),
'livinghistory' => array(),
'localhistory' => array(),
'london' => array(),
'losangeles' => array(),
'louvre' => array(),
'loyalist' => array(),
'lucerne' => array(),
'luxembourg' => array(),
'luzern' => array(),
'mad' => array(),
'madrid' => array(),
'mallorca' => array(),
'manchester' => array(),
'mansion' => array(),
'mansions' => array(),
'manx' => array(),
'marburg' => array(),
'maritime' => array(),
'maritimo' => array(),
'maryland' => array(),
'marylhurst' => array(),
'media' => array(),
'medical' => array(),
'medizinhistorisches' => array(),
'meeres' => array(),
'memorial' => array(),
'mesaverde' => array(),
'michigan' => array(),
'midatlantic' => array(),
'military' => array(),
'mill' => array(),
'miners' => array(),
'mining' => array(),
'minnesota' => array(),
'missile' => array(),
'missoula' => array(),
'modern' => array(),
'moma' => array(),
'money' => array(),
'monmouth' => array(),
'monticello' => array(),
'montreal' => array(),
'moscow' => array(),
'motorcycle' => array(),
'muenchen' => array(),
'muenster' => array(),
'mulhouse' => array(),
'muncie' => array(),
'museet' => array(),
'museumcenter' => array(),
'museumvereniging' => array(),
'music' => array(),
'national' => array(),
'nationalfirearms' => array(),
'nationalheritage' => array(),
'nativeamerican' => array(),
'naturalhistory' => array(),
'naturalhistorymuseum' => array(),
'naturalsciences' => array(),
'nature' => array(),
'naturhistorisches' => array(),
'natuurwetenschappen' => array(),
'naumburg' => array(),
'naval' => array(),
'nebraska' => array(),
'neues' => array(),
'newhampshire' => array(),
'newjersey' => array(),
'newmexico' => array(),
'newport' => array(),
'newspaper' => array(),
'newyork' => array(),
'niepce' => array(),
'norfolk' => array(),
'north' => array(),
'nrw' => array(),
'nuernberg' => array(),
'nuremberg' => array(),
'nyc' => array(),
'nyny' => array(),
'oceanographic' => array(),
'oceanographique' => array(),
'omaha' => array(),
'online' => array(),
'ontario' => array(),
'openair' => array(),
'oregon' => array(),
'oregontrail' => array(),
'otago' => array(),
'oxford' => array(),
'pacific' => array(),
'paderborn' => array(),
'palace' => array(),
'paleo' => array(),
'palmsprings' => array(),
'panama' => array(),
'paris' => array(),
'pasadena' => array(),
'pharmacy' => array(),
'philadelphia' => array(),
'philadelphiaarea' => array(),
'philately' => array(),
'phoenix' => array(),
'photography' => array(),
'pilots' => array(),
'pittsburgh' => array(),
'planetarium' => array(),
'plantation' => array(),
'plants' => array(),
'plaza' => array(),
'portal' => array(),
'portland' => array(),
'portlligat' => array(),
'posts-and-telecommunications' => array(),
'preservation' => array(),
'presidio' => array(),
'press' => array(),
'project' => array(),
'public' => array(),
'pubol' => array(),
'quebec' => array(),
'railroad' => array(),
'railway' => array(),
'research' => array(),
'resistance' => array(),
'riodejaneiro' => array(),
'rochester' => array(),
'rockart' => array(),
'roma' => array(),
'russia' => array(),
'saintlouis' => array(),
'salem' => array(),
'salvadordali' => array(),
'salzburg' => array(),
'sandiego' => array(),
'sanfrancisco' => array(),
'santabarbara' => array(),
'santacruz' => array(),
'santafe' => array(),
'saskatchewan' => array(),
'satx' => array(),
'savannahga' => array(),
'schlesisches' => array(),
'schoenbrunn' => array(),
'schokoladen' => array(),
'school' => array(),
'schweiz' => array(),
'science' => array(),
'scienceandhistory' => array(),
'scienceandindustry' => array(),
'sciencecenter' => array(),
'sciencecenters' => array(),
'science-fiction' => array(),
'sciencehistory' => array(),
'sciences' => array(),
'sciencesnaturelles' => array(),
'scotland' => array(),
'seaport' => array(),
'settlement' => array(),
'settlers' => array(),
'shell' => array(),
'sherbrooke' => array(),
'sibenik' => array(),
'silk' => array(),
'ski' => array(),
'skole' => array(),
'society' => array(),
'sologne' => array(),
'soundandvision' => array(),
'southcarolina' => array(),
'southwest' => array(),
'space' => array(),
'spy' => array(),
'square' => array(),
'stadt' => array(),
'stalbans' => array(),
'starnberg' => array(),
'state' => array(),
'stateofdelaware' => array(),
'station' => array(),
'steam' => array(),
'steiermark' => array(),
'stjohn' => array(),
'stockholm' => array(),
'stpetersburg' => array(),
'stuttgart' => array(),
'suisse' => array(),
'surgeonshall' => array(),
'surrey' => array(),
'svizzera' => array(),
'sweden' => array(),
'sydney' => array(),
'tank' => array(),
'tcm' => array(),
'technology' => array(),
'telekommunikation' => array(),
'television' => array(),
'texas' => array(),
'textile' => array(),
'theater' => array(),
'time' => array(),
'timekeeping' => array(),
'topology' => array(),
'torino' => array(),
'touch' => array(),
'town' => array(),
'transport' => array(),
'tree' => array(),
'trolley' => array(),
'trust' => array(),
'trustee' => array(),
'uhren' => array(),
'ulm' => array(),
'undersea' => array(),
'university' => array(),
'usa' => array(),
'usantiques' => array(),
'usarts' => array(),
'uscountryestate' => array(),
'usculture' => array(),
'usdecorativearts' => array(),
'usgarden' => array(),
'ushistory' => array(),
'ushuaia' => array(),
'uslivinghistory' => array(),
'utah' => array(),
'uvic' => array(),
'valley' => array(),
'vantaa' => array(),
'versailles' => array(),
'viking' => array(),
'village' => array(),
'virginia' => array(),
'virtual' => array(),
'virtuel' => array(),
'vlaanderen' => array(),
'volkenkunde' => array(),
'wales' => array(),
'wallonie' => array(),
'war' => array(),
'washingtondc' => array(),
'watchandclock' => array(),
'watch-and-clock' => array(),
'western' => array(),
'westfalen' => array(),
'whaling' => array(),
'wildlife' => array(),
'williamsburg' => array(),
'windmill' => array(),
'workshop' => array(),
'york' => array(),
'yorkshire' => array(),
'yosemite' => array(),
'youth' => array(),
'zoological' => array(),
'zoology' => array(),
'ירושלים' => array(),
'иком' => array()),
'mv' => array('aero' => array(),
'biz' => array(),
'com' => array(),
'coop' => array(),
'edu' => array(),
'gov' => array(),
'info' => array(),
'int' => array(),
'mil' => array(),
'museum' => array(),
'name' => array(),
'net' => array(),
'org' => array(),
'pro' => array()),
'mw' => array('ac' => array(),
'biz' => array(),
'co' => array(),
'com' => array(),
'coop' => array(),
'edu' => array(),
'gov' => array(),
'int' => array(),
'museum' => array(),
'net' => array(),
'org' => array()),
'mx' => array('com' => array(),
'org' => array(),
'gob' => array(),
'edu' => array(),
'net' => array()),
'my' => array('com' => array(),
'net' => array(),
'org' => array(),
'gov' => array(),
'edu' => array(),
'mil' => array(),
'name' => array()),
'mz' => array('*' => array()),
'na' => array('info' => array(),
'pro' => array(),
'name' => array(),
'school' => array(),
'or' => array(),
'dr' => array(),
'us' => array(),
'mx' => array(),
'ca' => array(),
'in' => array(),
'cc' => array(),
'tv' => array(),
'ws' => array(),
'mobi' => array(),
'co' => array(),
'com' => array(),
'org' => array()),
'name' => array(),
'nc' => array('asso' => array()),
'ne' => array(),
'net' => array('gb' => array(),
'se' => array(),
'uk' => array(),
'za' => array()),
'nf' => array('com' => array(),
'net' => array(),
'per' => array(),
'rec' => array(),
'web' => array(),
'arts' => array(),
'firm' => array(),
'info' => array(),
'other' => array(),
'store' => array()),
'ng' => array('ac' => array(),
'com' => array(),
'edu' => array(),
'gov' => array(),
'net' => array(),
'org' => array()),
'ni' => array('*' => array()),
'nl' => array('bv' => array()),
'no' => array('fhs' => array(),
'vgs' => array(),
'fylkesbibl' => array(),
'folkebibl' => array(),
'museum' => array(),
'idrett' => array(),
'priv' => array(),
'mil' => array(),
'stat' => array(),
'dep' => array(),
'kommune' => array(),
'herad' => array(),
'aa' => array('gs' => array()),
'ah' => array('gs' => array()),
'bu' => array('gs' => array()),
'fm' => array('gs' => array()),
'hl' => array('gs' => array()),
'hm' => array('gs' => array()),
'jan-mayen' => array('gs' => array()),
'mr' => array('gs' => array()),
'nl' => array('gs' => array()),
'nt' => array('gs' => array()),
'of' => array('gs' => array()),
'ol' => array('gs' => array()),
'oslo' => array('gs' => array()),
'rl' => array('gs' => array()),
'sf' => array('gs' => array()),
'st' => array('gs' => array()),
'svalbard' => array('gs' => array()),
'tm' => array('gs' => array()),
'tr' => array('gs' => array()),
'va' => array('gs' => array()),
'vf' => array('gs' => array()),
'akrehamn' => array(),
'åkrehamn' => array(),
'algard' => array(),
'ålgård' => array(),
'arna' => array(),
'brumunddal' => array(),
'bryne' => array(),
'bronnoysund' => array(),
'brønnøysund' => array(),
'drobak' => array(),
'drøbak' => array(),
'egersund' => array(),
'fetsund' => array(),
'floro' => array(),
'florø' => array(),
'fredrikstad' => array(),
'hokksund' => array(),
'honefoss' => array(),
'hønefoss' => array(),
'jessheim' => array(),
'jorpeland' => array(),
'jørpeland' => array(),
'kirkenes' => array(),
'kopervik' => array(),
'krokstadelva' => array(),
'langevag' => array(),
'langevåg' => array(),
'leirvik' => array(),
'mjondalen' => array(),
'mjøndalen' => array(),
'mo-i-rana' => array(),
'mosjoen' => array(),
'mosjøen' => array(),
'nesoddtangen' => array(),
'orkanger' => array(),
'osoyro' => array(),
'osøyro' => array(),
'raholt' => array(),
'råholt' => array(),
'sandnessjoen' => array(),
'sandnessjøen' => array(),
'skedsmokorset' => array(),
'slattum' => array(),
'spjelkavik' => array(),
'stathelle' => array(),
'stavern' => array(),
'stjordalshalsen' => array(),
'stjørdalshalsen' => array(),
'tananger' => array(),
'tranby' => array(),
'vossevangen' => array(),
'afjord' => array(),
'åfjord' => array(),
'agdenes' => array(),
'al' => array(),
'ål' => array(),
'alesund' => array(),
'ålesund' => array(),
'alstahaug' => array(),
'alta' => array(),
'áltá' => array(),
'alaheadju' => array(),
'álaheadju' => array(),
'alvdal' => array(),
'amli' => array(),
'åmli' => array(),
'amot' => array(),
'åmot' => array(),
'andebu' => array(),
'andoy' => array(),
'andøy' => array(),
'andasuolo' => array(),
'ardal' => array(),
'årdal' => array(),
'aremark' => array(),
'arendal' => array(),
'ås' => array(),
'aseral' => array(),
'åseral' => array(),
'asker' => array(),
'askim' => array(),
'askvoll' => array(),
'askoy' => array(),
'askøy' => array(),
'asnes' => array(),
'åsnes' => array(),
'audnedaln' => array(),
'aukra' => array(),
'aure' => array(),
'aurland' => array(),
'aurskog-holand' => array(),
'aurskog-høland' => array(),
'austevoll' => array(),
'austrheim' => array(),
'averoy' => array(),
'averøy' => array(),
'balestrand' => array(),
'ballangen' => array(),
'balat' => array(),
'bálát' => array(),
'balsfjord' => array(),
'bahccavuotna' => array(),
'báhccavuotna' => array(),
'bamble' => array(),
'bardu' => array(),
'beardu' => array(),
'beiarn' => array(),
'bajddar' => array(),
'bájddar' => array(),
'baidar' => array(),
'báidár' => array(),
'berg' => array(),
'bergen' => array(),
'berlevag' => array(),
'berlevåg' => array(),
'bearalvahki' => array(),
'bearalváhki' => array(),
'bindal' => array(),
'birkenes' => array(),
'bjarkoy' => array(),
'bjarkøy' => array(),
'bjerkreim' => array(),
'bjugn' => array(),
'bodo' => array(),
'bodø' => array(),
'badaddja' => array(),
'bådåddjå' => array(),
'budejju' => array(),
'bokn' => array(),
'bremanger' => array(),
'bronnoy' => array(),
'brønnøy' => array(),
'bygland' => array(),
'bykle' => array(),
'barum' => array(),
'bærum' => array(),
'telemark' => array('bo' => array(),
'bø' => array()),
'nordland' => array('bo' => array(),
'bø' => array(),
'heroy' => array(),
'herøy' => array()),
'bievat' => array(),
'bievát' => array(),
'bomlo' => array(),
'bømlo' => array(),
'batsfjord' => array(),
'båtsfjord' => array(),
'bahcavuotna' => array(),
'báhcavuotna' => array(),
'dovre' => array(),
'drammen' => array(),
'drangedal' => array(),
'dyroy' => array(),
'dyrøy' => array(),
'donna' => array(),
'dønna' => array(),
'eid' => array(),
'eidfjord' => array(),
'eidsberg' => array(),
'eidskog' => array(),
'eidsvoll' => array(),
'eigersund' => array(),
'elverum' => array(),
'enebakk' => array(),
'engerdal' => array(),
'etne' => array(),
'etnedal' => array(),
'evenes' => array(),
'evenassi' => array(),
'evenášši' => array(),
'evje-og-hornnes' => array(),
'farsund' => array(),
'fauske' => array(),
'fuossko' => array(),
'fuoisku' => array(),
'fedje' => array(),
'fet' => array(),
'finnoy' => array(),
'finnøy' => array(),
'fitjar' => array(),
'fjaler' => array(),
'fjell' => array(),
'flakstad' => array(),
'flatanger' => array(),
'flekkefjord' => array(),
'flesberg' => array(),
'flora' => array(),
'fla' => array(),
'flå' => array(),
'folldal' => array(),
'forsand' => array(),
'fosnes' => array(),
'frei' => array(),
'frogn' => array(),
'froland' => array(),
'frosta' => array(),
'frana' => array(),
'fræna' => array(),
'froya' => array(),
'frøya' => array(),
'fusa' => array(),
'fyresdal' => array(),
'forde' => array(),
'førde' => array(),
'gamvik' => array(),
'gangaviika' => array(),
'gáŋgaviika' => array(),
'gaular' => array(),
'gausdal' => array(),
'gildeskal' => array(),
'gildeskål' => array(),
'giske' => array(),
'gjemnes' => array(),
'gjerdrum' => array(),
'gjerstad' => array(),
'gjesdal' => array(),
'gjovik' => array(),
'gjøvik' => array(),
'gloppen' => array(),
'gol' => array(),
'gran' => array(),
'grane' => array(),
'granvin' => array(),
'gratangen' => array(),
'grimstad' => array(),
'grong' => array(),
'kraanghke' => array(),
'kråanghke' => array(),
'grue' => array(),
'gulen' => array(),
'hadsel' => array(),
'halden' => array(),
'halsa' => array(),
'hamar' => array(),
'hamaroy' => array(),
'habmer' => array(),
'hábmer' => array(),
'hapmir' => array(),
'hápmir' => array(),
'hammerfest' => array(),
'hammarfeasta' => array(),
'hámmárfeasta' => array(),
'haram' => array(),
'hareid' => array(),
'harstad' => array(),
'hasvik' => array(),
'aknoluokta' => array(),
'ákŋoluokta' => array(),
'hattfjelldal' => array(),
'aarborte' => array(),
'haugesund' => array(),
'hemne' => array(),
'hemnes' => array(),
'hemsedal' => array(),
'more-og-romsdal' => array('heroy' => array(),
'sande' => array()),
'møre-og-romsdal' => array('herøy' => array(),
'sande' => array()),
'hitra' => array(),
'hjartdal' => array(),
'hjelmeland' => array(),
'hobol' => array(),
'hobøl' => array(),
'hof' => array(),
'hol' => array(),
'hole' => array(),
'holmestrand' => array(),
'holtalen' => array(),
'holtålen' => array(),
'hornindal' => array(),
'horten' => array(),
'hurdal' => array(),
'hurum' => array(),
'hvaler' => array(),
'hyllestad' => array(),
'hagebostad' => array(),
'hægebostad' => array(),
'hoyanger' => array(),
'høyanger' => array(),
'hoylandet' => array(),
'høylandet' => array(),
'ha' => array(),
'hå' => array(),
'ibestad' => array(),
'inderoy' => array(),
'inderøy' => array(),
'iveland' => array(),
'jevnaker' => array(),
'jondal' => array(),
'jolster' => array(),
'jølster' => array(),
'karasjok' => array(),
'karasjohka' => array(),
'kárášjohka' => array(),
'karlsoy' => array(),
'galsa' => array(),
'gálsá' => array(),
'karmoy' => array(),
'karmøy' => array(),
'kautokeino' => array(),
'guovdageaidnu' => array(),
'klepp' => array(),
'klabu' => array(),
'klæbu' => array(),
'kongsberg' => array(),
'kongsvinger' => array(),
'kragero' => array(),
'kragerø' => array(),
'kristiansand' => array(),
'kristiansund' => array(),
'krodsherad' => array(),
'krødsherad' => array(),
'kvalsund' => array(),
'rahkkeravju' => array(),
'ráhkkerávju' => array(),
'kvam' => array(),
'kvinesdal' => array(),
'kvinnherad' => array(),
'kviteseid' => array(),
'kvitsoy' => array(),
'kvitsøy' => array(),
'kvafjord' => array(),
'kvæfjord' => array(),
'giehtavuoatna' => array(),
'kvanangen' => array(),
'kvænangen' => array(),
'navuotna' => array(),
'návuotna' => array(),
'kafjord' => array(),
'kåfjord' => array(),
'gaivuotna' => array(),
'gáivuotna' => array(),
'larvik' => array(),
'lavangen' => array(),
'lavagis' => array(),
'loabat' => array(),
'loabát' => array(),
'lebesby' => array(),
'davvesiida' => array(),
'leikanger' => array(),
'leirfjord' => array(),
'leka' => array(),
'leksvik' => array(),
'lenvik' => array(),
'leangaviika' => array(),
'leaŋgaviika' => array(),
'lesja' => array(),
'levanger' => array(),
'lier' => array(),
'lierne' => array(),
'lillehammer' => array(),
'lillesand' => array(),
'lindesnes' => array(),
'lindas' => array(),
'lindås' => array(),
'lom' => array(),
'loppa' => array(),
'lahppi' => array(),
'láhppi' => array(),
'lund' => array(),
'lunner' => array(),
'luroy' => array(),
'lurøy' => array(),
'luster' => array(),
'lyngdal' => array(),
'lyngen' => array(),
'ivgu' => array(),
'lardal' => array(),
'lerdal' => array(),
'lærdal' => array(),
'lodingen' => array(),
'lødingen' => array(),
'lorenskog' => array(),
'lørenskog' => array(),
'loten' => array(),
'løten' => array(),
'malvik' => array(),
'masoy' => array(),
'måsøy' => array(),
'muosat' => array(),
'muosát' => array(),
'mandal' => array(),
'marker' => array(),
'marnardal' => array(),
'masfjorden' => array(),
'meland' => array(),
'meldal' => array(),
'melhus' => array(),
'meloy' => array(),
'meløy' => array(),
'meraker' => array(),
'meråker' => array(),
'moareke' => array(),
'moåreke' => array(),
'midsund' => array(),
'midtre-gauldal' => array(),
'modalen' => array(),
'modum' => array(),
'molde' => array(),
'moskenes' => array(),
'moss' => array(),
'mosvik' => array(),
'malselv' => array(),
'målselv' => array(),
'malatvuopmi' => array(),
'málatvuopmi' => array(),
'namdalseid' => array(),
'aejrie' => array(),
'namsos' => array(),
'namsskogan' => array(),
'naamesjevuemie' => array(),
'nååmesjevuemie' => array(),
'laakesvuemie' => array(),
'nannestad' => array(),
'narvik' => array(),
'narviika' => array(),
'naustdal' => array(),
'nedre-eiker' => array(),
'akershus' => array('nes' => array()),
'buskerud' => array('nes' => array()),
'nesna' => array(),
'nesodden' => array(),
'nesseby' => array(),
'unjarga' => array(),
'unjárga' => array(),
'nesset' => array(),
'nissedal' => array(),
'nittedal' => array(),
'nord-aurdal' => array(),
'nord-fron' => array(),
'nord-odal' => array(),
'norddal' => array(),
'nordkapp' => array(),
'davvenjarga' => array(),
'davvenjárga' => array(),
'nordre-land' => array(),
'nordreisa' => array(),
'raisa' => array(),
'ráisa' => array(),
'nore-og-uvdal' => array(),
'notodden' => array(),
'naroy' => array(),
'nærøy' => array(),
'notteroy' => array(),
'nøtterøy' => array(),
'odda' => array(),
'oksnes' => array(),
'øksnes' => array(),
'oppdal' => array(),
'oppegard' => array(),
'oppegård' => array(),
'orkdal' => array(),
'orland' => array(),
'ørland' => array(),
'orskog' => array(),
'ørskog' => array(),
'orsta' => array(),
'ørsta' => array(),
'hedmark' => array('os' => array(),
'valer' => array(),
'våler' => array()),
'hordaland' => array('os' => array()),
'osen' => array(),
'osteroy' => array(),
'osterøy' => array(),
'ostre-toten' => array(),
'østre-toten' => array(),
'overhalla' => array(),
'ovre-eiker' => array(),
'øvre-eiker' => array(),
'oyer' => array(),
'øyer' => array(),
'oygarden' => array(),
'øygarden' => array(),
'oystre-slidre' => array(),
'øystre-slidre' => array(),
'porsanger' => array(),
'porsangu' => array(),
'porsáŋgu' => array(),
'porsgrunn' => array(),
'radoy' => array(),
'radøy' => array(),
'rakkestad' => array(),
'rana' => array(),
'ruovat' => array(),
'randaberg' => array(),
'rauma' => array(),
'rendalen' => array(),
'rennebu' => array(),
'rennesoy' => array(),
'rennesøy' => array(),
'rindal' => array(),
'ringebu' => array(),
'ringerike' => array(),
'ringsaker' => array(),
'rissa' => array(),
'risor' => array(),
'risør' => array(),
'roan' => array(),
'rollag' => array(),
'rygge' => array(),
'ralingen' => array(),
'rælingen' => array(),
'rodoy' => array(),
'rødøy' => array(),
'romskog' => array(),
'rømskog' => array(),
'roros' => array(),
'røros' => array(),
'rost' => array(),
'røst' => array(),
'royken' => array(),
'røyken' => array(),
'royrvik' => array(),
'røyrvik' => array(),
'rade' => array(),
'råde' => array(),
'salangen' => array(),
'siellak' => array(),
'saltdal' => array(),
'salat' => array(),
'sálát' => array(),
'sálat' => array(),
'samnanger' => array(),
'vestfold' => array('sande' => array()),
'sandefjord' => array(),
'sandnes' => array(),
'sandoy' => array(),
'sandøy' => array(),
'sarpsborg' => array(),
'sauda' => array(),
'sauherad' => array(),
'sel' => array(),
'selbu' => array(),
'selje' => array(),
'seljord' => array(),
'sigdal' => array(),
'siljan' => array(),
'sirdal' => array(),
'skaun' => array(),
'skedsmo' => array(),
'ski' => array(),
'skien' => array(),
'skiptvet' => array(),
'skjervoy' => array(),
'skjervøy' => array(),
'skierva' => array(),
'skiervá' => array(),
'skjak' => array(),
'skjåk' => array(),
'skodje' => array(),
'skanland' => array(),
'skånland' => array(),
'skanit' => array(),
'skánit' => array(),
'smola' => array(),
'smøla' => array(),
'snillfjord' => array(),
'snasa' => array(),
'snåsa' => array(),
'snoasa' => array(),
'snaase' => array(),
'snåase' => array(),
'sogndal' => array(),
'sokndal' => array(),
'sola' => array(),
'solund' => array(),
'songdalen' => array(),
'sortland' => array(),
'spydeberg' => array(),
'stange' => array(),
'stavanger' => array(),
'steigen' => array(),
'steinkjer' => array(),
'stjordal' => array(),
'stjørdal' => array(),
'stokke' => array(),
'stor-elvdal' => array(),
'stord' => array(),
'stordal' => array(),
'storfjord' => array(),
'omasvuotna' => array(),
'strand' => array(),
'stranda' => array(),
'stryn' => array(),
'sula' => array(),
'suldal' => array(),
'sund' => array(),
'sunndal' => array(),
'surnadal' => array(),
'sveio' => array(),
'svelvik' => array(),
'sykkylven' => array(),
'sogne' => array(),
'søgne' => array(),
'somna' => array(),
'sømna' => array(),
'sondre-land' => array(),
'søndre-land' => array(),
'sor-aurdal' => array(),
'sør-aurdal' => array(),
'sor-fron' => array(),
'sør-fron' => array(),
'sor-odal' => array(),
'sør-odal' => array(),
'sor-varanger' => array(),
'sør-varanger' => array(),
'matta-varjjat' => array(),
'mátta-várjjat' => array(),
'sorfold' => array(),
'sørfold' => array(),
'sorreisa' => array(),
'sørreisa' => array(),
'sorum' => array(),
'sørum' => array(),
'tana' => array(),
'deatnu' => array(),
'time' => array(),
'tingvoll' => array(),
'tinn' => array(),
'tjeldsund' => array(),
'dielddanuorri' => array(),
'tjome' => array(),
'tjøme' => array(),
'tokke' => array(),
'tolga' => array(),
'torsken' => array(),
'tranoy' => array(),
'tranøy' => array(),
'tromso' => array(),
'tromsø' => array(),
'tromsa' => array(),
'romsa' => array(),
'trondheim' => array(),
'troandin' => array(),
'trysil' => array(),
'trana' => array(),
'træna' => array(),
'trogstad' => array(),
'trøgstad' => array(),
'tvedestrand' => array(),
'tydal' => array(),
'tynset' => array(),
'tysfjord' => array(),
'divtasvuodna' => array(),
'divttasvuotna' => array(),
'tysnes' => array(),
'tysvar' => array(),
'tysvær' => array(),
'tonsberg' => array(),
'tønsberg' => array(),
'ullensaker' => array(),
'ullensvang' => array(),
'ulvik' => array(),
'utsira' => array(),
'vadso' => array(),
'vadsø' => array(),
'cahcesuolo' => array(),
'čáhcesuolo' => array(),
'vaksdal' => array(),
'valle' => array(),
'vang' => array(),
'vanylven' => array(),
'vardo' => array(),
'vardø' => array(),
'varggat' => array(),
'várggát' => array(),
'vefsn' => array(),
'vaapste' => array(),
'vega' => array(),
'vegarshei' => array(),
'vegårshei' => array(),
'vennesla' => array(),
'verdal' => array(),
'verran' => array(),
'vestby' => array(),
'vestnes' => array(),
'vestre-slidre' => array(),
'vestre-toten' => array(),
'vestvagoy' => array(),
'vestvågøy' => array(),
'vevelstad' => array(),
'vik' => array(),
'vikna' => array(),
'vindafjord' => array(),
'volda' => array(),
'voss' => array(),
'varoy' => array(),
'værøy' => array(),
'vagan' => array(),
'vågan' => array(),
'voagat' => array(),
'vagsoy' => array(),
'vågsøy' => array(),
'vaga' => array(),
'vågå' => array(),
'ostfold' => array('valer' => array()),
'østfold' => array('våler' => array())),
'np' => array('*' => array()),
'nr' => array('biz' => array(),
'info' => array(),
'gov' => array(),
'edu' => array(),
'org' => array(),
'net' => array(),
'com' => array()),
'nu' => array(),
'nz' => array('*' => array()),
'om' => array('*' => array(),
'mediaphone' => array('!' => ''),
'nawrastelecom' => array('!' => ''),
'nawras' => array('!' => ''),
'omanmobile' => array('!' => ''),
'omanpost' => array('!' => ''),
'omantel' => array('!' => ''),
'rakpetroleum' => array('!' => ''),
'siemens' => array('!' => ''),
'songfest' => array('!' => ''),
'statecouncil' => array('!' => '')),
'org' => array('ae' => array(),
'za' => array()),
'pa' => array('ac' => array(),
'gob' => array(),
'com' => array(),
'org' => array(),
'sld' => array(),
'edu' => array(),
'net' => array(),
'ing' => array(),
'abo' => array(),
'med' => array(),
'nom' => array()),
'pe' => array('edu' => array(),
'gob' => array(),
'nom' => array(),
'mil' => array(),
'org' => array(),
'com' => array(),
'net' => array()),
'pf' => array('com' => array(),
'org' => array(),
'edu' => array()),
'pg' => array('*' => array()),
'ph' => array('com' => array(),
'net' => array(),
'org' => array(),
'gov' => array(),
'edu' => array(),
'ngo' => array(),
'mil' => array(),
'i' => array()),
'pk' => array('com' => array(),
'net' => array(),
'edu' => array(),
'org' => array(),
'fam' => array(),
'biz' => array(),
'web' => array(),
'gov' => array(),
'gob' => array(),
'gok' => array(),
'gon' => array(),
'gop' => array(),
'gos' => array(),
'info' => array()),
'pl' => array('aid' => array(),
'agro' => array(),
'atm' => array(),
'auto' => array(),
'biz' => array(),
'com' => array(),
'edu' => array(),
'gmina' => array(),
'gsm' => array(),
'info' => array(),
'mail' => array(),
'miasta' => array(),
'media' => array(),
'mil' => array(),
'net' => array(),
'nieruchomosci' => array(),
'nom' => array(),
'org' => array(),
'pc' => array(),
'powiat' => array(),
'priv' => array(),
'realestate' => array(),
'rel' => array(),
'sex' => array(),
'shop' => array(),
'sklep' => array(),
'sos' => array(),
'szkola' => array(),
'targi' => array(),
'tm' => array(),
'tourism' => array(),
'travel' => array(),
'turystyka' => array(),
'6bone' => array(),
'art' => array(),
'mbone' => array(),
'gov' => array('uw' => array(),
'um' => array(),
'ug' => array(),
'upow' => array(),
'starostwo' => array(),
'so' => array(),
'sr' => array(),
'po' => array(),
'pa' => array()),
'ngo' => array(),
'irc' => array(),
'usenet' => array(),
'augustow' => array(),
'babia-gora' => array(),
'bedzin' => array(),
'beskidy' => array(),
'bialowieza' => array(),
'bialystok' => array(),
'bielawa' => array(),
'bieszczady' => array(),
'boleslawiec' => array(),
'bydgoszcz' => array(),
'bytom' => array(),
'cieszyn' => array(),
'czeladz' => array(),
'czest' => array(),
'dlugoleka' => array(),
'elblag' => array(),
'elk' => array(),
'glogow' => array(),
'gniezno' => array(),
'gorlice' => array(),
'grajewo' => array(),
'ilawa' => array(),
'jaworzno' => array(),
'jelenia-gora' => array(),
'jgora' => array(),
'kalisz' => array(),
'kazimierz-dolny' => array(),
'karpacz' => array(),
'kartuzy' => array(),
'kaszuby' => array(),
'katowice' => array(),
'kepno' => array(),
'ketrzyn' => array(),
'klodzko' => array(),
'kobierzyce' => array(),
'kolobrzeg' => array(),
'konin' => array(),
'konskowola' => array(),
'kutno' => array(),
'lapy' => array(),
'lebork' => array(),
'legnica' => array(),
'lezajsk' => array(),
'limanowa' => array(),
'lomza' => array(),
'lowicz' => array(),
'lubin' => array(),
'lukow' => array(),
'malbork' => array(),
'malopolska' => array(),
'mazowsze' => array(),
'mazury' => array(),
'mielec' => array(),
'mielno' => array(),
'mragowo' => array(),
'naklo' => array(),
'nowaruda' => array(),
'nysa' => array(),
'olawa' => array(),
'olecko' => array(),
'olkusz' => array(),
'olsztyn' => array(),
'opoczno' => array(),
'opole' => array(),
'ostroda' => array(),
'ostroleka' => array(),
'ostrowiec' => array(),
'ostrowwlkp' => array(),
'pila' => array(),
'pisz' => array(),
'podhale' => array(),
'podlasie' => array(),
'polkowice' => array(),
'pomorze' => array(),
'pomorskie' => array(),
'prochowice' => array(),
'pruszkow' => array(),
'przeworsk' => array(),
'pulawy' => array(),
'radom' => array(),
'rawa-maz' => array(),
'rybnik' => array(),
'rzeszow' => array(),
'sanok' => array(),
'sejny' => array(),
'siedlce' => array(),
'slask' => array(),
'slupsk' => array(),
'sosnowiec' => array(),
'stalowa-wola' => array(),
'skoczow' => array(),
'starachowice' => array(),
'stargard' => array(),
'suwalki' => array(),
'swidnica' => array(),
'swiebodzin' => array(),
'swinoujscie' => array(),
'szczecin' => array(),
'szczytno' => array(),
'tarnobrzeg' => array(),
'tgory' => array(),
'turek' => array(),
'tychy' => array(),
'ustka' => array(),
'walbrzych' => array(),
'warmia' => array(),
'warszawa' => array(),
'waw' => array(),
'wegrow' => array(),
'wielun' => array(),
'wlocl' => array(),
'wloclawek' => array(),
'wodzislaw' => array(),
'wolomin' => array(),
'wroclaw' => array(),
'zachpomor' => array(),
'zagan' => array(),
'zarow' => array(),
'zgora' => array(),
'zgorzelec' => array(),
'gda' => array(),
'gdansk' => array(),
'gdynia' => array(),
'med' => array(),
'sopot' => array(),
'gliwice' => array(),
'krakow' => array(),
'poznan' => array(),
'wroc' => array(),
'zakopane' => array(),
'co' => array()),
'pn' => array('gov' => array(),
'co' => array(),
'org' => array(),
'edu' => array(),
'net' => array()),
'pr' => array('com' => array(),
'net' => array(),
'org' => array(),
'gov' => array(),
'edu' => array(),
'isla' => array(),
'pro' => array(),
'biz' => array(),
'info' => array(),
'name' => array(),
'est' => array(),
'prof' => array(),
'ac' => array()),
'pro' => array('aca' => array(),
'bar' => array(),
'cpa' => array(),
'jur' => array(),
'law' => array(),
'med' => array(),
'eng' => array()),
'ps' => array('edu' => array(),
'gov' => array(),
'sec' => array(),
'plo' => array(),
'com' => array(),
'org' => array(),
'net' => array()),
'pt' => array('net' => array(),
'gov' => array(),
'org' => array(),
'edu' => array(),
'int' => array(),
'publ' => array(),
'com' => array(),
'nome' => array()),
'pw' => array('co' => array(),
'ne' => array(),
'or' => array(),
'ed' => array(),
'go' => array(),
'belau' => array()),
'py' => array('*' => array()),
'qa' => array('*' => array()),
're' => array('com' => array(),
'asso' => array(),
'nom' => array()),
'ro' => array('com' => array(),
'org' => array(),
'tm' => array(),
'nt' => array(),
'nom' => array(),
'info' => array(),
'rec' => array(),
'arts' => array(),
'firm' => array(),
'store' => array(),
'www' => array()),
'rs' => array('co' => array(),
'org' => array(),
'edu' => array(),
'ac' => array(),
'gov' => array(),
'in' => array()),
'ru' => array('ac' => array(),
'com' => array(),
'edu' => array(),
'int' => array(),
'net' => array(),
'org' => array(),
'pp' => array(),
'adygeya' => array(),
'altai' => array(),
'amur' => array(),
'arkhangelsk' => array(),
'astrakhan' => array(),
'bashkiria' => array(),
'belgorod' => array(),
'bir' => array(),
'bryansk' => array(),
'buryatia' => array(),
'cbg' => array(),
'chel' => array(),
'chelyabinsk' => array(),
'chita' => array(),
'chukotka' => array(),
'chuvashia' => array(),
'dagestan' => array(),
'dudinka' => array(),
'e-burg' => array(),
'grozny' => array(),
'irkutsk' => array(),
'ivanovo' => array(),
'izhevsk' => array(),
'jar' => array(),
'joshkar-ola' => array(),
'kalmykia' => array(),
'kaluga' => array(),
'kamchatka' => array(),
'karelia' => array(),
'kazan' => array(),
'kchr' => array(),
'kemerovo' => array(),
'khabarovsk' => array(),
'khakassia' => array(),
'khv' => array(),
'kirov' => array(),
'koenig' => array(),
'komi' => array(),
'kostroma' => array(),
'krasnoyarsk' => array(),
'kuban' => array(),
'kurgan' => array(),
'kursk' => array(),
'lipetsk' => array(),
'magadan' => array(),
'mari' => array(),
'mari-el' => array(),
'marine' => array(),
'mordovia' => array(),
'mosreg' => array(),
'msk' => array(),
'murmansk' => array(),
'nalchik' => array(),
'nnov' => array(),
'nov' => array(),
'novosibirsk' => array(),
'nsk' => array(),
'omsk' => array(),
'orenburg' => array(),
'oryol' => array(),
'palana' => array(),
'penza' => array(),
'perm' => array(),
'pskov' => array(),
'ptz' => array(),
'rnd' => array(),
'ryazan' => array(),
'sakhalin' => array(),
'samara' => array(),
'saratov' => array(),
'simbirsk' => array(),
'smolensk' => array(),
'spb' => array(),
'stavropol' => array(),
'stv' => array(),
'surgut' => array(),
'tambov' => array(),
'tatarstan' => array(),
'tom' => array(),
'tomsk' => array(),
'tsaritsyn' => array(),
'tsk' => array(),
'tula' => array(),
'tuva' => array(),
'tver' => array(),
'tyumen' => array(),
'udm' => array(),
'udmurtia' => array(),
'ulan-ude' => array(),
'vladikavkaz' => array(),
'vladimir' => array(),
'vladivostok' => array(),
'volgograd' => array(),
'vologda' => array(),
'voronezh' => array(),
'vrn' => array(),
'vyatka' => array(),
'yakutia' => array(),
'yamal' => array(),
'yaroslavl' => array(),
'yekaterinburg' => array(),
'yuzhno-sakhalinsk' => array(),
'amursk' => array(),
'baikal' => array(),
'cmw' => array(),
'fareast' => array(),
'jamal' => array(),
'kms' => array(),
'k-uralsk' => array(),
'kustanai' => array(),
'kuzbass' => array(),
'magnitka' => array(),
'mytis' => array(),
'nakhodka' => array(),
'nkz' => array(),
'norilsk' => array(),
'oskol' => array(),
'pyatigorsk' => array(),
'rubtsovsk' => array(),
'snz' => array(),
'syzran' => array(),
'vdonsk' => array(),
'zgrad' => array(),
'gov' => array(),
'mil' => array(),
'test' => array()),
'rw' => array('gov' => array(),
'net' => array(),
'edu' => array(),
'ac' => array(),
'com' => array(),
'co' => array(),
'int' => array(),
'mil' => array(),
'gouv' => array()),
'sa' => array('com' => array(),
'net' => array(),
'org' => array(),
'gov' => array(),
'med' => array(),
'pub' => array(),
'edu' => array(),
'sch' => array()),
'sb' => array('com' => array(),
'edu' => array(),
'gov' => array(),
'net' => array(),
'org' => array()),
'sc' => array('com' => array(),
'gov' => array(),
'net' => array(),
'org' => array(),
'edu' => array()),
'sd' => array('com' => array(),
'net' => array(),
'org' => array(),
'edu' => array(),
'med' => array(),
'gov' => array(),
'info' => array()),
'se' => array('a' => array(),
'ac' => array(),
'b' => array(),
'bd' => array(),
'brand' => array(),
'c' => array(),
'd' => array(),
'e' => array(),
'f' => array(),
'fh' => array(),
'fhsk' => array(),
'fhv' => array(),
'g' => array(),
'h' => array(),
'i' => array(),
'k' => array(),
'komforb' => array(),
'kommunalforbund' => array(),
'komvux' => array(),
'l' => array(),
'lanbib' => array(),
'm' => array(),
'n' => array(),
'naturbruksgymn' => array(),
'o' => array(),
'org' => array(),
'p' => array(),
'parti' => array(),
'pp' => array(),
'press' => array(),
'r' => array(),
's' => array(),
'sshn' => array(),
't' => array(),
'tm' => array(),
'u' => array(),
'w' => array(),
'x' => array(),
'y' => array(),
'z' => array()),
'sg' => array('com' => array(),
'net' => array(),
'org' => array(),
'gov' => array(),
'edu' => array(),
'per' => array()),
'sh' => array(),
'si' => array(),
'sk' => array(),
'sl' => array('com' => array(),
'net' => array(),
'edu' => array(),
'gov' => array(),
'org' => array()),
'sm' => array(),
'sn' => array('art' => array(),
'com' => array(),
'edu' => array(),
'gouv' => array(),
'org' => array(),
'perso' => array(),
'univ' => array()),
'so' => array('com' => array(),
'net' => array(),
'org' => array()),
'sr' => array(),
'st' => array('co' => array(),
'com' => array(),
'consulado' => array(),
'edu' => array(),
'embaixada' => array(),
'gov' => array(),
'mil' => array(),
'net' => array(),
'org' => array(),
'principe' => array(),
'saotome' => array(),
'store' => array()),
'su' => array(),
'sv' => array('*' => array()),
'sy' => array('edu' => array(),
'gov' => array(),
'net' => array(),
'mil' => array(),
'com' => array(),
'org' => array()),
'sz' => array('co' => array(),
'ac' => array(),
'org' => array()),
'tc' => array(),
'td' => array(),
'tel' => array(),
'tf' => array(),
'tg' => array(),
'th' => array('ac' => array(),
'co' => array(),
'go' => array(),
'in' => array(),
'mi' => array(),
'net' => array(),
'or' => array()),
'tj' => array('ac' => array(),
'biz' => array(),
'co' => array(),
'com' => array(),
'edu' => array(),
'go' => array(),
'gov' => array(),
'int' => array(),
'mil' => array(),
'name' => array(),
'net' => array(),
'nic' => array(),
'org' => array(),
'test' => array(),
'web' => array()),
'tk' => array(),
'tl' => array('gov' => array()),
'tm' => array(),
'tn' => array('com' => array(),
'ens' => array(),
'fin' => array(),
'gov' => array(),
'ind' => array(),
'intl' => array(),
'nat' => array(),
'net' => array(),
'org' => array(),
'info' => array(),
'perso' => array(),
'tourism' => array(),
'edunet' => array(),
'rnrt' => array(),
'rns' => array(),
'rnu' => array(),
'mincom' => array(),
'agrinet' => array(),
'defense' => array(),
'turen' => array()),
'to' => array('com' => array(),
'gov' => array(),
'net' => array(),
'org' => array(),
'edu' => array(),
'mil' => array()),
'tr' => array('*' => array(),
'nic' => array('!' => ''),
'tsk' => array('!' => ''),
'nc' => array('gov' => array())),
'travel' => array(),
'tt' => array('co' => array(),
'com' => array(),
'org' => array(),
'net' => array(),
'biz' => array(),
'info' => array(),
'pro' => array(),
'int' => array(),
'coop' => array(),
'jobs' => array(),
'mobi' => array(),
'travel' => array(),
'museum' => array(),
'aero' => array(),
'name' => array(),
'gov' => array(),
'edu' => array()),
'tv' => array(),
'tw' => array('edu' => array(),
'gov' => array(),
'mil' => array(),
'com' => array(),
'net' => array(),
'org' => array(),
'idv' => array(),
'game' => array(),
'ebiz' => array(),
'club' => array(),
'網路' => array(),
'組織' => array(),
'商業' => array()),
'tz' => array('ac' => array(),
'co' => array(),
'go' => array(),
'mil' => array(),
'ne' => array(),
'or' => array(),
'sc' => array()),
'ua' => array('com' => array(),
'edu' => array(),
'gov' => array(),
'in' => array(),
'net' => array(),
'org' => array(),
'cherkassy' => array(),
'chernigov' => array(),
'chernovtsy' => array(),
'ck' => array(),
'cn' => array(),
'crimea' => array(),
'cv' => array(),
'dn' => array(),
'dnepropetrovsk' => array(),
'donetsk' => array(),
'dp' => array(),
'if' => array(),
'ivano-frankivsk' => array(),
'kh' => array(),
'kharkov' => array(),
'kherson' => array(),
'khmelnitskiy' => array(),
'kiev' => array(),
'kirovograd' => array(),
'km' => array(),
'kr' => array(),
'ks' => array(),
'kv' => array(),
'lg' => array(),
'lugansk' => array(),
'lutsk' => array(),
'lviv' => array(),
'mk' => array(),
'nikolaev' => array(),
'od' => array(),
'odessa' => array(),
'pl' => array(),
'poltava' => array(),
'rovno' => array(),
'rv' => array(),
'sebastopol' => array(),
'sumy' => array(),
'te' => array(),
'ternopil' => array(),
'uzhgorod' => array(),
'vinnica' => array(),
'vn' => array(),
'zaporizhzhe' => array(),
'zp' => array(),
'zhitomir' => array(),
'zt' => array()),
'ug' => array('co' => array(),
'ac' => array(),
'sc' => array(),
'go' => array(),
'ne' => array(),
'or' => array()),
'uk' => array('*' => array(),
'sch' => array('*' => array()),
'bl' => array('!' => ''),
'british-library' => array('!' => ''),
'icnet' => array('!' => ''),
'jet' => array('!' => ''),
'nel' => array('!' => ''),
'nhs' => array('!' => ''),
'nls' => array('!' => ''),
'national-library-scotland' => array('!' => ''),
'parliament' => array('!' => '')),
'us' => array('dni' => array(),
'fed' => array(),
'isa' => array(),
'kids' => array(),
'nsn' => array(),
'ak' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'al' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'ar' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'as' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'az' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'ca' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'co' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'ct' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'dc' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'de' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'fl' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'ga' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'gu' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'hi' => array('cc' => array(),
'lib' => array()),
'ia' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'id' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'il' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'in' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'ks' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'ky' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'la' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'ma' => array('k12' => array('pvt' => array(),
'chtr' => array(),
'paroch' => array()),
'cc' => array(),
'lib' => array()),
'md' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'me' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'mi' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'mn' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'mo' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'ms' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'mt' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'nc' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'nd' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'ne' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'nh' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'nj' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'nm' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'nv' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'ny' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'oh' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'ok' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'or' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'pa' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'pr' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'ri' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'sc' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'sd' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'tn' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'tx' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'ut' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'vi' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'vt' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'va' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'wa' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'wi' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'wv' => array('k12' => array(),
'cc' => array(),
'lib' => array()),
'wy' => array('k12' => array(),
'cc' => array(),
'lib' => array())),
'uy' => array('*' => array()),
'uz' => array('com' => array(),
'co' => array()),
'va' => array(),
'vc' => array('com' => array(),
'net' => array(),
'org' => array(),
'gov' => array(),
'mil' => array(),
'edu' => array()),
've' => array('*' => array()),
'vg' => array(),
'vi' => array('co' => array(),
'com' => array(),
'k12' => array(),
'net' => array(),
'org' => array()),
'vn' => array('com' => array(),
'net' => array(),
'org' => array(),
'edu' => array(),
'gov' => array(),
'int' => array(),
'ac' => array(),
'biz' => array(),
'info' => array(),
'name' => array(),
'pro' => array(),
'health' => array()),
'vu' => array(),
'ws' => array('com' => array(),
'net' => array(),
'org' => array(),
'gov' => array(),
'edu' => array()),
'امارات' => array(),
'中国' => array(),
'中國' => array(),
'مصر' => array(),
'香港' => array(),
'الاردن' => array(),
'ලංකා' => array(),
'இலங்கை' => array(),
'فلسطين' => array(),
'рф' => array(),
'قطر' => array(),
'السعودية' => array(),
'新加坡' => array(),
'சிங்கப்பூர்' => array(),
'ไทย' => array(),
'تونس' => array(),
'台灣' => array(),
'台湾' => array(),
'ye' => array('*' => array()),
'yu' => array('*' => array()),
'za' => array('*' => array()),
'zm' => array('*' => array()),
'zw' => array('*' => array()));
?>


code:
<?

/*
 * Calculate the effective registered domain of a fully qualified domain name.
 *
 * <@LICENSE>
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to you under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * </@LICENSE>
 *
 * Florian Sager, 25.07.2008, sager@agitos.de
 */

/*
 * Remove subdomains from a signing domain to get the registered domain.
 *
 * dkim-reputation.org blocks signing domains on the level of registered domains
 * to rate senders who use e.g. a.spamdomain.tld, b.spamdomain.tld, ... under
 * the most common identifier - the registered domain - finally.
 *
 * This function returns NULL if $signingDomain is TLD itself
 */

function getRegisteredDomain($signingDomain) {

	global $tldTree;

	$signingDomainParts = explode('.', $signingDomain);

	$result = findRegisteredDomain($signingDomainParts, $tldTree);

	if ($result===NULL || $result=="") {
		// this is an invalid domain name
		return NULL;
	}

	// assure there is at least 1 TLD in the stripped signing domain
	if (!strpos($result, '.')) {
		$cnt = count($signingDomainParts);
		if ($cnt==1 || $signingDomainParts[$cnt-2]=="") return NULL;
		return $signingDomainParts[$cnt-2].'.'.$signingDomainParts[$cnt-1];
	}
	return $result;
}

// recursive helper method
function findRegisteredDomain($remainingSigningDomainParts, &$treeNode) {

	$sub = array_pop($remainingSigningDomainParts);

	$result = NULL;
	if (isset($treeNode['!'])) {
		return '#';
	} else if (is_array($treeNode) && array_key_exists($sub, $treeNode)) {
		$result = findRegisteredDomain($remainingSigningDomainParts, $treeNode[$sub]);
	} else if (is_array($treeNode) && array_key_exists('*', $treeNode)) {
		$result = findRegisteredDomain($remainingSigningDomainParts, $treeNode['*']);
	} else {
		return $sub;
	}

	// this is a hack 'cause PHP interpretes '' as NULL
	if ($result == '#') {
		return $sub;
	} else if (strlen($result)>0) {
		return $result.'.'.$sub;
	}
	return NULL;
}

?>

license: mit


code:
<?php
/**
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2011, StatusNet, Inc.
 *
 * Installer class for domain-based multi-homing systems
 *
 * PHP version 5
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @category  DomainStatusNetwork
 * @package   StatusNet
 * @author    Evan Prodromou <evan@status.net>
 * @copyright 2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
 * @link      http://status.net/
 */

if (!defined('STATUSNET')) {
    // This check helps protect against security problems;
    // your code file can't be executed directly from the web.
    exit(1);
}

/**
 * Installer class for domain-based multi-homing systems
 *
 * @category  DomainStatusNetwork
 * @package   StatusNet
 * @author    Evan Prodromou <evan@status.net>
 * @copyright 2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
 * @link      http://status.net/
 */
class DomainStatusNetworkInstaller extends Installer
{
    protected $domain   = null;
    protected $rootname = null;
    protected $sitedb   = null;
    protected $rootpass = null;
    protected $nickname = null;
    protected $sn       = null;

    public $verbose     = false;

    function __construct($domain)
    {
        $this->domain = $domain;
    }

    /**
     * Go for it!
     * @return boolean success
     */
    function main()
    {
        // We don't check prereqs. Check 'em before setting up a
        // multi-home system, kthxbi
        if ($this->prepare()) {
            return $this->handle();
        } else {
            $this->showHelp();
            return false;
        }
    }

    /**
     * Get our input parameters...
     * @return boolean success
     */
    function prepare()
    {
        $config = $this->getConfig();

        $this->nickname = DomainStatusNetworkPlugin::nicknameForDomain($this->domain);

        // XXX make this configurable

        $this->sitename = sprintf('The %s Status Network', $this->domain);

        $this->server   = $this->nickname.'.'.$config['WILDCARD'];
        $this->path     = null;
        $this->fancy    = true;

        $datanick = $this->databaseize($this->nickname);

        $this->host     = $config['DBHOSTNAME'];
        $this->database = $datanick.$config['DBBASE'];
        $this->dbtype   = 'mysql'; // XXX: support others... someday
        $this->username = $datanick.$config['USERBASE'];

        // Max size for MySQL

        if (strlen($this->username) > 16) {
            $this->username = sprintf('%s%08x', substr($this->username, 0, 8), crc32($this->username));
        }

        $pwgen = $config['PWDGEN'];

        $password = `$pwgen`;

        $this->password = trim($password);

        // For setting up the database

        $this->rootname = $config['ADMIN'];
        $this->rootpass = $config['ADMINPASS'];
        $this->sitehost = $config['SITEDBHOSTNAME'];
        $this->sitedb   = $config['SITEDB'];

        $tagstr = $config['TAGS'];

        if (!empty($tagstr)) {
            $this->tags = preg_split('/[\s,]+/', $tagstr);
        } else {
            $this->tags = array();
        }

        // Explicitly empty

        $this->adminNick    = null;
        $this->adminPass    = null;
        $this->adminEmail   = null;

        /** Should we skip writing the configuration file? */
        $this->skipConfig = true;

        if (!$this->validateDb()) {
            return false;
        }

        return true;
    }

    function handle()
    {
        return $this->doInstall();
    }

    function setupDatabase()
    {
        $this->updateStatus('Creating database...');
        $this->createDatabase();
        parent::setupDatabase();
        $this->updateStatus('Creating file directories...');
        $this->createDirectories();
        $this->updateStatus('Saving status network...');
        $this->saveStatusNetwork();
        $this->updateStatus('Checking schema for plugins...');
        $this->checkSchema();
    }

    function saveStatusNetwork()
    {
        Status_network::setupDB($this->sitehost,
                                $this->rootname,
                                $this->rootpass,
                                $this->sitedb, array());

        $sn = new Status_network();

        $sn->nickname = $this->nickname;
        $sn->dbhost   = $this->host;
        $sn->dbuser   = $this->username;
        $sn->dbpass   = $this->password;
        $sn->dbname   = $this->database;
        $sn->sitename = $this->sitename;
        $sn->created  = common_sql_now();

        $result = $sn->insert();

        if (!$result) {
            throw new ServerException("Could not create status_network: " . print_r($sn, true));
        }

        // Re-fetch; stupid auto-increment integer isn't working

        $sn = Status_network::getKV('nickname', $sn->nickname);

        if (empty($sn)) {
            throw new ServerException("Created {$this->nickname} status_network and could not find it again.");
        }

        // Set default tags

        $tags = $this->tags;

        // Add domain tag

        $tags[] = 'domain='.$this->domain;

        $sn->setTags($tags);

        $this->sn = $sn;
    }

    function checkSchema()
    {
        $config = $this->getConfig();

        Status_network::$wildcard = $config['WILDCARD'];

        GNUsocial::switchSite($this->nickname);

        // We need to initialize the schema_version stuff to make later setup easier

        $schema = array();
        require INSTALLDIR.'/db/core.php';
        $tableDefs = $schema;

        $schema = Schema::get();
        $schemaUpdater = new SchemaUpdater($schema);

        foreach ($tableDefs as $table => $def) {
            $schemaUpdater->register($table, $def);
        }

        $schemaUpdater->checkSchema();

        Event::handle('CheckSchema');
    }

    function getStatusNetwork()
    {
        return $this->sn;
    }

    function createDirectories()
    {
        $config = $this->getConfig();

        foreach (array('AVATARBASE', 'BACKGROUNDBASE', 'FILEBASE') as $key) {
            $base = $config[$key];
            $dirname = $base.'/'.$this->nickname;

            // Make sure our bits are set
            $mask = umask(0);
            mkdir($dirname, 0770, true);
            umask($mask);

            // If you set the setuid bit on your base dirs this should be
            // unnecessary, but just in case. You must be root for this
            // to work.

            if (array_key_exists('WEBUSER', $config)) {
                chown($dirname, $config['WEBUSER']);
            }
            if (array_key_exists('WEBGROUP', $config)) {
                chgrp($dirname, $config['WEBGROUP']);
            }
        }
    }

    function createDatabase()
    {
        // Create the New DB
        /* FIXME
         * Extension 'mysql_' is deprecated since PHP 5.5 - use mysqli instead.
         */
        $res = mysql_connect($this->host, $this->rootname, $this->rootpass);
        if (!$res) {
            throw new ServerException("Cannot connect to {$this->host} as {$this->rootname}.");
        }

        mysql_query("CREATE DATABASE ". mysql_real_escape_string($this->database), $res);

        $return = mysql_select_db($this->database, $res);

        if (!$return) {
            throw new ServerException("Unable to connect to {$this->database} on {$this->host}.");
        }

        foreach (array('localhost', '%') as $src) {
            mysql_query("GRANT ALL ON " .
                        mysql_real_escape_string($this->database).".* TO '" .
                        $this->username . "'@'".$src."' ".
                        "IDENTIFIED BY '".$this->password."'", $res);
        }

        mysql_close($res);
    }

    function getConfig()
    {
        static $config;

        $cfg_file = "/etc/statusnet/setup.cfg";

        if (empty($config)) {
            $result = parse_ini_file($cfg_file);

            $config = array();
            foreach ($result as $key => $value) {
                $key = str_replace('export ', '', $key);
                $config[$key] = $value;
            }
        }

        return $config;
    }

    function showHelp()
    {
    }

    function warning($message, $submessage='')
    {
        print $this->html2text($message) . "\n";
        if ($submessage != '') {
            print "  " . $this->html2text($submessage) . "\n";
        }
        print "\n";
    }

    function updateStatus($status, $error=false)
    {
        if ($this->verbose || $error) {
            if ($error) {
                print "ERROR: ";
            }
            print $this->html2text($status);
            print "\n";
        }
    }

    private function html2text($html)
    {
        // break out any links for text legibility
        $breakout = preg_replace('/<a[^>+]\bhref="(.*)"[^>]*>(.*)<\/a>/',
                                 '\2 <\1>',
                                 $html);
        return common_strip_html($breakout);
    }

    function databaseize($nickname)
    {
        $nickname = str_replace('-', '_', $nickname);
        return $nickname;
    }
}