<?php
ob_start();
// session_start();
header("Expires: Mon, 20 Mar 1998 12:01:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

require_once("Sigma.php");

// mb_http_output('UTF-8');
$tpl =& new HTML_Template_Sigma('.','./template/cache');

//redireccionamientos.
$tpl->loadTemplateFile('nhl.htm');
$tpl->setVariable('fecha', date("d/m/Y"));
$colores = "";
$archivo = $_GET['file'];
if (file_exists($archivo))
{
  // $tpl->setVariable('dep', 'NATIONAL HOCKEY LEAGUE (NHL)');
   //60;

  $afl = 1;
  $nhl = 1;
  if(is_readable($archivo))
  {

   if (!$myxml=simplexml_load_file($archivo))
        echo 'Error al Cargar Archivo XML';
       else
       {

        foreach($myxml as $node)
        {
              if ($colores == "grey")
              {
                  $tpl->setVariable('colores', '');
                  $colores = "";
              }
               else
               {
                 $tpl->setVariable('colores', ' class="grey"');
                 $colores = "grey";
               }

               $timegame = explode(":", $node->TimeGame);
               $hora = $timegame[0].':'.$timegame[1];
               //$meridian = $timegame[2];

                if($timegame[2] == 'p.' || $timegame[2] == 'P.')
                 $meridian = 'PM';
               elseif($timegame[2] == 'a.' || $timegame[2] == 'A.')
                 $meridian = 'AM';
               else
                 $meridian = $timegame[2];

                  $tpl->setVariable('dep',   $node->Liga);

                  $tpl->setVariable('nu'  ,BlankSpace($node->Orden));

                  $tpl->setVariable('hora',$hora);
                  $tpl->setVariable('espa',$meridian);
                  $tpl->setVariable('vId',$node->VisTeam);

                  $tpl->setVariable('eq_visitante',   $node->EquipoVisitante);
                  $tpl->setVariable('lId', $node->LocTeam);

                  $tpl->setVariable('eq_local',   ($node->EquipoLocal));

                  $tpl->setVariable('q1rlv',     utf8_decode(BlankSpace($node->RLPPVis.' '.$node->PriceRLPPVis)));
                  $tpl->setVariable('q1rll',     utf8_decode(BlankSpace($node->RLPPLoc.' '.$node->PriceRLPPLoc)));

                  $tpl->setVariable('q1mlv',     utf8_decode(BlankSpace($node->PriceMLPPVis)));
                  $tpl->setVariable('q1mll',     utf8_decode(BlankSpace($node->PriceMLPPLoc)));

                  $tpl->setVariable('tq1',       utf8_decode(BlankSpace($node->TotalPP)));

                  $tpl->setVariable('q2rlv',     utf8_decode(BlankSpace($node->RLSPVis.' '.$node->PriceRLSPVis)));
                  $tpl->setVariable('q2rll',     utf8_decode(BlankSpace($node->RLSPLoc.' '.$node->PriceRLSPLoc)));

                  $tpl->setVariable('q2mlv',    utf8_decode(BlankSpace($node->PriceMLSPVis)));
                  $tpl->setVariable('q2mll',    utf8_decode(BlankSpace($node->PriceMLSPLoc)));

                  $tpl->setVariable('tq2',       utf8_decode(BlankSpace($node->TotalSP)));

                  $tpl->setVariable('q3rlv',     utf8_decode(BlankSpace($node->RLTPVis.' '.$node->PriceRLTPVis)));
                  $tpl->setVariable('q3rll',     utf8_decode(BlankSpace($node->RLTPLoc.' '.$node->PriceRLTPLoc)));


                  $tpl->setVariable('q3mlv',     utf8_decode(BlankSpace($node->PriceMLTPVis)));
                  $tpl->setVariable('q3mll',     utf8_decode(BlankSpace($node->PriceMLTPLoc)));

                  $tpl->setVariable('tq3',       utf8_decode(BlankSpace($node->TotalTP)));


                  $tpl->setVariable('q4rlv',     utf8_decode(BlankSpace($node->RLJCVis.' '.$node->PriceRLJCVis)));
                  $tpl->setVariable('q4rll',     utf8_decode(BlankSpace($node->RLJCLoc.' '.$node->PriceRLJCLoc)));

                  $tpl->setVariable('q4mlv',     utf8_decode(BlankSpace($node->PriceMLJCVis)));
                  $tpl->setVariable('q4mll',     utf8_decode(BlankSpace($node->PriceMLJCLoc)));

                  $tpl->setVariable('tq4',       utf8_decode(BlankSpace($node->TotalJC)));
                  //$registro++;

               $tpl->parse('bloque2');

        }//for.
       }//else
   }//is readable.
}
$tpl->show();

?>