Added hit_count to add <type> list and modify <type> list
authorAndrew DeFaria <Andrew.DeFaria@Broadcom.com>
Tue, 18 Oct 2016 23:12:08 +0000 (16:12 -0700)
committerAndrew DeFaria <Andrew.DeFaria@Broadcom.com>
Tue, 18 Oct 2016 23:12:08 +0000 (16:12 -0700)
Not complete but works sorta.

maps/bin/MAPS.pm
maps/bin/MAPSDB.pm
maps/bin/add2nulllist.cgi
maps/bin/add2nulllist.pl
maps/bin/modifyentries.cgi
maps/bin/processaction.cgi

index 1c85e83..bb0c368 100644 (file)
@@ -169,15 +169,15 @@ sub Add2Blacklist {
   Info "Removed $count emails from $sender"
 } # Add2Blacklist
 
-sub Add2Nulllist ($$;$) {
+sub Add2Nulllist ($$;$$) {
   # Add2Nulllist will add an entry to the nulllist
-  my ($sender, $userid, $comment) = @_;
+  my ($sender, $userid, $comment, $hit_count) = @_;
   
   # First SetContext to the userid whose null list we are adding to
   MAPSDB::SetContext $userid;
 
   # Add to null list
-  AddList "null", $sender, 0, $comment;
+  AddList "null", $sender, 0, $comment, $hit_count;
 
   # Log that we null listed the sender
   Info "Added $sender to " . ucfirst $userid . "'s null list";
@@ -242,10 +242,12 @@ sub AddEmail ($$$) {
   MAPSDB::AddEmail $sender, $subject, $data;
 } # AddEmail
 
-sub AddList ($$$;$) {
-  my ($listtype, $pattern, $sequence, $comment) = @_;
+sub AddList ($$$;$$) {
+  my ($listtype, $pattern, $sequence, $comment, $hit_count) = @_;
+
+  $hit_count //= CountMsg $pattern;
 
-  MAPSDB::AddList $listtype, $pattern, $sequence, $comment, CountMsg $pattern;
+  MAPSDB::AddList $listtype, $pattern, $sequence, $comment, $hit_count;
 } # AddList
 
 sub AddUser ($$$$) {
@@ -723,10 +725,10 @@ sub Space ($) {
   return MAPSDB::Space $userid;
 } # Space
 
-sub UpdateList ($$$$$$) {
-  my ($userid, $type, $pattern, $domain, $comment, $sequence) = @_;
+sub UpdateList ($$$$$$$) {
+  my ($userid, $type, $pattern, $domain, $comment, $hit_count, $sequence) = @_;
 
-  return MAPSDB::UpdateList $userid, $type, $pattern, $domain, $comment, $sequence;
+  return MAPSDB::UpdateList $userid, $type, $pattern, $domain, $comment, $hit_count, $sequence;
 } # UpdateList
 
 sub UpdateUser ($$$$) {
index d454ee2..1f09902 100644 (file)
@@ -2,7 +2,7 @@
 #################################################################################
 #
 # File:         $RCSfile: MAPSDB.pm,v $
-# Revision:    $Revision: 1.1 $
+# Revision:        $Revision: 1.1 $
 # Description:  MAPS Database routines
 # Author:       Andrew@DeFaria.com
 # Created:      Fri Nov 29 14:17:21  2002
@@ -216,18 +216,18 @@ sub CheckOnList ($$) {
   while (my @row = $sth->fetchrow_array) {
     last if !@row;
 
-    my $hit_count      = pop (@row);
-    my $sequence       = pop (@row);
-    my $comment                = pop (@row);
-    my $domain                 = pop (@row);
-    my $pattern                = pop (@row);
+    my $hit_count = pop (@row);
+    my $sequence  = pop (@row);
+    my $comment   = pop (@row);
+    my $domain    = pop (@row);
+    my $pattern   = pop (@row);
     my $email_on_file;
 
     unless ($domain) {
       $email_on_file = $pattern;
     } else {
       unless ($pattern) {
-       $email_on_file = '@' . $domain;
+        $email_on_file = '@' . $domain;
       } else {
         $email_on_file = $pattern . '@' . $domain;
       } # if
@@ -404,16 +404,16 @@ sub CleanList ($;$) {
   while (my @row = $sth->fetchrow_array) {
     last if !@row;
 
-    my $hit_count      = pop (@row);
-    my $sequence       = pop (@row);
-    my $listtype       = pop (@row);
+    my $hit_count = pop (@row);
+    my $sequence  = pop (@row);
+    my $listtype  = pop (@row);
 
     if ($hit_count == 0) {
       $count++;
 
       $statement = "delete from list where userid='$userid' and type='$listtype' and sequence=$sequence";
       $DB->do ($statement)
-       or DBError 'CleanList: Unable to execute statement', $statement;
+        or DBError 'CleanList: Unable to execute statement', $statement;
     } else {
       # Age entry: Sometimes entries are initially very popular and
       # the $hit_count gets very high quickly. Then the domain is
@@ -430,14 +430,14 @@ sub CleanList ($;$) {
       # $hit_count's too quickly, therefore once their numbers drop to
       # < 30 we revert to the old method of subtracting 1.
       if ($hit_count < 30) {
-       $hit_count--;
+        $hit_count--;
       } else {
-       $hit_count = $hit_count / 2;
+        $hit_count = $hit_count / 2;
       } # if
 
       $statement = "update list set hit_count=$hit_count where userid='$userid' and type='$listtype' and sequence=$sequence;";
       $DB->do ($statement)
-       or DBError 'CleanList: Unable to execute statement', $statement;
+        or DBError 'CleanList: Unable to execute statement', $statement;
     } # if
   } # while
 
@@ -452,7 +452,7 @@ sub CloseDB () {
 
 sub CountMsg ($) {
   my ($sender) = @_;
-  
+
   return count ('email', "userid = '$userid' and sender like '%$sender%'");
 } # CountMsg
 
@@ -686,14 +686,14 @@ sub GetList ($) {
   my @list;
 
   if (@list = $sth->fetchrow_array) {
-    my $last_hit       = pop @list;
-    my $hit_count      = pop @list;
-    my $sequence       = pop @list;
-    my $comment                = pop @list;
-    my $domain         = pop @list;
-    my $pattern                = pop @list;
-    my $type           = pop @list;
-    my $userid         = pop @list;
+    my $last_hit  = pop @list;
+    my $hit_count = pop @list;
+    my $sequence  = pop @list;
+    my $comment   = pop @list;
+    my $domain    = pop @list;
+    my $pattern   = pop @list;
+    my $type      = pop @list;
+    my $userid    = pop @list;
     return $userid, $type, $pattern, $domain, $comment, $sequence, $hit_count, $last_hit;
   } else {
     return undef;
@@ -731,10 +731,10 @@ sub GetUser ($) {
   my @user;
 
   if (@user = $sth->fetchrow_array) {
-    my $password       = pop @user;
-    my $email          = pop @user;
-    my $name           = pop @user;
-    my $userid         = pop @user;
+    my $password = pop @user;
+    my $email    = pop @user;
+    my $name     = pop @user;
+    my $userid   = pop @user;
     return ($userid, $name, $email, $password);
   } else {
     return undef;
@@ -778,8 +778,8 @@ sub GetUserOptions ($) {
   %useropts = ();
 
   while (@useropts = $sth->fetchrow_array) {
-    my $value  = pop @useropts;
-    my $name   = pop @useropts;
+    my $value = pop @useropts;
+    my $name  = pop @useropts;
     pop @useropts;
     $useropts{$name} = $value;
   } # while
@@ -883,10 +883,10 @@ sub ResequenceList ($$) {
 
     if ($old_sequence != $sequence) {
       my $update_statement = "update list set sequence = $sequence " .
-                            "where userid = '$userid' and " .
-                            "type = '$type' and sequence = $old_sequence";
+                             "where userid = '$userid' and " .
+                             "type = '$type' and sequence = $old_sequence";
       $DB->do ($update_statement)
-       or DBError 'ResequenceList: Unable to do statement', $statement;
+        or DBError 'ResequenceList: Unable to do statement', $statement;
     } # if
 
     $sequence++;
@@ -1138,13 +1138,13 @@ END
       my $date    = pop @row;
 
       if ($earliestDate) {
-       my $earliestDateShort = substr $earliestDate, 0, 10;
+        my $earliestDateShort = substr $earliestDate, 0, 10;
         my $dateShort         = substr $date,         0, 10;
 
         if ($earliestDateShort eq $dateShort and
-           $earliestDate > $date) {
+            $earliestDate > $date) {
           $earliestDate = $date
-           if $earliestDateShort eq $dateShort;
+            if $earliestDateShort eq $dateShort;
         } # if
       } else {
         $earliestDate = $date;
@@ -1162,7 +1162,7 @@ END
       push @emails, [$earliestDate, [$sender, @messages]];
     } else {
       push @emails, [$earliestDate, [$sender, @messages]]
-       if @messages > 0;
+        if @messages > 0;
     } # unless
   } # while
 
@@ -1180,11 +1180,11 @@ sub ReturnList ($$$) {
   my $statement;
 
   if ($start_at) {
-    $statement = "select * from list where userid = '$userid' "        .
-                 "and type = '$type' order by sequence "               .
-                "limit $start_at, $lines";
+    $statement = "select * from list where userid = '$userid' " .
+                 "and type = '$type' order by sequence "        .
+                 "limit $start_at, $lines";
   } else {
-    $statement = "select * from list where userid = '$userid' "        .
+    $statement = "select * from list where userid = '$userid' "        .
                  "and type = '$type' order by sequence";
   } # if
 
@@ -1202,14 +1202,14 @@ sub ReturnList ($$$) {
 
     my %list;
 
-    $list {last_hit}   = pop @row;
-    $list {hit_count}  = pop @row;
-    $list {sequence}   = pop @row;
-    $list {comment}    = pop @row;
-    $list {domain}     = pop @row;
-    $list {pattern}    = pop @row;
-    $list {type}               = pop @row;
-    $list {userid}     = pop @row;
+    $list {last_hit}  = pop @row;
+    $list {hit_count} = pop @row;
+    $list {sequence}  = pop @row;
+    $list {comment}   = pop @row;
+    $list {domain}    = pop @row;
+    $list {pattern}   = pop @row;
+    $list {type}      = pop @row;
+    $list {userid}    = pop @row;
     push @list, \%list;
   } # for
 
@@ -1219,7 +1219,7 @@ sub ReturnList ($$$) {
 sub ReturnListEntry ($$) {
   my ($type, $sequence) = @_;
 
-  my $statement = "select * from list where userid = '$userid' "       .
+  my $statement = "select * from list where userid = '$userid' "        .
                  "and type = '$type' and sequence = '$sequence'";
 
   my $sth = $DB->prepare ($statement)
@@ -1241,8 +1241,8 @@ sub ReturnListEntry ($$) {
   return %list;
 } # ReturnListEntry
 
-sub UpdateList ($$$$$$) {
-  my ($userid, $type, $pattern, $domain, $comment, $sequence) = @_;
+sub UpdateList ($$$$$$$) {
+  my ($userid, $type, $pattern, $domain, $comment, $hit_count, $sequence) = @_;
 
   if (!$pattern || $pattern eq '') {
     $pattern = 'NULL';
@@ -1261,10 +1261,16 @@ sub UpdateList ($$$$$$) {
   } else {
     $comment = "'" . quotemeta ($comment) . "'";
   } # if
+
+  if (!$hit_count || $hit_count eq '') {
+    $hit_count = 0;
+  #} else {
+  # TODO: Check if numeric
+  } # fi
   
   my $statement =
     'update list set ' .
-    "pattern = $pattern, domain = $domain, comment = $comment " .
+    "pattern = $pattern, domain = $domain, comment = $comment, hit_count = $hit_count " .
     "where userid = '$userid' and type = '$type' and sequence = $sequence";
 
   $DB->do ($statement)
@@ -1319,7 +1325,7 @@ sub SetContext ($) {
 sub Space ($) {
   my ($userid) = @_;
 
-  my $total_space      = 0;
+  my $total_space        = 0;
   my %msg_space;
 
   my $statement = "select * from email where userid = '$userid'";
index 7fcf668..003dbd5 100755 (executable)
@@ -36,12 +36,13 @@ sub Add2List {
   my $nextseq  = MAPSDB::GetNextSequenceNo $userid, $type;
 
   while () {
-    my $pattern = param "pattern$nextseq";
-    my $domain  = param "domain$nextseq";
-    my $comment = param "comment$nextseq";
+    my $pattern   = param "pattern$nextseq";
+    my $domain    = param "domain$nextseq";
+    my $comment   = param "comment$nextseq";
+    my $hit_count = param "hit_count$nextseq";
 
     last if ((!defined $pattern || $pattern eq '') &&
-              (!defined $domain  || $domain  eq ''));
+              (!defined $domain || $domain  eq ''));
 
     $sender = lc "$pattern\@$domain";
 
@@ -50,10 +51,10 @@ sub Add2List {
     if ($status != 0) {
       print br {-class => 'error'}, "The email address $sender is already on ${Userid}'s $type list";
     } else {
-      Add2Nulllist $sender, $userid, $comment;
+      Add2Nulllist $sender, $userid, $comment, $hit_count;
 
       print br "The email address, $sender, has been added to ${Userid}'s $type list";
-        
+
       # Now remove this entry from the other lists (if present)
       foreach my $otherlist ('white', 'black') {
         my $sth = FindList $otherlist, $sender;
@@ -100,7 +101,7 @@ print start_form {
 
 print '<p></p><center>',
   hidden ({-name        => 'type',
-           -default   => $type}),
+           -default     => $type}),
   submit ({-name        => 'action',
            -value       => 'Add New Entry'}),
   '</center>';
index 21755b3..27d694e 100755 (executable)
@@ -30,9 +30,10 @@ sub GetItems {
 
     my @address = split /\@/, $fields [0];
 
-    $item {pattern}    = $address [0];
-    $item {domain}     = $address [1];
-    $item {comment}    = $fields [1] ? $fields [1] : "";
+    $item{pattern}   = $address[0];
+    $item{domain}    = $address[1];
+    $item{comment}   = $fields[1] ? $fields[1] : '';
+    $itme{hit_count} = $fields[2] ? $fields[2] : 0;
 
     push @items, \%item;
   } # while
@@ -41,37 +42,42 @@ sub GetItems {
 } # GetItems
 
 sub Add2List {
-  my @items    = @_;
+  my @items = @_;
 
-  my $sender   = "";
-  my $nextseq  = MAPSDB::GetNextSequenceNo $userid, $type;
+  my $sender  = "";
+  my $nextseq = MAPSDB::GetNextSequenceNo $userid, $type;
 
   foreach (@items) {
-    my %item   = %{$_};
+    my %item = %{$_};
 
-    my $pattern        = $item {pattern};
-    my $domain = $item {domain};
-    my $comment        = $item {comment};
+    my $pattern   = $item{pattern};
+    my $domain    = $item{domain};
+    my $comment   = $item{comment};
+    my $hit_count = $item{hit_count};
 
     display_nolf "Adding $pattern\@$domain ($comment) to null list ($nextseq)...";
-    last if ((!defined $pattern || $pattern eq "") &&
-            (!defined $domain  || $domain eq ""));
-    $sender    = lc ("$pattern\@$domain");
+
+    last if ((!defined $pattern || $pattern eq '') &&
+             (!defined $domain  || $domain  eq ''));
+
+    $sender = lc ("$pattern\@$domain");
 
     if (OnNulllist $sender) {
       display " Already on list";
     } else {
-      Add2Nulllist $sender, $userid, $comment;
+      Add2Nulllist $sender, $userid, $comment, $hit_count;
       display " done";
-       
+
       # Now remove this entry from the other lists (if present)
       foreach my $otherlist ("white", "black") {
-       my $sth = FindList $otherlist, $sender;
-       my ($sequence, $count);
-       ($_, $_, $_, $_, $_, $sequence) = GetList $sth;
-       if (defined $sequence) {
-         $count = DeleteList $otherlist, $sequence;
-       } # if
+        my $sth = FindList $otherlist, $sender;
+        my ($sequence, $count);
+
+        ($_, $_, $_, $_, $_, $sequence) = GetList $sth;
+
+        if ($sequence) {
+          $count = DeleteList $otherlist, $sequence;
+        } # if
       } # foreach
     } # if
     $nextseq++;
@@ -82,7 +88,7 @@ sub Add2List {
 my $filename;
 
 if ($ARGV [0]) {
-  $filename = $ARGV [0];
+  $filename = $ARGV[0];
 } else {
   error "Must specify a filename of addresses to null list", 1;
 } # if
index 0d92c27..b2624a1 100755 (executable)
@@ -2,8 +2,8 @@
 ################################################################################
 #
 # File:         $RCSfile: modifyentries.cgi,v $
-# Revision:    $Revision: 1.1 $
-# Description: Modify list entries
+# Revision:     $Revision: 1.1 $
+# Description:  Modify list entries
 # Author:       Andrew@DeFaria.com
 # Created:      Mon Jan 16 20:25:32 PST 2006
 # Modified:     $Date: 2013/06/12 14:05:47 $
@@ -49,7 +49,6 @@ sub ReturnSequenceNbrs {
 # Main
 my $i = 0;
 
-
 foreach (ReturnSequenceNbrs) {
   UpdateList
     $userid,
@@ -57,6 +56,7 @@ foreach (ReturnSequenceNbrs) {
     param ("pattern$_"),
     param ("domain$_"),
     param ("comment$_"),
+    param ("hit_count$_"),
     $_;
   $i++;
 } # foreach
index d294bc8..539572e 100755 (executable)
@@ -26,13 +26,13 @@ use MAPSWeb;
 use CGI qw (:standard *table start_Tr end_Tr);
 use CGI::Carp 'fatalsToBrowser';
 
-my $type       = param 'type';
-my $action     = param 'action';
-my $next       = param 'next';
-my $userid     = cookie 'MAPSUser';
+my $type   = param 'type';
+my $action = param 'action';
+my $next   = param 'next';
+my $userid = cookie 'MAPSUser';
 my $lines;
 my $total;
-my $table_name = 'list';
+my $table_name = 'list';
 
 my @scripts = ('ListActions.js');
 
@@ -64,12 +64,12 @@ sub DeleteEntries {
     $count += DeleteList $type, $_;
   } # foreach
 
-  if ($count eq 0) {
+  if ($count == 0) {
     DisplayError 'Nothing to delete!';
   } else {
     ResequenceList $userid, $type;
 
-    if ($count eq 1) {
+    if ($count == 1) {
       print redirect ("/maps/php/list.php?type=$type&next=$next&message=Deleted entry");
     } else {
       print redirect ("/maps/php/list.php?type=$type&next=$next&message=Deleted $count entries");
@@ -82,52 +82,65 @@ sub DeleteEntries {
 sub PrintInputLine ($$$$$) {
   my ($nextseq, $email_nbr, $leftclass, $dataclass, $rightclass) = @_;
 
-  my $email    = '';
-  my $pattern  = '';
-  my $domain   = '';
+  my $email     = '';
+  my $pattern   = '';
+  my $domain    = '';
+  my $hit_count = 0;
 
   if (defined $email_nbr && $email_nbr ne '') {
     $email = param "email$email_nbr";
     if ($email && $email ne '') {
       ($pattern, $domain) = split /\@/, $email;
     } # if
+
+    $hit_count = param "hit_count$email_nbr";
   } # if
 
   print Tr [
-    td {-class                 => $leftclass,
-       -align                  => 'center'}, "$nextseq",
-    td {-class                 => $dataclass,
-       -align                  => 'right'},
-      (textfield {-class       => 'inputfield',
-                 -style        => 'width:100%',
-                 -align        => 'right',
-                 -size         => 25,
-                 -maxlength    => '255',
-                 -name         => "pattern$nextseq",
-                 -value        => $pattern}),
-    td {-class                 => $dataclass,
-       -align                  => 'center'}, '@',
-    td {-class                 => $dataclass},
-      (textfield {-class       => 'inputfield',
-                 -style        => 'width:100%',
-                 -align        => 'left',
-                 -size         => 25,
-                 -maxlength    => '255',
-                 -name         => "domain$nextseq",
-                 -value        => $domain}),
-    td {-class                 => $rightclass},
-      (textfield {-class       => 'inputfield',
-                 -style        => 'width:100%',
-                 -align        => 'left',
-                 -size         => 25,
-                 -maxlength    => '255',
-                 -name         => "comment$nextseq",
-                 -value        => ''}),
+    td {-class      => $leftclass,
+        -align      => 'center'}, "$nextseq",
+    td {-class      => $dataclass,
+        -align      => 'right'},
+      (textfield {-class     => 'inputfield',
+                  -style     => 'width:100%',
+                  -align     => 'right',
+                  -size      => 25,
+                  -maxlength => '255',
+                  -name      => "pattern$nextseq",
+                  -value     => $pattern}),
+    td {-class      => $dataclass,
+        -align      => 'center'}, '@',
+    td {-class      => $dataclass},
+      (textfield {-class      => 'inputfield',
+                  -style      => 'width:100%',
+                  -align      => 'left',
+                  -size       => 25,
+                  -maxlength  => '255',
+                  -name       => "domain$nextseq",
+                  -value      => $domain}),
+    td {-class      => $dataclass},
+      (textfield {-class     => 'inputfield',
+                  -style     => 'width:100%',
+                  -align     => 'left',
+                  -size      => 25,
+                  -maxlength => '255',
+                  -name      => "comment$nextseq",
+                  -value     => ''}),
+    td {-class      => $rightclass},
+      (textfield {-class     => 'inputfield',
+                  -style     => 'width:100%',
+                  -align     => 'left',
+                  -size      => 25,
+                  -maxlength => '255',
+                  -name      => "hit_count$nextseq",
+                  -value     => $hit_count}),
   ];
+
+  return;
 } # PrintInputLine
 
 sub AddNewEntry {
-  my ($type, @selected)        = @_;
+  my ($type, @selected)  = @_;
 
   # First display the last page and add the appropriate number of
   # empty, editable entries (possibly filled in) for the user to add
@@ -155,23 +168,24 @@ sub AddNewEntry {
 
   # Now display table and new entry
   print start_form {
-    -method    => 'post',
-    -action    => 'add2' . $type . 'list.cgi',
-    -name      => 'list'
+    -method => 'post',
+    -action => 'add2' . $type . 'list.cgi',
+    -name   => 'list'
   };
 
-  print start_table {-align            => 'center',
-                    -id                => $table_name,
-                    -border            => 0,
-                    -cellspacing       => 0,
-                    -cellpadding       => 4,
-                    -width             => '100%'};
+  print start_table {-align       => 'center',
+                     -id          => $table_name,
+                     -border      => 0,
+                     -cellspacing => 0,
+                     -cellpadding => 4,
+                     -width       => '100%'};
   print Tr [
-    th {-class => 'tableleftend'},     'Seq',
-    th {-class => 'tableheader'},      'Username',
-    th {-class => 'tableheader'},      '@',
-    th {-class => 'tableheader'},      'Domain',
-    th {-class => 'tablerightend'},    'Comments'
+    th {-class => 'tableleftend'},  'Seq',
+    th {-class => 'tableheader'},   'Username',
+    th {-class => 'tableheader'},   '@',
+    th {-class => 'tableheader'},   'Domain',
+    th {-class => 'tableheader'},   'Comments',
+    th {-class => 'tablerightend'}, 'Hit Count'
   ];
 
   my @list = ReturnList $type, $next, $lines;
@@ -184,27 +198,30 @@ sub AddNewEntry {
     %record = %{$_};
 
     # Normalize fields
-    my $sequence = $record{sequence};
-    my $pattern  = $record{pattern} ? $record{pattern} : '&nbsp;';
-    my $domain   = $record{domain}  ? $record{domain}  : '&nbsp;';
-    my $comment  = $record{comment} ? $record{comment} : '&nbsp;';
+    my $sequence  = $record{sequence};
+    my $pattern   = $record{pattern}   ? $record{pattern}   : '&nbsp;';
+    my $domain    = $record{domain}    ? $record{domain}    : '&nbsp;';
+    my $comment   = $record{comment}   ? $record{comment}   : '&nbsp;';
+    my $hit_count = $record{hit_count} ? $record{hit_count} : '&nbsp;';
 
     print Tr [
-      td {-class       => 'tableleftdata',
-         -align        => 'center'}, $sequence,
-      td {-class       => 'tabledata',
-         -align        => 'right'}, $pattern,
-      td {-class       => 'tabledata',
-         -align        => 'center'}, '@',
-      td {-class       => 'tabledata',
-         -align        => 'left'}, $domain,
-      td {-class       => 'tablerightdata',
-         -align        => 'left'}, $comment
+      td {-class  => 'tableleftdata',
+          -align  => 'center'}, $sequence,
+      td {-class  => 'tabledata',
+          -align  => 'right'}, $pattern,
+      td {-class  => 'tabledata',
+          -align  => 'center'}, '@',
+      td {-class  => 'tabledata',
+          -align  => 'left'}, $domain,
+      td {-class  => 'tabledata',
+          -align  => 'left'}, $comment,
+      td {-class  => 'tablerightdata',
+          -align  => 'right'}, $hit_count,
     ];
   } # foreach
 
   # Now the input line(s)
-  if (@selected eq 0) {
+  if (@selected == 0) {
     PrintInputLine $nextseq, undef, 'tablebottomleft', 'tablebottomdata',
                                     'tablebottomright';
   } else {
@@ -220,14 +237,16 @@ sub AddNewEntry {
   print end_table;
   print br,
     '<center>',
-      submit ({-name   => 'update',
-              -value   => 'Update',
-              -onClick => 'return CheckEntry (document.list);'}),
-      submit ({-name   => 'Reset',
-              -value   => 'Reset',
-              -onClick => 'history.back(); return false'}),
+      submit ({-name    => 'update',
+               -value   => 'Update',
+               -onClick => 'return CheckEntry (document.list);'}),
+      submit ({-name    => 'Reset',
+               -value   => 'Reset',
+               -onClick => 'history.back(); return false'}),
     '</center>';
   print end_form;
+
+  return;
 } # AddNewEntry
 
 sub ModifyEntries {
@@ -251,30 +270,31 @@ sub ModifyEntries {
 
   # Redisplay the page but open up the lines that are getting modified
   print start_form {
-    -method    => 'post',
-    -action    => 'modifyentries.cgi',
-    -name      => 'list'
+    -method  => 'post',
+    -action  => 'modifyentries.cgi',
+    -name    => 'list'
   };
 
   # Print some hidden fields to pass along
   print
-    hidden ({-name     => 'type',
-            -default   => $type}),
-    hidden ({-name     => 'next',
-            -default   => $next});
-
-  print start_table {-align            => 'center',
-                    -id                => $table_name,
-                    -border            => 0,
-                    -cellspacing       => 0,
-                    -cellpadding       => 4,
-                    -width             => '100%'};
+    hidden ({-name    => 'type',
+             -default => $type}),
+    hidden ({-name    => 'next',
+             -default => $next});
+
+  print start_table {-align       => 'center',
+                     -id          => $table_name,
+                     -border      => 0,
+                     -cellspacing => 0,
+                     -cellpadding => 4,
+                     -width       => '100%'};
   print Tr [
-    th {-class => 'tableleftend'},     'Seq',
-    th {-class => 'tableheader'},      'Username',
-    th {-class => 'tableheader'},      '@',
-    th {-class => 'tableheader'},      'Domain',
-    th {-class => 'tablerightend'},    'Comments'
+    th {-class => 'tableleftend'},  'Seq',
+    th {-class => 'tableheader'},   'Username',
+    th {-class => 'tableheader'},   '@',
+    th {-class => 'tableheader'},   'Domain',
+    th {-class => 'tableheader'},   'Comments',
+    th {-class => 'tablerightend'}, 'Hit Count',
   ];
 
   my @list = ReturnList $type, $next, $lines;
@@ -296,59 +316,71 @@ sub ModifyEntries {
     $i++;
 
     print start_Tr,
-      td {-class       => $leftclass,
-         -align        => 'center'}, $record{sequence};
+      td {-class  => $leftclass,
+          -align  => 'center'}, $record{sequence};
 
     if ($record{sequence} eq $selected[$s]) {
       $s++;
       # Normalize fields
-      my $pattern = $record{pattern} ? $record{pattern} : '';
-      my $domain  = $record{domain}  ? $record{domain}  : '';
-      my $comment = $record{comment} ? $record{comment} : '';
+      my $pattern   = $record{pattern}   ? $record{pattern}   : '';
+      my $domain    = $record{domain}    ? $record{domain}    : '';
+      my $comment   = $record{comment}   ? $record{comment}   : '';
+      my $hit_count = $record{hit_count} ? $record{hit_count} : '';
 
       print
-        td {-class                     => $dataclass,
-           -align                      => 'right'},
-          (textfield {-class           => 'inputfield',
-                     -style            => 'width:100%',
-                     -align            => 'right',
-                     -size             => 25,
-                     -maxlength        => '255',
-                     -name             => "pattern$sequence",
-                     -value            => $pattern}),
-        td {-class                     => $dataclass,
-           -align                      => 'center'}, '@',
-        td {-class                     => $dataclass},
-          (textfield {-class           => 'inputfield',
-                     -style            => 'width:100%',
-                     -align            => 'left',
-                     -size             => 25,
-                     -maxlength        => '255',
-                     -name             => "domain$sequence",
-                     -value            => $domain}),
-        td {-class                     => $rightclass},
-           (textfield {-class          => 'inputfield',
-                      -style           => 'width:100%',
-                      -align           => 'left',
-                      -size            => 25,
-                      -maxlength       => '255',
-                      -name            => "comment$sequence",
-                      -value           => $comment});
+        td {-class      => $dataclass,
+            -align      => 'right'},
+          (textfield {-class     => 'inputfield',
+                      -style     => 'width:100%',
+                      -align     => 'right',
+                      -size      => 25,
+                      -maxlength => '255',
+                      -name      => "pattern$sequence",
+                      -value     => $pattern}),
+        td {-class      => $dataclass,
+            -align      => 'center'}, '@',
+        td {-class      => $dataclass},
+          (textfield {-class     => 'inputfield',
+                      -style     => 'width:100%',
+                      -align     => 'left',
+                      -size      => 25,
+                      -maxlength => '255',
+                      -name      => "domain$sequence",
+                      -value     => $domain}),
+        td {-class      => $dataclass},
+           (textfield {-class     => 'inputfield',
+                       -style     => 'width:100%',
+                       -align     => 'left',
+                       -size      => 25,
+                       -maxlength => '255',
+                       -name      => "comment$sequence",
+                       -value     => $comment}),
+        td {-class      => $rightclass},
+           (textfield {-class     => 'inputfield',
+                       -style     => 'width:100%',
+                       -align     => 'left',
+                       -size      => 25,
+                       -maxlength => '255',
+                       -name      => "hit_count$sequence",
+                       -value     => $hit_count});
     } else {
       # Put in '&nbsp;' for undefined fields
-      my $pattern = $record{pattern} ? $record{pattern} : '&nbsp;';
-      my $domain  = $record{domain}  ? $record{domain}  : '&nbsp;';
-      my $comment = $record{comment} ? $record{comment} : '&nbsp;';
+      my $pattern   = $record{pattern}   ? $record{pattern}   : '&nbsp;';
+      my $domain    = $record{domain}    ? $record{domain}    : '&nbsp;';
+      my $comment   = $record{comment}   ? $record{comment}   : '&nbsp;';
+      my $hit_count = $record{hit_count} ? $record{hit_count} : '&nbsp;';
 
       print
         td {-class => $dataclass,
-           -align => 'right'}, $pattern,
+            -align => 'right'}, $pattern,
+        td {-class => $dataclass,
+            -align => 'center'}, '@',
         td {-class => $dataclass,
-           -align => 'center'}, '@',
+            -align => 'left'}, $domain,
         td {-class => $dataclass,
-           -align => 'left'}, $domain,
+            -align => 'left'}, $comment,
         td {-class => $rightclass,
-           -align => 'left'}, $comment;
+            -align => 'left'}, $hit_count;
     } # if
 
     print end_Tr;
@@ -357,14 +389,16 @@ sub ModifyEntries {
   print end_table;
   print br,
     '<center>',
-      submit ({-name   => 'update',
-              -value   => 'Update',
-              -onClick => 'return CheckEntry (document.list);'}),
-      submit ({-name   => 'Reset',
-              -value   => 'Reset',
-              -onClick => 'history.back(); return false'}),
+      submit ({-name    => 'update',
+               -value   => 'Update',
+               -onClick => 'return CheckEntry (document.list);'}),
+      submit ({-name    => 'Reset',
+               -value   => 'Reset',
+               -onClick => 'history.back(); return false'}),
     '</center>';
   print end_form;
+
+  return;
 } # ModifyEntries
 
 sub WhitelistMarked {