--- db/prgsrc/db.cgi 2002/06/15 02:20:23 1.69 +++ 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 @@ -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" ): ''; } @@ -885,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)); @@ -1058,36 +1058,35 @@ sub PrintQuestion { 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'}) { @@ -1130,8 +1129,8 @@ EOTT $output.="" } -# $output.=br.a({href=> url."?metod=proxy&qid=$Id"}, 'Близкие вопросы').p -# if $answer; + $output.=br.a({href=> url."?metod=proxy&qid=$Id"}, 'Близкие вопросы').p + if $answer; return $output; }