Date: Wed, 18 Jan 2006 11:47:43 +0100 From: Roland Romero <rolandromero@gmail.com> To: freebsd-questions@FreeBSD.org Subject: urgent, agir vite Message-ID: <607306ab0601180247t132f3cc6j@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
on dirait qu'il y a un bug l=E0 : http://www.fr.freebsd.org/cgi/search.cgi?max=3D25&source=3Dwww&words=3DTurb= oGX&submit=3DRechercher =E7a affiche tout le code perl ! de rien. Rol, fan de frib=E9hesd=E9 #!/usr/bin/perl -T # # mail-archive.pl -- a CGI interface to a wais indexed maling list archiv= e. # # Origin: # Tony Sanders <sanders@bsdi.com>, Nov 1993 # # Hacked beyond recognition by: # John Fieber <jfieber@cs.smith.edu>, Nov 1994 # # Format the mail messages a little nicer. # Add code to check database status before searching. # John Fieber <jfieber@indiana.edu>, Aug 1996 # # Disclaimer: # This is pretty ugly in places. # # $FreeBSD: www/en/cgi/search.cgi,v 1.26 2005/10/24 20:59:01 wosch Exp $ $server_root =3D '/usr/local/www'; $waisq =3D "/usr/local/www/bin/waisq"; $sourcepath =3D "$server_root/db/index"; $hints =3D "/search/searchhints.html"; $searchpage =3D '/search/search.html'; $myurl =3D $ENV{'SCRIPT_NAME'}; require "open2.pl"; require "./cgi-lib.pl"; require "./cgi-style.pl"; @months =3D ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); sub escape($) { $_ =3D $_[0]; s/&/&/g; s/</</g; s/>/>/g; $_; } sub do_wais { &ReadParse; @FORM_words =3D split(/ /, escape($in{"words"})); @FORM_source =3D split(/\0/, escape($in{"source"})); $FORM_max =3D $in{"max"}; $FORM_docnum =3D $in{"docnum"}; $FORM_index =3D $in{"index"}; if ($FORM_index =3D~ /^re[sc]ent$/) { =09$sourcepath =3D "$server_root/db/index-recent"; } if ($#FORM_words < 0) { =09print &html_header("Mail Archive Search") . =09 "<p>No search term given."; =09print "<p>\nPlease return to the " . =09 "search page and fill out the 'Search for' field!\n"; =09print &html_footer; =09exit 0; } @AVAIL_source =3D &checksource(@FORM_source); if ($#FORM_source !=3D $#AVAIL_source) { =09$j =3D 0; =09$k =3D 0; =09foreach $i (0 .. $#FORM_source) { =09 if ($FORM_source[$i] ne $AVAIL_source[$j]) { =09 =09$badsource[$k] =3D $FORM_source[$i]; =09 =09$k++; =09 } else { =09 =09$j++; =09 } =09} =09$badsource =3D join("</em>, <em>", @badsource); =09$badsource =3D~ s/,([^,]*)$/ and $1/; =09if ($#FORM_source - $#AVAIL_source > 1) { =09 $availmsg =3D "<p>[The <em>$badsource</em> archives are currently unavailable.]</p>"; =09} else { =09 $availmsg =3D "<p>[The <em>$badsource</em> archive is currently unavailable.]</p>"; =09} } if ($#AVAIL_source < 0) { =09$i =3D join("</em>, <em>", @FORM_source); =09$i =3D~ s/,([^,]*)$/ and $1/; =09print &html_header("Mail Archive Search") . =09 "<p>None of the archives you requested (<em>$i</em>) are " . =09=09" available at this time.</p>\n"; =09print "<p>Please try again later, or return to the " . =09 "search page and select a different archive.</p>\n"; =09print &html_footer; =09exit 0; } # Now we formulate the question to ask the server foreach $i (@AVAIL_source) { =09$w_sources .=3D "(:source-id\n :filename \"$i.src\"\n ) = "; } $w_question =3D "\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) { =09$src =3D join("</em>, <em>", @AVAIL_source); =09$src =3D~ s/,([^,]*)$/ and $1/; =09print "<p>The archives <em>$src</em> contain "; } else { =09print "The archive <em>@AVAIL_source</em> contains "; } print " the following items relevant to \`@FORM_words\':\n"; print "<ol>\n"; &open2(WAISOUT, WAISIN, $waisq, "-g"); print WAISIN $w_question; local(@mylist) =3D (); local($hits, $score, $headline, $lines, $bytes, $docid, $date, $file); while (<WAISOUT>) { =09/:original-local-id.*#\(\s+([^\)]*)/ && =09 ($docid =3D pack("C*", split(/\s+/, $1)), =09 $docid =3D~ s/\s+/+/g); =09/:score\s+(\d+)/ && ($score =3D $1); =09/:filename "(.*)"/ && ($file =3D $1); =09/:number-of-lines\s+(\d+)/ && ($lines =3D $1); =09/:number-of-bytes\s+(\d+)/ && ($bytes =3D $1); =09/:headline "(.*)"/ && ($headline =3D $1, =09=09=09 $headline =3D~ s/[Rr]e://); # XXX =09/:date "(\d+)"/ && $docid !~ /\.src$/ && ($date =3D $1, $hits++, =09=09=09 push(@mylist, join("\t", $date, $headline, $docid, =09=09=09=09=09 $bytes, $lines, $file, $score, $hits))); } if ($in{'sort'} eq "date") { =09foreach (reverse sort {$a <=3D> $b} @mylist) { =09 ($date, $headline, $docid, $bytes, $lines, =09 $file, $score, $hits) =3D split("\t"); =09 &docdone; =09} } elsif ($in{'sort'} eq "subject") { =09local(@a, @c, $b, $d); =09foreach (@mylist) { =09 @a =3D split("\t"); =09 $b =3D $a[0]; =09 # swap date and subject =09 if ($a[1] =3D~ /(^[^:]+)(Re:.*)/) { =09=09$a[0] =3D "$2\t$1"; =09 } else { =09=09$a[0] =3D "$a[1]\t."; =09 } =09 $a[1] =3D $b; =09 push(@c, join("\t", @a)); =09} =09local($subject, $author); =09foreach (sort {$a cmp $b} @c) { =09 ($subject, $author, $date, $docid, $bytes, =09 $lines, $file, $score, $hits) =3D split("\t"); =09 $headline =3D $author . $subject; =09 &docdone; =09} } elsif ($in{'sort'} eq "author") { =09local(@a, @c, $b); =09foreach (@mylist) { =09 @a =3D split("\t"); =09 # swap date and subject =09 $b =3D $a[0]; $a[0] =3D $a[1]; $a[1] =3D $b; =09 push(@c, join("\t", @a)); =09} =09foreach (sort {$a cmp $b} @c) { =09 ($headline, $date, $docid, $bytes, =09 $lines, $file, $score, $hits) =3D split("\t"); =09 &docdone; =09} } else { =09foreach (@mylist) { =09 ($date, $headline, $docid, $bytes, =09 $lines, $file, $score, $hits) =3D split("\t"); =09 &docdone; =09} } #print qq[in: $in{'sort'}\n]; print "</ol>\n"; print "<p>Didn't get what you expected? "; print "<a href=3D\"$hints\">Look here for searching hints</a>.</p>"; print qq{<p><a href=3D"$searchpage">Return to the search page</a></p>\n= }; if ($hits =3D=3D 0) { =09print "Nothing found.\n"; } print &html_footer; close(WAISOUT); close(WAISIN); }=09=09=09 # 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) =3D @_; $j =3D 0; foreach $i (@sources) { =09if (stat("$sourcepath/$i.src")) { =09 if (!stat("$sourcepath/$i.update.lock")) { =09 =09$goodsources[$j] =3D $i; =09 =09$j++; =09 } =09} } return(@goodsources); } sub docdone { $file =3D~ s/\.src$//; if ($headline =3D~ /Search produced no result/) { =09print "<p>The archive <em>$file</em> contains no relevant documents.</p>= " } else { $headline =3D escape($headline); $headline =3D~ s/\\"/\"/g; if ($file eq "www" || $file =3D~ /^www-[a-z][a-z]$/ || $file eq 'pkgdescr' || $file eq "manpages") { print "<li><a href=3D\"$headline\">$headline</a>\n"; } else { print "<li><a href=3D\"getmsg.cgi?fetch=3D${docid}\">$headline<= /a>\n"; } print "<br/>"; #=09print "<input type=3D\"checkbox\" name=3D\"rf\" value=3D\"$docnum\"/>"; =09print "Score: <em>$score</em>; "; =09$_ =3D $date; =09/(...?)(..)(..)/ && ($yr =3D $1 + 1900, $mo =3D $months[$2 - 1], $dy= =3D $3); =09print "Lines: <em>$lines</em>; "; =09print "${dy}-${mo}-${yr}; "; =09print "Archive: <em>$file</em>"; =09print "<p></p></li>\n"; } $score =3D $headline =3D $lines =3D $bytes =3D $docid =3D $date =3D $fi= le =3D ''; $yr =3D $mo =3D $dy =3D ''; } $| =3D 1; open (STDERR,"> /dev/null"); #open (STDERR,">> /tmp/search"); eval '&do_wais';
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?607306ab0601180247t132f3cc6j>