? statistics.patch
Index: modules/statistics/statistics.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/statistics/statistics.admin.inc,v
retrieving revision 1.7
diff -u -p -r1.7 statistics.admin.inc
--- modules/statistics/statistics.admin.inc	14 Apr 2008 17:48:41 -0000	1.7
+++ modules/statistics/statistics.admin.inc	30 Apr 2008 14:27:06 -0000
@@ -82,14 +82,20 @@ function statistics_top_visitors() {
     array('data' => t('Operations'))
   );
 
-  $sql = "SELECT COUNT(a.uid) AS hits, a.uid, u.name, a.hostname, SUM(a.timer) AS total, ac.aid FROM {accesslog} a LEFT JOIN {access} ac ON ac.type = 'host' AND LOWER(a.hostname) LIKE (ac.mask) LEFT JOIN {users} u ON a.uid = u.uid GROUP BY a.hostname, a.uid, u.name, ac.aid" . tablesort_sql($header);
+  $sql = "SELECT COUNT(a.uid) AS hits, a.uid, u.name, a.hostname, SUM(a.timer) AS total, bl.iid FROM {accesslog} a LEFT JOIN {blocked_ips} bl ON a.hostname = bl.ip LEFT JOIN {users} u ON a.uid = u.uid GROUP BY a.hostname, a.uid, u.name, bl.iid" . tablesort_sql($header);
   $sql_cnt = "SELECT COUNT(DISTINCT(CONCAT(uid, hostname))) FROM {accesslog}";
   $result = pager_query($sql, 30, 0, $sql_cnt);
 
   $rows = array();
   while ($account = db_fetch_object($result)) {
     $qs = drupal_get_destination();
-    $ban_link = $account->aid ? l(t('unban'), "admin/user/rules/delete/$account->aid", array('query' => $qs)) : l(t('ban'), "admin/user/rules/add/$account->hostname/host", array('query' => $qs));
+    // Only show the link for blocking IP addresses if the user has the appropriate permission, and if the IP address is not associated with an authenticated user.
+    if (user_access('block IP addresses') && !$account->uid) {
+      $ban_link =  $account->iid ? l(t('Remove IP address block'), "admin/settings/ip-blocking/delete/$account->iid", array('query' => $qs)) : l(t('Block IP address'), "admin/settings/ip-blocking/$account->hostname", array('query' => $qs));
+    }
+    else {
+      $ban_link = '';
+    }    
     $rows[] = array($account->hits, ($account->uid ? theme('username', $account) : $account->hostname), format_interval(round($account->total / 1000)), $ban_link);
   }
 
Index: modules/system/system.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v
retrieving revision 1.73
diff -u -p -r1.73 system.admin.inc
--- modules/system/system.admin.inc	30 Apr 2008 06:48:27 -0000	1.73
+++ modules/system/system.admin.inc	30 Apr 2008 14:27:06 -0000
@@ -1113,6 +1113,7 @@ function system_ip_blocking_form($form_s
     '#type' => 'textfield',
     '#size' => 64,
     '#maxlength' => 32,
+    '#default_value' => arg(3),
     '#description' => t('Enter a valid IP address.'),
   );
   $form['submit'] = array(
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.599
diff -u -p -r1.599 system.module
--- modules/system/system.module	23 Apr 2008 20:01:54 -0000	1.599
+++ modules/system/system.module	30 Apr 2008 14:27:06 -0000
@@ -499,7 +499,7 @@ function system_menu() {
   );
 
   // IP address blocking.
-  $items['admin/settings/ip-blocking'] = array(
+  $items['admin/settings/ip-blocking/%'] = array(
     'title' => 'IP address blocking',
     'description' => 'Manage blocked IP addresses.',
     'page callback' => 'system_ip_blocking',
