#!/usr/local/bin/perl # CGI for the dictionary lookup # Stanislav Sinyagin http://sinyagin.pp.ru/ # Version: 25-FEB-2000 # Uncomment this if you use Russian Apache (http://apache.lexa.ru) # Then the output is in KOI8 only. # $russianApache = 1; $|=1; require "./read.dict.pl"; require "./cgi-lib.pl"; $ENV{'PATH'} .= ":/usr/local/bin"; ############################################################### # Parse the CGI input ############################################################### &ReadParse(*input); local $english = $input{'English'}; local $encoding = $input{'Encoding'}; $encoding = "1251" unless $encoding; local $selected{$encoding} = 'SELECTED'; $myURL = &MyURL(); ############################################################### # Print the head of the document and the form ############################################################### if( not $russianApache ) { %charsetName = ("koi8" => "KOI8-R", "1251" => "WINDOWS-1251", "866" => "IBM866"); printf("Content-type: text/html; charset=%s\n\n", $charsetName{$encoding}); } else { printf("Content-type: text/html\n\n"); $encoding = "koi8"; } print <English-Russian Dictionary

English-Russian Dictionary

EOT open(MOTD, "motd.html"); print $_ while ; close MOTD; print < Enter English words (at least 4 first letters):

EOT if( not $russianApache ) { print < EOT } print "\n"; if( $encoding eq "866" ) { open( SAVEOUT, ">&STDOUT" ); open( STDOUT, "| ./koi8to866" ); } elsif( $encoding eq "1251" ) { open( SAVEOUT, ">&STDOUT" ); open( STDOUT, "| ./koi8to1251" ); } elsif( $encoding ne "koi8" ) { printf("Incorrect encoding: %s\n", $encoding); exit; } $english =~ s/\W+/ /g; # remove all non-word characters $english =~ s/^\s+//; # remove the leading space foreach $word ( split( /\s+/, $english ) ) { $found = 0; print "

Search results: $word

\n
\n"; my $handle = &OpenDictionaryFileHandle( $word ); local @array; while( &ReadDictionaryEntry( $handle, *array ) ) { if( $array[0] =~ s/(^|\s)($word)/$1\$2\<\/B\>/i ) { $found = 1; print "
", $array[0]; foreach $str ( split( '\n', $array[1] ) ) { print "
", $str; } } } close( $handle ); if( !$found ) { print "Nothing found: $word
"; push @cgiReport, "Word not found: $word"; } print "
\n"; } print <<'EOT'
Copyright (C) 2000, Stanislav Sinyagin EOT