source: trunk/src/kml.php@ 7781

Last change on this file since 7781 was 7771, checked in by Pieter Naber, 15 years ago

Fixed small bug in kml.php.

File size: 1.2 KB
RevLine 
[7768]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
[7771]11$time = isset($_GET['time']) ? $_GET['time'] : mktime() - (mktime() % 300);
[7768]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
[7771]29 $file = new FileHandler($config['root'] . '/kml/nodemap-' . $time . '.kml', 'w');
30 $file->write($kmlFile->toString()); // Function doesn't work yet... Waiting for David...
[7768]31}
32
[7771]33//header('Location: ' . $config['root'] . '/kml/nodemap-' . $time . '.kml');
[7768]34?>
Note: See TracBrowser for help on using the repository browser.