Skip to content

Commit

Permalink
introduce tracknumber
Browse files Browse the repository at this point in the history
  • Loading branch information
aloxe committed Nov 15, 2024
1 parent 00ed8b1 commit 770c959
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
6 changes: 3 additions & 3 deletions public/datavelo/tracklist.json.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
}
closedir($dir);
sort($tracks);
$trackliste = [];
$tracklist = [];
$i = 0;
foreach ($tracks as $key => $val) {
$date = substr($val, 0, 10);
Expand All @@ -46,8 +46,8 @@
$flag = $flag." ".$lettred.$lettref;
}
$trackobject = (object) ['id' => $i, 'date' => $date, 'name' => $name, 'url' => $val, 'cc' => $cc, 'flag' => $flag];
array_push($trackliste, $trackobject);
array_push($tracklist, $trackobject);
}
}
echo json_encode($trackliste);
echo json_encode($tracklist);
?>
31 changes: 31 additions & 0 deletions public/datavelo/tracknumber.json.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
$velotracks = "json";
$year = $_REQUEST['y'];
/* make sure country is iso 3166 */
if ($_REQUEST['c']) $country = ".".$_REQUEST['c'];

// An array of the json file names
$tracks = array();

//Open images directory
$dir = opendir($velotracks);

//List files in tracks directory
while (($file = readdir($dir)) !== false) {
if (substr($file, -4, 4)=="json") {
// if no selection we display all tracks
if (!$year && !$country) {
if (substr($val, 0, 10) != "2010-01-01") $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
if (substr($val, 0, 10) != "2010-01-01") $tracks[] = $file;
}
}
}
}
closedir($dir);

$trackobject = (object) ['number' => sizeof($tracks)];
echo json_encode($trackobject);
?>

0 comments on commit 770c959

Please sign in to comment.