Matt's Simple Search - a new angle?

T

Toby Newman

Hi,

I'm using Matt's Simple Search script, and have set it up to work
correctly. It searches my '/home/public_html/' directory and returns
results. Great!

Problem:

I'd like it to search through *.wiki files (they're just text files)
in '/home/wiki/', i.e. not inside my public_html folder.

It doesn't seem to work!

i.e It works if I use the following variables:

$basedir = '/home/public_html/';
$baseurl = 'http://www.asktoby.com/';
@files = ('*.html','*.php');
$title = "TITLE";
$title_url = 'http://www.asktoby.com/';
$search_url = 'http://www.asktoby.com/search.html';

But if I use these variables:

$basedir = '/home/wiki/';
$baseurl = 'http://www.asktoby.com/';
@files = ('*.wiki');
$title = "TITLE";
$title_url = 'http://www.asktoby.com/';
$search_url = 'http://www.asktoby.com/search.html';

I get no results.

Why could this be?

Thanks for any insight you can give.
Toby

(ps I am working on my ISP's server, not locally).
 
J

John Strauss

On 8 Jul 2003 04:42:06 -0700
Hi,

I'm using Matt's Simple Search script, and have set it up to work
correctly. It searches my '/home/public_html/' directory and returns
results. Great!

Problem:

I'd like it to search through *.wiki files (they're just text files)
in '/home/wiki/', i.e. not inside my public_html folder.

It doesn't seem to work!

i.e It works if I use the following variables:

$basedir = '/home/public_html/';
$baseurl = 'http://www.asktoby.com/';
@files = ('*.html','*.php');
$title = "TITLE";
$title_url = 'http://www.asktoby.com/';
$search_url = 'http://www.asktoby.com/search.html';

But if I use these variables:

$basedir = '/home/wiki/';
$baseurl = 'http://www.asktoby.com/';
@files = ('*.wiki');
$title = "TITLE";
$title_url = 'http://www.asktoby.com/';
$search_url = 'http://www.asktoby.com/search.html';

I get no results.

Why could this be?

Thanks for any insight you can give.
Toby

(ps I am working on my ISP's server, not locally).



have you asked matt?



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drop the .thetenant to get me via mail
 
C

Cat

Toby said:
I'd like it to search through *.wiki files (they're just text files)
in '/home/wiki/', i.e. not inside my public_html folder.

It doesn't seem to work!

i.e It works if I use the following variables:

$basedir = '/home/public_html/';
$baseurl = 'http://www.asktoby.com/';
@files = ('*.html','*.php');
$title = "TITLE";
$title_url = 'http://www.asktoby.com/';
$search_url = 'http://www.asktoby.com/search.html';

But if I use these variables:

$basedir = '/home/wiki/';
$baseurl = 'http://www.asktoby.com/';
@files = ('*.wiki');
$title = "TITLE";
$title_url = 'http://www.asktoby.com/';
$search_url = 'http://www.asktoby.com/search.html';

I get no results.

Why could this be?

Do you have permission to view the contents of /home/wiki ?
Do you get any results with ls /home/wiki/*.wiki ?
Are you executing the script from a web page ?
 
T

Toby Newman

----- Original Message -----
From: "Cat" <[email protected]>
Newsgroups: comp.lang.perl.misc
Sent: Tuesday, July 08, 2003 1:08 PM
Subject: Re: Matt's Simple Search - a new angle?

Do you have permission to view the contents of /home/wiki ?
Do you get any results with ls /home/wiki/*.wiki ?
Are you executing the script from a web page ?


Hi! Thank you for your response.

I have asked Matt but he does not reply! I am hoping someone in this
discussion group will have a clue for me :)

The permissions of the /home/wiki/ folder are drwxrwxrwx, and the
permissions of the *.wiki files within are all -rw-r--r--. Unless I'm
mistaken, that means everyone has permission to read the files (i.e. all r's
and no -'s).

I am executing this script from a web page on my ISP's space. As such, I
don't know a way to enter commands like ls /home/wiki/*.wiki

I hope I have answered your questions correctly, Cat. Look forward to your
reply.

Toby
 
S

Simon Andrews

[about wanting to use Matts search script]

[snip parameters used]
Toby Newman wrote:

Hi! Thank you for your response.

I have asked Matt but he does not reply! I am hoping someone in this
discussion group will have a clue for me :)


Toby,

Just to explain a couple of the responses you've had to your original
post, and the general lack of specific help.

You're using a script from Matts script archive. Those scripts are
a continual source of problems here. They were written a long time
ago and have been shown to contain many bugs, and in some cases
potential sectrity holes. Where bugs have been pointed out to Matt
he has failed to provide updated versions of his scripts and
continued to distribute the old code. You are unlikely to get help
fixing Matts scripts as the regulars here have been over this ground
too many times :)

On a positive note, a while back the London Perl Mongers group
decided to rewrite Matts scripts from scratch, providing their
own alternatives which were a drop in replacement for the originals
but which fixed the bugs and were more secure. Even Matts site
now acknowedges that people should be using these versions of the
scripts.

You can get a new version of the search program from:

http://sourceforge.net/projects/nms-cgi/

You may find that this version will fix the problem you're having
or it may not, but you're much more likely to get help here if
you're using the NMS version of the script as a least there should
be no major bugs in it. You may find that even if it doesn't work
it may give more informative error messages than the original.

As an aside, I'm not familiar with the layout of Wiki documents, but
it's possible that the search script is looking for certain HTML tags
to define which parts of each document to search. If these aren't
present in the Wiki pages then the script may fail because of that.

Are you able to check your server error logs when the script runs?
Are there any messages reported?

Hope this gets you a bit further.

Cheers

Simon.
 
C

Cat

Toby said:
The permissions of the /home/wiki/ folder are drwxrwxrwx, and the
permissions of the *.wiki files within are all -rw-r--r--. Unless I'm
mistaken, that means everyone has permission to read the files (i.e. all r's
and no -'s).

I am executing this script from a web page on my ISP's space. As such, I
don't know a way to enter commands like ls /home/wiki/*.wiki

I hope I have answered your questions correctly, Cat. Look forward to your
reply.

Look at your search.pl script and scroll down to the first function;

sub parse_form {

# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
^^^^^^^^^^^^^^^^^^^^^^

# Split the name-value pairs
@pairs = split(/&/, $buffer);

foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);

$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

$FORM{$name} = $value;
}
}


change the read line to something like;
read(STDIN, $buffer, 40);

because $ENV{'CONTENT_LENGTH'} is expecting an environmental variable that
isn't defined anywhere.
 
T

Toby Newman

Simon Andrews said:
[about wanting to use Matts search script]

[snip parameters used]

From: "Cat said:
Toby Newman wrote:

Hi! Thank you for your response.

I have asked Matt but he does not reply! I am hoping someone in this
discussion group will have a clue for me :)


Toby,

Just to explain a couple of the responses you've had to your original
post, and the general lack of specific help.

You're using a script from Matts script archive. Those scripts are
a continual source of problems here. They were written a long time
ago and have been shown to contain many bugs, and in some cases
potential sectrity holes. Where bugs have been pointed out to Matt
he has failed to provide updated versions of his scripts and
continued to distribute the old code. You are unlikely to get help
fixing Matts scripts as the regulars here have been over this ground
too many times :)

On a positive note, a while back the London Perl Mongers group
decided to rewrite Matts scripts from scratch, providing their
own alternatives which were a drop in replacement for the originals
but which fixed the bugs and were more secure. Even Matts site
now acknowedges that people should be using these versions of the
scripts.

You can get a new version of the search program from:

http://sourceforge.net/projects/nms-cgi/

You may find that this version will fix the problem you're having
or it may not, but you're much more likely to get help here if
you're using the NMS version of the script as a least there should
be no major bugs in it. You may find that even if it doesn't work
it may give more informative error messages than the original.

As an aside, I'm not familiar with the layout of Wiki documents, but
it's possible that the search script is looking for certain HTML tags
to define which parts of each document to search. If these aren't
present in the Wiki pages then the script may fail because of that.

Are you able to check your server error logs when the script runs?
Are there any messages reported?

Hope this gets you a bit further.

Cheers

Simon.

Simon, thankyou for your reasoned and helpful response. I'd like to
apologise to the group for picking the MSA scab and making it sore!
Maybe I can redeem myself with the below :)

I switched to the NMS script and after a litte tweaking I got it
working perfectly. I also made some changes to the script so that it
doesn't return file extensions nor the / slash between the $baseurl
and the $paths.

For example, this may be helpful for working with php pages such ask
where $baseurl is:

http://www.blah.com/page.php?action=

and $paths is:

view.wiki

The original script would return:
http://www.blah.com/page.php?action=/view.wiki
but now will return
http://www.blah.com/page.php?action=view

The changes I made were:

if (!$emulate_matts_code)
{
my @base = sort {$hits[$b] <=> $hits[$a]} (0 .. $#hits);
@titles = @titles[@base];
@paths = @paths[@base];

for my $i (0 .. $#hits)
{
print_result($baseurl, $paths[$i], $titles[$i])
if ($hits[$i] >= $hit_threshhold);

print "<a href=";#begin link
print ($baseurl);#output pages URL
$paths[$i] =~ s/\.wiki//gi;#stip extension from path
print ($paths[$i]);#output path
print ">link</a>";#close link

}
}



'tis all. Thanks for the help folks!
Toby Newman
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top