Coder Social home page Coder Social logo

domain-availability's Introduction

Domain Availability

Latest Version on Packagist Software License Total Downloads

A PHP library used to check domain name availability.

#f03c15 READ THIS, SERIOUSLY:

This is not a reliable way to check for domain availability on a large or even a medium scale, this will not handle your "webhosting business" or anything that requires a high level of data accuracy, if you need something like that, please use WhoAPI or Namecheap's API.

And no, I did not build nor do i support the WordPress plugin that is being sold on CodeCanyon which uses this package under the hood.

Install

$ composer require --dev helgesverre/domain-availability

or

{
    "require": {
        "helgesverre/domain-availability": "~1.5.0"
    }
}

Usage

<?php

require './vendor/autoload.php';

use Helge\Loader\JsonLoader;
use Helge\Client\SimpleWhoisClient;
use Helge\Service\DomainAvailability;

$whoisClient = new SimpleWhoisClient();
$dataLoader = new JsonLoader("path/to/servers.json");

$service = new DomainAvailability($whoisClient, $dataLoader);

if ($service->isAvailable("helgesverre.com")) {
    echo "Domain is available";
} else {
    echo "Domain is already taken!";
}

or look at example.php for a more real world example.

Notes

The WHOIS server list is incomplete and some data is missing. The most popular TLDs are working, though, and I will update these as I can. I suggest making your own list of whois servers and their "not found"-responses so you know which TLD is available. For a full list of TLDs and WHOIS servers please go to the IANA website.

To check what they return when a domain is not found, you simply have to manually query the servers and check.

Supported Domain Extensions

These are the domain extensions that are supported by this script.

.com, .net, .org, .co.uk, .io, .computer, .ac, .academy, .actor, .ae, .aero, .af, .ag, 
.agency, .ai, .am, .archi, .arpa, .as, .asia, .associates, .at, .au, .aw, .ax, .az, .bar, 
.bargains, .bayern, .be, .berlin, .bg, .bi, .bike, .biz, .bj, .blackfriday, .bn, .boutique, .build, 
.builders, .bw, .by, .ca, .cab, .camera, .camp, .capital, .cards, .careers, .cat, .catering, 
.cc, .center, .ceo, .cf, .ch, .cheap, .christmas, .ci, .cl, .cleaning, .clothing, .club, 
.cn, .co, .codes, .coffee, .college, .cologne, .community, .company, .construction, 
.contractors, .cooking, .cool, .coop, .country, .cruises, .cx, .cz, .dating, .de, 
.democrat, .desi, .diamonds, .directory, .dk, .dm, .domains, .dz, .ec, .edu, .education,
.ee, .email, .engineering, .enterprises, .equipment, .es, .estate, .eu, .eus, .events,
.expert, .exposed, .farm, .feedback, .fi, .fish, .fishing, .flights, .florist, .fo, 
.foo, .foundation, .fr, .frogans, .futbol, .ga, .gal, .gd, .gg, .gi, .gift, .gl, .glass,
.gop, .gov, .gq, .graphics, .gripe, .gs, .guitars, .guru, .gy, .haus, .hk, .hn, .holiday, 
.horse, .house, .hr, .ht, .hu, .id, .ie, .il, .im, .immobilien, .in, .industries, 
.institute, .int, .international, .iq, .ir, .is, .it, .je, .jobs, .jp, .kaufen, .ke, 
.kg, .ki, .kitchen, .kiwi, .koeln, .kr, .kz, .la, .land, .lease, .li, .lighting, .limo, 
.link, .london, .lt, .lu, .luxury, .lv, .ly, .ma, .management, .mango, .marketing, .md,
.me, .media, .menu, .mg, .miami, .mk, .ml, .mn, .mo, .mobi, .moda, .monash, .mp, .ms,
.mu, .museum, .mx, .my, .na, .name, .nc, .nf, .ng, .ninja, .nl, .no, .nu, .nz, .om, 
.onl, .paris, .partners, .parts, .pe, .pf, .photo, .photography, .photos, .pics, 
.pictures, .pl, .plumbing, .pm, .post, .pr, .pro, .productions, .properties, .pt, 
.pub, .pw, .qa, .quebec, .re, .recipes, .reisen, .rentals, .repair, .report, .rest, 
.reviews, .rich, .ro, .rocks, .rodeo, .rs, .ru, .ruhr, .sa, .saarland, .sb, .sc, .se,
.services, .sexy, .sg, .sh, .shoes, .si, .singles, .sk, .sm, .sn, .so, .social, .solar, 
.solutions, .soy, .st, .su, .supplies, .supply, .support, .sx, .sy, .systems, .tattoo, 
.tc, .technology, .tel, .tf, .th, .tienda, .tips, .tk, .tl, .tm, .tn, .to, .today, 
.tools, .town, .toys, .tr, .training, .travel, .tv, .tw, .tz, .ua, .ug, .uk, .university, 
.us, .uy, .black, .blue, .info, .kim, .pink, .red, .shiksha, .uz, .vacations, .vc, .ve,
.vegas, .ventures, .vg, .viajes, .villas, .vision, .vodka, .voting, .voyage, .vu, .wang,
.watch, .wed, .wf, .wien, .wiki, .works, .ws, .xxx, .xyz, .yt, .za, .zm, .zone, 

Unsupported Domain Extensions

Due to the fact that a lot of the domain extensions listed on the IANA website do not contain any information on which WHOIS server to use when querying for the domain information, the following domain extensions are not available (yet):

.dj, .do, .eg, .eh, .er, .et, .fj, .fk, .fm, .gallery, .gb, .ge, .gf, .gh, .gm, .gn, .gp,
.gr, .gt, .gu, .gw, .hm, .jetzt, .jm, .jo, .kh, .km, .kn, .kp, .kred, .kw, .ky, .lb, 
.lk, .lr, .ls, .mc, .mf, .mh, .mil, .mm, .moe, .mq, .mr, .mt, .mv, .mw, .mz, .nagoya, .ne, 
.neustar, .ni, .np, .nr, .nyc, .okinawa, .pa, .pg, .ph, .pk, .pn, .ps, .py, .qpon, .ren, 
.rw, .sd, .sj, .sl, .sohu, .sr, .ss, .sv, .sz, .td, .tg, .tj, .tokyo, .tp, .trade, .tt, 
.um, .uno, .va, .vi, .vi, .vn, .webcam, .ye, .yokohoma, .ryukyu, .meet, .vote, .lc, 
.voto, .wed, .zw

If you know the whois server for any of these please feel free to create an issue with an update.

Credits

Notes

If you are getting the error:

Fatal error: Call to undefined function Pdp\idn_to_ascii()

Be sure to enable the php extension called intl as the domain parsing extension requires it!

If certain domain extensions are always or very often returning an unexpected value, please create an issue instead of emailing me in broken english. In your issue provide me with the following:

  • Your webhost
  • Link to your website where the error is happening
  • The extension and domain you are trying to check availability for

Keep in mind that this library queries the WHOIS servers directly and if you "spam" them with requests, you will get temporary banned and that will cause the library to say the domain always is taken.

License

The MIT License (MIT). Please see License File for more information.

domain-availability's People

Contributors

adililhan avatar chinmay241 avatar dmyers avatar dowayneb avatar ganeshpandey avatar helgesverre avatar kronthto avatar mostertb avatar mrk-j avatar orthographic-pedant avatar rufinus avatar seanhussey avatar stollr avatar tomasnorre avatar yusufonur avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

domain-availability's Issues

TLD not found

I follow your usage steps but i found this exception No WHOIS entry was found for that TLD

.ws wrong results

I have this domain tripto.ws when check for this domain it says available which it's wrong results
it should be not available any help here please!

vendor/autoload.php

cant find this file on the pack
'./vendor/autoload.php'

is there any other place where we can search for it?

cheers

domains .it .ue are always recorded

Hi,
Thanks for your great work!!!

With the help of a friend , I have modified a form with the script

But domains .it .ue are always recorded

Could you help me ?

This is the php file modified , but it may depend on the file instead AvailabilityService.php:

<?php
require('src/AvailabilityService.php');
$service = new HelgeSverre\DomainAvailability\AvailabilityService(true);

// define variables and set to empty values
$websiteErr = "";
$domain = "";
$availableDomain;
$isValid = false;


   if (empty($_POST["website"])) {
     $domain = "";
   } else {
     $domain = test_input($_POST["website"]);
     // check if URL address syntax is valid (this regular expression also allows dashes in the URL)
     if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$domain)) {
       $websiteErr = "Invalid URL"; 
     }
     else
        $isValid = true;
   }

function test_input($data) {
   $data = trim($data);
   $data = stripslashes($data);
   $data = htmlspecialchars($data);
   return $data;
}
?>

<h2>Ricerca Dominio</h2>
<p><span class="error">* required field.</span></p>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> 

   <br><br>
   Website: <input type="text" name="website" value="<?php echo $domain;?>">

   <span class="error"><?php echo $websiteErr;?></span>
   <br><br>

   <br><br>
   <input type="submit" name="submit" value="Submit"> 
</form>

<?php


    if ($domain != "" && $isValid)
    {
        $available = $service->isAvailable($domain);

        if ($available) {
            echo $domain." is not registered\n";
            $availableDomain = $domain;
        } else {
            echo $domain." is registered\n";
        }
    }
?>

'./vendor/ folder is missing

I've tried to test the script, but I've got a Fatal error:

require(): Failed opening required './vendor/autoload.php' (include_path='.:/usr/local/pear/php54') in example.php on line 9

Can you tell me why it's missing?

Class 'Pdp\Manager' not found

Hello,

I am using PHP 7.3.17 and I have the intl extension installed, but when I run the example.php file I get:

PHP Fatal error: Uncaught Error: Class 'Pdp\Manager' not found.

Has anyone experienced the same error?

Also, can someone tell me where to find the Pdp class docs?

Thanks.

.bayern is missing

Hi,

I'm using your script for a few weeks now but theres one new tld missing - that's .bayern. It would be cool if you may add it.

Best regards
Vitus

Fatal error: Interface 'Helge\Client\WhoisClientInterface' not found in /home/xxx/domainchecker/vendor/helgesverre/domain-availability/src/Client/SimpleWhoisClient.php on line 13

Hi Helge,

I'm trying to use your domain checker and I'm pretty sure it's the best open-source checker out there. However, I can't get it to work...

I'm using this test code :

isAvailable("helgesverre.com")) { echo "Domain is available"; } else { echo "Domain is already taken!"; } ?>

and I get this error Fatal error: Interface 'Helge\Client\WhoisClientInterface' not found in /home/xxx/domainchecker/vendor/helgesverre/domain-availability/src/Client/SimpleWhoisClient.php on line 13

Thanks to help me

Run without composer?

Hi, I want to integrate your code to my current project and deploy to remote server. Possible I integrate without this line of code? Thanks

require './vendor/autoload.php';

on searching .co.uk or co.in getting error

Fatal error: Uncaught exception 'Exception' with message 'No WHOIS entry was found for that TLD' in /var/www/html/api/domain/src/Service/DomainAvailability.php:50

I tried to add co.uk or co.in servers to src/data/servers.json then error message is comming WHOIS query failed

Please help.

Fatal error

( ! ) Fatal error: Call to undefined function Pdp\idn_to_ascii() in C:\wamp\www\Domain-Availability-master\vendor\jeremykendall\php-domain-parser\src\Pdp\Parser.php on line 319
Call Stack

Time Memory Function Location

1 0.0004 251176 {main}( ) ..\example.php:0
2 0.0094 645272 Helge\Service\DomainAvailability->isAvailable( ) ..\example.php:35
3 0.0094 645424 Helge\Service\DomainAvailability->parse( ) ..\DomainAvailability.php:47
4 0.0228 2459456 Pdp\Parser->isSuffixValid( ) ..\DomainAvailability.php:99
5 0.0228 2459608 Pdp\Parser->getRawPublicSuffix( ) ..\Parser.php:245
6 0.0228 2459688 Pdp\Parser->normalize( ) ..\Parser.php:154

Bug in get_tld function

Hi,
I think your count test in get_tld function is not right :
You use the explode function with '.' as delimiter then check
if(count($split) === 0)
but even if there is no '.' in the domain name, explode will return a 1 element array with the whole incorrect string in it.
So get_tld('foo') will not throw the expected exception. I think this test solves it :
if(count($split) < 2 )

explode documentation : If delimiter contains a value that is not contained in string and a negative limit is used, then an empty array will be returned, otherwise an array containing string will be returned.

By the way, thank you for this so usefull class.

Refactor script

The big refactor

TODO List

  • Adhere to the coding standards set forth in PSR-2 (and consequentially PSR-1)
  • Adhere to autoloading standards set forth in PSR-4
  • Add composer support under the Helge\ namepsace
  • Use CURL instead of file_get_contents
  • Add Unit tests (PHPUnit)
  • Add Travis.yml
  • Write better Documentation
  • Create a GitHub Page with said documentation

nic.cz

Server whois.nic.cz sometimes returns "Your connection limit exceeded. Please slow down and try again later.". The domain then misidentifies it.

Always return registered.

I am trying localhost. I tried other tld's for check if i over query limiteion but all of tlds return registered.

gethostbyname logic + example issues

Hi -

On ~line 418 in AvailabilityScript.php there is a check to determine if the domain name == the ipv4 address (as returned by gethostbyname). This will always fail meaning isAvaible will always return false. Not sure why this is being done?:

if (gethostbyname($domain) == $domain) { 
    $tld = $this->getTld($domain);

Also, the logic in the README for the example usage is wrong. This:

if ($available) { 
    echo $domain." is not registered\n";
} else {
    echo $domain." is registered\n";
}

Should probably be something like this:

if ($available === false) {
    echo $domain." is not registered\n";
} else {
    echo $domain." is registered\n";
}

Whois for .gq

please amend the following domain whois to the servers list

"gq": {
    "server": "whois.dominio.gq",
    "not_found": "domain name not known"
},

make tlds available

I would like to be able to get the list of supported tlds

something like:

public function getTlds() {
  return array_keys($this->whois);
}

.do whois server

Hello,

i think the whois server of the domain .do is whois.nic.do

Invalid .IN WHOIS Server

I noticed the servers.json is using the old WHOIS Server for .IN TLDs which don't operate anymore. This needs a update as well as adding support for newer 2nd Level .IN Domains

  • .IN
  • CO.IN
  • NET.IN
  • FIRM.IN
  • GEN.IN
  • ORG.IN

Showing available domain as unavailable

Today I did just a small test. First, I tried to find a domain that for sure is available. So I visited the official Verisign page (http://www.verisign.com/en_US/domain-names/index.xhtml) and inserted a domain name "sjekruze.com" (I just wanted some nonsense word for the test purpose). See the Screenshot attached:
verisign-test
Next, I went to your Ajax Call example, edited the domain variable to "sjekruze.com" - here: http://jsfiddle.net/cs8t1jgf/4/ but the result is "sjekruze.com is not available or invalid". So, my first test failed. So please, can you confirm that the code is basically working? Maybe there is a small problem somewhere that I do not see...anyways, this script is very useful and thank you for your time making this.

Add a positive test for more certainty

Hi,

at the current state DomainAvailability::isAvailable only checks if the 'not_found' string that is specified in the servers.json is found in the response to declare a domain as available.

But the response for available domains may change from time to time, which would leads to wrong results. See #50 for example.

To return a trustworthier result it would be better to also do a positive test.

For the .io tld one could change the servers.json to

  "io": {
    "server": "whois.nic.io",
    "not_found": "NOT FOUND",
    "found": "Registry Domain ID"
  },

The check could be extended now to:

    // DomainAvailability.php
    // Check if the WHOIS data contains the "not found"-string
    if (strpos($whoisData, $whoisServerInfo["not_found"]) !== false) {
        // The domain is available
         return true;
    } else if (!isset($whoisServerInfo["found"]) || strpos($whoisData, $whoisServerInfo["found"]) !== false) {
        // If we've come this far, the domain is not available.
        return false;
    }
    throw new \Exception('The domain registration status is not clear.');

The use of the isset makes sure that the additional test is only done for tlds that have the new 'found'-key.

What do you mean? If you like it, I'd be happy to create a PR.

this code can't use.

This is stupid code, i have downloaded and put in my server but example can't run.

com.tr

Hello,

can you upload this tld's:
.com.tr, .gen.tr, .biz.tr

I think it the same of
"tr": {
"server": "whois.nic.tr",
"not_found": "Invalid input"
},

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.