12345678910111213141516171819202122232425 |
- <?php
- require_once "sql.php";
-
- $where = "";
- $array = array();
- if(isset($_GET['id']))
- {
- $id = intval($_GET['id']);
- if($id <= 0)
- error("Invalid id");
-
- $where = "WHERE id=:id";
- $array = array(":id" => $id);
- }
-
- $select = $db->prepare("SELECT * FROM gates ".$where);
- if(!$select->execute($array))
- error("Unable to read gates");
- $gates = array();
- while($gate = $select->fetch())
- $gates[] = array("id" => intval($gate['id']), "name" => $gate['name'],
- "number" => $gate['number'], "lastSeen" => intval(time()));
-
- echo json_encode(array("timestamp" => time(), "gateTimeout" => $gateTimeout, "gates" => $gates));
- ?>
|