Diff for /db/prgsrc/db.cgi between versions 1.120 and 1.121

version 1.120, 2003/06/04 23:18:46 version 1.121, 2003/06/23 02:09:35
Line 10  use vars qw($opt_z); Line 10  use vars qw($opt_z);
 use Getopt::Std;  use Getopt::Std;
 getopts('z');  getopts('z');
 $opt_z||=param("makehtml");  $opt_z||=param("makehtml");
   my $timestamp="_timestamp.tmp";
 my $paramtour;  my $paramtour;
 my $withanswers=param('answer')||param('answers');  my $withanswers=param('answer')||param('answers');
 open STDERR, ">/var/tmp/errors1";  open STDERR, ">/var/tmp/errors1";
Line 24  $reklama="../reklama.html" if $opt_z; Line 25  $reklama="../reklama.html" if $opt_z;
 $footer="../footer.html" if $opt_z;  $footer="../footer.html" if $opt_z;
 $datefooter="../date" if $opt_z;  $datefooter="../date" if $opt_z;
 my $HTMLDIR="/znatoki/dimrub/db/baza/";  my $HTMLDIR="/znatoki/dimrub/db/baza/";
 $HTMLDIR="/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/piataev/public_html/dimrub/db/baza/";    $realHTMLDIR="/home/piataev/public_html/dimrub/db/files/";
 }  }
 my $usehtml=$opt_z||0;  my $usehtml=$opt_z||0;
   $usehtml=1;
 my $usewas=0;  my $usewas=0;
 my $cashednumber=500;  my $cashednumber=500;
 my $outputnumber=10;  my $outputnumber=10;
Line 126  sub NewEnough { Line 128  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 141  by clicking <A HREF="$destination">here< Line 149  by clicking <A HREF="$destination">here<
 </HTML>  </HTML>
 EndOfHTML  EndOfHTML
 ;  ;
   =cut
 }  }
   
   
Line 1198  sub PrintTour { Line 1207  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.$n",1)},                           "[" . a({href=>tourhref("$fname$nn",1)}, 
                          "ответы") .  "] " . br;                           "ответы") .  "] " . br;
         }          }
         if ($n>1) {          if ($n>1) {
Line 1826  MAIN: Line 1838  MAIN:
         POSIX::setlocale( &POSIX::LC_ALL, $thislocale );          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 $texttour=$tour;
           my ($sth,$dbh);
           $dbh = DBI->connect("DBI:mysql:chgk", "piataev", "")
                   or do {
                           print 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://db.chgk.info/search.html';             my $destination='http://db.chgk.info/search.html';
 #               print header (-'Content-Type' => 'text/html',  #               print header (-'Content-Type' => 'text/html',
 #                -'Location:'=> 'http:\\db.chgk.info');  #                -'Location:'=> 'http:\\db.chgk.info');
Line 1834  MAIN: Line 1859  MAIN:
                 exit                  exit
         }          }
   
           if ($tour && (!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')) {          if ($text && !param ('comp')) {
                 print header('text/plain');                  print header('text/plain');
         } elsif (!param('comp')) {print header;}          } elsif (!param('comp')) {print header;}
         my($dbh) = DBI->connect("DBI:mysql:chgk", "piataev", "")  
                 or do {  
                         print h1("Временные проблемы") . "База вопросов временно не  
                         работает. Заходите попозже.";  
                         print &Include_virtual("$reklama") 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");            $opt_z||=param("makehtml");
           if (param('qid')) {            if (param('qid')) {
Line 1935  th {font-size: x-small; font-family : sa Line 1999  th {font-size: x-small; font-family : sa
                   }                    }
                   $sth->finish;                    $sth->finish;
         }          }
                 $tour = (param('tour')) ? param('tour') : 0;  
                 my $sth;  
                 my $texttour=$tour;  
                 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 (param('rand')) {          if (param('rand')) {
Line 2059  EOT Line 2099  EOT
         else {          else {
                   $opt_z=1;                    $opt_z=1;
                   $url="http://db.chgk.info/cgi-bin/db.cgi";                    $url="http://db.chgk.info/cgi-bin/db.cgi";
                   open TS, "timestamp";                    open TS, $timestamp;
                   my $d=$dbh->quote(<TS>);                    my $d=$dbh->quote(<TS>);
                   close TS;                    close TS;
                   open FF, ">${realHTMLDIR}index.html" or die "ERROR! - ${HTMLDIR}index.html\n";                    open FF, ">${realHTMLDIR}index.html" or die "ERROR! - ${HTMLDIR}index.html\n";

Removed from v.1.120  
changed lines
  Added in v.1.121


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