<?php
if(@$_GET['adresar'])
{

  include("./inc/func.php");
  
  $cas=time();
  
  db_update("uloziste", "PRIKAZ=\"adresare ". trim($_GET['adresar']) ."\", 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=\"adresare ". trim($_GET['adresar']) ."\") ) order by DATUM desc");
     sleep(1);
     $i++;
  };  
  
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
    <style>
      <!--    
      
      body  {margin: 0px 0px 0px 0px; font-family: Arial; background-color: #f0f0f6; font-size: 12px; text-align: center;}
      
      a {color: #080; text-decoration: none;}
      a:hover {text-decoration: underline; font-weight: bold;}
                  
      -->
    </style>
    <script language="JavaScript">
      
      parent.document.getElementById('nabidka').style.visibility= 'hidden';
      parent.document.getElementById('prubeh').style.visibility="hidden";
      
      function nahrat(viditelne)
      {
         parent.document.getElementById('nahrat').style.visibility= viditelne?'visible':'hidden';
      };
    
    </script>
</head>
<body>
  <div style="font-weight: bold; font-size: 13px; background-color: #ccd9f4;">adresář</div>
  
  <?php
    if(!$chyba)
    {
    ?>
    <?php
      $result=explode("|",$result);
    ?>
    <script language="JavaScript">
      nahrat(<?php echo (count($result)>1?1:0); ?>);
      
      var d = new Date();
      
      parent.document.getElementById('soubory').src='user_dir_soubory.php?cas='+d.getTime()<?php if(count($result)>1){ ?>+'&adresar=<?php echo addslashes(entita(trim(@$result[0]))); ?>'<?php ;}; ?>;
      parent.document.adresa='<?php echo entita(substr(trim(@$result[0]),0,-1)); ?>';
      parent.document.adresa2='<?php echo addslashes(substr(trim(@$result[0]),0,-1)); ?>';
    </script>
    <div style="background-color: #d9e0f2;"><a href="?cas=<?php echo time(); ?>&adresar=<?php echo entita(trim(@$result[0])); ?>"><?php echo str_replace("\\", "\\ ", trim(@$result[0])); ?></a></div>
    <?php
       for($i=1;$i<count($result);$i++)
       {
          ?>
          <div align="left" style="padding-left: 5px; padding-right: 5px;"><a style="<?php if(substr($result[$i],strrpos($result[$i],"\\")+1)=='..'){ ?>font-size: 18px; font-weight: bold;<?php ;}; ?>" href="?cas=<?php echo time(); ?>&adresar=<?php echo entita(trim($result[$i])); ?>\." title="<?php echo trim($result[$i]); ?>"><?php echo substr($result[$i],strrpos($result[$i],"\\")+1); ?></a></div>
          <?php
       };
    }else{
    ?>
      <div align="center" style="color: #f00;">Vypršel čas pro odpověď<br>
      <a href="javascript:document.location.reload();">obnovit</a></div>
    <?php
    };
  ?>
</body>
</html>
<?php
;};
?>
