45 lines
15 KiB
PHP
45 lines
15 KiB
PHP
|
<?php
|
||
|
|
||
|
function gettlds() {
|
||
|
$tlds=['zw', 'zuerich', 'zone', 'zm', 'zip', 'zero', 'zara', 'zappos', 'za', 'yun', 'yt', 'youtube', 'you', 'yokohama', 'yoga', 'yodobashi', 'ye', 'yandex', 'yamaxun', 'yahoo', 'yachts', 'xyz', 'xxx', 'xn--zfr164b', 'xn--ygbi2ammx', 'xn--yfro4i67o', 'xn--y9a3aq', 'xn--xkc2dl3a5ee0h', 'xn--xkc2al3hye2a', 'xn--xhq521b', 'xn--wgbl6a', 'xn--wgbh1c', 'xn--w4rs40l', 'xn--w4r85el8fhu5dnra', 'xn--vuq861b', 'xn--vhquv', 'xn--vermgensberatung-pwb', 'xn--vermgensberater-ctb', 'xn--unup4y', 'xn--tiq49xqyj', 'xn--tckwe', 'xn--t60b56a', 'xn--ses554g', 'xn--s9brj9c', 'xn--rvc1e0am3e', 'xn--rovu88b', 'xn--rhqv96g', 'xn--qxam', 'xn--qxa6a', 'xn--qcka1pmc', 'xn--q9jyb4c', 'xn--q7ce6a', 'xn--pssy2u', 'xn--pgbs0dh', 'xn--p1ai', 'xn--p1acf', 'xn--otu796d', 'xn--ogbpf8fl', 'xn--o3cw4h', 'xn--nyqy26a', 'xn--nqv7fs00ema', 'xn--nqv7f', 'xn--node', 'xn--ngbrx', 'xn--ngbe9e0a', 'xn--ngbc5azd', 'xn--mxtq1m', 'xn--mk1bu44c', 'xn--mix891f', 'xn--mgbx4cd0ab', 'xn--mgbtx2b', 'xn--mgbt3dhd', 'xn--mgbpl2fh', 'xn--mgbi4ecexp', 'xn--mgbgu82a', 'xn--mgberp4a5d4ar', 'xn--mgbcpq6gpa1a', 'xn--mgbca7dzdo', 'xn--mgbc0a9azcg', 'xn--mgbbh1a71e', 'xn--mgbbh1a', 'xn--mgbayh7gpa', 'xn--mgbai9azgqp6j', 'xn--mgbah1a3hjkrd', 'xn--mgbab2bd', 'xn--mgbaam7a8h', 'xn--mgbaakc7dvf', 'xn--mgba7c0bbn0a', 'xn--mgba3a4f16a', 'xn--mgba3a3ejt', 'xn--mgb9awbf', 'xn--lgbbat1ad8j', 'xn--l1acc', 'xn--kput3i', 'xn--kpry57d', 'xn--kprw13d', 'xn--kcrx77d1x4a', 'xn--jvr189m', 'xn--jlq480n2rg', 'xn--j6w193g', 'xn--j1amh', 'xn--j1aef', 'xn--io0a7i', 'xn--imr513n', 'xn--i1b6b1a6a2e', 'xn--hxt814e', 'xn--h2brj9c8c', 'xn--h2brj9c', 'xn--h2breg3eve', 'xn--gk3at1e', 'xn--gecrj9c', 'xn--gckr3f0f', 'xn--g2xx48c', 'xn--fzys8d69uvgm', 'xn--fzc2c9e2c', 'xn--fpcrj9c3d', 'xn--flw351e', 'xn--fjq720a', 'xn--fiqz9s', 'xn--fiqs8s', 'xn--fiq64b', 'xn--fiq228c5hs', 'xn--fhbei', 'xn--fct429k', 'xn--efvy88h', 'xn--eckvdtc9d', 'xn--e1a4c', 'xn--d1alf', 'xn--d1acj3b', 'xn--czru2d', 'xn--czrs0t', 'xn--czr694b', 'xn--clchc0ea0b2g2a9gcd', 'xn--cg4bki', 'xn--cckwcxetd', 'xn--cck2b3b', 'xn--c2br7g', 'xn--c1avg', 'xn--bck1b9a5dre4c', 'xn--b4w605ferd', 'xn--9krt00a', 'xn--9et52u', 'xn--9dbq2a', 'xn--90ais', 'xn--90ae', 'xn--90a3ac', 'xn--8y0a063a', 'xn--80aswg', 'xn--80asehdb', 'xn--80aqecdr1a', 'xn--80ao21a', 'xn--80adxhks', 'xn--6qq986b3xl', 'xn--6frz82g', 'xn--5tzm5g', 'xn--5su34j936bgsg', 'xn--55qx5d', 'xn--55qw42g', 'xn--54b7fta0cc', 'xn--4gbrim', 'xn--4dbrk0ce', 'xn--45q11c', 'xn--45brj9c', 'xn--45br5cyl', 'xn--42c2d9a', 'xn--3pxu8k', 'xn--3hcrj9c', 'xn--3e0b707e', 'xn--3ds443g', 'xn--3bst00m', 'xn--30rr7y', 'xn--2scrj9c', 'xn--1qqw23a', 'xn--1ck2e1b', 'xn--11b4c3d', 'xin', 'xihuan', 'xfinity', 'xerox', 'xbox', 'wtf', 'wtc', 'ws', 'wow', 'world', 'works', 'work', 'woodside', 'wolterskluwer', 'wme', 'winners', 'wine', 'windows', 'win', 'williamhill', 'wiki', 'wien', 'whoswho', 'wf', 'weir', 'weibo', 'wedding', 'wed', 'website', 'weber', 'webcam', 'weatherchannel', 'weather', 'watches', 'watch', 'wanggou', 'wang', 'walter', 'walmart', 'wales', 'vuelos', 'vu', 'voyage', 'voto', 'voting', 'vote', 'volvo', 'volkswagen', 'vodka', 'vn', 'vlaanderen', 'vivo', 'viva', 'vision', 'visa', 'virgin', 'vip', 'vin', 'villas', 'viking', 'vig', 'video', 'viajes', 'vi', 'vg', 'vet', 'versicherung', 'verisign', 'ventures', 'vegas', 've', 'vc', 'vanguard', 'vana', 'vacations', 'va', 'uz', 'uy', 'us', 'ups', 'uol', 'uno', 'university', 'unicom', 'uk', 'ug', 'ubs', 'ubank', 'ua', 'tz', 'tw', 'tvs', 'tv', 'tushu', 'tunes', 'tui', 'tube', 'tt', 'trv', 'trust', 'travelersinsurance', 'travelers', 'travel', 'training', 'trading', 'trade', 'tr', 'toys', 'toyota', 'town', 'tours', 'total', 'toshiba', 'toray', 'top', 'tools', 'tokyo', 'today', 'to', 'tn', 'tmall', 'tm', 'tl', 'tkmaxx', 'tk', 'tjx', 'tjmaxx', 'tj', 'tirol', 'tires', 'tips', 'tiffany', 'tienda', 'tickets', 'tiaa', 'theatre', 'theater', 'thd', 'th', 'tg', 'tf', 'teva', 'tennis', 'temasek', 'tel', 'technology', 'tech', 'team', 'tdk', 'td', 'tci', 'tc', 'taxi', 'tax', 'tattoo', 'tatar', 'tatamotors', 'target', 'taobao', 'talk', 'taipei', 'tab', 'sz', 'systems', 'sydney', 'sy', 'sx
|
||
|
$now=time();
|
||
|
// files path will be the one where the top level requiring file resides
|
||
|
$ldlfp='tlds_last_dl_time';
|
||
|
$tldsfp='tlds-alpha-by-domain.txt';
|
||
|
$ldlt=@file_get_contents($ldlfp);
|
||
|
if ($ldlt===false) {
|
||
|
$ldlt=0;
|
||
|
} else {
|
||
|
$ldlt=rtrim($ldlt);
|
||
|
if (preg_match('#^\d+$#',$ldlt)!==1)
|
||
|
$ldlt=0;
|
||
|
else
|
||
|
$ldlt+=0;
|
||
|
}
|
||
|
if ($now-$ldlt>86400 || !file_exists($tldsfp)) {// if more than 1 day has passed since last list dl or list file can't be found
|
||
|
$url='https://data.iana.org/TLD/tlds-alpha-by-domain.txt';
|
||
|
$buf=@file_get_contents($url);
|
||
|
if ($buf===false)
|
||
|
echo "gettlds: could not download «{$url}»\n";
|
||
|
elseif (@file_put_contents($tldsfp,$buf)===false)
|
||
|
echo "gettlds: could not save «{$tldsfp}»\n";
|
||
|
elseif (@file_put_contents($ldlfp,$now."\n")===false)
|
||
|
echo "gettlds: could not save «{$ldlfp}»\n";
|
||
|
}
|
||
|
if (!isset($buf))
|
||
|
$buf=@file_get_contents($tldsfp);
|
||
|
if ($buf!==false) {
|
||
|
$tlds=[];
|
||
|
$buf=explode("\n",$buf);
|
||
|
foreach ($buf as $val)
|
||
|
if (trim($val)!=='' && $val[0]!='#')
|
||
|
$tlds[]=$val;
|
||
|
rsort($tlds);
|
||
|
foreach ($tlds as $key=>$val)
|
||
|
$tlds[$key]=strtolower($val);
|
||
|
}
|
||
|
return $tlds;
|
||
|
}
|
||
|
|
||
|
?>
|