You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gates.php 616B

12345678910111213141516171819202122232425
  1. <?php
  2. require_once "sql.php";
  3. $where = "";
  4. $array = array();
  5. if(isset($_GET['id']))
  6. {
  7. $id = intval($_GET['id']);
  8. if($id <= 0)
  9. error("Invalid id");
  10. $where = "WHERE id=:id";
  11. $array = array(":id" => $id);
  12. }
  13. $select = $db->prepare("SELECT * FROM gates ".$where);
  14. if(!$select->execute($array))
  15. error("Unable to read gates");
  16. $gates = array();
  17. while($gate = $select->fetch())
  18. $gates[] = array("id" => intval($gate['id']), "name" => $gate['name'],
  19. "number" => $gate['number'], "lastSeen" => intval(time()));
  20. echo json_encode(array("timestamp" => time(), "gateTimeout" => $gateTimeout, "gates" => $gates));
  21. ?>