diff -urp statistics/statistics.admin.inc 6.x/statistics/statistics.admin.inc
--- statistics/statistics.admin.inc	2008-01-08 10:35:42.000000000 +0100
+++ 6.x/statistics/statistics.admin.inc	2008-05-07 17:23:15.000000000 +0200
@@ -211,5 +211,88 @@ function statistics_access_logging_setti
     '#options' => $options,
     '#description' => t('Increment a counter each time content is viewed.'));
 
+  /* Extended settings added by SiliconMind */
+  $form['extended'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Extended statistics settings'),
+    '#description' => t('These extended statistics settings are extremely useful for small sites or sites that are just getting started. They allow you to exclude from statistics all the traffic generated by site administrators or by search engines.')
+  );
+  $form['extended']['statistics_exclude_root'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Exclude system administrator (UID1)'),
+    '#default_value' => variable_get('statistics_exclude_root',true),
+    '#description' => t('When this field is checked all page views generated by system administrator (user with UID1) will be excluded from statistics.')
+  );
+  $form['extended']['statistics_exclude_admins'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Exclude site administrators'),
+    '#default_value' => variable_get('statistics_exclude_admins',true),
+    '#description' => t('When this field is checked all page views generated by site administrators (users with permission %perm) will be excluded from statistics.',array('%perm' => t('administer site configuration')))
+  );
+  $form['extended']['statistics_exclude_self'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Exclude self'),
+    '#default_value' => variable_get('statistics_exclude_self',false),
+    '#description' => t('Some hosting companies run complete scan of your pages on regular basis. You can easily recognize this traffic because it originates from the same IP address as your website. By checking this field you exclude all this traffic from statistics.')
+  );
+  $form['extended']['statistics_exclude_users'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Exclude users'),
+    '#default_value' => variable_get('statistics_exclude_users',''),
+    '#description' => t('You may provide a list of users that will be excluded from statistics. Provide one username per line.')
+  );
+  $form['extended']['statistics_exclude_ips'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Exclude IPs'),
+    '#default_value' => variable_get('statistics_exclude_ips',''),
+    '#description' => t('You may provide a list of IP addresses that will be excluded from statistics. Provide one IP address per line.')
+  );
+  $form['extended']['statistics_exclude_agents'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Exclude user agents'),
+    '#default_value' => variable_get('statistics_exclude_agents',implode("\n", statistics_default_user_agents_exclude_array())),
+    '#description' => t('You may provide a list of user agents that will be excluded from statistics. Provide one user agent per line. Note that you do not have to provide full user agent names. I.e. if you write "Google" then all user agents like Google-Sitemaps, Googlebot or AdsBot-Google will be excluded. But be careful! Browsers with Google Toolbar installed will be excluded too, because these browsers have additional user agent string containing "Google" phrase.')
+  );
+  /* extended settings ends here */
+  
   return system_settings_form($form);
 }
+
+/**
+ * Helper function for extended settings.
+ * returns default array of user agents that can safely be excluded from statistics.
+ * These are mainly bots but this list could be extended with payment gateways and simmilar
+ */
+function statistics_default_user_agents_exclude_array(){
+  return array(
+    'msnbot',
+    'Google-Sitemaps',
+    'Homenet-Search',
+    'ia_archiver',
+    'Googlebot',
+    'Yahoo! Slurp',
+    'Indy Library',
+    'findlinks',
+    'AdsBot-Google',
+    'gemiusbot',
+    'Szukacz',
+    'http://www.ilial.com/crawler',
+    'Speedy Spider',
+    'IRLbot',
+    'Nutch',
+    'Lorkyll',
+    'http://www.cuill.com/twiceler/robot.html',
+    'WebRankSpider',
+    'UtilMind HTTPGet',
+    'CazoodleBot',
+    '+http://szukaj.onet.pl;',
+    'ediapartners-Google',
+    'MJ12bot',
+    'Feedfetcher-Google',
+    'ichiro',
+    'NetSprint',
+    'MSRBOT',
+    'VadixBot',
+    'PayGW-OnLine'
+  );
+}
diff -urp statistics/statistics.install 6.x/statistics/statistics.install
--- statistics/statistics.install	2007-12-18 12:59:22.000000000 +0100
+++ 6.x/statistics/statistics.install	2008-05-07 17:23:14.000000000 +0200
@@ -42,6 +42,13 @@ function statistics_uninstall() {
   variable_del('statistics_block_top_day_num');
   variable_del('statistics_block_top_all_num');
   variable_del('statistics_block_top_last_num');
+  
+  variable_del('statistics_exclude_root');
+  variable_del('statistics_exclude_admins');
+  variable_del('statistics_exclude_self');
+  variable_del('statistics_exclude_users');
+  variable_del('statistics_exclude_ips');
+  variable_del('statistics_exclude_agents');
 }
 
 /**
diff -urp statistics/statistics.module 6.x/statistics/statistics.module
--- statistics/statistics.module	2008-01-04 09:31:48.000000000 +0100
+++ 6.x/statistics/statistics.module	2008-05-07 17:23:14.000000000 +0200
@@ -4,6 +4,7 @@
 /**
  * @file
  * Logs access statistics for your site.
+ * Extended by SiliconMind - siliconmind.eu
  */
 
 /**
@@ -44,6 +45,25 @@ function statistics_help($path, $arg) {
  */
 function statistics_exit() {
   global $user, $recent_activity;
+  
+  /* Extended filtering added by SiliconMind */
+  if (variable_get('statistics_exclude_root',true) && intval($user->uid) === 1)
+    return;
+  if (variable_get('statistics_exclude_admins',true) && user_access('administer site configuration'))
+    return;
+  if (variable_get('statistics_exclude_self',false) && $_SERVER['SERVER_ADDR'] == ip_address())
+    return;
+  if ($user->uid && in_array($user->name,explode("\n", str_replace("\r","",variable_get('statistics_exclude_users','')))) === true)
+    return;
+  if (in_array(ip_address(),explode("\n", str_replace("\r","",variable_get('statistics_exclude_ips','')))) === true)
+    return;
+  $agents = explode("\n", str_replace("\r","",
+    variable_get('statistics_exclude_agents',implode("\n", statistics_default_user_agents_exclude_array()))));
+  foreach($agents as $ag){
+    if (stripos($_SERVER['HTTP_USER_AGENT'], $ag) !== false)
+      return;
+  }
+  /* extended filtering ends here */
 
   drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH);
 
