From owner-freebsd-doc@FreeBSD.ORG Wed May 17 19:31:29 2006 Return-Path: X-Original-To: freebsd-doc@FreeBSD.ORG Delivered-To: freebsd-doc@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BBDC516A68E for ; Wed, 17 May 2006 19:31:29 +0000 (UTC) (envelope-from pyros@bozs.org) Received: from random.bozs.org (bozs.org [82.231.140.27]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0D49C43D46 for ; Wed, 17 May 2006 19:31:26 +0000 (GMT) (envelope-from pyros@bozs.org) Received: from localhost (localhost [127.0.0.1]) by random.bozs.org (Postfix) with ESMTP id C7A47E9347 for ; Wed, 17 May 2006 21:31:24 +0200 (CEST) Received: from random.bozs.org ([127.0.0.1]) by localhost (random.bozs.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 15169-10 for ; Wed, 17 May 2006 21:31:19 +0200 (CEST) Received: from [192.168.1.4] (unknown [192.168.1.4]) by random.bozs.org (Postfix) with ESMTP id 135C8E9346 for ; Wed, 17 May 2006 21:31:18 +0200 (CEST) Message-ID: <446B7A0A.7090007@bozs.org> Date: Wed, 17 May 2006 21:31:22 +0200 From: Pyros User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) MIME-Version: 1.0 To: freebsd-doc@FreeBSD.ORG Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at random.bozs.org Cc: Subject: Recherche affiche le contenu du script X-BeenThere: freebsd-doc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Documentation project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 May 2006 19:31:29 -0000 Bonjour, A priori y a un pb d'interprétation du script perl de recherche :par ex : Bon courage... http://www.fr.freebsd.org/cgi/search.cgi?max=25&source=www&words=test&submit=Rechercher Affiche : #!/usr/bin/perl -T # # mail-archive.pl -- a CGI interface to a wais indexed maling list archive. # # Origin: # Tony Sanders , Nov 1993 # # Hacked beyond recognition by: # John Fieber , Nov 1994 # # Format the mail messages a little nicer. # Add code to check database status before searching. # John Fieber , Aug 1996 # # Disclaimer: # This is pretty ugly in places. # # $FreeBSD: www/en/cgi/search.cgi,v 1.27 2006/03/24 01:51:18 kuriyama Exp $ $server_root = '/usr/local/www'; $waisq = "/usr/local/www/bin/waisq"; $sourcepath = "$server_root/db/index"; $hints = "/search/searchhints.html"; $searchpage = '/search/search.html'; $myurl = $ENV{'SCRIPT_NAME'}; $ENV{PATH} = "/bin:/usr/bin:/usr/local/bin"; require "open2.pl"; require "./cgi-lib.pl"; require "./cgi-style.pl"; @months = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); sub escape($) { $_ = $_[0]; s/&/&/g; s//>/g; $_; } sub do_wais { &ReadParse; @FORM_words = map { s|"||g; $_ } split(/ /, escape($in{"words"})); @FORM_source = split(/\0/, escape($in{"source"})); ($FORM_max) = $in{"max"} =~ m|^(\d+)$|; $FORM_docnum = $in{"docnum"}; $FORM_index = $in{"index"}; if ($FORM_index =~ /^re[sc]ent$/) { $sourcepath = "$server_root/db/index-recent"; } if ($#FORM_words < 0) { print &html_header("Mail Archive Search") . "

No search term given."; print "

\nPlease return to the " . "search page and fill out the 'Search for' field!\n"; print &html_footer; exit 0; } @AVAIL_source = &checksource(@FORM_source); if ($#FORM_source != $#AVAIL_source) { $j = 0; $k = 0; foreach $i (0 .. $#FORM_source) { if ($FORM_source[$i] ne $AVAIL_source[$j]) { $badsource[$k] = $FORM_source[$i]; $k++; } else { $j++; } } $badsource = join(", ", @badsource); $badsource =~ s/,([^,]*)$/ and $1/; if ($#FORM_source - $#AVAIL_source > 1) { $availmsg = "

[The $badsource archives are currently unavailable.]

"; } else { $availmsg = "

[The $badsource archive is currently unavailable.]

"; } } if ($#AVAIL_source < 0) { $i = join("
, ", @FORM_source); $i =~ s/,([^,]*)$/ and $1/; print &html_header("Mail Archive Search") . "

None of the archives you requested ($i) are " . " available at this time.

\n"; print "

Please try again later, or return to the " . "search page and select a different archive.

\n"; print &html_footer; exit 0; } # Now we formulate the question to ask the server foreach $i (@AVAIL_source) { $w_sources .= "(:source-id\n :filename \"$i.src\"\n ) "; } $w_question = "\n (:question :version 2 :seed-words \"@FORM_words\" :relevant-documents ( ) :sourcepath \"$sourcepath/:\" :sources ( $w_sources ) :maximum-results $FORM_max :result-documents ( ) )\n"; # # First case, no document number so this is a regular search # print &html_header("Search Results"); print $availmsg; if ($#AVAIL_source > 0) { $src = join("
, ", @AVAIL_source); $src =~ s/,([^,]*)$/ and $1/; print "

The archives $src contain "; } else { print "The archive @AVAIL_source contains "; } print " the following items relevant to \`@FORM_words\':\n"; print "

    \n"; &open2(WAISOUT, WAISIN, $waisq, "-g"); print WAISIN $w_question; local(@mylist) = (); local($hits, $score, $headline, $lines, $bytes, $docid, $date, $file); while () { /:original-local-id.*#\(\s+([^\)]*)/ && ($docid = pack("C*", split(/\s+/, $1)), $docid =~ s/\s+/+/g); /:score\s+(\d+)/ && ($score = $1); /:filename "(.*)"/ && ($file = $1); /:number-of-lines\s+(\d+)/ && ($lines = $1); /:number-of-bytes\s+(\d+)/ && ($bytes = $1); /:headline "(.*)"/ && ($headline = $1, $headline =~ s/[Rr]e://); # XXX /:date "(\d+)"/ && $docid !~ /\.src$/ && ($date = $1, $hits++, push(@mylist, join("\t", $date, $headline, $docid, $bytes, $lines, $file, $score, $hits))); } if ($in{'sort'} eq "date") { foreach (reverse sort {$a <=> $b} @mylist) { ($date, $headline, $docid, $bytes, $lines, $file, $score, $hits) = split("\t"); &docdone; } } elsif ($in{'sort'} eq "subject") { local(@a, @c, $b, $d); foreach (@mylist) { @a = split("\t"); $b = $a[0]; # swap date and subject if ($a[1] =~ /(^[^:]+)(Re:.*)/) { $a[0] = "$2\t$1"; } else { $a[0] = "$a[1]\t."; } $a[1] = $b; push(@c, join("\t", @a)); } local($subject, $author); foreach (sort {$a cmp $b} @c) { ($subject, $author, $date, $docid, $bytes, $lines, $file, $score, $hits) = split("\t"); $headline = $author . $subject; &docdone; } } elsif ($in{'sort'} eq "author") { local(@a, @c, $b); foreach (@mylist) { @a = split("\t"); # swap date and subject $b = $a[0]; $a[0] = $a[1]; $a[1] = $b; push(@c, join("\t", @a)); } foreach (sort {$a cmp $b} @c) { ($headline, $date, $docid, $bytes, $lines, $file, $score, $hits) = split("\t"); &docdone; } } else { foreach (@mylist) { ($date, $headline, $docid, $bytes, $lines, $file, $score, $hits) = split("\t"); &docdone; } } #print qq[in: $in{'sort'}\n]; print "
\n"; print "

Didn't get what you expected? "; print "Look here for searching hints.

"; print qq{

Return to the search page

\n}; if ($hits == 0) { print "Nothing found.\n"; } print &html_footer; close(WAISOUT); close(WAISIN); } # Given an array of sources (sans .src extension), this routine # checks to see if they actually exist, and if they do, if they # are currently available (ie, not being updated). It returns # an array of sources that are actually available. sub checksource { local (@sources) = @_; $j = 0; foreach $i (@sources) { ($i) = $i =~ m|^([-a-z0-9]*)|; if (stat("$sourcepath/$i.src")) { if (!stat("$sourcepath/$i.update.lock")) { $goodsources[$j] = $i; $j++; } } } return(@goodsources); } sub docdone { $file =~ s/\.src$//; if ($headline =~ /Search produced no result/) { print "

The archive $file contains no relevant documents.

" } else { $headline = escape($headline); $headline =~ s/\\"/\"/g; if ($file eq "www" || $file =~ /^www-[a-z][a-z]$/ || $file eq 'pkgdescr' || $file eq "manpages") { print "
  • $headline\n"; } else { print "
  • $headline\n"; } print "
    "; # print ""; print "Score: $score; "; $_ = $date; /(...?)(..)(..)/ && ($yr = $1 + 1900, $mo = $months[$2 - 1], $dy = $3); print "Lines: $lines; "; print "${dy}-${mo}-${yr}; "; print "Archive: $file"; print "

  • \n"; } $score = $headline = $lines = $bytes = $docid = $date = $file = ''; $yr = $mo = $dy = ''; } $| = 1; open (STDERR,"> /dev/null"); #open (STDERR,">> /tmp/search"); eval '&do_wais'; if ($@) { warn "eval failed: $@"; }