#!/usr/local/bin/perl -w
#use strict;
use DBI;
use CGI::Minimal;
use vars qw($sql_server $sql_db $sql_table $sql_user $sql_pass $tpl_dir $mdate $stdhdr $tpl $dbh $sth $row $mrow @drow @str $todayb);
$sql_server = 'localhost';
$sql_db = 'euro2000';
$sql_user = 'euro2000';
$sql_pass = '3ur02OOO';
if( $^O=~/linux/i ) {
$tpl_dir = '/usr/local/apache/cgi-bin/online/html';
} else {
$tpl_dir = '/opt/clients/gazeta/cgi-bin/online/html';
}
sub getmd {
my ($comma, $commb, $commc, $commd, $varstr) = @_;
my ($todaya, $sstra, $sstrb, $mrowa, $mrowb);
$sth->execute($comma,$commb,$commc,$commd,$comma,$commb,$commc,$commd);
while ($row=$sth->fetchrow_hashref)
{
(@drow)=split(/-/,$row->{match_date});
$todaya = "$drow[0]-$drow[1]-$drow[2]";
if (($todaya lt $todayb)||($row->{score_1} != 'NULL'))
{
$mrowa="$row->{score_1}:$row->{score_2}";
$mrowb="$row->{score_2}:$row->{score_1}";
} else
{
$mrowa="$drow[2]\.$drow[1]";
$mrowb="$drow[2]\.$drow[1]";
}
if ($row->{teama} eq $comma)
{
if ($row->{teamb} eq $commb) {$sstra="${varstr}1x2::"; $sstrb="${varstr}2x1::";}
if ($row->{teamb} eq $commc) {$sstra="${varstr}1x3::"; $sstrb="${varstr}3x1::";}
if ($row->{teamb} eq $commd) {$sstra="${varstr}1x4::"; $sstrb="${varstr}4x1::";}
$tpl=~s/$sstra/$mrowa/g;
$tpl=~s/$sstrb/$mrowb/g;
}
if ($row->{teama} eq $commb)
{
if ($row->{teamb} eq $comma) {$sstra="${varstr}2x1::"; $sstrb="${varstr}1x2::";}
if ($row->{teamb} eq $commc) {$sstra="${varstr}2x3::"; $sstrb="${varstr}3x2::";}
if ($row->{teamb} eq $commd) {$sstra="${varstr}2x4::"; $sstrb="${varstr}4x2::";}
$tpl=~s/$sstra/$mrowa/g;
$tpl=~s/$sstrb/$mrowb/g;
}
if ($row->{teama} eq $commc)
{
if ($row->{teamb} eq $comma) {$sstra="${varstr}3x1::"; $sstrb="${varstr}1x3::";}
if ($row->{teamb} eq $commb) {$sstra="${varstr}3x2::"; $sstrb="${varstr}2x3::";}
if ($row->{teamb} eq $commd) {$sstra="${varstr}3x4::"; $sstrb="${varstr}4x3::";}
$tpl=~s/$sstra/$mrowa/g;
$tpl=~s/$sstrb/$mrowb/g;
}
if ($row->{teama} eq $commd)
{
if ($row->{teamb} eq $comma) {$sstra="${varstr}4x1::"; $sstrb="${varstr}1x4::";}
if ($row->{teamb} eq $commb) {$sstra="${varstr}4x2::"; $sstrb="${varstr}2x4::";}
if ($row->{teamb} eq $commc) {$sstra="${varstr}4x3::"; $sstrb="${varstr}3x4::";}
$tpl=~s/$sstra/$mrowa/g;
$tpl=~s/$sstrb/$mrowb/g;
}
# if ($todaya lt $todayb)
# {
# if ($row->{teama} eq $comma) {$mrow="$row->{score_1}:$row->{score_2}";}
# else {$mrow="$row->{score_2}:$row->{score_1}";}
# } else {$mrow="$drow[2]\.$drow[1]";}
#
# print "$todaya == $todayb\n";
# print "$row->{match_id}!!$mrow!!\n";
# $tpl=~s/$varstr/$mrow/g;
#exit;
}
}
sub html_die {
print "Content-type: text/html\n\n$_[0]";
}
sub show_channels {
my ($sel_id)=shift;
my ($tmp);
@str = localtime;
$tmp = 1900+$str[5];
$todayb = "$tmp-";
$tmp = "";
if ($str[4]<9) {$tmp = "0";}
$todayb .="$tmp";
$tmp = $str[4]+1;
$todayb .="$tmp-";
$tmp = "";
if ($str[3]<9) {$tmp = "0";}
$todayb .="$tmp$str[3]";
local $/=undef;
open(T,"$tpl_dir/groupa.html") or die "$stdhdr Unable to open template file euro-tabs.html";
$tpl=; close(T);
$dbh=DBI->connect("dbi:mysql:database=$sql_db;host=$sql_server",$sql_user,$sql_pass);
html_die "Cannot connect: $DBI::errstr" unless $dbh;
$sth=$dbh->prepare("select match_date, score_1, score_2, team1_id as teama, team2_id as teamb from matches where matches.match_date>\"2000-06-09\" and team1_id in (?,?,?,?) and team2_id in (?,?,?,?) order by match_date");
getmd(9,13,12,3,"::gA");
# getmd(6,16,17,10,"::gB");
# getmd(15,11,18,14,"::gC");
# getmd(5,7,4,8,"::gD");
print $tpl;
$sth->finish;
$dbh->disconnect;
}
# ----------------------------------------------------------------------------
# main
# ----------------------------------------------------------------------------
my ($q,$act,$newq,$neww,$pair,$name,$value,$yourip,$zlo,$stdhdr,$ip,$form,$timestamp,$newip,$arein,$ipf);
$q=CGI::Minimal->new;
print "Content-type: text/html\n\n";
show_channels();
Португалия: игры с участниками Евро2000 за последние 15 лет
|