Gossamer Forum
Home : Products : Links 2.0 : Customization :

Neat Suggestion for Top Search Mod (Keyword Logger)

(Page 2 of 3)
> > > >
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
you could have added a hidden variable.. like

<input type="hidden" name="nolog" value="1">

and then in search.cgi

Code:
($in{'nolog'}) or &log;

jerry
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Ok, this thread went farther since the last time i read it. Can someone tell me from what i see all of what you did to make it execute the perl file in ssi using javascript, then made it rotate the words. Thanks
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Thanks for the heads-up, Jerry...Although I am not concerned about the number of queries because my site has a lot of traffic and the search log file is around 40,000 bytes right now with tons of queries.

But your codes are very nice. I will use them later if I experience problems.

About the no logging...great codes.

Bmxer,

That sums it up. Basically, we worked up a random text script that takes the keywords out of the keywords.txt file (generated by the Keyword Logger Mod), and then displays them randomly in the search box.

A simple matter of replace the following codes in the js:

Code:
var text = new Array()

with the following codes:

Code:
var text = new Array ( <!--#exec cgi="/cgi-bin/random.cgi"--> )

Works great!

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
just realized that the subjec said "Top Search"..

oh well.. i thought he wanted "random" queries based on the keyword file so that is why the ssi thingy was there..

Code:
<script language="JavaScript">
<!--
var text = new Array(<!--#exec cgi="random.cgi"-->)
var i = 0;
function scroll() {
if (text.length > -1) {
if (document.search) {
if (i == text.length) i = 0;
document.search.query.value = text[i++];
}
setTimeout ("scroll()", 3500);
}
}
// -->
</script>

is code that would work better than Ask Jeeves.. hehe.. and it goes forwards.. not backwards.. Smile

the main thing about it is that it returns random queries.. the original ssi perl code basically took random lines scattered around the keyword file.. but i realized that if there were only 3 lines and they wanted 5 lines.. the while loop will keep going without stopping because lines 1, 2, and 3 would be all taken. and it doesn't stop unless it gets a number that isn't taken..

so the second ssi perl code basically doesn't do that.. instead.. it does what i beleive Ask Jeeves does.. opens the file and selects a random line.. then starting from that line it starts getting the next X lines after it and if it goes past the total starts at the beginning.. so basically it's stupid in the sense that it will keep LOOPING over and over if you have like 2 queries.. and you select 20 to show up..

jerry
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Widgetz,

While the Thread began as a way to get Top Searches...it has nicely evolved into the development of a cool Mod. I like the way it works. It basically takes random top searches from the keywords.txt file, which was my goal.

Thanks for your help.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
eliot.. i don't think you should do that. even if you have many.. if by coincidence the script gets the random number 5 more than once. it will slow down the script.

since you are only showing 5 queries right now.. it's not much of a slow down.. but just say.. you go through the for loop.. then you get the random number 5.. it gets line 5 hen continues to the second.. you get 5 again.. it makes a loop and gets another number.. if it gets 5 again.. loop.. and it keeps going.. until not a 5.. just remember.. this happens 4 times total for each load.. it gets worse if the second one ends up with a 2 or something.. then the next loop might get both 5 and 2..

it's not really a good idea to go with somethig that *MIGHT* crash.. really..

jerry
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Widgetz,

I am confused. Are you saying that I need to use your latter codes for the random.cgi to prevent the script from crashing in the future? The script seems to be humming along just fine.

Please advise.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
ok.. even though the odds of it happening is like 1 in a million.. it still has a chance to happen Wink

yes.. i am saying use the newer code..

jerry
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Thanks, Widgetz.

Appreciate the continued guidance and support.

BTW: The new Perl codes for the random.cgi file only prints one keyword. So, I am going to use my original random.cgi because it seems to work fine for now.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------




[This message has been edited by Eliot (edited November 06, 1999).]
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
this is the quickest random.cgi i could figure out..

Code:
#!/usr/local/bin/perl

$display = 20;

open (FILE, "jsrandomq.txt");
@file = <FILE>;
close FILE;
$start = int rand $#file;

if ($start+$display > $#file) {
@queries = @file[$start .. $#file];
push (@queries, @file[0 .. $display-($#file-$start)-2]);
}
else { @queries = @file[$start .. $start+$display-1]; }

foreach (@queries) { chomp; $output .= qq~"$_",~; }
chop $output;
print "Content-type: text/plain\n\n";
print $output;

it's a little longer.. but it only has one loop and less calculating..

jerry
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Okay...Jerry these latter codes seem to work even nicer, however, I am having a problem splitting the count number out of the keywords displayed.

It know displays the count number like it was doing a little earlier today:

keyword|12

I used the following codes to split the count number, but it is not working:

Code:
$file = (split(/\|/, $file[$start]))[0];

Any ideas???

Thanks.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Code:
foreach (@queries) { chomp; $output .= qq~"$_",~; }

change to

Code:
foreach (@queries) { chomp; $output .= qq~"~ . (split(/\|/, $_))[0] . qq~",~; }

jerry
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Thanks, Jerry! It worked like a charm.

I would recommend making this Mod available in the Resource Center. If you want help with writing some instructions, let me know.

But this Mod is mostly yours and Bmxer.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
i'd rather not have another mod posted in the resource center until it is cleaned out of the mods that don't work Wink

or at least has some sub categories so we can file the mods.. hehe

Code:
<script language="JavaScript">
<!--
var text = new Array(<!--#exec cgi="random.cgi"-->)
var i = 0;
function scroll() {
if (text.length > -1) {
if (document.search) {
document.search.query.value = text[i++];
if (i == text.length) i = 0;
}
}
setTimeout ("scroll()", 3500);
}
// -->
</script>

is the javascript i recommend using.. it doesn't have any excess code and one thing is flip flopped so that it won't take any time for the query text to change.. (it's shorter too Wink)

jerry
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Great...Codes look a lot cleaner. I will use them and see what happens.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
At first i thought it was bad javascript but its Hypermart that is annoying me with an ssi problem. I've never gotten it to run on their server. Here is the vartext line
var text = new Array([an error occurred while processing this directive]). Sucks.
-----------------
Ok, i found that on hypermart for files without content-type calls, use exec cmd, but now it prints undefined in the search box
and var text = new Array(), its empty. So its a problem with random.cgi.

[This message has been edited by Bmxer (edited November 06, 1999).]
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Jerry,

The latest Javascript codes you gave do NOT work. I got three too many argument errors and then my browser crashed.

So, I am going to stick with the original codes.

Thanks.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Ok, i finally got it up on mine. I really gotta clear out my database and let people put real stuff in.
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
my example works on both ie and netscape so obviously your doing something wrong..

bmxer.. try calling the random.cgi from the browser and see if it returns anything

jerry
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Jerry (Widgetz),

It now works...That was weird. I recopied the latest JS codes and placed them back into my home.html template. Then I re-built my directory.

Voila...works just fine.

Thanks.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------




[This message has been edited by Eliot (edited November 06, 1999).]
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Widgetz,
It asked me to download it, but, i opened it and there were the keywords in notepad. Then i did it again and they were different. Do you think there is something that can look at the keyword|12 12 part and see if its the highest. I'd like to know if you could make a top 10 or whatever using the numbers next to them.
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Bmxer,

Good idea. Although it may be best to look at the logging routine in search.cgi and see if the keywords and hit count can be sorted in a better way to accomodate this goal.

Although, may be Widgetz knows of a way to add some codes to this random text cgi file that will do the same thing.

BTW, Widgetz, I tested the new cgi codes and I noticed that it tended to "crash" with too many arguments in the JS, so,I reduced the $display variable to 5 and it seems to be more stable.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
well.. you'd just get all of them.. and then sort it by the hits..

so instead of @file = <FILE>;

you'd put like

Code:
while (<FILE> ) {
chomp;
@data = split(/\|/, $_);
push (@file, @data);
}

then the rest would be like

Code:
my ($num) = ($#file+1) / 2;

for ($i = 0; $i < $num; $i++) {
$sortby{$i} = $unsorted[1 + ($i * 2)];
}

foreach $hit (sort {
$sortby{$b} <=> $sortby{$a};
} (keys %sortby)) {
$first = ($hit * 1) + $hit;
$last = ($hit * 1) + 1 + $hit;
push (@queries, @file[$first .. $last]);
}

for ($i = 0; $i < 10; $i++) {
$output .= qq~"~ . $queries[$i*2] . qq~",~;
}

however.. i'm not saying that will work on my first try Wink

jerry
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Hello guys,

All I am getting when I execute random.cgi is this:

"","","","",""

I have two types of log fiels.

One has just the keywords - like this:
barebones
free tgp
las hijas del amapolo
%22toronto pharmacists%22
terminal oils limited

And the other like this:
accounting|24|940106975

which is by using the keyword mod from the resource center.

Thanks for your help.
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
you set the correct path to the file?

jerry
> > > >