public function postProcess(&$whoisParser) { $whoisResult = $whoisParser->getResult(); $configObj = $whoisParser->getConfig(); $config = $configObj->getCurrent(); $proxyConfig = $whoisParser->getProxyConfigFile(); $customNamespace = $whoisParser->getCustomAdapterNamespace(); $adapter = AbstractAdapter::factory('socket', $proxyConfig, $customNamespace); // Fetch nameservers foreach ($this->data['Name Server Handle'] as $nsHandle) { $config['format'] = $nsHandle; $result = $adapter->call($nsHandle, $config); $result = $this->translateRawData($result, $config); $whoisResult->addItem('rawdata', $result); if (!array_key_exists('Name Server Hostname', $this->data)) { $this->data['Name Server Hostname'] = array(); } $data = $this->parseRawData($result); $data = $this->reformatDataArray($data); $this->parseKeyValues($whoisResult, $data, $this->regexKeysNameservers, true); } // Fetch additional contacts $contactKeys = array('contacts:admin' => 'Legal-c Handle', 'contacts:tech' => 'Tech-c Handle'); foreach ($contactKeys as $contactKey => $handleKey) { if (!array_key_exists($handleKey, $this->data)) { continue; } $config['format'] = $this->data[$handleKey]; $result = $adapter->call($this->data[$handleKey], $config); $result = $this->translateRawData($result, $config); $whoisResult->addItem('rawdata', $result); $data = $this->parseRawData($result); $data = $this->reformatDataArray($data); $regexContacts = array(); foreach ($this->regexKeysContacts as $key => $regex) { $regexContacts[$contactKey . $key] = $regex; } $this->parseKeyValues($whoisResult, $data, $regexContacts, true); } if (array_key_exists('Registrar Handle', $this->data)) { $registrarHandle = $this->data['Registrar Handle']; $config['format'] = $registrarHandle; $result = $adapter->call($registrarHandle, $config); $result = $this->translateRawData($result, $config); $whoisResult->addItem('rawdata', $result); $data = $this->parseRawData($result); $data = $this->reformatDataArray($data); $this->parseKeyValues($whoisResult, $data, $this->regexKeysRegistrar, true); } }
public function postProcess(&$whoisParser) { $whoisResult = $whoisParser->getResult(); $configObj = $whoisParser->getConfig(); $config = $configObj->getCurrent(); $proxyConfig = $whoisParser->getProxyConfigFile(); $customNamespace = $whoisParser->getCustomAdapterNamespace(); $adapter = AbstractAdapter::factory('socket', $proxyConfig, $customNamespace); // Fetch additional contacts $contactKeys = array('contacts:owner' => 'Owner\'s handle', 'contacts:admin' => 'Administrative Contact\'s handle', 'contacts:tech' => 'Technical Contact\'s handle'); $seenContacts = array(); foreach ($contactKeys as $contactKey => $handleKey) { if (!array_key_exists($handleKey, $this->data)) { continue; } $handle = $this->data[$handleKey]; if (array_key_exists($handle, $seenContacts)) { $data = $seenContacts[$handle]; } else { $config['format'] = $handle; $result = $adapter->call($handle, $config); $result = $this->translateRawData($result, $config); $whoisResult->addItem('rawdata', $result); $data = $this->parseRawData($result); $seenContacts[$handle] = $data; } if (array_key_exists('Firstname', $data) && array_key_exists('Name', $data)) { $data['Name'] = trim($data['Firstname'] . ' ' . $data['Name']); } $regexContacts = array(); foreach ($this->regexKeysContacts as $key => $regex) { $regexContacts[$contactKey . $key] = $regex; } $this->parseKeyValues($whoisResult, $data, $regexContacts, true); $type = array_key_exists('Person', $data) && $data['Person'] == 'True' ? 'Person' : 'Organization'; $this->result->addItem($contactKey . ':type', $type); if ($type == 'Organization') { $this->result->addItem($contactKey . ':organization', $data['Name']); $this->result->addItem($contactKey . ':name', null); } } }
/** * Send data to whois server and call parse() to process rawdata * * @throws NoAdapterException * @throws RateLimitException * @param string $query * @return void */ public function call($query = '') { $this->rawdata = null; if ($query != '') { $this->Query = filter_var($query, FILTER_SANITIZE_STRING); } $Config = $this->Config->getCurrent(); $Adapter = AbstractAdapter::factory($Config['adapter'], $this->proxyConfigFile, $this->customAdapterNamespace); $server = $Config['server']; if (in_array($server, $this->rateLimitedServers)) { throw new RateLimitException("Rate limit exceeded for server: " . $server); } if ($Adapter instanceof AbstractAdapter) { $this->rawdata = $Adapter->call($this->Query, $Config); $this->parse(); } else { throw new NoAdapterException('Adapter ' . $Config['adapter'] . ' could not be found'); } }
public function __construct($proxyConfig) { parent::__construct($proxyConfig); }