@vidro/map-handler 1.0.18 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,194 +1,264 @@
1
1
  <html>
2
- <head>
3
- <title>🛠️ MAP TESTER</title>
4
- <link rel="stylesheet" href="../tester.css"></link>
5
- <link rel="icon" type="image/png" href="https://www.vidrosoftware.com/favicon/favicon-32x32.png" sizes="32x32" />
6
- <link rel="icon" type="image/png" href="https://www.vidrosoftware.com/favicon/favicon-16x16.png" sizes="16x16" />
7
- </head>
8
- <body onload="checkToken()">
9
- <div class="form">
10
- <div>
11
- Api URL <input type="text" name="apiurl" id="apiurl" value="http://localhost" size="30">
12
- </div>
13
- <div>
14
- User token: <input type="text" name="usertoken" id="usertoken" disabled size="40" value="<?php echo getUserToken(); ?>"> - <button id="btLoginAgain">Login again</button>
15
- </div>
2
+
3
+ <head>
4
+ <title>🛠️ MAP TESTER - FULL DEMO</title>
5
+ <link rel="stylesheet" href="../tester.css">
6
+ </link>
7
+ <link rel="icon" type="image/png" href="https://www.vidrosoftware.com/favicon/favicon-32x32.png" sizes="32x32" />
8
+ <link rel="icon" type="image/png" href="https://www.vidrosoftware.com/favicon/favicon-16x16.png" sizes="16x16" />
9
+ </head>
10
+
11
+ <body onload="checkToken()">
12
+ <div class="form">
13
+ <div>
14
+ Api URL <input type="text" name="apiurl" id="apiurl" value="http://localhost" size="30">
16
15
  </div>
17
- <div class="error hide" id="errorContainer">Errr</div>
18
- <div class="form hide" id="loginContainer">
19
- User: <input type="text" name="user" id="user" value="">
20
- Password: <input type="password" name="pwd" id="pwd" value="">
21
- <button id="btLogin">Log in</button>
16
+ <div>
17
+ User token: <input type="text" name="usertoken" id="usertoken" disabled size="40" value="<?php echo getUserToken(); ?>"> - <button id="btLoginAgain">Login again</button>
22
18
  </div>
19
+ </div>
20
+ <div class="error hide" id="errorContainer">Errr</div>
21
+ <div class="form hide" id="loginContainer">
22
+ User: <input type="text" name="user" id="user" value="">
23
+ Password: <input type="password" name="pwd" id="pwd" value="">
24
+ <button id="btLogin">Log in</button>
25
+ </div>
23
26
 
24
- <div class="form" id="userData">
25
- <h1>Map Properties</h1>
26
- <div>
27
- Project ID
28
- <select id="selectProject">
29
- <?php
30
- $cachedProjects = getCachedProjects();
31
- if(count($cachedProjects)>0){
32
- foreach ($cachedProjects as $pr) {
33
- ?>
34
- <option id="<?php echo $pr; ?>"><?php echo $pr; ?></option>
35
- <?php
36
- }
37
- ?>
38
- <?php
27
+ <div class="form" id="userData">
28
+ <h1>Map Properties</h1>
29
+ <div>
30
+ Project ID
31
+ <select id="selectProject">
32
+ <?php
33
+ $cachedProjects = getCachedProjects();
34
+ if (count($cachedProjects) > 0) {
35
+ foreach ($cachedProjects as $pr) {
36
+ ?>
37
+ <option id="<?php echo $pr; ?>"><?php echo $pr; ?></option>
38
+ <?php
39
39
  }
40
40
  ?>
41
- </select>
42
- </div>
43
- <div>
44
- Zoom: <input type="text" name="zoom" id="zoom" size="5" value=""> <small>Override default zoom level</small>
45
- </div>
46
- <div>
47
- Custom logo: <input type="text" name="logo" id="logo" size="25" value=""> <small>Customize logo</small>
48
- </div>
49
- <div>
50
- Show Layers: <input type="text" name="show_layers" id="show_layers" size="25" value="" placeholder="Arc,LOT"> <small>Show layers on map load</small>
51
- </div>
52
- <div>
53
- Active layer: <input type="text" name="active_layer" id="active_layer" size="25" value=""> <small>Set a layer as active layer on map load</small>
54
- </div>
55
-
56
- <div>
57
- Use Giswater tiled: <input type="checkbox" name="use_giswater_tiled" id="use_giswater_tiled" size="5" value=""> <small>If tiled background available, load it with map render</small>
58
- </div>
59
- <div>
60
- Override Capabitilites extent: <input type="text" name="extent" id="extent" size="55" value="" placeholder="397663,4615771,406392,4623596"> <small>Override project extent</small>
61
- </div>
62
- <div>
63
- Override Capabitilites SRID: <input type="text" name="srid" id="srid" size="10" value="" placeholder="EPSG:2831"> <small>Override project srid</small>
64
- </div>
65
- <hr>
66
- <h5>Development parameters</h5>
67
- <div>
68
- Override iframe url: <input type="text" name="overrideHost" id="overrideHost" size="35" value="http://localhost:3000" placeholder="http://localhost:3000"> <small>Override map component url</small>
69
- </div>
70
- <div>
71
- Debug
72
- <button id="btDebug">Debug</button>
73
- <select id="debug">
74
- <option id="1" selected value=1>Show logs</option>
75
- <option id="0" value=0>Hide logs</option>
76
- </select> <small>Show/hide component logs</small>
77
- </div>
78
- <hr>
79
- <div>
80
- <button id="btLoadMap">Load Map</button> -
81
- <button id="btLoadProjectLayers">Load Project layers</button>
82
- </div>
41
+ <?php
42
+ }
43
+ ?>
44
+ </select>
83
45
  </div>
84
-
85
- <hr/>
86
- <h2>Backgrounds</h2>
87
- <button id="btChangeBackground">Change background</button>: <input type="text" name="newBackground" id="newBackground" size="20" value="catastromeh" placeholder="Google">
88
-
89
- <div id="mapContainer" class="hide">
90
- <div id="Error_container"></div>
91
- <div id="sessionToken"></div>
92
- <div id="iframes-container">
93
- <iframe id="map-frame" name="map-frame" src="" style="width:100%; height:600px;" allow="geolocation"></iframe>
94
- </div>
95
- <hr />
96
- <pre id="Result_container"></pre>
97
-
98
- <hr/>
99
- <h2>Layers</h2>
100
-
101
- Project Layers: <select id="projectlayers"></select> - <small>click on "Load Project Layers button</small> <button id="btToggleLayer">Add / Remove Layer</button><br><br>
102
- Displayed Layers: <select id="layers"></select> -
103
- <button id="btActiveLayer">Set Active Layer</button>
104
- <button id="btGetActiveLayer">Get Active Layer</button>
105
- <span id="currentActiveLayer"></span>
106
- <button id="btReloadDisplayedLayers">Reload displayed layers</button>
107
- <br><br>
108
- Get TOC: <button id="btGetToc">Get TOC</button>
109
-
110
- <br><br>
111
- Override layer properties (gutter, single/multi tile, transparent)
112
- <input type="checkbox" name="overrideLayerProperties" id="overrideLayerProperties" value="">
113
- <div id="containerOverride" style="display: none;">____________________________________________________<br><br>
114
- Gutter: <input type="text" name="gutter" id="gutter" size="5" value="">
115
- <br><br>
116
- Transparent layer:
117
- <input type="checkbox" name="toggleTransparentLayer" id="toggleTransparentLayer" checked value=""><br><br>
118
- SingleTile layer:
119
- <input type="checkbox" name="toggleSingleTile" id="toggleSingleTile" checked value=""><br>
120
- <br>
121
- ____________________________________________________
46
+ <div>
47
+ Zoom: <input type="text" name="zoom" id="zoom" size="5" value=""> <small>Override default zoom level</small>
48
+ </div>
49
+ <div>
50
+ Custom logo: <input type="text" name="logo" id="logo" size="25" value=""> <small>Customize logo</small>
51
+ </div>
52
+ <div>
53
+ Show Layers: <input type="text" name="show_layers" id="show_layers" size="25" value="" placeholder="Arc,LOT"> <small>Show layers on map load</small>
54
+ </div>
55
+ <div>
56
+ Active layer: <input type="text" name="active_layer" id="active_layer" size="25" value=""> <small>Set a layer as active layer on map load</small>
122
57
  </div>
123
58
 
124
- <h4>Tiled layer</h4>
125
- <button id="btToggleGiswaterTiled" disabled="true">Show/hide tiled Giswater tiled background</button>
126
- <input type="checkbox" name="toggleGiswaterTiledCheck" id="toggleGiswaterTiledCheck" size="5" value=""><br><br>
127
- <small>only for giswater projects with tiled enabled</small>
59
+ <div>
60
+ Use Giswater tiled: <input type="checkbox" name="use_giswater_tiled" id="use_giswater_tiled" size="5" value=""> <small>If tiled background available, load it with map render</small>
128
61
  </div>
129
- <h2>Zoom</h2>
130
- <button id="btZoomIn">Zoom In</button>
131
- <button id="btZoomOut">Zoom Out</button>
132
- <button id="btZoomToExtent">Zoom to extent</button>
133
- <br><br>
134
- <button id="btZoomToCoordinates">Zoom to coordinates</button>
135
- ZoomToCoordinates level: <input type="text" name="zoomLevelToCoordinates" id="zoomLevelToCoordinates" size="5" value="4">
136
- <h2>Add geometry</h2>
137
- <button id="btAddPoint">Add point</button>
138
- <button id="btAddPolygon">Add polygon</button>
139
- <button id="btAddLine">Add line</button>
140
- <button id="btClear">Clear geometries</button>
141
- <h2>Info</h2>
142
- <button id="btWMSInfo" disabled="true">WMS Info</button>
143
- <button id="btGiswaterInfo">Giswater Info</button>
144
-
145
- <h2>Geolocation</h2>
146
- <button id="btGeolocalize">Geolocalize User</button>
147
- <button id="btStopGeolocalize">Cancel Geolocalize</button>
148
-
149
- <h2>Highlight</h2>
150
- <button id="btHighlight">Highlight geom</button>
151
- Geom: <input type="text" name="geom" id="geom" size="25" value="">
152
- <br>
153
- Highlight to zoom level: <input type="text" name="zoomLevel" id="zoomLevel" size="5" value=""> or Zoom to geometry: <input type="checkbox" name="zoomToHighlightCheck" id="zoomToHighlightCheck" size="5" value="">
154
- <h2>Giswater Filters</h2>
155
- <button id="btsetGiswaterFilters">Set giswater filters</button> - <button id="btgetGiswaterFilters">Get giswater layer available filters</button><br><br>
156
- <textarea name="giswaterFilters" id="giswaterFilters" rows="10" cols="20">{"expl_id":[1,2,3]}</textarea>
157
- <h2>GeoJSON</h2>
158
- <input type="file" id="geojsonfile" name="geojsonfile" accept="application/json"><small> Select geoJSON file</small><br><br>
159
- <small>Load a geojson from a Giswater layer<b><span id="currentActiveLayerForGeoJSON"></span></b></span></small> <button id="btAddGeoJSONFromGiswater" disabled>Add GeoJSON from Giswater Layer </button>
160
- <input type="hidden" name="geojsondata" id="geojsondata"/>
62
+ <div>
63
+ Override Capabitilites extent: <input type="text" name="extent" id="extent" size="55" value="" placeholder="397663,4615771,406392,4623596"> <small>Override project extent</small>
64
+ </div>
65
+ <div>
66
+ Override Capabitilites SRID: <input type="text" name="srid" id="srid" size="10" value="" placeholder="EPSG:2831"> <small>Override project srid</small>
67
+ </div>
68
+ <hr>
69
+ <h5>Development parameters</h5>
70
+ <div>
71
+ Override iframe url: <input type="text" name="overrideHost" id="overrideHost" size="35" value="http://localhost:3000" placeholder="http://localhost:3000"> <small>Override map component url</small>
72
+ </div>
73
+ <div>
74
+ Debug
75
+ <button id="btDebug">Debug</button>
76
+ <select id="debug">
77
+ <option id="1" selected value=1>Show logs</option>
78
+ <option id="0" value=0>Hide logs</option>
79
+ </select> <small>Show/hide component logs</small>
80
+ </div>
81
+ <hr>
82
+ <div>
83
+ <button id="btLoadMap">Load Map</button> -
84
+ <button id="btLoadProjectLayers">Load Project layers</button>
85
+ </div>
86
+ <div><button id="btMeasureDistance">Measure distance</button> <button id="btMeasureArea">Measure area</button> - <button id="btCancelMeasure">Cancel measure</button></div>
87
+
88
+ </div>
89
+
90
+ <hr />
91
+ <h2>Backgrounds</h2>
92
+ <button id="btChangeBackground">Change background</button>: <input type="text" name="newBackground" id="newBackground" size="20" value="catastromeh" placeholder="Google">
93
+
94
+ <div id="mapContainer" class="hide">
95
+ <div id="Error_container"></div>
96
+ <div id="sessionToken"></div>
97
+ <div id="iframes-container">
98
+ <iframe id="map-frame" name="map-frame" src="" style="width:100%; height:600px;" allow="geolocation"></iframe>
99
+ </div>
100
+ <hr />
101
+ <pre id="Result_container"></pre>
102
+
103
+ <hr />
104
+ <h2>Layers</h2>
105
+
106
+ Project Layers: <select id="projectlayers"></select> - <small>click on "Load Project Layers button</small> <button id="btToggleLayer">Add / Remove Layer</button><br><br>
107
+ Displayed Layers: <select id="layers"></select> -
108
+ <button id="btActiveLayer">Set Active Layer</button>
109
+ <button id="btGetActiveLayer">Get Active Layer</button>
110
+ <span id="currentActiveLayer"></span>
111
+ <button id="btReloadDisplayedLayers">Reload displayed layers</button>
112
+ <br><br>
113
+ Get TOC: <button id="btGetToc">Get TOC</button>
114
+
115
+ <br><br>
116
+ Override layer properties (gutter, single/multi tile, transparent)
117
+ <input type="checkbox" name="overrideLayerProperties" id="overrideLayerProperties" value="">
118
+ <div id="containerOverride" style="display: none;">____________________________________________________<br><br>
119
+ Gutter: <input type="text" name="gutter" id="gutter" size="5" value="">
161
120
  <br><br>
162
- <b>Options</b><br><br>
163
- Stroke color: <input type="text" name="strokecolor" id="strokecolor" size="10" value="#994d4d" placeholder="#000000"> <small>Override stroke color, desfault #ff0000</small><br>
164
- Fill color: <input type="text" name="fillcolor" id="fillcolor" size="10" value="#4d995c" placeholder="#000000"> <small>Override fill color, desfault #ff0000</small><br><br>
165
- <button id="btAddGeoJSON">Add GeoJSON Layer</button> <button id="btClearGeoJSON">Clear GeoJSON Layers</button><br><br>
166
- <input type="text" name="hitTolerance" id="hitTolerance" size="5" value="" placeholder="5"> <small>Override hit tolerance</small><br><br>
121
+ Transparent layer:
122
+ <input type="checkbox" name="toggleTransparentLayer" id="toggleTransparentLayer" checked value=""><br><br>
123
+ SingleTile layer:
124
+ <input type="checkbox" name="toggleSingleTile" id="toggleSingleTile" checked value=""><br>
125
+ <br>
126
+ ____________________________________________________
127
+ </div>
128
+
129
+ <h4>Tiled layer</h4>
130
+ <button id="btToggleGiswaterTiled" disabled="true">Show/hide tiled Giswater tiled background</button>
131
+ <input type="checkbox" name="toggleGiswaterTiledCheck" id="toggleGiswaterTiledCheck" size="5" value=""> - <small>only for giswater projects with tiled enabled</small>
132
+ <br>
133
+ <h4>Vector layer</h4>
134
+ <button id="btAddVectorLayer">Add vector layer</button> <input type="text" name="vectorLayerName" id="vectorLayerName" placeholder="Layer name" size="10" value="test"><br>
135
+ <br><button id="btRemoveVectorLayer">Remove vector layer</button>
136
+ </div>
137
+ <h2>Zoom</h2>
138
+ <button id="btZoomIn">Zoom In</button>
139
+ <button id="btZoomOut">Zoom Out</button>
140
+ <button id="btZoomToExtent">Zoom to extent</button>
141
+ <button id="btCenterToCoordinates">Center map to coordinates </button>
142
+ <br><br>
143
+ <button id="btZoomToCoordinates">Zoom to coordinates</button>
144
+ ZoomToCoordinates level: <input type="text" name="zoomLevelToCoordinates" id="zoomLevelToCoordinates" size="5" value="4">
145
+ <h2>Add geometry</h2>
146
+ <button id="btAddPoint">Add point</button>
147
+ <button id="btAddPolygon">Add polygon</button>
148
+ <button id="btAddLine">Add line</button>
149
+ <button id="btClear">Clear geometries</button>
150
+ <br><br>
151
+ <h3>Draw geometry in a layer</h3>
152
+ <small>Geometry as text</small><br><textarea type="text" name="geomAstext" id="geomAstext" rows="10" cols="20" value=""></textarea>
153
+ <br>Label: <input type="text" name="geomLabel" id="geomLabel" size="10" value="test" placeholder="geom label">
154
+ <br>Id: <input type="text" name="uuid" id="uuid" size="10" value="" placeholder="element unique ID">
155
+ <br>Layer to draw: <input type="text" name="layerToDraw" id="layerToDraw" size="5" value="">
156
+ <br><br><button id="btDrawGeometryInLayer">Draw</button> <button id="btRemoveGeometryInLayer">Remove element</button>
157
+
158
+ <h2>Info</h2>
159
+ <button id="btWMSInfo" disabled="true">WMS Info</button>
160
+ <button id="btGiswaterInfo">Giswater Info</button>
161
+
162
+ <h2>Geolocation</h2>
163
+ <button id="btGeolocalize">Geolocalize User</button>
164
+ <button id="btStopGeolocalize">Cancel Geolocalize</button>
165
+
166
+ <h2>Highlight</h2>
167
+ <button id="btHighlight">Highlight geom</button>
168
+ Geom: <input type="text" name="geom" id="geom" size="25" value="">
169
+ <br>
170
+ Highlight to zoom level: <input type="text" name="zoomLevel" id="zoomLevel" size="5" value=""> or Zoom to geometry: <input type="checkbox" name="zoomToHighlightCheck" id="zoomToHighlightCheck" size="5" value="">
171
+ <h2>Giswater Filters</h2>
172
+ <button id="btsetGiswaterFilters">Set giswater filters</button> - <button id="btgetGiswaterFilters">Get giswater layer available filters</button><br><br>
173
+ <textarea name="giswaterFilters" id="giswaterFilters" rows="10" cols="20">{"expl_id":[1,2,3]}</textarea>
174
+ <h2>GeoJSON</h2>
175
+ <input type="file" id="geojsonfile" name="geojsonfile" accept="application/json"><small> Select geoJSON file</small><br><br>
176
+ <small>Load a geojson from a Giswater layer<b><span id="currentActiveLayerForGeoJSON"></span></b></span></small> <button id="btAddGeoJSONFromGiswater" disabled>Add GeoJSON from Giswater Layer </button>
177
+ <input type="hidden" name="geojsondata" id="geojsondata" />
178
+ <br><br>
179
+ <b>Options</b><br><br>
180
+ Stroke color: <input type="text" name="strokecolor" id="strokecolor" size="10" value="#994d4d" placeholder="#000000"> <small>Override stroke color, desfault #ff0000</small><br>
181
+ Fill color: <input type="text" name="fillcolor" id="fillcolor" size="10" value="#4d995c" placeholder="#000000"> <small>Override fill color, desfault #ff0000</small><br>
182
+ Stroke width: <input type="text" name="strokeWidth" id="strokeWidth" size="2" value="1" placeholder="1"> <small>Override stroke width, desfault 1px</small><br>
183
+ Radius : <input type="text" name="radius" id="radius" size="2" value="6" placeholder="1"> <small>Override poit radius 2px</small><br>
184
+ <h3>Label style</h3>
185
+ Font: <input type="text" name="font" id="font" size="10" value="Arial"><br>
186
+ Font size: <input type="text" name="fontSize" id="fontSize" size="2" value="10"><br><br>
187
+ Label placement: <select id="labelPlacement">
188
+ <option value="line">Line</option>
189
+ <option value="point" selected="selected">Point</option>
190
+
191
+ </select>
192
+ Label align: <select id="labelAlign">
193
+ <option value="center" selected="selected">Center</option>
194
+ <option value="end">End</option>
195
+ <option value="left">Left</option>
196
+ <option value="right">Right</option>
197
+ <option value="start">Start</option>
198
+
199
+ </select>
200
+ Label baseline: <select id="labelBaseline">
201
+ <option value="alphabetic">Alphabetic</option>
202
+ <option value="bottom">Bottom</option>
203
+ <option value="hanging">Hanging</option>
204
+ <option value="ideographic">Ideographic</option>
205
+ <option value="middle" selected="selected">Middle</option>
206
+ <option value="top">Top</option>
207
+ </select><br>
208
+ Label max resolution: <select id="maxReso">
209
+ <option value="38400">38,400</option>
210
+ <option value="19200">19,200</option>
211
+ <option value="9600">9,600</option>
212
+ <option value="4800">4,800</option>
213
+ <option value="2400">2,400</option>
214
+ <option value="1200" selected="selected">1,200</option>
215
+ <option value="600">600</option>
216
+ <option value="300">300</option>
217
+ <option value="150">150</option>
218
+ <option value="75">75</option>
219
+ <option value="32">32</option>
220
+ <option value="16">16</option>
221
+ <option value="8">8</option>
222
+ </select> Display: <select id="display">
223
+ <option value="hide">Hide</option>
224
+ <option value="normal">Normal</option>
225
+ <option value="shorten">Shorten</option>
226
+ <option value="wrap" selected="selected">Wrap</option>
227
+ </select><br>
228
+ Label stroke color: <input type="text" name="fontStrokeColor" id="fontStrokeColor" size="10" value="#994d4d" placeholder="#000000"> <small>Override stroke color, desfault #ff0000</small><br>
229
+ Label Fill color: <input type="text" name="fontFillColor" id="fontFillColor" size="10" value="#4d995c" placeholder="#000000"> <small>Override fill color, desfault #ff0000</small><br>
230
+ Label stroke width: <input type="text" name="fontStrokeWidth" id="fontStrokeWidth" size="2" value="1" placeholder="1"> <small>Override stroke width, desfault 1px</small><br>
231
+ <br>
232
+ <button id="btAddGeoJSON">Add GeoJSON Layer</button> <button id="btClearGeoJSON">Clear GeoJSON Layers</button><br><br>
233
+ <input type="text" name="hitTolerance" id="hitTolerance" size="5" value="" placeholder="5"> <small>Override hit tolerance</small><br><br>
234
+
235
+ Selected GeoJSON Layer: <select id="geojsonlayers"></select> - <button id="btGeoJSONInfo" disabled="true">GeoJSON Info</button> <button id="btRemoveGeoJSONLayer" disabled="true">Remove GeoJSON Layer</button><br><br>
236
+
237
+
238
+ <!--<script src="https://unpkg.com/@vidro/map-handler@1.0.12/dist/map-handler.js"></script>-->
239
+ <script src="../../dist/map-handler.js"></script>
240
+ <script src="./tester.js"></script>
241
+ <script src="./apidemo.js"></script>
242
+ </body>
167
243
 
168
- Selected GeoJSON Layer: <select id="geojsonlayers"></select> - <button id="btGeoJSONInfo" disabled="true">GeoJSON Info</button> <button id="btRemoveGeoJSONLayer" disabled="true">Remove GeoJSON Layer</button><br><br>
169
-
170
-
171
- <!--<script src="https://unpkg.com/@vidro/map-handler@1.0.12/dist/map-handler.js"></script>-->
172
- <script src="../../dist/map-handler.js"></script>
173
- <script src="./tester.js"></script>
174
- <script src="./apidemo.js"></script>
175
- </body>
176
244
  </html>
177
245
  <?php
178
- function getCachedProjects(){
246
+ function getCachedProjects()
247
+ {
179
248
 
180
249
  $cacheFileName = "cachedTokenData.dat";
181
- if(file_exists($cacheFileName) && time() - filemtime($cacheFileName) < 86400){ // 24 hours
250
+ if (file_exists($cacheFileName) && time() - filemtime($cacheFileName) < 86400) { // 24 hours
182
251
  $chachedProjects = file_get_contents($cacheFileName);
183
252
  }
184
- return explode(",",$chachedProjects);
253
+ return explode(",", $chachedProjects);
185
254
  }
186
255
 
187
256
 
188
- function getUserToken(){
257
+ function getUserToken()
258
+ {
189
259
 
190
260
  $cacheFileName = "cachedToken.dat";
191
- if(file_exists($cacheFileName) && time() - filemtime($cacheFileName) < 86400){ // 24 hours
261
+ if (file_exists($cacheFileName) && time() - filemtime($cacheFileName) < 86400) { // 24 hours
192
262
  $userToken = file_get_contents($cacheFileName);
193
263
  }
194
264
  return $userToken;