This code is called at http://www.queenfans.com/topsites. If someone presses the search button, a line is added to the data file - search|ip address|time stamp - and the following code counts how many times a search has been used. But some people are pressing the button more than once on purpose to push a search to the top... how do I stop this from showing up?
#!/usr/bin/perl
print "Content-type: text/html\n\n";
open (TXTFILE, "Searches.dat");
@lines = <TXTFILE>;
close(TXTFILE);
chomp(@lines);
my %seen_hash;
my $key_nums =0;
foreach $line(@lines){
@data = split(/\|/, $line);
push(@searches, $data[0]);
}
foreach (@searches) {
$seen_hash{$_}++;
}
my @sorted_keys = sort { $seen_hash{ $b } <=> $seen_hash{ $a } } keys
+ %seen_hash;
print "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
# then just do a print for each key in the %seen_hash hash
$rows = 0;
foreach(@sorted_keys){
if ($rows<5){
print "<tr height=\"8\"><td><font face=\"Verdana\" size=\"1\">" . $_
+ . "</font></td><td height=\"22\"><font face=\"Verdana\" size=\"1\">"
+ . $seen_hash{$_} . "</font></td></tr>\n";
}
$rows++;
}
print "</table>";
Data
--------
search|ip address|time stamp
search|ip address|time stamp
search2|ip address|time stamp
|