Last change
on this file since 7799 was 7799, checked in by Pieter Naber, 15 years ago |
Small bug fixing + formating code
|
File size:
1.1 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 |
|
---|
8 | require_once('config.php');
|
---|
9 | require_once($config['file_init']);
|
---|
10 |
|
---|
11 | $time = isset($_GET['time']) ? $_GET['time'] : mktime() - (mktime() % 300);
|
---|
12 |
|
---|
13 | // Check if the file is already cached
|
---|
14 | if (!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 | header('Location: ' . $config['root'] . '/kml/nodemap-' . $time . '.kml');
|
---|
34 | ?>
|
---|
Note:
See
TracBrowser
for help on using the repository browser.