Release of grains plugin to racktables-contribs
[racktables-contribs] / gmaps / data.php
CommitLineData
41e8a5f2
DO
1<?php
2header('Content-Type: text/xml');
3/*header("<?xml version=\"1.0\" encoding=\"utf-8\"?>");*/
4
5require_once("./DB.php");
6$db = getDB();
7
8?>
9<markers>
10
11<?php
12 $sql = "SELECT *, RackRow.id as RackRow_id FROM " . $db . ".maps, " . $db . ".RackRow WHERE RackRow.id = maps.RackRow_id";
13 $res = query($sql);
14 if ($res != "niets gevonden"){
15
16 while ($row = mysql_fetch_array($res)){
17
18 echo "<marker lat=\"";
19 echo $row['lat'];
20 echo "\" lng=\"";
21 echo $row['lng'];
22 echo "\" label=\"";
23 echo $row['name'];
24 echo "\">";
25 echo "<infowindow><![CDATA[";
26 echo "<h2>" . $row['name'] . "</h2><b>Racks</b><br />";
27 $sql1 = "SELECT * FROM " . $db . ".Rack WHERE Rack.row_id = " . $row["RackRow_id"] ;
28 $res1 = query($sql1);
29 if ($res1 != "niets gevonden"){
30 while ($row1 = mysql_fetch_array($res1)){
31 echo "<a href=../index.php?page=rack&rack_id=" . $row1["id"] . " TARGET=\"_blank\">" . $row1["name"] . "</a><br />";
32 }
33 }
34
35 echo "<br /><a href=../index.php?page=row&row_id=" . $row['RackRow_id'] . " TARGET=\"_blank\">Racks</a>";
36 echo $row['html'];
37 echo "]]></infowindow>";
38 echo "</marker>";
39 }
40 }
41
42
43 $sql = "select ".
44 "DISTINCT m.lat as lat1, ".
45 "m.lng as lng1, ".
46 "mm.lat as lat2, ".
47 "mm.lng as lng2 ".
48 "from ".
49 $db . ".RackObject as ro, ".
50 $db . ".RackObject as rro, ".
51 $db . ".RackSpace as s, ".
52 $db . ".RackSpace as ss, ".
53 $db . ".Rack as r, ".
54 $db . ".Rack as rr, ".
55 $db . ".maps as m, ".
56 $db . ".maps as mm, ".
57 $db . ".Link k inner join ".
58 $db . ".Port g on k.porta=g.id inner join ".
59 $db . ".Port gg on k.portb=gg.id ".
60 "WHERE ".
61 "g.object_id = ro.id && ".
62 "gg.object_id = rro.id && ".
63 "s.object_id = g.object_id && ".
64 "ss.object_id = gg.object_id && ".
65 "s.rack_id = r.id && ".
66 "ss.rack_id = rr.id && ".
67 "m.RackRow_id = r.row_id && ".
68 "mm.RackRow_id = rr.row_id;";
69
70 $res = query($sql);
71 if ($res != "niets gevonden"){
72
73 while ($row = mysql_fetch_array($res)){
74 if ($row['lat1'] != $row['lat2'] && $row['lng1'] != $row['lng2']){
75 echo "<line colour=\"#FF0000\" width=\"4\" html=\"1\">";
76 echo "<point lat=\"" . $row['lat1'] . "\"";
77 echo " lng=\"" . $row['lng1'] . "\"/>";
78 echo "<point lat=\"" . $row['lat2'] . "\"";
79 echo " lng=\"" . $row['lng2'] . "\"/>";
80 echo "</line>";
81 }
82 }
83 }
84?>
85</markers>