-
Notifications
You must be signed in to change notification settings - Fork 2
/
dataset.php
39 lines (29 loc) · 1.09 KB
/
dataset.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
39
<?php
header('Content-type: application/json; charset=utf-8');
header("Expires: Tue, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
include_once 'Config.php';
include_once CLASSES.'Response.class.php';
include_once CLASSES.'PoisDataset.class.php';
include_once CLASSES.'Util.class.php';
include_once CLASSES.'Database.class.php';
if(USE_DATABASE) {
// open db connection
Database::connect();
$poisDataset = Response::createFromDb(DatasetTypes::Poi, DATASET_ID);
Util::printJsonObj(new Response($poisDataset));
Database::disconnect();
}
else {
$handle = fopen(DATASET_FILE, "r");
$json = fread($handle, filesize(DATASET_FILE));
fclose($handle);
// TODO: should type check the source file
$assocArray = json_decode($json, true);
$poisDataset = Response::createFromArray(DatasetTypes::Poi, $assocArray);
Util::printJsonObj(new Response($poisDataset));
}
?>