forked from FreifunkFranken/VPNkeyXchange
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hoods.php
38 lines (30 loc) · 960 Bytes
/
hoods.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
require_once "db.class.php";
require "function.php";
$polydata = getPolyhoodsByHood(); // read polygon data for later use
try {
$q = 'SELECT ID, active, name, lat, lon, ESSID_AP FROM hoods;';
$rs = db::getInstance()->prepare($q);
$rs->execute();
} catch (PDOException $e) {
exit(showError(500, $e));
}
$hoods = array();
while ( $result = $rs->fetch ( PDO::FETCH_ASSOC ) ) {
$hood = array();
$hood['id'] = intval($result['ID']);
$hood['active'] = $result['active'];
$hood['name'] = $result['name'];
$hood['essid_ap'] = $result['ESSID_AP'];
if ($result ['lat'] > 0 && $result ['lon'] > 0) {
$hood['lat'] = floatval($result['lat']);
$hood['lon'] = floatval($result['lon']);
}
if(isset($polydata[$result['ID']])) {
$hood['polygons'] = array_values($polydata[$result['ID']]); // we don't need the polyids here
}
array_push($hoods, $hood);
}
header("Content-Type: application/json");
echo json_encode($hoods, JSON_PRETTY_PRINT);
?>