Completed
Push — master ( 3f174d...72d96f )
by Yannick
12:45
created
getImages.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -4,66 +4,66 @@
 block discarded – undo
4 4
 	$hex = str_replace("#", "", $hex);
5 5
 	$color = array();
6 6
 	if (strlen($hex) == 3) {
7
-	    $color['r'] = hexdec(substr($hex, 0, 1) . substr($hex,0,1));
8
-	    $color['g'] = hexdec(substr($hex, 1, 1) . substr($hex,1,1));
9
-	    $color['b'] = hexdec(substr($hex, 2, 1) . substr($hex,2,1));
7
+		$color['r'] = hexdec(substr($hex, 0, 1) . substr($hex,0,1));
8
+		$color['g'] = hexdec(substr($hex, 1, 1) . substr($hex,1,1));
9
+		$color['b'] = hexdec(substr($hex, 2, 1) . substr($hex,2,1));
10 10
 	} else if (strlen($hex) == 6) {
11
-	    $color['r'] = hexdec(substr($hex, 0, 2));
12
-	    $color['g'] = hexdec(substr($hex, 2, 2));
13
-	    $color['b'] = hexdec(substr($hex, 4, 2));
11
+		$color['r'] = hexdec(substr($hex, 0, 2));
12
+		$color['g'] = hexdec(substr($hex, 2, 2));
13
+		$color['b'] = hexdec(substr($hex, 4, 2));
14 14
 	}
15 15
 	return $color;
16 16
 }
17 17
 
18 18
 
19 19
 if (!isset($_GET['color']) || $_GET['color'] == '' || !preg_match('/^([a-fA-F0-9]){3}(([a-fA-F0-9]){3})?\b/',$_GET['color'])) { 
20
-    exit(0);
20
+	exit(0);
21 21
 }
22 22
 $color = $_GET['color'];
23 23
 if (!isset($_GET['filename']) || !preg_match('/^[a-z0-9-_]+\.png$/', strtolower($_GET['filename']))) {
24
-    echo "Incorrect filename";
25
-    exit(0);
24
+	echo "Incorrect filename";
25
+	exit(0);
26 26
 }
27 27
 $filename = $_GET['filename'];
28 28
 if (file_exists(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$color.'-'.$filename)) {
29
-    header('Content-type: image/png');
30
-    readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$color.'-'.$filename);
31
-    exit(0);
29
+	header('Content-type: image/png');
30
+	readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$color.'-'.$filename);
31
+	exit(0);
32 32
 }
33 33
 $original = dirname(__FILE__).DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'aircrafts'.DIRECTORY_SEPARATOR.'new'.DIRECTORY_SEPARATOR.$filename;
34 34
 if (!file_exists($original)) {
35
-    echo "File not found";
35
+	echo "File not found";
36 36
 }
37 37
 
38 38
 if (extension_loaded('gd') && function_exists('gd_info')) {
39
-    $image = imagecreatefrompng($original);
40
-    $index = imagecolorexact($image,26,49,81);
41
-    if ($index < 0) {
39
+	$image = imagecreatefrompng($original);
40
+	$index = imagecolorexact($image,26,49,81);
41
+	if ($index < 0) {
42 42
 	$index = imagecolorexact($image,25,49,79);
43
-    }
44
-    if ($index < 0) {
43
+	}
44
+	if ($index < 0) {
45 45
 	$index = imagecolorexact($image,0,0,0);
46
-    }
47
-    $c = hexToRGB($color);
48
-    imagecolorset($image,$index,$c['r'],$c['g'],$c['b']);
46
+	}
47
+	$c = hexToRGB($color);
48
+	imagecolorset($image,$index,$c['r'],$c['g'],$c['b']);
49 49
  /*
50 50
     $ig = imagecolorat($image, 0, 0);
51 51
     imagecolortransparent($image, $ig);
52 52
    */
53 53
 
54 54
 
55
-    header('Content-type: image/png');
56
-    imagealphablending($image, false);
57
-    imagesavealpha($image, true);
58
-    imagepng($image);
59
-    if (is_writable('cache')) {
60
-        imagepng($image,dirname(__FILE__).DIRECTORY_SEPARATOR.'cache/'.$color.'-'.$filename);
61
-    }
55
+	header('Content-type: image/png');
56
+	imagealphablending($image, false);
57
+	imagesavealpha($image, true);
58
+	imagepng($image);
59
+	if (is_writable('cache')) {
60
+		imagepng($image,dirname(__FILE__).DIRECTORY_SEPARATOR.'cache/'.$color.'-'.$filename);
61
+	}
62 62
     
63
-    imagedestroy($image);
63
+	imagedestroy($image);
64 64
 } else {
65
-    header('Content-type: image/png');
66
-    if ($color == 'FF0000') readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/aircrafts/selected/'.$filename);
67
-    else readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/aircrafts/'.$filename);
65
+	header('Content-type: image/png');
66
+	if ($color == 'FF0000') readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/aircrafts/selected/'.$filename);
67
+	else readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/aircrafts/'.$filename);
68 68
 }
69 69
 ?>
70 70
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -4,9 +4,9 @@  discard block
 block discarded – undo
4 4
 	$hex = str_replace("#", "", $hex);
5 5
 	$color = array();
6 6
 	if (strlen($hex) == 3) {
7
-	    $color['r'] = hexdec(substr($hex, 0, 1) . substr($hex,0,1));
8
-	    $color['g'] = hexdec(substr($hex, 1, 1) . substr($hex,1,1));
9
-	    $color['b'] = hexdec(substr($hex, 2, 1) . substr($hex,2,1));
7
+	    $color['r'] = hexdec(substr($hex, 0, 1).substr($hex, 0, 1));
8
+	    $color['g'] = hexdec(substr($hex, 1, 1).substr($hex, 1, 1));
9
+	    $color['b'] = hexdec(substr($hex, 2, 1).substr($hex, 2, 1));
10 10
 	} else if (strlen($hex) == 6) {
11 11
 	    $color['r'] = hexdec(substr($hex, 0, 2));
12 12
 	    $color['g'] = hexdec(substr($hex, 2, 2));
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 }
17 17
 
18 18
 
19
-if (!isset($_GET['color']) || $_GET['color'] == '' || !preg_match('/^([a-fA-F0-9]){3}(([a-fA-F0-9]){3})?\b/',$_GET['color'])) { 
19
+if (!isset($_GET['color']) || $_GET['color'] == '' || !preg_match('/^([a-fA-F0-9]){3}(([a-fA-F0-9]){3})?\b/', $_GET['color'])) { 
20 20
     exit(0);
21 21
 }
22 22
 $color = $_GET['color'];
@@ -37,15 +37,15 @@  discard block
 block discarded – undo
37 37
 
38 38
 if (extension_loaded('gd') && function_exists('gd_info')) {
39 39
     $image = imagecreatefrompng($original);
40
-    $index = imagecolorexact($image,26,49,81);
40
+    $index = imagecolorexact($image, 26, 49, 81);
41 41
     if ($index < 0) {
42
-	$index = imagecolorexact($image,25,49,79);
42
+	$index = imagecolorexact($image, 25, 49, 79);
43 43
     }
44 44
     if ($index < 0) {
45
-	$index = imagecolorexact($image,0,0,0);
45
+	$index = imagecolorexact($image, 0, 0, 0);
46 46
     }
47 47
     $c = hexToRGB($color);
48
-    imagecolorset($image,$index,$c['r'],$c['g'],$c['b']);
48
+    imagecolorset($image, $index, $c['r'], $c['g'], $c['b']);
49 49
  /*
50 50
     $ig = imagecolorat($image, 0, 0);
51 51
     imagecolortransparent($image, $ig);
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
     imagesavealpha($image, true);
58 58
     imagepng($image);
59 59
     if (is_writable('cache')) {
60
-        imagepng($image,dirname(__FILE__).DIRECTORY_SEPARATOR.'cache/'.$color.'-'.$filename);
60
+        imagepng($image, dirname(__FILE__).DIRECTORY_SEPARATOR.'cache/'.$color.'-'.$filename);
61 61
     }
62 62
     
63 63
     imagedestroy($image);
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Indentation   +343 added lines, -343 removed lines patch added patch discarded remove patch
@@ -9,16 +9,16 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.Source.php');
10 10
 
11 11
 class SpotterImport {
12
-    private $all_flights = array();
13
-    private $last_delete_hourly = '';
14
-    private $last_delete = '';
15
-    private $stats = array();
16
-    private $tmd = 0;
17
-    private $source_locatioon = array();
18
-    public $db = null;
19
-    public $nb = 0;
20
-
21
-    function __construct($dbc = null) {
12
+	private $all_flights = array();
13
+	private $last_delete_hourly = '';
14
+	private $last_delete = '';
15
+	private $stats = array();
16
+	private $tmd = 0;
17
+	private $source_locatioon = array();
18
+	public $db = null;
19
+	public $nb = 0;
20
+
21
+	function __construct($dbc = null) {
22 22
 	global $globalBeta;
23 23
 	$Connection = new Connection($dbc);
24 24
 	$this->db = $Connection->db;
@@ -29,18 +29,18 @@  discard block
 block discarded – undo
29 29
 	$currentdate = date('Y-m-d');
30 30
 	$sourcestat = $Stats->getStatsSource($currentdate);
31 31
 	if (!empty($sourcestat)) {
32
-	    foreach($sourcestat as $srcst) {
33
-	    	$type = $srcst['stats_type'];
32
+		foreach($sourcestat as $srcst) {
33
+			$type = $srcst['stats_type'];
34 34
 		if ($type == 'polar' || $type == 'hist') {
35
-		    $source = $srcst['source_name'];
36
-		    $data = $srcst['source_data'];
37
-		    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
38
-	        }
39
-	    }
35
+			$source = $srcst['source_name'];
36
+			$data = $srcst['source_data'];
37
+			$this->stats[$currentdate][$source][$type] = json_decode($data,true);
38
+			}
39
+		}
40
+	}
40 41
 	}
41
-    }
42 42
 
43
-    function get_Schedule($id,$ident) {
43
+	function get_Schedule($id,$ident) {
44 44
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
45 45
 	// Get schedule here, so it's done only one time
46 46
 	
@@ -58,35 +58,35 @@  discard block
 block discarded – undo
58 58
 	$Translation = new Translation($dbc);
59 59
 	$operator = $Spotter->getOperator($ident);
60 60
 	if ($Schedule->checkSchedule($operator) == 0) {
61
-	    $operator = $Translation->checkTranslation($ident);
62
-	    if ($Schedule->checkSchedule($operator) == 0) {
61
+		$operator = $Translation->checkTranslation($ident);
62
+		if ($Schedule->checkSchedule($operator) == 0) {
63 63
 		$schedule = $Schedule->fetchSchedule($operator);
64 64
 		if (count($schedule) > 0) {
65
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
66
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
67
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
68
-		    // Should also check if route schedule = route from DB
69
-		    if ($schedule['DepartureAirportIATA'] != '') {
65
+			if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
66
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
67
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
68
+			// Should also check if route schedule = route from DB
69
+			if ($schedule['DepartureAirportIATA'] != '') {
70 70
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
71
-			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
72
-			    if ($airport_icao != '') {
71
+				$airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
72
+				if ($airport_icao != '') {
73 73
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
74 74
 				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
75
-			    }
75
+				}
76
+			}
76 77
 			}
77
-		    }
78
-		    if ($schedule['ArrivalAirportIATA'] != '') {
78
+			if ($schedule['ArrivalAirportIATA'] != '') {
79 79
 			if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) {
80
-			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
81
-			    if ($airport_icao != '') {
80
+				$airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
81
+				if ($airport_icao != '') {
82 82
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
83 83
 				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
84
-			    }
84
+				}
85
+			}
85 86
 			}
86
-		    }
87
-		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
87
+			$Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
88
+		}
88 89
 		}
89
-	    }
90 90
 	}
91 91
 	// close connection, at least one way will work ?
92 92
        
@@ -104,90 +104,90 @@  discard block
 block discarded – undo
104 104
 	}
105 105
 	  */
106 106
 	}
107
-    }
107
+	}
108 108
 
109
-    public function checkAll() {
109
+	public function checkAll() {
110 110
 	global $globalDebug;
111 111
 	if ($globalDebug) echo "Update last seen flights data...\n";
112 112
 	foreach ($this->all_flights as $key => $flight) {
113
-	    if (isset($this->all_flights[$key]['id'])) {
113
+		if (isset($this->all_flights[$key]['id'])) {
114 114
 		//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
115
-    		$Spotter = new Spotter($this->db);
116
-        	$real_arrival = $this->arrival($key);
117
-        	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
118
-            }
115
+			$Spotter = new Spotter($this->db);
116
+			$real_arrival = $this->arrival($key);
117
+			$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
118
+			}
119
+	}
119 120
 	}
120
-    }
121 121
 
122
-    public function arrival($key) {
122
+	public function arrival($key) {
123 123
 	global $globalClosestMinDist, $globalDebug;
124 124
 	$Spotter = new Spotter($this->db);
125
-        $airport_icao = '';
126
-        $airport_time = '';
127
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
125
+		$airport_icao = '';
126
+		$airport_time = '';
127
+		if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
128 128
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
129
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
130
-    	    if (isset($closestAirports[0])) {
131
-        	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
132
-        	    $airport_icao = $closestAirports[0]['icao'];
133
-        	    $airport_time = $this->all_flights[$key]['datetime'];
134
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
135
-        	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
136
-        	    foreach ($closestAirports as $airport) {
137
-        		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
138
-        		    $airport_icao = $airport['icao'];
139
-        		    $airport_time = $this->all_flights[$key]['datetime'];
140
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
141
-        		    break;
142
-        		}
143
-        	    }
144
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
145
-        		$airport_icao = $closestAirports[0]['icao'];
146
-        		$airport_time = $this->all_flights[$key]['datetime'];
147
-        	} else {
148
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
149
-        	}
150
-    	    } else {
151
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
152
-    	    }
153
-
154
-        } else {
155
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
156
-        }
157
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
158
-    }
159
-
160
-
161
-
162
-    function del() {
129
+		$closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
130
+			if (isset($closestAirports[0])) {
131
+			if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
132
+				$airport_icao = $closestAirports[0]['icao'];
133
+				$airport_time = $this->all_flights[$key]['datetime'];
134
+				if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
135
+			} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
136
+				foreach ($closestAirports as $airport) {
137
+				if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
138
+					$airport_icao = $airport['icao'];
139
+					$airport_time = $this->all_flights[$key]['datetime'];
140
+					if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
141
+					break;
142
+				}
143
+				}
144
+			} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
145
+				$airport_icao = $closestAirports[0]['icao'];
146
+				$airport_time = $this->all_flights[$key]['datetime'];
147
+			} else {
148
+				if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
149
+			}
150
+			} else {
151
+				if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
152
+			}
153
+
154
+		} else {
155
+			if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
156
+		}
157
+		return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
158
+	}
159
+
160
+
161
+
162
+	function del() {
163 163
 	global $globalDebug;
164 164
 	// Delete old infos
165 165
 	foreach ($this->all_flights as $key => $flight) {
166
-    	    if (isset($flight['lastupdate'])) {
167
-        	if ($flight['lastupdate'] < (time()-3000)) {
168
-            	    if (isset($this->all_flights[$key]['id'])) {
169
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
166
+			if (isset($flight['lastupdate'])) {
167
+			if ($flight['lastupdate'] < (time()-3000)) {
168
+					if (isset($this->all_flights[$key]['id'])) {
169
+					if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
170 170
 			/*
171 171
 			$SpotterLive = new SpotterLive();
172 172
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
173 173
 			$SpotterLive->db = null;
174 174
 			*/
175
-            		$real_arrival = $this->arrival($key);
176
-            		$Spotter = new Spotter($this->db);
177
-            		if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
175
+					$real_arrival = $this->arrival($key);
176
+					$Spotter = new Spotter($this->db);
177
+					if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
178 178
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
179 179
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
180 180
 			}
181 181
 			// Put in archive
182 182
 //			$Spotter->db = null;
183
-            	    }
184
-            	    unset($this->all_flights[$key]);
185
-    	        }
186
-	    }
187
-        }
188
-    }
189
-
190
-    function add($line) {
183
+					}
184
+					unset($this->all_flights[$key]);
185
+				}
186
+		}
187
+		}
188
+	}
189
+
190
+	function add($line) {
191 191
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBSupdate, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta;
192 192
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
193 193
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
@@ -212,18 +212,18 @@  discard block
 block discarded – undo
212 212
 	
213 213
 	// SBS format is CSV format
214 214
 	if(is_array($line) && isset($line['hex'])) {
215
-	    //print_r($line);
216
-  	    if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) {
215
+		//print_r($line);
216
+  		if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) {
217 217
 
218 218
 		// Increment message number
219 219
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
220
-		    $current_date = date('Y-m-d');
221
-		    $source = $line['source_name'];
222
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
223
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
224
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
225
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
226
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
220
+			$current_date = date('Y-m-d');
221
+			$source = $line['source_name'];
222
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
223
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
224
+				$this->stats[$current_date][$source]['msg']['date'] = time();
225
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
226
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
227 227
 		}
228 228
 		
229 229
 		/*
@@ -239,16 +239,16 @@  discard block
 block discarded – undo
239 239
 		//$this->db = $dbc;
240 240
 
241 241
 		$hex = trim($line['hex']);
242
-	        $id = trim($line['hex']);
242
+			$id = trim($line['hex']);
243 243
 		
244 244
 		//print_r($this->all_flights);
245 245
 		if (!isset($this->all_flights[$id]['hex'])) {
246
-		    $this->all_flights[$id] = array('hex' => $hex);
247
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
248
-		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
246
+			$this->all_flights[$id] = array('hex' => $hex);
247
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
248
+			//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
249 249
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
250
-		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
251
-		    if (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') {
250
+			//} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
251
+			if (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') {
252 252
 
253 253
 			$timeelapsed = microtime(true);
254 254
 			$Spotter = new Spotter($this->db);
@@ -257,30 +257,30 @@  discard block
 block discarded – undo
257 257
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
258 258
 
259 259
 			if ($aircraft_icao == '' && isset($line['aircraft_type'])) {
260
-			    if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
261
-			    elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
262
-			    elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
263
-			    elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
260
+				if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
261
+				elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
262
+				elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
263
+				elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
264 264
 			}
265 265
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
266
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
267
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => false));
268
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
269
-		    if (!isset($line['id'])) {
266
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
267
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => false));
268
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
269
+			if (!isset($line['id'])) {
270 270
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
271 271
 //			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
272 272
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
273 273
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
274
-		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
275
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
274
+				//else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
275
+			 } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
276 276
 
277
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n";
277
+			if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n";
278 278
 		}
279 279
 		
280 280
 		if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
281
-		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
281
+			if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
282 282
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
283
-		    } else {
283
+			} else {
284 284
 				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
285 285
 				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
286 286
 				/*
@@ -289,32 +289,32 @@  discard block
 block discarded – undo
289 289
 				print_r($line);
290 290
 				*/
291 291
 				return '';
292
-		    }
292
+			}
293 293
 		} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
294 294
 
295 295
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
296
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
296
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
297 297
 		}
298 298
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
299
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
299
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
300 300
 		}
301 301
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
302
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
302
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
303 303
 		}
304 304
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
305
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
305
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
306 306
 		}
307 307
  
308 308
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
309
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
310
-		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
309
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
310
+			if ($this->all_flights[$id]['addedSpotter'] == 1) {
311 311
 			$timeelapsed = microtime(true);
312
-            		$Spotter = new Spotter($this->db);
313
-            		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident']);
312
+					$Spotter = new Spotter($this->db);
313
+					$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident']);
314 314
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
315 315
 			$Spotter->db = null;
316 316
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
317
-		    }
317
+			}
318 318
 
319 319
 /*
320 320
 		    if (!isset($line['id'])) {
@@ -324,26 +324,26 @@  discard block
 block discarded – undo
324 324
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
325 325
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
326 326
   */
327
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
327
+			if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
328 328
 
329
-		    //$putinarchive = true;
330
-		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
329
+			//$putinarchive = true;
330
+			if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
331 331
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
332
-		    }
333
-		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
332
+			}
333
+			if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
334 334
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
335
-		    }
336
-		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
337
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
338
-		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
335
+			}
336
+			if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
337
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
338
+			} elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
339 339
 				$timeelapsed = microtime(true);
340 340
 				$Spotter = new Spotter($this->db);
341 341
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
342 342
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
343
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
343
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
344 344
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
345 345
 
346
-		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
346
+			} elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
347 347
 			$timeelapsed = microtime(true);
348 348
 			$Spotter = new Spotter($this->db);
349 349
 			$route = $Spotter->getRouteInfo(trim($line['ident']));
@@ -357,11 +357,11 @@  discard block
 block discarded – undo
357 357
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
358 358
 
359 359
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
360
-			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
361
-			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
360
+				//if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
361
+				if ($route['fromairport_icao'] != $route['toairport_icao']) {
362 362
 				//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
363
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
364
-		    	    }
363
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
364
+					}
365 365
 			}
366 366
 			if (!isset($globalFork)) $globalFork = TRUE;
367 367
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
@@ -379,33 +379,33 @@  discard block
 block discarded – undo
379 379
 				$this->get_Schedule($id,trim($line['ident']));
380 380
 			//    }
381 381
 			}
382
-		    }
382
+			}
383 383
 		}
384 384
 
385 385
 		if (isset($line['speed']) && $line['speed'] != '') {
386 386
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
387
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
388
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
389
-		    //$dataFound = true;
387
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
388
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
389
+			//$dataFound = true;
390 390
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
391
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
392
-		    if ($distance > 1000 && $distance < 10000) {
393
-		    // use datetime
391
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
392
+			if ($distance > 1000 && $distance < 10000) {
393
+			// use datetime
394 394
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
395 395
 			$speed = $speed*3.6;
396 396
 			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
397 397
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
398
-		    }
398
+			}
399 399
 		}
400 400
 
401 401
 
402 402
 
403
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '') {
404
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
405
-	    	    else unset($timediff);
406
-	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
403
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '') {
404
+				if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
405
+				else unset($timediff);
406
+				if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
407 407
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
408
-			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
408
+				if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
409 409
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
410 410
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
411 411
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -421,21 +421,21 @@  discard block
 block discarded – undo
421 421
 				$this->tmd = 0;
422 422
 				//echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
423 423
 				//$putinarchive = true;
424
-			    } else {
425
-			    /*
424
+				} else {
425
+				/*
426 426
 				echo '//////// checkLine FALSE'."\n";
427 427
 				echo 'Check DATA : '.$this->all_flights[$id]['archive_latitude'].' '.$this->all_flights[$id]['archive_longitude'].' '.$this->all_flights[$id]['livedb_latitude'].' '.$this->all_flights[$id]['livedb_longitude'].' '.$line['latitude'].' '.$line['longitude']."\n";
428 428
 			    */
429
-			    }
429
+				}
430 430
 			}
431 431
 
432 432
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
433
-			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
433
+				//if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
434 434
 				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
435 435
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
436
-				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
437
-				    $dataFound = true;
438
-				    $this->all_flights[$id]['time_last_coord'] = time();
436
+					$this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
437
+					$dataFound = true;
438
+					$this->all_flights[$id]['time_last_coord'] = time();
439 439
 				}
440 440
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
441 441
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
@@ -446,20 +446,20 @@  discard block
 block discarded – undo
446 446
 				    //$putinarchive = true;
447 447
 				}
448 448
 				*/
449
-			    /*
449
+				/*
450 450
 			    } elseif (isset($this->all_flights[$id]['latitude'])) {
451 451
 				if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n";
452 452
 			    }
453 453
 			    */
454 454
 			}
455 455
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
456
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
457
-			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
456
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
457
+				//if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
458 458
 				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
459 459
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
460
-				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
461
-				    $dataFound = true;
462
-				    $this->all_flights[$id]['time_last_coord'] = time();
460
+					$this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
461
+					$dataFound = true;
462
+					$this->all_flights[$id]['time_last_coord'] = time();
463 463
 				}
464 464
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
465 465
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
@@ -477,49 +477,49 @@  discard block
 block discarded – undo
477 477
 			    */
478 478
 			}
479 479
 
480
-		    } else if ($globalDebug && $timediff > 20) {
480
+			} else if ($globalDebug && $timediff > 20) {
481 481
 			$this->tmd = $this->tmd + 1;
482 482
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
483 483
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
484 484
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
485 485
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
486
-		    }
486
+			}
487 487
 		}
488 488
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
489
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
490
-		    //$dataFound = true;
489
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
490
+			//$dataFound = true;
491 491
 		}
492 492
 		if (isset($line['format_source']) && $line['format_source'] != '') {
493
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
493
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
494 494
 		}
495 495
 		if (isset($line['source_name']) && $line['source_name'] != '') {
496
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
496
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
497 497
 		}
498 498
 		if (isset($line['emergency']) && $line['emergency'] != '') {
499
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
500
-		    //$dataFound = true;
499
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
500
+			//$dataFound = true;
501 501
 		}
502 502
 		if (isset($line['ground']) && $line['ground'] != '') {
503
-		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
503
+			if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
504 504
 			// Here we force archive of flight because after ground it's a new one (or should be)
505 505
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
506 506
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
507 507
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
508
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
508
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
509 509
 			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
510
-		    }
511
-		    if ($line['ground'] != 1) $line['ground'] = 0;
512
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
513
-		    //$dataFound = true;
510
+			}
511
+			if ($line['ground'] != 1) $line['ground'] = 0;
512
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
513
+			//$dataFound = true;
514 514
 		}
515 515
 		if (isset($line['squawk']) && $line['squawk'] != '') {
516
-		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
517
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
518
-			    $highlight = '';
519
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
520
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
521
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
522
-			    if ($highlight != '') {
516
+			if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
517
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
518
+				$highlight = '';
519
+				if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
520
+				if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
521
+				if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
522
+				if ($highlight != '') {
523 523
 				$timeelapsed = microtime(true);
524 524
 				$Spotter = new Spotter($this->db);
525 525
 				$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
@@ -529,38 +529,38 @@  discard block
 block discarded – undo
529 529
 				$this->all_flights[$id]['putinarchive'] = true;
530 530
 				//$putinarchive = true;
531 531
 				$highlight = '';
532
-			    }
532
+				}
533 533
 			    
534
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
535
-		    //$dataFound = true;
534
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
535
+			//$dataFound = true;
536 536
 		}
537 537
 
538 538
 		if (isset($line['altitude']) && $line['altitude'] != '') {
539
-		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
539
+			//if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
540 540
 			if (abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true;
541 541
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
542 542
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
543 543
 			//$dataFound = true;
544
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
544
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
545 545
   		}
546 546
 
547 547
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
548
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
548
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
549 549
 		}
550 550
 		
551 551
 		if (isset($line['heading']) && $line['heading'] != '') {
552
-		    if (abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
553
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
554
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
555
-		    //$dataFound = true;
552
+			if (abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
553
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
554
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
555
+			//$dataFound = true;
556 556
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
557
-  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
558
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
559
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
560
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
557
+  			$heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
558
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
559
+			if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
560
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
561 561
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
562
-  		    // If not enough messages and ACARS set heading to 0
563
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
562
+  			// If not enough messages and ACARS set heading to 0
563
+  			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
564 564
   		}
565 565
 		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
566 566
 		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
@@ -570,118 +570,118 @@  discard block
 block discarded – undo
570 570
 		//if (time()-$this->all_flights[$id]['lastupdate'] > 30 && $dataFound == true && $this->all_flights[$id]['ident'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
571 571
 		//if ($dataFound == true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['ident'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
572 572
 		if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
573
-		    $this->all_flights[$id]['lastupdate'] = time();
574
-		    if ($this->all_flights[$id]['addedSpotter'] == 0) {
575
-		        if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
576
-			    //print_r($this->all_flights);
577
-			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
578
-			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
579
-			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
573
+			$this->all_flights[$id]['lastupdate'] = time();
574
+			if ($this->all_flights[$id]['addedSpotter'] == 0) {
575
+				if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
576
+				//print_r($this->all_flights);
577
+				//echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
578
+				//$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
579
+				if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
580 580
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
581 581
 				$timeelapsed = microtime(true);
582 582
 				$SpotterLive = new SpotterLive($this->db);
583 583
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
584
-				    $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
585
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
584
+					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
585
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
586 586
 
587 587
 				} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
588
-				    $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
589
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
588
+					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
589
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
590 590
 
591 591
 				} else $recent_ident = '';
592 592
 				$SpotterLive->db=null;
593 593
 
594 594
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
595 595
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
596
-			    } else {
596
+				} else {
597 597
 				$recent_ident = '';
598 598
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
599
-			    }
600
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
601
-			    if($recent_ident == "")
602
-			    {
599
+				}
600
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
601
+				if($recent_ident == "")
602
+				{
603 603
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
604 604
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
605 605
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
606 606
 				//adds the spotter data for the archive
607 607
 				$ignoreImport = false;
608 608
 				foreach($globalAirportIgnore as $airportIgnore) {
609
-				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
609
+					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
610 610
 					$ignoreImport = true;
611
-				    }
611
+					}
612 612
 				}
613 613
 				if (count($globalAirportAccept) > 0) {
614
-				    $ignoreImport = true;
615
-				    foreach($globalAirportIgnore as $airportIgnore) {
614
+					$ignoreImport = true;
615
+					foreach($globalAirportIgnore as $airportIgnore) {
616 616
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
617
-					    $ignoreImport = false;
617
+						$ignoreImport = false;
618
+					}
618 619
 					}
619
-				    }
620 620
 				}
621 621
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
622
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
622
+					foreach($globalAirlineIgnore as $airlineIgnore) {
623 623
 					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
624
-					    $ignoreImport = true;
624
+						$ignoreImport = true;
625
+					}
625 626
 					}
626
-				    }
627 627
 				}
628 628
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
629
-				    $ignoreImport = true;
630
-				    foreach($globalAirlineAccept as $airlineAccept) {
629
+					$ignoreImport = true;
630
+					foreach($globalAirlineAccept as $airlineAccept) {
631 631
 					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
632
-					    $ignoreImport = false;
632
+						$ignoreImport = false;
633
+					}
633 634
 					}
634
-				    }
635 635
 				}
636 636
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
637
-				    $ignoreImport = true;
638
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
637
+					$ignoreImport = true;
638
+					foreach($globalPilotIdAccept as $pilotIdAccept) {
639 639
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
640
-					    $ignoreImport = false;
640
+						$ignoreImport = false;
641
+					}
641 642
 					}
642
-				    }
643 643
 				}
644 644
 				
645 645
 				if (!$ignoreImport) {
646
-				    $highlight = '';
647
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
648
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
649
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
650
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
651
-				    $timeelapsed = microtime(true);
652
-				    $Spotter = new Spotter($this->db);
653
-				    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']);
654
-				    $Spotter->db = null;
655
-				    if ($globalDebug && isset($result)) echo $result."\n";
656
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
646
+					$highlight = '';
647
+					if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
648
+					if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
649
+					if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
650
+					if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
651
+					$timeelapsed = microtime(true);
652
+					$Spotter = new Spotter($this->db);
653
+					$result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']);
654
+					$Spotter->db = null;
655
+					if ($globalDebug && isset($result)) echo $result."\n";
656
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
657 657
 				    
658
-				    // Add source stat in DB
659
-				    $Stats = new Stats($this->db);
660
-				    if (!empty($this->stats)) {
658
+					// Add source stat in DB
659
+					$Stats = new Stats($this->db);
660
+					if (!empty($this->stats)) {
661 661
 					if ($globalDebug) echo 'Add source stats : ';
662
-				        foreach($this->stats as $date => $data) {
663
-					    foreach($data as $source => $sourced) {
664
-					        //print_r($sourced);
665
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
666
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
667
-				    		if (isset($sourced['msg'])) {
668
-				    		    if (time() - $sourced['msg']['date'] > 10) {
669
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
670
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
671
-			    			        unset($this->stats[$date][$source]['msg']);
672
-			    			    }
673
-			    			}
674
-			    		    }
675
-			    		    if ($date != date('Y-m-d')) {
676
-			    			unset($this->stats[$date]);
677
-			    		    }
678
-				    	}
679
-				    	if ($globalDebug) echo 'Done'."\n";
680
-
681
-				    }
682
-				    $Stats->db = null;
662
+						foreach($this->stats as $date => $data) {
663
+						foreach($data as $source => $sourced) {
664
+							//print_r($sourced);
665
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
666
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
667
+							if (isset($sourced['msg'])) {
668
+								if (time() - $sourced['msg']['date'] > 10) {
669
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
670
+									echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
671
+									unset($this->stats[$date][$source]['msg']);
672
+								}
673
+							}
674
+							}
675
+							if ($date != date('Y-m-d')) {
676
+							unset($this->stats[$date]);
677
+							}
678
+						}
679
+						if ($globalDebug) echo 'Done'."\n";
680
+
681
+					}
682
+					$Stats->db = null;
683 683
 				    
684
-				    $this->del();
684
+					$this->del();
685 685
 				} elseif ($globalDebug) echo 'Ignore data'."\n";
686 686
 				$ignoreImport = false;
687 687
 				$this->all_flights[$id]['addedSpotter'] = 1;
@@ -699,18 +699,18 @@  discard block
 block discarded – undo
699 699
 			*/
700 700
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
701 701
 				if ($this->last_delete == '' || time() - $this->last_delete > 1800) {
702
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
703
-				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
704
-				    $SpotterLive = new SpotterLive($this->db);
705
-				    $SpotterLive->deleteLiveSpotterData();
706
-				    $SpotterLive->db=null;
707
-				    if ($globalDebug) echo " Done\n";
708
-				    $this->last_delete = time();
702
+					if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
703
+					//SpotterLive->deleteLiveSpotterDataNotUpdated();
704
+					$SpotterLive = new SpotterLive($this->db);
705
+					$SpotterLive->deleteLiveSpotterData();
706
+					$SpotterLive->db=null;
707
+					if ($globalDebug) echo " Done\n";
708
+					$this->last_delete = time();
709 709
 				}
710
-			    } else {
710
+				} else {
711 711
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) {
712
-				    $this->all_flights[$id]['id'] = $recent_ident;
713
-				    $this->all_flights[$id]['addedSpotter'] = 1;
712
+					$this->all_flights[$id]['id'] = $recent_ident;
713
+					$this->all_flights[$id]['addedSpotter'] = 1;
714 714
 				}
715 715
 				if (isset($globalDaemon) && !$globalDaemon) {
716 716
 					$Spotter = new Spotter($this->db);
@@ -718,14 +718,14 @@  discard block
 block discarded – undo
718 718
 					$Spotter->db = null;
719 719
 				}
720 720
 				
721
-			    }
721
+				}
722
+			}
722 723
 			}
723
-		    }
724
-		    //adds the spotter LIVE data
725
-		    //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
726
-		    //echo "\nAdd in Live !! \n";
727
-		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
728
-		    if ($globalDebug) {
724
+			//adds the spotter LIVE data
725
+			//SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
726
+			//echo "\nAdd in Live !! \n";
727
+			//echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
728
+			if ($globalDebug) {
729 729
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
730 730
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
731 731
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
@@ -733,49 +733,49 @@  discard block
 block discarded – undo
733 733
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
734 734
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
735 735
 			}
736
-		    }
737
-		    $ignoreImport = false;
738
-		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
739
-		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
736
+			}
737
+			$ignoreImport = false;
738
+			if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
739
+			if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
740 740
 
741
-		    foreach($globalAirportIgnore as $airportIgnore) {
742
-		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
743
-			    $ignoreImport = true;
741
+			foreach($globalAirportIgnore as $airportIgnore) {
742
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
743
+				$ignoreImport = true;
744
+			}
744 745
 			}
745
-		    }
746
-		    if (count($globalAirportAccept) > 0) {
747
-		        $ignoreImport = true;
748
-		        foreach($globalAirportIgnore as $airportIgnore) {
749
-			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
746
+			if (count($globalAirportAccept) > 0) {
747
+				$ignoreImport = true;
748
+				foreach($globalAirportIgnore as $airportIgnore) {
749
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
750 750
 				$ignoreImport = false;
751
-			    }
751
+				}
752
+			}
752 753
 			}
753
-		    }
754
-		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
754
+			if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
755 755
 			foreach($globalAirlineIgnore as $airlineIgnore) {
756
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
756
+				if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
757 757
 				$ignoreImport = true;
758
-			    }
758
+				}
759
+			}
759 760
 			}
760
-		    }
761
-		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
761
+			if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
762 762
 			$ignoreImport = true;
763 763
 			foreach($globalAirlineAccept as $airlineAccept) {
764
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
764
+				if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
765 765
 				$ignoreImport = false;
766
-			    }
766
+				}
767 767
 			}
768
-		    }
769
-		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
768
+			}
769
+			if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
770 770
 			$ignoreImport = true;
771 771
 			foreach($globalPilotIdAccept as $pilotIdAccept) {
772
-			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
773
-			        $ignoreImport = false;
774
-			    }
772
+				if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
773
+					$ignoreImport = false;
774
+				}
775
+			}
775 776
 			}
776
-		    }
777 777
 
778
-		    if (!$ignoreImport) {
778
+			if (!$ignoreImport) {
779 779
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
780 780
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
781 781
 				$timeelapsed = microtime(true);
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 					if ($stats_heading == 16) $stats_heading = 0;
814 814
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
815 815
 						for ($i=0;$i<=15;$i++) {
816
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
816
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
817 817
 						}
818 818
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
819 819
 					} else {
@@ -826,11 +826,11 @@  discard block
 block discarded – undo
826 826
 					//var_dump($this->stats);
827 827
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
828 828
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
829
-						    end($this->stats[$current_date][$source]['hist']);
830
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
829
+							end($this->stats[$current_date][$source]['hist']);
830
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
831 831
 						} else $mini = 0;
832 832
 						for ($i=$mini;$i<=$distance;$i+=10) {
833
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
833
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
834 834
 						}
835 835
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
836 836
 					} else {
@@ -847,22 +847,22 @@  discard block
 block discarded – undo
847 847
 			
848 848
 			
849 849
 			if ($this->last_delete_hourly == '' || time() - $this->last_delete_hourly > 900) {
850
-			    if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
851
-			    $SpotterLive = new SpotterLive($this->db);
852
-			    $SpotterLive->deleteLiveSpotterDataNotUpdated();
853
-			    $SpotterLive->db = null;
854
-			    //SpotterLive->deleteLiveSpotterData();
855
-			    if ($globalDebug) echo " Done\n";
856
-			    $this->last_delete_hourly = time();
850
+				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
851
+				$SpotterLive = new SpotterLive($this->db);
852
+				$SpotterLive->deleteLiveSpotterDataNotUpdated();
853
+				$SpotterLive->db = null;
854
+				//SpotterLive->deleteLiveSpotterData();
855
+				if ($globalDebug) echo " Done\n";
856
+				$this->last_delete_hourly = time();
857 857
 			}
858 858
 			
859
-		    }
860
-		    $ignoreImport = false;
859
+			}
860
+			$ignoreImport = false;
861 861
 		}
862 862
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
863 863
 		if ($send) return $this->all_flights[$id];
864
-	    }
864
+		}
865
+	}
865 866
 	}
866
-    }
867 867
 }
868 868
 ?>
Please login to merge, or discard this patch.
require/class.Scheduler.php 1 patch
Indentation   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -8,29 +8,29 @@  discard block
 block discarded – undo
8 8
 
9 9
 class Schedule {
10 10
 	protected $cookies = array();
11
-        public $db;
11
+		public $db;
12 12
 	function __construct($dbc = null) {
13 13
 		$Connection = new Connection($dbc);
14 14
 		$this->db = $Connection->db;
15
-        }
15
+		}
16 16
 	
17 17
 	/**
18
-	* Add schedule data to database
19
-	* @param String $ident aircraft ident
20
-	* @param String $departure_airport_icao departure airport icao
21
-	* @param String $departure_airport_time departure airport time
22
-	* @param String $arrival_airport_icao arrival airport icao
23
-	* @param String $arrival_airport_time arrival airport time
18
+	 * Add schedule data to database
19
+	 * @param String $ident aircraft ident
20
+	 * @param String $departure_airport_icao departure airport icao
21
+	 * @param String $departure_airport_time departure airport time
22
+	 * @param String $arrival_airport_icao arrival airport icao
23
+	 * @param String $arrival_airport_time arrival airport time
24 24
 	/ @param String $source source of data
25
-	*/
25
+	 */
26 26
 	
27 27
 	public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') {
28 28
 		date_default_timezone_set('UTC');
29 29
 		$date = date("Y-m-d H:i:s",time());
30
-	        //if ($departure_airport_time == '' && $arrival_airport_time == '') exit;
31
-	        //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident";
32
-	        $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident";
33
-	        $query_values = array(':ident' => $ident);
30
+			//if ($departure_airport_time == '' && $arrival_airport_time == '') exit;
31
+			//$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident";
32
+			$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident";
33
+			$query_values = array(':ident' => $ident);
34 34
 		 try {
35 35
 			$sth = $this->db->prepare($query);
36 36
 			$sth->execute($query_values);
@@ -39,18 +39,18 @@  discard block
 block discarded – undo
39 39
 		}
40 40
 		if ($sth->fetchColumn() > 0) {
41 41
 			if ($departure_airport_time == '' && $arrival_airport_time == '') {
42
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
43
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
42
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
43
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
44 44
 			} elseif ($arrival_airport_time == '') {
45
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
46
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
45
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
46
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
47 47
 			} elseif ($departure_airport_time == '') {
48
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
49
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
48
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
49
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
50 50
 			} else {
51
-			    //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
52
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
53
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
51
+				//$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
52
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
53
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
54 54
 			}
55 55
 			try {
56 56
 				$sth = $this->db->prepare($query);
@@ -61,17 +61,17 @@  discard block
 block discarded – undo
61 61
 			if ($sth->fetchColumn() == 0) {
62 62
 				//$query = 'UPDATE schedule SET departure_airport_icao = :departure_airport_icao, departure_airport_time = :departure_airport_time, arrival_airport_icao = :arrival_airport_icao, arrival_airport_time = :arrival_airport_time, date_modified = :date, source = :source WHERE ident = :ident';
63 63
 				if ($departure_airport_time == '' && $arrival_airport_time == '') {
64
-                            	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
65
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
64
+									$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
65
+					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
66 66
 				} elseif ($arrival_airport_time == '') {
67
-                            	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
68
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
67
+									$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
68
+					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
69 69
 				} elseif ($departure_airport_time == '') {
70
-                            	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
71
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
70
+									$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
71
+					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
72 72
 				} else {
73
-                            	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
74
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
73
+									$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
74
+					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
75 75
 				}
76 76
 				 try {
77 77
 					$sth = $this->db->prepare($query);
@@ -104,15 +104,15 @@  discard block
 block discarded – undo
104 104
 	}
105 105
 
106 106
 	public function getSchedule($ident) {
107
-	        $Translation = new Translation($this->db);
108
-	        $operator = $Translation->checkTranslation($ident,false);
109
-	        if ($ident != $operator) {
110
-	    		$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE CallSign = :operator OR CallSign = :ident LIMIT 1";
111
-	    		$query_values = array(':ident' => $ident,'operator' => $operator);
112
-	    	} else {
113
-		        $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE CallSign = :ident LIMIT 1";
114
-	    		$query_values = array(':ident' => $ident);
115
-	    	}
107
+			$Translation = new Translation($this->db);
108
+			$operator = $Translation->checkTranslation($ident,false);
109
+			if ($ident != $operator) {
110
+				$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE CallSign = :operator OR CallSign = :ident LIMIT 1";
111
+				$query_values = array(':ident' => $ident,'operator' => $operator);
112
+			} else {
113
+				$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE CallSign = :ident LIMIT 1";
114
+				$query_values = array(':ident' => $ident);
115
+			}
116 116
 		 try {
117 117
 			$sth = $this->db->prepare($query);
118 118
 			$sth->execute($query_values);
@@ -127,15 +127,15 @@  discard block
 block discarded – undo
127 127
 
128 128
 	public function checkSchedule($ident) {
129 129
 		global $globalDBdriver;
130
-	        //$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1";
131
-	        if ($globalDBdriver == 'mysql') {
130
+			//$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1";
131
+			if ($globalDBdriver == 'mysql') {
132 132
 			$query = "SELECT COUNT(*) as nb FROM routes WHERE CallSign = :ident AND ((date_added BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 15 DAY)) AND DATE(NOW()) and date_modified IS NULL) OR (date_modified BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 15 DAY)) AND DATE(NOW()))) LIMIT 1";
133 133
 		} else {
134 134
 			$query = "SELECT COUNT(*) as nb FROM routes WHERE CallSign = :ident 
135 135
 			AND ((date_added::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '15 DAYS' AND CURRENT_TIMESTAMP) and date_modified::timestamp IS NULL)
136 136
 			     OR (date_modified::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '15 DAYS' AND CURRENT_TIMESTAMP) LIMIT 1";
137 137
 		}
138
-	        $query_values = array(':ident' => $ident);
138
+			$query_values = array(':ident' => $ident);
139 139
 		 try {
140 140
 			$sth = $this->db->prepare($query);
141 141
 			$sth->execute($query_values);
@@ -147,12 +147,12 @@  discard block
 block discarded – undo
147 147
 	}
148 148
 
149 149
 	/**
150
-	* Get flight info from Air France
151
-	* @param String $callsign The callsign
152
-	* @param String $date date we want flight number info
153
-	* @param String $carrier IATA code
154
-	* @return Flight departure and arrival airports and time
155
-	*/
150
+	 * Get flight info from Air France
151
+	 * @param String $callsign The callsign
152
+	 * @param String $date date we want flight number info
153
+	 * @param String $carrier IATA code
154
+	 * @return Flight departure and arrival airports and time
155
+	 */
156 156
 	private function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') {
157 157
 		$Common = new Common();
158 158
 		$check_date = new Datetime($date);
@@ -188,11 +188,11 @@  discard block
 block discarded – undo
188 188
 	}
189 189
 
190 190
 	/**
191
-	* Get flight info from EasyJet
192
-	* @param String $callsign The callsign
193
-	* @param String $date date we want flight number info
194
-	* @return Flight departure and arrival airports and time
195
-	*/
191
+	 * Get flight info from EasyJet
192
+	 * @param String $callsign The callsign
193
+	 * @param String $date date we want flight number info
194
+	 * @return Flight departure and arrival airports and time
195
+	 */
196 196
 	private function getEasyJet($callsign, $date = 'NOW') {
197 197
 		global $globalTimezone;
198 198
 		$Common = new Common();
@@ -216,10 +216,10 @@  discard block
 block discarded – undo
216 216
 	}
217 217
 
218 218
 	/**
219
-	* Get flight info from Ryanair
220
-	* @param String $callsign The callsign
221
-	* @return Flight departure and arrival airports and time
222
-	*/
219
+	 * Get flight info from Ryanair
220
+	 * @param String $callsign The callsign
221
+	 * @return Flight departure and arrival airports and time
222
+	 */
223 223
 	private function getRyanair($callsign) {
224 224
 		$Common = new Common();
225 225
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -242,10 +242,10 @@  discard block
 block discarded – undo
242 242
 	}
243 243
 
244 244
 	/**
245
-	* Get flight info from Swiss
246
-	* @param String $callsign The callsign
247
-	* @return Flight departure and arrival airports and time
248
-	*/
245
+	 * Get flight info from Swiss
246
+	 * @param String $callsign The callsign
247
+	 * @return Flight departure and arrival airports and time
248
+	 */
249 249
 	private function getSwiss($callsign) {
250 250
 		$Common = new Common();
251 251
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
 	}
273 273
 	
274 274
 	/**
275
-	* Get flight info from British Airways API
276
-	* @param String $callsign The callsign
277
-	* @param String $date date we want flight number info
278
-	* @return Flight departure and arrival airports and time
279
-	*/
275
+	 * Get flight info from British Airways API
276
+	 * @param String $callsign The callsign
277
+	 * @param String $date date we want flight number info
278
+	 * @return Flight departure and arrival airports and time
279
+	 */
280 280
 	public function getBritishAirways($callsign, $date = 'NOW') {
281 281
 		global $globalBritishAirwaysKey;
282 282
 		$Common = new Common();
@@ -300,11 +300,11 @@  discard block
 block discarded – undo
300 300
 	}
301 301
 
302 302
 	/**
303
-	* Get flight info from Lutfhansa API
304
-	* @param String $callsign The callsign
305
-	* @param String $date date we want flight number info
306
-	* @return Flight departure and arrival airports and time
307
-	*/
303
+	 * Get flight info from Lutfhansa API
304
+	 * @param String $callsign The callsign
305
+	 * @param String $date date we want flight number info
306
+	 * @return Flight departure and arrival airports and time
307
+	 */
308 308
 	public function getLufthansa($callsign, $date = 'NOW') {
309 309
 		global $globalLufthansaKey;
310 310
 		$Common = new Common();
@@ -334,11 +334,11 @@  discard block
 block discarded – undo
334 334
 	}
335 335
 
336 336
 	/**
337
-	* Get flight info from Transavia API
338
-	* @param String $callsign The callsign
339
-	* @param String $date date we want flight number info
340
-	* @return Flight departure and arrival airports and time
341
-	*/
337
+	 * Get flight info from Transavia API
338
+	 * @param String $callsign The callsign
339
+	 * @param String $date date we want flight number info
340
+	 * @return Flight departure and arrival airports and time
341
+	 */
342 342
 	private function getTransavia($callsign, $date = 'NOW') {
343 343
 		global $globalTransaviaKey;
344 344
 		$Common = new Common();
@@ -362,10 +362,10 @@  discard block
 block discarded – undo
362 362
 	}
363 363
 
364 364
 	/**
365
-	* Get flight info from Tunisair
366
-	* @param String $callsign The callsign
367
-	* @return Flight departure and arrival airports and time
368
-	*/
365
+	 * Get flight info from Tunisair
366
+	 * @param String $callsign The callsign
367
+	 * @return Flight departure and arrival airports and time
368
+	 */
369 369
 	private function getTunisair($callsign) {
370 370
 		$Common = new Common();
371 371
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -382,10 +382,10 @@  discard block
 block discarded – undo
382 382
 	}
383 383
 
384 384
 	/**
385
-	* Get flight info from Vueling
386
-	* @param String $callsign The callsign
387
-	* @return Flight departure and arrival airports and time
388
-	*/
385
+	 * Get flight info from Vueling
386
+	 * @param String $callsign The callsign
387
+	 * @return Flight departure and arrival airports and time
388
+	 */
389 389
 	private function getVueling($callsign) {
390 390
 		$Common = new Common();
391 391
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -408,11 +408,11 @@  discard block
 block discarded – undo
408 408
 	}
409 409
 
410 410
 	/**
411
-	* Get flight info from Iberia
412
-	* @param String $callsign The callsign
413
-	* @param String $date date we want flight number info
414
-	* @return Flight departure and arrival airports and time
415
-	*/
411
+	 * Get flight info from Iberia
412
+	 * @param String $callsign The callsign
413
+	 * @param String $date date we want flight number info
414
+	 * @return Flight departure and arrival airports and time
415
+	 */
416 416
 	private function getIberia($callsign, $date = 'NOW') {
417 417
 		$Common = new Common();
418 418
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -442,11 +442,11 @@  discard block
 block discarded – undo
442 442
 	}
443 443
 
444 444
 	/**
445
-	* Get flight info from Star Alliance
446
-	* @param String $callsign The callsign
447
-	* @param String $date date we want flight number info
448
-	* @return Flight departure and arrival airports and time
449
-	*/
445
+	 * Get flight info from Star Alliance
446
+	 * @param String $callsign The callsign
447
+	 * @param String $date date we want flight number info
448
+	 * @return Flight departure and arrival airports and time
449
+	 */
450 450
 	private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') {
451 451
 		$Common = new Common();
452 452
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -476,11 +476,11 @@  discard block
 block discarded – undo
476 476
 	}
477 477
 
478 478
 	/**
479
-	* Get flight info from Alitalia
480
-	* @param String $callsign The callsign
481
-	* @param String $date date we want flight number info
482
-	* @return Flight departure and arrival airports and time
483
-	*/
479
+	 * Get flight info from Alitalia
480
+	 * @param String $callsign The callsign
481
+	 * @param String $date date we want flight number info
482
+	 * @return Flight departure and arrival airports and time
483
+	 */
484 484
 	private function getAlitalia($callsign, $date = 'NOW') {
485 485
 		$Common = new Common();
486 486
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -499,11 +499,11 @@  discard block
 block discarded – undo
499 499
 	}
500 500
 
501 501
 	/**
502
-	* Get flight info from Brussels airlines
503
-	* @param String $callsign The callsign
504
-	* @param String $date date we want flight number info
505
-	* @return Flight departure and arrival airports and time
506
-	*/
502
+	 * Get flight info from Brussels airlines
503
+	 * @param String $callsign The callsign
504
+	 * @param String $date date we want flight number info
505
+	 * @return Flight departure and arrival airports and time
506
+	 */
507 507
 	private function getBrussels($callsign, $date = 'NOW') {
508 508
 		$Common = new Common();
509 509
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -513,24 +513,24 @@  discard block
 block discarded – undo
513 513
 		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
514 514
 		$data = $Common->getData($url);
515 515
 		if ($data != '') {
516
-		    //echo $data;
517
-		    $parsed_json = json_decode($data);
518
-		    if (isset($parsed_json[0]->FromAirportCode)) {
516
+			//echo $data;
517
+			$parsed_json = json_decode($data);
518
+			if (isset($parsed_json[0]->FromAirportCode)) {
519 519
 			$DepartureAirportIata = $parsed_json[0]->FromAirportCode;
520 520
 			$ArrivalAirportIata = $parsed_json[0]->ToAirportCode;
521 521
 			$departureTime = date('H:i',strtotime($parsed_json[0]->ScheduledDepatureDate));
522 522
 			$arrivalTime = date('H:i',strtotime($parsed_json[0]->ScheduledArrivalDate));
523 523
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels');
524
-		    }
524
+			}
525 525
 		}
526 526
 	}
527 527
 
528 528
 	/**
529
-	* Get flight info from FlightRadar24
530
-	* @param String $callsign The callsign
531
-	* @param String $date date we want flight number info
532
-	* @return Flight departure and arrival airports and time
533
-	*/
529
+	 * Get flight info from FlightRadar24
530
+	 * @param String $callsign The callsign
531
+	 * @param String $date date we want flight number info
532
+	 * @return Flight departure and arrival airports and time
533
+	 */
534 534
 /*
535 535
 	public function getFlightRadar24($callsign, $date = 'NOW') {
536 536
 		$Common = new Common();
@@ -559,11 +559,11 @@  discard block
 block discarded – undo
559 559
 	}
560 560
   */
561 561
 	/**
562
-	* Get flight info from Lufthansa
563
-	* @param String $callsign The callsign
564
-	* @param String $date date we want flight number info
565
-	* @return Flight departure and arrival airports and time
566
-	*/
562
+	 * Get flight info from Lufthansa
563
+	 * @param String $callsign The callsign
564
+	 * @param String $date date we want flight number info
565
+	 * @return Flight departure and arrival airports and time
566
+	 */
567 567
 
568 568
 /*	private function getLufthansa($callsign, $date = 'NOW') {
569 569
 		$Common = new Common();
@@ -591,11 +591,11 @@  discard block
 block discarded – undo
591 591
 	}
592 592
   */
593 593
 	/**
594
-	* Get flight info from flytap
595
-	* @param String $callsign The callsign
596
-	* @param String $date date we want flight number info
597
-	* @return Flight departure and arrival airports and time
598
-	*/
594
+	 * Get flight info from flytap
595
+	 * @param String $callsign The callsign
596
+	 * @param String $date date we want flight number info
597
+	 * @return Flight departure and arrival airports and time
598
+	 */
599 599
 	private function getFlyTap($callsign, $date = 'NOW') {
600 600
 		$Common = new Common();
601 601
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -618,11 +618,11 @@  discard block
 block discarded – undo
618 618
 	}
619 619
 
620 620
 	/**
621
-	* Get flight info from flightmapper
622
-	* @param String $callsign The callsign
623
-	* @param String $date date we want flight number info
624
-	* @return Flight departure and arrival airports and time
625
-	*/
621
+	 * Get flight info from flightmapper
622
+	 * @param String $callsign The callsign
623
+	 * @param String $date date we want flight number info
624
+	 * @return Flight departure and arrival airports and time
625
+	 */
626 626
 	public function getFlightMapper($callsign, $date = 'NOW') {
627 627
 		$Common = new Common();
628 628
 		if (!is_numeric(substr($callsign, 0, 3)))
@@ -644,11 +644,11 @@  discard block
 block discarded – undo
644 644
 				$sched = $table[5][0];
645 645
 				$n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr);
646 646
 				if ($n == 7) {
647
-				    $departureTime = $dhour;
648
-				    $arrivalTime = $ahour;
649
-				    $DepartureAirportIata = str_replace(array('(',')'),'',$darr);
650
-				    $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
651
-				    return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
647
+					$departureTime = $dhour;
648
+					$arrivalTime = $ahour;
649
+					$DepartureAirportIata = str_replace(array('(',')'),'',$darr);
650
+					$ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
651
+					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
652 652
 				}
653 653
 			}
654 654
 		}
@@ -656,11 +656,11 @@  discard block
 block discarded – undo
656 656
 	}
657 657
 
658 658
 	/**
659
-	* Get flight info from flightaware
660
-	* @param String $callsign The callsign
661
-	* @param String $date date we want flight number info
662
-	* @return Flight departure and arrival airports and time
663
-	*/
659
+	 * Get flight info from flightaware
660
+	 * @param String $callsign The callsign
661
+	 * @param String $date date we want flight number info
662
+	 * @return Flight departure and arrival airports and time
663
+	 */
664 664
 	public function getFlightAware($callsign, $date = 'NOW') {
665 665
 		$Common = new Common();
666 666
 		if (!is_numeric(substr($callsign, 0, 3)))
@@ -691,11 +691,11 @@  discard block
 block discarded – undo
691 691
 	}
692 692
 
693 693
 	/**
694
-	* Get flight info from CostToTravel
695
-	* @param String $callsign The callsign
696
-	* @param String $date date we want flight number info
697
-	* @return Flight departure and arrival airports and time
698
-	*/
694
+	 * Get flight info from CostToTravel
695
+	 * @param String $callsign The callsign
696
+	 * @param String $date date we want flight number info
697
+	 * @return Flight departure and arrival airports and time
698
+	 */
699 699
 	public function getCostToTravel($callsign, $date = 'NOW') {
700 700
 		$Common = new Common();
701 701
 		$url= "http://www.costtotravel.com/flight-number/".$callsign;
@@ -717,11 +717,11 @@  discard block
 block discarded – undo
717 717
 	}
718 718
 
719 719
 	/**
720
-	* Get flight info from Air Canada
721
-	* @param String $callsign The callsign
722
-	* @param String $date date we want flight number info
723
-	* @return Flight departure and arrival airports and time
724
-	*/
720
+	 * Get flight info from Air Canada
721
+	 * @param String $callsign The callsign
722
+	 * @param String $date date we want flight number info
723
+	 * @return Flight departure and arrival airports and time
724
+	 */
725 725
 	private function getAirCanada($callsign,$date = 'NOW') {
726 726
 		$Common = new Common();
727 727
 		date_default_timezone_set('UTC');
@@ -745,11 +745,11 @@  discard block
 block discarded – undo
745 745
 	}
746 746
 
747 747
 	/**
748
-	* Get flight info from Vietnam Airlines
749
-	* @param String $callsign The callsign
750
-	* @param String $date date we want flight number info
751
-	* @return Flight departure and arrival airports and time
752
-	*/
748
+	 * Get flight info from Vietnam Airlines
749
+	 * @param String $callsign The callsign
750
+	 * @param String $date date we want flight number info
751
+	 * @return Flight departure and arrival airports and time
752
+	 */
753 753
 	private function getVietnamAirlines($callsign, $date = 'NOW') {
754 754
 		$Common = new Common();
755 755
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -771,12 +771,12 @@  discard block
 block discarded – undo
771 771
 	}
772 772
 
773 773
 	/**
774
-	* Get flight info from Air Berlin
775
-	* @param String $callsign The callsign
776
-	* @param String $date date we want flight number info
777
-	* @param String $carrier IATA code
778
-	* @return Flight departure and arrival airports and time
779
-	*/
774
+	 * Get flight info from Air Berlin
775
+	 * @param String $callsign The callsign
776
+	 * @param String $date date we want flight number info
777
+	 * @param String $carrier IATA code
778
+	 * @return Flight departure and arrival airports and time
779
+	 */
780 780
 	private function getAirBerlin($callsign, $date = 'NOW', $carrier = 'AB') {
781 781
 		$Common = new Common();
782 782
 		date_default_timezone_set('UTC');
@@ -805,11 +805,11 @@  discard block
 block discarded – undo
805 805
 			$table = $Common->table2array($data);
806 806
 			$flight = $table;
807 807
 			if (isset($flight[5][4])) {
808
-			    $arrivalTime = $flight[5][4];
809
-			    $arrivalAirport = $flight[5][3];
808
+				$arrivalTime = $flight[5][4];
809
+				$arrivalAirport = $flight[5][3];
810 810
 			} else {
811
-			    $arrivalTime = '';
812
-			    $arrivalAirport = '';
811
+				$arrivalTime = '';
812
+				$arrivalAirport = '';
813 813
 			}
814 814
 		}
815 815
 		$url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner';
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
 					}
1092 1092
 			}
1093 1093
 		}
1094
-	        return array();
1094
+			return array();
1095 1095
 	}
1096 1096
 }
1097 1097
 
Please login to merge, or discard this patch.
require/class.SpotterArchive.php 3 patches
Indentation   +514 added lines, -514 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class SpotterArchive {
3
-    public $global_query = "SELECT spotter_archive.* FROM spotter_archive";
4
-    public $db;
3
+	public $global_query = "SELECT spotter_archive.* FROM spotter_archive";
4
+	public $db;
5 5
 
6
-    function __construct($dbc = null) {
7
-            $Connection = new Connection($dbc);
8
-            $this->db = $Connection->db;
9
-    }
6
+	function __construct($dbc = null) {
7
+			$Connection = new Connection($dbc);
8
+			$this->db = $Connection->db;
9
+	}
10 10
 
11 11
 
12
-    // Spotter_archive
12
+	// Spotter_archive
13 13
     
14
-    function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') {
14
+	function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') {
15 15
 	require_once(dirname(__FILE__).'/class.Spotter.php');
16
-        if ($over_country == '') {
17
-	        $Spotter = new Spotter($this->db);
18
-	        $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
16
+		if ($over_country == '') {
17
+			$Spotter = new Spotter($this->db);
18
+			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
19 19
 		if (!empty($data_country)) $country = $data_country['iso2'];
20 20
 		else $country = '';
21 21
 	} else $country = $over_country;
@@ -28,55 +28,55 @@  discard block
 block discarded – undo
28 28
 	$query  = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name)
29 29
                 VALUES (:flightaware_id, :ident, :registration, :airline_name, :airline_icao, :airline_country, :airline_type, :aircraft_icao, :aircraft_shadow, :aircraft_name, :aircraft_manufacturer, :departure_airport_icao, :departure_airport_name, :departure_airport_city, :departure_airport_country, :departure_airport_time,:arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :arrival_airport_time, :route_stop, :date,:latitude, :longitude, :waypoints, :altitude, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name)";
30 30
 
31
-        $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name);
32
-        try {
33
-            $sth = $this->db->prepare($query);
34
-            $sth->execute($query_values);
35
-        } catch(PDOException $e) {
36
-            return "error : ".$e->getMessage();
37
-        }
38
-        return "success";
39
-    }
40
-
41
-
42
-        /**
43
-        * Gets all the spotter information based on a particular callsign
44
-        *
45
-        * @return Array the spotter information
46
-        *
47
-        */
48
-        public function getLastArchiveSpotterDataByIdent($ident)
49
-        {
31
+		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name);
32
+		try {
33
+			$sth = $this->db->prepare($query);
34
+			$sth->execute($query_values);
35
+		} catch(PDOException $e) {
36
+			return "error : ".$e->getMessage();
37
+		}
38
+		return "success";
39
+	}
40
+
41
+
42
+		/**
43
+		 * Gets all the spotter information based on a particular callsign
44
+		 *
45
+		 * @return Array the spotter information
46
+		 *
47
+		 */
48
+		public function getLastArchiveSpotterDataByIdent($ident)
49
+		{
50 50
 		$Spotter = new Spotter($this->db);
51
-                date_default_timezone_set('UTC');
51
+				date_default_timezone_set('UTC');
52 52
 
53
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
54
-                //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
55
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
53
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
54
+				//$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
55
+				$query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
56 56
 
57
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
57
+				$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
58 58
 
59
-                return $spotter_array;
60
-        }
59
+				return $spotter_array;
60
+		}
61 61
 
62 62
 
63
-        /**
64
-        * Gets last the spotter information based on a particular id
65
-        *
66
-        * @return Array the spotter information
67
-        *
68
-        */
69
-        public function getLastArchiveSpotterDataById($id)
70
-        {
71
-    		$Spotter = new Spotter($this->db);
72
-                date_default_timezone_set('UTC');
73
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
74
-                //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
75
-                //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
76
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
63
+		/**
64
+		 * Gets last the spotter information based on a particular id
65
+		 *
66
+		 * @return Array the spotter information
67
+		 *
68
+		 */
69
+		public function getLastArchiveSpotterDataById($id)
70
+		{
71
+			$Spotter = new Spotter($this->db);
72
+				date_default_timezone_set('UTC');
73
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
74
+				//$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
75
+				//$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
76
+				$query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
77 77
 
78 78
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
79
-                  /*
79
+				  /*
80 80
                 try {
81 81
                         $Connection = new Connection();
82 82
                         $sth = Connection->$db->prepare($query);
@@ -86,225 +86,225 @@  discard block
 block discarded – undo
86 86
                 }
87 87
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
88 88
                 */
89
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
90
-
91
-                return $spotter_array;
92
-        }
93
-
94
-        /**
95
-        * Gets all the spotter information based on a particular id
96
-        *
97
-        * @return Array the spotter information
98
-        *
99
-        */
100
-        public function getAllArchiveSpotterDataById($id)
101
-        {
102
-                date_default_timezone_set('UTC');
103
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
104
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
89
+				$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
90
+
91
+				return $spotter_array;
92
+		}
93
+
94
+		/**
95
+		 * Gets all the spotter information based on a particular id
96
+		 *
97
+		 * @return Array the spotter information
98
+		 *
99
+		 */
100
+		public function getAllArchiveSpotterDataById($id)
101
+		{
102
+				date_default_timezone_set('UTC');
103
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
104
+				$query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
105 105
 
106 106
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
107 107
 
108
-                try {
109
-                        $sth = $this->db->prepare($query);
110
-                        $sth->execute(array(':id' => $id));
111
-                } catch(PDOException $e) {
112
-                        return "error";
113
-                }
114
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
115
-
116
-                return $spotter_array;
117
-        }
118
-
119
-        /**
120
-        * Gets coordinate & time spotter information based on a particular id
121
-        *
122
-        * @return Array the spotter information
123
-        *
124
-        */
125
-        public function getCoordArchiveSpotterDataById($id)
126
-        {
127
-                date_default_timezone_set('UTC');
128
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
129
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
108
+				try {
109
+						$sth = $this->db->prepare($query);
110
+						$sth->execute(array(':id' => $id));
111
+				} catch(PDOException $e) {
112
+						return "error";
113
+				}
114
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
115
+
116
+				return $spotter_array;
117
+		}
118
+
119
+		/**
120
+		 * Gets coordinate & time spotter information based on a particular id
121
+		 *
122
+		 * @return Array the spotter information
123
+		 *
124
+		 */
125
+		public function getCoordArchiveSpotterDataById($id)
126
+		{
127
+				date_default_timezone_set('UTC');
128
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
129
+				$query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
130 130
 
131 131
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
132 132
 
133
-                try {
134
-                        $sth = $this->db->prepare($query);
135
-                        $sth->execute(array(':id' => $id));
136
-                } catch(PDOException $e) {
137
-                        return $e->getMessage();
138
-                }
139
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
133
+				try {
134
+						$sth = $this->db->prepare($query);
135
+						$sth->execute(array(':id' => $id));
136
+				} catch(PDOException $e) {
137
+						return $e->getMessage();
138
+				}
139
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
140 140
 
141
-                return $spotter_array;
142
-        }
141
+				return $spotter_array;
142
+		}
143 143
 
144 144
 
145
-        /**
146
-        * Gets altitude information based on a particular callsign
147
-        *
148
-        * @return Array the spotter information
149
-        *
150
-        */
151
-        public function getAltitudeArchiveSpotterDataByIdent($ident)
152
-        {
145
+		/**
146
+		 * Gets altitude information based on a particular callsign
147
+		 *
148
+		 * @return Array the spotter information
149
+		 *
150
+		 */
151
+		public function getAltitudeArchiveSpotterDataByIdent($ident)
152
+		{
153 153
 
154
-                date_default_timezone_set('UTC');
154
+				date_default_timezone_set('UTC');
155 155
 
156
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
157
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
156
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
157
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
158 158
 
159
-                try {
160
-                        $sth = $this->db->prepare($query);
161
-                        $sth->execute(array(':ident' => $ident));
162
-                } catch(PDOException $e) {
163
-                        return "error";
164
-                }
165
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
159
+				try {
160
+						$sth = $this->db->prepare($query);
161
+						$sth->execute(array(':ident' => $ident));
162
+				} catch(PDOException $e) {
163
+						return "error";
164
+				}
165
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
166 166
 
167
-                return $spotter_array;
168
-        }
167
+				return $spotter_array;
168
+		}
169 169
 
170
-        /**
171
-        * Gets altitude information based on a particular id
172
-        *
173
-        * @return Array the spotter information
174
-        *
175
-        */
176
-        public function getAltitudeArchiveSpotterDataById($id)
177
-        {
170
+		/**
171
+		 * Gets altitude information based on a particular id
172
+		 *
173
+		 * @return Array the spotter information
174
+		 *
175
+		 */
176
+		public function getAltitudeArchiveSpotterDataById($id)
177
+		{
178 178
 
179
-                date_default_timezone_set('UTC');
179
+				date_default_timezone_set('UTC');
180 180
 
181
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
182
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
181
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
182
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
183 183
 
184
-                try {
185
-                        $sth = $this->db->prepare($query);
186
-                        $sth->execute(array(':id' => $id));
187
-                } catch(PDOException $e) {
188
-                        return "error";
189
-                }
190
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
184
+				try {
185
+						$sth = $this->db->prepare($query);
186
+						$sth->execute(array(':id' => $id));
187
+				} catch(PDOException $e) {
188
+						return "error";
189
+				}
190
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
191 191
 
192
-                return $spotter_array;
193
-        }
192
+				return $spotter_array;
193
+		}
194 194
 
195
-        /**
196
-        * Gets altitude & speed information based on a particular id
197
-        *
198
-        * @return Array the spotter information
199
-        *
200
-        */
201
-        public function getAltitudeSpeedArchiveSpotterDataById($id)
202
-        {
195
+		/**
196
+		 * Gets altitude & speed information based on a particular id
197
+		 *
198
+		 * @return Array the spotter information
199
+		 *
200
+		 */
201
+		public function getAltitudeSpeedArchiveSpotterDataById($id)
202
+		{
203 203
 
204
-                date_default_timezone_set('UTC');
204
+				date_default_timezone_set('UTC');
205 205
 
206
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
207
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
206
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
207
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
208 208
 
209
-                try {
210
-                        $sth = $this->db->prepare($query);
211
-                        $sth->execute(array(':id' => $id));
212
-                } catch(PDOException $e) {
213
-		        return "error : ".$e->getMessage();
214
-                }
215
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
209
+				try {
210
+						$sth = $this->db->prepare($query);
211
+						$sth->execute(array(':id' => $id));
212
+				} catch(PDOException $e) {
213
+				return "error : ".$e->getMessage();
214
+				}
215
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
216 216
 
217
-                return $spotter_array;
218
-        }
217
+				return $spotter_array;
218
+		}
219 219
 
220 220
 
221
-        /**
222
-        * Gets altitude information based on a particular callsign
223
-        *
224
-        * @return Array the spotter information
225
-        *
226
-        */
227
-        public function getLastAltitudeArchiveSpotterDataByIdent($ident)
228
-        {
221
+		/**
222
+		 * Gets altitude information based on a particular callsign
223
+		 *
224
+		 * @return Array the spotter information
225
+		 *
226
+		 */
227
+		public function getLastAltitudeArchiveSpotterDataByIdent($ident)
228
+		{
229 229
 
230
-                date_default_timezone_set('UTC');
230
+				date_default_timezone_set('UTC');
231 231
 
232
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
233
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
232
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
233
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
234 234
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
235 235
 
236
-                try {
237
-                        $sth = $this->db->prepare($query);
238
-                        $sth->execute(array(':ident' => $ident));
239
-                } catch(PDOException $e) {
240
-                        return "error";
241
-                }
242
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
236
+				try {
237
+						$sth = $this->db->prepare($query);
238
+						$sth->execute(array(':ident' => $ident));
239
+				} catch(PDOException $e) {
240
+						return "error";
241
+				}
242
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
243 243
 
244
-                return $spotter_array;
245
-        }
244
+				return $spotter_array;
245
+		}
246 246
 
247 247
 
248 248
 
249
-       /**
250
-        * Gets all the archive spotter information
251
-        *
252
-        * @return Array the spotter information
253
-        *
254
-        */
255
-        public function getSpotterArchiveData($ident,$flightaware_id,$date)
256
-        {
257
-    		$Spotter = new Spotter($this->db);
258
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
259
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
249
+	   /**
250
+	    * Gets all the archive spotter information
251
+	    *
252
+	    * @return Array the spotter information
253
+	    *
254
+	    */
255
+		public function getSpotterArchiveData($ident,$flightaware_id,$date)
256
+		{
257
+			$Spotter = new Spotter($this->db);
258
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
259
+				$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
260 260
 
261
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
261
+				$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
262 262
 
263
-                return $spotter_array;
264
-        }
263
+				return $spotter_array;
264
+		}
265 265
         
266
-        public function deleteSpotterArchiveTrackData()
267
-        {
266
+		public function deleteSpotterArchiveTrackData()
267
+		{
268 268
 		global $globalArchiveKeepTrackMonths;
269
-                date_default_timezone_set('UTC');
269
+				date_default_timezone_set('UTC');
270 270
 		$query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)';
271
-                try {
272
-                        $sth = $this->db->prepare($query);
273
-                        $sth->execute();
274
-                } catch(PDOException $e) {
275
-                        return "error";
276
-                }
271
+				try {
272
+						$sth = $this->db->prepare($query);
273
+						$sth->execute();
274
+				} catch(PDOException $e) {
275
+						return "error";
276
+				}
277 277
 	}
278 278
 
279 279
 	/**
280
-        * Gets Minimal Live Spotter data
281
-        *
282
-        * @return Array the spotter information
283
-        *
284
-        */
285
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
286
-        {
287
-                global $globalDBdriver, $globalLiveInterval;
288
-                date_default_timezone_set('UTC');
289
-
290
-                $filter_query = '';
291
-                if (isset($filter['source']) && !empty($filter['source'])) {
292
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
293
-                }
294
-                // Use spotter_output also ?
295
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
296
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
297
-                }
298
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
299
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
300
-                }
301
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
302
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
303
-                }
304
-
305
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
306
-                if ($globalDBdriver == 'mysql') {
307
-                        /*
280
+	 * Gets Minimal Live Spotter data
281
+	 *
282
+	 * @return Array the spotter information
283
+	 *
284
+	 */
285
+		public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
286
+		{
287
+				global $globalDBdriver, $globalLiveInterval;
288
+				date_default_timezone_set('UTC');
289
+
290
+				$filter_query = '';
291
+				if (isset($filter['source']) && !empty($filter['source'])) {
292
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
293
+				}
294
+				// Use spotter_output also ?
295
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
296
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
297
+				}
298
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
299
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
300
+				}
301
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
302
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
303
+				}
304
+
305
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
306
+				if ($globalDBdriver == 'mysql') {
307
+						/*
308 308
                         $query  = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk 
309 309
                     		    FROM spotter_archive 
310 310
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
@@ -316,50 +316,50 @@  discard block
 block discarded – undo
316 316
 						WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".') 
317 317
 						GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id 
318 318
 				    AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
319
-                } else if ($globalDBdriver == 'pgsql') {
320
-                        $query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
321
-                }
322
-                //echo $query;
323
-                try {
324
-                        $sth = $this->db->prepare($query);
325
-                        $sth->execute();
326
-                } catch(PDOException $e) {
327
-                        return "error";
328
-                }
329
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
330
-
331
-                return $spotter_array;
332
-        }
319
+				} else if ($globalDBdriver == 'pgsql') {
320
+						$query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
321
+				}
322
+				//echo $query;
323
+				try {
324
+						$sth = $this->db->prepare($query);
325
+						$sth->execute();
326
+				} catch(PDOException $e) {
327
+						return "error";
328
+				}
329
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
330
+
331
+				return $spotter_array;
332
+		}
333 333
 
334 334
 	/**
335
-        * Gets Minimal Live Spotter data
336
-        *
337
-        * @return Array the spotter information
338
-        *
339
-        */
340
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
341
-        {
342
-                global $globalDBdriver, $globalLiveInterval;
343
-                date_default_timezone_set('UTC');
344
-
345
-                $filter_query = '';
346
-                if (isset($filter['source']) && !empty($filter['source'])) {
347
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
348
-                }
349
-                // FIXME : use spotter_output also
350
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
351
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
352
-                }
353
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
354
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
355
-                }
356
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
357
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
358
-                }
359
-
360
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
361
-                if ($globalDBdriver == 'mysql') {
362
-                        /*
335
+	 * Gets Minimal Live Spotter data
336
+	 *
337
+	 * @return Array the spotter information
338
+	 *
339
+	 */
340
+		public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
341
+		{
342
+				global $globalDBdriver, $globalLiveInterval;
343
+				date_default_timezone_set('UTC');
344
+
345
+				$filter_query = '';
346
+				if (isset($filter['source']) && !empty($filter['source'])) {
347
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
348
+				}
349
+				// FIXME : use spotter_output also
350
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
351
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
352
+				}
353
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
354
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
355
+				}
356
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
357
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
358
+				}
359
+
360
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
361
+				if ($globalDBdriver == 'mysql') {
362
+						/*
363 363
                         $query  = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk 
364 364
                     		    FROM spotter_archive 
365 365
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
@@ -370,91 +370,91 @@  discard block
 block discarded – undo
370 370
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
371 371
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
372 372
 
373
-                } else if ($globalDBdriver == 'pgsql') {
374
-                        //$query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao';
375
-                        $query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
373
+				} else if ($globalDBdriver == 'pgsql') {
374
+						//$query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao';
375
+						$query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
376 376
                         	    FROM spotter_archive_output 
377 377
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
378 378
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
379 379
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
380
-                        $query  = 'SELECT DISTINCT spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao as departure_airport, spotter_output.arrival_airport_icao as arrival_airport, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow
380
+						$query  = 'SELECT DISTINCT spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao as departure_airport, spotter_output.arrival_airport_icao as arrival_airport, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow
381 381
                         	    FROM spotter_output 
382 382
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_output.aircraft_icao = a.icao
383 383
                         	    WHERE spotter_output.date >= '."'".$begindate."'".' AND spotter_output.date <= '."'".$enddate."'".'
384 384
                         	    '.$filter_query.' LIMIT 200 OFFSET 0';
385 385
 //                        	    .' GROUP BY spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow';
386 386
                         	    
387
-                }
388
-                //echo $query;
389
-                try {
390
-                        $sth = $this->db->prepare($query);
391
-                        $sth->execute();
392
-                } catch(PDOException $e) {
393
-                        return $e->getMessage();
394
-                }
395
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
396
-
397
-                return $spotter_array;
398
-        }
387
+				}
388
+				//echo $query;
389
+				try {
390
+						$sth = $this->db->prepare($query);
391
+						$sth->execute();
392
+				} catch(PDOException $e) {
393
+						return $e->getMessage();
394
+				}
395
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
396
+
397
+				return $spotter_array;
398
+		}
399 399
 
400 400
 	 /**
401
-        * Gets count Live Spotter data
402
-        *
403
-        * @return Array the spotter information
404
-        *
405
-        */
406
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
407
-        {
408
-                global $globalDBdriver, $globalLiveInterval;
409
-                date_default_timezone_set('UTC');
410
-
411
-                $filter_query = '';
412
-                if (isset($filter['source']) && !empty($filter['source'])) {
413
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
414
-                }
415
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
416
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
417
-                }
418
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
419
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
420
-                }
421
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
422
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
423
-                }
424
-
425
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
426
-                if ($globalDBdriver == 'mysql') {
401
+	  * Gets count Live Spotter data
402
+	  *
403
+	  * @return Array the spotter information
404
+	  *
405
+	  */
406
+		public function getLiveSpotterCount($begindate,$enddate,$filter = array())
407
+		{
408
+				global $globalDBdriver, $globalLiveInterval;
409
+				date_default_timezone_set('UTC');
410
+
411
+				$filter_query = '';
412
+				if (isset($filter['source']) && !empty($filter['source'])) {
413
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
414
+				}
415
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
416
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
417
+				}
418
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
419
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
420
+				}
421
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
422
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
423
+				}
424
+
425
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
426
+				if ($globalDBdriver == 'mysql') {
427 427
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb 
428 428
 			FROM spotter_archive l 
429 429
 			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query;
430 430
 
431
-                } else if ($globalDBdriver == 'pgsql') {
431
+				} else if ($globalDBdriver == 'pgsql') {
432 432
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
433
-                }
434
-                //echo $query;
435
-                try {
436
-                        $sth = $this->db->prepare($query);
437
-                        $sth->execute();
438
-                } catch(PDOException $e) {
439
-                        return "error";
440
-                }
433
+				}
434
+				//echo $query;
435
+				try {
436
+						$sth = $this->db->prepare($query);
437
+						$sth->execute();
438
+				} catch(PDOException $e) {
439
+						return "error";
440
+				}
441 441
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
442
-                return $result['nb'];
442
+				return $result['nb'];
443 443
 
444
-        }
444
+		}
445 445
 
446 446
 
447 447
 
448 448
 	// Spotter_Archive_output
449 449
 	
450
-    /**
451
-    * Gets all the spotter information
452
-    *
453
-    * @return Array the spotter information
454
-    *
455
-    */
456
-    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '')
457
-    {
450
+	/**
451
+	 * Gets all the spotter information
452
+	 *
453
+	 * @return Array the spotter information
454
+	 *
455
+	 */
456
+	public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '')
457
+	{
458 458
 	global $globalTimezone, $globalDbdriver;
459 459
 	require_once(dirname(__FILE__).'/class.Translation.php');
460 460
 	$Translation = new Translation();
@@ -465,159 +465,159 @@  discard block
 block discarded – undo
465 465
 	$additional_query = '';
466 466
 	if ($q != "")
467 467
 	{
468
-	    if (!is_string($q))
469
-	    {
468
+		if (!is_string($q))
469
+		{
470 470
 		return false;
471
-	    } else {
471
+		} else {
472 472
 	        
473 473
 		$q_array = explode(" ", $q);
474 474
 		
475 475
 		foreach ($q_array as $q_item){
476
-		    $additional_query .= " AND (";
477
-		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
478
-		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
479
-		    $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR ";
480
-		    $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
481
-		    $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR ";
482
-		    $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR ";
483
-		    $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR ";
484
-		    $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
485
-		    $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR ";
486
-		    $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR ";
487
-		    $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR ";
488
-		    $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
489
-		    $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
490
-		    $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
491
-		    $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
492
-		    $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR ";
493
-		    $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR ";
494
-		    $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR ";
495
-		    $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
496
-		    $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
497
-		    $translate = $Translation->ident2icao($q_item);
498
-		    if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
499
-		    $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
500
-		    $additional_query .= ")";
501
-		}
502
-	    }
476
+			$additional_query .= " AND (";
477
+			$additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
478
+			$additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
479
+			$additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR ";
480
+			$additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
481
+			$additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR ";
482
+			$additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR ";
483
+			$additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR ";
484
+			$additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
485
+			$additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR ";
486
+			$additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR ";
487
+			$additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR ";
488
+			$additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
489
+			$additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
490
+			$additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
491
+			$additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
492
+			$additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR ";
493
+			$additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR ";
494
+			$additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR ";
495
+			$additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
496
+			$additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
497
+			$translate = $Translation->ident2icao($q_item);
498
+			if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
499
+			$additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
500
+			$additional_query .= ")";
501
+		}
502
+		}
503 503
 	}
504 504
 	
505 505
 	if ($registration != "")
506 506
 	{
507
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
508
-	    if (!is_string($registration))
509
-	    {
507
+		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
508
+		if (!is_string($registration))
509
+		{
510 510
 		return false;
511
-	    } else {
511
+		} else {
512 512
 		$additional_query .= " AND (spotter_archive_output.registration = '".$registration."')";
513
-	    }
513
+		}
514 514
 	}
515 515
 	
516 516
 	if ($aircraft_icao != "")
517 517
 	{
518
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
519
-	    if (!is_string($aircraft_icao))
520
-	    {
518
+		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
519
+		if (!is_string($aircraft_icao))
520
+		{
521 521
 		return false;
522
-	    } else {
522
+		} else {
523 523
 		$additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')";
524
-	    }
524
+		}
525 525
 	}
526 526
 	
527 527
 	if ($aircraft_manufacturer != "")
528 528
 	{
529
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
530
-	    if (!is_string($aircraft_manufacturer))
531
-	    {
529
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
530
+		if (!is_string($aircraft_manufacturer))
531
+		{
532 532
 		return false;
533
-	    } else {
533
+		} else {
534 534
 		$additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
535
-	    }
535
+		}
536 536
 	}
537 537
 	
538 538
 	if ($highlights == "true")
539 539
 	{
540
-	    if (!is_string($highlights))
541
-	    {
540
+		if (!is_string($highlights))
541
+		{
542 542
 		return false;
543
-	    } else {
543
+		} else {
544 544
 		$additional_query .= " AND (spotter_archive_output.highlight <> '')";
545
-	    }
545
+		}
546 546
 	}
547 547
 	
548 548
 	if ($airline_icao != "")
549 549
 	{
550
-	    $registration = filter_var($airline_icao,FILTER_SANITIZE_STRING);
551
-	    if (!is_string($airline_icao))
552
-	    {
550
+		$registration = filter_var($airline_icao,FILTER_SANITIZE_STRING);
551
+		if (!is_string($airline_icao))
552
+		{
553 553
 		return false;
554
-	    } else {
554
+		} else {
555 555
 		$additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')";
556
-	    }
556
+		}
557 557
 	}
558 558
 	
559 559
 	if ($airline_country != "")
560 560
 	{
561
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
562
-	    if (!is_string($airline_country))
563
-	    {
561
+		$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
562
+		if (!is_string($airline_country))
563
+		{
564 564
 		return false;
565
-	    } else {
565
+		} else {
566 566
 		$additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')";
567
-	    }
567
+		}
568 568
 	}
569 569
 	
570 570
 	if ($airline_type != "")
571 571
 	{
572
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
573
-	    if (!is_string($airline_type))
574
-	    {
572
+		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
573
+		if (!is_string($airline_type))
574
+		{
575 575
 		return false;
576
-	    } else {
576
+		} else {
577 577
 		if ($airline_type == "passenger")
578 578
 		{
579
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')";
579
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')";
580 580
 		}
581 581
 		if ($airline_type == "cargo")
582 582
 		{
583
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')";
583
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')";
584 584
 		}
585 585
 		if ($airline_type == "military")
586 586
 		{
587
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'military')";
587
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'military')";
588
+		}
588 589
 		}
589
-	    }
590 590
 	}
591 591
 	
592 592
 	if ($airport != "")
593 593
 	{
594
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
595
-	    if (!is_string($airport))
596
-	    {
594
+		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
595
+		if (!is_string($airport))
596
+		{
597 597
 		return false;
598
-	    } else {
598
+		} else {
599 599
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))";
600
-	    }
600
+		}
601 601
 	}
602 602
 	
603 603
 	if ($airport_country != "")
604 604
 	{
605
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
606
-	    if (!is_string($airport_country))
607
-	    {
605
+		$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
606
+		if (!is_string($airport_country))
607
+		{
608 608
 		return false;
609
-	    } else {
609
+		} else {
610 610
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))";
611
-	    }
611
+		}
612 612
 	}
613 613
     
614 614
 	if ($callsign != "")
615 615
 	{
616
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
617
-	    if (!is_string($callsign))
618
-	    {
616
+		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
617
+		if (!is_string($callsign))
618
+		{
619 619
 		return false;
620
-	    } else {
620
+		} else {
621 621
 		$translate = $Translation->ident2icao($callsign);
622 622
 		if ($translate != $callsign) {
623 623
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
@@ -625,99 +625,99 @@  discard block
 block discarded – undo
625 625
 		} else {
626 626
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
627 627
 		}
628
-	    }
628
+		}
629 629
 	}
630 630
 
631 631
 	if ($owner != "")
632 632
 	{
633
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
634
-	    if (!is_string($owner))
635
-	    {
633
+		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
634
+		if (!is_string($owner))
635
+		{
636 636
 		return false;
637
-	    } else {
637
+		} else {
638 638
 		$additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')";
639
-	    }
639
+		}
640 640
 	}
641 641
 
642 642
 	if ($pilot_name != "")
643 643
 	{
644
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
645
-	    if (!is_string($pilot_name))
646
-	    {
644
+		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
645
+		if (!is_string($pilot_name))
646
+		{
647 647
 		return false;
648
-	    } else {
648
+		} else {
649 649
 		$additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')";
650
-	    }
650
+		}
651 651
 	}
652 652
 	
653 653
 	if ($pilot_id != "")
654 654
 	{
655
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
656
-	    if (!is_string($pilot_id))
657
-	    {
655
+		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
656
+		if (!is_string($pilot_id))
657
+		{
658 658
 		return false;
659
-	    } else {
659
+		} else {
660 660
 		$additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')";
661
-	    }
661
+		}
662 662
 	}
663 663
 	
664 664
 	if ($departure_airport_route != "")
665 665
 	{
666
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
667
-	    if (!is_string($departure_airport_route))
668
-	    {
666
+		$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
667
+		if (!is_string($departure_airport_route))
668
+		{
669 669
 		return false;
670
-	    } else {
670
+		} else {
671 671
 		$additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')";
672
-	    }
672
+		}
673 673
 	}
674 674
 	
675 675
 	if ($arrival_airport_route != "")
676 676
 	{
677
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
678
-	    if (!is_string($arrival_airport_route))
679
-	    {
677
+		$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
678
+		if (!is_string($arrival_airport_route))
679
+		{
680 680
 		return false;
681
-	    } else {
681
+		} else {
682 682
 		$additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
683
-	    }
683
+		}
684 684
 	}
685 685
 	
686 686
 	if ($altitude != "")
687 687
 	{
688
-	    $altitude_array = explode(",", $altitude);
688
+		$altitude_array = explode(",", $altitude);
689 689
 	    
690
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
691
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
690
+		$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
691
+		$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
692 692
 	    
693 693
 
694
-	    if ($altitude_array[1] != "")
695
-	    {                
694
+		if ($altitude_array[1] != "")
695
+		{                
696 696
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
697 697
 		$altitude_array[1] = substr($altitude_array[1], 0, -2);
698 698
 		$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
699
-	    } else {
699
+		} else {
700 700
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
701 701
 		$additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
702
-	    }
702
+		}
703 703
 	}
704 704
 	
705 705
 	if ($date_posted != "")
706 706
 	{
707
-	    $date_array = explode(",", $date_posted);
707
+		$date_array = explode(",", $date_posted);
708 708
 	    
709
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
710
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
709
+		$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
710
+		$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
711 711
 	    
712
-	    if ($globalTimezone != '') {
712
+		if ($globalTimezone != '') {
713 713
 		date_default_timezone_set($globalTimezone);
714 714
 		$datetime = new DateTime();
715 715
 		$offset = $datetime->format('P');
716
-	    } else $offset = '+00:00';
716
+		} else $offset = '+00:00';
717 717
 
718 718
 
719
-	    if ($date_array[1] != "")
720
-	    {                
719
+		if ($date_array[1] != "")
720
+		{                
721 721
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
722 722
 		$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
723 723
 		if ($globalDBdriver == 'mysql') {
@@ -725,28 +725,28 @@  discard block
 block discarded – undo
725 725
 		} else {
726 726
 			$additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) ";
727 727
 		}
728
-	    } else {
728
+		} else {
729 729
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
730
-                if ($globalDBdriver == 'mysql') {
730
+				if ($globalDBdriver == 'mysql') {
731 731
 			$additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
732 732
 		} else {
733 733
 			$additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
734 734
 		}
735
-	    }
735
+		}
736 736
 	}
737 737
 	
738 738
 	if ($limit != "")
739 739
 	{
740
-	    $limit_array = explode(",", $limit);
740
+		$limit_array = explode(",", $limit);
741 741
 	    
742
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
743
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
742
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
743
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
744 744
 	    
745
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
746
-	    {
745
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
746
+		{
747 747
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
748 748
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
749
-	    }
749
+		}
750 750
 	}
751 751
 	
752 752
 
@@ -778,33 +778,33 @@  discard block
 block discarded – undo
778 778
 	$spotter_array = $Spotter->getDataFromDB($query, array(),$limit_query);
779 779
 
780 780
 	return $spotter_array;
781
-    }
781
+	}
782 782
 
783
-    public function deleteSpotterArchiveData()
784
-    {
783
+	public function deleteSpotterArchiveData()
784
+	{
785 785
 		global $globalArchiveKeepMonths, $globalDBdriver;
786
-                date_default_timezone_set('UTC');
787
-                if ($globalDBdriver == 'mysql') {
786
+				date_default_timezone_set('UTC');
787
+				if ($globalDBdriver == 'mysql') {
788 788
 			$query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
789 789
 		} else {
790 790
 			$query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
791 791
 		}
792
-                try {
793
-                        $sth = $this->db->prepare($query);
794
-                        $sth->execute();
795
-                } catch(PDOException $e) {
796
-                        return "error";
797
-                }
792
+				try {
793
+						$sth = $this->db->prepare($query);
794
+						$sth->execute();
795
+				} catch(PDOException $e) {
796
+						return "error";
797
+				}
798 798
 	}
799 799
 
800
-    /**
801
-    * Gets all the spotter information based on the callsign
802
-    *
803
-    * @return Array the spotter information
804
-    *
805
-    */
806
-    public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
807
-    {
800
+	/**
801
+	 * Gets all the spotter information based on the callsign
802
+	 *
803
+	 * @return Array the spotter information
804
+	 *
805
+	 */
806
+	public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
807
+	{
808 808
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
809 809
 	
810 810
 	date_default_timezone_set('UTC');
@@ -813,35 +813,35 @@  discard block
 block discarded – undo
813 813
 	
814 814
 	if ($ident != "")
815 815
 	{
816
-	    if (!is_string($ident))
817
-	    {
816
+		if (!is_string($ident))
817
+		{
818 818
 		return false;
819
-	    } else {
819
+		} else {
820 820
 		$additional_query = " AND (spotter_archive_output.ident = :ident)";
821 821
 		$query_values = array(':ident' => $ident);
822
-	    }
822
+		}
823 823
 	}
824 824
 	
825 825
 	if ($limit != "")
826 826
 	{
827
-	    $limit_array = explode(",", $limit);
827
+		$limit_array = explode(",", $limit);
828 828
 	    
829
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
830
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
829
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
830
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
831 831
 	    
832
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
833
-	    {
832
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
833
+		{
834 834
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
835 835
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
836
-	    }
836
+		}
837 837
 	}
838 838
 
839 839
 	if ($sort != "")
840 840
 	{
841
-	    $search_orderby_array = $this->getOrderBy();
842
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
841
+		$search_orderby_array = $this->getOrderBy();
842
+		$orderby_query = $search_orderby_array[$sort]['sql'];
843 843
 	} else {
844
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
844
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
845 845
 	}
846 846
 
847 847
 	$query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
@@ -850,16 +850,16 @@  discard block
 block discarded – undo
850 850
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
851 851
 
852 852
 	return $spotter_array;
853
-    }
854
-
855
-    /**
856
-    * Gets all number of flight over countries
857
-    *
858
-    * @return Array the airline country list
859
-    *
860
-    */
861
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
862
-    {
853
+	}
854
+
855
+	/**
856
+	 * Gets all number of flight over countries
857
+	 *
858
+	 * @return Array the airline country list
859
+	 *
860
+	 */
861
+	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
862
+	{
863 863
 	global $globalDBdriver;
864 864
 	/*
865 865
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -869,14 +869,14 @@  discard block
 block discarded – undo
869 869
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
870 870
 		    FROM countries c, spotter_archive s
871 871
 		    WHERE c.iso2 = s.over_country ";
872
-                if ($olderthanmonths > 0) {
873
-            		if ($globalDBdriver == 'mysql') {
872
+				if ($olderthanmonths > 0) {
873
+					if ($globalDBdriver == 'mysql') {
874 874
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
875 875
 			} else {
876 876
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
877 877
 			}
878 878
 		}
879
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
879
+				if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
880 880
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
881 881
 	if ($limit) $query .= " LIMIT 0,10";
882 882
       
@@ -889,14 +889,14 @@  discard block
 block discarded – undo
889 889
         
890 890
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
891 891
 	{
892
-	    $temp_array['flight_count'] = $row['nb'];
893
-	    $temp_array['flight_country'] = $row['name'];
894
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
895
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
896
-	    $flight_array[] = $temp_array;
892
+		$temp_array['flight_count'] = $row['nb'];
893
+		$temp_array['flight_country'] = $row['name'];
894
+		$temp_array['flight_country_iso3'] = $row['iso3'];
895
+		$temp_array['flight_country_iso2'] = $row['iso2'];
896
+		$flight_array[] = $temp_array;
897 897
 	}
898 898
 	return $flight_array;
899
-    }
899
+	}
900 900
 
901 901
 }
902 902
 ?>
903 903
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -11,28 +11,28 @@  discard block
 block discarded – undo
11 11
 
12 12
     // Spotter_archive
13 13
     
14
-    function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') {
14
+    function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '', $arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city = '', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') {
15 15
 	require_once(dirname(__FILE__).'/class.Spotter.php');
16 16
         if ($over_country == '') {
17 17
 	        $Spotter = new Spotter($this->db);
18
-	        $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
18
+	        $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude);
19 19
 		if (!empty($data_country)) $country = $data_country['iso2'];
20 20
 		else $country = '';
21 21
 	} else $country = $over_country;
22
-	if ($airline_type === NULL) $airline_type ='';
22
+	if ($airline_type === NULL) $airline_type = '';
23 23
 	
24 24
 	//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n";
25 25
 	//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n";
26 26
 
27 27
 	// Route is not added in spotter_archive
28
-	$query  = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name)
28
+	$query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name)
29 29
                 VALUES (:flightaware_id, :ident, :registration, :airline_name, :airline_icao, :airline_country, :airline_type, :aircraft_icao, :aircraft_shadow, :aircraft_name, :aircraft_manufacturer, :departure_airport_icao, :departure_airport_name, :departure_airport_city, :departure_airport_country, :departure_airport_time,:arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :arrival_airport_time, :route_stop, :date,:latitude, :longitude, :waypoints, :altitude, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name)";
30 30
 
31
-        $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name);
31
+        $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name);
32 32
         try {
33 33
             $sth = $this->db->prepare($query);
34 34
             $sth->execute($query_values);
35
-        } catch(PDOException $e) {
35
+        } catch (PDOException $e) {
36 36
             return "error : ".$e->getMessage();
37 37
         }
38 38
         return "success";
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 
53 53
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
54 54
                 //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
55
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
55
+                $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
56 56
 
57
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
57
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident));
58 58
 
59 59
                 return $spotter_array;
60 60
         }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
74 74
                 //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
75 75
                 //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
76
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
76
+                $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
77 77
 
78 78
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
79 79
                   /*
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
                 }
87 87
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
88 88
                 */
89
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
89
+                $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id));
90 90
 
91 91
                 return $spotter_array;
92 92
         }
@@ -101,14 +101,14 @@  discard block
 block discarded – undo
101 101
         {
102 102
                 date_default_timezone_set('UTC');
103 103
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
104
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
104
+                $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
105 105
 
106 106
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
107 107
 
108 108
                 try {
109 109
                         $sth = $this->db->prepare($query);
110 110
                         $sth->execute(array(':id' => $id));
111
-                } catch(PDOException $e) {
111
+                } catch (PDOException $e) {
112 112
                         return "error";
113 113
                 }
114 114
                 $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -126,14 +126,14 @@  discard block
 block discarded – undo
126 126
         {
127 127
                 date_default_timezone_set('UTC');
128 128
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
129
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
129
+                $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
130 130
 
131 131
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
132 132
 
133 133
                 try {
134 134
                         $sth = $this->db->prepare($query);
135 135
                         $sth->execute(array(':id' => $id));
136
-                } catch(PDOException $e) {
136
+                } catch (PDOException $e) {
137 137
                         return $e->getMessage();
138 138
                 }
139 139
                 $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -154,12 +154,12 @@  discard block
 block discarded – undo
154 154
                 date_default_timezone_set('UTC');
155 155
 
156 156
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
157
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
157
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
158 158
 
159 159
                 try {
160 160
                         $sth = $this->db->prepare($query);
161 161
                         $sth->execute(array(':ident' => $ident));
162
-                } catch(PDOException $e) {
162
+                } catch (PDOException $e) {
163 163
                         return "error";
164 164
                 }
165 165
                 $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -179,12 +179,12 @@  discard block
 block discarded – undo
179 179
                 date_default_timezone_set('UTC');
180 180
 
181 181
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
182
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
182
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
183 183
 
184 184
                 try {
185 185
                         $sth = $this->db->prepare($query);
186 186
                         $sth->execute(array(':id' => $id));
187
-                } catch(PDOException $e) {
187
+                } catch (PDOException $e) {
188 188
                         return "error";
189 189
                 }
190 190
                 $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -204,12 +204,12 @@  discard block
 block discarded – undo
204 204
                 date_default_timezone_set('UTC');
205 205
 
206 206
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
207
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
207
+                $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
208 208
 
209 209
                 try {
210 210
                         $sth = $this->db->prepare($query);
211 211
                         $sth->execute(array(':id' => $id));
212
-                } catch(PDOException $e) {
212
+                } catch (PDOException $e) {
213 213
 		        return "error : ".$e->getMessage();
214 214
                 }
215 215
                 $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -230,13 +230,13 @@  discard block
 block discarded – undo
230 230
                 date_default_timezone_set('UTC');
231 231
 
232 232
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
233
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
233
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
234 234
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
235 235
 
236 236
                 try {
237 237
                         $sth = $this->db->prepare($query);
238 238
                         $sth->execute(array(':ident' => $ident));
239
-                } catch(PDOException $e) {
239
+                } catch (PDOException $e) {
240 240
                         return "error";
241 241
                 }
242 242
                 $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -252,13 +252,13 @@  discard block
 block discarded – undo
252 252
         * @return Array the spotter information
253 253
         *
254 254
         */
255
-        public function getSpotterArchiveData($ident,$flightaware_id,$date)
255
+        public function getSpotterArchiveData($ident, $flightaware_id, $date)
256 256
         {
257 257
     		$Spotter = new Spotter($this->db);
258 258
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
259
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
259
+                $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
260 260
 
261
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
261
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%'));
262 262
 
263 263
                 return $spotter_array;
264 264
         }
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
                 try {
272 272
                         $sth = $this->db->prepare($query);
273 273
                         $sth->execute();
274
-                } catch(PDOException $e) {
274
+                } catch (PDOException $e) {
275 275
                         return "error";
276 276
                 }
277 277
 	}
@@ -282,24 +282,24 @@  discard block
 block discarded – undo
282 282
         * @return Array the spotter information
283 283
         *
284 284
         */
285
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
285
+        public function getMinLiveSpotterData($begindate, $enddate, $filter = array())
286 286
         {
287 287
                 global $globalDBdriver, $globalLiveInterval;
288 288
                 date_default_timezone_set('UTC');
289 289
 
290 290
                 $filter_query = '';
291 291
                 if (isset($filter['source']) && !empty($filter['source'])) {
292
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
292
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
293 293
                 }
294 294
                 // Use spotter_output also ?
295 295
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
296
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
296
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
297 297
                 }
298 298
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
299 299
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
300 300
                 }
301 301
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
302
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
302
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
303 303
                 }
304 304
 
305 305
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
                     		    FROM spotter_archive 
310 310
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
311 311
 			*/
312
-			$query  = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk 
312
+			$query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk 
313 313
 				    FROM spotter_archive 
314 314
 				    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
315 315
 						FROM spotter_archive l 
@@ -317,13 +317,13 @@  discard block
 block discarded – undo
317 317
 						GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id 
318 318
 				    AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
319 319
                 } else if ($globalDBdriver == 'pgsql') {
320
-                        $query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
320
+                        $query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
321 321
                 }
322 322
                 //echo $query;
323 323
                 try {
324 324
                         $sth = $this->db->prepare($query);
325 325
                         $sth->execute();
326
-                } catch(PDOException $e) {
326
+                } catch (PDOException $e) {
327 327
                         return "error";
328 328
                 }
329 329
                 $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -337,24 +337,24 @@  discard block
 block discarded – undo
337 337
         * @return Array the spotter information
338 338
         *
339 339
         */
340
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
340
+        public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array())
341 341
         {
342 342
                 global $globalDBdriver, $globalLiveInterval;
343 343
                 date_default_timezone_set('UTC');
344 344
 
345 345
                 $filter_query = '';
346 346
                 if (isset($filter['source']) && !empty($filter['source'])) {
347
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
347
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
348 348
                 }
349 349
                 // FIXME : use spotter_output also
350 350
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
351
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
351
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
352 352
                 }
353 353
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
354 354
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
355 355
                 }
356 356
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
357
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
357
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
358 358
                 }
359 359
 
360 360
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
                     		    FROM spotter_archive 
365 365
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
366 366
 			*/
367
-			$query  = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk 
367
+			$query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk 
368 368
 				    FROM spotter_archive_output 
369 369
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao 
370 370
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
@@ -372,12 +372,12 @@  discard block
 block discarded – undo
372 372
 
373 373
                 } else if ($globalDBdriver == 'pgsql') {
374 374
                         //$query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao';
375
-                        $query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
375
+                        $query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
376 376
                         	    FROM spotter_archive_output 
377 377
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
378 378
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
379 379
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
380
-                        $query  = 'SELECT DISTINCT spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao as departure_airport, spotter_output.arrival_airport_icao as arrival_airport, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow
380
+                        $query = 'SELECT DISTINCT spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao as departure_airport, spotter_output.arrival_airport_icao as arrival_airport, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow
381 381
                         	    FROM spotter_output 
382 382
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_output.aircraft_icao = a.icao
383 383
                         	    WHERE spotter_output.date >= '."'".$begindate."'".' AND spotter_output.date <= '."'".$enddate."'".'
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
                 try {
390 390
                         $sth = $this->db->prepare($query);
391 391
                         $sth->execute();
392
-                } catch(PDOException $e) {
392
+                } catch (PDOException $e) {
393 393
                         return $e->getMessage();
394 394
                 }
395 395
                 $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -403,23 +403,23 @@  discard block
 block discarded – undo
403 403
         * @return Array the spotter information
404 404
         *
405 405
         */
406
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
406
+        public function getLiveSpotterCount($begindate, $enddate, $filter = array())
407 407
         {
408 408
                 global $globalDBdriver, $globalLiveInterval;
409 409
                 date_default_timezone_set('UTC');
410 410
 
411 411
                 $filter_query = '';
412 412
                 if (isset($filter['source']) && !empty($filter['source'])) {
413
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
413
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
414 414
                 }
415 415
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
416
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
416
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
417 417
                 }
418 418
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
419 419
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
420 420
                 }
421 421
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
422
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
422
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
423 423
                 }
424 424
 
425 425
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
                 try {
436 436
                         $sth = $this->db->prepare($query);
437 437
                         $sth->execute();
438
-                } catch(PDOException $e) {
438
+                } catch (PDOException $e) {
439 439
                         return "error";
440 440
                 }
441 441
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
     * @return Array the spotter information
454 454
     *
455 455
     */
456
-    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '')
456
+    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '')
457 457
     {
458 458
 	global $globalTimezone, $globalDbdriver;
459 459
 	require_once(dirname(__FILE__).'/class.Translation.php');
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 	        
473 473
 		$q_array = explode(" ", $q);
474 474
 		
475
-		foreach ($q_array as $q_item){
475
+		foreach ($q_array as $q_item) {
476 476
 		    $additional_query .= " AND (";
477 477
 		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
478 478
 		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 	
505 505
 	if ($registration != "")
506 506
 	{
507
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
507
+	    $registration = filter_var($registration, FILTER_SANITIZE_STRING);
508 508
 	    if (!is_string($registration))
509 509
 	    {
510 510
 		return false;
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
 	
516 516
 	if ($aircraft_icao != "")
517 517
 	{
518
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
518
+	    $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
519 519
 	    if (!is_string($aircraft_icao))
520 520
 	    {
521 521
 		return false;
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 	
527 527
 	if ($aircraft_manufacturer != "")
528 528
 	{
529
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
529
+	    $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
530 530
 	    if (!is_string($aircraft_manufacturer))
531 531
 	    {
532 532
 		return false;
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 	
548 548
 	if ($airline_icao != "")
549 549
 	{
550
-	    $registration = filter_var($airline_icao,FILTER_SANITIZE_STRING);
550
+	    $registration = filter_var($airline_icao, FILTER_SANITIZE_STRING);
551 551
 	    if (!is_string($airline_icao))
552 552
 	    {
553 553
 		return false;
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 	
559 559
 	if ($airline_country != "")
560 560
 	{
561
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
561
+	    $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
562 562
 	    if (!is_string($airline_country))
563 563
 	    {
564 564
 		return false;
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
 	
570 570
 	if ($airline_type != "")
571 571
 	{
572
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
572
+	    $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
573 573
 	    if (!is_string($airline_type))
574 574
 	    {
575 575
 		return false;
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
 	
592 592
 	if ($airport != "")
593 593
 	{
594
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
594
+	    $airport = filter_var($airport, FILTER_SANITIZE_STRING);
595 595
 	    if (!is_string($airport))
596 596
 	    {
597 597
 		return false;
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 	
603 603
 	if ($airport_country != "")
604 604
 	{
605
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
605
+	    $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
606 606
 	    if (!is_string($airport_country))
607 607
 	    {
608 608
 		return false;
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
     
614 614
 	if ($callsign != "")
615 615
 	{
616
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
616
+	    $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
617 617
 	    if (!is_string($callsign))
618 618
 	    {
619 619
 		return false;
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
 		$translate = $Translation->ident2icao($callsign);
622 622
 		if ($translate != $callsign) {
623 623
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
624
-			$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
624
+			$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
625 625
 		} else {
626 626
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
627 627
 		}
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 
631 631
 	if ($owner != "")
632 632
 	{
633
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
633
+	    $owner = filter_var($owner, FILTER_SANITIZE_STRING);
634 634
 	    if (!is_string($owner))
635 635
 	    {
636 636
 		return false;
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
 
642 642
 	if ($pilot_name != "")
643 643
 	{
644
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
644
+	    $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
645 645
 	    if (!is_string($pilot_name))
646 646
 	    {
647 647
 		return false;
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
 	
653 653
 	if ($pilot_id != "")
654 654
 	{
655
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
655
+	    $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
656 656
 	    if (!is_string($pilot_id))
657 657
 	    {
658 658
 		return false;
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
 	
664 664
 	if ($departure_airport_route != "")
665 665
 	{
666
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
666
+	    $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
667 667
 	    if (!is_string($departure_airport_route))
668 668
 	    {
669 669
 		return false;
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
 	
675 675
 	if ($arrival_airport_route != "")
676 676
 	{
677
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
677
+	    $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
678 678
 	    if (!is_string($arrival_airport_route))
679 679
 	    {
680 680
 		return false;
@@ -687,8 +687,8 @@  discard block
 block discarded – undo
687 687
 	{
688 688
 	    $altitude_array = explode(",", $altitude);
689 689
 	    
690
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
691
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
690
+	    $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
691
+	    $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
692 692
 	    
693 693
 
694 694
 	    if ($altitude_array[1] != "")
@@ -706,8 +706,8 @@  discard block
 block discarded – undo
706 706
 	{
707 707
 	    $date_array = explode(",", $date_posted);
708 708
 	    
709
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
710
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
709
+	    $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
710
+	    $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
711 711
 	    
712 712
 	    if ($globalTimezone != '') {
713 713
 		date_default_timezone_set($globalTimezone);
@@ -739,8 +739,8 @@  discard block
 block discarded – undo
739 739
 	{
740 740
 	    $limit_array = explode(",", $limit);
741 741
 	    
742
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
743
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
742
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
743
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
744 744
 	    
745 745
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
746 746
 	    {
@@ -751,8 +751,8 @@  discard block
 block discarded – undo
751 751
 	
752 752
 
753 753
 	if ($origLat != "" && $origLon != "" && $dist != "") {
754
-		$dist = number_format($dist*0.621371,2,'.','');
755
-		$query="SELECT spotter_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
754
+		$dist = number_format($dist*0.621371, 2, '.', '');
755
+		$query = "SELECT spotter_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
756 756
                           FROM spotter_output_archive, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
757 757
                           AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist ORDER BY distance";
758 758
 	} else {
@@ -769,13 +769,13 @@  discard block
 block discarded – undo
769 769
 			$additional_query .= " AND (spotter_archive_output.waypoints <> '')";
770 770
 		}
771 771
 
772
-		$query  = "SELECT spotter_archive_output.* FROM spotter_archive_output 
772
+		$query = "SELECT spotter_archive_output.* FROM spotter_archive_output 
773 773
 		    WHERE spotter_archive_output.ident <> '' 
774 774
 		    ".$additional_query."
775 775
 		    ".$orderby_query;
776 776
 	}
777 777
 	$Spotter = new Spotter($this->db);
778
-	$spotter_array = $Spotter->getDataFromDB($query, array(),$limit_query);
778
+	$spotter_array = $Spotter->getDataFromDB($query, array(), $limit_query);
779 779
 
780 780
 	return $spotter_array;
781 781
     }
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
                 try {
793 793
                         $sth = $this->db->prepare($query);
794 794
                         $sth->execute();
795
-                } catch(PDOException $e) {
795
+                } catch (PDOException $e) {
796 796
                         return "error";
797 797
                 }
798 798
 	}
@@ -826,8 +826,8 @@  discard block
 block discarded – undo
826 826
 	{
827 827
 	    $limit_array = explode(",", $limit);
828 828
 	    
829
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
830
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
829
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
830
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
831 831
 	    
832 832
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
833 833
 	    {
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
     * @return Array the airline country list
859 859
     *
860 860
     */
861
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
861
+    public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
862 862
     {
863 863
 	global $globalDBdriver;
864 864
 	/*
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
 	$flight_array = array();
888 888
 	$temp_array = array();
889 889
         
890
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
890
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
891 891
 	{
892 892
 	    $temp_array['flight_count'] = $row['nb'];
893 893
 	    $temp_array['flight_country'] = $row['name'];
Please login to merge, or discard this patch.
Braces   +23 added lines, -8 removed lines patch added patch discarded remove patch
@@ -16,10 +16,17 @@  discard block
 block discarded – undo
16 16
         if ($over_country == '') {
17 17
 	        $Spotter = new Spotter($this->db);
18 18
 	        $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
19
-		if (!empty($data_country)) $country = $data_country['iso2'];
20
-		else $country = '';
21
-	} else $country = $over_country;
22
-	if ($airline_type === NULL) $airline_type ='';
19
+		if (!empty($data_country)) {
20
+			$country = $data_country['iso2'];
21
+		} else {
22
+			$country = '';
23
+		}
24
+	} else {
25
+		$country = $over_country;
26
+	}
27
+	if ($airline_type === NULL) {
28
+		$airline_type ='';
29
+	}
23 30
 	
24 31
 	//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n";
25 32
 	//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n";
@@ -495,7 +502,9 @@  discard block
 block discarded – undo
495 502
 		    $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
496 503
 		    $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
497 504
 		    $translate = $Translation->ident2icao($q_item);
498
-		    if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
505
+		    if ($translate != $q_item) {
506
+		    	$additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
507
+		    }
499 508
 		    $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
500 509
 		    $additional_query .= ")";
501 510
 		}
@@ -713,7 +722,9 @@  discard block
 block discarded – undo
713 722
 		date_default_timezone_set($globalTimezone);
714 723
 		$datetime = new DateTime();
715 724
 		$offset = $datetime->format('P');
716
-	    } else $offset = '+00:00';
725
+	    } else {
726
+	    	$offset = '+00:00';
727
+	    }
717 728
 
718 729
 
719 730
 	    if ($date_array[1] != "")
@@ -876,9 +887,13 @@  discard block
 block discarded – undo
876 887
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
877 888
 			}
878 889
 		}
879
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
890
+                if ($sincedate != '') {
891
+                	$query .= "AND date > '".$sincedate."' ";
892
+                }
880 893
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
881
-	if ($limit) $query .= " LIMIT 0,10";
894
+	if ($limit) {
895
+		$query .= " LIMIT 0,10";
896
+	}
882 897
       
883 898
 	
884 899
 	$sth = $this->db->prepare($query);
Please login to merge, or discard this patch.