ref: 684a5b38ec0977ecaf2bd1d06f701061d14e7e02
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 35 |
<?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_IF_NONE_MATCH']; 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")); header('X-Uncompressed-Content-Length: ' . $sizeU); readfile("$current.db.gz"); } ?> |