version 1.106, 2003/04/20 11:45:48
|
version 1.115, 2003/04/22 10:50:37
|
Line 9 use locale;
|
Line 9 use locale;
|
use vars qw($opt_z); |
use vars qw($opt_z); |
use Getopt::Std; |
use Getopt::Std; |
getopts('z'); |
getopts('z'); |
|
my $withanswers=param('answer')||param('answers'); |
open STDERR, ">/var/tmp/errors1"; |
open STDERR, ">/var/tmp/errors1"; |
my $newsurl='http://news.chgk.info/'; |
my $newsurl='http://news.chgk.info/'; |
my $HTMLDIR=""; |
my $reklama="../dimrub/db/reklama.html"; |
|
$reklama="../reklama.html" if $opt_z; |
|
my $HTMLDIR="/znatoki/dimrub/db/baza/"; |
my $realHTMLDIR; |
my $realHTMLDIR; |
if ($^O =~ /win/i) { |
if ($^O =~ /win/i) { |
$realHTMLDIR="/html/znatoki/baza/"; |
$realHTMLDIR="/html/znatoki/baza/"; |
Line 19 if ($^O =~ /win/i) {
|
Line 22 if ($^O =~ /win/i) {
|
{ |
{ |
$realHTMLDIR="/home/znatoki/public_html/dimrub/db/baza/"; |
$realHTMLDIR="/home/znatoki/public_html/dimrub/db/baza/"; |
} |
} |
my $usehtml=1; |
my $usehtml=$opt_z||0; |
my $usewas=0; |
my $usewas=0; |
my $cashednumber=500; |
my $cashednumber=500; |
my $outputnumber=10; |
my $outputnumber=10; |
Line 35 $outputkvo=100 if $outputkvo>100;
|
Line 38 $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\.chgk\.info/ && $url !~ /localhost/ ) { |
if ($url !~ /db\.chgk\.info/ && $url !~ /localhost/ && $url !~ /bilbo/) { |
my $u="http://db.chgk.info/cgi-bin/db.cgi?$qs"; |
my $u="http://db.chgk.info/cgi-bin/db.cgi?$qs"; |
Redirect ($u); |
Redirect ($u); |
exit; |
exit; |
Line 224 sub tourhref {
|
Line 227 sub tourhref {
|
$res=$t; |
$res=$t; |
$res.=$a?"-a":"-q" unless $gr; |
$res.=$a?"-a":"-q" unless $gr; |
$res.=".html"; |
$res.=".html"; |
|
$res=~s/(\#\d+)(.*)$/$2$1/; |
|
$res="$HTMLDIR$res" unless $opt_z; |
return $res; |
return $res; |
} else { |
} else { |
$res=$url; |
$res=$url; |
$res.="?tour=$t"; |
$res.="?tour=$t"; |
$res.=$a?"?answers=1":""; |
$res.=$a?"&answers=1":""; |
return $res; |
return $res; |
} |
} |
|
|
Line 1414 sub Get12Random {
|
Line 1419 sub Get12Random {
|
|
|
sub Include_virtual { |
sub Include_virtual { |
my ($fn, $output) = (@_, ''); |
my ($fn, $output) = (@_, ''); |
|
return "<!--#include virtual=\"$fn\"-->" if ($opt_z); |
open F , $fn |
open F , $fn |
or return ""; #die "Can't open the file $fn: $!\n"; |
or return ""; #die "Can't open the file $fn: $!\n"; |
|
|
Line 1452 sub PrintAll {
|
Line 1457 sub PrintAll {
|
|
|
my (%Tournament) = &GetTournament($dbh, $Id); |
my (%Tournament) = &GetTournament($dbh, $Id); |
my (@Tours) = &GetTours($dbh, $Id); |
my (@Tours) = &GetTours($dbh, $Id); |
|
my $SingleTour = $#Tours == 0; |
|
|
my ($New) = ($Id and $Tournament{'Type'} eq 'Ч' and |
my ($New) = ($Id and $Tournament{'Type'} eq 'Ч' and |
&NewEnough($Tournament{"CreatedAt"})) ? |
&NewEnough($Tournament{"CreatedAt"})) ? |
img({src=>"/znatoki/dimrub/db/new-sml.gif", alt=>"NEW!"}) : ""; |
img({src=>"/znatoki/dimrub/db/new-sml.gif", alt=>"NEW!"}) : ""; |
Line 1473 sub PrintAll {
|
Line 1480 sub PrintAll {
|
|
|
|
|
$output .= dd(img({src=>"/icons/folder.gif", alt=>"[*]"}) . |
$output .= dd(img({src=>"/icons/folder.gif", alt=>"[*]"}) . |
" " . a({href=>tourhref($textid,0,1)}, |
" " . a({href=>tourhref($textid,0,!$SingleTour)}, |
$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 '') { |
Line 1809 MAIN:
|
Line 1816 MAIN:
|
or do { |
or do { |
print h1("Временные проблемы") . "База вопросов временно не |
print h1("Временные проблемы") . "База вопросов временно не |
работает. Заходите попозже."; |
работает. Заходите попозже."; |
print &Include_virtual("../dimrub/db/reklama.html") if $url!~/localhost/; |
print &Include_virtual("$reklama") if $url!~/localhost/; |
print end_html; |
print end_html; |
die "Can't connect to DB chgk\n"; |
die "Can't connect to DB chgk\n"; |
}; |
}; |
Line 1874 td {font-size: x-small; font-family : sa
|
Line 1881 td {font-size: x-small; font-family : sa
|
th {font-size: x-small; font-family : sans-serif} |
th {font-size: x-small; font-family : sans-serif} |
</style>\n"; |
</style>\n"; |
|
|
$globaloutput.=&Include_virtual("../dimrub/db/reklama.html")||''; |
$globaloutput.=&Include_virtual("$reklama")||''; |
} |
} |
|
|
if (length ($qs)<=255 && $qs !~ /(sstr)|(rand)|(comp)|(all=)/i) { |
if (length ($qs)<=255 && $qs !~ /(sstr)|(rand)|(comp)|(all=)/i) { |
Line 2015 EOT
|
Line 2022 EOT
|
$QuestionNumber=($sth->fetchrow)[0]||0; |
$QuestionNumber=($sth->fetchrow)[0]||0; |
} |
} |
if ($QuestionNumber) { |
if ($QuestionNumber) { |
$globaloutput.= &PrintQuestion($dbh, $QuestionNumber, param('answer')||0, $qnum, 1,0,0); |
$globaloutput.= &PrintQuestion($dbh, $QuestionNumber, $withanswers||0, $qnum, 1,0,0); |
# $dbh, $Id, $answer, $qnum, $title, $text |
# $dbh, $Id, $answer, $qnum, $title, $text |
} else { |
} else { |
$globaloutput.=&PrintTournament($dbh, $tour, param('answer')); |
$globaloutput.=&PrintTournament($dbh, $tour, $withanswers); |
} |
} |
} |
} |
else { |
else { |
Line 2053 my ($sth) = $dbh->prepare("SELECT t1.Id,
|
Line 2060 my ($sth) = $dbh->prepare("SELECT t1.Id,
|
$fname=~s/\.txt$//; |
$fname=~s/\.txt$//; |
if ($type=~/Т/ || $c<=1) |
if ($type=~/Т/ || $c<=1) |
{ |
{ |
open FF, ">$realHTMLDIR$fname-q.html" or die "ERROR! - $HTMLDIR$fname-q.html\n"; |
open FF, ">$realHTMLDIR$fname-q.html" or die "ERROR! - $fname-q.html\n"; |
my $o=$globaloutput; |
my $o=$globaloutput; |
$o.=&PrintTournament($dbh, $Id, 0); |
$o.=&PrintTournament($dbh, $Id, 0); |
$o.=&Bottom; |
$o.=&Bottom; |
Line 2067 my ($sth) = $dbh->prepare("SELECT t1.Id,
|
Line 2074 my ($sth) = $dbh->prepare("SELECT t1.Id,
|
close FF; |
close FF; |
} |
} |
else { |
else { |
open FF, ">$realHTMLDIR$fname.html" or die "ERROR! - $HTMLDIR$fname-q.html\n"; |
open FF, ">$realHTMLDIR$fname.html" or die "ERROR! - $fname-q.html\n"; |
my $o=$globaloutput; |
my $o=$globaloutput; |
$o.=&PrintTournament($dbh, $Id, 0); |
$o.=&PrintTournament($dbh, $Id, 0); |
$o.=&Bottom; |
$o.=&Bottom; |