-
Notifications
You must be signed in to change notification settings - Fork 0
/
tracks.php
40 lines (31 loc) · 916 Bytes
/
tracks.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
40
<?php
$year = $_REQUEST['y'];
/* make sure country is iso 3166 */
if ($_REQUEST['c']) $country = ".".$_REQUEST['c'];
// An array of the image file names
$tracks = array();
$velotracks = "../data/velo/gpx";
//Open images directory
if (is_dir($velotracks)) {
$dir = opendir($velotracks);
//List files in images directory
while (($file = readdir($dir)) !== false)
{
if (substr($file, -3, 3)=="gpx") {
// if no selection we display all tracks
if (!$year && !$country) {
$tracks[] = $file;
}
else if (substr($file, 0, 4)==$year || !$year) { // year in file or no year choice
if (strpos($file, $country) != FALSE || !$country) { // country in file or no country choice
$tracks[] = $file;
}
}
}
}
closedir($dir);
echo json_encode($tracks); //, JSON_PRETTY_PRINT);
} else {
echo('nope');
}
?>