<?php
require "build/db_connect.inc.php"  ;
  if (IsSet($_GET['stat'])){
    if ($_GET['stat']=='start'){
      $query="UPDATE asterisk_stats SET value=1 
              WHERE Status_name=\"runStats\""; 
      $result = mysql_query($query);
      if (!$result) {
         die('Asterisk nelze zapnout:' . mysql_error());
      }
    }
    if ($_GET['stat']=='stop'){
      $query="UPDATE asterisk_stats SET value=3 
              WHERE Status_name=\"runStats\""; 
      $result = mysql_query($query);
      if (!$result) {
         die('Asterisk nelze vypnout:' . mysql_error());
      }
    }
  
  }



  $query="SELECT value FROM asterisk_stats
          WHERE Status_name=\"runStats\"";
          $result = mysql_query($query);
          if (!$result) {
            die('Status nelze zjistit:' . mysql_error());
          }
   list($status) = mysql_fetch_row($result);
   if ($status==0){
   echo "<a href=\"admin_page.php?NEXTFORM=3&stat=start\"><img src=\"files/pictures/off.gif\"></a>";
   }
   if ($status==1){
   echo "<img src=\"files/pictures/change.gif\">";
   }
   if ($status==2){
   echo "<a href=\"admin_page.php?NEXTFORM=3&stat=stop\"><img src=\"files/pictures/on.gif\"></a>";
   } 
   if ($status==3){
   echo "<img src=\"files/pictures/change.gif\">";
   }
   

?>
