ref: ba7b9a6a9eb48ca5f80b65b8ed532a497a4a9c7a
converter/gtfs.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 |
<?php require 'vendor/mustangostang/spyc/Spyc.php'; $metadata = Spyc::YAMLLoad('metadata.yml'); $today = date('Ymd'); $current = ''; $sizeU = ''; $sizeC = ''; foreach($metadata as $row) { $start = $row['start']; $end = $row['end']; if ($start <= $today and $today <= $end) { $current = $row['id']; $sizeU = $row['size_uncompressed']; $sizeC = $row['size_compressed']; break; } } unset($row); $etag = $_SERVER['HTTP_ETAG']; if ($etag == $current) { http_response_code(304); } else { header("ETag: $current"); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="timetable.db.gz"'); header('Content-Length: ' . filesize("$current.db.gz")); readfile("$current.db.gz"); } ?> |