Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

verifying a domain using php

Tags:

php

I have a member area, where they can add their domains and it will be displayed in the profile page..but now I want to add a verification process, just like google web-masters does..where they need to upload a certain file and so.. please tell me whats the best way to do this ?

Thanks :)

like image 581
Vamsi Krishna B Avatar asked Sep 27 '10 14:09

Vamsi Krishna B


People also ask

How to verify domain in PHP?

We can do this in PHP via Regx aka Regular Expression. We can perform 3 checks: first, the characters need to be lowercase/uppercases, digits, hypens, and dots. Second, the overall domain length should between 1 to 253. Lastly, the length of each label (separated by dots) should be no longer than 63 characters.

How do you validate a domain?

If you want to find out if a domain name is validated, simply type the URL into the WHOIS database. The search results will also provide you with other crucial information such as who owns it, when it was registered and when it is due to expire.

How can I check if an email address is valid in PHP?

The easiest and safest way to check whether an email address is well-formed is to use PHP's filter_var() function.

How do I find the regex for a domain name?

[A-Za-z0-9-]{1, 63} represents the domain name should be a-z or A-Z or 0-9 and hyphen (-) between 1 and 63 characters long.


1 Answers

  1. Generate a token for each domain (sha-1 of domain or so), store it in your DB or what have you.
  2. Generate a text-file containing the token on user request.
  3. Ask the user to inform you to poll or poll every now and then to check the URL. This can easily be done by file_get_contents in PHP if fopen_wrappers are enabled.
  4. The token is obviously compared to the token in your DB to make sure it wasn't just a random file present at a random domain..
  5. Could be a good idea to check at some time interval if the file is still there, to keep someone from selling the domain but remain in control

It's not really black art as we can assume the user has access to its domain once any specific request which proves access can be fulfilled by the user. There's no real way to fool the system except doing some DNS-magic, or gaining entry to the webserver running on the domain, which is out of your control anyway.

like image 116
Alexander Sagen Avatar answered Oct 10 '22 12:10

Alexander Sagen