/** * Skip the test if curl is not available in your PHP installation. * * @return void */ public function skip() { $message = 'Your PHP installation was not compiled with curl support.'; $this->skipIf(!function_exists('curl_init'), $message); $config = $this->_testConfig; $url = "{$config['scheme']}://{$config['host']}"; $message = "Could not open {$url} - skipping " . __CLASS__; $this->skipIf(!curl_init($url), $message); $this->skipIf(dns_check_record("google.com") === false, "No internet connection."); }
public function testGeocodeLookupAndReverse() { $this->skipIf(dns_check_record("google.com") === false, "No internet connection."); $address = '1600 Pennsylvania Avenue Northwest, Washington, DC'; foreach (array('osm') as $service) { $location = Geocoder::find($service, compact('address')); $expected = array('latitude' => 38, 'longitude' => -77); $this->assertEqual($expected, array_map('intval', $location->coordinates())); $address = Geocoder::find($service, $location->coordinates()); $this->assertTrue(is_object($address)); } }
/** * Checks for a working internet connection. * * This method is used to check for a working connection to google.com, both * testing for proper DNS resolution and reading the actual URL. * * @param array $config Override the default URL to check. * @return boolean True if a network connection is established, false otherwise. */ protected function _hasNetwork($config = array()) { $defaults = array('scheme' => 'http', 'host' => 'google.com'); $config += $defaults; $url = "{$config['scheme']}://{$config['host']}"; $failed = false; set_error_handler(function ($errno, $errstr) use(&$failed) { $failed = true; }); dns_check_record($config['host'], 'A'); if ($handle = fopen($url, 'r')) { fclose($handle); } restore_error_handler(); return !$failed; }
public static function check(FormChecker_Field &$oField, $params) { $value = $oField->getValue(); if (is_null($value) && !$oField->isRequired()) { return true; } if (!mb_eregi('^[a-z0-9\\._-]+@[a-z0-9\\._-]+$', $value)) { // if ( !mb_eregi( '^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $value ) ) return $oField->raiseError('Votre email n\'est pas correct'); } else { $tmp = explode('@', $value); if (!is_array($tmp)) { return false; } elseif (!dns_check_record($tmp[1], 'MX')) { return $oField->raiseError('Votre nom de domaine n\'est pas valide, veuillez vérifier votre saisie'); } } return true; }
/** * Attempt to query a host name's DNS record. * * @param type $hostname * @return boolean */ function checkDNS($hostname) { if (function_exists('dns_check_record')) { return (int) @dns_check_record($hostname); } else { return 0; } }
public function skip() { $host = $this->_testConfig['host']; $this->skipIf(dns_check_record($host) === false, "No internet connection."); }
public function testInstallDocs() { $this->skipIf(strpos(shell_exec('git --version'), 'git version') === false, 'The git is not installed.'); $this->skipIf(dns_check_record("lithify.me") === false, "No internet connection."); $this->library->path = $this->_testPath; $result = $this->library->install('li3_docs'); $this->assertTrue($result); $result = is_dir($this->_testPath . '/li3_docs'); $this->assertTrue($result); $this->_cleanUp(); }
* DNS Record Types and Their Meanings * A Address code, used for storing an IP address associated with the domain * MX Mail exchange, the domain name used for sending and receiving mail * NS The authoritative name server * SOA Start of Authority * PTR Domain name pointer * CNAME Canonical name for a DNS alias * AAAA Address code used for IPv6 Addresses * ANY Any of the above * TXT */ /** * Using the dns_check_record() Function */ $hostname = "google.com"; if (dns_check_record($hostname, "NS")) { echo "An authoritative name server exists.\n"; } else { echo "No name server was found for this domain\n"; } /** * Fetches DNS records associated with a hostname */ $record = dns_get_record("php.net"); print_r($record); //$hostname = "google.com"; // //$records = dns_get_record($hostname, DNS_ALL); // //echo "The domain $hostname has the following DNS records: "; //
/** * Checks for a working internet connection. * * This method is used to check for a working connection to lithify.me, both * testing for proper dns resolution and reading the actual URL. * * @param array $config Override the default URI to check. * @return boolean True if a network connection is established, false otherwise. */ protected function _hasNetwork($config = array()) { $defaults = array( 'scheme' => 'http', 'host' => 'lithify.me' ); $config += $defaults; $url = "{$config['scheme']}://{$config['host']}"; $failed = false; set_error_handler(function($errno, $errstr) use (&$failed) { $failed = true; }); $dnsCheck = dns_check_record($config['host'], "ANY"); $fileCheck = fopen($url, "r"); restore_error_handler(); return !$failed; }
public function skip() { $this->skipIf(dns_check_record("google.com") === false, "No internet connection."); }
/** * Tests email address validation, with additional hostname lookup * * @return void */ public function testEmailDomainCheck() { $this->skipIf(dns_check_record("google.com") === false, "No internet connection."); $this->assertTrue(Validator::isEmail('*****@*****.**', null, array('deep' => true))); $this->assertFalse(Validator::isEmail('*****@*****.**', null, array('deep' => true))); $this->assertFalse(Validator::isEmail('*****@*****.**', null, array('deep' => true))); }
public function skip() { $this->skipIf(dns_check_record("lithify.me") === false, "No internet connection."); }
/** This uses tricks like DNS lookup of IP Address - so can handle more * complex domains, but also more error prone. Don't use unless necessary. * @return string - domain name */ function getDomainHard($url = null) { if (!$url) { #Use our URL $url = getBaseUrl(); } $dots = substr_count($url, '.'); $domain = ''; for ($end_pieces = $dots; $end_pieces > 0; $end_pieces--) { $test_domain = end(explode('.', $url, $end_pieces)); if (dns_check_record($test_domain, 'A')) { $domain = $test_domain; break; } } return $domain; }
<?php var_dump(dns_check_record(''));