You are here

function _ip2country_fetch_page in IP-based Determination of a Visitor's Country 7

Same name and namespace in other branches
  1. 5 uc_ip2country.inc \_ip2country_fetch_page()
  2. 6 ip2country.inc \_ip2country_fetch_page()

Fetches the pages via FTP with 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 _ip2country_fetch_page()
ip2country_update_database in ./ip2country.inc
Updates the database.

File

./ip2country.inc, line 256
Utility routines to load the IP to Country database.

Code

function _ip2country_fetch_page($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;
}