/** * Lookup query * * @param string $query IP or hostname to lookup * @param bool $is_utf Require UTF-8 * * @return WhoisResult */ public static function Lookup($query = '', $is_utf = true) { // See if this query has been cached by Core <3 $cachekey = \Core\str_to_url('whois-' . $query); $cached = \Core\Cache::Get($cachekey); if ($cached) { $result = $cached; } else { $whois = new phpwhois\Whois(); $result = $whois->lookup($query, $is_utf); // Cache the results for 6 hours \Core\Cache::Set($cachekey, $result, 3600 * 6); } if (!is_array($result)) { return new WhoisNotFoundResult($query); } if (!sizeof($result)) { return new WhoisNotFoundResult($query); } return new WhoisResult($result, $query); }
protected function _check($domain, $expected) { $whois = new phpwhois\Whois(); $result = $whois->lookup($domain); $this->assertEquals($domain, $result['regrinfo']['domain']['name'], $domain . ' domain-name check did not match'); if ($expected['expires']) { $this->assertEquals($expected['expires'], $result['regrinfo']['domain']['expires'], $domain . ' domain-expires check did not match'); } $this->assertGreaterThan(0, sizeof($result['regrinfo']['domain']['nserver']), $domain . ' domain-nserver check did not return any nameservers'); $this->assertEquals($expected['organization'], $result['regrinfo']['owner']['organization'], $domain . ' owner-organization check did not match'); $street = $result['regrinfo']['admin']['address']['street']; if (is_array($street)) { $this->assertEquals($expected['street'], $street[0], $domain . ' admin-address-street check did not match'); } else { $this->assertEquals($expected['street'], $street, $domain . ' admin-address-street check did not match'); } $this->assertEquals($expected['city'], $result['regrinfo']['admin']['address']['city'], $domain . ' admin-address-city check did not match'); $this->assertEquals($expected['state'], $result['regrinfo']['admin']['address']['state'], $domain . ' admin-address-state check did not match'); $this->assertEquals($expected['pcode'], $result['regrinfo']['admin']['address']['pcode'], $domain . ' admin-address-pcode check did not match'); $this->assertEquals($expected['country'], $result['regrinfo']['admin']['address']['country'], $domain . ' admin-address-country check did not match'); $this->assertEquals($expected['name'], $result['regrinfo']['tech']['name'], $domain . ' tech-name check did not match'); $this->assertEquals($expected['email'], $result['regrinfo']['tech']['email'], $domain . ' domain-email check did not match'); $this->assertEquals('yes', $result['regrinfo']['registered'], $domain . ' domain-name check did not match'); $this->assertNotEmpty($result['regyinfo']['registrar'], $domain . ' domain-name check did not match'); }