/** * Run the database seeds. * * @return void */ public function run() { Tld::create(['tld' => 'no', 'server' => 'whois.norid.no', 'answer' => 'no match']); Tld::create(['tld' => 'com', 'server' => 'whois.internic.net', 'answer' => 'No match']); Tld::create(['tld' => 'net', 'server' => 'whois.internic.net', 'answer' => 'No match']); Tld::create(['tld' => 'org', 'server' => 'whois.publicinterestregistry.net', 'answer' => 'Not found']); Tld::create(['tld' => 'as', 'server' => 'whois.nic.as', 'answer' => 'Not Registered']); }
/** * @param string $domain full domain name (without trailing dot) */ public function __construct($domain) { $this->domain = $domain; // check $domain syntax and split full domain name on subdomain and TLDs if (preg_match('/^([\\p{L}\\d\\-]+)\\.((?:[\\p{L}\\-]+\\.?)+)$/ui', $this->domain, $matches) || preg_match('/^(xn\\-\\-[\\p{L}\\d\\-]+)\\.(xn\\-\\-(?:[a-z\\d-]+\\.?1?)+)$/ui', $this->domain, $matches)) { $this->sld = $matches[1]; $this->tld = $matches[2]; } else { throw new \InvalidArgumentException("Invalid {$domain} syntax"); } //Get server and answer for TLD table $getTld = Tld::where('tld', $this->tld)->get(array('server', 'answer')); //Extract the data into the private variables foreach ($getTld as $gt) { $this->server = $gt->server; $this->answer = $gt->answer; } }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $tlds = Tld::all(); return Response::json($tlds); }