It will count the number of times each individual record is viewed.
Maybe I ought to recap it for you, just so everything's together.
First, you need to add a field to hold the count -- you could call it "Counter."
Then set a variable -- call it $db_counter_field and set it to the number of the field that your counter is in. Put this in your default.cfg file, like this:
$db_counter_field = 4;
Now, add the following to html_record, just after
my (%rec) = @_;
Code:
open (DB, "<$db_file_name") or &cgierr("error. unable to open db file: $db_file_name.\nReason:$!");
if ($db_use_flock) { flock(DB, 1); }
@lines = <DB>; # Slurp the database into @lines..
close DB;
LINE: foreach $line (@lines) {
if ($line =~ /^$/) { next LINE; }
if ($line =~ /^#/) { $output .= $line; next LINE; }
chomp ($line);
@data = &split_decode($line);
if ($data[$db_key_pos] eq $rec{$db_key}) {
++$data[$db_counter_field];
$output .= join($db_delim, @data) . "\n";
}
else {
$output .= $line . "\n";
}
}
open (DB, ">$db_file_name") or &cgierr("error. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) {
flock(DB, 2) or &cgierr("unable to get exclusive lock on $db_file_name.\nReason: $!");
}
print DB $output;
close DB;
This will work even if you use the autogenerate feature. If you are using the short/long display mod, it probably would be better to put this in html_record_long. If you don't know what I'm talking about in the previous sentence, just ignore it.
------------------
JPD
[This message has been edited by JPDeni (edited July 09, 1999).]