version 1.74, 2002/10/06 08:58:12
|
version 1.84, 2003/01/27 10:58:56
|
Line 7 use Time::Local;
|
Line 7 use Time::Local;
|
use POSIX qw(locale_h); |
use POSIX qw(locale_h); |
use locale; |
use locale; |
open STDERR, ">/var/tmp/errors1"; |
open STDERR, ">/var/tmp/errors1"; |
|
my $newsurl='http://news.chgk.info/'; |
my $printqueries=0; |
my $printqueries=0; |
my %forbidden=(); |
my %forbidden=(); |
my $debug=0; #added by R7 |
my $debug=0; #added by R7 |
Line 17 my %rusfieldname=('Question','Вопрос', '
|
Line 18 my %rusfieldname=('Question','Вопрос', '
|
'Comments', 'Комментарии', 'Authors', 'Автор', |
'Comments', 'Комментарии', 'Authors', 'Автор', |
'Sources', 'Источник','old','Старый','rus','Новый', |
'Sources', 'Источник','old','Старый','rus','Новый', |
'chgk', 'ЧГК', 'brain', 'Брейн-ринг','game', 'Своя игра', |
'chgk', 'ЧГК', 'brain', 'Брейн-ринг','game', 'Своя игра', |
'ehruditka', 'Эрудитка', 'beskrylka', 'Бескрылка' |
'ehruditka', 'Эрудитка', 'beskrylka', 'Бескрылка', 'igp', 'Интернет' |
); |
); |
my %searchin; |
my %searchin; |
my $rl=qr/[йцукенгшщзхъфывапролджэячсмитьбюё]/; |
my $rl=qr/[йцукенгшщзхъфывапролджэячсмитьбюё]/; |
Line 32 my %metodchar=('rus',1,'old',2);
|
Line 33 my %metodchar=('rus',1,'old',2);
|
my $thislocale; |
my $thislocale; |
|
|
$searchin{$_}=1 foreach param('searchin'); |
$searchin{$_}=1 foreach param('searchin'); |
my %TypeName=('children'=>'Д', 'game'=>'И', |
my %TypeName=('children'=>'Д', 'game'=>'Я', 'igp'=>'И', |
'chgk'=>'Ч', 'brain'=>'Б', 'beskrylka'=>'Л','ehruditka'=>'Э'); |
'chgk'=>'Ч', 'brain'=>'Б', 'beskrylka'=>'Л','ehruditka'=>'Э'); |
|
|
|
|
Line 159 print "timee0=".time.br if $debug;
|
Line 160 print "timee0=".time.br if $debug;
|
sub printform |
sub printform |
{ |
{ |
|
|
my $submit=submit(-value=>'Поиск'); |
my $qnumber=(" "x10)."Выводить по ". textfield(-name=>'kvo', |
my $inputstring=textfield(-name=>'sstr', |
|
-default=>param('sstr')||'', |
|
-size=>30, |
|
-maxlength=>50); |
|
my $qnumber="Выводить по".br. textfield(-name=>'kvo', |
|
-default=>param('kvo')||'150', |
-default=>param('kvo')||'150', |
-size=>3, |
-size=>3, |
-maxlength=>5). br."вопросов"; |
-maxlength=>5)." вопросов"; |
|
my $sstr=param('sstr'); |
my @df=keys %searchin; |
my @df=keys %searchin; |
|
my %checked; |
@df=('Question', 'Answer') unless @df; |
@df=('Question', 'Answer') unless @df; |
|
$checked{lc $_}="checked" foreach @df; |
my $fields=checkbox_group('searchin',['Question','Answer','Comments','Authors','Sources'], [@df], |
my $fields=checkbox_group('searchin',['Question','Answer','Comments','Authors','Sources'], [@df], |
'false',\%rusfieldname); |
'false',\%rusfieldname); |
@df=param('type'); |
@df=param('type'); |
@df=('chgk','brain','game','ehruditka','beskrylka') unless @df; |
@df=('chgk','brain','igp','game','ehruditka','beskrylka') unless @df; |
|
$checked{lc $_}="checked" foreach @df; |
my $types=checkbox_group('type',['chgk','brain','game','ehruditka','beskrylka'], [@df], |
$checked{'all'}=param('all')?"checked":""; |
'false',\%rusfieldname); |
$checked{'any'}=param('all')?"":"checked"; |
my $metod=radio_group(-name=>'metod',-values=>['old','rus'], |
$checked{lc param('metod')}="checked"; |
-default=>(param('metod')||'rus'), |
$checked{'russian'}=1 unless $checked{'russian'} || $checked{'old'}; |
-labels=>\%rusfieldname); |
|
my $all=radio_group(-name=>'all',-values=>['yes','no'], |
|
-default=>(param('all')||'no'), |
|
-labels=>{'yes'=>'Все','no'=>'Любое'}); |
|
|
|
################################################# |
################################################# |
return start_form(-method=>'get', |
return |
-action=>url, |
<<EOT |
-enctype=> |
<form method="get" enctype="application/x-www-form-urlencoded" |
"application/x-www-form-urlencoded" |
action="/znatoki/cgi-bin/db.cgi"> |
).br. |
<h2>Поиск в базе данных</h2> |
table(Tr |
|
( |
<input type="text" name="sstr" value=$sstr size="30" maxlength="50"> |
td({-valign=>'TOP'},$inputstring.$submit.p."Метод: $metod".p."Слова: $all"), |
<input type="submit" value="Поиск"> $qnumber |
td({-valign=>'TOP'},(' 'x 8).'Поля:'), |
<p> |
td({-valign=>'TOP'},$fields), |
|
td({-valign=>'TOP'},(' 'x 1).'Типы:'), |
<table border="1" cellpadding=4 cellspacing=0> |
td({-valign=>'TOP'},$types), td(" "x5), |
<tr> |
td({-valign=>'TOP'},$qnumber) |
<th align="left" rowspan=3 width="20%"> Вариант поиска: |
) |
</td><td rowspan=2 colspan=2> |
) |
<input type="radio" $checked{'old'} name="metod" value="old"> Простой (старый) |
|
</td><td> |
#$fields. |
<input type="checkbox" $checked{'chgk'} name="type" value="chgk"> "Что? Где? Когда?" |
#$inputstring.$submit.br.$metod.$all |
</td><td><nobr> |
|
<input type="checkbox" $checked{'brain'} name="type" value="brain"> "Брейн-Ринг"</nobr> |
|
</td><td> |
|
<input type="checkbox" $checked{'igp'} name="type" value="igp"> "Интернет" |
|
</td> |
|
</tr><tr> |
|
<td> |
|
<input type="checkbox" $checked{'game'} name="type" value="game"> "Своя игра" |
|
</td><td> |
|
<input type="checkbox" $checked{'ehruditka'} name="type" value="ehruditka"> "Эрудитка" |
|
</td><td> |
|
<input type="checkbox" $checked{'beskrylka'} name="type" value="beskrylka"> "Бескрылка" |
|
</td> |
|
</tr><tr> |
|
<td colspan=5><input type="radio" $checked{'russian'} name="metod" value="rus"> Расширенный (с учетом грамматики, в вопросах всех типов) |
|
</td> |
|
</tr><tr> |
|
<th align="left">Искать: |
|
</td><td colspan=2> |
|
<input type="radio" $checked{'all'} name="all" value="yes">Все слова |
|
</td><td colspan=3> |
|
<input type="radio" $checked{'any'} name="all" value="no">Любое слово |
|
</td> |
|
</tr><tr> |
|
<th align="left">Поля для поиска: |
|
</td><td width="15%"> |
|
<input type="checkbox" name="searchin" value="Question" $checked{'question'}>Вопрос |
|
</td><td width="15%"> |
|
<input type="checkbox" name="searchin" value="Answer" $checked{'answer'}>Ответ<br> |
|
</td><td width="15%"> |
|
<input type="checkbox" name="searchin" value="Comments" $checked{'comments'}>Комментарии<br> |
|
</td><td width="15%"> |
|
<input type="checkbox" name="searchin" value="Authors" $checked{'authors'}>Автор<br> |
|
</td><td width="15%"> |
|
<input type="checkbox" name="searchin" value="Sources" $checked{'sources'}>Источник<br> |
|
</td> |
|
</tr> |
|
</table> |
|
</center> |
|
|
|
EOT |
.endform |
.endform |
.hr |
.hr |
|
|
Line 533 sub Search {
|
Line 567 sub Search {
|
for $i (0 .. $#sar) { |
for $i (0 .. $#sar) { |
$sar[$i] = $dbh->quote("%${sar[$i]}%"); |
$sar[$i] = $dbh->quote("%${sar[$i]}%"); |
} |
} |
|
$_.=' ' foreach (@fields); # Это чтобы последнее слово поля |
|
# не сливалось с первым словом |
|
# следующего поля, R7 |
my($f) = "CONCAT(" . join(',', @fields) . ")"; |
my($f) = "CONCAT(" . join(',', @fields) . ")"; |
if (param('all') eq 'yes') { |
if (param('all') eq 'yes') { |
$sstr = join " AND $f LIKE ", @sar; |
$sstr = join " AND $f LIKE ", @sar; |
Line 685 sub PrintList {
|
Line 721 sub PrintList {
|
sub PrintSearch { |
sub PrintSearch { |
my ($dbh, $sstr, $metod,$was) = @_; |
my ($dbh, $sstr, $metod,$was) = @_; |
my $t=time; |
my $t=time; |
print h2("Поиск в базе вопросов"); |
# print h2("Поиск в базе вопросов"); |
print printform; |
print printform; |
my @allnf; |
my @allnf; |
my @Questions; |
my @Questions; |
Line 776 print "$query" if $printqueries;
|
Line 812 print "$query" if $printqueries;
|
|
|
sub PrintRandom { |
sub PrintRandom { |
my ($dbh, $type, $num, $text) = @_; |
my ($dbh, $type, $num, $text) = @_; |
|
my $razd=param('razd'); |
|
my $answer=$razd?0:1; |
my (@Questions) = &Get12Random($dbh, $type, $num); |
my (@Questions) = &Get12Random($dbh, $type, $num); |
my ($output, $i) = ('', 0); |
my ($output, $i) = ('', 0); |
|
|
Line 790 sub PrintRandom {
|
Line 828 sub PrintRandom {
|
# Passing DB handler, question ID, print answer, question |
# Passing DB handler, question ID, print answer, question |
# number, print title, print text/html |
# number, print title, print text/html |
$output .= |
$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; |
return $output; |
} |
} |
|
|
Line 811 sub PrintTournament {
|
Line 858 sub PrintTournament {
|
%Tournament = &GetTournament($dbh, $Id) if ($Id); |
%Tournament = &GetTournament($dbh, $Id) if ($Id); |
|
|
my ($URL) = $Tournament{'URL'}; |
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 ($Info) = $Tournament{'Info'}; |
my ($Copyright) = $Tournament{'Copyright'}; |
my ($Copyright) = $Tournament{'Copyright'}; |
my $fname=$Tournament{'FileName'}; |
my $fname=$Tournament{'FileName'}; |
Line 1036 sub PrintField {
|
Line 1085 sub PrintField {
|
$value =~ s/^\s+/<br> /mg; |
$value =~ s/^\s+/<br> /mg; |
$value =~ s/^\|([^\n]*)/<pre>$1<\/pre>/mg; |
$value =~ s/^\|([^\n]*)/<pre>$1<\/pre>/mg; |
$value =~ s/\s+-+\s+/ – /mg; |
$value =~ s/\s+-+\s+/ – /mg; |
|
$value =~ s/(http:\/\/\S+[^\s\)\(\,\.])/<a href="$1">$1<\/a>/g if $header !~ /^Авто/; |
|
# $value =~ s/(http:\/\/(?:\w+.)+[\w\\\~]+(\?[^\s.]+)?)/<a href="$1">$1<\/a>/g if $header !~ /^Авто/; |
# $value =~ s/(\s)"/$1“/mg; |
# $value =~ s/(\s)"/$1“/mg; |
# $value =~ s/^"/“/mg; |
# $value =~ s/^"/“/mg; |
# $value =~ s/"/”/mg; |
# $value =~ s/"/”/mg; |
Line 1055 sub PrintQuestion {
|
Line 1106 sub PrintQuestion {
|
$qnum = $Question{'Number'} |
$qnum = $Question{'Number'} |
if ($qnum == 0); |
if ($qnum == 0); |
if (!$text) { |
if (!$text) { |
$output .= hr({width=>"50%"}); |
$output .= hr({width=>"50%"}) if $answer>=0; |
if ($title) { |
if ($title) { |
my (%Tour) = GetTournament($dbh, $Question{'ParentId'}); |
my (%Tour) = GetTournament($dbh, $Question{'ParentId'}); |
my (%Tournament) = GetTournament($dbh, $Tour{'ParentId'}); |
my (%Tournament) = GetTournament($dbh, $Tour{'ParentId'}); |
my $fname=$Tournament{'FileName'}; |
my $fname=$Tournament{'FileName'}; |
|
#return "" if $fname=~/mgp0203/; |
$fname=~s/\.txt//; |
$fname=~s/\.txt//; |
$titles .= |
$titles .= |
dd(img({src=>"/icons/folder.open.gif"}) . " " . |
dd(img({src=>"/icons/folder.open.gif"}) . " " . |
Line 1072 sub PrintQuestion {
|
Line 1124 sub PrintQuestion {
|
} |
} |
|
|
|
|
$output.= "<a NAME=\"$qnum\">"; |
$output.= "<a NAME=\"$qnum\">" 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 .= |
$output .= |
&PrintField("Ответ", $Question{'Answer'}, $text); |
&PrintField("Ответ", $Question{'Answer'}, $text); |
|
|
if ($Question{'Authors'}) { |
if ($Question{'Authors'} ) { |
my $q=$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.Id,Name, Surname, Nicks from Authors, A2Q |
where Authors.Id=Author And Question=$Id"); |
where Authors.Id=Author And Question=$Id"); |
$sth->execute; |
$sth->execute; |
my ($AuthorId,$Name, $Surname,$other,$Nicks); |
my ($AuthorId,$Name, $Surname,$other,$Nicks); |
|
if (!$text) { |
while ((($AuthorId,$Name, $Surname,$Nicks)=$sth->fetchrow),$AuthorId) |
while ((($AuthorId,$Name, $Surname,$Nicks)=$sth->fetchrow),$AuthorId) |
{ |
{ |
my ($firstletter)=$Name=~m/^./g; |
my ($firstletter)=$Name=~m/^./g; |
Line 1109 sub PrintQuestion {
|
Line 1161 sub PrintQuestion {
|
} |
} |
$q=~s/($sha)/a({href=>url."?qofauthor=$AuthorId"},$1)/ei; |
$q=~s/($sha)/a({href=>url."?qofauthor=$AuthorId"},$1)/ei; |
} |
} |
|
} |
$output .= &PrintField("Автор(ы)", $q, $text); |
$output .= &PrintField("Автор(ы)", $q, $text); |
|
|
} |
} |
Line 1151 EOTT
|
Line 1203 EOTT
|
} |
} |
|
|
|
|
|
|
$output.="</span>" |
$output.="</span>" |
|
|
} |
} |
|
$output=~s/\(pic: ([^\)]*)\)/<p><img src="\/znatoki\/images\/db\/$1"><p>/g unless $text; |
$output.=br.a({href=> url."?metod=proxy&qid=$Id"}, 'Близкие вопросы').p |
$output.=br.a({href=> url."?metod=proxy&qid=$Id"}, 'Близкие вопросы').p |
if $answer; |
if $answer>0 && !$text; |
return $output; |
return $output; |
} |
} |
|
|
Line 1581 MAIN:
|
Line 1635 MAIN:
|
-author=>'dimrub@icomverse.com', |
-author=>'dimrub@icomverse.com', |
-bgcolor=>'#fff0e0', |
-bgcolor=>'#fff0e0', |
-vlink=>'#800020'); |
-vlink=>'#800020'); |
|
print "<style> |
|
td {font-size: 9pt; font-family : sans-serif} |
|
th {font-size: 9pt; font-family : sans-serif} |
|
</style>\n"; |
|
|
print &Include_virtual("../dimrub/db/reklama.html"); |
print &Include_virtual("../dimrub/db/reklama.html"); |
} |
} |
|
|