source: trunk/src/kml.php@ 7841

Last change on this file since 7841 was 7841, checked in by rick, 15 years ago

kml hiding comment

File size: 1.3 KB
Line 
1<?php
2/*
3 * Project: NodeMap2.0
4 * File: kml.php
5 * Purpose: Creates up-to-date KML if not exists, otherwise redirect to last KML file in KML folder
6 */
7
8require_once('config.php');
9require_once($config['file_init']);
10
11$time = isset($_GET['time']) ? $_GET['time'] : mktime() - (mktime() % 300);
12
13// Check if the file is already cached
14if (!is_link($config['root'] . '/kml/nodemap-' . $time . '.kml')) {
15 // No file found, let's create a new cache file
16
17 // First off, we create a new KMLFile object
18 $kmlFile = new KMLFile();
19
20 // Let's try to read the node location file
21 $nodeLocation = new FileHandler($config['node_location_file'], 'r');
22 $kmlFile->parseLocationFile($nodeLocation->read());
23
24 // Let's try to read the node status file
25 $nodeStatus = new FileHandler($config['node_status_file'], 'r');
26 $kmlFile->parseStatusFile($nodeStatus->read());
27
28 // Write the file to the server
29 $file = new FileHandler($config['root'] . '/kml/nodemap-' . $time . '.kml', 'w');
30 $file->write($kmlFile->toString());
31}
32
33/* Instead of exposing the kml file, one could also argue to hide it at the back
34 * so you can can so some dirty hacking and more easy ACL
35 * $kmlFile = fopen($config['root'] . '/kml/nodemap-' . $time . '.kml');
36 * print $fread($kmlFile);
37 * fclose($kmlFile);
38 */
39header('Location: kml/nodemap-' . $time . '.kml');
40?>
Note: See TracBrowser for help on using the repository browser.