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.

Parameters

  • array $config Override the default URI to check.

Returns

boolean True if a network connection is established, false otherwise.

Source

						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;
		});

		$dnsCheck = dns_check_record($config['host'], "ANY");
		$fileCheck = fopen($url, "r");

		restore_error_handler();
		return !$failed;
	}