You are here

function smart_ip_maxmind_bin_db_up_to_date in Smart IP 6.2

Same name and namespace in other branches
  1. 7.2 includes/smart_ip.utility.inc \smart_ip_maxmind_bin_db_up_to_date()

MaxMind updates the binary database every Tuesday, and we download every Wednesday for licensed version. Every first Tuesday of the month for lite or free version, and we download every first Wednesday of the month. That means that we only want to download if the current database was downloaded prior to the most recently available version.

1 call to smart_ip_maxmind_bin_db_up_to_date()
smart_ip_maxmind_bin_db_update in includes/smart_ip.utility.inc
Download a Maxmind binary database and activate it for use

File

includes/smart_ip.utility.inc, line 572
Utility routines to load the Smart IP database.

Code

function smart_ip_maxmind_bin_db_up_to_date($version, $last_update_time) {
  $version = variable_get('smart_ip_maxmind_bin_version', SMART_IP_MAXMIND_BIN_LICENSED_VERSION);
  $time_now = strtotime('midnight', (int) $_SERVER['REQUEST_TIME']);
  $last_update_time = strtotime('midnight', variable_get('smart_ip_maxmind_bin_db_last_update', 0));
  if ($version == SMART_IP_MAXMIND_BIN_LICENSED_VERSION) {
    $wednesday = strtotime('Wednesday this week', $time_now);
    if ($wednesday <= $time_now && $wednesday > $last_update_time) {
      return FALSE;
    }
  }
  elseif ($version == SMART_IP_MAXMIND_BIN_LITE_VERSION) {
    $first_wed = strtotime('first Wednesday of this month', $time_now);
    if ($first_wed <= $time_now && $first_wed > $last_update_time) {
      return FALSE;
    }
  }
  return TRUE;
}