From adaa1f628f04a6af247e142edbea679578b90fef Mon Sep 17 00:00:00 2001
From: Jacek Kowalski <Jacek@jacekk.info>
Date: Sat, 15 Apr 2017 11:43:18 +0000
Subject: [PATCH] Add layers with stops and stop points
---
proxy.php | 65 ++++++++++++++++++++++++++++++--
1 files changed, 61 insertions(+), 4 deletions(-)
diff --git a/proxy.php b/proxy.php
index dad3670..f91989a 100644
--- a/proxy.php
+++ b/proxy.php
@@ -1,21 +1,78 @@
<?php
+function is_number($str) {
+ $str = (string)$str;
+
+ return
+ ctype_digit($str)
+ OR
+ (
+ substr($str, 0, 1) == '-'
+ AND
+ ctype_digit(substr($str, 1))
+ );
+}
+
$base_proxy = 'http://www.ttss.krakow.pl/internetservice';
$method = [
'/services/lookup/autocomplete/json' => [
'query' => function() { return TRUE; },
],
+ '/services/lookup/stopsByCharacter' => [
+ 'character' => 'ctype_alnum',
+ ],
'/services/passageInfo/stopPassages/stop' => [
- 'stop' => 'ctype_alnum',
+ 'stop' => 'is_number',
'mode' => function($mode) { return in_array($mode, ['arrival', 'departure']); },
],
'/services/tripInfo/tripPassages' => [
- 'tripId' => 'ctype_digit',
+ 'tripId' => 'is_number',
'mode' => function($mode) { return in_array($mode, ['arrival', 'departure']); },
- #'vehicleId' => 'ctype_digit',
+ #'vehicleId' => 'is_number',
+ ],
+ '/geoserviceDispatcher/services/stopinfo/stops' => [
+ 'left' => 'is_number',
+ 'bottom' => 'is_number',
+ 'right' => 'is_number',
+ 'top' => 'is_number',
+ ],
+ '/geoserviceDispatcher/services/stopinfo/stopPoints' => [
+ 'left' => 'is_number',
+ 'bottom' => 'is_number',
+ 'right' => 'is_number',
+ 'top' => 'is_number',
+ ],
+ '/geoserviceDispatcher/services/pathinfo/route' => [
+ 'id' => 'is_number',
+ 'direction' => 'is_number',
+ ],
+ '/geoserviceDispatcher/services/pathinfo/vehicle' => [
+ 'id' => 'is_number',
+ ],
+ '/geoserviceDispatcher/services/vehicleinfo/vehicles' => [
+ 'lastUpdate' => 'ctype_digit',
+ 'positionType' => function($type) { return in_array($type, ['CORRECTED', 'NORMAL']); },
+ 'colorType' => function($type) { return in_array($type, ['ROUTE_BASED']); },
],
'/services/routeInfo/routeStops' => [
- 'routeId' => 'ctype_alnum'
+ 'routeId' => 'is_number',
],
+ '/services/stopInfo/stop' => [
+ 'stop' => 'is_number',
+ ],
+ '/services/stopInfo/stopPoint' => [
+ 'stopPoint' => 'is_number',
+ ],
+ '/services/passageInfo/stopPassages/stopPoint' => [
+ 'stopPoint' => 'is_number',
+ 'mode' => function($mode) { return in_array($mode, ['arrival', 'departure']); },
+ 'startTime' => 'ctype_digit',
+ 'timeFrame' => 'ctype_digit',
+ ],
+];
+$rewrite = [
+ '/lookup/autocomplete/json' => '/services/lookup/autocomplete/json',
+ '/passageInfo/stopPassages/stop' => '/services/passageInfo/stopPassages/stop',
+ '/routeInfo/routeStops' => '/services/routeInfo/routeStops',
];
$rewrite = [
'/lookup/autocomplete/json' => '/services/lookup/autocomplete/json',
--
Gitblit v1.9.1