<?php
include('protector.php');
/*
This file is very hardcoded for gboxcontrol,it will not work if gboxcontrol is not running.
*/


function start(){
$trigger = "gboxstart.trigger";
$h = fopen($trigger, 'w') or die("De momento não é possivel ligar o gbox");
fclose($h);
}

function stop(){
$trigger = "gboxstop.trigger";
$h = fopen($trigger, 'w') or die("De momento não é possivel desligar o gbox");
fclose($h);
}

function restart(){
$trigger = "gboxrestart.trigger";
$h = fopen($trigger, 'w') or die("De momento não é possivel reiniciar o gbox");
fclose($h);
}

if (isset($_POST['action'])) {
$action = $_POST['action'];

if ($action == 'Iniciar') {
start();
}

if ($action == 'Desligar') {
stop();
}

if ($action == 'Reiniciar') {
restart();
}
header('Location: reboot.php');
exit();
}
include('header.php');

?>
<style type="text/css">
<!--
.style1 {color: #000000}
-->
</style>
<p align="center" class="style1" style="margin-left: 20">&nbsp;</p>
<p align="center" class="style1" style="margin-left: 20"><font face="Arial" size="4">Controlo do Gbox </font></p>
<table width="340"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="16"><img src="images/top_lef.gif" alt="f" width="16" height="16" /></td>
    <td height="16" background="images/top_mid.gif"><img src="images/top_mid.gif" alt="g" width="16" height="16" /></td>
    <td width="24"><img src="images/top_rig.gif" alt="h" width="24" height="16" /></td>
  </tr>
  <tr>
    <td width="16" background="images/cen_lef.gif"><img src="images/cen_lef.gif" alt="d" width="16" height="11" /></td>
    <td align="center" valign="middle" bgcolor="#FFFFFF">&nbsp;&nbsp;</font></p>
  <font face="Arial" size="4" color="#000000">
  <center><img src="images/gbox.jpg" /></center>
  <blockquote>
  <div align="center">
    <?php 
if (!file_exists('gboxrun.trigger')) {print "<font color=\"#FF0000\">Gbox Offline<br>";} else {print "<font color=\"#669900\">Gbox Online<br>";}
?>
    
  </div>
  <form id="form1" name="form1" method="post" action="reboot.php">
    <p align="center">
      <input name="action" type="submit" id="start" value="Iniciar" />
      <input name="action" type="submit" id="stop" value="Desligar" />
      <input name="action" type="submit" id="restart" value="Reiniciar" />
    </p>
</form>
  </blockquote>
</td>
    <td width="24" background="images/cen_rig.gif"><img src="images/cen_rig.gif" alt="e" width="24" height="11" /></td>
  </tr>
  <tr>
    <td width="16" height="16"><img src="images/bot_lef.gif" alt="a" width="16" height="16" /></td>
    <td height="16" background="images/bot_mid.gif"><img src="images/bot_mid.gif" alt="b" width="16" height="16" /></td>
    <td width="24" height="16"><img src="images/bot_rig.gif" alt="c" width="24" height="16" /></td>
  </tr>
</table>
      <p style="margin-left: 20"><font face="Arial" size="2" color="#000000">&nbsp;</font></p>
<?php 
include('footer.php');
?>
  </div>
