Gossamer Forum
Home : Products : DBMan : Customization :

Search Word Log

Quote Reply
Search Word Log
Hello Everyone

I was wondering if anyone has a script that will track the search words used on the Database by users?.

Here is what i need to do. Say a user searches for the word Ford Mustang on my Ford database. I need to know the time and user that did the search along with the search words.

Is this possible?? I'm willing to pay for this mod.

Thanks
Quote Reply
Re: Search Word Log In reply to
I have that mod, working of course. It's not mine, I've just made it works with DBMan, as originally it was created for Links.

Ok, here it is: (to see keyword list just call your keyword.cgi)

in your default.cfg add this line
$kword_file = $db_script_path . "/keywords.txt";


Make file keyword.cgi and put this in it. Put keyword.cgi in the same dir
as db.cgi
-------------------------------------cut here-------------
#!/usr/bin/perl5
#
# Sort Routine was written by Alex Krohn ( thanx a million )
# This script is little more than the sort routine. It
# Just takes the Keyword Mod and makes a nice pretty table
# out of it. Thought this would be useful if you wanted
# to show it to your users, or just make it easier to read.
#
# This script uses The Search Log mod found at
# http://www.monster-submit.com/mods01.html
# Its easy to install and counts each search.
#
# Send Feedback to crowe@darkspiral.com
#
#
############################################################
print "Content-Type: text/html\n\n";
# If greater than this number the script will highlight those entries.
$targetnumba = 5 ;
# Print out the HTML that Appears BEFORE the sorting.
print "<HTML><HEAD><TITLE>Keyword List Html Build</TITLE></HEAD><body link=red vlink=red bgcolor=ffffff text=000000><center>\n";
print "<br><br><a href=keyword.cgi>Build Keywords</a><br><br><font size=1>Currently Highlighting words greater than <font color=RED>$targetnumba</font> searches.</font> <br><br>\n";
print "<table bgcolor=C0C0C0 width=600 border=1 cellpadding=0 cellspacing=0><tr><td bgcolor=E0E0E0 valign=top>Keyword</td><td bgcolor=E0E0E0 valign=top>Number of Searches</td></tr>\n";
# Open The DB, Sorts and Print out the Results.
# I run mine from the same dir as my Keywords.txt file, change it
# to your full path if you want people to have access to it.
open (DB, "keywords.txt") or die $!;
while (<DB> ) {
chomp;
($name, $score) = split /:/;
$scores{$name} = $score;
}
close DB;
foreach $word (sort { $scores{$b} <=> $scores{$a} } keys %scores) {
if ($scores{$word} > $targetnumba)
{
print "<tr><td valign=top><font color=RED><b><em>$word</font></em></b></td><td valign=top><font color=RED><b><em>$scores{$word}</font></em></b></td></tr>\n";
}
else {
print "<tr><td valign=top><font color=blue>$word </font></td><td valign=top><font color=BLUE>$scores{$word}</font></td></tr>\n";
}
}
# Prints the End of the HTML
print "</table><br><br><font size=1>Search Log Table-izer by Crowe\@darkspiral.com</font></center></body></html>\n";

--------------------------------------------------CUT HERE-----------



Ok, now in your db.cgi change from

# First thing we do is find out what we are searching for. We build a list of fields
# we want to search on in @search_fields.
if ($in{'keyword'}) { # If this is a keyword search, we are searching the same

to

# First thing we do is find out what we are searching for. We build a list of fields
# we want to search on in @search_fields.
if ($in{'keyword'}) { # If this is a keyword search, we are searching the same
&track_kwords;




and at the end of db.cgi add

sub track_kwords {

if (-e "$kword_file") {
open (DAT, "$kword_file") or &cgierr("Error [search.cgi]: Unable to open keyword file. Reason: $!");
if ($db_use_flock) {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 create backup keyword file. Reason: $!");
@kwords = <DAT>;
chomp(@kwords);
$found = "0";
foreach $line (@kwords) {
($word, $count) = split (/\:/, $line);
if ($in{'keyword'} eq $word) {
$count++;
$found = "1";
}
print BAK "$word:$count\n";
}
if ($found eq "0") {
print BAK "$in{'keyword'}:1\n";
}
close (DAT);
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{'keyword'}:1\n";
close (DAT);
chmod (0666, "$kword_file") or &cgierr("Error [search.cgi]: Unable to chmod keyword file. Reason: $!");
}
}


Quote Reply
Re: Search Word Log In reply to
This mod is fine for keyword searches ONLY. Has anybody been able to modify this script that will allow tracking of fields searched for (NOT keywords)? Also, this mod does not seem to be cross platform compatible with NT. I have tried it on NT and it doesn't work. I get error messages regarding unable to change name. The process of changing names and permissions does not function in NT according to this script. It would be nice if someone comes up with a cross-platform and more robust logging script.

Smile

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Search Word Log In reply to
Ask the author of the script, as I'm sure he has done many, many improvements. But you'll have to convert it to work with DBman as originally it's made for Links.

Quote Reply
Re: Search Word Log In reply to
Thanks for the obvious suggestion. I will do that. Smile

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us