source: trunk/src/map/inc/kmlHandler.php@ 7832

Last change on this file since 7832 was 7827, checked in by janveeden, 15 years ago

Gebruiker and beheerder view are now different. Beheerder view shows all info, gebruiker only a bit of info. Fixed typo in kmlHandler.php. Added a Math.random to calls to node_info.php to prevent unwanted caching.

  • Property svn:eol-style set to native
File size: 2.8 KB
Line 
1<?php
2//$file contains place of the KML file we will be getting our node information from
3function get_node_array($file)
4{
5 //Check if the file exists, if it does we load it. If it doesn't we exit and return an error message
6 if (file_exists($file))
7 {
8 $xml = simplexml_load_file($file);
9 }
10 else
11 {
12 exit('Failed to open'.$file);
13 }
14
15 //Counter starts at 0. For every foreach done counter will go up by one. Thus resulting in total nodes added(counter starts at 0 so add 1 to the total )
16 $counter = 0;
17
18 //Now we go through the xml files, storing the data in an array called $markers. More data can be stored by adding more rows in the array
19 foreach($xml->Document->Folder->Placemark as $placemark)
20 {
21 /*
22 * Getting all data from the datatags in the KML file.
23 * First we declare variables we will use.
24 * Then we itirate trough all the data and fill the variables
25 */
26 $location = "";
27 $status = "";
28 $interfaces = "";
29 $masterIP = "";
30 $nodeType = "";
31 $type = "";
32 $hostname = "";
33 $hasBeenChecked = "";
34 $checkExecutionTime = "";
35 $currentState = "";
36 $lastCheck = "";
37 $problemHasBeenAcknowledged = "";
38
39 foreach($placemark->ExtendedData->Data as $data)
40 {
41 foreach($data->attributes() as $nameAttribute => $name)
42 {
43 if($name == "location")
44 $location = $data->value;
45
46 if($name == "status")
47 $status = $data->value;
48
49 if($name == "interfaces")
50 $interfaces = $data->value;
51
52 if($name == "masterIP")
53 $masterIP = $data->value;
54
55 if($name == "nodeType")
56 $nodeType = $data->value;
57
58 if($name == "type")
59 $type = $data->value;
60
61 if($name == "hostName")
62 $hostname = $data->value;
63
64 if($name == "hasBeenChecked")
65 $hasBeenChecked = $data->value;
66
67 if($name == "checkExecutionTime")
68 $checkExecutionTime = $data->value;
69
70 if($name == "lastCheck")
71 $lastCheck = $data->value;
72
73 if($name == "currentState")
74 $currentState = $data->value;
75
76 if($name == "problemHasBeenAcknowledged")
77 $problemHasBeenAcknowledged = $data->value;
78 }
79 }
80
81 /*
82 * We now fill up our array with Longitude and Latitude and Name by accessing $placemark
83 * Then we fill the rest of the array with the variables we declared and filled earlier
84 */
85
86 $markers[] = array( "latitude"=>$placemark->LookAt->latitude,
87 "longitude"=>$placemark->LookAt->longitude,
88 "name"=>$placemark->name,
89 "location"=>$location,
90 "status"=>$status,
91 "interfaces"=>$interfaces,
92 "masterIP"=>$masterIP,
93 "nodeType"=>$nodeType,
94 "type"=>$type,
95 "hostname"=>$hostname,
96 "hasBeenChecked"=>$hasBeenChecked,
97 "checkExecutionTime"=>$checkExecutionTime,
98 "currentState"=>$currentState,
99 "lastCheck"=>$lastCheck,
100 "problemHasBeenAcknowledged"=>$problemHasBeenAcknowledged);
101 }
102 return $markers;
103}
Note: See TracBrowser for help on using the repository browser.