version 1.57, 2002/01/08 23:15:31
|
version 1.82, 2003/01/12 10:01:00
|
Line 2
|
Line 2
|
|
|
use DBI; |
use DBI; |
use CGI ':all'; |
use CGI ':all'; |
#use Text::Query; |
|
use strict; |
use strict; |
use Time::Local; |
use Time::Local; |
use POSIX qw(locale_h); |
use POSIX qw(locale_h); |
use locale; |
use locale; |
open STDERR, ">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 16 if (param('debug')) {$debug=1; $printque
|
Line 16 if (param('debug')) {$debug=1; $printque
|
my %fieldname= (0,'Question', 1, 'Answer', 2, 'Comments', 3, 'Authors', 4, 'Sources'); |
my %fieldname= (0,'Question', 1, 'Answer', 2, 'Comments', 3, 'Authors', 4, 'Sources'); |
my %rusfieldname=('Question','÷ÏÐÒÏÓ', 'Answer', 'ïÔ×ÅÔ', |
my %rusfieldname=('Question','÷ÏÐÒÏÓ', 'Answer', 'ïÔ×ÅÔ', |
'Comments', 'ëÏÍÍÅÎÔÁÒÉÉ', 'Authors', 'á×ÔÏÒ', |
'Comments', 'ëÏÍÍÅÎÔÁÒÉÉ', 'Authors', 'á×ÔÏÒ', |
'Sources', 'éÓÔÏÞÎÉË','old','óÔÁÒÙÊ','rus','îÏ×ÙÊ'); |
'Sources', 'éÓÔÏÞÎÉË','old','óÔÁÒÙÊ','rus','îÏ×ÙÊ', |
|
'chgk', 'þçë', 'brain', 'âÒÅÊÎ-ÒÉÎÇ','game', 'ó×ÏÑ ÉÇÒÁ', |
|
'ehruditka', 'üÒÕÄÉÔËÁ', 'beskrylka', 'âÅÓËÒÙÌËÁ', 'igp', 'éÎÔÅÒÎÅÔ' |
|
); |
my %searchin; |
my %searchin; |
my $rl=qr/[ÊÃÕËÅÎÇÛÝÚÈßÆÙ×ÁÐÒÏÌÄÖÜÑÞÓÍÉÔØÂÀ£]/; |
my $rl=qr/[ÊÃÕËÅÎÇÛÝÚÈßÆÙ×ÁÐÒÏÌÄÖÜÑÞÓÍÉÔØÂÀ£]/; |
my $RL=qr/[êãõëåîçûýúèÿüöäìïòðá÷ùæñþóíéôøâà³]/; |
my $RL=qr/[êãõëåîçûýúèÿüöäìïòðá÷ùæñþóíéôøâà³]/; |
Line 30 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 39 my $all=param('all');
|
Line 42 my $all=param('all');
|
$all=0 if lc $all eq 'no'; |
$all=0 if lc $all eq 'no'; |
my ($PWD) = `pwd`; |
my ($PWD) = `pwd`; |
chomp $PWD; |
chomp $PWD; |
my ($SRCPATH) = "$PWD/../dimrub/src"; |
my ($SRCPATH) = "/home/piataev/public_html/dimrub/src"; |
my ($ZIP) = "/home/piataev/bin/zip"; |
my ($ZIP) = "/usr/local/bin/zip"; |
my $DUMPFILE = "/tmp/chgkdump"; |
my $DUMPFILE = "/tmp/chgkdump"; |
my ($SENDMAIL) = "/usr/sbin/sendmail"; |
my ($SENDMAIL) = "/usr/sbin/sendmail"; |
|
my ($TMPDIR) = "/var/tmp"; |
my ($TMSECS) = 30*24*60*60; |
my ($TMSECS) = 30*24*60*60; |
my (%RevMonths) = |
my (%RevMonths) = |
('Jan', '0', 'Feb', '1', 'Mar', '2', 'Apr', '3', 'May', '4', 'Jun', '5', |
('Jan', '0', 'Feb', '1', 'Mar', '2', 'Apr', '3', 'May', '4', 'Jun', '5', |
Line 51 my (%RevMonths) =
|
Line 55 my (%RevMonths) =
|
'ñÎ×', '0', 'æÅ×', 1, 'íÁÒ', 2, 'áÐÒ', 3, 'íÁÊ', '4', |
'ñÎ×', '0', 'æÅ×', 1, 'íÁÒ', 2, 'áÐÒ', 3, 'íÁÊ', '4', |
'éÀÎ', '5', 'éÀÌ', 6, 'á×Ç', '7', 'óÅÎ', '8', |
'éÀÎ', '5', 'éÀÌ', 6, 'á×Ç', '7', 'óÅÎ', '8', |
'ïËÔ', '9', 'îÏÑ', '19', 'äÅË', '11'); |
'ïËÔ', '9', 'îÏÑ', '19', 'äÅË', '11'); |
|
my @months=('000','Jan',"Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct", |
|
"Nov","Dec"); |
|
|
|
|
# Determine whether the given time is within 2 months from now. |
# Determine whether the given time is within 2 months from now. |
sub NewEnough { |
sub NewEnough { |
Line 106 sub GetTourQuestions {
|
Line 113 sub GetTourQuestions {
|
my (@arr, @Questions); |
my (@arr, @Questions); |
|
|
my ($sth) = $dbh->prepare("SELECT QuestionId FROM Questions |
my ($sth) = $dbh->prepare("SELECT QuestionId FROM Questions |
WHERE ParentId=$ParentId"); |
WHERE ParentId=$ParentId order by Number"); |
|
|
$sth->execute; |
$sth->execute; |
|
|
Line 157 sub printform
|
Line 164 sub printform
|
my $inputstring=textfield(-name=>'sstr', |
my $inputstring=textfield(-name=>'sstr', |
-default=>param('sstr')||'', |
-default=>param('sstr')||'', |
-size=>30, |
-size=>30, |
-maxlength=>30); |
-maxlength=>50); |
my $qnumber="÷Ù×ÏÄÉÔØ ÐÏ".br. textfield(-name=>'kvo', |
my $qnumber="÷Ù×ÏÄÉÔØ ÐÏ".br. textfield(-name=>'kvo', |
-default=>param('kvo')||'150', |
-default=>param('kvo')||'150', |
-size=>3, |
-size=>3, |
Line 167 sub printform
|
Line 174 sub printform
|
@df=('Question', 'Answer') unless @df; |
@df=('Question', 'Answer') unless @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=('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'], |
my $metod=radio_group(-name=>'metod',-values=>['old','rus'], |
-default=>(param('metod')||'rus'), |
-default=>(param('metod')||'rus'), |
-labels=>\%rusfieldname); |
-labels=>\%rusfieldname); |
Line 185 table(Tr
|
Line 196 table(Tr
|
( |
( |
td({-valign=>'TOP'},$inputstring.$submit.p."íÅÔÏÄ: $metod".p."óÌÏ×Á: $all"), |
td({-valign=>'TOP'},$inputstring.$submit.p."íÅÔÏÄ: $metod".p."óÌÏ×Á: $all"), |
td({-valign=>'TOP'},(' 'x 8).'ðÏÌÑ:'), |
td({-valign=>'TOP'},(' 'x 8).'ðÏÌÑ:'), |
td({-valign=>'TOP'},$fields), td(" "x5), |
td({-valign=>'TOP'},$fields), |
|
td({-valign=>'TOP'},(' 'x 1).'ôÉÐÙ:'), |
|
td({-valign=>'TOP'},$types), td(" "x5), |
td({-valign=>'TOP'},$qnumber) |
td({-valign=>'TOP'},$qnumber) |
) |
) |
) |
) |
Line 354 print "$query\n",br if $printqueries;
|
Line 367 print "$query\n",br if $printqueries;
|
{ |
{ |
($field,$lo,$hi,$wordnumber)=@blob[$ii..($ii+3)]; |
($field,$lo,$hi,$wordnumber)=@blob[$ii..($ii+3)]; |
$ii+=4; |
$ii+=4; |
$number=$lo+$hi*256; |
my $addnumber=($field >> 4) << 16; |
$field=$fieldname{$field}; |
$number=(($field >> 4) << 16)+($hi << 8) + $lo; |
|
$field=$fieldname{$field & 0xF}; |
if ($searchin{$field}) |
if ($searchin{$field}) |
{ |
{ |
push @{$tasksof{$i}{$number}}, $wordnumber; |
push @{$tasksof{$i}{$number}}, $wordnumber; |
Line 520 sub Search {
|
Line 534 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; |
} else { |
} else { |
$sstr = join " OR $f LIKE ", @sar; |
$sstr = join " OR $f LIKE ", @sar; |
} |
} |
|
|
my $query; |
my $query; |
$query="SELECT QuestionId FROM Questions |
$query="SELECT QuestionId FROM Questions |
WHERE $f LIKE $sstr ORDER BY QuestionId"; |
WHERE ($f LIKE $sstr) AND (".&makewhere.") ORDER BY QuestionId"; |
|
|
|
|
print $query if $printqueries; |
print $query if $printqueries; |
Line 543 print $query if $printqueries;
|
Line 559 print $query if $printqueries;
|
} |
} |
$sth->finish; |
$sth->finish; |
print "@Questions" if $printqueries; |
print "@Questions" if $printqueries; |
|
|
return @Questions; |
return @Questions; |
} |
} |
|
|
|
sub makewhere { |
|
my @type=param('type'); |
|
my $type=''; |
|
|
|
$type .= ($_=$TypeName{$_}) foreach @type; |
|
my $where=' 0 '; |
|
foreach (@type) { |
|
$where.= " OR (Type ='$_') OR (Type ='$_ä') "; |
|
} |
|
$where.= "OR (Type='þâ')" if ($type=~/þ|â/); |
|
return $where; |
|
} |
|
|
# Substitute every letter by a pair (for case insensitive search). |
# Substitute every letter by a pair (for case insensitive search). |
my (@letters) = qw/Áá Ââ ×÷ Çç Ää Åå Öö Úú Éé Êê Ëë Ìì Íí Îî Ïï |
my (@letters) = qw/Áá Ââ ×÷ Çç Ää Åå Öö Úú Éé Êê Ëë Ìì Íí Îî Ïï |
Ðð Òò Óó Ôô Õõ Ææ Èè Ãã Þþ Ûû Ýý Øø Ùù Üü Àà Ññ/; |
Ðð Òò Óó Ôô Õõ Ææ Èè Ãã Þþ Ûû Ýý Øø Ùù Üü Àà Ññ/; |
Line 575 sub PrintList {
|
Line 605 sub PrintList {
|
my $qs=query_string; |
my $qs=query_string; |
$qs=~s/\;/\&/g; |
$qs=~s/\;/\&/g; |
$qs=~s/\&first\=[^\&]+//g; |
$qs=~s/\&first\=[^\&]+//g; |
my $sstr=param('sstr'); |
my $sstr=param('sstr')||''; |
$qs=~s/sstr=[^\&]+/sstr=$sstr/; |
$qs=~s/sstr=[^\&]+/sstr=$sstr/; |
$qs=~s/\&was=[^\&]+//; |
$qs=~s/\&was=[^\&]+//; |
$qs.="&was=$was"; |
$qs.="&was=$was"||''; |
if ($first>$kvo*3+1) |
if ($first>$kvo*3+1) |
{ |
{ |
$nav.= |
$nav.= |
Line 640 sub PrintList {
|
Line 670 sub PrintList {
|
|
|
print "$nav".br."\n"; |
print "$nav".br."\n"; |
for (my $i = $first; $i <= $last; $i++) { |
for (my $i = $first; $i <= $last; $i++) { |
my $output = &PrintQuestion($dbh, $$Questions[$i-1], 1, $i, 1); |
my $output = &PrintQuestion($dbh, $$Questions[$i-1], 1, 0, 1); |
if (param('metod') eq 'rus' || param('metod') eq 'proxy') |
if (param('metod') && (param('metod') eq 'rus' || param('metod') eq 'proxy')) |
{ |
{ |
$output=~s/\b($shablon)\b/\<strong\>$1\<\/strong\>/gi; |
$output=~s/\b($shablon)\b/\<strong\>$1\<\/strong\>/gi; |
} else { |
} else { |
Line 668 sub PrintSearch {
|
Line 698 sub PrintSearch {
|
$sth->execute; |
$sth->execute; |
my ($q,$nf); |
my ($q,$nf); |
($sstr, $q,$nf)=($sth->fetchrow); |
($sstr, $q,$nf)=($sth->fetchrow); |
@Questions=unpack 'S*',$q; |
@Questions=unpack 'L*',$q; |
@allnf=unpack 'S*',$nf; |
@allnf=unpack 'L*',$nf; |
$sth->finish; |
$sth->finish; |
} else |
} else |
{ |
{ |
@Questions=&Search($dbh, \$sstr,$metod,$all,\@allnf); |
@Questions=&Search($dbh, \$sstr,$metod,$all,\@allnf); |
my $tmp=$dbh->quote(pack("S*",@Questions)); |
my $tmp=$dbh->quote(pack("L*",@Questions)); |
my $qsstr=$dbh->quote($sstr); |
my $qsstr=$dbh->quote($sstr); |
my $nf=$dbh->quote(pack("S*", @allnf)); |
my $nf=$dbh->quote(pack("L*", @allnf)); |
my $ss=200; |
my $ss=200; |
do |
do |
{ |
{ |
Line 734 print "$query" if $printqueries;
|
Line 764 print "$query" if $printqueries;
|
$sstr = '[ \.\,:;]' . $sstr . '[ \.\,:\;]'; |
$sstr = '[ \.\,:;]' . $sstr . '[ \.\,:\;]'; |
} |
} |
|
|
$sstr =~ s/(.)/&NoCase($1)/ge; |
# $sstr =~ s/(.)/&NoCase($1)/ge; |
|
|
my @sar; |
my @sar; |
if ($metod ne 'rus') |
if ($metod ne 'rus') |
{ |
{ |
(@sar) = split(' ', $sstr); |
my $ss=$sstr; |
|
(@sar) = split(' ', $ss); |
|
s/(\W)/\\$1/g foreach (@sar); |
$shablon=join "|",@sar; |
$shablon=join "|",@sar; |
} |
} |
PrintList($dbh,\@Questions,$shablon,$was); |
PrintList($dbh,\@Questions,$shablon,$was); |
Line 747 print "$query" if $printqueries;
|
Line 779 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 761 sub PrintRandom {
|
Line 795 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; |
} |
} |
|
|
sub PrintEditor { |
sub PrintEditor { |
my $t=shift; #ÓÓÙÌËÁ ÎÁ èÜÛ Ó ÐÏÌÑÍÉ |
my $t=shift; #ÓÓÙÌËÁ ÎÁ èÜÛ Ó ÐÏÌÑÍÉ |
my $ed=$$t{'Editors'}; |
my $ed=$$t{'Editors'}||''; |
my $edname=($ed=~/\,/ ) ? "òÅÄÁËÔÏÒÙ" : "òÅÄÁËÔÏÒ" ; |
my $edname=($ed=~/\,/ ) ? "òÅÄÁËÔÏÒÙ" : "òÅÄÁËÔÏÒ" ; |
return $ed? h4({align=>"center"},"$edname: $ed" ): ''; |
return $ed? h4({align=>"center"},"$edname: $ed" ): ''; |
} |
} |
Line 782 sub PrintTournament {
|
Line 825 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 793 sub PrintTournament {
|
Line 838 sub PrintTournament {
|
/ç/ && do { |
/ç/ && do { |
$output .= h2({align=>"center"}, |
$output .= h2({align=>"center"}, |
"çÒÕÐÐÁ: $Tournament{'Title'} ", |
"çÒÕÐÐÁ: $Tournament{'Title'} ", |
"$Tournament{'PlayedAt'}") . p . "\n"; |
$Tournament{'PlayedAt'}||'') . p . "\n"; |
last; |
last; |
}; |
}; |
/þ/ && do { |
/þ/ && do { |
Line 816 sub PrintTournament {
|
Line 861 sub PrintTournament {
|
} |
} |
} else { |
} else { |
my ($qnum) = GetQNum($dbh); |
my ($qnum) = GetQNum($dbh); |
$output .= h2("âÁÎË ÷ÏÐÒÏÓÏ×: $qnum ×ÏÐÒÏÓÏ×") . p . "\n"; |
$output .= h2("âÁÎË ÷ÏÐÒÏÓÏ×: $qnum ×ÏÐÒÏÓ".&Suffix($qnum)) |
|
. p . "\n"; |
} |
} |
|
|
for ($i = 0; $i <= $#Tours; $i++) { |
for ($i = 0; $i <= $#Tours; $i++) { |
Line 835 sub PrintTournament {
|
Line 881 sub PrintTournament {
|
$qnum = ''; |
$qnum = ''; |
} |
} |
if ($Tournament{'Type'} =~ /ç/) { |
if ($Tournament{'Type'} =~ /ç/) { |
|
$SingleTour=0; |
$imgsrc = "/icons/folder.gif"; |
$imgsrc = "/icons/folder.gif"; |
$alt = "[*]"; |
$alt = "[*]"; |
} else { |
} else { |
Line 868 sub PrintTournament {
|
Line 915 sub PrintTournament {
|
); |
); |
} else { |
} else { |
$list .= dd(a({href=>url . "?tour=$textid&comp=1"}, |
$list .= dd(a({href=>url . "?tour=$textid&comp=1"}, |
img({src=>'/icons/compressed.gif', alt=>'[ZIP]', border=>1})) |
img({src=>'/icons/compressed.gif', alt=>'[ZIP]', border=>1})). " " . |
. " " . img({src=>$imgsrc, alt=>$alt}) |
img({src=>$imgsrc, alt=>$alt}) |
. " " . a({href=>url . "?tour=$textid&answer=0"}, |
. " " . a({href=>url . "?tour=$textid&answer=0"}, |
$Tournament{'Title'}. " ". |
$Tournament{'Title'}. " ". |
$Tournament{'PlayedAt'}) . $qnum); |
$Tournament{'PlayedAt'}||'') . $qnum); |
} |
} |
} |
} |
$output .= dl($list); |
$output .= dl($list); |
|
|
if ($URL) { |
if ($URL) { |
|
if (url=~/zaba\.ru/ && $URL=~/^\//){$URL="http://info.chgk.info$URL"} |
$output .= |
$output .= |
p("äÏÐÏÌÎÉÔÅÌØÎÁÑ ÉÎÆÏÒÍÁÃÉÑ Ï ÜÔÏÍ ÔÕÒÎÉÒÅ - ÐÏ ÁÄÒÅÓÕ " . |
p("äÏÐÏÌÎÉÔÅÌØÎÁÑ ÉÎÆÏÒÍÁÃÉÑ Ï ÜÔÏÍ ÔÕÒÎÉÒÅ - ÐÏ ÁÄÒÅÓÕ " . |
a({-'href'=>$URL}, $URL)); |
a({-'href'=>$URL}, $URL)); |
Line 942 sub PrintTour {
|
Line 990 sub PrintTour {
|
my ($suffix) = &Suffix($qnum); |
my ($suffix) = &Suffix($qnum); |
|
|
$output .= h2({align=>"center"}, $Tournament{"Title"}, |
$output .= h2({align=>"center"}, $Tournament{"Title"}, |
$Tournament{'PlayedAt'}, |
$Tournament{'PlayedAt'}||'', |
"<br>", $Tour{"Title"} . |
"<br>", $Tour{"Title"} . |
" ($qnum ×ÏÐÒÏÓ$suffix)\n") . p; |
" ($qnum ×ÏÐÒÏÓ$suffix)\n") . p; |
$output .=&PrintEditor(\%Tour); |
$output .=&PrintEditor(\%Tour); |
Line 999 sub PrintTour {
|
Line 1047 sub PrintTour {
|
sub PrintField { |
sub PrintField { |
my ($header, $value, $text) = @_; |
my ($header, $value, $text) = @_; |
if ($text) { |
if ($text) { |
$value =~ s/<[\/\w]*>//sg; |
$value =~ s/<[\/\w]*?>//sg; |
} else { |
} else { |
$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/(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/^"/“/mg; |
|
# $value =~ s/"/”/mg; |
} |
} |
|
|
|
|
return $text ? "$header:\n$value\n\n" : |
return $text ? "$header:\n$value\n\n" : |
strong("$header: ") . $value . p . "\n"; |
strong("$header: ") . $value . p . "\n"; |
} |
} |
Line 1015 sub PrintQuestion {
|
Line 1070 sub PrintQuestion {
|
my ($dbh, $Id, $answer, $qnum, $title, $text) = @_; |
my ($dbh, $Id, $answer, $qnum, $title, $text) = @_; |
my ($output, $titles) = ('', ''); |
my ($output, $titles) = ('', ''); |
my (%Question) = &GetQuestion($dbh, $Id); |
my (%Question) = &GetQuestion($dbh, $Id); |
|
$qnum = $Question{'Number'} |
|
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"}) . " " . |
a({href=>url . "?tour=$fname"}, $Tournament{'Title'}, $Tournament{'PlayedAt'})); |
a({href=>url . "?tour=$fname"}, $Tournament{'Title'}, $Tournament{'PlayedAt'}||'')); |
$titles .= |
$titles .= |
dl(dd(img({src=>"/icons/folder.open.gif"}) . " " . |
dl(dd(img({src=>"/icons/folder.open.gif"}) . " " . |
a({href=>url . "?tour=$fname.$Tour{Number}"}, $Tour{'Title'}))); |
a({href=>url . "?tour=$fname.$Tour{Number}#$qnum"}, $Tour{'Title'}))); |
} |
} |
$output .= dl(strong($titles)); |
$output .= dl(strong($titles)); |
} |
} |
|
|
$qnum = $Question{'Number'} |
|
if ($qnum == 0); |
|
|
|
$output .= |
$output.= "<a NAME=\"$qnum\">" unless $text; |
&PrintField("÷ÏÐÒÏÓ $qnum", $Question{'Question'}, $text); |
|
|
|
if ($answer) { |
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; |
# $Name=~s/\./\\\./g; |
$Name=~s/\./\\\./g; |
# my $sha="(?:$Name\\s+$Surname)|(?:$Surname\\s+$Name)|(?:$firstletter\\.\\s*$Surname)|(?:$Surname\\s+$firstletter\\.)|(?:$Surname)|(?:$Name)"; |
my $sha="(?:$Name\\s+$Surname)|(?:$Surname\\s+$Name)|(?:$firstletter\\.\\s*$Surname)|(?:$Surname\\s+$firstletter\\.)|(?:$Surname)|(?:$Name)"; |
# if ($Nicks) |
if ($Nicks) |
# { |
{ |
# $Nicks=~s/^\|//; |
$Nicks=~s/^\|//; |
# foreach (split /\|/, $Nicks) |
foreach (split /\|/, $Nicks) |
# { |
{ |
# s/\s+/ /g; |
s/\s+/ /g; |
# s/\s+$//; |
s/\s+$//; |
# s/ /\\s+/g; |
s/ /\\s+/g; |
# s/\./\\\./g; |
s/\./\\\./g; |
# if (s/>$//) {$sha="$sha|(?:$_)"} |
if (s/>$//) {$sha="$sha|(?:$_)"} |
# else {$sha="(?:$_)|$sha"} |
else {$sha="(?:$_)|$sha"} |
# } |
} |
# } |
} |
# $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); |
|
|
# $output.= &PrintField("äÒÕÇÉÅ ×ÏÐÒÏÓÙ", $other); |
|
} |
} |
|
|
if ($Question{'Sources'}) { |
if ($Question{'Sources'}) { |
Line 1084 sub PrintQuestion {
|
Line 1141 sub PrintQuestion {
|
$output .= &PrintField("ëÏÍÍÅÎÔÁÒÉÉ", $Question{'Comments'}, $text); |
$output .= &PrintField("ëÏÍÍÅÎÔÁÒÉÉ", $Question{'Comments'}, $text); |
} |
} |
} |
} |
# $output.=br.a({href=> url."?metod=proxy&qid=$Id"}, 'âÌÉÚËÉÅ ×ÏÐÒÏÓÙ').p |
elsif ($answer==2) { |
# if $answer; |
my $text=$Question{'Answer'}; |
|
$text=~s/\n/<option>/mg; |
|
$output.="<select><option selected>ïÔ×ÅÔ:<option>$text</select>"; |
|
$text=$Question{'Comments'}||''; |
|
if ($text) { |
|
$text=~s/\n/<option>/mg; |
|
$output.="<select><option selected>ëÏÍÍÅÎÔÁÒÉÊ:<option>$text</select>" |
|
} |
|
} |
|
elsif ($answer==3) { |
|
$output.= <<EOTT |
|
<div align=right STYLE="cursor:hand;" OnStart="toggle(document.all.HideShow$qnum);" OnClick="toggle(document.all.HideShow$qnum);"> |
|
<font size=-2 color=red> ðÏËÁÚÁÔØ/ÕÂÒÁÔØ ÏÔ×ÅÔ</font></div> |
|
<span style="display:none" id=HideShow$qnum> |
|
EOTT |
|
.&PrintField("ïÔ×ÅÔ", $Question{'Answer'}, $text); |
|
if ($Question{'Authors'}) { |
|
$output .= &PrintField("á×ÔÏÒ(Ù)", $Question{'Authors'}, $text); |
|
} |
|
if ($Question{'Sources'}) { |
|
$output .= &PrintField("éÓÔÏÞÎÉË(É)", $Question{'Sources'}, $text); |
|
} |
|
|
|
if ($Question{'Comments'}) { |
|
$output .= &PrintField("ëÏÍÍÅÎÔÁÒÉÉ", $Question{'Comments'}, $text); |
|
} |
|
|
|
$output=~s/\(pic: ([^\)]*)\)/<img src="\/images\/$1">/g; |
|
|
|
$output.="</span>" |
|
|
|
} |
|
$output.=br.a({href=> url."?metod=proxy&qid=$Id"}, 'âÌÉÚËÉÅ ×ÏÐÒÏÓÙ').p |
|
if $answer>0 && !$text; |
return $output; |
return $output; |
} |
} |
|
|
Line 1115 sub Get12Random {
|
Line 1205 sub Get12Random {
|
my ($qnum) = &GetMaxQId($dbh); |
my ($qnum) = &GetMaxQId($dbh); |
my (%chosen); |
my (%chosen); |
srand; |
srand; |
|
|
my $where=0; |
my $where=0; |
my $r=int (rand(10000)); |
my $r=int (rand(10000)); |
|
|
Line 1127 sub Get12Random {
|
Line 1216 sub Get12Random {
|
|
|
$q="select QuestionId, QuestionId/$r-floor(QuestionId/$r) as val |
$q="select QuestionId, QuestionId/$r-floor(QuestionId/$r) as val |
from Questions where $where order by val limit $num"; |
from Questions where $where order by val limit $num"; |
|
|
# ëÏÇÄÁ ÎÁ ËÕÌÉÞËÁÈ ÐÏÑ×ÉÔÓÑ mysql >=3.23 ÎÁÄÏ ÚÁÍÅÎÉÔØ ÎÁ order by rand(); |
# ëÏÇÄÁ ÎÁ ËÕÌÉÞËÁÈ ÐÏÑ×ÉÔÓÑ mysql >=3.23 ÎÁÄÏ ÚÁÍÅÎÉÔØ ÎÁ order by rand(); |
|
|
$sth=$dbh->prepare($q); |
$sth=$dbh->prepare($q); |
Line 1168 sub PrintArchive {
|
Line 1256 sub PrintArchive {
|
|
|
my (%Tournament) = &GetTournament($dbh, $Id); |
my (%Tournament) = &GetTournament($dbh, $Id); |
my (@Tours) = &GetTours($dbh, $Id); |
my (@Tours) = &GetTours($dbh, $Id); |
|
|
if ($Tournament{'Type'} =~ /ç/ || $Id == 0) { |
if ($Tournament{'Type'} =~ /ç/ || $Id == 0) { |
for ($i = 0; $i <= $#Tours; $i++) { |
for ($i = 0; $i <= $#Tours; $i++) { |
push(@list ,&PrintArchive($dbh, $Tours[$i])); |
push(@list ,&PrintArchive($dbh, $Tours[$i])); |
} |
} |
return @list; |
return @list; |
} |
} |
return "$SRCPATH/$Tournament{'FileName'} "; |
# return "$SRCPATH/$Tournament{'FileName'} "; |
|
return "$TMPDIR/$Tournament{'FileName'} "; |
} |
} |
|
|
sub PrintAll { |
sub PrintAll { |
Line 1206 sub PrintAll {
|
Line 1294 sub PrintAll {
|
|
|
$output .= dd(img({src=>"/icons/folder.gif", alt=>"[*]"}) . |
$output .= dd(img({src=>"/icons/folder.gif", alt=>"[*]"}) . |
" " . a({href=>url . "?tour=$textid&answer=0"}, |
" " . a({href=>url . "?tour=$textid&answer=0"}, |
$Tournament{'Title'}) ." " . $Tournament{'PlayedAt'} . " $New"); |
$Tournament{'Title'}) ." " . ($Tournament{'PlayedAt'}||'') . " $New"); |
} |
} |
if ($Id == 0 or $Tournament{'Type'} =~ /ç/ or $Tournament{'Type'} eq '') { |
if ($Id == 0 or $Tournament{'Type'} =~ /ç/ or $Tournament{'Type'} eq '') { |
for ($i = 0; $i <= $#Tours; $i++) { |
for ($i = 0; $i <= $#Tours; $i++) { |
Line 1240 sub PrintDates {
|
Line 1328 sub PrintDates {
|
%Tournament = &GetTournament($dbh, $array[0]); |
%Tournament = &GetTournament($dbh, $array[0]); |
$list .= dd(img({src=>"/icons/folder.gif", alt=>"[*]"}) . |
$list .= dd(img({src=>"/icons/folder.gif", alt=>"[*]"}) . |
" " . a({href=>url . "?tour=$Tournament{'Id'}&answer=0"}, |
" " . a({href=>url . "?tour=$Tournament{'Id'}&answer=0"}, |
$Tournament{'Title'}, $Tournament{'PlayedAt'})); |
$Tournament{'Title'}, $Tournament{'PlayedAt'}||'')); |
} |
} |
$sth->finish; |
$sth->finish; |
$output .= dl($list); |
$output .= dl($list); |
Line 1342 a({href=>url."?authors=surname"},"ÆÁÍÉÌÉ
|
Line 1430 a({href=>url."?authors=surname"},"ÆÁÍÉÌÉ
|
} |
} |
|
|
|
|
|
sub WriteFile { |
|
my ($dbh,$fname) = @_; |
|
$fname=~s/\s+$//; |
|
$fname=~s/^\s+//; |
|
$fname=~s/\.txt$//; |
|
$fname=~s/.*\/(\w+)/$1/; |
|
|
|
my $query= "SELECT Id, Title, Copyright, Info, URL, |
|
Editors, EnteredBy, PlayedAt, CreatedAt |
|
from Tournaments where FileName=".$dbh->quote("$fname.txt"); |
|
my $sth=$dbh->prepare($query); |
|
my (%Question,%editor,%qnumber,%copyright,%author,%vid,%tourtitle); |
|
$sth->execute; |
|
my ($Id, $Title, $Copyright, $Info, $URL, |
|
$Editors, $EnteredBy, $PlayedAt, $CreatedAt)= |
|
$sth->fetchrow; |
|
return -1 unless $Id; |
|
open (OUT, ">$TMPDIR/$fname.txt") || print STDERR "Error in $fname.txt\n"; |
|
print OUT "þÅÍÐÉÏÎÁÔ:\n$Title\n\n"; |
|
my $date=$PlayedAt||'00-00-00'; |
|
my ($year,$month,$day)=split /-/, $date; |
|
# $month=0,$date=0 if $year && $month==1 && $day==1; |
|
my $pdate=sprintf("%02d-%3s-%4d",$day,$months[$month],$year); |
|
|
|
print OUT "äÁÔÁ:\n$pdate\n\n" if $date; |
|
|
|
print OUT "URL:\n$URL\n\n" if $URL; |
|
|
|
print OUT "éÎÆÏ:\n$Info\n\n" if $Info; |
|
|
|
print OUT "ëÏÐÉÒÁÊÔ:\n$Copyright\n\n" if $Copyright; |
|
|
|
print OUT "òÅÄÁËÔÏÒ:\n$Editors\n\n" if $Editors; |
|
|
|
|
|
$query= "SELECT Id, Title, Copyright, Editors from Tournaments where ParentId=$Id order by Id"; |
|
$sth=$dbh->prepare($query); |
|
$sth->execute; |
|
my ($tourid,$tourtitle,$cright,$editor,@tours,$vid,$author,$tourauthor); |
|
|
|
|
|
while (($tourid,$tourtitle,$cright,$editor)=$sth->fetchrow,$tourid) |
|
{ |
|
# $text{$tourid}="ôÕÒ:\n$tourtitle\n\n"; |
|
$query= "SELECT * from Questions where ParentId=$tourid order by QuestionId"; |
|
my $sth1=$dbh->prepare($query); |
|
$sth1->execute; |
|
push(@tours,$tourid); |
|
$tourtitle{$tourid}=$tourtitle; |
|
$copyright{$tourid}=$cright; |
|
$editor{$tourid}=$editor; |
|
$vid=''; |
|
my $author=''; |
|
my $eqauthor=1; |
|
my $qnumber=0; |
|
my @arr; |
|
while ( (@arr=$sth1->fetchrow), $arr[0]) |
|
{ |
|
my($i, $name); |
|
$i=0; |
|
$qnumber++; |
|
foreach $name (@{$sth1->{NAME}}) { |
|
if ($arr[$i]) { |
|
$arr[$i]=~s/^(.*?)\s*$/$1/; |
|
$Question{$tourid}[$qnumber]{$name} = $arr[$i]; |
|
} else { |
|
$Question{$tourid}[$qnumber]{$name} = |
|
''} |
|
$i++; |
|
} |
|
if ($vid) |
|
{ |
|
if ($vid ne $Question{$tourid}[$qnumber]{'Type'}) {print STDERR "Warning: Different types for Tournament $tourid\n"} |
|
} else |
|
{ |
|
$vid=$Question{$tourid}[$qnumber]{'Type'}; |
|
} |
|
|
|
if ($author) |
|
{ |
|
if ($author ne $Question{$tourid}[$qnumber]{'Authors'}) |
|
{ |
|
$eqauthor=0; |
|
} |
|
} else |
|
{ |
|
$author=$Question{$tourid}[$qnumber]{'Authors'}; |
|
$eqauthor=0 unless $author; |
|
} |
|
} |
|
$vid{$tourid}=$vid; |
|
$qnumber{$tourid}=$qnumber; |
|
$author{$tourid}=$eqauthor ? $author : ''; |
|
} |
|
|
|
|
|
$vid=''; |
|
my $eqvid=1; |
|
my $eqauthor=1; |
|
foreach (@tours) |
|
{ |
|
$vid||=$vid{$_}; |
|
if ($vid{$_} ne $vid) |
|
{ |
|
$eqvid=0; |
|
} |
|
$author||=$author{$_}; |
|
if (!$author{$_} || ($author{$_} ne $author)) |
|
{ |
|
$eqauthor=0; |
|
} |
|
} |
|
|
|
print OUT "÷ÉÄ:\n$vid\n\n" if $eqvid; |
|
print OUT "á×ÔÏÒ:\n$author\n\n" if $eqauthor; |
|
|
|
foreach my $tour(@tours) |
|
{ |
|
print OUT "ôÕÒ:\n$tourtitle{$tour}\n\n"; |
|
print OUT "÷ÉÄ:\n$vid{$tour}\n\n" if !$eqvid; |
|
print OUT "ëÏÐÉÒÁÊÔ:\n$copyright{$tour}\n\n" if $copyright{$tour} && ($copyright{$tour} ne $Copyright); |
|
print OUT "òÅÄÁËÔÏÒ:\n$editor{$tour}\n\n" if $editor{$tour} && ($editor{$tour} ne $Editors); |
|
$tourauthor=0; |
|
if (!$eqauthor && $author{$tour}) |
|
{ |
|
print OUT "á×ÔÏÒ:\n$author{$tour}\n\n"; |
|
$tourauthor=1; |
|
} |
|
foreach my $q(1..$qnumber{$tour}) |
|
{ |
|
print OUT "÷ÏÐÒÏÓ $q:\n".$Question{$tour}[$q]{'Question'}."\n\n"; |
|
print OUT "ïÔ×ÅÔ:\n".$Question{$tour}[$q]{'Answer'}."\n\n"; |
|
print OUT "á×ÔÏÒ:\n".$Question{$tour}[$q]{'Authors'}."\n\n" |
|
if !$tourauthor && !$eqauthor && $Question{$tour}[$q]{'Authors'}; |
|
print OUT "ëÏÍÍÅÎÔÁÒÉÊ:\n".$Question{$tour}[$q]{'Comments'}."\n\n" |
|
if $Question{$tour}[$q]{'Comments'}; |
|
print OUT "éÓÔÏÞÎÉË:\n".$Question{$tour}[$q]{'Sources'}."\n\n" |
|
if $Question{$tour}[$q]{'Sources'}; |
|
print OUT "òÅÊÔÉÎÇ:\n".$Question{$tour}[$q]{'Rating'}."\n\n" |
|
if $Question{$tour}[$q]{'Rating'}; |
|
|
|
} |
|
} |
|
|
|
close OUT; |
|
|
|
|
|
|
|
} |
|
|
|
|
MAIN: |
MAIN: |
{ |
{ |
Line 1390 if ((uc 'Á') ne 'á') {print "Koi8-r loca
|
Line 1628 if ((uc 'Á') ne 'á') {print "Koi8-r loca
|
} |
} |
$sth->finish; |
$sth->finish; |
} |
} |
|
$tour = (param('tour')) ? param('tour') : 0; |
|
my $sth; |
|
if ($tour !~ /^[0-9]*$/) { |
|
if ($tour=~/\./) |
|
{ |
|
my ($fname,$n)= split /\./ , $tour; |
|
|
|
$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=$n"); |
|
} |
|
else |
|
{ |
|
$sth = $dbh->prepare("SELECT Id FROM Tournaments |
|
WHERE FileName = '$tour.txt'"); |
|
} |
|
$sth->execute; |
|
$tour = ($sth->fetchrow)[0]; |
|
$sth->finish; |
|
} |
|
|
|
|
if (param('rand')) { |
if (param('rand')) { |
Line 1446 $sstr=~s/[^ÊÃÕËÅÎÇÛÝÚÈßÆÙ×ÁÐÒÏÌÄÖÜÑÞÓÍÉÔ
|
Line 1706 $sstr=~s/[^ÊÃÕËÅÎÇÛÝÚÈßÆÙ×ÁÐÒÏÌÄÖÜÑÞÓÍÉÔ
|
# print &PrintQuestion($dbh,$qid, 1, '!'); |
# print &PrintQuestion($dbh,$qid, 1, '!'); |
&PrintSearch($dbh, $sstr, 'proxy'); |
&PrintSearch($dbh, $sstr, 'proxy'); |
} |
} |
|
elsif (param('getfile')){ |
elsif (param('all')) { |
print &writefile |
|
} elsif (param('all')) { |
print &PrintAll($dbh, 0); |
print &PrintAll($dbh, 0); |
} elsif (param('from_year') && param('to_year')) { |
} elsif (param('from_year') && param('to_year')) { |
print &PrintDates($dbh); |
print &PrintDates($dbh); |
} elsif (param('comp')) { |
} elsif (param('comp')) { |
print header( |
print "Content-Type: application/octet-stream\n"; |
-'Content-Type' => 'application/x-zip-compressed; name="db.zip"', |
print "Content-Type: application/force-download\n"; |
-'Content-Disposition' => 'attachment; filename="db.zip"' |
print "Content-Type: application/download\n"; |
); |
print "Content-Type: application/x-zip-compressed; name=db.zip\n"; |
$tour = (param('tour')) ? param('tour') : 0; |
print "Content-Disposition: attachment; filename=db.zip \n\n"; |
|
# print header( |
|
# -'Content-Type' => 'application/x-zip-compressed; name="db.zip"', |
|
# -'Content-Type' => 'application/zip', |
|
# -'Content-Disposition' => 'attachment; filename="db.zip"' |
|
# ); |
|
$tour ||= 0; |
my (@files) = &PrintArchive($dbh, $tour); |
my (@files) = &PrintArchive($dbh, $tour); |
open F, "$ZIP -j - $SRCPATH/COPYRIGHT @files |"; |
WriteFile($dbh,$_) foreach @files; |
|
# open F, "$ZIP -j - $SRCPATH/COPYRIGHT @files |"; |
|
open F, "$ZIP -j - @files |"; |
|
binmode(F); |
|
binmode(STDOUT); |
print (<F>); |
print (<F>); |
close F; |
close F; |
$dbh->disconnect; |
$dbh->disconnect; |
Line 1475 $sstr=~s/[^ÊÃÕËÅÎÇÛÝÚÈßÆÙ×ÁÐÒÏÌÄÖÜÑÞÓÍÉÔ
|
Line 1746 $sstr=~s/[^ÊÃÕËÅÎÇÛÝÚÈßÆÙ×ÁÐÒÏÌÄÖÜÑÞÓÍÉÔ
|
exit; |
exit; |
|
|
} else { |
} else { |
$tour = (param('tour')) ? param('tour') : 0; |
my $QuestionNumber=0; |
my $sth; |
my $qnum; |
if ($tour !~ /^[0-9]*$/) { |
if ($qnum=param('qnumber')){ |
if ($tour=~/\./) |
my ($sth) = $dbh->prepare("SELECT QuestionId FROM Questions |
{ |
WHERE ParentId=$tour AND Number=$qnum"); |
my ($fname,$n)= split /\./ , $tour; |
$sth->execute; |
|
$QuestionNumber=($sth->fetchrow)[0]||0; |
$sth = $dbh->prepare( |
} |
"SELECT t2.Id FROM Tournaments as t1, |
if ($QuestionNumber) { |
Tournaments as t2 |
print &PrintQuestion($dbh, $QuestionNumber, param('answer')||0, $qnum, 1); |
WHERE t1.FileName = '$fname.txt' |
# $dbh, $Id, $answer, $qnum, $title, $text |
AND t1.Id=t2.ParentId AND t2.Number=$n"); |
} else { |
} |
print &PrintTournament($dbh, $tour, param('answer')); |
else |
} |
{ |
|
$sth = $dbh->prepare("SELECT Id FROM Tournaments |
|
WHERE FileName = '$tour.txt'"); |
|
} |
|
$sth->execute; |
|
$tour = ($sth->fetchrow)[0]; |
|
$sth->finish; |
|
} |
|
print &PrintTournament($dbh, $tour, param('answer')); |
|
} |
} |
if (!$text) { |
if (!$text) { |
print &Include_virtual("../dimrub/db/footer.html"); |
print &Include_virtual("../dimrub/db/footer.html"); |
|
print <<EEE |
|
<SCRIPT LANGUAGE="JavaScript"> |
|
function toggle(e) { |
|
if (e.style.display == "none") { |
|
e.style.display=""; |
|
} else { |
|
e.style.display = "none"; |
|
} |
|
} |
|
</SCRIPT> |
|
EEE |
|
; |
print end_html; |
print end_html; |
} |
} |
$dbh->disconnect; |
$dbh->disconnect; |