--- db/prgsrc/db.cgi 2002/11/26 05:34:39 1.79 +++ db/prgsrc/db.cgi 2003/01/27 13:04:25 1.86 @@ -160,51 +160,84 @@ 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; - - 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{lc $_}="checked" foreach @df; + $checked{'all'}=param('all')?"checked":""; + $checked{'any'}=param('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 +721,7 @@ sub PrintList { sub PrintSearch { my ($dbh, $sstr, $metod,$was) = @_; my $t=time; - print h2("Поиск в базе вопросов"); +# print h2("Поиск в базе вопросов"); print printform; my @allnf; my @Questions; @@ -779,6 +812,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); @@ -793,8 +828,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; } @@ -1062,12 +1106,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/; +#return "" if $fname=~/mgp0203/; $fname=~s/\.txt//; $titles .= dd(img({src=>"/icons/folder.open.gif"}) . " " . @@ -1082,10 +1126,10 @@ return "" if $fname=~/mgp0203/; $output.= "" unless $text; - $output .= - &PrintField("Вопрос $qnum", $Question{'Question'}, $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); @@ -1159,11 +1203,13 @@ EOTT } + $output.="" } + $output=~s/\(pic: ([^\)]*)\)/

/g unless $text; $output.=br.a({href=> url."?metod=proxy&qid=$Id"}, 'Близкие вопросы').p - if $answer && !$text; + if $answer>0 && !$text; return $output; } @@ -1574,6 +1620,10 @@ 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 { @@ -1584,11 +1634,15 @@ MAIN: 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"); } @@ -1603,10 +1657,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;