Diff for /db/prgsrc/db.cgi between versions 1.136 and 1.139

version 1.136, 2004/09/05 14:57:05 version 1.139, 2005/02/26 11:03:41
Line 11  use locale; Line 11  use locale;
 use vars qw($opt_z);  use vars qw($opt_z);
 use Getopt::Std;  use Getopt::Std;
 #my ($dbuser,$dbname,$dbpass,$dbhost);  #my ($dbuser,$dbname,$dbpass,$dbhost);
 require "dbdefs.pl";  eval {require "dbdefs.pl";} ;
 my $url=url||'';  my $url=url||'';
   my @used_stop=();
 $dbuser||="piataev";  $dbuser||="piataev";
 $dbname||="chgk";  $dbname||="chgk";
 $dbpass||="";  $dbpass||="";
Line 500  sub russearch { Line 501  sub russearch {
             my %relevance;              my %relevance;
             my @blob;              my @blob;
             my %count;              my %count;
               my %stop_word;
         POSIX::setlocale( &POSIX::LC_ALL, $thislocale );          POSIX::setlocale( &POSIX::LC_ALL, $thislocale );
 $sstr=~tr/йцукенгшщзхъфывапролджэячсмитьбю/ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ/;  $sstr=~tr/йцукенгшщзхъфывапролджэячсмитьбю/ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ/;
 #           @qw=@w =split (' ', uc $sstr);  #           @qw=@w =split (' ', uc $sstr);
             my $ts=uc $sstr;              my $ts=uc $sstr;
             @qw=@w= $ts=~m/(?:(?:${RLrl})+)|(?:[A-Za-z0-9]+)/gom;              @qw=@w= $ts=~m/(?:(?:${RLrl})+)|(?:[A-Za-z0-9]+)/gom;
               $query="select nf.word from nf  where number>=50000";
               $sth=$dbh->prepare($query);
               $sth->execute();
               %stop_word=();
               while (@arr = $sth->fetchrow)
                   {
                      $stop_word{$arr[0]}=1;
                   }
                   $sth->finish;
               
   
 #-----------  #-----------
             foreach $i (0..$#w) # заполняем массив @nf начальных форм              foreach $i (0..$#w) # заполняем массив @nf начальных форм
                            # $nf[$i] -- ссылка на массив возможных                             # $nf[$i] -- ссылка на массив возможных
                            # начальных форм словоформы $i                             # начальных форм словоформы $i
             {              {
                   (push @used_stop, uc $w[$i]),next if $stop_word{uc $w[$i]};
                 $qw= $dbh->quote (uc $w[$i]);                  $qw= $dbh->quote (uc $w[$i]);
   
                 $query="  select distinct w2 from nests                  $query="  select distinct w2 from nests
                                 where w1=$qw";                                  where w1=$qw";
                 $sth=$dbh -> prepare($query);                  $sth=$dbh -> prepare($query);
Line 557  $sstr=~tr/йцукенгшщзхъфывапролджэячсмить Line 570  $sstr=~tr/йцукенгшщзхъфывапролджэячсмить
               $_= " word2question.word=$_" foreach @arr;                $_= " word2question.word=$_" foreach @arr;
               $_= " nf.id=".$_. ' ' foreach @arr1;                $_= " nf.id=".$_. ' ' foreach @arr1;
 #              @arr=(0) unless @arr;  #              @arr=(0) unless @arr;
               $query="select questions from word2question where (". (join ' OR ', @arr).") AND length(questions)<80000";                $query="select questions from word2question where (". (join ' OR ', @arr).") ";
   
               $sth=$dbh -> prepare($query);                $sth=$dbh -> prepare($query);
               $sth->execute;                $sth->execute;
Line 891  sub PrintList { Line 904  sub PrintList {
         for (my $i = $first; $i <= $last; $i++) {          for (my $i = $first; $i <= $last; $i++) {
                 my $q=$q{$$Questions[$i-1]};                  my $q=$q{$$Questions[$i-1]};
                 my $output;                  my $output;
                 $output = &PrintQuestion($dbh, $q, 1, 0, 1,0,1  );                  $output = &PrintQuestion($dbh, $q, 1, 0, 1,$text,1  );
 #                if (param('metod') && (param('metod') eq 'rus' || param('metod') eq 'proxy'))  #                if (param('metod') && (param('metod') eq 'rus' || param('metod') eq 'proxy'))
                 {                  {
                      $output=~s/\b($shablon)\b/\<strong\>$1\<\/strong\>/gi;                       $output=~s/\b($shablon)\b/\<strong\>$1\<\/strong\>/gi;
Line 945  sub PrintSearch { Line 958  sub PrintSearch {
   
   
         $Output.= p. "Время поиска: " . (time-$t) ." сек.".p;          $Output.= p. "Время поиска: " . (time-$t) ." сек.".p;
           $_="\"$_\"" foreach @used_stop;
           $Output.= p. (join ', ',@used_stop) ." ignored".p if @used_stop;
         my ($output, $i, $suffix, $hits) = ('', 0, '', $#Questions + 1);          my ($output, $i, $suffix, $hits) = ('', 0, '', $#Questions + 1);
   
         my $shablon;          my $shablon;
Line 1263  sub PrintTour { Line 1278  sub PrintTour {
         my $sth=SelectQuestions($dbh,\@Questions,0);          my $sth=SelectQuestions($dbh,\@Questions,0);
         for ($q = 0; $q <= $#Questions; $q++) {          for ($q = 0; $q <= $#Questions; $q++) {
                 fetchquestion($sth,\%q,0);                  fetchquestion($sth,\%q,0);
                 $output .= &PrintQuestion($dbh, \%q, $answer, 0,0,0,1);                  $output .= &PrintQuestion($dbh, \%q, $answer, 0,0,$text,1);
         }          }
         $sth->finish;          $sth->finish;
         $output .= hr({-'align'=>'center', -'width'=>'80%'});          $output .= hr({-'align'=>'center', -'width'=>'80%'});
Line 1484  $output.="</span>" Line 1499  $output.="</span>"
   
         }          }
         $output=~s/\(pic: ([^\)]*)\)/<p><img src="\/znatoki\/images\/db\/$1"><p>/g unless $text;          $output=~s/\(pic: ([^\)]*)\)/<p><img src="\/znatoki\/images\/db\/$1"><p>/g unless $text;
           $output=~s/⌡/\&iuml;/g;
           $output=~s/⌠/\&Iuml;/g;
   
         $paramtour||=param("tour");          $paramtour||=param("tour");
         $fname=$fname.".$Question{'TourNumber'}" if $fname && $Question{'TourNumber'};          $fname=$fname.".$Question{'TourNumber'}" if $fname && $Question{'TourNumber'};
 $fname||=param('tour');  $fname||=param('tour');
Line 2214  EOT Line 2232  EOT
                   $QuestionNumber=($sth->fetchrow)[0]||0;                    $QuestionNumber=($sth->fetchrow)[0]||0;
                 }                  }
                 if ($QuestionNumber) {                  if ($QuestionNumber) {
                   $globaloutput.= &PrintQuestion($dbh, $QuestionNumber, $withanswers||0, $qnum, 1,0,0);                    $globaloutput.= &PrintQuestion($dbh, $QuestionNumber, $withanswers||0, $qnum, 1,$text,0);
 #                                        $dbh, $Id, $answer, $qnum, $title, $text  #                                        $dbh, $Id, $answer, $qnum, $title, $text
                 } else  {                  } else  {
                    $globaloutput.=&PrintTournament($dbh, $tour, $withanswers);                     $globaloutput.=&PrintTournament($dbh, $tour, $withanswers);

Removed from v.1.136  
changed lines
  Added in v.1.139


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>