Improved www.ttss.krakow.pl
Jacek Kowalski
2017-04-12 68aeb4a997a99ac7dde426ad7a3c87205b4f89d2
proxy.php
@@ -1,20 +1,34 @@
<?php
$base_proxy = 'http://www.ttss.krakow.pl/internetservice/services';
$base_proxy = 'http://www.ttss.krakow.pl/internetservice';
$method = [
   '/lookup/autocomplete/json' => [
   '/services/lookup/autocomplete/json' => [
      'query' => function() { return TRUE; },
   ],
   '/passageInfo/stopPassages/stop' => [
   '/services/passageInfo/stopPassages/stop' => [
      'stop' => 'ctype_alnum',
      'mode' => function($mode) { return in_array($mode, ['arrival', 'departure']); },
   ],
   '/routeInfo/routeStops' => [
   '/services/tripInfo/tripPassages' => [
      'tripId' => 'ctype_digit',
      'mode' => function($mode) { return in_array($mode, ['arrival', 'departure']); },
      #'vehicleId' => 'ctype_digit',
   ],
   '/services/routeInfo/routeStops' => [
      'routeId' => 'ctype_alnum'
   ],
];
$rewrite = [
   '/lookup/autocomplete/json' => '/services/lookup/autocomplete/json',
   '/passageInfo/stopPassages/stop' => '/services/passageInfo/stopPassages/stop',
   '/routeInfo/routeStops' => '/services/routeInfo/routeStops',
];
$path = $_SERVER['PATH_INFO'];
if(isset($rewrite[$path])) {
   $path = $rewrite[$path];
}
if(!isset($method[$path])) {
   header('HTTP/1.1 403 Forbidden');
   die('Forbidden');