--- db/prgsrc/db.cgi 2002/10/06 08:58:12 1.74 +++ db/prgsrc/db.cgi 2003/01/12 11:17:23 1.83 @@ -7,6 +7,7 @@ use Time::Local; use POSIX qw(locale_h); use locale; open STDERR, ">/var/tmp/errors1"; +my $newsurl='http://news.chgk.info/'; my $printqueries=0; my %forbidden=(); my $debug=0; #added by R7 @@ -17,7 +18,7 @@ my %rusfieldname=('Question','Вопрос', ' 'Comments', 'Комментарии', 'Authors', 'Автор', 'Sources', 'Источник','old','Старый','rus','Новый', 'chgk', 'ЧГК', 'brain', 'Брейн-ринг','game', 'Своя игра', - 'ehruditka', 'Эрудитка', 'beskrylka', 'Бескрылка' + 'ehruditka', 'Эрудитка', 'beskrylka', 'Бескрылка', 'igp', 'Интернет' ); my %searchin; my $rl=qr/[йцукенгшщзхъфывапролджэячсмитьбюё]/; @@ -32,7 +33,7 @@ my %metodchar=('rus',1,'old',2); my $thislocale; $searchin{$_}=1 foreach param('searchin'); -my %TypeName=('children'=>'Д', 'game'=>'И', +my %TypeName=('children'=>'Д', 'game'=>'Я', 'igp'=>'И', 'chgk'=>'Ч', 'brain'=>'Б', 'beskrylka'=>'Л','ehruditka'=>'Э'); @@ -174,9 +175,9 @@ sub printform my $fields=checkbox_group('searchin',['Question','Answer','Comments','Authors','Sources'], [@df], 'false',\%rusfieldname); @df=param('type'); - @df=('chgk','brain','game','ehruditka','beskrylka') unless @df; + @df=('chgk','brain','igp','game','ehruditka','beskrylka') unless @df; - my $types=checkbox_group('type',['chgk','brain','game','ehruditka','beskrylka'], [@df], + my $types=checkbox_group('type',['chgk','brain','igp','game','ehruditka','beskrylka'], [@df], 'false',\%rusfieldname); my $metod=radio_group(-name=>'metod',-values=>['old','rus'], -default=>(param('metod')||'rus'), @@ -533,7 +534,9 @@ sub Search { for $i (0 .. $#sar) { $sar[$i] = $dbh->quote("%${sar[$i]}%"); } - + $_.=' ' foreach (@fields); # Это чтобы последнее слово поля + # не сливалось с первым словом + # следующего поля, R7 my($f) = "CONCAT(" . join(',', @fields) . ")"; if (param('all') eq 'yes') { $sstr = join " AND $f LIKE ", @sar; @@ -776,6 +779,8 @@ print "$query" if $printqueries; sub PrintRandom { my ($dbh, $type, $num, $text) = @_; + my $razd=param('razd'); + my $answer=$razd?0:1; my (@Questions) = &Get12Random($dbh, $type, $num); my ($output, $i) = ('', 0); @@ -790,8 +795,17 @@ sub PrintRandom { # Passing DB handler, question ID, print answer, question # number, print title, print text/html $output .= - &PrintQuestion($dbh, $Questions[$i], 1, $i + 1, 0, $text); + &PrintQuestion($dbh, $Questions[$i], $answer, $i + 1, 0, $text); } + unless ($answer ) + { + $output.=$text?"\n".('-'x 20)."\nОтветы\n~~~~~~\n\n":h2('Ответы'); + for ($i = 0; $i <= $#Questions; $i++) { + $output .= + &PrintQuestion($dbh, $Questions[$i], -1, $i + 1, 0, $text); + } + } + return $output; } @@ -811,6 +825,8 @@ sub PrintTournament { %Tournament = &GetTournament($dbh, $Id) if ($Id); my ($URL) = $Tournament{'URL'}; + $URL=~s/http:\/znatoki\/boris\/reports\//$newsurl/ if url=~/kulichki/; + $URL=~s/\/znatoki\/boris\/reports\//$newsurl/ if url=~/kulichki/;; my ($Info) = $Tournament{'Info'}; my ($Copyright) = $Tournament{'Copyright'}; my $fname=$Tournament{'FileName'}; @@ -1036,6 +1052,8 @@ sub PrintField { $value =~ s/^\s+/
    /mg; $value =~ s/^\|([^\n]*)/
$1<\/pre>/mg;
 	    $value =~ s/\s+-+\s+/ – /mg;
+	    $value =~ s/(http:\/\/\S+[^\s\)\(\,\.])/$1<\/a>/g if $header !~ /^Авто/;
+#	    $value =~ s/(http:\/\/(?:\w+.)+[\w\\\~]+(\?[^\s.]+)?)/$1<\/a>/g if $header !~ /^Авто/;
 #	    $value =~ s/(\s)"/$1“/mg;
 #	    $value =~ s/^"/“/mg;
 #	    $value =~ s/"/”/mg;
@@ -1055,11 +1073,12 @@ sub PrintQuestion {
 	$qnum = $Question{'Number'}
 		if ($qnum == 0);
 	if (!$text) {
-		$output .= hr({width=>"50%"});
+		$output .= hr({width=>"50%"}) if $answer>=0;
 		if ($title) {
 			my (%Tour) = GetTournament($dbh, $Question{'ParentId'});
 			my (%Tournament) = GetTournament($dbh, $Tour{'ParentId'});
 			my $fname=$Tournament{'FileName'};
+#return "" if $fname=~/mgp0203/;
 			$fname=~s/\.txt//;
 			$titles .=
 				dd(img({src=>"/icons/folder.open.gif"}) . " " .
@@ -1072,23 +1091,23 @@ sub PrintQuestion {
 	}
 
 
-	$output.= "";
-
-	$output .=
-		&PrintField("Вопрос $qnum", $Question{'Question'}, $text);
+	$output.= "" unless $text;
 
-	if ($answer==1) {
+	if ($answer>=0) {$output .=
+		&PrintField("Вопрос $qnum", $Question{'Question'}, $text);}
+	else {$output .="$qnum. "}
+	if ($answer==1|| $answer==-1) {
 		$output .=
 			&PrintField("Ответ", $Question{'Answer'}, $text);
 
-		if ($Question{'Authors'}) {
+		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);
-
+                      if (!$text) {
                        while ((($AuthorId,$Name, $Surname,$Nicks)=$sth->fetchrow),$AuthorId)
                        {
                          my ($firstletter)=$Name=~m/^./g;
@@ -1109,7 +1128,7 @@ sub PrintQuestion {
                            }
                            $q=~s/($sha)/a({href=>url."?qofauthor=$AuthorId"},$1)/ei;
                        }
- 
+                      }
 			$output .= &PrintField("Автор(ы)", $q, $text);
 
 		}
@@ -1151,11 +1170,13 @@ EOTT
 		}
 
 
+
 $output.=""
 
 	}
+	$output=~s/\(pic: ([^\)]*)\)/

/g unless $text; $output.=br.a({href=> url."?metod=proxy&qid=$Id"}, 'Близкие вопросы').p - if $answer; + if $answer>0 && !$text; return $output; }