Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is the code i made that 100% finds only the domain name, since it takes mozilla sub tlds to account. Only thing you have to check is how you make cache of that file, so you dont query mozilla every time. </p> <p>For some strange reason, domains like co.uk are not in the list, so you have to make some hacking and add them manually. Its not cleanest solution but i hope it helps someone. </p> <pre><code>//===================================================== static function domain($url) { $slds = ""; $url = strtolower($url); $address = 'http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/effective_tld_names.dat?raw=1'; if(!$subtlds = @kohana::cache('subtlds', null, 60)) { $content = file($address); foreach($content as $num =&gt; $line) { $line = trim($line); if($line == '') continue; if(@substr($line[0], 0, 2) == '/') continue; $line = @preg_replace("/[^a-zA-Z0-9\.]/", '', $line); if($line == '') continue; //$line = '.'.$line; if(@$line[0] == '.') $line = substr($line, 1); if(!strstr($line, '.')) continue; $subtlds[] = $line; //echo "{$num}: '{$line}'"; echo "&lt;br&gt;"; } $subtlds = array_merge(Array( 'co.uk', 'me.uk', 'net.uk', 'org.uk', 'sch.uk', 'ac.uk', 'gov.uk', 'nhs.uk', 'police.uk', 'mod.uk', 'asn.au', 'com.au', 'net.au', 'id.au', 'org.au', 'edu.au', 'gov.au', 'csiro.au', ),$subtlds); $subtlds = array_unique($subtlds); //echo var_dump($subtlds); @kohana::cache('subtlds', $subtlds); } preg_match('/^(http:[\/]{2,})?([^\/]+)/i', $url, $matches); //preg_match("/^(http:\/\/|https:\/\/|)[a-zA-Z-]([^\/]+)/i", $url, $matches); $host = @$matches[2]; //echo var_dump($matches); preg_match("/[^\.\/]+\.[^\.\/]+$/", $host, $matches); foreach($subtlds as $sub) { if (preg_match("/{$sub}$/", $host, $xyz)) preg_match("/[^\.\/]+\.[^\.\/]+\.[^\.\/]+$/", $host, $matches); } return @$matches[0]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload