forked from ffansbach/de-map
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.php
36 lines (29 loc) · 1.04 KB
/
data.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
<?php
/**
* ajax response with parseresult
*
* this will try to load a cched result if not older than 24h
*/
header('Cache-Control: no-cache, must-revalidate');
$offset = 24 * 60 * 60;
header ("Expires: " . gmdate ("D, d M Y H:i:s", time() + $offset) . " GMT");
header('Content-Type: application/json');
require 'config.php';
require 'lib/simpleCachedCurl.inc.php';
require 'lib/nodelistparser.php';
$apiUrl = 'https://raw.githubusercontent.com/freifunk/directory.api.freifunk.net/master/directory.json';
$parser = new nodeListParser();
$parser->setCachePath(dirname(__FILE__).'/cache/');
$parser->setSource($apiUrl);
$parser->addAdditional('ffnw', array(
'name' => 'Freifunk NordWest',
'nameShort' => 'FF NordWest',
'url' => 'https://netmon.nordwest.freifunk.net/'
)
);
$parseResult = $parser->getParsed(isset($_REQUEST[$forceReparseKey]));
$response = array(
'communities' => $parseResult['communities'],
'allTheRouters' => $parseResult['routerList']
);
echo json_encode($response, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);