#!/usr/local/bin/perl # (C) Copyright 1997,98 Czo # Parts (C) A.Fenyo BEGIN { # Use the CGI::Carp module and import the carpout() function. # use CGI::Carp qw(carpout); # Send warnings and die messages to the browser. # carpout(STDOUT); } use CGI; use POSIX; # SCRIPT_NAME = /cgi-bin/test.cgi # SCRIPT_FILENAME = /users/largo2/webmastr/wwwroot/cgi-bin/printenv.cgi $ASIM_HEADER=`/bin/cat /users/largo2/webmastr/wwwroot/slash/ssi/asim_header.html`; $ASIM_FOOTER=`/bin/cat /users/largo2/webmastr/wwwroot/slash/ssi/asim_footer.html`; $SEARCH_HEADER=`/bin/cat /users/largo2/webmastr/wwwroot/slash/ssi/search_header.html`; $SEARCH_MIDDLE=`/bin/cat /users/largo2/webmastr/wwwroot/slash/ssi/search_middle.html`; $SEARCH_FOOTER=`/bin/cat /users/largo2/webmastr/wwwroot/slash/ssi/search_footer.html`; $lock = "/tmp/search.lock"; $log = "/users/largo2/webmastr/wwwroot/slash/cgi-bin/private/search.log"; print "Content-type: text/html\n\n"; #unlink("$lock"); $query = new CGI; $str = $query->param('searchstring'); # Czo 990607 : autorise . et _ $str =~ s/[^a-zA-Z0-9-_ \*\.]//g; $str =~ s/ -/ /g; $str =~ s/^-/ /; $grepstr=$str; $grepstr =~ tr/A-Z/a-z/; @words = split / +/, $grepstr; foreach $word (@words) { $word =~ s/ *//; next if (!$word); next if (($word eq 'or') || ($word eq 'and')); @allwords = (@allwords, $word); }; $scope = $query->param('ComboSearchList'); if ( $scope eq "Alliance Mailling Lists" ) { $scopefile = "/users/largo2/webmastr/wwwroot/slash/cgi-bin/alml.dat"; } elsif ( $scope eq "Alliance" ) { $scopefile = "/users/largo2/webmastr/wwwroot/slash/cgi-bin/alliance.dat"; } elsif ( $scope eq "Education" ) { $scopefile = "/users/largo2/webmastr/wwwroot/slash/cgi-bin/education.dat"; } elsif ( $scope eq "Mpc" ) { $scopefile = "/users/largo2/webmastr/wwwroot/slash/cgi-bin/mpc.dat"; } elsif ( $scope eq "Multimedia" ) { $scopefile = "/users/largo2/webmastr/wwwroot/slash/cgi-bin/multimedia.dat"; } elsif ( $scope eq "Publications" ) { $scopefile = "/users/largo2/webmastr/wwwroot/slash/cgi-bin/publications.dat"; } elsif ( $scope eq "Personal pages" ) { $scopefile = "/users/largo2/webmastr/wwwroot/slash/cgi-bin/users.dat"; } else { $scopefile = "/users/largo2/webmastr/wwwroot/slash/cgi-bin/allsite.dat"; } if (-e $lock) { print "$ASIM_HEADER\n$SEARCH_HEADER\n"; print ' '; print "$SEARCH_MIDDLE\n"; print 'Sorry, server was busy, please try again.'; print "\n"; print "$SEARCH_FOOTER\n$ASIM_FOOTER\n"; } else { print "$ASIM_HEADER\n$SEARCH_HEADER\n"; print ' '; print "$SEARCH_MIDDLE\n"; #system (date); #print system ( "/usr/local/home/czo/local/FreeBSD/bin/swish-e -f /usr/local/home/czo/public_html/cgi-bin/index.swish-e -w $str" ); #$RET = `/usr/local/home/czo/local/FreeBSD/bin/swish-e -c /usr/local/home/czo/public_html/cgi-bin/index.swish-e -w $str`; #print "
";

open RESULT, "/usr/local/bin/swish-e -m 40 -f $scopefile -w $str |";

$cpt = 0;
while () {
#    chop;
#print ;

    m/err: no results/ && do
    {
      $nmatch=0;
      print 'No match found in "'.$scope.'". ';
      print '';
     };

    m/^# Number of hits: (.*)/ && do 
    {
      $nmatch=$1;
      print ''.$1.' matches were found in "'.$scope.'". ';
      print '';
     };

    m/^#/ && next;

    
    m/^(.*) (.*) "(.*)" (.*)/ && (($res1, $res2, $res3, $res4) = ($1, $2, $3, $4)) && do
      {
         $cpt++;
         $tmp1 = $res1/10; $tmp1 =~ s/^(.*)\..*/\1/;
         $tmp = $res4/1024; $tmp =~ s/^(.*\..).*/\1/;

print '

'.$cpt.'. ['.$tmp1.'%] '.$res3.'
[URL: '.$res2.']
Page size '.$tmp.' Kb

' ; #Last modified 7-Oct-97 - # $file=$res2; # $file =~ s%http://www-asim.lip6.fr/%/users/largo2/webmastr/wwwroot/%; # # # print "

$file\n

"; # # #$FILE = `/asim/gnu/bin/lynxx -dump -reload -nolist $file`; # $FILE = `cat $file`; # # $FILE =~ s/
/ - /sg; # $FILE =~ s/


/ - /sg; # $FILE =~ s/
  • / - /sg; # $FILE =~ s/
    / - /sg; # $FILE =~ s/
    / - /sg; # $FILE =~ s/

    / - /sg; # $FILE =~ s/-( -)*/-/sg; # # $FILE =~ s/<.*?>/ /sg; # # foreach $word (@allwords) { # $FILEinsensitive = $FILE; # $FILEinsensitive =~ tr/A-Z/a-z/; # $wordinsensitive = $word; # $wordinsensitive =~ tr/A-Z/a-z/; # $fileindex = index $FILEinsensitive, $wordinsensitive; # next if ($fileindex == -1); # # $fileindex = 160 if ($fileindex < 160); # $grep = substr $FILE, $fileindex - 160, 320; # $grep =~ s/^[^ ]* //s; # $grep =~ s/ [^ ]*$//s; # # foreach $w (@allwords) { # $grep =~ s%($w)%\1%si; # }; # # print "... $grep ...

    \n"; # # last; # }; # # # # }; } ; close(RESULT); #print "$scopefile\n"; print "$SEARCH_FOOTER\n$ASIM_FOOTER\n"; # REMOTE_ADDR = 132.227.103.10 # HTTP_X_FORWARDED_FOR = 132.227.103.10 $CLIENT = $ENV{"HTTP_X_FORWARDED_FOR"}; if ( $CLIENT eq "" ) { $CLIENT = $ENV{"REMOTE_ADDR"}; } $TIME=strftime("%Y/%m/%d %H:%M:%S",localtime()); open(LOCK,">$lock") || warn "Can't open lock : $!"; close (LOCK); open(SORTIE, ">>$log") || die "Can't open log : $!"; print SORTIE "$TIME $CLIENT \"$scope\" \"$str\" $nmatch\n";; close (SORTIE); unlink("$lock") || warn "Can't delete lock : $!"; } exit 0 __END__