You are here

function smart_ip_check_allowed_page in Smart IP 7.2

Same name and namespace in other branches
  1. 6.2 smart_ip.module \smart_ip_check_allowed_page()

Check page URL in allowed geolocate list.

Return value

string

4 calls to smart_ip_check_allowed_page()
device_geolocation_check_geolocation_attempt_ajax in modules/device_geolocation/device_geolocation.module
Check for Geolocation attempt ajax callback.
device_geolocation_get_coordinates in modules/device_geolocation/device_geolocation.module
Get Visitor's coordinates.
device_geolocation_init in modules/device_geolocation/device_geolocation.module
Implements hook_init().
smart_ip_init in ./smart_ip.module
Implements hook_init()

File

./smart_ip.module, line 1318
Determines country, geo location (longitude/latitude), region, city and postal code of the user, based on IP address

Code

function smart_ip_check_allowed_page() {
  $pages = variable_get('smart_ip_allowed_pages', '');
  if (empty($pages)) {

    // No pages specified then all pages are allowed
    return TRUE;
  }
  else {
    if (isset($_GET['uri'])) {

      // Handle "uri" from ajax request
      if (empty($_GET['uri'])) {
        $url = variable_get('site_frontpage', 'node');
      }
      else {
        $url = $_GET['uri'];
      }
    }
    else {
      $url = $_GET['q'];
    }

    // Convert the Drupal path to lowercase
    $path = drupal_strtolower(drupal_get_path_alias($url));

    // Compare the lowercase internal and lowercase path alias (if any).
    $page_match = drupal_match_path($path, $pages);
    if ($path != $url) {
      $page_match = $page_match || drupal_match_path($url, $pages);
    }
    elseif ($path == $url) {
      $url = drupal_get_normal_path($url);
      $page_match = $page_match || drupal_match_path($url, $pages);
    }
    return $page_match;
  }
}