44 lines
1.6 KiB
PHP
Executable File
44 lines
1.6 KiB
PHP
Executable File
<?php
|
|
$nomFicAppelant = basename(__FILE__);
|
|
function is_valid_domain($url) {
|
|
|
|
$validation = FALSE;
|
|
/*Parse URL*/
|
|
$urlparts = parse_url(filter_var($url, FILTER_SANITIZE_URL));
|
|
/*Check host exist else path assign to host*/
|
|
if (!isset($urlparts['host'])) {
|
|
$urlparts['host'] = $urlparts['path'];
|
|
}
|
|
if ($urlparts['host']!='') {
|
|
/*Add scheme if not found*/
|
|
// echo 'urlparts[host] ' .$urlparts['host'];
|
|
// echo 'urlparts[scheme] ' .$urlparts['scheme'];
|
|
if (!isset($urlparts['scheme'])) {
|
|
$urlparts['scheme'] = 'http';
|
|
}
|
|
/*Validation*/
|
|
if (checkdnsrr($urlparts['host'], 'A') && in_array($urlparts['scheme'],array('http','https')) && ip2long($urlparts['host']) === FALSE) {
|
|
$urlparts['host'] = preg_replace('/^www\./', '', $urlparts['host']);
|
|
$url = $urlparts['scheme']. '://' .$urlparts['host']. "/";
|
|
|
|
if (filter_var($url, FILTER_VALIDATE_URL) !== false && @get_headers($url)) {
|
|
$validation = TRUE;
|
|
}
|
|
}
|
|
}
|
|
|
|
// if (!$validation) {
|
|
// echo "<br>$url is Invalid Domain Name. ";
|
|
// }else {
|
|
// echo "<br>$url is a Valid Domain Name. ";
|
|
// }
|
|
|
|
// if (!$validation) {
|
|
// echo "$domToBuy " .$seoMsg[18];
|
|
// }else {
|
|
// echo "$domToBuy " .$seoMsg[19];
|
|
// }
|
|
return $validation;
|
|
exit;
|
|
}
|
|
?>
|