Gossamer Forum
Home : Products : Links 2.0 : Customization :

Keyword Tracker problem...

Quote Reply
Keyword Tracker problem...
Hi,
I have installed the keyword Tracker using Version 2 with Templates, and followed the directions on the website, but I get the following error message when I try using it... (Code snippets to follow the error)

CGI ERROR
==========================================
Error Message : fatal error: Undefined subroutine &main::track_kwords called at F:\Links\cgi-bin\search.pl line 181.

Script Location : F:\Links\cgi-bin\search.pl
Perl Version : 5.00502

Form Variables
-------------------------------------------
bool : and
mh : 25
query : Thelema
type : keyword
-------------------------------------------
From Search.cgi
Code:
sub logsearch {

my $newtime = time;
if (-e "$kword_file") {
open (DAT, "$kword_file") or &cgierr("Error [search.cgi]: Unable to open keyword file. Reason: $!");
flock (DAT,2) or &cgierr("Error [search.cgi]: Unable to flock keyword file. Reason: $!");
open (BAK, ">>$kword_file.bak") or &cgierr("Error [search.cgi]: Unable to open backup keyword file. Reason: $!");
@kwords = <DAT>;
close (DAT);
$found = 0;
foreach $line (@kwords) {
chomp $line;
($word, $count, $oldtime) = split(/\|/,$line);
if ($in{'query'} eq $word) {
$count++;
$found = 1;
print BAK "$word|$count|$newtime\n";
}
else {
print BAK "$word|$count|$oldtime\n";
}
}
if ($found == 0) {
print BAK "$in{'query'}|1|$newtime\n";
}
close (BAK);
rename ("$kword_file.bak", "$kword_file") or &cgierr("Error [search.cgi]: Unable to rename backup keyword file. Reason: $!");
}
else {
open (DAT, ">$kword_file") or &cgierr("Error [search.cgi]: Unable to create keyword file. Reason: $!");
print DAT "$in{'query'}|1|$newtime\n";
close (DAT);
}
}

Again from Search.cgi
Code:
sub search {
# --------------------------------------------------------
# This routine does the actual search of the database.
#
# CALLS LAST SUBROUTINE - TRACKS SEARCH TERMS TO FILE
&track_kwords;
my ($search_terms, $bool) = @_;
my ($regexp, @values, $grand_total, $match, $andmatch, $field, $or_match, %seen, $link, $tmp);

# Save the reg expressions to avoid rebuilding.
$or_match = $bool ne 'and';
if ($or_match) {
for (0 .. $#{$search_terms}) {
next if (length ${$search_terms}[$_] < 2); # Skip single letter words.
$tmp .= "m/\Q${$search_terms}[$_]\E/io &#0124; &#0124;";
}
}
else {
for (0 .. $#{$search_terms}) {
next if (length ${$search_terms}[$_] < 2); # Skip single letter words.
$tmp .= "m/\Q${$search_terms}[$_]\E/io &&";
}
}
chop ($tmp); chop ($tmp);

(Only the 1st few lines from the routine above were copied)

From links.cfg
Code:
$db_hits_path = "$db_script_path/data/hits"; # PATH to hits directory.
$db_template_path = "$db_script_path/templates"; # PATH to templates.
$db_rates_path = "$db_script_path/data/rates"; # PATH to ratings.
$kword_file = "$db_script_path/data/keywords.txt"; # PATH to Keyword Tracker Textfile.

I am totally stuck trying to figgure out what is wrong here...

Babalon

Quote Reply
Re: Keyword Tracker problem... In reply to
Hi:

Sorry about that! Please change the following:

sub logsearch => sub log_search

&track_kwords => &log_search

Thanks for bringing this to my attention. I amended the site.

Dan Smile

Quote Reply
Re: Keyword Tracker problem... In reply to
Dan,

THANKS Smile

I thought I was going crazy ...

Babalon