uid == 1)) { $do_filtering = TRUE; } else { $filtered_roles = variable_get('statistics_filter_roles', FALSE); if (!$filtered_roles) $filtered_roles = array(); $filtered_roles = array_flip($filtered_roles); foreach ($user->roles as $key => $value) { if (array_key_exists($key, $filtered_roles)) { $do_filtering = TRUE; break; } } } if (!$do_filtering) { $filter_crawlers = variable_get('statistics_filter_crawlers', FALSE); if ($filter_crawlers) { $browser = get_browser(); if ($browser->crawler) { $do_filtering = TRUE; } } } // We don't want these stats to count, precisely undo what // statistics.module did if ($do_filtering) { if (variable_get('statistics_count_content_views', 0)) { // We are counting content views. if ((arg(0) == 'node') && arg(1)) { // A node has been viewed (and logged by the statistics module), // so decrement what statistics.module incremented db_query('UPDATE {node_counter} SET daycount = daycount - 1, totalcount = totalcount - 1 WHERE nid = %d', arg(1)); } } if ((variable_get('statistics_enable_access_log', 0)) && (module_invoke('throttle', 'status') < 5)) { // Statistical logs are enabled. $referrer = referer_uri(); $hostname = $_SERVER['REMOTE_ADDR']; $path = (drupal_get_path_alias($_GET['q'])) ? drupal_get_path_alias($_GET['q']) : $_GET['q']; // Unlog this page access. db_query("DELETE FROM {accesslog} WHERE title='%s' AND path='%s' " . "AND url='%s' AND hostname='%s' AND uid=%d", drupal_get_title(), $path, $referrer, $hostname, $user->uid); } } } /** * Implementation of hook_perm(). * * The following permissions are defined: * - "administer statistics module": full administrative control of module * - "administer statistics": view statistics / referrer log * - "access statistics": see how many times individual nodes have been * viewed (if enabled) */ function statistics_filter_perm() { return array('administer statistics filter'); } /** * Implementation of hook_settings(). */ function statistics_filter_settings() { $output = ''; // Restrict administration of this module if (!user_access('administer statistics filter')) { return message_access(); } if (!module_exist('statistics')) { $output .= t('
The statistics_filter module is an extension of the statistics '. 'module - you must enable statistics to use it.
'); return $output; } $output .= form_checkbox(t('Ignore administrator'), 'statistics_filter_noadmin', TRUE, variable_get('statistics_filter_noadmin', FALSE), t("Ignore the special administrator account's accesses to this site.")); $roles = user_roles(); //variable_get('statistics_filter_roles', FALSE), $output .= form_checkboxes(t('Roles to ignore'), 'statistics_filter_roles', variable_get('statistics_filter_roles', FALSE), $roles, t("Ignore accesses by users in any of the checked roles.")); $output .= form_checkbox(t('Ignore crawlers'), 'statistics_filter_crawlers', TRUE, variable_get('statistics_filter_crawlers', FALSE), t("Ignore search engine crawlers' accesses to this site.")); return $output; } ?>