Bimba.git

ref: aa22149d0c7ee91a66b0bb82baebb740fe3843cc

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
<?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");
    // todo send file
    echo $current;
}
?>