function smart_ip_get_csv_source_filename in Smart IP 7.2
Same name and namespace in other branches
- 6.2 smart_ip.module \smart_ip_get_csv_source_filename()
- 6 smart_ip.module \smart_ip_get_csv_source_filename()
- 7 smart_ip.module \smart_ip_get_csv_source_filename()
Helper function for grabbing Maxmind's CSV archive filename.
3 calls to smart_ip_get_csv_source_filename()
- smart_ip_admin_settings in includes/
smart_ip.admin.inc - Smart IP administration settings.
- smart_ip_run_batch in ./
smart_ip.module - Menu page callback for Smart IP batch operations.
- smart_ip_update_db_batch in includes/
smart_ip.utility.inc - Prepare a batch definition
File
- ./
smart_ip.module, line 1425 - Determines country, geo location (longitude/latitude), region, city and postal code of the user, based on IP address
Code
function smart_ip_get_csv_source_filename() {
$maxmind_csv =& drupal_static(__FUNCTION__);
if (!isset($maxmind_csv)) {
// Get CSV list of zip files
$html = smart_ip_file_get_contents(SMART_IP_MAXMIND_LITE_CSV_DOWNLOAD_BASE_URL);
$regex = '/GeoLiteCity_' . format_date(REQUEST_TIME, 'custom', 'Ym') . '.{2}\\.zip/';
preg_match($regex, $html, $match);
// Check if Maxmind CSV file not updated, then fallback to the previous month
if (empty($match)) {
$regex = '/GeoLiteCity_' . format_date(REQUEST_TIME - 2764800, 'custom', 'Ym') . '.{2}\\.zip/';
preg_match($regex, $html, $match);
if (isset($match[0])) {
$maxmind_csv = check_url(SMART_IP_MAXMIND_LITE_CSV_DOWNLOAD_BASE_URL . '/' . $match[0]);
return $maxmind_csv;
}
}
$maxmind_csv = check_url(SMART_IP_MAXMIND_LITE_CSV_DOWNLOAD_BASE_URL . '/GeoLiteCity-latest.zip');
}
return $maxmind_csv;
}