Matt's Simple Search - a new angle?

Discussion in 'Perl Misc' started by Toby Newman, Jul 8, 2003.

  1. Toby Newman

    Toby Newman Guest

    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).
     
    Toby Newman, Jul 8, 2003
    #1
    1. Advertising

  2. Toby Newman

    John Strauss Guest

    On 8 Jul 2003 04:42:06 -0700
    (Toby Newman) wrote:
    >
    > 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
     
    John Strauss, Jul 8, 2003
    #2
    1. Advertising

  3. Toby Newman

    Cat Guest

    Toby Newman wrote:
    >
    > 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 ?
     
    Cat, Jul 8, 2003
    #3
  4. Toby Newman

    Toby Newman Guest

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


    > Toby Newman wrote:
    > >
    > > 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 ?



    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
     
    Toby Newman, Jul 8, 2003
    #4

  5. >>Toby Newman wrote:


    [about wanting to use Matts search script]

    >>>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!


    [snip parameters used]

    >>>
    >>>I get no results.
    >>>
    >>>Why could this be?
    >>>


    > From: "Cat" <>
    >>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 ?



    > 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 Andrews, Jul 9, 2003
    #5
  6. Toby Newman

    Cat Guest

    Toby Newman wrote:
    >
    > 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.
     
    Cat, Jul 9, 2003
    #6
  7. Toby Newman

    Toby Newman Guest

    Simon Andrews <> wrote in message news:<>...
    > >>Toby Newman wrote:

    >
    > [about wanting to use Matts search script]
    >
    > >>>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!

    >
    > [snip parameters used]
    >
    > >>>
    > >>>I get no results.
    > >>>
    > >>>Why could this be?
    > >>>

    >
    > From: "Cat" <>
    > >>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 ?

    >
    >
    > > 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
     
    Toby Newman, Jul 10, 2003
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. LH

    Matt's Form Mail.pl

    LH, Jun 13, 2006, in forum: HTML
    Replies:
    2
    Views:
    553
  2. Replies:
    2
    Views:
    1,112
    Stan McCann
    Jul 13, 2006
  3. Butch
    Replies:
    5
    Views:
    191
    Trent Curry
    Feb 18, 2004
  4. Matt Garrish

    Matt Garrish -> Troll

    Matt Garrish, Mar 3, 2006, in forum: Perl Misc
    Replies:
    5
    Views:
    109
    robic0
    Mar 5, 2006
  5. Replies:
    3
    Views:
    138
    Dr John Stockton
    Apr 4, 2006
Loading...

Share This Page