version 1.47, 2001/12/10 20:37:23
|
version 1.52, 2001/12/17 11:47:23
|
Line 7 use strict;
|
Line 7 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, ">errors1"; |
my $printqueries=0; |
my $printqueries=0; |
my %forbidden=(); |
my %forbidden=(); |
my $debug=0; #added by R7 |
my $debug=0; #added by R7 |
Line 74 sub GetTournament {
|
Line 74 sub GetTournament {
|
foreach $name (@{$sth->{NAME}}) { |
foreach $name (@{$sth->{NAME}}) { |
$Tournament{$name} = $arr[$i++]; |
$Tournament{$name} = $arr[$i++]; |
} |
} |
|
$sth->finish; |
return %Tournament; |
return %Tournament; |
} |
} |
|
|
Line 95 sub GetQuestion {
|
Line 95 sub GetQuestion {
|
$Question{$name} = $arr[$i++]; |
$Question{$name} = $arr[$i++]; |
} |
} |
|
|
|
$sth->finish; |
return %Question; |
return %Question; |
} |
} |
|
|
Line 104 sub GetTourQuestions {
|
Line 105 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 ORDER BY QuestionId"); |
WHERE ParentId=$ParentId"); |
|
|
$sth->execute; |
$sth->execute; |
|
|
Line 112 sub GetTourQuestions {
|
Line 113 sub GetTourQuestions {
|
push @Questions, $arr[0]; |
push @Questions, $arr[0]; |
} |
} |
|
|
|
$sth->finish; |
return @Questions; |
return @Questions; |
} |
} |
|
|
Line 128 sub GetTours {
|
Line 130 sub GetTours {
|
while (@arr = $sth->fetchrow) { |
while (@arr = $sth->fetchrow) { |
push @Tours, $arr[0]; |
push @Tours, $arr[0]; |
} |
} |
|
$sth->finish; |
return @Tours; |
return @Tours; |
} |
} |
|
|
Line 142 print "timeb=".time.br if $debug;
|
Line 144 print "timeb=".time.br if $debug;
|
$sth->execute; |
$sth->execute; |
my @a=$sth->fetchrow; |
my @a=$sth->fetchrow; |
print "timee0=".time.br if $debug; |
print "timee0=".time.br if $debug; |
|
$sth->finish; |
$a[0]||0; |
$a[0]||0; |
} |
} |
|
|
Line 154 sub printform
|
Line 157 sub printform
|
-default=>param('sstr')||'', |
-default=>param('sstr')||'', |
-size=>30, |
-size=>30, |
-maxlength=>30); |
-maxlength=>30); |
|
my $qnumber="Выводить по".br. textfield(-name=>'kvo', |
|
-default=>param('kvo')||'150', |
|
-size=>3, |
|
-maxlength=>5). br."вопросов"; |
|
|
my @df=keys %searchin; |
my @df=keys %searchin; |
@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], |
Line 176 table(Tr
|
Line 184 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({-valign=>'TOP'},$fields), td(" "x5), |
|
td({-valign=>'TOP'},$qnumber) |
) |
) |
) |
) |
|
|
Line 267 print "$query",br if $printqueries;
|
Line 276 print "$query",br if $printqueries;
|
{ |
{ |
push (@{$nf[$i]},$arr[0]) |
push (@{$nf[$i]},$arr[0]) |
} |
} |
|
$sth->finish; |
} |
} |
|
|
|
|
Line 313 print STDERR "!$query\n",br if $printque
|
Line 323 print STDERR "!$query\n",br if $printque
|
{ |
{ |
@blob=(@blob,unpack 'C*',$arr[0]); |
@blob=(@blob,unpack 'C*',$arr[0]); |
} |
} |
|
$sth->finish; |
$query="select number from nf where ".(join ' OR ', @arr1); |
$query="select number from nf where ".(join ' OR ', @arr1); |
print "$query\n",br if $printqueries; |
print "$query\n",br if $printqueries; |
$sth=$dbh -> prepare($query); |
$sth=$dbh -> prepare($query); |
Line 322 print "$query\n",br if $printqueries;
|
Line 333 print "$query\n",br if $printqueries;
|
{ |
{ |
$frequence[$i]+=$arr[0]; |
$frequence[$i]+=$arr[0]; |
} |
} |
|
$sth->finish; |
|
|
|
|
if (@blob < 4) |
if (@blob < 4) |
Line 529 print $query if $printqueries;
|
Line 540 print $query if $printqueries;
|
while (@arr = $sth->fetchrow) { |
while (@arr = $sth->fetchrow) { |
push @Questions, $arr[0] unless $forbidden{$arr[0]}; |
push @Questions, $arr[0] unless $forbidden{$arr[0]}; |
} |
} |
|
$sth->finish; |
print "@Questions" if $printqueries; |
print "@Questions" if $printqueries; |
return @Questions; |
return @Questions; |
} |
} |
Line 553 sub PrintList {
|
Line 564 sub PrintList {
|
my ($dbh,$Questions,$shablon)=@_; |
my ($dbh,$Questions,$shablon)=@_; |
|
|
my $first=param('first') ||1; |
my $first=param('first') ||1; |
my $kvo=param('kvo') ||30; |
my $kvo=param('kvo') ||150; |
|
|
$first=$first-($first-1)%$kvo; |
$first=$first-($first-1)%$kvo; |
my $last=$first+$kvo-1; |
my $last=$first+$kvo-1; |
Line 563 sub PrintList {
|
Line 574 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'); |
|
$qs=~s/sstr=[^\&]+/sstr=$sstr/; |
if ($first>$kvo*3+1) |
if ($first>$kvo*3+1) |
{ |
{ |
$nav.= |
$nav.= |
Line 1034 sub Get12Random {
|
Line 1045 sub Get12Random {
|
$sth->execute; |
$sth->execute; |
$t = ($sth->fetchrow)[0]; |
$t = ($sth->fetchrow)[0]; |
} until !$chosen{$q} && $t && $type =~ /[$t]/; |
} until !$chosen{$q} && $t && $type =~ /[$t]/; |
|
$sth->finish; |
$chosen{$q} = 'y'; |
$chosen{$q} = 'y'; |
push @questions, $q; |
push @questions, $q; |
} |
} |
Line 1125 sub PrintDates {
|
Line 1137 sub PrintDates {
|
" " . 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; |
$output .= dl($list); |
$output .= dl($list); |
return $output; |
return $output; |
} |
} |
Line 1144 sub PrintQOfAuthor
|
Line 1157 sub PrintQOfAuthor
|
my @Questions; |
my @Questions; |
while (($q)=$sth->fetchrow,$q) |
while (($q)=$sth->fetchrow,$q) |
{push @Questions,$q unless $forbidden{$q}} |
{push @Questions,$q unless $forbidden{$q}} |
|
$sth->finish; |
|
|
my ($output, $i, $suffix, $hits) = ('', 0, '', $#Questions + 1); |
my ($output, $i, $suffix, $hits) = ('', 0, '', $#Questions + 1); |
|
|
Line 1217 a({href=>url."?authors=surname"},"фамили
|
Line 1231 a({href=>url."?authors=surname"},"фамили
|
} |
} |
} |
} |
$output.="</TABLE>"; |
$output.="</TABLE>"; |
|
$sth->finish; |
return $output; |
return $output; |
} |
} |
|
|
Line 1277 if ((uc 'а') ne 'А') {print "Koi8-r loca
|
Line 1292 if ((uc 'а') ne 'А') {print "Koi8-r loca
|
$type .= 'Ч' if (param('chgk')); |
$type .= 'Ч' if (param('chgk')); |
$qnum = param('qnum') if (param('qnum') =~ /^\d+$/); |
$qnum = param('qnum') if (param('qnum') =~ /^\d+$/); |
$qnum = 0 if (!$type); |
$qnum = 0 if (!$type); |
if (param('email') && -x $SENDMAIL && |
my $Email; |
open(F, "| $SENDMAIL -t -n")) { |
*STDERR=*STDOUT; |
my ($Email) = param('email'); |
if (($Email=param('email')) && -x $SENDMAIL && |
|
open(F, "| $SENDMAIL $Email")) { |
my ($mime_type) = $text ? "plain" : "html"; |
my ($mime_type) = $text ? "plain" : "html"; |
print F <<EOT; |
print F <<EOT; |
To: $Email |
To: $Email |
From: olegstemanov\@mail.ru |
From: olegstepanov\@mail.ru |
Subject: Sluchajnij Paket Voprosov "Chto? Gde? Kogda?" |
Subject: Sluchajnij Paket Voprosov "Chto? Gde? Kogda?" |
MIME-Version: 1.0 |
MIME-Version: 1.0 |
Content-type: text/$mime_type; charset="koi8-r" |
Content-type: text/$mime_type; charset="koi8-r" |
Line 1291 Content-type: text/$mime_type; charset="
|
Line 1307 Content-type: text/$mime_type; charset="
|
EOT |
EOT |
print F &PrintRandom($dbh, $type, $qnum, $text); |
print F &PrintRandom($dbh, $type, $qnum, $text); |
close F; |
close F; |
print "Пакет случайно выбранных вопросов послан. Нажмите |
print "Пакет случайно выбранных вопросов послан по адресу $Email. Нажмите |
на <B>Reload</B> для получения еще одного пакета"; |
на <B>Reload</B> для получения еще одного пакета"; |
} else { |
} else { |
print &PrintRandom($dbh, $type, $qnum, $text); |
print &PrintRandom($dbh, $type, $qnum, $text); |
Line 1313 print $query if $printqueries;
|
Line 1329 print $query if $printqueries;
|
my $sth=$dbh->prepare($query); |
my $sth=$dbh->prepare($query); |
$sth->execute; |
$sth->execute; |
my $sstr= join ' ',$sth->fetchrow; |
my $sstr= join ' ',$sth->fetchrow; |
|
$sth->finish; |
$searchin{'Question'}=1; |
$searchin{'Question'}=1; |
$searchin{'Answer'}=1; |
$searchin{'Answer'}=1; |
$sstr=~tr/ёЁ/еЕ/; |
$sstr=~tr/ёЁ/еЕ/; |
Line 1355 $sstr=~s/[^йцукенгшщзхъфывапролджэячсмит
|
Line 1372 $sstr=~s/[^йцукенгшщзхъфывапролджэячсмит
|
WHERE FileName = '$tour.txt'"); |
WHERE FileName = '$tour.txt'"); |
$sth->execute; |
$sth->execute; |
$tour = ($sth->fetchrow)[0]; |
$tour = ($sth->fetchrow)[0]; |
|
$sth->finish; |
} |
} |
print &PrintTournament($dbh, $tour, param('answer')); |
print &PrintTournament($dbh, $tour, param('answer')); |
} |
} |