--- db/prgsrc/db.cgi 2002/01/15 03:34:31 1.60 +++ db/prgsrc/db.cgi 2002/06/20 12:54:52 1.70 @@ -2,12 +2,11 @@ use DBI; use CGI ':all'; -#use Text::Query; use strict; use Time::Local; use POSIX qw(locale_h); use locale; -open STDERR, ">errors1"; +open STDERR, ">>errors1"; my $printqueries=0; my %forbidden=(); my $debug=0; #added by R7 @@ -110,7 +109,7 @@ sub GetTourQuestions { my (@arr, @Questions); my ($sth) = $dbh->prepare("SELECT QuestionId FROM Questions - WHERE ParentId=$ParentId"); + WHERE ParentId=$ParentId order by Number"); $sth->execute; @@ -161,7 +160,7 @@ sub printform my $inputstring=textfield(-name=>'sstr', -default=>param('sstr')||'', -size=>30, - -maxlength=>30); + -maxlength=>50); my $qnumber="Выводить по".br. textfield(-name=>'kvo', -default=>param('kvo')||'150', -size=>3, @@ -645,7 +644,7 @@ sub PrintList { print "$nav".br."\n"; for (my $i = $first; $i <= $last; $i++) { - my $output = &PrintQuestion($dbh, $$Questions[$i-1], 1, $i, 1); + my $output = &PrintQuestion($dbh, $$Questions[$i-1], 1, 0, 1); if (param('metod') eq 'rus' || param('metod') eq 'proxy') { $output=~s/\b($shablon)\b/\$1\<\/strong\>/gi; @@ -773,7 +772,7 @@ sub PrintRandom { sub PrintEditor { my $t=shift; #ссылка на Хэш с полями - my $ed=$$t{'Editors'}; + my $ed=$$t{'Editors'}||''; my $edname=($ed=~/\,/ ) ? "Редакторы" : "Редактор" ; return $ed? h4({align=>"center"},"$edname: $ed" ): ''; } @@ -821,7 +820,8 @@ sub PrintTournament { } } else { my ($qnum) = GetQNum($dbh); - $output .= h2("Банк Вопросов: $qnum вопросов") . p . "\n"; + $output .= h2("Банк Вопросов: $qnum вопрос".&Suffix($qnum)) + . p . "\n"; } for ($i = 0; $i <= $#Tours; $i++) { @@ -840,6 +840,7 @@ sub PrintTournament { $qnum = ''; } if ($Tournament{'Type'} =~ /Г/) { + $SingleTour=0; $imgsrc = "/icons/folder.gif"; $alt = "[*]"; } else { @@ -883,6 +884,7 @@ sub PrintTournament { $output .= dl($list); if ($URL) { + if (url=~/zaba\.ru/ && $URL=~/^\//){$URL="http://info.chgk.info$URL"} $output .= p("Дополнительная информация об этом турнире - по адресу " . a({-'href'=>$URL}, $URL)); @@ -1009,9 +1011,9 @@ sub PrintField { $value =~ s/^\s+/
    /mg; $value =~ s/^\|([^\n]*)/
$1<\/pre>/mg;
 	    $value =~ s/\s+-+\s+/ – /mg;
-	    $value =~ s/(\s)"/$1“/mg;
-	    $value =~ s/^"/“/mg;
-	    $value =~ s/"/”/mg;
+#	    $value =~ s/(\s)"/$1“/mg;
+#	    $value =~ s/^"/“/mg;
+#	    $value =~ s/"/”/mg;
 	}
 
 
@@ -1025,6 +1027,8 @@ sub PrintQuestion {
 	my ($dbh, $Id, $answer, $qnum, $title, $text) = @_;
 	my ($output, $titles) = ('', '');
 	my (%Question) = &GetQuestion($dbh, $Id);
+	$qnum = $Question{'Number'}
+		if ($qnum == 0);
 	if (!$text) {
 		$output .= hr({width=>"50%"});
 		if ($title) {
@@ -1037,53 +1041,52 @@ sub PrintQuestion {
 					 a({href=>url . "?tour=$fname"}, $Tournament{'Title'}, $Tournament{'PlayedAt'}));
 			$titles .=
 				dl(dd(img({src=>"/icons/folder.open.gif"}) . " " .
-					a({href=>url . "?tour=$fname.$Tour{Number}"}, $Tour{'Title'})));
+					a({href=>url . "?tour=$fname.$Tour{Number}#$qnum"}, $Tour{'Title'})));
 		}
 		$output .= dl(strong($titles));
 	}
 
-	$qnum = $Question{'Number'}
-		if ($qnum == 0);
+
+	$output.= "";
 
 	$output .=
 		&PrintField("Вопрос $qnum", $Question{'Question'}, $text);
 
-	if ($answer) {
+	if ($answer==1) {
 		$output .=
 			&PrintField("Ответ", $Question{'Answer'}, $text);
 
 		if ($Question{'Authors'}) {
                       my $q=$Question{'Authors'};
-
-#		      my $sth=$dbh->prepare("select Authors.Id,Name, Surname, Nicks from Authors, A2Q
-#                                 where Authors.Id=Author And Question=$Id");
-#                      $sth->execute;
-#                      my ($AuthorId,$Name, $Surname,$other,$Nicks);
-
-#                      while ((($AuthorId,$Name, $Surname,$Nicks)=$sth->fetchrow),$AuthorId)
-#                      {
-#                        my ($firstletter)=$Name=~m/^./g;
-#                         $Name=~s/\./\\\./g;
-#                          my $sha="(?:$Name\\s+$Surname)|(?:$Surname\\s+$Name)|(?:$firstletter\\.\\s*$Surname)|(?:$Surname\\s+$firstletter\\.)|(?:$Surname)|(?:$Name)";
-#                          if ($Nicks)
-#                          {
-#                            $Nicks=~s/^\|//;
-#                            foreach (split /\|/, $Nicks)
-#                            {
-#                              s/\s+/ /g;
-#                              s/\s+$//;
-#                              s/ /\\s+/g;
-#                              s/\./\\\./g;
-#                              if (s/>$//) {$sha="$sha|(?:$_)"}
-#                              else        {$sha="(?:$_)|$sha"}
-#                            }
-#                          }
-#                          $q=~s/($sha)/a({href=>url."?qofauthor=$AuthorId"},$1)/ei;
-#                      }
-
+###АВТОРА!!
+ 		      my $sth=$dbh->prepare("select Authors.Id,Name, Surname, Nicks from Authors, A2Q
+                                  where Authors.Id=Author And Question=$Id");
+                       $sth->execute;
+                       my ($AuthorId,$Name, $Surname,$other,$Nicks);
+
+                       while ((($AuthorId,$Name, $Surname,$Nicks)=$sth->fetchrow),$AuthorId)
+                       {
+                         my ($firstletter)=$Name=~m/^./g;
+                          $Name=~s/\./\\\./g;
+                           my $sha="(?:$Name\\s+$Surname)|(?:$Surname\\s+$Name)|(?:$firstletter\\.\\s*$Surname)|(?:$Surname\\s+$firstletter\\.)|(?:$Surname)|(?:$Name)";
+                           if ($Nicks)
+                           {
+                             $Nicks=~s/^\|//;
+                             foreach (split /\|/, $Nicks)
+                             {
+                               s/\s+/ /g;
+                               s/\s+$//;
+                               s/ /\\s+/g;
+                               s/\./\\\./g;
+                               if (s/>$//) {$sha="$sha|(?:$_)"}
+                               else        {$sha="(?:$_)|$sha"}
+                             }
+                           }
+                           $q=~s/($sha)/a({href=>url."?qofauthor=$AuthorId"},$1)/ei;
+                       }
+ 
 			$output .= &PrintField("Автор(ы)", $q, $text);
 
-#                        $output.= &PrintField("Другие вопросы", $other);
 		}
 
 		if ($Question{'Sources'}) {
@@ -1094,8 +1097,40 @@ sub PrintQuestion {
 			$output .= &PrintField("Комментарии", $Question{'Comments'}, $text);
 		}
 	}
-#	$output.=br.a({href=> url."?metod=proxy&qid=$Id"}, 'Близкие вопросы').p
-#             if $answer;
+	elsif ($answer==2) {
+	  my $text=$Question{'Answer'};
+	  $text=~s/\n/