<!DOCTYPE html>
<html>
<head>
<title>PE1RXF APRS server</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="refresh" content="600">

<link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="css/popup.css">
<link rel="stylesheet" href="css/font-awesome.min.css">

<meta http-equiv="refresh" content="3; url='./5ghz.php" />
</head>
<body>

<?php
    #Data format:
    #0,1,2,3,4,5,6,7,8,9

    #  0 = acces point off/on (0/1)
    #  1 = station stal off/on (0/1)
    #  2 = station tiny house off/on (0/1)
    $status = array_map('str_getcsv', file("/home/marcel/ham/aprs_utils/5ghz/5ghz-status.dat"));
    
    if ($status[0][0] == 0)
        $execuatable_string = sprintf("/home/marcel/ham/aprs_utils/power-on-hamnet-link.sh > /dev/null 2>&1 &");
    else
        $execuatable_string = sprintf("/home/marcel/ham/aprs_utils/power-off-hamnet-link.sh > /dev/null 2>&1 &");
                    
    exec("$execuatable_string");

?> 

<div class="header">
  <a href="index.php" >
    <h1><i class="fa fa-home" aria-hidden="true"></i>&nbsp; PE1RXF 5 GHz access point manager</h1>
  </a>
</div>

<div class="row">
  <div class="col-3 col-s-3 menu">
    <ul>
      <li><h3>Access point: <?php if ($status[0][0] == 0) echo "OFF";else echo "ON" ?></h3></li>
      <li><h3>Station stal: <?php if ($status[0][1] == 0) echo "OFF";else echo "ON" ?></h3></li>
      <li><h3>Station tiny house: <?php if ($status[0][2] == 0) echo "OFF";else echo "ON" ?></h3></li>
    </ul>
  </div>

  <div class="col-6 col-s-9"  id="main_page">

    <h1>Toggle state of Access Point</h1>
    <h1>This may take a while</h1>
  
  </div>
  
  <div class="col-3 col-s-12 menu">
      <ul>
        <li><h3>Access point: <?php if ($status[0][0] == 0) echo "OFF";else echo "ON" ?></h3></li>
        <li><h3>Station stal: <?php if ($status[0][1] == 0) echo "OFF";else echo "ON" ?></h3></li>
        <li><h3>Station tiny house: <?php if ($status[0][2] == 0) echo "OFF";else echo "ON" ?></h3></li>
    </ul>
  </div>
</div>

</body>
</html>


