Jump to content

How to block free domain name extensions like .tk?


Recommended Posts

HI Jafar,

4 hours ago, Jafar Muhammed said:

I wish to block free domain name extensions like .tk. When people are trying to place an order with .tk or similar TLDs, the system must not allow them to use those domains.

Is there any way to accomplish this?

if you wanted to block specific domains, e.g gmail.com, from signing up, then you could have used the Banned Email Domains option...

https://docs.whmcs.com/Security/Ban_Control#Banning_Email_Domains

Quote

With WHMCS it is possible to ban email domains from signing up. This is useful if you want to block customers signing up using free email accounts.

To enable this feature, simply go to Setup > Other > Manage Banned Emails. You will then see a list of all the currently banned email domains and the number of times a customer has attempted to signup using them.

To add a new banned email domain, click the Add tab at the top of the page and then enter the email domain you wish to ban, for example "hotmail.com".

but you effectively want to use a wildcard domain (e.g the client might be using mail@jafar.tk or mail@brian.tk) and I doubt the above feature would support that.

I suspect that you would have to use a client validation hook and display an error message if someone tries to register using a .tk email address...

<?php

# Block .tk Email Addresses From Registering Hook
# Written by brian!

add_hook('ClientDetailsValidation', 1, function($vars) {
	
	if (substr($vars['email'], -3) == '.tk') {
		return Lang::trans('clientareaerroremailinvalid');
	}
});

glgcjWU.png

so this basic hook will return the above error string (in the user's current language) if they try to use a .tk address and the registration will not progress until they use a valid email address.

you can easily change the hook to use another language string, or hard-code the error reply instead (e.g if your site only uses one language and you want to warn them specifically about using .tk domains), or even expand the hook to block other TLDs or domains.

Link to comment
Share on other sites

Hello @brian!

I am not about blocking email addresses with disposable domain names for signing up. 

I used to get people to sign up, for example.tk, for example.cf etc. 

In the Cart page when someone places an order for a shared hosting account, they shouldn't be able to place an order for such free domain names. 

Do we have any workaround for that?

Link to comment
Share on other sites

There's a way but...

36 minutes ago, Jafar Muhammed said:

they shouldn't be able to place an order for such free domain names.

Just why? 🤔 You sold an hosting package. What's the problem in using .tk domains? They cause no harm. If you block .tk domains these people won't be able to place an order with you therefore you are willing to lose money for no apparent reason.

Edited by Kian
Link to comment
Share on other sites

These are disposable domain names. People register this for free, and after a few weeks, Freenom will remove the domain name. 

Most of these customers are indeed first time customers, and they don't have much knowledge about how domains and hosting accounts works. 

When Freenom terminates their free domains, these people first assume that it is an issue with my service. 

Most of the time, the people who are only looking for free or cheap service will be tough to convert as a paying customer. 

So technically for me at least, it is a waste of my resources. 

Link to comment
Share on other sites

Instead of preventing them from using .tk domains and lose money, why don't you just show them an alert where you explain that .tk domains last for a very limited amount of time and that it's not your fault if the website stops working. You could even encourage them to register a more serious TLD. You could show this message as soon as they add the .tk domain.

Link to comment
Share on other sites

I'm guessing you want to block the service domain from being a .tk domain and not like the customer's contact info.  As such this hook should do the trick:

add_hook('ShoppingCartValidateDomain', 1, function($vars)
{
    if ($vars['tld'] === '.tk')
        return array(".tk Domains are not accepted for services. ");
    else
        return false; // validates 
});

Though on testing it doesn't return the error but some generic error and tried it with a string and array as docs say it takes both.

Link to comment
Share on other sites

3 hours ago, Jafar Muhammed said:

Nope @brian!

Not just .tk, I want to block all the free TLDs which Freenom offers.

In that case, check this hook would be better as you can add the TLDs to the array instead of duplicating:

add_hook('ShoppingCartValidateDomain', 1, function($vars)
{
    $BlockedTLDS = array('.tk','.free','.nomies','.mmmm');
    
    if (in_array( $vars['tld'], $BlockedTLDS))
        return array(".tk Domains are not accepted for services. ");
    else
        return false;
});

 

Link to comment
Share on other sites

The problem is that ShoppingCartValidateDomain doesn't work 😀 Not with standard cart. It only works on discontinued orderform templates like Modern. It's a known issue. I don't know if it works with the latest version of WHMCS. For sure it doesn't on 7.6.1 (can't try on newer WHMCS atm).

Edited by Kian
Link to comment
Share on other sites

On 17/04/2019 at 18:41, Jafar Muhammed said:

Nope @brian!

Not just .tk, I want to block all the free TLDs which Freenom offers.

ok - if you were, then removing them (or at least not setting a price) from your domain pricing would have removed them as registration/transfer options for products and would have left you with only "use existing domain" option to take care of.

in the absence of the ShoppingCartValidateDomain hook not responding correctly (which has been known about for at least 6 months by WHMCS and was why I didn't suggest it), there are a few other options...

  • you could validate it at checkout with a hook, but that's not really practical as it's too late by then to send them back to choose another domain...
  • you could use a html5 pattern in the template, but as they're case sensitive, you'd need to cover all permutations of cf, ga, gq, ml and tk - doable, but again not really practical.
    lV9DoCn.png
  • you could use a footer hook to disallow these TLDs using jQuery - e.g so that if someone enters .tk (.cf or whatever), it removes it from the TLD field and the user will have to enter another TLD (or you can make it show an INVALID error in the TLD form field itself)... i'm not sure if you can easily show an error similar to the patterns output though... I suppose you could use Language Overrides to change the "I will use my existing domain and update my nameservers" string to tell the users that these TLDs will be blocked.
Link to comment
Share on other sites

14 hours ago, Jafar Muhammed said:

This seems an easy fix. I will give a try.

it's not really a fix - it's more like a warning outside a shop not to steal... it might make some users think, but it won't stop the the naughty ones! 👮‍♂️

try it alongside the attached hook - it should prevent users trying to add any free freenom TLD as an existing domain option...

block_freenom.php

Link to comment
Share on other sites

4 minutes ago, Jafar Muhammed said:

Interestingly, I found one thing, m cart accepts .tk.

that implies the hook isn't working, because if it was, the field would be emptied.

7 minutes ago, Jafar Muhammed said:

And when I try .ml, .ga, .cf, .gq, I get Invalid domain name provided error. Screenshot https://prnt.sc/nev8xy

I switched between ResellerClub and WHMCS Name Spinning as my Lookup Provider. 

almost certainly, resellerclub and Namespinning (which is eNom) won't sell these free TLDs, so WHMCS will revert to using the whois server entries for these TLD checks... there is an entry for .tk, but not for the others... I did consider suggesting removing .tk from the whois list, but it's not a foolproof solution.

the fact it gives that error is a long-standing bug... WHMCS has for years often shown the wrong error messages in the cart... e.g the error message bears no relation to the actual error. 🙄

Link to comment
Share on other sites

  • 3 years later...
  • 2 weeks later...

Hello,

The document referenced in the previous post offers instructions on how to prevent cPanel users from creating certain domain names as addon domains or aliases but does not apply to new account creations in Web Host Manager. I encourage you to open a feature request if you'd like to see an option that prevents resellers from creating certain domain extensions as new accounts.

Thanks

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated