--- db/prgsrc/db.cgi 2003/01/27 13:04:25 1.86 +++ db/prgsrc/db.cgi 2003/02/02 13:44:06 1.87 @@ -174,8 +174,10 @@ sub printform @df=param('type'); @df=('chgk','brain','igp','game','ehruditka','beskrylka') unless @df; $checked{lc $_}="checked" foreach @df; - $checked{'all'}=param('all')?"checked":""; - $checked{'any'}=param('all')?"":"checked"; + my $all=param('all') && param('all') eq 'yes'; + + $checked{'all'}=$all?"checked":""; + $checked{'any'}=$all?"":"checked"; $checked{lc param('metod')}="checked"; $checked{'russian'}=1 unless $checked{'russian'} || $checked{'old'}; @@ -184,9 +186,9 @@ return < -

Поиск в базе данных

+

Поиск в базе вопросов

- + $qnumber

@@ -211,7 +213,7 @@ action="/znatoki/cgi-bin/db.cgi">  "Бескрылка" - Расширенный (с учетом грамматики, в вопросах всех типов) + Расширенный (с учетом грамматики, в вопросах всех типов) Искать: @@ -1111,7 +1113,6 @@ sub PrintQuestion { 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"}) . " " . @@ -1136,14 +1137,14 @@ sub PrintQuestion { if ($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.CharId,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; + 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) @@ -1208,8 +1209,11 @@ $output.="" } $output=~s/\(pic: ([^\)]*)\)/

/g unless $text; - $output.=br.a({href=> url."?metod=proxy&qid=$Id"}, 'Близкие вопросы').p - if $answer>0 && !$text; + my $qid=param('tour') ? (param('tour').".$Question{'Number'}" ): ''; + + $output.=br.a({href=> url."?metod=proxy& +qid=$qid"}, 'Близкие вопросы').p + if $answer>0 && !$text && $qid; return $output; } @@ -1373,7 +1377,15 @@ sub PrintQOfAuthor { my ($dbh, $id) = @_; - $id=$dbh->quote($id); + unless ($id=~/^\d+$/) { + $id=$dbh->quote($id); + my $sth = $dbh->prepare("SELECT Id FROM Authors WHERE CharId=$id"); + $sth->execute; + ($id)=$sth->fetchrow; + $sth->finish; + } + $id=$dbh->quote($id); + my $sth = $dbh->prepare("SELECT Name, Surname FROM Authors WHERE Id=$id"); $sth->execute; my ($name,$surname)=$sth->fetchrow; @@ -1395,7 +1407,7 @@ sub PrintQOfAuthor } else { $suffix = 'я'; } - print h2("Поиск в базе вопросов"); +# print h2("Поиск в базе вопросов"); print printform; print p({align=>"center"}, "Автор ".strong("$name $surname. ") . " : $hits попадани$suffix."); @@ -1624,10 +1636,9 @@ MAIN: print header('text/plain'); } else {print header;} - my($dbh) = DBI->connect("DBI:mysql:chgk", "piataev", "") or do { - print h1("Временные проблемы") . "База данных временно не + print h1("Временные проблемы") . "База вопросов временно не работает. Заходите попозже."; print &Include_virtual("../dimrub/db/reklama.html"); print end_html; @@ -1731,6 +1742,33 @@ EOT } elsif (param('qid')) { my $qid=param('qid'); + if ($qid !~ /^[0-9]*$/) { + my ($fname,$t,$n)= split /\./ , $qid; + $n=$t,$t='' unless $n; + if ($n) + { + $sth = $dbh->prepare( + "SELECT t2.Id FROM Tournaments as t1, + Tournaments as t2 + WHERE t1.FileName = '$fname.txt' + AND t1.Id=t2.ParentId AND t2.Number=$t"); + } + else + { + $sth = $dbh->prepare("SELECT Id FROM Tournaments + WHERE FileName = '$fname.txt'"); + } + $sth->execute; + $tour = ($sth->fetchrow)[0]; + $sth->finish; + $sth = $dbh->prepare( + "SELECT QuestionId FROM + Questions + WHERE ParentId=$tour AND + Questions.Number=$n"); + $sth->execute; + $qid = ($sth->fetchrow)[0]; + } my $query="SELECT Question, Answer from Questions where QuestionId=$qid"; print $query if $printqueries; my $sth=$dbh->prepare($query);