#!/usr/bin/perl # # RiSearch Pro # # web search engine, version 3.0.003 # (c) Sergej Tarasov, 2000-2002 # # Homepage: http://risearch.org/ # email: risearch@risearch.org # Last modified: 21.01.2003 use riconfig; use lib::common_lib; use lib::search_lib; use strict; $| = 1; print "Content-Type: text/html\n\n"; get_query(); if (scalar(@query) != 0) { get_results(); eval { ($search_time,undef,undef,undef) = times }; if ($@) { $search_time = $@ } } make_links(); read_template("templates/template.htm"); print print_template($templates{"header"}); if (scalar(@query) != 0) { if ($rescount>0) { print print_template($templates{"results_header"}); print_results(); print print_template($templates{"results_footer"}); } else { print print_template($templates{"no_results"}); } } else { print print_template($templates{"empty_query"}); } print print_template($templates{"footer"}); #=================================================================== sub get_query { my $ndquery; my $query; my $stpos; my $stype; my $sorting; my $sorting_order; my %zones; if($ENV{'REQUEST_METHOD'} eq 'GET') { $query=$ENV{'QUERY_STRING'}; } elsif($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN, $query, $ENV{'CONTENT_LENGTH'}); } my @formfields=split /&/,$query; $stype = "AND"; foreach(@formfields){ if(/^query=(.*)/) {$ndquery=$1} if(/^stpos=(.*)/) {$stpos=$1} if(/^stype=(.*)/) {$stype=$1} if(/^s=(.*)/) {$sorting=$1} if(/^o=(.*)/) {$sorting_order=$1} if(/^z=(.*)/) {$zones{$1}++ if ($1 != 0)} } # Uncomment and use required recoding function if necessary #$query = urldecode($ndquery); #$query = recode_function($query); #$ndquery = urlencode($query); prepare_query($ndquery, $stpos, $stype, $sorting, $sorting_order, \%zones); } #=================================================================== sub print_results { my $strpos; my $key; my $val; for (my $i=$stpos; $i<$stpos+$res_num; $i++) { if ($i == scalar(@res)) {last}; $score = $sorting_data[$res[$i]]; read_data($res[$i]); my ($type) = ($url =~ m|\.([^.]+)(?:[?#].*)?$|); if ( $cfg{read_file_from_local_disk} ne "YES" || $type =~ m|$cfg{ext_parser_ext}|i || $url=~m|/$|) { $description = &high_light_query($description); } else { (my $filename = $url) =~ s|$cfg{base_url}|$cfg{base_dir}/|; local $/; open FILE, $filename; my $text = ; if ($cfg{use_selective_indexing} eq "YES") { foreach $key (keys %{$cfg{no_index_strings}}) { $val = $cfg{no_index_strings}{$key}; $text =~ s/$key.*?$val/ /gs; } } $text =~ s// /gs; $text =~ s/<[Ss][Cc][Rr][Ii][Pp][Tt].*?<\/[Ss][Cc][Rr][Ii][Pp][Tt]>/ /gs; $text =~ s/<[Ss][Tt][Yy][Ll][Ee].*?<\/[Ss][Tt][Yy][Ll][Ee]>/ /gs; $text =~ s/<[Tt][Ii][Tt][Ll][Ee]>\s*(.*?)\s*<\/[Tt][Ii][Tt][Ll][Ee]>/ /s; $text =~ s/<[^>]*>/ /gs; $text =~ s/(&[a-zA-Z0-9#]*?;)/&esc2char($1)/egs; $text =~ s/\s+/ /gs; if ($text ne "") { $description = &high_light_query($text); } else { $description = &high_light_query($description); } } print print_template($templates{"results"}); }; # for } #===================================================================