--- db/prgsrc/db.cgi 2002/10/22 04:23:13 1.76 +++ db/prgsrc/db.cgi 2003/01/27 12:55:55 1.85 @@ -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'=>'Э'); @@ -159,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','game','ehruditka','beskrylka') unless @df; - - my $types=checkbox_group('type',['chgk','brain','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'=>'Любое'}); + @df=('chgk','brain','igp','game','ehruditka','beskrylka') unless @df; + $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 @@ -687,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; @@ -778,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); @@ -792,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; } @@ -813,6 +858,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'}; @@ -1038,6 +1085,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;
@@ -1057,11 +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/;
 			$fname=~s/\.txt//;
 			$titles .=
 				dd(img({src=>"/icons/folder.open.gif"}) . " " .
@@ -1074,23 +1124,23 @@ sub PrintQuestion {
 	}
 
 
-	$output.= "";
+	$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);
 
-		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;
@@ -1111,7 +1161,7 @@ sub PrintQuestion {
                            }
                            $q=~s/($sha)/a({href=>url."?qofauthor=$AuthorId"},$1)/ei;
                        }
- 
+                      }
 			$output .= &PrintField("Автор(ы)", $q, $text);
 
 		}
@@ -1153,11 +1203,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; } @@ -1568,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 { @@ -1583,6 +1639,11 @@ MAIN: -author=>'dimrub@icomverse.com', -bgcolor=>'#fff0e0', -vlink=>'#800020'); +print "\n"; + print &Include_virtual("../dimrub/db/reklama.html"); } @@ -1597,10 +1658,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;