I think I've got it.
This is the whole mod, not just changes you'll need to make.
.
Code:
###############################################################
# default.cfg
#-------------------------------------------------------------
# Add the following to your .cfg file:
###############################################################
### In the # File and URL's section add:
# Full Path and File name of the record view count directory.
$counter_dir = $db_script_path . "/temp";
### After $auth_logoff = "http://www.yourdomain.com"; add:
# How many seconds to remove the old ip addresses for record view count?
# 3600 - One Hour (Recomended)
$ipupdate = "3600"; ### Added for time interval
###############################################################
# html.pl #
#-------------------------------------------------------------#
# In 'sub html_record' (or 'sub html_record_long', if you're #
# using the short/long display mod): #
###############################################################
### After
my (%rec) = @_;
### add
&top10($rec{$db_key},$rec{'Sex'});
sub html_topten {
#-------------------------------------------------------------
&html_print_headers;
print qq|
<html>
<head><title>$html_title: top Ten Records.</title></head>
<BODY>
header html code goes here
|;
print "<table><tr>";
for ($j=1;$j<3 ;++$j) {
undef (@files,%count,@top_ten,$toparray,$toplist);
opendir (TEMPDIR, "$counter_dir/$j");
@files = readdir(TEMPDIR); # Read in list of files in directory..
closedir (TEMPDIR);
FILE: foreach $file (@files) {
next if ($file =~ /^\./); # Skip "." and ".." entries..
next if ($file =~ /^index/); # Skip index.htm type files..
open (COUNTER, "<$counter_dir/$j/$file");
$count{$file} = int(<COUNTER> );
close COUNTER;
}
foreach $key (sort {$count{$b} <=> $count{$a} } keys %count) { push (@top_ten,$key); }
for ($i=0;$i<10 ;$i++) {
$toparray .= "$top_ten[$i],";
}
chop $toparray;
print "<td>";
foreach my $toplist (split(/,/,$toparray)) {
&html_record(&get_record($toplist)); ## See below if you're using short/long display mod
}
print "</td>";
}
print "</tr></table>";
print qq|footer html code goes here|;
&html_footer;
print qq|</body></html>|;
}
#### For short/long display, use the following, and change $rec{'FieldName'} to match your database.
%rec = (&get_record($toplist));
print qq|
<a href="$db_script_link_url&$db_key=$rec{$db_key}&view_records=1&ww=1">$rec{'FieldName'}</a><BR>
|;
### In 'sub html_footer', add
print qq!|<A HREF="$db_script_link_url&topten=1">top Ten</A> ! if ($per_view);
###############################################################
# db.cgi #
#-------------------------------------------------------------#
# Delete (or comment out) this line in sub get_record: #
###############################################################
($restricted = 1) if ($auth_modify_own and !$per_admin);
### In 'sub main', after
if ($in{'add_form'}) { if ($per_add) { &html_add_form; } else { &html_unauth; } }
### add
elsif ($in{'topten'}) { if ($per_view) { &html_topten; } else { &html_unauth; } }
sub top10 {
#-----------------------------------------------------------
my ($key) = $_[0];
my ($gender) = $_[1];
$key =~ s/<?.B>//g;
$gender =~ s/<?.B>//g;
$iptime = time();
$remote = $ENV{'REMOTE_ADDR'};
$cheat = 0;
if (-e "$counter_dir/iplog.txt") {
open (iplog, "+<$counter_dir/iplog.txt");
if ($db_use_flock) { flock(iplog, 2); }
@ipdata = <iplog>;
seek (iplog, 0, 0);
truncate (iplog,0);
foreach $log (@ipdata) {
@ips = split(/\|/, $log);
$iptotal = $iptime - $ips[1];
if (($ips[0] == $remote) && ($ips[2] == $key) && ($iptotal < $ipupdate)) { $cheat = 1; }
if ($iptotal < $ipupdate) { print iplog "$ips[0]|$ips[1]|$ips[2]\n"; }
}
unless ($cheat) { print iplog "$remote|$iptime|$db_key\n"; }
close (iplog);
}
else {
open(newip, ">$counter_dir/iplog.txt");
print newip "$remote|$iptime|$key\n";
close (newip);
}
if (!$cheat) {
open (COUNT, "$counter_dir/$gender/$key");
if ($db_use_flock) { flock(COUNT, 2); }
$countup = <COUNT>;
$countup++;
close COUNT;
open (COUNT, ">$counter_dir/$gender/$key");
if ($db_use_flock) { flock(COUNT, 2); }
print COUNT $countup;
close COUNT;
}
else {
open (COUNT, "<$counter_dir/$gender/$key");
if ($db_use_flock) { flock(COUNT, 2); }
$countup = <COUNT>;
close COUNT;
}
}