<?php
  include("./inc/func.php");

  
  $cas=time();
  
  @unlink("usr/". uzivatel('LOGIN') ."/download.dwn");
  db_update("uloziste", "PRIKAZ=\"get ". trim($_GET['soubor']) ."\", ODPOVED=\"\", DATUM=". $cas, "ID=". $_SESSION['UZIVATEL_ID']);
  
  $result="";
  $i=0;
  $chyba=false;
  
  while(!$result)
  {
     if($i>=9){$chyba=true; break;};
     
     $result=db_vypis1("ODPOVED", "historie where ( (UID=". $_SESSION['UZIVATEL_ID'] .") and (DATUM>=$cas) and (PRIKAZ=\"get ". $_GET['soubor'] ."\") ) order by DATUM desc");
     sleep(1);
     $i++;
  };  

  
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
</head>
<body>
  
  <?php

    if(!$chyba)
    {
  ?>
  <script language="JavaScript">
    window.location='user_dir_download_progress.php?velikost=<?php $result=explode("velikost:", $result); echo substr($result[1],0,-1); ?>';
  </script>
  <?php
    }else{
  ?>
  <script language="JavaScript">
    alert('Vypršel časový limit!');
  </script>
  <?php
    };
  
  ?>
</body>
</html>
