-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdata.php
34 lines (32 loc) · 1.27 KB
/
data.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
include('config.php');
include('db.php');
function get_hosts() {
$raw = mysql_query("SELECT `hostid`,`host`,`name`,`available` FROM `hosts` WHERE `status`=0 ");
while ($host = mysql_fetch_array($raw)) {
$loc_sql = "SELECT `location_lat`,`location_lon` FROM `host_inventory` WHERE `hostid`='".$host['hostid']."'";
$loc_raw = mysql_query($loc_sql);
$loc = mysql_fetch_array($loc_raw);
if (is_numeric($loc['location_lat']) AND is_numeric($loc['location_lon'])) {
$hosts[$host['hostid']]['location'] = $loc['location_lat'].",".$loc['location_lon'];
} else {
unset($host);
continue;
}
if (($host['available']==2) OR ($host['available']==0)) {
$hosts[$host['hostid']]['status_human'] = "PROBLEM"; };
$hosts[$host['hostid']]['marker_color'] = '';
if ($host['available']==1) {
$hosts[$host['hostid']]['status_human'] = 'OK';
$hosts[$host['hostid']]['marker_color'] = '_green';
};
$hosts[$host['hostid']]['available'] = $host['available'];
$hosts[$host['hostid']]['name'] = $host['name'];
$hosts[$host['hostid']]['host'] = $host['host'];
$hosts[$host['hostid']]['id'] = $host['hostid'];
$hosts[$host['hostid']]['zagmap_host'] = "x".$host['hostid']."x";
unset($host);
}
return $hosts;
}
?>