Completed
Push — master ( f4833e...da028e )
by Yannick
07:06
created

location-geojson.php (1 issue)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
0 ignored issues
show
It is not recommended to output anything before PHP's opening tag in non-template files.
Loading history...
2
<?php
3
require_once('require/class.Connection.php');
4
require_once('require/class.Source.php');
5
$Source = new Source();
6
7
if (isset($_GET['download']))
8
{
9
	header('Content-disposition: attachment; filename="locations.geojson"');
10
}
11
header('Content-Type: text/javascript');
12
13
if (!isset($globalDemo)) {
14
	if (isset($_GET['coord'])) 
15
	{
16
		$coords = explode(',',$_GET['coord']);
17
//		$spotter_array = Source::getAllLocationInfobyCoord($coords);
18
		if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') 
19
		    || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) {
20
			$spotter_array = $Source->getAllLocationInfo();
21
		} else {
22
			$spotter_array = $Source->getLocationInfoByType('');
23
		}
24
	} else {
25
		if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') 
26
		    || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) {
27
			$spotter_array = $Source->getAllLocationInfo();
28
		} else {
29
			$spotter_array = $Source->getLocationInfoByType('');
30
		}
31
	}
32
}
33
34
$output = '{"type": "FeatureCollection","features": [';
35
if (!empty($spotter_array) && count($spotter_array) > 0)
36
{
37
	foreach($spotter_array as $spotter_item)
38
	{
39
		date_default_timezone_set('UTC');
40
		//waypoint plotting
41
		$output .= '{"type": "Feature",';
42
		    $output .= '"properties": {';
43
			$output .= '"id": "'.$spotter_item['id'].'",';
44
			$output .= '"location_id": "'.$spotter_item['location_id'].'",';
45
			$output .= '"name": "'.$spotter_item['name'].'",';
46
			$output .= '"city": "'.$spotter_item['city'].'",';
47
			$output .= '"country": "'.$spotter_item['country'].'",';
48
			$output .= '"altitude": "'.$spotter_item['altitude'].'",';
49
			if ($spotter_item['name'] != '' && $spotter_item['city'] != '' && $spotter_item['country'] != '')
50
				$output .= '"popupContent": "'.$spotter_item['name'].' : '.$spotter_item['city'].', '.$spotter_item['country'].'",';
51
			elseif ($spotter_item['location_id'] != '')
52
				$output .= '"popupContent": "'.$spotter_item['location_id'].'",';
53
			$output .= '"icon": "'.$globalURL.'/images/'.$spotter_item['logo'].'",';
54
			$output .= '"type": "'.$spotter_item['type'].'",';
55
			$output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"';
56
		    $output .= '},';
57
		    $output .= '"geometry": {';
58
			$output .= '"type": "Point",';
59
			$output .= '"coordinates": [';
60
			    $output .= $spotter_item['longitude'].', '.$spotter_item['latitude'];
61
			$output .= ']';
62
		    $output .= '}';
63
		$output .= '},';
64
	}
65
	$output  = substr($output, 0, -1);
66
}
67
$output .= ']}';
68
69
print $output;
70
71
?>