--- db/prgsrc/db.cgi 2003/01/12 10:01:00 1.82 +++ db/prgsrc/db.cgi 2003/02/02 13:44:06 1.87 @@ -160,51 +160,86 @@ print "timee0=".time.br if $debug; sub printform { - my $submit=submit(-value=>'Поиск'); - my $inputstring=textfield(-name=>'sstr', - -default=>param('sstr')||'', - -size=>30, - -maxlength=>50); - my $qnumber="Выводить по".br. textfield(-name=>'kvo', + my $qnumber=(" "x10)."Выводить по ". textfield(-name=>'kvo', -default=>param('kvo')||'150', -size=>3, - -maxlength=>5). br."вопросов"; - + -maxlength=>5)." вопросов"; + my $sstr=param('sstr'); my @df=keys %searchin; + my %checked; @df=('Question', 'Answer') unless @df; + $checked{lc $_}="checked" foreach @df; my $fields=checkbox_group('searchin',['Question','Answer','Comments','Authors','Sources'], [@df], 'false',\%rusfieldname); @df=param('type'); @df=('chgk','brain','igp','game','ehruditka','beskrylka') unless @df; + $checked{lc $_}="checked" foreach @df; + my $all=param('all') && param('all') eq 'yes'; - 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'), - -labels=>\%rusfieldname); - my $all=radio_group(-name=>'all',-values=>['yes','no'], - -default=>(param('all')||'no'), - -labels=>{'yes'=>'Все','no'=>'Любое'}); + $checked{'all'}=$all?"checked":""; + $checked{'any'}=$all?"":"checked"; + $checked{lc param('metod')}="checked"; + $checked{'russian'}=1 unless $checked{'russian'} || $checked{'old'}; ################################################# -return start_form(-method=>'get', - -action=>url, - -enctype=> - "application/x-www-form-urlencoded" -).br. -table(Tr -( - td({-valign=>'TOP'},$inputstring.$submit.p."Метод: $metod".p."Слова: $all"), - td({-valign=>'TOP'},(' 'x 8).'Поля:'), - td({-valign=>'TOP'},$fields), - td({-valign=>'TOP'},(' 'x 1).'Типы:'), - td({-valign=>'TOP'},$types), td(" "x5), - td({-valign=>'TOP'},$qnumber) -) -) - -#$fields. -#$inputstring.$submit.br.$metod.$all +return +< +

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

+ + + $qnumber +

+ + + + + + + + + + + + + +
Вариант поиска: + + Простой (старый) + + "Что? Где? Когда?" + + "Брейн-Ринг" + + "Интернет" +
+ "Своя игра" + + "Эрудитка" + + "Бескрылка" +
Расширенный (с учетом грамматики, в вопросах всех типов) +
Искать: + +Все слова + +Любое слово +
Поля для поиска: + +Вопрос + +Ответ
+
+Комментарии
+
+Автор
+
+Источник
+
+ + +EOT .endform .hr @@ -688,7 +723,7 @@ sub PrintList { sub PrintSearch { my ($dbh, $sstr, $metod,$was) = @_; my $t=time; - print h2("Поиск в базе вопросов"); +# print h2("Поиск в базе вопросов"); print printform; my @allnf; my @Questions; @@ -1078,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"}) . " " . @@ -1103,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) @@ -1169,13 +1203,17 @@ EOTT $output .= &PrintField("Комментарии", $Question{'Comments'}, $text); } - $output=~s/\(pic: ([^\)]*)\)//g; + $output.="" } - $output.=br.a({href=> url."?metod=proxy&qid=$Id"}, 'Близкие вопросы').p - if $answer>0 && !$text; + $output=~s/\(pic: ([^\)]*)\)/

/g unless $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; } @@ -1339,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; @@ -1361,7 +1407,7 @@ sub PrintQOfAuthor } else { $suffix = 'я'; } - print h2("Поиск в базе вопросов"); +# print h2("Поиск в базе вопросов"); print printform; print p({align=>"center"}, "Автор ".strong("$name $surname. ") . " : $hits попадани$suffix."); @@ -1586,21 +1632,28 @@ MAIN: setlocale(LC_CTYPE,'russian'); my($i, $tour); my($text) = (param('text')) ? 1 : 0; + if ($text) { + 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; die "Can't connect to DB chgk\n"; }; if (!param('comp') and !param('sqldump') and !$text) { - print header; print start_html(-"title"=>'Database of the questions', -author=>'dimrub@icomverse.com', -bgcolor=>'#fff0e0', -vlink=>'#800020'); +print "\n"; + print &Include_virtual("../dimrub/db/reklama.html"); } @@ -1615,10 +1668,6 @@ POSIX::setlocale( &POSIX::LC_ALL, $thisl if ((uc 'а') ne 'А') {print "Koi8-r locale not installed!\n"}; - if ($text) { - print header('text/plain'); - } - if (param('hideequal')) { my ($sth)= $dbh -> prepare("select first, second FROM equalto"); $sth -> execute; @@ -1693,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);