Diff for /db/prgsrc/db.cgi between versions 1.101 and 1.130

version 1.101, 2003/04/20 08:06:44 version 1.130, 2004/03/11 07:14:14
Line 8  use POSIX qw(locale_h); Line 8  use POSIX qw(locale_h);
 use locale;  use locale;
 use vars qw($opt_z);  use vars qw($opt_z);
 use Getopt::Std;  use Getopt::Std;
   my ($dbuser,$dbname,$dbpass,$dbhost);
   require "dbdefs.pl";
   $dbuser||="piataev";
   $dbname||="chgk";
   $dbpass||="";
   $dbhost||="localhost";
 getopts('z');  getopts('z');
   $opt_z||=param("makehtml");
   my $timestamp="_timestamp.tmp";
   my $usehash=0;
   my $paramtour;
   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";
   my $footer="../dimrub/db/footer.html";
   
   my $datefooter="../dimrub/db/date";
   
   my $fname;
   $reklama="../reklama.html" if $opt_z;
   $footer="../footer.html" if $opt_z;
   $datefooter="../date" if $opt_z;
   my $HTMLDIR="/znatoki/dimrub/db/baza/";
   $HTMLDIR="/files/";
 my $realHTMLDIR;  my $realHTMLDIR;
 if ($^O =~ /win/i) {  if ($^O =~ /win/i) {
  $realHTMLDIR="/html/znatoki/baza";   $realHTMLDIR="/html/znatoki/baza/";
 } else   } else 
 {  {
   $realHTMLDIR="/home/znatoki/public_html/dimrub/db/baza";    $realHTMLDIR="/home/piataev/public_html/dimrub/db/files/";
 }  }
 my $usehtml=1;  my $url=url||'';
   
   my $usehtml=$opt_z||0;
   $usehtml=1;
   $usehtml=0 if $url=~/zaba/;
   
 my $usewas=0;  my $usewas=0;
 my $cashednumber=500;  my $cashednumber=500;
 my $outputnumber=10;  my $outputnumber=10;
 my ($proxyptext,$proxysstr);  my ($proxyptext,$proxysstr);
 my $printqueries=0;  my $printqueries=0;
 my $url=url||'';  
 my $qs=query_string;  my $qs=query_string;
 my $globaloutput;  my $globaloutput;
 my %forbidden=();  my %forbidden=();
 my $debug=0; #added by R7  my $debug=0; #added by R7
   my $metod=param('metod')||'';
 my $outputkvo=param('kvo') ||$outputnumber;  my $outputkvo=param('kvo') ||$outputnumber;
 $outputkvo=100 if $outputkvo>100;  $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/ && $url !~ /zaba/) {
    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;
 }  }
 if (!param('sstr') && param('all')) {  
            my $destination='http://db.chgk.info/all.html';  if ($metod=~/proxy/ && $url !~ /localhost/ && $url !~ /bilbo/ && $url !~ /zaba/) {
                 Redirect($destination);     my $u="http://chgk.zaba.ru/cgi-bin/db.cgi?$qs";
                 exit;     Redirect ($u);
      exit;
 }  }
   
   #if (!param('sstr') && param('all')) {
   #          my $destination='http://db.chgk.info/all.html';
   #               Redirect($destination);
   #                exit;
   #}
 my $thislocale;  my $thislocale;
 if ($^O =~ /win/i) {  if ($^O =~ /win/i) {
         $thislocale = "Russian_Russia.20866";          $thislocale = "Russian_Russia.20866";
Line 78  my %TypeName=('children'=>'ä', 'game'=>' Line 111  my %TypeName=('children'=>'ä', 'game'=>'
               'chgk'=>'þ', 'brain'=>'â', 'beskrylka'=>'ì','ehruditka'=>'ü');                'chgk'=>'þ', 'brain'=>'â', 'beskrylka'=>'ì','ehruditka'=>'ü');
   
   
   sub countz {
     my ($dbh,$type)=@_;
     
     my $sth=$dbh->prepare("select count(*) from Questions where Type LIKE '%$type%'");
     $sth->execute();
     my ($tmp)=$sth->fetchrow();
     return $tmp;
   }
   
 my $all=param('all');  my $all=param('all');
 $all=0 if lc $all eq 'no';  $all=0 if lc $all eq 'no';
Line 104  my @months=('000','Jan',"Feb","Mar","Apr Line 145  my @months=('000','Jan',"Feb","Mar","Apr
 sub NewEnough {  sub NewEnough {
         my ($a) = @_;          my ($a) = @_;
         my ($year, $month, $day) = split('-', $a);          my ($year, $month, $day) = split('-', $a);
           $month=1 if ($month<=0);
           $day=1 if ($day<=0);
         return (time - timelocal(0, 0, 0, $day, $month -1, $year) < $TMSECS);          return (time - timelocal(0, 0, 0, $day, $month -1, $year) < $TMSECS);
 }  }
   
Line 112  sub NewEnough { Line 154  sub NewEnough {
   
 sub Redirect {  sub Redirect {
 my ($destination) = @_;  my ($destination) = @_;
   print header.<<EndOfHTML;
   <head><meta http-equiv="refresh" content="0; URL=$destination"></head>
   EndOfHTML
   ;
   =head
   
 print <<EndOfHTML;  print <<EndOfHTML;
 Content-type: text/html  Content-type: text/html
 Location: $destination  Location: $destination
Line 127  by clicking <A HREF="$destination">here< Line 175  by clicking <A HREF="$destination">here<
 </HTML>  </HTML>
 EndOfHTML  EndOfHTML
 ;  ;
   =cut
 }  }
   
   
Line 153  sub GetTournament { Line 202  sub GetTournament {
 sub fetchquestion {  sub fetchquestion {
         my ($sth,$q,$WithTour)=@_;          my ($sth,$q,$WithTour)=@_;
         if ($WithTour) {          if ($WithTour) {
                 ($$q{'Question'},$$q{'Answer'},$$q{'Comments'},$$q{'Authors'},                  ($$q{'QuestionId'}, $$q{'Question'},$$q{'Answer'},$$q{'Comments'},$$q{'Authors'},$$q{'Sources'},
                 $$q{'Number'},                   $$q{'Number'}, 
                 $$q{'Title'}, $$q{'TourTitle'}, $$q{'FileName'},$$q{'PlayedAt'},$$q{'TourNumber'}) =                   $$q{'Title'}, $$q{'TourTitle'}, $$q{'FileName'},$$q{'PlayedAt'},$$q{'TourNumber'}) = 
                 $sth->fetchrow;                  $sth->fetchrow;
         } else {          } else {
                 ($$q{'Question'},$$q{'Answer'},$$q{'Comments'},$$q{'Authors'},                  ($$q{'QuestionId'}, $$q{'Question'},$$q{'Answer'},$$q{'Comments'},$$q{'Authors'},$$q{'Sources'},
                 $$q{'Number'})=                   $$q{'Number'})= 
                 $sth->fetchrow;                  $sth->fetchrow;
         }          }
Line 166  sub fetchquestion { Line 215  sub fetchquestion {
   
   
   
   
 sub SelectQuestions {  sub SelectQuestions {
         my ($dbh,$q,$WithTour) = @_;          my ($dbh,$q,$WithTour) = @_;
         my %q=();          my %q=();
         $_ = "QuestionId=$_" foreach @$q;  #       $_ = "QuestionId=$_" foreach @$q;
         my $where=join " OR ",@$q;  #       my $where=join " OR ",@$q;
           my $where=join ',',@$q;
           $where &&= "QuestionId IN (".(join ',',$where).")";
         $where||=1;          $where||=1;
         $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;
   
         my $query;          my $query;
         if ($WithTour) {          if ($WithTour) {
                 $query="SELECT Questions.Question, Answer, Comments, Authors,                  $query="SELECT QuestionId, Questions.Question, Answer, Comments, Authors, Sources,
                         Questions.Number                          Questions.Number
                         , t2.Title, t1.Title, t2.FileName,  t2.PlayedAt,t1.Number                          , t2.Title, t1.Title, t2.FileName,  t2.PlayedAt,t1.Number
                         from Questions,Tournaments as t1, Tournaments as t2                           from Questions,Tournaments as t1, Tournaments as t2 
                         WHERE $where";                          WHERE $where";
         } else {          } else {
                 $query="SELECT Questions.Question, Answer, Comments, Authors,                  $query="SELECT QuestionId, Questions.Question, Answer, Comments, Authors, Sources,
                         Questions.Number from Questions                           Questions.Number from Questions 
                         WHERE $where";                          WHERE $where";
         }          }
Line 223  sub tourhref { Line 275  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/;
           my $t=$res;
           $t=~s/\#.*$//;
           $res=~s/\.1// unless -e "$realHTMLDIR$t";
           $t=$res;
           $t=~s/\#.*$//;
           $res=~s/\.html/-q\.html/ unless -e "$realHTMLDIR$t";
           $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 382  sub proxy Line 442  sub proxy
 sub makeproxysstr {  sub makeproxysstr {
       my ($dbh,$ptext)=@_;        my ($dbh,$ptext)=@_;
       my $text=$$ptext;        my $text=$$ptext;
         POSIX::setlocale( &POSIX::LC_ALL, $thislocale );
       $text=~tr/£³/Åå/;        $text=~tr/£³/Åå/;
       $text=~s/(${RLrl})p(${RLrl})/$1p$2/gom;        $text=~s/(${RLrl})p(${RLrl})/$1p$2/gom;
       $text=~s/p(${RLrl})/Ò$1/gom;        $text=~s/p(${RLrl})/Ò$1/gom;
Line 390  sub makeproxysstr { Line 451  sub makeproxysstr {
       $text=~s/[^ÊÃÕËÅÎÇÛÝÚÈßÆÙ×ÁÐÒÏÌÄÖÜÑÞÓÍÉÔØÂÀêãõëåîçûýúèÿæù÷áðòïìäöüñþóíéôøâàQWERTYUIOPASDFGHJKLZXCVBNM0-9]/ /g;        $text=~s/[^ÊÃÕËÅÎÇÛÝÚÈßÆÙ×ÁÐÒÏÌÄÖÜÑÞÓÍÉÔØÂÀêãõëåîçûýúèÿæù÷áðòïìäöüñþóíéôøâàQWERTYUIOPASDFGHJKLZXCVBNM0-9]/ /g;
       $text=uc $text;        $text=uc $text;
       my @list= $text=~m/(?:(?:${RLrl})+)|(?:[A-Za-z0-9]+)/gom;        my @list= $text=~m/(?:(?:${RLrl})+)|(?:[A-Za-z0-9]+)/gom;
   
       my (%c, %good,$sstr);        my (%c, %good,$sstr);
       foreach (@list)        foreach (@list)
       {        {
Line 398  sub makeproxysstr { Line 460  sub makeproxysstr {
       my @words=sort {$c{$a}<=> $c{$b}} @list;        my @words=sort {$c{$a}<=> $c{$b}} @list;
   
 #      $good{$words[$_]}=1 foreach 0..4;  #      $good{$words[$_]}=1 foreach 0..4;
   
       foreach (@words)        foreach (@words)
       {        {
          $good{$_}=1 if $c{$_}<200;           $good{$_}=1 if $c{$_}<200;
Line 428  sub russearch { Line 489  sub russearch {
             my %relevance;              my %relevance;
             my @blob;              my @blob;
             my %count;              my %count;
           POSIX::setlocale( &POSIX::LC_ALL, $thislocale );
 $sstr=~tr/ÊÃÕËÅÎÇÛÝÚÈßÆÙ×ÁÐÒÏÌÄÖÜÑÞÓÍÉÔØÂÀ/êãõëåîçûýúèÿæù÷áðòïìäöüñþóíéôøâà/;  $sstr=~tr/ÊÃÕËÅÎÇÛÝÚÈßÆÙ×ÁÐÒÏÌÄÖÜÑÞÓÍÉÔØÂÀ/êãõëåîçûýúèÿæù÷áðòïìäöüñþóíéôøâà/;
             @qw=@w =split (' ', uc $sstr);  #           @qw=@w =split (' ', uc $sstr);
               my $ts=uc $sstr;
               @qw=@w= $ts=~m/(?:(?:${RLrl})+)|(?:[A-Za-z0-9]+)/gom;
   
   
 #-----------  #-----------
             foreach $i (0..$#w) # ÚÁÐÏÌÎÑÅÍ ÍÁÓÓÉ× @nf ÎÁÞÁÌØÎÙÈ ÆÏÒÍ              foreach $i (0..$#w) # ÚÁÐÏÌÎÑÅÍ ÍÁÓÓÉ× @nf ÎÁÞÁÌØÎÙÈ ÆÏÒÍ
Line 559  foreach (keys %wordsof) Line 623  foreach (keys %wordsof)
   
 @tasks=sort {$relevance{$b}<=>$relevance{$a}} @tasks;  @tasks=sort {$relevance{$b}<=>$relevance{$a}} @tasks;
   
   
 ############  ############
   
   
Line 701  sub makewhere { Line 764  sub makewhere {
       $type .= ($_=$TypeName{$_}) foreach @type;        $type .= ($_=$TypeName{$_}) foreach @type;
       my $where=' 0 ';        my $where=' 0 ';
       foreach (@type) {        foreach (@type) {
              $where.= " OR (Type ='$_') OR (Type ='$_ä') ";               $where.= " OR (Type ='$_') OR (Type ='$_ä') OR (Type ='ä$_') ";
       }         } 
       $where.= "OR (Type='þâ')" if ($type=~/þ|â/);        $where.= "OR (Type='þâ')" if ($type=~/þ|â/);
       return $where;        return $where;
Line 726  sub PrintList { Line 789  sub PrintList {
    my ($dbh,$Questions,$shablon,$was)=@_;     my ($dbh,$Questions,$shablon,$was)=@_;
         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')||($#$Questions+1);
         my $last=$first+$outputkvo-1;          my $last=$first+$outputkvo-1;
Line 803  sub PrintList { Line 865  sub PrintList {
         my @q=@$Questions[$first-1..$last-1];          my @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 @Q;
           for (0..$#q) {
                   %{$Q[$_]}=();
                   fetchquestion($sth,$Q[$_],1);
                   $q{$Q[$_]{'QuestionId'}}=$Q[$_];
           }
   
         for (my $i = $first; $i <= $last; $i++) {          for (my $i = $first; $i <= $last; $i++) {
                 fetchquestion($sth,\%q,1);                  my $q=$q{$$Questions[$i-1]};
                 my $output;                  my $output;
                 $output = &PrintQuestion($dbh, \%q, 1, 0, 1,0,1  );                  $output = &PrintQuestion($dbh, $q, 1, 0, 1,0,1  );
                 if (param('metod') && (param('metod') eq 'rus' || param('metod') eq 'proxy'))  #                if (param('metod') && (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;
                 } else {  
                      $output=~s/($shablon)/\<strong\>$1\<\/strong\>/gi;                       $output=~s/($shablon)/\<strong\>$1\<\/strong\>/gi;
                 }                  }
                 $Output.= $output;                  $Output.= $output;
Line 923  sub PrintRandom { Line 992  sub PrintRandom {
    my %q;     my %q;
    my $answer=$razd?0:1;     my $answer=$razd?0:1;
    my @answers;     my @answers;
   #my $t=time;
    my (@Questions) = &Get12Random($dbh, $type, $num);     my (@Questions) = &Get12Random($dbh, $type, $num);
         my ($output, $i) = ('', 0);  
   
           my ($output, $i) = ('', 0);
   #$output.="time=".(time-$t).p;
         if ($text) {          if ($text) {
                 $output .= "    $num ÓÌÕÞÁÊÎÙÈ ×ÏÐÒÏÓÏ×.\n\n";                  $output .= "    $num ÓÌÕÞÁÊÎÙÈ ×ÏÐÒÏÓÏ×.\n\n";
         } else {          } else {
Line 971  sub PrintTournament { Line 1042  sub PrintTournament {
   
         %Tournament = &GetTournament($dbh, $Id) if ($Id);          %Tournament = &GetTournament($dbh, $Id) if ($Id);
   
         my ($URL) = $Tournament{'URL'};          my ($URL) = $Tournament{'URL'}||'';
         $URL=~s/http:\/znatoki\/boris\/reports\//$newsurl/ if $url=~/kulichki/;          $URL=~s/http:\/znatoki\/boris\/reports\//$newsurl/ if $url=~/kulichki/ || $url=~/db.chgk.info/;
         $URL=~s/\/znatoki\/boris\/reports\//$newsurl/ if url=~/kulichki/;;          $URL=~s/\/znatoki\/boris\/reports\//$newsurl/ if url=~/kulichki/ || $url=~/db.chgk.info/;
         my ($Info) = $Tournament{'Info'};          my ($Info) = $Tournament{'Info'};
         my ($Copyright) = $Tournament{'Copyright'};          my ($Copyright) = $Tournament{'Copyright'};
         my $fname=$Tournament{'FileName'};          my $fname=$Tournament{'FileName'};
Line 1007  sub PrintTournament { Line 1078  sub PrintTournament {
                         };                          };
                 }                  }
         } else {          } else {
                 my ($qnum) = GetQNum($dbh);                  my ($qnum) = GetQNum($dbh,0);
                 $output .= h2("âÁÎË ÷ÏÐÒÏÓÏ×: $qnum ×ÏÐÒÏÓ".&Suffix($qnum))                   my ($qnum1) = GetQNum($dbh,1);
                           . p . "\n";                  $output .= h2("âÁÚÁ ×ÏÐÒÏÓÏ×").
                    h3("$qnum ÚÁÐÉÓ".&Suffix2($qnum).
                    " (ÕÎÉËÁÌØÎÙÈ $qnum1)");
   
   #                h4("<table>".
   #                Tr(td("éÚ ÎÉÈ:"), td("÷ÏÐÒÏÓÏ× þçë: ".countz($dbh,'þ'))).               
   #                Tr(td("&nbsp;"), td("÷ÏÐÒÏÓÏ× ÄÌÑ ÂÒÅÊÎÁ: ".countz($dbh,'â'))).                 
   #                Tr(td("&nbsp;"), td("÷ÏÐÒÏÓÏ× ÄÌÑ þçë É ÂÒÅÊÎÁ: ".countz($dbh,'þâ'))).          
   #                Tr(td("&nbsp;"), td("éÎÔÅÒÎÅÔ-×ÏÐÒÏÓÏ×: ".countz($dbh,'é'))).           
   #                Tr(td("&nbsp;"), td("âÅÓËÒÙÌÏË: ".countz($dbh,'ì'))).
   #                Tr(td("&nbsp;"),td("úÁÄÁÎÉÊ ÄÌÑ ó×ÏÅÊ éÇÒÙ: ".countz($dbh,'ñ'))).
   #                Tr(td("&nbsp;"),td("üÒÕÄÉÔÏË: ".countz($dbh,'ü'))))."</table>"
         }          }
   
         for ($i = 0; $i <= $#Tours; $i++) {          for ($i = 0; $i <= $#Tours; $i++) {
Line 1049  sub PrintTournament { Line 1131  sub PrintTournament {
                else {$textid=$Tournament{'Id'}};                 else {$textid=$Tournament{'Id'}};
                                   
   
                 if ($SingleTour or $Tournament{'Type'} =~ /ô/) {                  if ($SingleTour or ($Tournament{'Type'} =~ /ô/)) {
                         $list .= dd(img({src=>$imgsrc, alt=>$alt})                          $list .= dd(img({src=>$imgsrc, alt=>$alt})
                                 . " " . $Tournament{'Title'} . " " .                                  . " " . $Tournament{'Title'} . " " .
                                     $Tournament{'PlayedAt'} . $qnum) .                                      ($Tournament{'PlayedAt'}||"") . $qnum) .
                                 dl(                                  dl(
                                         dd("["                                          dd("["
                                                 . a({href=>tourhref($textid,0)},                                                  . a({href=>tourhref($textid,0)},
Line 1063  sub PrintTournament { Line 1145  sub PrintTournament {
                 } else {                  } else {
                         $list .= dd(a({href=>                          $list .= dd(a({href=>
                                  $url . "?tour=$textid&comp=1"},                                   $url . "?tour=$textid&comp=1"},
                                 img({src=>'/icons/compressed.gif', alt=>'[ZIP]', border=>1})). " " .                                   img({src=>'/icons/compressed.gif', alt=>'[ZIP]', border=>1}))                           .  
                                   " " . 
                                 img({src=>$imgsrc, alt=>$alt})                                  img({src=>$imgsrc, alt=>$alt})
                                 . " " . a({href=>tourhref($textid,0,1)},                                  . " " . a({href=>tourhref($textid,0,1)},
                                 $Tournament{'Title'}. " ".                                  $Tournament{'Title'}. " ".
                                           $Tournament{'PlayedAt'}||'') . $qnum);                                            ($Tournament{'PlayedAt'}||'')) . $qnum); 
                 }                  }
         }          }
         $output .= dl($list);          $output .= dl($list);
Line 1099  sub Suffix { Line 1182  sub Suffix {
         return $suffix;          return $suffix;
 }  }
   
   
   sub Suffix1 {
           my ($qnum) = @_;
           my ($suffix) = 'Ñ' if $qnum =~ /[234]$/;
          $suffix = 'Å' if $qnum =~ /1$/;
          $suffix = 'Ê' if $qnum =~ /[567890]$/ || $qnum =~ /1.$/;
           return $suffix;
   }
   
   sub Suffix2 {
           my ($qnum) = @_;
           my ($suffix) = 'É' if $qnum =~ /[234]$/;
          $suffix = 'Ø' if $qnum =~ /1$/;
          $suffix = 'ÅÊ' if $qnum =~ /[567890]$/ || $qnum =~ /1.$/;
           return $suffix;
   }
   
 sub IsTour {  sub IsTour {
         my ($dbh, $Id,$n) = @_;          my ($dbh, $Id,$n) = @_;
   
Line 1169  sub PrintTour { Line 1269  sub PrintTour {
   
         my $n=$Tour{'Number'};          my $n=$Tour{'Number'};
         if ($answer == 0) {          if ($answer == 0) {
                   my $nn=".$n";
                   $nn="" if ($n==1 && !&IsTour($dbh, $Tour{'ParentId'}, $n + 1));
                   
                 $bottom .=                  $bottom .=
                         "[" . a({href=>tourhref($fname,1)},                           "[" . a({href=>tourhref("$fname$nn",1)}, 
                          "ÏÔ×ÅÔÙ") .  "] " . br;                           "ÏÔ×ÅÔÙ") .  "] " . br;
         }          }
         if ($n>1) {          if ($n>1) {
Line 1202  sub PrintField { Line 1305  sub PrintField {
             $value =~ s/<[\/\w]*?>//sg;              $value =~ s/<[\/\w]*?>//sg;
         } else {          } else {
             $value =~ s/^\s+/<br>&nbsp;&nbsp;&nbsp;&nbsp;/mg;              $value =~ s/^\s+/<br>&nbsp;&nbsp;&nbsp;&nbsp;/mg;
               $value =~ s/(\s+)-+(\s+)/$1&#0150;$2/mg;
               $value =~ s/\s+\&#0150/&nbsp;\&#0150/mg 
                           if $value !~ /^\|/;
             $value =~ s/^\|([^\n]*)/<pre>$1<\/pre>/mg;              $value =~ s/^\|([^\n]*)/<pre>$1<\/pre>/mg;
             $value =~ s/\s+-+\s+/&nbsp;&#0150; /mg;  
             $value =~ s/(http:\/\/\S+[^\s\)\(\,\.])/<a href="$1">$1<\/a>/g if $header !~ /^á×ÔÏ/;              $value =~ s/(http:\/\/\S+[^\s\)\(\,\.])/<a href="$1">$1<\/a>/g if $header !~ /^á×ÔÏ/;
 #           $value =~ s/(http:\/\/(?:\w+.)+[\w\\\~]+(\?[^\s.]+)?)/<a href="$1">$1<\/a>/g if $header !~ /^á×ÔÏ/;  #           $value =~ s/(http:\/\/(?:\w+.)+[\w\\\~]+(\?[^\s.]+)?)/<a href="$1">$1<\/a>/g if $header !~ /^á×ÔÏ/;
 #           $value =~ s/(\s)"/$1&#147;/mg;  #           $value =~ s/(\s)"/$1&#147;/mg;
Line 1347  $output.="</span>" Line 1452  $output.="</span>"
   
         }          }
         $output=~s/\(pic: ([^\)]*)\)/<p><img src="\/znatoki\/images\/db\/$1"><p>/g unless $text;          $output=~s/\(pic: ([^\)]*)\)/<p><img src="\/znatoki\/images\/db\/$1"><p>/g unless $text;
         my $qid=param('tour') ? (param('tour').".$Question{'Number'}" ): '';          $paramtour||=param("tour");
           my $qid=$paramtour ? ($paramtour.".$Question{'Number'}" ): '';
   
         $output.=br.a({href=> $url."?metod=proxy&          $output.=br.a({href=> $url."?metod=proxy&
 qid=$qid"}, 'âÌÉÚËÉÅ ×ÏÐÒÏÓÙ').p  qid=$qid"}, 'âÌÉÚËÉÅ ×ÏÐÒÏÓÙ').p
Line 1357  qid=$qid"}, 'âÌÉÚËÉÅ ×ÏÐÒÏÓÙ').p Line 1463  qid=$qid"}, 'âÌÉÚËÉÅ ×ÏÐÒÏÓÙ').p
   
 # Returns the total number of questions currently in the DB.  # Returns the total number of questions currently in the DB.
 sub GetQNum {  sub GetQNum {
         my ($dbh) = @_;          my ($dbh,$x) = @_;
         my ($sth) = $dbh->prepare("SELECT COUNT(*) FROM Questions");          my ($sth) = $dbh->prepare("SELECT COUNT(*) FROM Questions");
         $sth->execute;          $sth->execute;
         my $tmp=($sth->fetchrow)[0];          my $tmp=($sth->fetchrow)[0];
         $sth->finish;          $sth->finish;
         return $tmp;          ($sth)=  $dbh -> prepare("select distinct count(first) FROM equalto");
                      $sth -> execute;
           my ($c)=$sth->fetchrow;
   
   #                  $i++  while ( my  ($first, $second)=$sth -> fetchrow)
   #                  {
   #                       $forbidden{$first}=1;
   #                  }
                     $sth->finish;
   
           return $tmp-($x?$c:0);
 }  }
 sub GetMaxQId {  sub GetMaxQId {
         my ($dbh) = @_;          my ($dbh) = @_;
Line 1383  sub Get12Random { Line 1499  sub Get12Random {
         srand;          srand;
         my $where=0;          my $where=0;
         my $r=int (rand(10000));          my $r=int (rand(10000));
           my $w1=$r<5000? "QuestionId<50000 ":"QuestionId>=50000";
           $w1=1 if $url=~/zaba/;
           $w1=1 if $type!~/þ/;
         foreach (split '', $type)          foreach (split '', $type)
         {          {
            $where.= " OR (Type ='$_') OR (Type ='$_ä') ";             $where.= " OR (Type ='$_') OR (Type ='$_ä') ";
Line 1393  sub Get12Random { Line 1511  sub Get12Random {
 #   $q="select QuestionId, QuestionId/$r-floor(QuestionId/$r) as val   #   $q="select QuestionId, QuestionId/$r-floor(QuestionId/$r) as val 
 #       from Questions where $where order by val limit $num";  #       from Questions where $where order by val limit $num";
 # ëÏÇÄÁ ÎÁ ËÕÌÉÞËÁÈ ÐÏÑ×ÉÔÓÑ mysql >=3.23 ÎÁÄÏ ÚÁÍÅÎÉÔØ ÎÁ order by rand();  # ëÏÇÄÁ ÎÁ ËÕÌÉÞËÁÈ ÐÏÑ×ÉÔÓÑ mysql >=3.23 ÎÁÄÏ ÚÁÍÅÎÉÔØ ÎÁ order by rand();
    $q="select QuestionId from Questions where $where order by rand() limit $num";     $q="select QuestionId from Questions where ($w1) AND ($where) order by rand() limit $num";
   
   
    $sth=$dbh->prepare($q);     $sth=$dbh->prepare($q);
Line 1412  sub Get12Random { Line 1530  sub Get12Random {
   
 sub Include_virtual {  sub Include_virtual {
         my ($fn, $output) = (@_, '');          my ($fn, $output) = (@_, '');
           return "\n<!--#include virtual=\"$fn\"-->\n" 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";
   
         while (<F>) {          while (<F>) {
                 if (/<!--#include/o) {                  if (/<!--#include/o) {
                         s/<!--#include virtual="\/(.*)" -->/&Include_virtual($1)/e;                          s/<!--#include virtual="\/?([^\/].*)" -->/&Include_virtual($1)/e;
                 }                  }
                 if (/<!--#exec/o) {                  if (/<!--#exec/o) {
                         s/<!--#exec.*cmd\s*=\s*"([^"]*)".*-->/`$1`/e;                          s/<!--#exec.*cmd\s*=\s*"([^"]*)".*-->/`$1`/e;
                 }                  }
                 $output .= $_;                  $output .= $_;
         }          }
         return $output;          return $output||"";
 }  }
   
 sub PrintArchive {  sub PrintArchive {
Line 1450  sub PrintAll { Line 1568  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 1471  sub PrintAll { Line 1591  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 1504  sub PrintDates { Line 1624  sub PrintDates {
                 next                  next
                         if (!$array[0]);                          if (!$array[0]);
                 %Tournament = &GetTournament($dbh, $array[0]);                  %Tournament = &GetTournament($dbh, $array[0]);
                    my $textid;
                    if ($textid=$Tournament{'FileName'})
                    {
                      $textid=~s/\.txt//;
                    }
                    elsif ($textid=$Tournament{'Number'})
                    {
                         $fname=~s/\.txt//;
                         $textid="$fname.$textid";
                    }
                    else {$textid=$Tournament{'Id'}};
       $list .= dd(img({src=>"/icons/folder.gif", alt=>"[*]"}) .        $list .= dd(img({src=>"/icons/folder.gif", alt=>"[*]"}) .
       " " . a({href=>tourhref($Tournament{'FileName'},0,1)},        " " . a({href=>tourhref($textid,0,1)},
       $Tournament{'Title'}, $Tournament{'PlayedAt'}||''));        $Tournament{'Title'}, $Tournament{'PlayedAt'}||''));
         }          }
         $sth->finish;          $sth->finish;
Line 1624  sub WriteFile { Line 1755  sub WriteFile {
   
   my $query= "SELECT Id, Title, Copyright, Info, URL,     my $query= "SELECT Id, Title, Copyright, Info, URL, 
                       Editors, EnteredBy, PlayedAt, CreatedAt                         Editors, EnteredBy, PlayedAt, CreatedAt 
                      from Tournaments where FileName=".$dbh->quote("$fname.txt");                       from Tournaments where FileName=
                        '$fname' OR FileName=".$dbh->quote("$fname.txt");
   my $sth=$dbh->prepare($query);    my $sth=$dbh->prepare($query);
   my (%Question,%editor,%qnumber,%copyright,%author,%vid,%tourtitle);    my (%Question,%editor,%qnumber,%copyright,%author,%vid,%tourtitle);
   $sth->execute;    $sth->execute;
Line 1767  sub WriteFile { Line 1899  sub WriteFile {
   
 sub Bottom  sub Bottom
 {  {
         my $output.=&Include_virtual("../dimrub/db/footer.html");          my $output.=&Include_virtual("$footer")||"";
         $output.=p."<center><font size=-2>ïÂÎÏ×ÌÅÎÉÅ: ".&Include_virtual("../dimrub/db/date")."</center></font>";          $output.=p."<center><font size=-2>ïÂÎÏ×ÌÅÎÉÅ: ".&Include_virtual("$datefooter")."</center></font>";
         $output.=<<EEE          $output.=<<EEE
 <SCRIPT LANGUAGE="JavaScript">  <SCRIPT LANGUAGE="JavaScript">
 function toggle(e) {  function toggle(e) {
Line 1790  MAIN: Line 1922  MAIN:
 {  {
                   
         setlocale(LC_CTYPE,'russian');          setlocale(LC_CTYPE,'russian');
           POSIX::setlocale( &POSIX::LC_ALL, $thislocale );
         my($i, $tour);          my($i, $tour);
         my($text) = (param('text')) ? 1 : 0;          my($text) = (param('text')) ? 1 : 0;
         if (param('qid') && (param('qid')=~/^\d+$/)) {          $tour = (param('tour')) ? param('tour') : 0;
            my $destination='http://db.chgk.info/search.html';          my $texttour=$tour;
           my ($sth,$dbh);
           my($dsn) = "DBI:mysql:database=$dbname;host=$dbhost";
           $dbh = DBI->connect($dsn, $dbuser, $dbpass) 
   #       $dbh = DBI->connect("DBI:mysql:$dbname", $username, $dbpass)
                   or do {
                           print header.h1("÷ÒÅÍÅÎÎÙÅ ÐÒÏÂÌÅÍÙ") . "âÁÚÁ ×ÏÐÒÏÓÏ× ×ÒÅÍÅÎÎÏ ÎÅ
                           ÒÁÂÏÔÁÅÔ. úÁÈÏÄÉÔÅ ÐÏÐÏÚÖÅ.";
                           print &Include_virtual("$reklama") if $url!~/localhost/;
                       print end_html;
                           die "Can't connect to DB chgk\n";
                   };
   
   
           if (param('qid') && (param('qid')=~/^\d+$/) || $tour && $tour=~/^\d+$/) {
              my $destination='http://chgk.zaba.ru/search.html';
 #               print header (-'Content-Type' => 'text/html',  #               print header (-'Content-Type' => 'text/html',
 #                -'Location:'=> 'http:\\db.chgk.info');  #                -'Location:'=> 'http:\\db.chgk.info');
                 Redirect($destination);                  Redirect($destination);
                 exit                  exit
         }          }
   
         if ($text) {          if ($tour && !param('qnumber') && (!param('answers')||(param('answers')<=1)))
           {       
                   my $n=param('tour');
                   $n=~s/.txt$//;        
                   my $gr=($n=~/^[A-Z]/) || (-e "$realHTMLDIR$n.html");
                   my $destination=tourhref($tour,param('answers')||0,$gr);
                   my $d=$destination;
                   $d=~s/$HTMLDIR/$realHTMLDIR/;
   #               print header.$destination;
                   print header."$d|".(-e "$realHTMLDIR$n.html");
                   if (-e $d) {
                           Redirect($destination);
                           exit
                   }
                   $d=~s/\.\d+//;
                   $destination=~s/\.\d+//;
   print br.br.$d;
                   if (-e $d) {
                           Redirect($destination);
                           exit
                   }
   
           }
   
           if ($tour !~ /^[0-9]*$/) {          
                       if ($tour=~/\./)
                       {
                           my ($fname,$n)= split /\./ , $tour;
   
                           $sth = $dbh->prepare(
                          "SELECT t2.Id FROM Tournaments as t1, 
                           Tournaments as t2 
                           WHERE (t1.FileName = '$fname.txt' OR t1.FileName='$fname')
                           AND t1.Id=t2.ParentId AND t2.Number=$n");
                       }   
                       else 
                           {
                             $sth = $dbh->prepare("SELECT Id FROM Tournaments
                                        WHERE FileName = '$tour.txt' OR 
                                          FileName = '$tour'");
                           }
                       $sth->execute;
                       $tour = ($sth->fetchrow)[0];
                       $sth->finish;
           }
   
   
           if ($text && !param ('comp')) {
                 print header('text/plain');                  print header('text/plain');
         } else {print header;}          } elsif (!param('comp')) {
         my($dbh) = DBI->connect("DBI:mysql:chgk", "piataev", "")                  print header(-charset =>'koi8-r')}
                 or do {  
                         print h1("÷ÒÅÍÅÎÎÙÅ ÐÒÏÂÌÅÍÙ") . "âÁÚÁ ×ÏÐÒÏÓÏ× ×ÒÅÍÅÎÎÏ ÎÅ  
                         ÒÁÂÏÔÁÅÔ. úÁÈÏÄÉÔÅ ÐÏÐÏÚÖÅ.";  
                         print &Include_virtual("../dimrub/db/reklama.html") if $url!~/localhost/;  
                     print end_html;  
                         die "Can't connect to DB chgk\n";  
                 };  
           my $sstr=param('sstr');            my $sstr=param('sstr');
             $opt_z||=param("makehtml");
           if (param('qid')) {            if (param('qid')) {
               my $sth;                my $sth;
               my $qid=param('qid');                my $qid=param('qid');
Line 1819  MAIN: Line 2008  MAIN:
                 {                  {
                     my ($fname,$t,$n)= split /\./ , $qid;                      my ($fname,$t,$n)= split /\./ , $qid;
                     $n=$t,$t='' unless $n;                      $n=$t,$t='' unless $n;
                       $t||=1;
                     if ($t)                      if ($t)
                     {                      {
                         $sth = $dbh->prepare(                          $sth = $dbh->prepare(
                        "SELECT t2.Id FROM Tournaments as t1,                          "SELECT t2.Id FROM Tournaments as t1, 
                         Tournaments as t2                           Tournaments as t2 
                         WHERE t1.FileName = '$fname.txt'                          WHERE (t1.FileName = '$fname.txt' OR t1.FileName='$fname')
                         AND t1.Id=t2.ParentId AND t2.Number=$t");                          AND t1.Id=t2.ParentId AND t2.Number=$t");
                     }                         }   
                     else   #                   else 
                         {  #                       {
                           $sth = $dbh->prepare("SELECT Id FROM Tournaments  #                          $sth = $dbh->prepare("SELECT Id FROM Tournaments
                                      WHERE FileName = '$fname.txt'");  #                                    WHERE FileName = '$fname.txt' OR FileName = '$fname'" );
                         }  #                       }
                     $sth->execute;                      $sth->execute;
                     $tour = ($sth->fetchrow)[0];                      $tour = ($sth->fetchrow)[0];
                     $sth->finish;                      $sth->finish;
Line 1872  td {font-size: x-small; font-family : sa Line 2062  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 ($usehash && !$opt_z && length ($qs)<=255 && $qs !~ /(sstr)|(rand)|(comp)|(all=)/i) {
                 my $sth=$dbh->prepare("SELECT page,times,t from hash where query=".$dbh->quote($qs));                  my $sth=$dbh->prepare("SELECT page,times,t from hash where query=".$dbh->quote($qs));
                 $sth->execute();                  $sth->execute();
                 my ($p,$times,$t)=$sth->fetchrow();                  my ($p,$times,$t)=$sth->fetchrow();
Line 1899  th {font-size: x-small; font-family : sa Line 2089  th {font-size: x-small; font-family : sa
                   }                    }
                   $sth->finish;                    $sth->finish;
         }          }
                 $tour = (param('tour')) ? param('tour') : 0;  
                 my $sth;  
                 if ($tour !~ /^[0-9]*$/) {  
                     if ($tour=~/\./)  
                     {  
                         my ($fname,$n)= split /\./ , $tour;  
   
                         $sth = $dbh->prepare(  
                        "SELECT t2.Id FROM Tournaments as t1,   
                         Tournaments as t2   
                         WHERE t1.FileName = '$fname.txt'  
                         AND t1.Id=t2.ParentId AND t2.Number=$n");  
                     }     
                     else   
                         {  
                           $sth = $dbh->prepare("SELECT Id FROM Tournaments  
                                      WHERE FileName = '$tour.txt' OR   
                                        FileName = '$tour'");  
                         }  
                     $sth->execute;  
                     $tour = ($sth->fetchrow)[0];  
                     $sth->finish;  
                 }  
   
   
         if (param('rand')) {          if (param('rand')) {
Line 1969  EOT Line 2136  EOT
         elsif (param('getfile')){          elsif (param('getfile')){
            $globaloutput.=&writefile             $globaloutput.=&writefile
         } elsif (param('all')) {          } elsif (param('all')) {
            my $destination='http://db.chgk.info/all.html';  #          my $destination='http://db.chgk.info/all.html';
                 Redirect($destination);  #               Redirect($destination);
                 exit;  #                exit;
 #               $globaloutput.=&PrintAll($dbh, 0);                  $globaloutput.=&PrintAll($dbh, 0);
         } elsif (param('from_year') && param('to_year')) {          } elsif (param('from_year') && param('to_year')) {
                 $globaloutput.=&PrintDates($dbh);                  $globaloutput.=&PrintDates($dbh);
         } elsif (param('comp')) {          } elsif (param('comp')) {
             $globaloutput.="Content-Type: application/octet-stream\n";              print "Content-Type: application/octet-stream\n";
             $globaloutput.="Content-Type: application/force-download\n";              print  "Content-Type: application/force-download\n";
             $globaloutput.="Content-Type: application/download\n";              print  "Content-Type: application/download\n";
             $globaloutput.="Content-Type: application/x-zip-compressed; name=db.zip\n";              print  "Content-Type: application/x-zip-compressed; name=$texttour.zip\n";
             $globaloutput.="Content-Disposition: attachment; filename=db.zip \n\n";              print "Content-Disposition: attachment; filename=$texttour.zip \n\n";
             $tour ||= 0;              $tour ||= 0;
             my (@files) = &PrintArchive($dbh, $tour);              my (@files) = &PrintArchive($dbh, $tour);
             WriteFile($dbh,$_) foreach @files;              WriteFile($dbh,$_) foreach @files;
             open F, "$ZIP -j - @files |";              open F, "$ZIP -j - @files |";
             binmode(F);              binmode(F);
             binmode(STDOUT);              binmode(STDOUT);
             $globaloutput.= join "",<F>;              print join "",<F>;
             close F;              close F;
             $dbh->disconnect;              $dbh->disconnect;
             exit;              exit;
Line 2003  EOT Line 2170  EOT
             exit;              exit;
   
         }           } 
         elsif (!$opt_z) {          elsif (!$opt_z && !param("makehtml")) {
                 my $QuestionNumber=0;                  my $QuestionNumber=0;
                 my $qnum;                  my $qnum;
                 if ($qnum=param('qnumber')){                  if ($qnum=param('qnumber')){
Line 2013  EOT Line 2180  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 {
                   open TS, "timestamp";                    $opt_z=1;
                     $url="http://db.chgk.info/cgi-bin/db.cgi";
                     open TS, $timestamp;
                   my $d=$dbh->quote(<TS>);                    my $d=$dbh->quote(<TS>);
                   close TS;                    close TS;
                   my ($sth) = $dbh->prepare("SELECT t1.Id, t1.FileName, t1.Type,                     open FF, ">${realHTMLDIR}index.html" or die "ERROR! - ${HTMLDIR}index.html\n";
                         count(t2.Id)                          my $o=$globaloutput;
                      FROM Tournaments as t1, Tournaments as t2                         $o.=&PrintTournament($dbh, 0, 0);
                      WHERE t1.CreatedAt>$d AND t2.ParentId=t1.Id GROUP BY t1.Id");                         $o.=&Bottom;
                          print FF $o;
                     close FF;
                     open FF, ">${realHTMLDIR}all.html" or die "ERROR! - ${HTMLDIR}all.html\n";
                          $o=$globaloutput;
                          $o.=&PrintAll($dbh,0);
                          $o.=&Bottom;
                          print FF $o;
                          close FF;
   
   
   #                 my ($sth) = $dbh->prepare("SELECT t1.Id, t1.FileName, t1.Type, 
   #                       count(t2.Id) 
   #                     FROM Tournaments as t1, Tournaments as t2
   #                    WHERE t1.CreatedAt>$d AND t2.ParentId=t1.Id GROUP BY t1.Id");
   my ($sth) = $dbh->prepare("SELECT t1.Id, t1.FileName, t1.Type, count(t2.Id)  FROM Tournaments as t1  LEFT JOIN Tournaments as t2 
    ON t2.ParentId=t1.id WHERE t1.CreatedAt>=$d GROUP BY t1.Id");
                   $sth->execute;                    $sth->execute;
                   my ($Id,$fname,$type,$c);                    my ($Id,$fname,$type,$c);
                   while (($Id,$fname,$type,$c)=$sth->fetchrow,$Id) {                    while (($Id,$fname,$type,$c)=$sth->fetchrow,$Id) {
                        next unless $fname;
                      print "$fname\n";                       print "$fname\n";
                      $fname=~s/\.txt$//;                       $fname=~s/\.txt$//;
 print "  c=$c\n";         
                      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;
                          $paramtour=$fname;
                        $o.=&PrintTournament($dbh, $Id, 0);                         $o.=&PrintTournament($dbh, $Id, 0);
                        $o.=&Bottom;                         $o.=&Bottom;
                        print FF $o;                         print FF $o;
Line 2049  print "  c=$c\n"; Line 2235  print "  c=$c\n";
                        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;
Line 2064  print "  c=$c\n"; Line 2250  print "  c=$c\n";
         }          }
         if (!$opt_z){           if (!$opt_z){ 
           print $globaloutput;            print $globaloutput;
           if (($qs!~ /(rand)|(sstr)|(comp)/i) && (length $qs<=255)) {            if (($qs!~ /(rand)|(sstr)|(comp)/i) && (length $qs<=255) && $usehash) {
                 $globaloutput=  $dbh->quote($globaloutput);                  $globaloutput=  $dbh->quote($globaloutput);
                 $dbh->do("insert into hash (query,page) values (".                  $dbh->do("insert into hash (query,page) values (".
                 $dbh->quote($qs).                  $dbh->quote($qs).

Removed from v.1.101  
changed lines
  Added in v.1.130


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>