--- db/prgsrc/db.cgi 2003/04/20 12:11:17 1.108 +++ db/prgsrc/db.cgi 2003/04/22 10:50:37 1.115 @@ -9,9 +9,12 @@ use locale; use vars qw($opt_z); use Getopt::Std; getopts('z'); +my $withanswers=param('answer')||param('answers'); open STDERR, ">/var/tmp/errors1"; 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; if ($^O =~ /win/i) { $realHTMLDIR="/html/znatoki/baza/"; @@ -19,7 +22,7 @@ if ($^O =~ /win/i) { { $realHTMLDIR="/home/znatoki/public_html/dimrub/db/baza/"; } -my $usehtml=1; +my $usehtml=$opt_z||0; my $usewas=0; my $cashednumber=500; my $outputnumber=10; @@ -224,11 +227,13 @@ sub tourhref { $res=$t; $res.=$a?"-a":"-q" unless $gr; $res.=".html"; + $res=~s/(\#\d+)(.*)$/$2$1/; + $res="$HTMLDIR$res" unless $opt_z; return $res; } else { $res=$url; $res.="?tour=$t"; - $res.=$a?"?answers=1":""; + $res.=$a?"&answers=1":""; return $res; } @@ -1414,7 +1419,7 @@ sub Get12Random { sub Include_virtual { my ($fn, $output) = (@_, ''); - + return "" if ($opt_z); open F , $fn or return ""; #die "Can't open the file $fn: $!\n"; @@ -1811,7 +1816,7 @@ MAIN: or do { print h1("Временные проблемы") . "База вопросов временно не работает. Заходите попозже."; - print &Include_virtual("../dimrub/db/reklama.html") if $url!~/localhost/; + print &Include_virtual("$reklama") if $url!~/localhost/; print end_html; die "Can't connect to DB chgk\n"; }; @@ -1876,7 +1881,7 @@ td {font-size: x-small; font-family : sa th {font-size: x-small; font-family : sans-serif} \n"; - $globaloutput.=&Include_virtual("../dimrub/db/reklama.html")||''; + $globaloutput.=&Include_virtual("$reklama")||''; } if (length ($qs)<=255 && $qs !~ /(sstr)|(rand)|(comp)|(all=)/i) { @@ -2017,10 +2022,10 @@ EOT $QuestionNumber=($sth->fetchrow)[0]||0; } 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 } else { - $globaloutput.=&PrintTournament($dbh, $tour, param('answer')); + $globaloutput.=&PrintTournament($dbh, $tour, $withanswers); } } else { @@ -2055,7 +2060,7 @@ my ($sth) = $dbh->prepare("SELECT t1.Id, $fname=~s/\.txt$//; 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; $o.=&PrintTournament($dbh, $Id, 0); $o.=&Bottom; @@ -2069,7 +2074,7 @@ my ($sth) = $dbh->prepare("SELECT t1.Id, close FF; } 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; $o.=&PrintTournament($dbh, $Id, 0); $o.=&Bottom;