Anzeige

 Domain-Check


Status
Dieses Thema wurde gelöst! Zur Lösung gehen…

CreativPur

Erfahrenes Mitglied
#1
Hi,

ich habe ein PHP-Script für ein Domain-Check.
Nun versuche ich seit Tagen das dazu passende Formular zu schreiben.
Leider hapert es an dieser stelle. Zumindest funktioniert es nicht.

Das PHP-Script

PHP:
<?php if(preg_match('/\Ahttps?:\/\/([-\w\.]+)+(:\d+)?(\/([\w\/_\.]*(\?\S+)?)?)?\Z/', 'http://'.$_POST['domain'])) // URL auf validität überprüfen.
{
  $whois=array(); // Array initialisieren. Es folgen Deklarationen des mehrdimensionalem Arrays.
  $whois['.de']['server']='whois.denic.de';
  $whois['.de']['string']='Status:      free';
  $whois['.com']['server']='whois.crsnic.net';
  $whois['.com']['string']='No match for';
  $whois['.net']['server']='whois.crsnic.net';
  $whois['.net']['string']='No match for';
  $whois['.org']['server']='whois.publicinterestregistry.net';
  $whois['.org']['string']='NOT FOUND';
  $whois['.info']['server']='whois.afilias.net';
  $whois['.info']['string']='NOT FOUND';
  $whois['.biz']['server']='whois.nic.biz';
  $whois['.biz']['string']='Not found';
  $whois['.ag']['server']='whois.nic.ag';
  $whois['.ag']['string']='NOT FOUND';
  $whois['.am']['server']='whois.nic.am';
  $whois['.am']['string']='No match';
  $whois['.as']['server']='whois.nic.as';
  $whois['.as']['string']='Domain Not Found';
  $whois['.at']['server']='whois.nic.at';
  $whois['.at']['string']='nothing found';
  $whois['.be']['server']='whois.dns.be';
  $whois['.be']['string']='Status:      FREE';
  $whois['.cd']['server']='whois.cd';
  $whois['.cd']['string']='No match';
  $whois['.ch']['server']='whois.nic.ch';
  $whois['.ch']['string']='not have an entry';
  $whois['.cx']['server']='whois.nic.cx';
  $whois['.cx']['string']='Status: Not Registered';
  $whois['.dk']['server']='whois.dk-hostmaster.dk';
  $whois['.dk']['string']='No entries found';
  $whois['.it']['server']='whois.nic.it';
  $whois['.it']['string']='Status: AVAILABLE';
  $whois['.li']['server']='whois.nic.li';
  $whois['.li']['string']='do not have an entry';
  $whois['.lu']['server']='whois.dns.lu';
  $whois['.lu']['string']='No such domain';
  $whois['.nu']['server']='whois.nic.nu';
  $whois['.nu']['string']='NO MATCH for';
  $whois['.ru']['server']='whois.ripn.net';
  $whois['.ru']['string']='No entries found';
  $whois['.uk.com']['server']='whois.centralnic.com';
  $whois['.uk.com']['string']='No match for';
  $whois['.eu.com']['server']='whois.centralnic.com';
  $whois['.eu.com']['string']='No match';
  $whois['.ws']['server']='whois.nic.ws';
  $whois['.ws']['string']='No match for';

  $domain=str_replace('www.', '', $_POST['domain']); // Solche Dinge sind Detailssache (..)  Letztlich muss die Anfrage an den WHOIS-Server ohne http::// , www. usw. stattfinden. -> Nur Domainname und Domainendung.

  if(get_magic_quotes_gpc==0)
  {
    $domain=addslashes($domain);
  }

// Verbindung zum whois server aufbauen / Status der Domain erfragen.

 $check=fsockopen($whois[$_POST['tld']]['server'], 43);
  fputs($check, $domain.$_POST['tld']."\r\n");
  while(!feof($check)) 
  {
    $report=$report.fgets($check, 128);
  }
  fclose($check);
  
  if(ereg($whois[$_POST['tld']]['string'], $report)) // Was soll geschehen, wenn domain noch frei ist?
  {
    print('domain frei.');
  }
  else // Was, wenn nicht?
  {
    print('domain nicht frei.');
  }
}
?>
Das Formular

HTML:
<form action="#" method="post">

<input name="domain" type="text" size="30" />&nbsp;&nbsp;<input name="server" type="text" size="5" />
<br />
<input name="" type="submit" />


</form>
Kann mir da jemand helfen ?
Vielen Dank
 

basti1012

Erfahrenes Mitglied
#4
Bei Action kommt der Link rein wo das Script ist ,bzw kein Link wenn alles auf einer Seite ist.
Aber dein Script ( php-einfach ) funktioniert bei mir auch nicht.
Hier https://serversupportforum.de/forum/projekte/37890-php-script-domaincheck.html
wird eine alternative besprochen bzw sprechen die darüber.
Ist aber auch schon älter und ob das alles noch so geht muß man testen.
Googel doch mal einfach nach ein aktuellen Script dafür weil bei php-einfach sind die Scropte auch schon alle etwas älter
 

CreativPur

Erfahrenes Mitglied
#5
Ich habe jetzt ein Script gefunden, welches sogar funktioniert.
Leider wird mir bei diesem Script bei belegter Domain zu viel Info ausgegeben.
Dabei möchte ich nur, das folgendes ausgegeben wird:
Die Domain xxxxx.de existiert schon.
Bildschirmfoto 2018-11-20 um 09.27.32.png

Der Quelltext:

PHP:
<?php
/*************************************************************************
php easy :: whois lookup script
==========================================================================
Author:      php easy code, www.phpeasycode.com
Web Site:    http://www.phpeasycode.com
Contact:     webmaster@phpeasycode.com
*************************************************************************/
$domain = $_GET['domain'];
// For the full list of TLDs/Whois servers see http://www.iana.org/domains/root/db/ and http://www.whois365.com/en/listtld/
$whoisservers = array(
    "ac" => "whois.nic.ac", // Ascension Island
    // ad - Andorra - no whois server assigned
    "ae" => "whois.nic.ae", // United Arab Emirates
    "aero"=>"whois.aero",
    "af" => "whois.nic.af", // Afghanistan
    "ag" => "whois.nic.ag", // Antigua And Barbuda
    "ai" => "whois.ai", // Anguilla
    "al" => "whois.ripe.net", // Albania
    "am" => "whois.amnic.net",  // Armenia
    // an - Netherlands Antilles - no whois server assigned
    // ao - Angola - no whois server assigned
    // aq - Antarctica (New Zealand) - no whois server assigned
    // ar - Argentina - no whois server assigned
    "arpa" => "whois.iana.org",
    "as" => "whois.nic.as", // American Samoa
    "asia" => "whois.nic.asia",
    "at" => "whois.nic.at", // Austria
    "au" => "whois.aunic.net", // Australia
    // aw - Aruba - no whois server assigned
    "ax" => "whois.ax", // Aland Islands
    "az" => "whois.ripe.net", // Azerbaijan
    // ba - Bosnia And Herzegovina - no whois server assigned
    // bb - Barbados - no whois server assigned
    // bd - Bangladesh - no whois server assigned
    "be" => "whois.dns.be", // Belgium
    "bg" => "whois.register.bg", // Bulgaria
    "bi" => "whois.nic.bi", // Burundi
    "biz" => "whois.biz",
    "bj" => "whois.nic.bj", // Benin
    // bm - Bermuda - no whois server assigned
    "bn" => "whois.bn", // Brunei Darussalam
    "bo" => "whois.nic.bo", // Bolivia
    "br" => "whois.registro.br", // Brazil
    "bt" => "whois.netnames.net", // Bhutan
    // bv - Bouvet Island (Norway) - no whois server assigned
    // bw - Botswana - no whois server assigned
    "by" => "whois.cctld.by", // Belarus
    "bz" => "whois.belizenic.bz", // Belize
    "ca" => "whois.cira.ca", // Canada
    "cat" => "whois.cat", // Spain
    "cc" => "whois.nic.cc", // Cocos (Keeling) Islands
    "cd" => "whois.nic.cd", // Congo, The Democratic Republic Of The
    // cf - Central African Republic - no whois server assigned
    "ch" => "whois.nic.ch", // Switzerland
    "ci" => "whois.nic.ci", // Cote d'Ivoire
    "ck" => "whois.nic.ck", // Cook Islands
    "cl" => "whois.nic.cl", // Chile
    // cm - Cameroon - no whois server assigned
    "cn" => "whois.cnnic.net.cn", // China
    "co" => "whois.nic.co", // Colombia
    "com" => "whois.verisign-grs.com",
    "coop" => "whois.nic.coop",
    // cr - Costa Rica - no whois server assigned
    // cu - Cuba - no whois server assigned
    // cv - Cape Verde - no whois server assigned
    // cw - Curacao - no whois server assigned
    "cx" => "whois.nic.cx", // Christmas Island
    // cy - Cyprus - no whois server assigned
    "cz" => "whois.nic.cz", // Czech Republic
    "de" => "whois.denic.de", // Germany
    // dj - Djibouti - no whois server assigned
    "dk" => "whois.dk-hostmaster.dk", // Denmark
    "dm" => "whois.nic.dm", // Dominica
    // do - Dominican Republic - no whois server assigned
    "dz" => "whois.nic.dz", // Algeria
    "ec" => "whois.nic.ec", // Ecuador
    "edu" => "whois.educause.edu",
    "ee" => "whois.eenet.ee", // Estonia
    "eg" => "whois.ripe.net", // Egypt
    // er - Eritrea - no whois server assigned
    "es" => "whois.nic.es", // Spain
    // et - Ethiopia - no whois server assigned
    "eu" => "whois.eu",
    "fi" => "whois.ficora.fi", // Finland
    // fj - Fiji - no whois server assigned
    // fk - Falkland Islands - no whois server assigned
    // fm - Micronesia, Federated States Of - no whois server assigned
    "fo" => "whois.nic.fo", // Faroe Islands
    "fr" => "whois.nic.fr", // France
    // ga - Gabon - no whois server assigned
    "gd" => "whois.nic.gd", // Grenada
    // ge - Georgia - no whois server assigned
    // gf - French Guiana - no whois server assigned
    "gg" => "whois.gg", // Guernsey
    // gh - Ghana - no whois server assigned
    "gi" => "whois2.afilias-grs.net", // Gibraltar
    "gl" => "whois.nic.gl", // Greenland (Denmark)
    // gm - Gambia - no whois server assigned
    // gn - Guinea - no whois server assigned
    "gov" => "whois.nic.gov",
    // gr - Greece - no whois server assigned
    // gt - Guatemala - no whois server assigned
    "gs" => "whois.nic.gs", // South Georgia And The South Sandwich Islands
    // gu - Guam - no whois server assigned
    // gw - Guinea-bissau - no whois server assigned
    "gy" => "whois.registry.gy", // Guyana
    "hk" => "whois.hkirc.hk", // Hong Kong
    // hm - Heard and McDonald Islands (Australia) - no whois server assigned
    "hn" => "whois.nic.hn", // Honduras
    "hr" => "whois.dns.hr", // Croatia
    "ht" => "whois.nic.ht", // Haiti
    "hu" => "whois.nic.hu", // Hungary
    // id - Indonesia - no whois server assigned
    "ie" => "whois.domainregistry.ie", // Ireland
    "il" => "whois.isoc.org.il", // Israel
    "im" => "whois.nic.im", // Isle of Man
    "in" => "whois.inregistry.net", // India
    "info" => "whois.afilias.net",
    "int" => "whois.iana.org",
    "io" => "whois.nic.io", // British Indian Ocean Territory
    "iq" => "whois.cmc.iq", // Iraq
    "ir" => "whois.nic.ir", // Iran, Islamic Republic Of
    "is" => "whois.isnic.is", // Iceland
    "it" => "whois.nic.it", // Italy
    "je" => "whois.je", // Jersey
    // jm - Jamaica - no whois server assigned
    // jo - Jordan - no whois server assigned
    "jobs" => "jobswhois.verisign-grs.com",
    "jp" => "whois.jprs.jp", // Japan
    "ke" => "whois.kenic.or.ke", // Kenya
    "kg" => "www.domain.kg", // Kyrgyzstan
    // kh - Cambodia - no whois server assigned
    "ki" => "whois.nic.ki", // Kiribati
    // km - Comoros - no whois server assigned
    // kn - Saint Kitts And Nevis - no whois server assigned
    // kp - Korea, Democratic People's Republic Of - no whois server assigned
    "kr" => "whois.kr", // Korea, Republic Of
    // kw - Kuwait - no whois server assigned
    // ky - Cayman Islands - no whois server assigned
    "kz" => "whois.nic.kz", // Kazakhstan
    "la" => "whois.nic.la", // Lao People's Democratic Republic
    // lb - Lebanon - no whois server assigned
    // lc - Saint Lucia - no whois server assigned
    "li" => "whois.nic.li", // Liechtenstein
    // lk - Sri Lanka - no whois server assigned
    "lt" => "whois.domreg.lt", // Lithuania
    "lu" => "whois.dns.lu", // Luxembourg
    "lv" => "whois.nic.lv", // Latvia
    "ly" => "whois.nic.ly", // Libya
    "ma" => "whois.iam.net.ma", // Morocco
    // mc - Monaco - no whois server assigned
    "md" => "whois.nic.md", // Moldova
    "me" => "whois.nic.me", // Montenegro
    "mg" => "whois.nic.mg", // Madagascar
    // mh - Marshall Islands - no whois server assigned
    "mil" => "whois.nic.mil",
    // mk - Macedonia, The Former Yugoslav Republic Of - no whois server assigned
    "ml" => "whois.dot.ml", // Mali
    // mm - Myanmar - no whois server assigned
    "mn" => "whois.nic.mn", // Mongolia
    "mo" => "whois.monic.mo", // Macao
    "mobi" => "whois.dotmobiregistry.net",
    "mp" => "whois.nic.mp", // Northern Mariana Islands
    // mq - Martinique (France) - no whois server assigned
    // mr - Mauritania - no whois server assigned
    "ms" => "whois.nic.ms", // Montserrat
    // mt - Malta - no whois server assigned
    "mu" => "whois.nic.mu", // Mauritius
    "museum" => "whois.museum",
    // mv - Maldives - no whois server assigned
    // mw - Malawi - no whois server assigned
    "mx" => "whois.mx", // Mexico
    "my" => "whois.domainregistry.my", // Malaysia
    // mz - Mozambique - no whois server assigned
    "na" => "whois.na-nic.com.na", // Namibia
    "name" => "whois.nic.name",
    "nc" => "whois.nc", // New Caledonia
    // ne - Niger - no whois server assigned
    "net" => "whois.verisign-grs.net",
    "nf" => "whois.nic.nf", // Norfolk Island
    "ng" => "whois.nic.net.ng", // Nigeria
    // ni - Nicaragua - no whois server assigned
    "nl" => "whois.domain-registry.nl", // Netherlands
    "no" => "whois.norid.no", // Norway
    // np - Nepal - no whois server assigned
    // nr - Nauru - no whois server assigned
    "nu" => "whois.nic.nu", // Niue
    "nz" => "whois.srs.net.nz", // New Zealand
    "om" => "whois.registry.om", // Oman
    "org" => "whois.pir.org",
    // pa - Panama - no whois server assigned
    "pe" => "kero.yachay.pe", // Peru
    "pf" => "whois.registry.pf", // French Polynesia
    // pg - Papua New Guinea - no whois server assigned
    // ph - Philippines - no whois server assigned
    // pk - Pakistan - no whois server assigned
    "pl" => "whois.dns.pl", // Poland
    "pm" => "whois.nic.pm", // Saint Pierre and Miquelon (France)
    // pn - Pitcairn (New Zealand) - no whois server assigned
    "post" => "whois.dotpostregistry.net",
    "pr" => "whois.nic.pr", // Puerto Rico
    "pro" => "whois.dotproregistry.net",
    // ps - Palestine, State of - no whois server assigned
    "pt" => "whois.dns.pt", // Portugal
    "pw" => "whois.nic.pw", // Palau
    // py - Paraguay - no whois server assigned
    "qa" => "whois.registry.qa", // Qatar
    "re" => "whois.nic.re", // Reunion (France)
    "ro" => "whois.rotld.ro", // Romania
    "rs" => "whois.rnids.rs", // Serbia
    "ru" => "whois.tcinet.ru", // Russian Federation
    // rw - Rwanda - no whois server assigned
    "sa" => "whois.nic.net.sa", // Saudi Arabia
    "sb" => "whois.nic.net.sb", // Solomon Islands
    "sc" => "whois2.afilias-grs.net", // Seychelles
    // sd - Sudan - no whois server assigned
    "se" => "whois.iis.se", // Sweden
    "sg" => "whois.sgnic.sg", // Singapore
    "sh" => "whois.nic.sh", // Saint Helena
    "si" => "whois.arnes.si", // Slovenia
    "sk" => "whois.sk-nic.sk", // Slovakia
    // sl - Sierra Leone - no whois server assigned
    "sm" => "whois.nic.sm", // San Marino
    "sn" => "whois.nic.sn", // Senegal
    "so" => "whois.nic.so", // Somalia
    // sr - Suriname - no whois server assigned
    "st" => "whois.nic.st", // Sao Tome And Principe
    "su" => "whois.tcinet.ru", // Russian Federation
    // sv - El Salvador - no whois server assigned
    "sx" => "whois.sx", // Sint Maarten (dutch Part)
    "sy" => "whois.tld.sy", // Syrian Arab Republic
    // sz - Swaziland - no whois server assigned
    "tc" => "whois.meridiantld.net", // Turks And Caicos Islands
    // td - Chad - no whois server assigned
    "tel" => "whois.nic.tel",
    "tf" => "whois.nic.tf", // French Southern Territories
    // tg - Togo - no whois server assigned
    "th" => "whois.thnic.co.th", // Thailand
    "tj" => "whois.nic.tj", // Tajikistan
    "tk" => "whois.dot.tk", // Tokelau
    "tl" => "whois.nic.tl", // Timor-leste
    "tm" => "whois.nic.tm", // Turkmenistan
    "tn" => "whois.ati.tn", // Tunisia
    "to" => "whois.tonic.to", // Tonga
    "tp" => "whois.nic.tl", // Timor-leste
    "tr" => "whois.nic.tr", // Turkey
    "travel" => "whois.nic.travel",
    // tt - Trinidad And Tobago - no whois server assigned
    "tv" => "tvwhois.verisign-grs.com", // Tuvalu
    "tw" => "whois.twnic.net.tw", // Taiwan
    "tz" => "whois.tznic.or.tz", // Tanzania, United Republic Of
    "ua" => "whois.ua", // Ukraine
    "ug" => "whois.co.ug", // Uganda
    "uk" => "whois.nic.uk", // United Kingdom
    "us" => "whois.nic.us", // United States
    "uy" => "whois.nic.org.uy", // Uruguay
    "uz" => "whois.cctld.uz", // Uzbekistan
    // va - Holy See (vatican City State) - no whois server assigned
    "vc" => "whois2.afilias-grs.net", // Saint Vincent And The Grenadines
    "ve" => "whois.nic.ve", // Venezuela
    "vg" => "whois.adamsnames.tc", // Virgin Islands, British
    // vi - Virgin Islands, US - no whois server assigned
    // vn - Viet Nam - no whois server assigned
    // vu - Vanuatu - no whois server assigned
    "wf" => "whois.nic.wf", // Wallis and Futuna
    "ws" => "whois.website.ws", // Samoa
    "xxx" => "whois.nic.xxx",
    // ye - Yemen - no whois server assigned
    "yt" => "whois.nic.yt", // Mayotte
    "yu" => "whois.ripe.net");
function LookupDomain($domain){
    global $whoisservers;
    $domain_parts = explode(".", $domain);
    $tld = strtolower(array_pop($domain_parts));
    $whoisserver = $whoisservers[$tld];
    if(!$whoisserver) {
        return "<span style='color:red;'>Die Endung für $domain existiert nicht!</span>";
    }
    $result = QueryWhoisServer($whoisserver, $domain);
    if(!$result) {
        return "Error: No results retrieved from $whoisserver server for $domain domain!";
    }
    else {
        while(strpos($result, "Whois Server:") !== FALSE){
            preg_match("/Whois Server: (.*)/", $result, $matches);
            $secondary = $matches[1];
            if($secondary) {
                $result = QueryWhoisServer($secondary, $domain);
                $whoisserver = $secondary;
            }
        }
    }
    return $result;
}
function LookupIP($ip) {
    $whoisservers = array(
        //"whois.afrinic.net", // Africa - returns timeout error :-(
        "whois.lacnic.net", // Latin America and Caribbean - returns data for ALL locations worldwide :-)
        "whois.apnic.net", // Asia/Pacific only
        "whois.arin.net", // North America only
        "whois.ripe.net" // Europe, Middle East and Central Asia only
    );
    $results = array();
    foreach($whoisservers as $whoisserver) {
        $result = QueryWhoisServer($whoisserver, $ip);
        if($result && !in_array($result, $results)) {
            $results[$whoisserver]= $result;
        }
    }
    $res = "RESULTS FOUND: " . count($results);
    foreach($results as $whoisserver=>$result) {
        $res .= "\n\n-------------\nLookup results for " . $ip . " from " . $whoisserver . " server:\n\n" . $result;
    }
    return $res;
}
function ValidateIP($ip) {
    $ipnums = explode(".", $ip);
    if(count($ipnums) != 4) {
        return false;
    }
    foreach($ipnums as $ipnum) {
        if(!is_numeric($ipnum) || ($ipnum > 255)) {
            return false;
        }
    }
    return $ip;
}
function ValidateDomain($domain) {
    if(!preg_match("/^([-a-z0-9]{2,100})\.([a-z\.]{2,8})$/i", $domain)) {
        return false;
    }
    return $domain;
}
function QueryWhoisServer($whoisserver, $domain) {
    $port = 43;
    $timeout = 10;
    $fp = @fsockopen($whoisserver, $port, $errno, $errstr, $timeout) or die("Socket Error " . $errno . " - " . $errstr);
    //if($whoisserver == "whois.verisign-grs.com") $domain = "=".$domain; // whois.verisign-grs.com requires the equals sign ("=") or it returns any result containing the searched string.
    fputs($fp, $domain . "\r\n");
    $out = "";
    while(!feof($fp)){
        $out .= fgets($fp);
    }
    fclose($fp);
    $res = "";
    if((strpos(strtolower($out), "error") === FALSE) && (strpos(strtolower($out), "not allocated") === FALSE)) {
        $rows = explode("\n", $out);
        foreach($rows as $row) {
            $row = trim($row);
            if(($row != '') && ($row{0} != '#') && ($row{0} != '%')) {
                $res .= $row."\n";
            }
        }
    }
    return $res;
}
?>
<html>
<head>
<title>Whois Lookup Script</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form action="<?=$_SERVER['PHP_SELF'];?>">
<p><b><label for="domain">Domain/IP Address:</label></b> <input type="text" name="domain" id="domain" value="<?=$domain;?>"> <input type="submit" value="Lookup"></p>
</form>
<?php
if($domain) {
    $domain = trim($domain);
    if(substr(strtolower($domain), 0, 7) == "http://") $domain = substr($domain, 7);
    if(substr(strtolower($domain), 0, 4) == "www.") $domain = substr($domain, 4);
    if(ValidateIP($domain)) {
        echo "hello before check";
        $result = LookupIP($domain);
    }
    elseif(ValidateDomain($domain)) {
        $result = LookupDomain($domain);
    }
    else die("Geben Sie bitte die vollständige Domain ein! z.B. Creativpur.com");
    echo "<pre>\n" . $result . "\n</pre>\n";
}
?>
</body>
</html>
Wenn eine Domain noch frei ist, sollte nur folgendes Erscheinen:
Die Domain xxx.de ist noch frei.

Bildschirmfoto 2018-11-20 um 09.33.46.png

Sicherlich wird die gesamte Info über whois abgegeben ??
Kann man dies unterbinden ?
 

Bratkartoffel

gebratene Kartoffel
Premium-User
#7
Hi,

warum so umständlich über whois gehen, wenn ein einfacher Domain-Lookup eigentlich das ist, was du brauchst?

https://secure.php.net/manual/de/function.dns-get-record.php

Beispiel:
PHP:
<?php
var_export(dns_get_record("example.com",  DNS_SOA));
/*
array (
  0 =>
  array (
    'host' => 'example.com',
    'class' => 'IN',
    'ttl' => 3370,
    'type' => 'SOA',
    'mname' => 'sns.dns.icann.org',
    'rname' => 'noc.dns.icann.org',
    'serial' => 2018100719,
    'refresh' => 7200,
    'retry' => 3600,
    'expire' => 1209600,
    'minimum-ttl' => 3600,
  ),
)
*/

var_export(dns_get_record("foo.nonexistant.bar",  DNS_SOA));
/*
array (
)
*/
Das funktioniert dann auch für Domains, welche keinen bekannten Whois-Server definiert haben (also auch die "neuen" TLD wie .bayern, .hamburg, .ovh etc.)

Grüsse,
BK
 
Zuletzt bearbeitet:

Bratkartoffel

gebratene Kartoffel
Premium-User
#9
Hi,

du kannst das Ergebnis der "dns_get_record" abfragen. Wenn das resultierende Array nicht leer ist, dann gibt es die Domain bereits. Mein "var_export" war nur zum veranschaulichen.

Grüsse,
BK
 

Bratkartoffel

gebratene Kartoffel
Premium-User
#11
Hi,

PHP:
function domainExists($name) {
  $res = dns_get_record($name,  DNS_SOA);
  return $res !== FALSE && count($res) > 0;
}
Das Schnippsel bietet dir eine Funktion, mit der du dann einen If-Block schreiben kannst.

PHP:
if(domainExists("foo.bar")) {
  echo "Gibts schon";
} else {
  echo "Gibts noch nicht";
}
(Ungetestet)

Grüsse,
BK
 

basti1012

Erfahrenes Mitglied
#12
@Bratkartoffel wie funktioniert so ein Script eigentlich ?
Weil bei nomalen Adressen scheint es ja zu funktionieren.
Wenn ich aber zb bei bplaced.net mein webseite anfrage sagt er es gibt die nicht .
Muß man dafür wieder einen anderen Code benutzen oder so ?
 

CreativPur

Erfahrenes Mitglied
#13
Ich habe es jetzt folgend gelöst..

PHP:
<form action="" method="post">
<table width="200" border="0" align="center">
  <tr>
    <td colspan="3" align="center">Wählen Sie Ihre Wunsch-Domain<br /><span style="font-size:12px; color:red;">(ohne www.)</span><hr /></td>
    </tr>
  <tr>
    <td width="20"><input type="text" name="domain_name" /></td>
    <td width="5%">
    <select name="ubhbz">
<option value=".de">.de</option>
<option value=".com">.com</option>
<option value=".info">.info</option>
<option value=".net">.net</option>
<option value=".org">.org</option>
</select>
    </td>
    <td width="5%"><input type="submit" name="check" value="Check" /></td>
  </tr>
</form>

<div align="center">
<?php

echo '<tr align="center">
    <td colspan="3">';
    
    if(isset($_POST['check'])) {
 
 if (!empty($_POST['domain_name'])){
 $name_domain = trim($_POST['domain_name']).$_POST['ubhbz'];
 $response = @dns_get_record($name_domain, DNS_ALL);
 if(empty($response)){
 echo "<hr /><span style='font-size:13px;'><span style='color:blue;'>www.$name_domain</span> ist noch <span style='color:green;'>frei</span>.</span>";
 
 }else{
 echo "<hr /><span style='font-size:13px;'><span style='color:blue;'>www.$name_domain</span> ist schon <span style='color:red;'>vergeben</span>.</span>";
 }
 }
 else {
 echo "<p style='color:red;'>Geben Sie bitte einen Domain-Namen ein.</p>";
 }
}
echo '   
    </td>
    </tr>
</table>';

?>
</div>
 

Bratkartoffel

gebratene Kartoffel
Premium-User
#14
@Bratkartoffel wie funktioniert so ein Script eigentlich ?
Weil bei nomalen Adressen scheint es ja zu funktionieren.
Wenn ich aber zb bei bplaced.net mein webseite anfrage sagt er es gibt die nicht .
Muß man dafür wieder einen anderen Code benutzen oder so ?
Also bei mir sagt er, die gibts (folgender Code, getestet auf http://phptester.net/
PHP:
<?php
function domainExists($name) {
  $res = dns_get_record($name,  DNS_SOA);
  return $res !== FALSE && count($res) > 0;
}

if(domainExists("bplaced.net")) {
  echo "Gibts schon";
} else {
  echo "Gibts noch nicht";
}
Es könnte sein, dass dein Hoster DNS Anfragen blockiert, resp. die Funktion "dns_get_record" deaktiviert hat.

Grüsse,
BK
 
Status
Dieses Thema wurde gelöst! Zur Lösung gehen…
Anzeige

Neue Beiträge

Anzeige