Completed
Push — master ( 029a3f...057a2a )
by Yannick
07:22
created
date-statistics-airline-country.php 1 patch
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,8 +8,11 @@
 block discarded – undo
8 8
 $date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING);
9 9
 
10 10
 $Spotter = new Spotter();
11
-if (isset($_GET['date'])) $spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort);
12
-else $spotter_array = array();
11
+if (isset($_GET['date'])) {
12
+	$spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort);
13
+} else {
14
+	$spotter_array = array();
15
+}
13 16
 
14 17
 if (!empty($spotter_array))
15 18
 {
Please login to merge, or discard this patch.
incident-latest.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,8 +38,12 @@
 block discarded – undo
38 38
 if (!empty($spotter_array) && $spotter_array[0]['query_number_rows'] != 0) {
39 39
 	include('table-output.php');
40 40
 	print '<div class="pagination">';
41
-	if ($limit_previous_1 >= 0) print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">&laquo;'._("Previous Page").'</a>';
42
-	if ($spotter_array[0]['query_number_rows'] == $absolute_difference) print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'&raquo;</a>';
41
+	if ($limit_previous_1 >= 0) {
42
+		print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">&laquo;'._("Previous Page").'</a>';
43
+	}
44
+	if ($spotter_array[0]['query_number_rows'] == $absolute_difference) {
45
+		print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'&raquo;</a>';
46
+	}
43 47
 	print '</div>';
44 48
 }
45 49
 print '</div>';
Please login to merge, or discard this patch.
scripts/update_db.php 1 patch
Braces   +22 added lines, -8 removed lines patch added patch discarded remove patch
@@ -9,7 +9,9 @@  discard block
 block discarded – undo
9 9
 if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
10 10
 	exec("ps ux", $output, $result);
11 11
 	$j = 0;
12
-	foreach ($output as $line) if(strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++;
12
+	foreach ($output as $line) {
13
+		if(strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++;
14
+	}
13 15
 	if ($j > 1) {
14 16
 		echo "Script is already runnning...";
15 17
 		die();
@@ -29,14 +31,18 @@  discard block
 block discarded – undo
29 31
 			$update_db->update_notam();
30 32
 		}
31 33
 		$update_db->insert_last_notam_update();
32
-	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) echo "NOTAM are only updated once a day.\n";
34
+	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) {
35
+		echo "NOTAM are only updated once a day.\n";
36
+	}
33 37
 	if ($update_db->check_last_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
34 38
 		$update_db->update_all();
35 39
 	//	require_once(dirname(__FILE__).'/../require/class.Spotter.php');
36 40
 	//	$Spotter = new Spotter();
37 41
 	//	$Spotter->updateFieldsFromOtherTables();
38 42
 		$update_db->insert_last_update();
39
-	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
43
+	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) {
44
+		echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
45
+	}
40 46
 	if (isset($globalWaypoints) && $globalWaypoints && $update_db->check_last_airspace_update()) {
41 47
 		echo "Check if new airspace version exist...";
42 48
 		echo $update_db->update_airspace_fam();
@@ -51,7 +57,9 @@  discard block
 block discarded – undo
51 57
 			$update_db->delete_duplicateowner();
52 58
 		}
53 59
 		$update_db->insert_last_owner_update();
54
-	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Owner are only updated every 15 days.\n";
60
+	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
61
+		echo "Owner are only updated every 15 days.\n";
62
+	}
55 63
 
56 64
 	if (isset($globalAccidents) && $globalAccidents && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
57 65
 		require_once(dirname(__FILE__).'/../require/class.Accident.php');
@@ -60,7 +68,9 @@  discard block
 block discarded – undo
60 68
 		if ($Accident->check_last_accidents_update()) {
61 69
 			$Accident->download_update();
62 70
 			$Accident->insert_last_accidents_update();
63
-		} else echo "Accidents are updated once a day.\n";
71
+		} else {
72
+			echo "Accidents are updated once a day.\n";
73
+		}
64 74
 	}
65 75
 
66 76
 }
@@ -73,15 +83,19 @@  discard block
 block discarded – undo
73 83
 	if ($METAR->check_last_update()) {
74 84
 		$METAR->addMETARCycle();
75 85
 		$METAR->insert_last_update();
76
-	} else echo "METAR are only updated every 30 minutes.\n";
77
-}
86
+	} else {
87
+		echo "METAR are only updated every 30 minutes.\n";
88
+	}
89
+	}
78 90
 
79 91
 if (isset($globalSchedules) && $globalSchedules && $update_db->check_last_schedules_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
80 92
 	echo "Updating schedules...";
81 93
 	//$update_db->update_oneworld();
82 94
 	$update_db->update_skyteam();
83 95
 	$update_db->insert_last_schedules_update();
84
-} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Schedules are only updated every 15 days.\n";
96
+} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
97
+	echo "Schedules are only updated every 15 days.\n";
98
+}
85 99
 
86 100
 if (isset($globalArchiveMonths) && $globalArchiveMonths > 0) {
87 101
 	echo "Updating statistics and archive old data...";
Please login to merge, or discard this patch.
accident.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
3
-if ($date == '') $date = date('Y-m-d');
3
+if ($date == '') {
4
+	$date = date('Y-m-d');
5
+}
4 6
 header('Location: '.$globalURL.'/accident/'.$date);
5 7
 ?>
6 8
\ No newline at end of file
Please login to merge, or discard this patch.
date.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
3
-if ($date == '') $date = date('Y-m-d');
3
+if ($date == '') {
4
+	$date = date('Y-m-d');
5
+}
4 6
 header('Location: '.$globalURL.'/date/'.$date);
5 7
 ?>
6 8
\ No newline at end of file
Please login to merge, or discard this patch.
incident.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
3
-if ($date == '') $date = date('Y-m-d');
3
+if ($date == '') {
4
+	$date = date('Y-m-d');
5
+}
4 6
 header('Location: '.$globalURL.'/incident/'.$date);
5 7
 ?>
6 8
\ No newline at end of file
Please login to merge, or discard this patch.
require/class.Image.php 1 patch
Braces   +123 added lines, -45 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@  discard block
 block discarded – undo
22 22
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
23 23
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
24 24
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
25
-		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
25
+		if ($registration == '' && $aircraft_icao != '') {
26
+			$registration = $aircraft_icao.$airline_icao;
27
+		}
26 28
 		$registration = trim($registration);
27 29
 		$query  = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
28 30
 			FROM spotter_image 
@@ -60,8 +62,11 @@  discard block
 block discarded – undo
60 62
 	public function getExifCopyright($url) {
61 63
 		$exif = exif_read_data($url);
62 64
 		$copyright = '';
63
-		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
64
-		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
65
+		if (isset($exif['COMPUTED']['copyright'])) {
66
+			$copyright = $exif['COMPUTED']['copyright'];
67
+		} elseif (isset($exif['copyright'])) {
68
+			$copyright = $exif['copyright'];
69
+		}
65 70
 		if ($copyright != '') {
66 71
 			$copyright = str_replace('Copyright ','',$copyright);
67 72
 			$copyright = str_replace('© ','',$copyright);
@@ -79,18 +84,29 @@  discard block
 block discarded – undo
79 84
 	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
80 85
 	{
81 86
 		global $globalDebug,$globalAircraftImageFetch;
82
-		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return '';
87
+		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) {
88
+			return '';
89
+		}
83 90
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
84 91
 		$registration = trim($registration);
85 92
 		//getting the aircraft image
86
-		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
87
-		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
88
-		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
89
-		else return "success";
93
+		if ($globalDebug && $registration != '') {
94
+			echo 'Try to find an aircraft image for '.$registration.'...';
95
+		} elseif ($globalDebug && $aircraft_icao != '') {
96
+			echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
97
+		} elseif ($globalDebug && $airline_icao != '') {
98
+			echo 'Try to find an aircraft image for '.$airline_icao.'...';
99
+		} else {
100
+			return "success";
101
+		}
90 102
 		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
91
-		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
103
+		if ($registration == '' && $aircraft_icao != '') {
104
+			$registration = $aircraft_icao.$airline_icao;
105
+		}
92 106
 		if ($image_url['original'] != '') {
93
-			if ($globalDebug) echo 'Found !'."\n";
107
+			if ($globalDebug) {
108
+				echo 'Found !'."\n";
109
+			}
94 110
 			$query  = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
95 111
 			try {
96 112
 				$sth = $this->db->prepare($query);
@@ -99,7 +115,9 @@  discard block
 block discarded – undo
99 115
 				echo $e->getMessage()."\n";
100 116
 				return "error";
101 117
 			}
102
-		} elseif ($globalDebug) echo "Not found :'(\n";
118
+		} elseif ($globalDebug) {
119
+			echo "Not found :'(\n";
120
+		}
103 121
 		return "success";
104 122
 	}
105 123
 
@@ -114,36 +132,75 @@  discard block
 block discarded – undo
114 132
 	{
115 133
 		global $globalAircraftImageSources, $globalIVAO;
116 134
 		$Spotter = new Spotter($this->db);
117
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
135
+		if (!isset($globalIVAO)) {
136
+			$globalIVAO = FALSE;
137
+		}
118 138
 		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
119 139
 		if ($aircraft_registration != '') {
120
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
140
+			if (strpos($aircraft_registration,'/') !== false) {
141
+				return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
142
+			}
121 143
 			$aircraft_registration = urlencode(trim($aircraft_registration));
122 144
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
123
-			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
124
-			else $aircraft_name = '';
125
-			if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao'];
126
-			else $aircraft_icao = '';
127
-			if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao'];
128
-			else $airline_icao = '';
145
+			if (isset($aircraft_info[0]['aircraft_name'])) {
146
+				$aircraft_name = $aircraft_info[0]['aircraft_name'];
147
+			} else {
148
+				$aircraft_name = '';
149
+			}
150
+			if (isset($aircraft_info[0]['aircraft_icao'])) {
151
+				$aircraft_name = $aircraft_info[0]['aircraft_icao'];
152
+			} else {
153
+				$aircraft_icao = '';
154
+			}
155
+			if (isset($aircraft_info[0]['airline_icao'])) {
156
+				$airline_icao = $aircraft_info[0]['airline_icao'];
157
+			} else {
158
+				$airline_icao = '';
159
+			}
129 160
 		} elseif ($aircraft_icao != '') {
130 161
 			$aircraft_registration = $aircraft_icao;
131 162
 			$aircraft_name = '';
132
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
133
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
163
+		} else {
164
+			return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
165
+		}
166
+		if (!isset($globalAircraftImageSources)) {
167
+			$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
168
+		}
134 169
 		foreach ($globalAircraftImageSources as $source) {
135 170
 			$source = strtolower($source);
136
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao);
137
-			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name);
138
-			if ($source == 'flickr') $images_array = $this->fromFlickr($aircraft_registration,$aircraft_name);
139
-			if ($source == 'bing') $images_array = $this->fromBing($aircraft_registration,$aircraft_name);
140
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name);
141
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name);
142
-			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name);
143
-			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name);
144
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData($aircraft_registration,$aircraft_name);
145
-			if ($source == 'customsources') $images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name);
146
-			if (isset($images_array) && $images_array['original'] != '') return $images_array;
171
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') {
172
+				$images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao);
173
+			}
174
+			if ($source == 'planespotters' && !$globalIVAO) {
175
+				$images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name);
176
+			}
177
+			if ($source == 'flickr') {
178
+				$images_array = $this->fromFlickr($aircraft_registration,$aircraft_name);
179
+			}
180
+			if ($source == 'bing') {
181
+				$images_array = $this->fromBing($aircraft_registration,$aircraft_name);
182
+			}
183
+			if ($source == 'deviantart') {
184
+				$images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name);
185
+			}
186
+			if ($source == 'wikimedia') {
187
+				$images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name);
188
+			}
189
+			if ($source == 'jetphotos' && !$globalIVAO) {
190
+				$images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name);
191
+			}
192
+			if ($source == 'planepictures' && !$globalIVAO) {
193
+				$images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name);
194
+			}
195
+			if ($source == 'airportdata' && !$globalIVAO) {
196
+				$images_array = $this->fromAirportData($aircraft_registration,$aircraft_name);
197
+			}
198
+			if ($source == 'customsources') {
199
+				$images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name);
200
+			}
201
+			if (isset($images_array) && $images_array['original'] != '') {
202
+				return $images_array;
203
+			}
147 204
 		}
148 205
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
149 206
 	}
@@ -301,8 +358,11 @@  discard block
 block discarded – undo
301 358
 	*/
302 359
 	public function fromFlickr($aircraft_registration,$aircraft_name='') {
303 360
 		$Common = new Common();
304
-		if ($aircraft_name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name);
305
-		else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft';
361
+		if ($aircraft_name != '') {
362
+			$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name);
363
+		} else {
364
+			$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft';
365
+		}
306 366
 		$data = $Common->getData($url);
307 367
 		if ($xml = simplexml_load_string($data)) {
308 368
 			if (isset($xml->channel->item)) {
@@ -346,9 +406,14 @@  discard block
 block discarded – undo
346 406
 	public function fromBing($aircraft_registration,$aircraft_name='') {
347 407
 		global $globalImageBingKey;
348 408
 		$Common = new Common();
349
-		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false;
350
-		if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
351
-		else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
409
+		if (!isset($globalImageBingKey) || $globalImageBingKey == '') {
410
+			return false;
411
+		}
412
+		if ($aircraft_name != '') {
413
+			$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
414
+		} else {
415
+			$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
416
+		}
352 417
 		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
353 418
 		$data = $Common->getData($url,'get','',$headers);
354 419
 		$result = json_decode($data);
@@ -402,13 +467,18 @@  discard block
 block discarded – undo
402 467
 	*/
403 468
 	public function fromWikimedia($aircraft_registration,$aircraft_name='') {
404 469
 		$Common = new Common();
405
-		if ($aircraft_name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name);
406
-		else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft';
470
+		if ($aircraft_name != '') {
471
+			$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name);
472
+		} else {
473
+			$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft';
474
+		}
407 475
 		$data = $Common->getData($url);
408 476
 		$result = json_decode($data);
409 477
 		if (isset($result->query->search[0]->title)) {
410 478
 			$fileo = $result->query->search[0]->title;
411
-			if (substr($fileo,-3) == 'pdf') return false;
479
+			if (substr($fileo,-3) == 'pdf') {
480
+				return false;
481
+			}
412 482
 			$file = urlencode($fileo);
413 483
 			$url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file;
414 484
 			$data2 = $Common->getData($url2);
@@ -478,17 +548,25 @@  discard block
 block discarded – undo
478 548
 					$image_url = array();
479 549
 					$image_url['thumbnail'] = $url_thumbnail;
480 550
 					$image_url['original'] = $url;
481
-					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
482
-					else $exifCopyright = '';
483
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
484
-					else $image_url['copyright'] = $source['copyright'];
551
+					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) {
552
+						$exifCopyright = $this->getExifCopyright($url);
553
+					} else {
554
+						$exifCopyright = '';
555
+					}
556
+					if ($exifCopyright  != '') {
557
+						$image_url['copyright'] = $exifCopyright;
558
+					} else {
559
+						$image_url['copyright'] = $source['copyright'];
560
+					}
485 561
 					$image_url['source_website'] = $source['source_website'];
486 562
 					$image_url['source'] = $source['source'];
487 563
 					return $image_url;
488 564
 				}
489 565
 			}
490 566
 			return false;
491
-		} else return false;
567
+		} else {
568
+			return false;
569
+		}
492 570
 	}
493 571
 }
494 572
 
Please login to merge, or discard this patch.
live-geojson.php 1 patch
Braces   +142 added lines, -55 removed lines patch added patch discarded remove patch
@@ -18,27 +18,52 @@  discard block
 block discarded – undo
18 18
 }
19 19
 header('Content-Type: text/javascript');
20 20
 
21
-if (!isset($globalJsonCompress)) $compress = true;
22
-else $compress = $globalJsonCompress;
21
+if (!isset($globalJsonCompress)) {
22
+	$compress = true;
23
+} else {
24
+	$compress = $globalJsonCompress;
25
+}
23 26
 
24 27
 $from_archive = false;
25 28
 $min = true;
26 29
 $allhistory = false;
27 30
 $filter['source'] = array();
28
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
29
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
30
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
31
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs'));
32
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
33
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
34
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
35
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
36
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
37
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
31
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
32
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
33
+}
34
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
35
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
36
+}
37
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
38
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
39
+}
40
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
41
+	$filter['source'] = array_merge($filter['source'],array('sbs'));
42
+}
43
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
44
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
45
+}
46
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
47
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
48
+}
49
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
50
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
51
+}
52
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
53
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
54
+}
55
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
56
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
57
+}
58
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
59
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
60
+}
38 61
 
39 62
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
40 63
 	$min = true;
41
-} else $min = false;
64
+} else {
65
+	$min = false;
66
+}
42 67
 
43 68
 if (isset($_GET['ident'])) {
44 69
 	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
@@ -88,20 +113,30 @@  discard block
 block discarded – undo
88 113
 	}
89 114
 */
90 115
 	$flightcnt = count($spotter_array);
91
-	if ($flightcnt == '') $flightcnt = 0;
92
-} else $flightcnt = 0;
116
+	if ($flightcnt == '') {
117
+		$flightcnt = 0;
118
+	}
119
+	} else {
120
+	$flightcnt = 0;
121
+}
93 122
 
94 123
 $sqltime = round(microtime(true)-$begintime,2);
95 124
 
96
-if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
97
-else $usenextlatlon = true;
125
+if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) {
126
+	$usenextlatlon = false;
127
+} else {
128
+	$usenextlatlon = true;
129
+}
98 130
 $j = 0;
99 131
 $prev_flightaware_id = '';
100 132
 $aircrafts_shadow = array();
101 133
 $output = '{';
102 134
 	$output .= '"type": "FeatureCollection",';
103
-		if ($min) $output .= '"minimal": "true",';
104
-		else $output .= '"minimal": "false",';
135
+		if ($min) {
136
+			$output .= '"minimal": "true",';
137
+		} else {
138
+			$output .= '"minimal": "false",';
139
+		}
105 140
 		$output .= '"fc": "'.$flightcnt.'",';
106 141
 		$output .= '"sqt": "'.$sqltime.'",';
107 142
 
@@ -138,11 +173,16 @@  discard block
 block discarded – undo
138 173
 						//$output .= '"sqt": "'.$sqltime.'",';
139 174
 						$output .= '"id": "'.$spotter_item['flightaware_id'].'",';
140 175
 						$output .= '"properties": {';
141
-							if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
142
-							else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
176
+							if ($compress) {
177
+								$output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
178
+							} else {
179
+								$output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
180
+							}
143 181
 							$output .= '"fc": "'.$flightcnt.'",';
144 182
 							$output .= '"sqt": "'.$sqltime.'",';
145
-							if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
183
+							if (isset($begindate)) {
184
+								$output .= '"archive_date": "'.$begindate.'",';
185
+							}
146 186
 
147 187
 /*
148 188
 							if ($min) $output .= '"minimal": "true",';
@@ -150,13 +190,21 @@  discard block
 block discarded – undo
150 190
 */
151 191
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
152 192
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
153
-							if ($compress) $output .= '"c": "'.$spotter_item['ident'].'",';
154
-							else $output .= '"callsign": "'.$spotter_item['ident'].'",';
193
+							if ($compress) {
194
+								$output .= '"c": "'.$spotter_item['ident'].'",';
195
+							} else {
196
+								$output .= '"callsign": "'.$spotter_item['ident'].'",';
197
+							}
155 198
 						} else {
156
-							if ($compress) $output .= '"c": "NA",';
157
-							else $output .= '"callsign": "NA",';
199
+							if ($compress) {
200
+								$output .= '"c": "NA",';
201
+							} else {
202
+								$output .= '"callsign": "NA",';
203
+							}
204
+						}
205
+						if (isset($spotter_item['registration'])) {
206
+							$output .= '"registration": "'.$spotter_item['registration'].'",';
158 207
 						}
159
-						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
160 208
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
161 209
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
162 210
 							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
@@ -169,25 +217,37 @@  discard block
 block discarded – undo
169 217
 							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
170 218
 						}
171 219
 						if (!isset($spotter_item['aircraft_shadow'])) {
172
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
173
-							else {
220
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
221
+								$spotter_item['aircraft_shadow'] = '';
222
+							} else {
174 223
 								$aircraft_icao = $spotter_item['aircraft_icao'];
175
-								if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
176
-								else {
224
+								if (isset($aircrafts_shadow[$aircraft_icao])) {
225
+									$spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
226
+								} else {
177 227
 									$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
178
-									if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
179
-									elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
180
-									else $spotter_item['aircraft_shadow'] = '';
228
+									if (count($aircraft_info) > 0) {
229
+										$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
230
+									} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
231
+										$spotter_item['aircraft_shadow'] = 'PA18.png';
232
+									} else {
233
+										$spotter_item['aircraft_shadow'] = '';
234
+									}
181 235
 									$aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow'];
182 236
 								}
183 237
 							}
184 238
 						}
185 239
 						if ($spotter_item['aircraft_shadow'] == '') {
186
-							if ($compress) $output .= '"as": "default.png",';
187
-							else $output .= '"aircraft_shadow": "default.png",';
240
+							if ($compress) {
241
+								$output .= '"as": "default.png",';
242
+							} else {
243
+								$output .= '"aircraft_shadow": "default.png",';
244
+							}
188 245
 						} else {
189
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
190
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
246
+							if ($compress) {
247
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
248
+							} else {
249
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
250
+							}
191 251
 						}
192 252
 						if (isset($spotter_item['airline_name'])) {
193 253
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -195,8 +255,11 @@  discard block
 block discarded – undo
195 255
 							$output .= '"airline_name": "NA",';
196 256
 						}
197 257
 						if (isset($spotter_item['departure_airport'])) {
198
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
199
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
258
+							if ($compress) {
259
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
260
+							} else {
261
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
262
+							}
200 263
 						}
201 264
 						if (isset($spotter_item['departure_airport_city'])) {
202 265
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -208,8 +271,11 @@  discard block
 block discarded – undo
208 271
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
209 272
 						}
210 273
 						if (isset($spotter_item['arrival_airport'])) {
211
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
212
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
274
+							if ($compress) {
275
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
276
+							} else {
277
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
278
+							}
213 279
 						}
214 280
 						if (isset($spotter_item['arrival_airport_city'])) {
215 281
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -227,10 +293,16 @@  discard block
 block discarded – undo
227 293
 							$output .= '"ground_speed": "'.$spotter_item['ground_speed'].'",';
228 294
 						}
229 295
 						
230
-						if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
231
-						else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
232
-						if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",';
233
-						else $output .= '"heading": "'.$spotter_item['heading'].'",';
296
+						if ($compress) {
297
+							$output .= '"a": "'.$spotter_item['altitude'].'",';
298
+						} else {
299
+							$output .= '"altitude": "'.$spotter_item['altitude'].'",';
300
+						}
301
+						if ($compress) {
302
+							$output .= '"h": "'.$spotter_item['heading'].'",';
303
+						} else {
304
+							$output .= '"heading": "'.$spotter_item['heading'].'",';
305
+						}
234 306
 						
235 307
 						if (isset($archivespeed)) {
236 308
 							$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);
@@ -240,7 +312,9 @@  discard block
 block discarded – undo
240 312
 							$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
241 313
 						}
242 314
 
243
-						if (!$min) $output .= '"image": "'.$image.'",';
315
+						if (!$min) {
316
+							$output .= '"image": "'.$image.'",';
317
+						}
244 318
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
245 319
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
246 320
 						}
@@ -248,8 +322,11 @@  discard block
 block discarded – undo
248 322
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
249 323
 						}
250 324
 						if (isset($spotter_item['squawk'])) {
251
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
252
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
325
+							if ($compress) {
326
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
327
+							} else {
328
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
329
+							}
253 330
 						}
254 331
 						if (isset($spotter_item['squawk_usage'])) {
255 332
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -267,8 +344,11 @@  discard block
 block discarded – undo
267 344
 							$output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",';
268 345
 						}
269 346
 						// type when not aircraft ?
270
-						if ($compress) $output .= '"t": "aircraft"';
271
-						else $output .= '"type": "aircraft"';
347
+						if ($compress) {
348
+							$output .= '"t": "aircraft"';
349
+						} else {
350
+							$output .= '"type": "aircraft"';
351
+						}
272 352
 						$output .= '},';
273 353
 						$output .= '"geometry": {';
274 354
 							$output .= '"type": "Point",';
@@ -335,7 +415,9 @@  discard block
 block discarded – undo
335 415
 			}
336 416
 */
337 417
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
338
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
418
+				if ($history == '' && isset($_COOKIE['history'])) {
419
+					$history = $_COOKIE['history'];
420
+				}
339 421
 				
340 422
 				if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
341 423
 				|| (!isset($_COOKIE['flightpath']) 
@@ -357,8 +439,11 @@  discard block
 block discarded – undo
357 439
 						$output_history .= ']}},';
358 440
 						$output .= $output_history;
359 441
 					    }
360
-					    if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
361
-					    else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
442
+					    if ($compress) {
443
+					    	$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
444
+					    } else {
445
+					    	$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
446
+					    }
362 447
 					}
363 448
 					$output_history .= '[';
364 449
 					$output_history .=  $spotter_history['longitude'].', ';
@@ -404,7 +489,9 @@  discard block
 block discarded – undo
404 489
 			$output .= ']';
405 490
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
406 491
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
407
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
492
+			if (isset($begindate)) {
493
+				$output .= '"archive_date": "'.$begindate.'",';
494
+			}
408 495
 			$output .= '"fc": "'.$j.'"';
409 496
 		} else {
410 497
 			$output .= '"features": ';
Please login to merge, or discard this patch.
js/map.js.php 1 patch
Braces   +128 added lines, -33 removed lines patch added patch discarded remove patch
@@ -5,8 +5,11 @@  discard block
 block discarded – undo
5 5
 setcookie("MapFormat",'2d');
6 6
 
7 7
 // Compressed GeoJson is used if true
8
-if (!isset($globalJsonCompress)) $compress = true;
9
-else $compress = $globalJsonCompress;
8
+if (!isset($globalJsonCompress)) {
9
+	$compress = true;
10
+} else {
11
+	$compress = $globalJsonCompress;
12
+}
10 13
 if (isset($_GET['archive'])) {
11 14
 	//$archiveupdatetime = 50;
12 15
 	$archiveupdatetime = $globalMapRefresh;
@@ -16,8 +19,11 @@  discard block
 block discarded – undo
16 19
 	//$lastupd = round(($_GET['enddate']-$_GET['begindate'])/(($_GET['during']*60)/10));
17 20
 	//$lastupd = 20;
18 21
 	$lastupd = $_GET['archivespeed']*$archiveupdatetime;
19
-	if (isset($_GET['enddate']) && $_GET['enddate'] != '') $enddate = $_GET['enddate'];
20
-	else $enddate = time();
22
+	if (isset($_GET['enddate']) && $_GET['enddate'] != '') {
23
+		$enddate = $_GET['enddate'];
24
+	} else {
25
+		$enddate = time();
26
+	}
21 27
 	setcookie("archive_begin",$begindate);
22 28
 	setcookie("archive_end",$enddate);
23 29
 	setcookie("archive_update",$lastupd);
@@ -123,7 +129,17 @@  discard block
 block discarded – undo
123 129
 	}
124 130
 
125 131
 	//create the map
126
-	map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) print $latitude; else print $globalCenterLatitude; ?>,<?php if (isset($longitude)) print $longitude; else print $globalCenterLongitude; ?>], zoom);
132
+	map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) {
133
+	print $latitude;
134
+} else {
135
+	print $globalCenterLatitude;
136
+}
137
+?>,<?php if (isset($longitude)) {
138
+	print $longitude;
139
+} else {
140
+	print $globalCenterLongitude;
141
+}
142
+?>], zoom);
127 143
 <?php
128 144
 	} else {
129 145
 ?>
@@ -136,9 +152,19 @@  discard block
 block discarded – undo
136 152
 	     || navigator.userAgent.match(/BlackBerry/i)
137 153
 	     || navigator.userAgent.match(/Windows Phone/i))
138 154
 	{
139
-		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom-1; else print '8'; ?>;
155
+		var zoom = <?php if (isset($globalLiveZoom)) {
156
+	print $globalLiveZoom-1;
157
+} else {
158
+	print '8';
159
+}
160
+?>;
140 161
 	} else {
141
-		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>;
162
+		var zoom = <?php if (isset($globalLiveZoom)) {
163
+	print $globalLiveZoom;
164
+} else {
165
+	print '9';
166
+}
167
+?>;
142 168
 	}
143 169
 
144 170
 	//create the map
@@ -163,16 +189,27 @@  discard block
 block discarded – undo
163 189
 	bounds = L.latLngBounds(southWest,northEast);
164 190
 	//a few title layers
165 191
 <?php
166
-	if (isset($_COOKIE['MapType'])) $MapType = $_COOKIE['MapType'];
167
-	else $MapType = $globalMapProvider;
192
+	if (isset($_COOKIE['MapType'])) {
193
+		$MapType = $_COOKIE['MapType'];
194
+	} else {
195
+		$MapType = $globalMapProvider;
196
+	}
168 197
 
169 198
 	if ($MapType == 'Mapbox') {
170
-		if ($_COOKIE['MapTypeId'] == 'default') $MapBoxId = $globalMapboxId;
171
-		else $MapBoxId = $_COOKIE['MapTypeId'];
172
-?>
199
+		if ($_COOKIE['MapTypeId'] == 'default') {
200
+			$MapBoxId = $globalMapboxId;
201
+		} else {
202
+			$MapBoxId = $_COOKIE['MapTypeId'];
203
+		}
204
+		?>
173 205
 	L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', {
174 206
 	    maxZoom: 18,
175
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
207
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
208
+	print 'false';
209
+} else {
210
+	print 'true';
211
+}
212
+?>,
176 213
 	    attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
177 214
 	      '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
178 215
 	      'Imagery © <a href="http://mapbox.com">Mapbox</a>',
@@ -184,7 +221,12 @@  discard block
 block discarded – undo
184 221
 ?>
185 222
 	L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
186 223
 	    maxZoom: 18,
187
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
224
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
225
+	print 'false';
226
+} else {
227
+	print 'true';
228
+}
229
+?>,
188 230
 	    attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
189 231
 	      '<a href="www.openstreetmap.org/copyright">Open Database Licence</a>'
190 232
 	}).addTo(map);
@@ -230,20 +272,26 @@  discard block
 block discarded – undo
230 272
 	map.addLayer(yandexLayer);
231 273
 <?php
232 274
 	} elseif ($MapType == 'Bing-Aerial') {
233
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
234
-?>
275
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
276
+			setcookie('MapType','OpenStreetMap');
277
+		}
278
+		?>
235 279
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Aerial'});
236 280
 	map.addLayer(bingLayer);
237 281
 <?php
238 282
 	} elseif ($MapType == 'Bing-Hybrid') {
239
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
240
-?>
283
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
284
+			setcookie('MapType','OpenStreetMap');
285
+		}
286
+		?>
241 287
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'AerialWithLabels'});
242 288
 	map.addLayer(bingLayer);
243 289
 <?php
244 290
 	} elseif ($MapType == 'Bing-Road') {
245
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
246
-?>
291
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
292
+			setcookie('MapType','OpenStreetMap');
293
+		}
294
+		?>
247 295
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Road'});
248 296
 	map.addLayer(bingLayer);
249 297
 <?php
@@ -291,7 +339,12 @@  discard block
 block discarded – undo
291 339
 		}
292 340
 	} elseif ($globalBounding == 'circle') {
293 341
 ?>
294
-	var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) print $globalBoundingCircleSize; else print '70000'; ?>,{
342
+	var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) {
343
+	print $globalBoundingCircleSize;
344
+} else {
345
+	print '70000';
346
+}
347
+?>,{
295 348
 	    color: '#92C7D1',
296 349
 	    fillColor: '#92C7D1',
297 350
 	    fillOpacity: 0.3,
@@ -350,8 +403,11 @@  discard block
 block discarded – undo
350 403
 
351 404
 	function update_airportsLayer() {
352 405
 	    <?php
353
-		if (isset($_COOKIE['AirportZoom'])) $getZoom = $_COOKIE['AirportZoom'];
354
-		else $getZoom = '7';
406
+		if (isset($_COOKIE['AirportZoom'])) {
407
+			$getZoom = $_COOKIE['AirportZoom'];
408
+		} else {
409
+			$getZoom = '7';
410
+		}
355 411
 	    ?>
356 412
 	    //if (map.getZoom() <= <?php print $getZoom; ?>) {
357 413
 		if (typeof airportsLayer != 'undefined') {
@@ -687,9 +743,13 @@  discard block
 block discarded – undo
687 743
 		    if (callsign != ""){ markerLabel += callsign; }
688 744
 		    if (departure_airport_code != "" && arrival_airport_code != "" && departure_airport_code != "NA" && arrival_airport_code != "NA"){ markerLabel += ' ( '+departure_airport_code+' - '+arrival_airport_code+' )'; }
689 745
 <?php
690
-	if (isset($_COOKIE['IconColor'])) $IconColor = $_COOKIE['IconColor'];
691
-	elseif (isset($globalAircraftIconColor)) $IconColor = $globalAircraftIconColor;
692
-	else $IconColor = '1a3151';
746
+	if (isset($_COOKIE['IconColor'])) {
747
+		$IconColor = $_COOKIE['IconColor'];
748
+	} elseif (isset($globalAircraftIconColor)) {
749
+		$IconColor = $globalAircraftIconColor;
750
+	} else {
751
+		$IconColor = '1a3151';
752
+	}
693 753
 	if (!isset($ident) && !isset($flightaware_id)) {
694 754
 ?>
695 755
 		    info_update(feature.properties.fc);
@@ -737,7 +797,12 @@  discard block
 block discarded – undo
737 797
 <?php
738 798
 		} else {
739 799
 ?>
740
-		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
800
+		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
801
+	print $archiveupdatetime*1000;
802
+} else {
803
+	print $globalMapRefresh*1000+20000;
804
+}
805
+?>+feature.properties.sqt*1000);
741 806
 		    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
742 807
 <?php
743 808
 		}
@@ -786,7 +851,12 @@  discard block
 block discarded – undo
786 851
 <?php
787 852
 		} else {
788 853
 ?>
789
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
854
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
855
+	print $archiveupdatetime*1000;
856
+} else {
857
+	print $globalMapRefresh*1000+20000;
858
+}
859
+?>+feature.properties.sqt*1000);
790 860
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
791 861
 <?php
792 862
 		}
@@ -834,7 +904,12 @@  discard block
 block discarded – undo
834 904
 <?php
835 905
 		} else {
836 906
 ?>
837
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
907
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
908
+	print $archiveupdatetime*1000;
909
+} else {
910
+	print $globalMapRefresh*1000+20000;
911
+}
912
+?>+feature.properties.sqt*1000);
838 913
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
839 914
 <?php
840 915
 		}
@@ -1177,14 +1252,24 @@  discard block
 block discarded – undo
1177 1252
 	if (isset($_GET['archive'])) {
1178 1253
 ?>
1179 1254
 //then load it again every 30 seconds
1180
-//  var reload = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) print ($globalMapRefresh*1000)/2; else print '15000'; ?>);
1255
+//  var reload = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) {
1256
+	print ($globalMapRefresh*1000)/2;
1257
+} else {
1258
+	print '15000';
1259
+}
1260
+?>);
1181 1261
 reloadPage = setInterval(function(){if (noTimeout) getLiveData(0)},<?php print $archiveupdatetime*1000; ?>);
1182 1262
 <?php
1183 1263
 	} else {
1184 1264
 ?>
1185 1265
 //then load it again every 30 seconds
1186 1266
 reloadPage = setInterval(
1187
-    function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>);
1267
+    function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) {
1268
+	print $globalMapRefresh*1000;
1269
+} else {
1270
+	print '30000';
1271
+}
1272
+?>);
1188 1273
 var currentdate = new Date();
1189 1274
 var currentyear = new Date().getFullYear();
1190 1275
 var begindate = new Date(Date.UTC(currentyear,11,24,2,0,0,0));
@@ -1196,7 +1281,12 @@  discard block
 block discarded – undo
1196 1281
 		if (!((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) && (isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
1197 1282
 ?>
1198 1283
 update_polarLayer();
1199
-setInterval(function(){map.removeLayer(polarLayer);update_polarLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
1284
+setInterval(function(){map.removeLayer(polarLayer);update_polarLayer()},<?php if (isset($globalMapRefresh)) {
1285
+	print $globalMapRefresh*1000*2;
1286
+} else {
1287
+	print '60000';
1288
+}
1289
+?>);
1200 1290
 <?php
1201 1291
 		}
1202 1292
 ?>
@@ -1212,7 +1302,12 @@  discard block
 block discarded – undo
1212 1302
 	if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
1213 1303
 ?>
1214 1304
 update_atcLayer();
1215
-setInterval(function(){map.removeLayer(atcLayer);update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
1305
+setInterval(function(){map.removeLayer(atcLayer);update_atcLayer()},<?php if (isset($globalMapRefresh)) {
1306
+	print $globalMapRefresh*1000*2;
1307
+} else {
1308
+	print '60000';
1309
+}
1310
+?>);
1216 1311
 <?php
1217 1312
 	}
1218 1313
 ?>
Please login to merge, or discard this patch.