You are here

protected function Ip2CountryManager::fetchPage in IP-based Determination of a Visitor's Country 8

Utility function which fetches pages via FTP using cURL.

Parameters

string $url: The ftp URL where the file is located.

Return value

string|false FALSE if ftp fetch failed. Otherwise, a string containing the contents of the fetched file.

1 call to Ip2CountryManager::fetchPage()
Ip2CountryManager::updateDatabase in src/Ip2CountryManager.php
Updates the database.

File

src/Ip2CountryManager.php, line 315

Class

Ip2CountryManager
The ip2country.manager service.

Namespace

Drupal\ip2country

Code

protected function fetchPage($url) {
  $curl = curl_init();

  // Fetch requested file.
  curl_setopt($curl, CURLOPT_URL, $url);
  curl_setopt($curl, CURLOPT_TIMEOUT, 60 * 2);
  curl_setopt($curl, CURLOPT_USERAGENT, 'Drupal (+http://drupal.org/)');
  curl_setopt($curl, CURLOPT_HEADER, FALSE);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
  $html = curl_exec($curl);
  curl_close($curl);
  return $html;
}