You are here

function smart_ip_check_allowed_page in Smart IP 6.2

Same name and namespace in other branches
  1. 7.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 1210
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));
    foreach ($pages as $page) {

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