Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

gates.php 698B

123456789101112131415161718192021222324252627
  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'], "address" => $gate['address'],
  20. "port" => intval($gate['port']), "lastSeen" =>
  21. strtotime($gate['lastSeen']));
  22. echo json_encode(array("timestamp" => time(), "gateTimeout" => $gateTimeout, "gates" => $gates));
  23. ?>