Diff for /db/prgsrc/db.cgi between versions 1.66 and 1.70

version 1.66, 2002/05/14 00:12:35 version 1.70, 2002/06/20 12:54:52
Line 2 Line 2
   
 use DBI;  use DBI;
 use CGI ':all';  use CGI ':all';
 #use Text::Query;  
 use strict;  use strict;
 use Time::Local;  use Time::Local;
 use POSIX qw(locale_h);  use POSIX qw(locale_h);
 use locale;  use locale;
 open STDERR, ">errors1";  open STDERR, ">>errors1";
 my $printqueries=0;  my $printqueries=0;
 my %forbidden=();  my %forbidden=();
 my $debug=0; #added by R7  my $debug=0; #added by R7
Line 110  sub GetTourQuestions { Line 109  sub GetTourQuestions {
         my (@arr, @Questions);          my (@arr, @Questions);
   
         my ($sth) = $dbh->prepare("SELECT QuestionId FROM Questions          my ($sth) = $dbh->prepare("SELECT QuestionId FROM Questions
                 WHERE ParentId=$ParentId");                  WHERE ParentId=$ParentId order by Number");
   
         $sth->execute;          $sth->execute;
   
Line 773  sub PrintRandom { Line 772  sub PrintRandom {
   
 sub PrintEditor {  sub PrintEditor {
        my $t=shift; #ссылка на Хэш с полями         my $t=shift; #ссылка на Хэш с полями
        my $ed=$$t{'Editors'};         my $ed=$$t{'Editors'}||'';
        my $edname=($ed=~/\,/ ) ? "Редакторы"  : "Редактор" ;         my $edname=($ed=~/\,/ ) ? "Редакторы"  : "Редактор" ;
        return $ed? h4({align=>"center"},"$edname: $ed" ): '';         return $ed? h4({align=>"center"},"$edname: $ed" ): '';
 }  }
Line 821  sub PrintTournament { Line 820  sub PrintTournament {
                 }                  }
         } else {          } else {
                 my ($qnum) = GetQNum($dbh);                  my ($qnum) = GetQNum($dbh);
                 $output .= h2("Банк Вопросов: $qnum вопросов") . p . "\n";                  $output .= h2("Банк Вопросов: $qnum вопрос".&Suffix($qnum)) 
                             . p . "\n";
         }          }
   
         for ($i = 0; $i <= $#Tours; $i++) {          for ($i = 0; $i <= $#Tours; $i++) {
Line 884  sub PrintTournament { Line 884  sub PrintTournament {
         $output .= dl($list);          $output .= dl($list);
   
         if ($URL) {          if ($URL) {
                   if (url=~/zaba\.ru/ && $URL=~/^\//){$URL="http://info.chgk.info$URL"}
                 $output .=                  $output .=
                 p("Дополнительная информация об этом турнире - по адресу " .                  p("Дополнительная информация об этом турнире - по адресу " .
                         a({-'href'=>$URL}, $URL));                          a({-'href'=>$URL}, $URL));
Line 1051  sub PrintQuestion { Line 1052  sub PrintQuestion {
         $output .=          $output .=
                 &PrintField("Вопрос $qnum", $Question{'Question'}, $text);                  &PrintField("Вопрос $qnum", $Question{'Question'}, $text);
   
         if ($answer) {          if ($answer==1) {
                 $output .=                  $output .=
                         &PrintField("Ответ", $Question{'Answer'}, $text);                          &PrintField("Ответ", $Question{'Answer'}, $text);
   
                 if ($Question{'Authors'}) {                  if ($Question{'Authors'}) {
                       my $q=$Question{'Authors'};                        my $q=$Question{'Authors'};
   ###АВТОРА!!
 #                     my $sth=$dbh->prepare("select Authors.Id,Name, Surname, Nicks from Authors, A2Q                        my $sth=$dbh->prepare("select Authors.Id,Name, Surname, Nicks from Authors, A2Q
 #                                 where Authors.Id=Author And Question=$Id");                                    where Authors.Id=Author And Question=$Id");
 #                      $sth->execute;                         $sth->execute;
 #                      my ($AuthorId,$Name, $Surname,$other,$Nicks);                         my ($AuthorId,$Name, $Surname,$other,$Nicks);
   
 #                      while ((($AuthorId,$Name, $Surname,$Nicks)=$sth->fetchrow),$AuthorId)                         while ((($AuthorId,$Name, $Surname,$Nicks)=$sth->fetchrow),$AuthorId)
 #                      {                         {
 #                        my ($firstletter)=$Name=~m/^./g;                           my ($firstletter)=$Name=~m/^./g;
 #                         $Name=~s/\./\\\./g;                            $Name=~s/\./\\\./g;
 #                          my $sha="(?:$Name\\s+$Surname)|(?:$Surname\\s+$Name)|(?:$firstletter\\.\\s*$Surname)|(?:$Surname\\s+$firstletter\\.)|(?:$Surname)|(?:$Name)";                             my $sha="(?:$Name\\s+$Surname)|(?:$Surname\\s+$Name)|(?:$firstletter\\.\\s*$Surname)|(?:$Surname\\s+$firstletter\\.)|(?:$Surname)|(?:$Name)";
 #                          if ($Nicks)                             if ($Nicks)
 #                          {                             {
 #                            $Nicks=~s/^\|//;                               $Nicks=~s/^\|//;
 #                            foreach (split /\|/, $Nicks)                               foreach (split /\|/, $Nicks)
 #                            {                               {
 #                              s/\s+/ /g;                                 s/\s+/ /g;
 #                              s/\s+$//;                                 s/\s+$//;
 #                              s/ /\\s+/g;                                 s/ /\\s+/g;
 #                              s/\./\\\./g;                                 s/\./\\\./g;
 #                              if (s/>$//) {$sha="$sha|(?:$_)"}                                 if (s/>$//) {$sha="$sha|(?:$_)"}
 #                              else        {$sha="(?:$_)|$sha"}                                 else        {$sha="(?:$_)|$sha"}
 #                            }                               }
 #                          }                             }
 #                          $q=~s/($sha)/a({href=>url."?qofauthor=$AuthorId"},$1)/ei;                             $q=~s/($sha)/a({href=>url."?qofauthor=$AuthorId"},$1)/ei;
 #                      }                         }
    
                         $output .= &PrintField("Автор(ы)", $q, $text);                          $output .= &PrintField("Автор(ы)", $q, $text);
   
 #                        $output.= &PrintField("Другие вопросы", $other);  
                 }                  }
   
                 if ($Question{'Sources'}) {                  if ($Question{'Sources'}) {
Line 1097  sub PrintQuestion { Line 1097  sub PrintQuestion {
                         $output .= &PrintField("Комментарии", $Question{'Comments'}, $text);                          $output .= &PrintField("Комментарии", $Question{'Comments'}, $text);
                 }                  }
         }          }
 #       $output.=br.a({href=> url."?metod=proxy&qid=$Id"}, 'Близкие вопросы').p          elsif ($answer==2) {
 #             if $answer;            my $text=$Question{'Answer'};
             $text=~s/\n/<option>/mg;
             $output.="<select><option selected>Ответ:<option>$text</select>";
             $text=$Question{'Comments'}||'';
             if ($text) {
                $text=~s/\n/<option>/mg;
                $output.="<select><option selected>Комментарий:<option>$text</select>"
             }
           } 
           elsif ($answer==3) {
           $output.=  <<EOTT
             <div align=right STYLE="cursor:hand;" OnStart="toggle(document.all.HideShow$qnum);" OnClick="toggle(document.all.HideShow$qnum);">
             <font size=-2 color=red> Показать/убрать ответ</font></div>
             <span style="display:none" id=HideShow$qnum>
   EOTT
             .&PrintField("Ответ", $Question{'Answer'}, $text);
                   if ($Question{'Authors'}) {
                           $output .= &PrintField("Автор(ы)", $Question{'Authors'}, $text);
                   }
                   if ($Question{'Sources'}) {
                           $output .= &PrintField("Источник(и)", $Question{'Sources'}, $text);
                   }
   
                   if ($Question{'Comments'}) {
                           $output .= &PrintField("Комментарии", $Question{'Comments'}, $text);
                   }
   
   
   $output.="</span>"
   
           }
           $output.=br.a({href=> url."?metod=proxy&qid=$Id"}, 'Близкие вопросы').p
                if $answer;
         return $output;          return $output;
 }  }
   
Line 1670  $sstr=~s/[^йцукенгшщзхъфывапролджэячсмит Line 1702  $sstr=~s/[^йцукенгшщзхъфывапролджэячсмит
         }          }
         if (!$text) {          if (!$text) {
                 print &Include_virtual("../dimrub/db/footer.html");                  print &Include_virtual("../dimrub/db/footer.html");
   print <<EEE
     <SCRIPT LANGUAGE="JavaScript">
   function toggle(e) {
     if (e.style.display == "none") {
        e.style.display="";
     } else {
        e.style.display = "none";
    }
   }
   </SCRIPT>
   EEE
   ;
                 print end_html;                  print end_html;
         }          }
         $dbh->disconnect;          $dbh->disconnect;

Removed from v.1.66  
changed lines
  Added in v.1.70


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