version 1.158, 2010/01/24 20:30:05
|
version 1.164, 2016/06/13 16:32:07
|
Line 11 use URI::Escape;
|
Line 11 use URI::Escape;
|
my $proxyredirect=1; |
my $proxyredirect=1; |
use POSIX qw(locale_h); |
use POSIX qw(locale_h); |
use locale; |
use locale; |
|
my $maxQuestions = 3000; |
|
|
use vars qw($opt_z); |
use vars qw($opt_z); |
use Getopt::Std; |
use Getopt::Std; |
#my ($dbuser,$dbname,$dbpass,$dbhost); |
#my ($dbuser,$dbname,$dbpass,$dbhost); |
Line 71 $outputkvo=100 if $outputkvo>100;
|
Line 73 $outputkvo=100 if $outputkvo>100;
|
|
|
if (param('debug')) {$debug=1; $printqueries=1} |
if (param('debug')) {$debug=1; $printqueries=1} |
*STDERR=*STDOUT if $debug; |
*STDERR=*STDOUT if $debug; |
if ($url!~ /\/\/db\// && $url !~ /db\.chgk\.info/ && $url !~ /localhost/ && $url !~ /bilbo/ && $url !~ /zaba/ && $url !~ /question\.chgk\.info/ ) { |
|
my $u="http://db.chgk.info/cgi-bin/db.cgi?$qs"; |
|
Redirect ($u); |
|
exit; |
|
} |
|
|
|
if ($proxyredirect && $metod=~/proxy/ && $url !~ /localhost/ && $url !~ /bilbo/ && $url !~ /zaba/) { |
if ($proxyredirect && $metod=~/proxy/ && $url !~ /localhost/ && $url !~ /bilbo/ && $url !~ /zaba/) { |
my $u="http://chgk.zaba.ru/cgi-bin/db.cgi?$qs"; |
my $u="http://chgk.zaba.ru/cgi-bin/db.cgi?$qs"; |
Line 233 sub SelectQuestions {
|
Line 230 sub SelectQuestions {
|
# my $where=join " OR ",@$q; |
# my $where=join " OR ",@$q; |
my $where=join ',',@$q; |
my $where=join ',',@$q; |
$where &&= "QuestionId IN (".(join ',',$where).")"; |
$where &&= "QuestionId IN (".(join ',',$where).")"; |
$where||=1; |
$where||=0; |
$where="($where) AND Questions.ParentId=t1.Id AND t1.ParentId=t2.Id" |
$where="($where) AND Questions.ParentId=t1.Id AND t1.ParentId=t2.Id" |
if $WithTour; |
if $WithTour; |
|
|
Line 779 sub Search {
|
Line 776 sub Search {
|
|
|
my $query; |
my $query; |
$query="SELECT QuestionId FROM Questions |
$query="SELECT QuestionId FROM Questions |
WHERE ($f LIKE $sstr) AND (".&makewhere.") ORDER BY QuestionId"; |
WHERE ($f LIKE $sstr) AND (".&makewhere.") ORDER BY QuestionId LIMIT $maxQuestions"; |
|
|
|
|
$sth = $dbh->prepare($query) |
$sth = $dbh->prepare($query) |
Line 824 sub NoCase {
|
Line 821 sub NoCase {
|
|
|
sub PrintList { |
sub PrintList { |
my ($dbh,$Questions,$shablon,$was)=@_; |
my ($dbh,$Questions,$shablon,$was)=@_; |
|
my $total_found = $totalfound||$#$Questions+1; |
my $Output; |
my $Output; |
my $first=param('first') ||1; |
my $first=param('first') ||1; |
$first=$first-($first-1)%$outputkvo; |
$first=$first-($first-1)%$outputkvo; |
my $fkvo=param('fkvo')||($#$Questions+1); |
my $fkvo=param('fkvo')||$total_found; |
my $last=$first+$outputkvo-1; |
my $last=$first+$outputkvo-1; |
$last=$fkvo if $fkvo<$last; |
$last=$fkvo if $fkvo<$last; |
my($f,$l); |
my($f,$l); |
Line 852 sub PrintList {
|
Line 850 sub PrintList {
|
else {$nav.=' 'x15;} |
else {$nav.=' 'x15;} |
|
|
my ($fprint,$lprint); |
my ($fprint,$lprint); |
my $llprint=$fkvo- ($fkvo)%$outputkvo+1; # |
my $llprint=$fkvo- ($fkvo-1)%$outputkvo; # |
if ($fkvo<=$outputkvo*7) |
if ($fkvo<=$outputkvo*7) |
{ $fprint=1; |
{ $fprint=1; |
$lprint=$llprint; |
$lprint=$llprint+($fkvo)%$outputkvo; |
} |
} |
elsif ($first>$outputkvo*3 && $fkvo-$first>$outputkvo*3) |
elsif ($first>$outputkvo*3 && $fkvo-$first>$outputkvo*3) |
{ |
{ |
Line 868 sub PrintList {
|
Line 866 sub PrintList {
|
} |
} |
else |
else |
{ |
{ |
$lprint=$llprint; |
$lprint=$fkvo; |
$fprint=$lprint-$outputkvo*6 |
$fprint=$lprint-($lprint-1)%$outputkvo-$outputkvo*6; |
} |
} |
|
|
# my $fprint=($first>$outputkvo*3) ? $first-$outputkvo*3 : 1; |
# my $fprint=($first>$outputkvo*3) ? $first-$outputkvo*3 : 1; |
Line 881 sub PrintList {
|
Line 879 sub PrintList {
|
# } |
# } |
|
|
|
|
|
|
for($f=$fprint; $f<=$lprint; $f+=$outputkvo) |
for($f=$fprint; $f<=$lprint; $f+=$outputkvo) |
{ |
{ |
# next if $first-$f>$outputkvo*3; |
# next if $first-$f>$outputkvo*3; |
Line 893 sub PrintList {
|
Line 890 sub PrintList {
|
} |
} |
if ($lprint+$outputkvo<$fkvo) |
if ($lprint+$outputkvo<$fkvo) |
{ |
{ |
|
my $reminder = ($llprint-1)%$outputkvo; |
|
my $newlprint = $llprint-$reminder; |
|
# $newlprint +=$outputkvo if $reminder!=$outputkvo-1; |
$nav.= |
$nav.= |
(" "x4). |
(" "x4). |
a({href=>($url."?".$qs."\&first=".($first+$outputkvo))},">").(" "x4). |
a({href=>($url."?".$qs."\&first=".($first+$outputkvo))},">").(" "x4). |
a({href=>$url."?".$qs."\&first=$llprint"},">>").(" "x4) |
a({href=>$url."?".$qs."\&first=$newlprint"},">>").(" "x4) |
} |
} |
$Output.= "$nav".br."\n"; |
$Output.= "$nav".br."\n"; |
my @q=@$Questions[$first-1..$last-1]; |
my @q; |
|
if ($totalfound) { |
|
@q = @$Questions; |
|
} else { |
|
@q=@$Questions[$first-1..$last-1]; |
|
} |
my %q=(); |
my %q=(); |
my $sth=SelectQuestions($dbh,\@q,1); |
my $sth=SelectQuestions($dbh,\@q,1); |
my $qq; |
my $qq; |
Line 910 sub PrintList {
|
Line 915 sub PrintList {
|
$q{$Q[$_]{'QuestionId'}}=$Q[$_]; |
$q{$Q[$_]{'QuestionId'}}=$Q[$_]; |
} |
} |
|
|
for (my $i = $first; $i <= $last; $i++) { |
for my $i(0..$#q) { |
my $q=$q{$$Questions[$i-1]}; |
my $q=$q{$q[$i]}; |
my $output; |
my $output; |
$output = &PrintQuestion($dbh, $q, 1, 0, 1,$text,1 ); |
$output = &PrintQuestion($dbh, $q, 1, 0, 1,$text,1 ); |
# if (param('metod') && (param('metod') eq 'rus' || param('metod') eq 'proxy')) |
# if (param('metod') && (param('metod') eq 'rus' || param('metod') eq 'proxy')) |
Line 1006 sub PrintSearch {
|
Line 1011 sub PrintSearch {
|
$suffix = 'я'; |
$suffix = 'я'; |
} |
} |
|
|
|
$hits = 'очень много' if ($hits==$maxQuestions); |
|
|
$Output.= p({align=>"center"}, "Результаты поиска на " . strong($sstr) |
$Output.= p({align=>"center"}, "Результаты поиска на " . strong($sstr) |
. " : $hits попадани$suffix."); |
. " : $hits попадани$suffix."); |
|
|
Line 1092 sub PrintTournament {
|
Line 1099 sub PrintTournament {
|
@Tours = &GetTours($dbh, $Id); |
@Tours = &GetTours($dbh, $Id); |
$list=''; |
$list=''; |
my $textid; |
my $textid; |
|
my $isGroup; |
if ($Id) { |
if ($Id) { |
for ($Tournament{'Type'}) { |
for ($Tournament{'Type'}) { |
/Г/ && do { |
/Г/ && do { |
Line 1102 sub PrintTournament {
|
Line 1110 sub PrintTournament {
|
$Tournament{'PlayedAt2'}:'') . |
$Tournament{'PlayedAt2'}:'') . |
|
|
p . "\n"; |
p . "\n"; |
|
$isGroup=1; |
last; |
last; |
}; |
}; |
/Ч/ && do { |
/Ч/ && do { |
Line 1223 sub PrintTournament {
|
Line 1232 sub PrintTournament {
|
$output .= p($Info); |
$output .= p($Info); |
} |
} |
|
|
|
|
|
|
$output.=p("<a href='/dbxml.php?tour=".param('tour')."'>XML</a>"); |
$output.=p("<a href='/dbxml.php?tour=".param('tour')."'>XML</a>"); |
|
|
|
if ($textid=$fname) |
|
{ |
|
$textid=~s/\.txt//; |
|
} |
|
if (!$isGroup) { |
|
$output .= center("<font size='-1'>[". |
|
a({href=>"/v2/tour/$textid/print", target=>'_blank'}, 'версия для печати')."] [". |
|
a({href=>"/v2/tour/$textid/fb2", target=>'_blank'}, 'fb2')."]"."</font>"); |
|
} |
|
|
return $output; |
return $output; |
} |
} |
Line 1340 sub PrintTour {
|
Line 1360 sub PrintTour {
|
|
|
$bottom .= |
$bottom .= |
"[" . a({href=>tourhref("$fname$nn",1)}, |
"[" . a({href=>tourhref("$fname$nn",1)}, |
"ответы") . "] " . br."\n"; |
"ответы") . "] " |
} |
} |
|
$bottom .= "[".a({href=>"/v2/tour/$fname/print", target=>'_blank'}, 'версия для печати')."] [". |
|
a({href=>"/v2/tour/$fname/fb2/", target=>'_blank'}, 'fb2')."]".br; |
|
|
|
# $bottom .= "[".a({href=>'/v2/print/'.$fname.'.'.$Tour{'Number'}, target=>'_blank'}, 'версия для печати')."]".br; |
|
|
if ($n>1) { |
if ($n>1) { |
$bottom .= |
$bottom .= |
"[" . a({href=>tourhref("$fname.".($n-1),0)}, |
"[" . a({href=>tourhref("$fname.".($n-1),0)}, |
Line 1350 sub PrintTour {
|
Line 1375 sub PrintTour {
|
"[" . a({href=>tourhref("$fname.".($n-1),1)}, |
"[" . a({href=>tourhref("$fname.".($n-1),1)}, |
"предыдущий тур с ответами") . "] " . br."\n"; |
"предыдущий тур с ответами") . "] " . br."\n"; |
} |
} |
|
|
if (&IsTour($dbh, $Tour{'ParentId'}, $n + 1)) { |
if (&IsTour($dbh, $Tour{'ParentId'}, $n + 1)) { |
$bottom .= |
$bottom .= |
"[" . a({href=>tourhref("$fname.".($n+1),0)}, |
"[" . a({href=>tourhref("$fname.".($n+1),0)}, |
Line 2233 div.razdatka_header {font-style:italic;}
|
Line 2259 div.razdatka_header {font-style:italic;}
|
my ($mime_type) = $text ? "plain" : "html"; |
my ($mime_type) = $text ? "plain" : "html"; |
print F <<EOT; |
print F <<EOT; |
To: $Email |
To: $Email |
From: olegstepanov\@mail.ru |
From: boris\@chgk.info |
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" |