<?php
  include("./inc/func.php");
  
  $cas=time();
  
  db_update("uloziste", "PRIKAZ=\"procesy\", 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=\"procesy\") ) order by DATUM desc");
     sleep(1);
     $i++;
  };  
  
?>
<html>
<head>
<title>spuštěné procesy</title>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
    <style>
      <!--    
      
      body  {margin: 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>
</head>
<body>
  <div style="font-weight: bold; font-size: 13px; background-color: #ccd9f4;">spuštěné procesy</div>
  <div style="margin-bottom: 15px;">kliknutím proces ukončíte</div>
  
  <?php
    if(!$chyba)
    {
       $result=explode("|",$result);
       for($i=1;$i<count($result);$i++)
       {
          $separator=strpos($result[$i]," ");
          $pid=substr($result[$i],0,$separator);
          $jmeno=substr($result[$i],$separator+1);
          
          ?>
          <div><a href="javascript:window.opener.prikaz('kill <?php echo $pid; ?>');window.close();" title="Ukončí proces s PID=<?php echo $pid; ?>"><?php echo $jmeno; ?></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>
