function entity_iframe_statistics_exit

cis7 entity_iframe_statistics.module entity_iframe_statistics_exit()
cle7 entity_iframe_statistics.module entity_iframe_statistics_exit()
elmsmedia7 entity_iframe_statistics.module entity_iframe_statistics_exit()
icor7 entity_iframe_statistics.module entity_iframe_statistics_exit()
meedjum_blog7 entity_iframe_statistics.module entity_iframe_statistics_exit()
mooc7 entity_iframe_statistics.module entity_iframe_statistics_exit()

Implements hook_exit().

Gathers statistics for iframe page accesses.

File

sites/all/modules/elmsln_contrib/entity_iframe/modules/entity_iframe_statistics/entity_iframe_statistics.module, line 8

Code

function entity_iframe_statistics_exit() {
  global $user;

  // When serving cached pages with the 'page_cache_without_database'
  // configuration, system variables need to be loaded. This is a major
  // performance decrease for non-database page caches, but with Statistics
  // module, it is likely to also have 'statistics_enable_access_log' enabled,
  // in which case we need to bootstrap to the session phase anyway.
  drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES);

  if (variable_get('statistics_count_content_views', 0)) {
    // We are counting content views.
    if (arg(0) == 'entity_iframe' && arg(1) == 'node' && is_numeric(arg(2)) && arg(3) == NULL) {
      // A node has been viewed, so update the node's counters.
      db_merge('node_counter')->key(array('nid' => arg(2)))->fields(array(
        'daycount' => 1,
        'totalcount' => 1,
        'timestamp' => REQUEST_TIME,
      ))->expression('daycount', 'daycount + 1')->expression('totalcount', 'totalcount + 1')->execute();
    }
  }
  if (variable_get('statistics_enable_access_log', 0)) {
    drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);

    // For anonymous users unicode.inc will not have been loaded.
    include_once DRUPAL_ROOT . '/includes/unicode.inc';
    // Log this page access.
    db_insert('accesslog')->fields(array(
      'title' => truncate_utf8(strip_tags(drupal_get_title()), 255),
      'path' => truncate_utf8($_GET['q'], 255),
      'url' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '',
      'hostname' => ip_address(),
      'uid' => $user->uid,
      'sid' => session_id(),
      'timer' => (int) timer_read('page'),
      'timestamp' => REQUEST_TIME,
    ))->execute();
  }
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.