/** * Get the whois information for a host. * @return Array|NULL Return a key=>value array with all host information * @link whois.internic.net */ public function getWhois() { $info = parse_url($this->url); //make sure there is no subdomains $parts = explode('.', $info['host']); $ltd = array_pop($parts); $name = array_pop($parts); return Whois::lookup($name . '.' . $ltd); }
public static function Run() { if (file_exists("cache.json")) { $cache = json_decode(file_get_contents("cache.json"), true); } else { $cache = array(); } $tlds = explode(",", isset($_GET['tlds']) ? $_GET['tlds'] : "com,co.uk,net,org"); $domains = explode(",", isset($_GET['domains']) ? $_GET['domains'] : ""); $whois = new Whois(); $rows = array(); foreach ($domains as $domain) { if (strlen($domain) == 0) { continue; } $results = array(); $domain = trim($domain); $alltaken = true; foreach ($tlds as $tld) { if (array_key_exists($domain . "." . $tld, $cache) && $cache[$domain . "." . $tld]['time'] > time() - 60 * 60 * 24) { $info = $cache[$domain . "." . $tld]['data']; } else { $info = $whois->lookup($domain . "." . $tld); $cache[$domain . "." . $tld] = array('time' => time(), 'data' => $info); } $expires = ""; switch ($info['regrinfo']['registered']) { case "yes": if (isset($info['regrinfo']['domain']['expires'])) { $expires = date("jS F Y", strtotime($info['regrinfo']['domain']['expires'])); } else { $expires = "Unknown"; } break; case "unknown": $expires = "???"; break; case "no": $alltaken = false; break; } $results[] = array('tld' => $tld, 'registered' => $info['regrinfo']['registered'], 'expires' => $expires); } $params = array('domain' => $domain, 'results' => $results, 'classes' => $alltaken ? "danger" : ""); $rows[] = getTemplate()->get('domain-row.php', $params); } $params = array('rows' => $rows, 'cols' => $tlds); getTemplate()->display('page.php', $params); file_put_contents("cache.json", json_encode($cache)); }
$results = []; } else { $results = unserialize(fgets($fp)); fclose($fp); } // Specific test ? if (!empty($argv[1]) && isset($domains[$argv[1]])) { $domains = [$domains[$argv[1]]]; } // Test domains include 'whois.main.php'; $whois = new Whois(); set_file_buffer(STDIN, 0); foreach ($domains as $domain) { echo "\nTesting {$domain} ---------------------------------\n"; $result = $whois->lookup($domain); unset($result['rawdata']); if (!isset($results[$domain])) { print_r($result); $res = get_answer("Add result for {$domain}"); if ($res) { // Add as it is unset($result['regrinfo']['disclaimer']); $results[$domain] = $result; save_results(); } } else { // Compare with previous result unset($result['regrinfo']['disclaimer']); unset($results[$domain]['regrinfo']['disclaimer']); if (empty($result)) {
<?php // ini_set('display_errors', 1); // Load composer framework if (file_exists(__DIR__ . '/vendor/autoload.php')) { require __DIR__ . '/vendor/autoload.php'; } // use phpWhois\Whois; // ini_set('display_errors', 1); $whois = new Whois(); $query = $_POST['query']; $result = $whois->lookup($query, false); echo json_encode($result);
} else { $output = ''; } include_once 'whois.main.php'; include_once 'whois.utils.php'; $whois = new Whois(); // Set to true if you want to allow proxy requests $allowproxy = false; // get faster but less acurate results $whois->deep_whois = empty($_GET['fast']); // To use special whois servers (see README) //$whois->useServer('uk','whois.nic.uk:1043?{hname} {ip} {query}'); //$whois->useServer('au','whois-check.ausregistry.net.au'); // Comment the following line to disable support for non ICANN tld's $whois->non_icann = true; $result = $whois->lookup($query); $resout = str_replace('{query}', $query, $resout); $winfo = ''; switch ($output) { case 'object': if ($whois->Query['status'] < 0) { $winfo = implode($whois->Query['errstr'], "\n<br></br>"); } else { $utils = new utils(); $winfo = $utils->showObject($result); } break; case 'nice': if (!empty($result['rawdata'])) { $utils = new utils(); $winfo = $utils->showHTML($result);