Diff for /db/prgsrc/db.cgi between versions 1.95 and 1.99

version 1.95, 2003/04/09 23:31:54 version 1.99, 2003/04/19 22:50:06
Line 23  $outputkvo=100 if $outputkvo>100; Line 23  $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)||(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;
 }  }
   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 137  sub fetchquestion { Line 142  sub fetchquestion {
         my ($sth,$q,$WithTour)=@_;          my ($sth,$q,$WithTour)=@_;
         if ($WithTour) {          if ($WithTour) {
                 ($$q{'Question'},$$q{'Answer'},$$q{'Comments'},$$q{'Authors'},                  ($$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{'Question'},$$q{'Answer'},$$q{'Comments'},$$q{'Authors'},
                   $$q{'Sources'},
                 $$q{'Number'})=                   $$q{'Number'})= 
                 $sth->fetchrow;                  $sth->fetchrow;
         }          }
Line 160  sub SelectQuestions { Line 167  sub SelectQuestions {
   
         my $query;          my $query;
         if ($WithTour) {          if ($WithTour) {
                 $query="SELECT Questions.Question, Answer, Comments, Authors,                  $query="SELECT 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 Questions.Question, Answer, Comments, Authors,Sources,
                         Questions.Number from Questions                           Questions.Number from Questions 
                         WHERE $where";                          WHERE $where";
         }          }
Line 177  sub SelectQuestions { Line 184  sub SelectQuestions {
         return $sth;          return $sth;
 }  }
   
   
 # Reads one question from the DB. Gets DB handler and Question ID.  # Reads one question from the DB. Gets DB handler and Question ID.
 sub GetQuestion {  sub GetQuestion {
         my ($dbh, $QuestionId) = @_;          my ($dbh, $QuestionId) = @_;
Line 766  sub PrintList { Line 772  sub PrintList {
             a({href=>url."?".$qs."\&first=$llprint"},">>").(" "x4)              a({href=>url."?".$qs."\&first=$llprint"},">>").(" "x4)
         }          }
         $Output.= "$nav".br."\n";          $Output.= "$nav".br."\n";
         my @q=@$Questions[$first..$last];          my @q=@$Questions[$first-1..$last-1];
         my %q=();          my %q=();
         my $sth=SelectQuestions($dbh,\@q,1);          my $sth=SelectQuestions($dbh,\@q,1);
         for (my $i = $first; $i <= $last; $i++) {          for (my $i = $first; $i <= $last; $i++) {
Line 1817  th {font-size: x-small; font-family : sa Line 1823  th {font-size: x-small; font-family : sa
                 $globaloutput.=&Include_virtual("../dimrub/db/reklama.html");                  $globaloutput.=&Include_virtual("../dimrub/db/reklama.html");
         }          }
   
        if (length ($qs)<=255 && $qs !~ /(sstr)|(rand)|(comp)/i) {         if (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 1857  th {font-size: x-small; font-family : sa Line 1863  th {font-size: x-small; font-family : sa
                     else                       else 
                         {                          {
                           $sth = $dbh->prepare("SELECT Id FROM Tournaments                            $sth = $dbh->prepare("SELECT Id FROM Tournaments
                                      WHERE FileName = '$tour.txt'");                                       WHERE FileName = '$tour.txt' OR 
                                          FileName = '$tour'");
                         }                          }
                     $sth->execute;                      $sth->execute;
                     $tour = ($sth->fetchrow)[0];                      $tour = ($sth->fetchrow)[0];
Line 1910  EOT Line 1917  EOT
         elsif (param('getfile')){          elsif (param('getfile')){
            $globaloutput.=&writefile             $globaloutput.=&writefile
         } elsif (param('all')) {          } elsif (param('all')) {
                 $globaloutput.=&PrintAll($dbh, 0);             my $destination='http://db.chgk.info/all.html';
                   Redirect($destination);
                   exit;
   #               $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')) {

Removed from v.1.95  
changed lines
  Added in v.1.99


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