version 1.59, 2002/01/14 11:31:43
|
version 1.66, 2002/05/14 00:12:35
|
Line 43 my ($SRCPATH) = "$PWD/../dimrub/src";
|
Line 43 my ($SRCPATH) = "$PWD/../dimrub/src";
|
my ($ZIP) = "/home/piataev/bin/zip"; |
my ($ZIP) = "/home/piataev/bin/zip"; |
my $DUMPFILE = "/tmp/chgkdump"; |
my $DUMPFILE = "/tmp/chgkdump"; |
my ($SENDMAIL) = "/usr/sbin/sendmail"; |
my ($SENDMAIL) = "/usr/sbin/sendmail"; |
|
my ($TMPDIR) = "/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 52 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 157 sub printform
|
Line 161 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 641 sub PrintList {
|
Line 645 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') eq 'rus' || param('metod') eq 'proxy') |
{ |
{ |
$output=~s/\b($shablon)\b/\<strong\>$1\<\/strong\>/gi; |
$output=~s/\b($shablon)\b/\<strong\>$1\<\/strong\>/gi; |
Line 836 sub PrintTournament {
|
Line 840 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 1005 sub PrintField {
|
Line 1010 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/(\s)"/$1“/mg; |
|
# $value =~ s/^"/“/mg; |
|
# $value =~ s/"/”/mg; |
} |
} |
|
|
|
|
Line 1018 sub PrintQuestion {
|
Line 1026 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 ($title) { |
if ($title) { |
Line 1030 sub PrintQuestion {
|
Line 1040 sub PrintQuestion {
|
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.= "<a NAME=\"$qnum\">"; |
|
|
$output .= |
$output .= |
&PrintField("÷ÏÐÒÏÓ $qnum", $Question{'Question'}, $text); |
&PrintField("÷ÏÐÒÏÓ $qnum", $Question{'Question'}, $text); |
Line 1178 sub PrintArchive {
|
Line 1188 sub PrintArchive {
|
} |
} |
return @list; |
return @list; |
} |
} |
return "$SRCPATH/$Tournament{'FileName'} "; |
# return "$SRCPATH/$Tournament{'FileName'} "; |
|
return "$TMPDIR/$Tournament{'FileName'} "; |
} |
} |
|
|
sub PrintAll { |
sub PrintAll { |
Line 1345 a({href=>url."?authors=surname"},"ÆÁÍÉÌÉ
|
Line 1356 a({href=>url."?authors=surname"},"ÆÁÍÉÌÉ
|
} |
} |
|
|
|
|
|
sub WriteFile { |
|
my ($dbh,$fname) = @_; |
|
$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 OUT "þÅÍÐÉÏÎÁÔ:\n$Title\n\n"; |
|
my $date=$PlayedAt; |
|
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) = 0; |
|
$qnumber++; |
|
foreach $name (@{$sth1->{NAME}}) { |
|
$arr[$i]=~s/^(.*?)\s*$/$1/; |
|
$Question{$tourid}[$qnumber]{$name} = $arr[$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 1461 $sstr=~s/[^ÊÃÕËÅÎÇÛÝÚÈßÆÙ×ÁÐÒÏÌÄÖÜÑÞÓÍÉÔ
|
Line 1613 $sstr=~s/[^ÊÃÕËÅÎÇÛÝÚÈßÆÙ×ÁÐÒÏÌÄÖÜÑÞÓÍÉÔ
|
); |
); |
$tour = (param('tour')) ? param('tour') : 0; |
$tour = (param('tour')) ? param('tour') : 0; |
my (@files) = &PrintArchive($dbh, $tour); |
my (@files) = &PrintArchive($dbh, $tour); |
|
WriteFile($dbh,$_) foreach @files; |
open F, "$ZIP -j - $SRCPATH/COPYRIGHT @files |"; |
open F, "$ZIP -j - $SRCPATH/COPYRIGHT @files |"; |
print (<F>); |
print (<F>); |
close F; |
close F; |
Line 1500 $sstr=~s/[^ÊÃÕËÅÎÇÛÝÚÈßÆÙ×ÁÐÒÏÌÄÖÜÑÞÓÍÉÔ
|
Line 1653 $sstr=~s/[^ÊÃÕËÅÎÇÛÝÚÈßÆÙ×ÁÐÒÏÌÄÖÜÑÞÓÍÉÔ
|
$tour = ($sth->fetchrow)[0]; |
$tour = ($sth->fetchrow)[0]; |
$sth->finish; |
$sth->finish; |
} |
} |
print &PrintTournament($dbh, $tour, param('answer')); |
my $QuestionNumber=0; |
|
my $qnum; |
|
if ($qnum=param('qnumber')){ |
|
my ($sth) = $dbh->prepare("SELECT QuestionId FROM Questions |
|
WHERE ParentId=$tour AND Number=$qnum"); |
|
$sth->execute; |
|
$QuestionNumber=($sth->fetchrow)[0]||0; |
|
} |
|
if ($QuestionNumber) { |
|
print &PrintQuestion($dbh, $QuestionNumber, param('answer')||0, $qnum, 1); |
|
# $dbh, $Id, $answer, $qnum, $title, $text |
|
} else { |
|
print &PrintTournament($dbh, $tour, param('answer')); |
|
} |
} |
} |
if (!$text) { |
if (!$text) { |
print &Include_virtual("../dimrub/db/footer.html"); |
print &Include_virtual("../dimrub/db/footer.html"); |