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