Completed
Push — master ( 36cc69...ef15cd )
by Yannick
07:23
created
airport-statistics-route.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -6,14 +6,14 @@  discard block
 block discarded – undo
6 6
         header('Location: '.$globalURL.'/airport');
7 7
         die();
8 8
 }
9
-$airport = filter_input(INPUT_GET,'airport',FILTER_SANITIZE_STRING);
9
+$airport = filter_input(INPUT_GET, 'airport', FILTER_SANITIZE_STRING);
10 10
 $Spotter = new Spotter();
11
-$spotter_array = $Spotter->getSpotterDataByAirport($airport,"0,1","");
11
+$spotter_array = $Spotter->getSpotterDataByAirport($airport, "0,1", "");
12 12
 $airport_array = $Spotter->getAllAirportInfo($airport);
13 13
 
14 14
 if (!empty($airport_array))
15 15
 {
16
-	$title = sprintf(_("Most Common Routes to/from %s, %s (%s)"),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']);
16
+	$title = sprintf(_("Most Common Routes to/from %s, %s (%s)"), $airport_array[0]['city'], $airport_array[0]['name'], $airport_array[0]['icao']);
17 17
 
18 18
 	require_once('header.php');
19 19
 	print '<div class="select-item">';
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
 	print '<option></option>';
23 23
 	$airport_names = $Spotter->getAllAirportNames();
24 24
 	ksort($airport_names);
25
-	foreach($airport_names as $airport_name)
25
+	foreach ($airport_names as $airport_name)
26 26
 	{
27
-		if($airport == $airport_name['airport_icao'])
27
+		if ($airport == $airport_name['airport_icao'])
28 28
 		{
29 29
 			print '<option value="'.$airport_name['airport_icao'].'" selected="selected">'.$airport_name['airport_city'].', '.$airport_name['airport_name'].', '.$airport_name['airport_country'].' ('.$airport_name['airport_icao'].')</option>';
30 30
 		} else {
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		print '<div><span class="label">'._("ICAO").'</span>'.$airport_array[0]['icao'].'</div>';
47 47
 		print '<div><span class="label">'._("IATA").'</span>'.$airport_array[0]['iata'].'</div>';
48 48
 		print '<div><span class="label">'._("Altitude").'</span>'.$airport_array[0]['altitude'].'</div>';
49
-		print '<div><span class="label">'._("Coordinates");'</span><a href="http://maps.google.ca/maps?z=10&t=k&q='.$airport_array[0]['latitude'].','.$airport_array[0]['longitude'].'" target="_blank">Google Map<i class="fa fa-angle-double-right"></i></a></div>';
49
+		print '<div><span class="label">'._("Coordinates"); '</span><a href="http://maps.google.ca/maps?z=10&t=k&q='.$airport_array[0]['latitude'].','.$airport_array[0]['longitude'].'" target="_blank">Google Map<i class="fa fa-angle-double-right"></i></a></div>';
50 50
 		print '</div>';
51 51
 	} else {
52 52
 		print '<div class="alert alert-warning">'._("This special airport profile shows all flights that do <u>not</u> have a departure and/or arrival airport associated with them.").'</div>';
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
 
55 55
 	include('airport-sub-menu.php');
56 56
 	print '<div class="column">';
57
-	print '<h2>'._("Most Common Routes");'</h2>';
58
-	print '<p>'.sprintf(_("The statistic below shows the most common routes to/from <strong>%s, %s (%s)</strong>."),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']).'</p>';
57
+	print '<h2>'._("Most Common Routes"); '</h2>';
58
+	print '<p>'.sprintf(_("The statistic below shows the most common routes to/from <strong>%s, %s (%s)</strong>."), $airport_array[0]['city'], $airport_array[0]['name'], $airport_array[0]['icao']).'</p>';
59 59
 
60 60
 	$route_array = $Spotter->countAllRoutesByAirport($airport);
61 61
 	if (!empty($route_array))
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 		print '</thead>';
72 72
 		print '<tbody>';
73 73
 		$i = 1;
74
-		foreach($route_array as $route_item)
74
+		foreach ($route_array as $route_item)
75 75
 		{
76 76
 			print '<tr>';
77 77
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 if (!isset($_GET['airport'])) {
6
-        header('Location: '.$globalURL.'/airport');
7
-        die();
6
+		header('Location: '.$globalURL.'/airport');
7
+		die();
8 8
 }
9 9
 $airport = filter_input(INPUT_GET,'airport',FILTER_SANITIZE_STRING);
10 10
 $Spotter = new Spotter();
Please login to merge, or discard this patch.
manufacturer-statistics-departure-airport.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
7 7
         die();
8 8
 }
9 9
 $Spotter = new Spotter();
10
-$manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING)));
11
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
12
-$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer,"0,1", $sort);
10
+$manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET, 'aircraft_manufacturer', FILTER_SANITIZE_STRING)));
11
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
12
+$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer, "0,1", $sort);
13 13
 
14 14
 if (!empty($spotter_array))
15 15
 {
16
-	$title = sprintf(_("Most Common Departure Airports from %s"),$manufacturer);
16
+	$title = sprintf(_("Most Common Departure Airports from %s"), $manufacturer);
17 17
 
18 18
 	require_once('header.php');
19 19
 	print '<div class="select-item">';
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
 	print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">';
22 22
 	print '<option></option>';
23 23
 	$all_manufacturers = $Spotter->getAllManufacturers();
24
-	foreach($all_manufacturers as $all_manufacturer)
24
+	foreach ($all_manufacturers as $all_manufacturer)
25 25
 	{
26
-		if($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])))
26
+		if ($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])))
27 27
 		{
28 28
 			print '<option value="'.strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])).'" selected="selected">'.$all_manufacturer['aircraft_manufacturer'].'</option>';
29 29
 		} else {
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	include('manufacturer-sub-menu.php');
43 43
 	print '<div class="column">';
44 44
 	print '<h2>'._("Most Common Departure Airports").'</h2>';
45
-	print '<p>'.sprintf(_("The statistic below shows all departure airports of flights from <strong>%s</strong>."),$manufacturer).'</p>';
45
+	print '<p>'.sprintf(_("The statistic below shows all departure airports of flights from <strong>%s</strong>."), $manufacturer).'</p>';
46 46
 	$airport_airport_array = $Spotter->countAllDepartureAirportsByManufacturer($manufacturer);
47 47
 	print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>
48 48
     	<script>
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
         	["'._("Airport").'", "'._("# of times").'"],';
58 58
 
59 59
 	$airport_data = '';
60
-	foreach($airport_airport_array as $airport_item)
60
+	foreach ($airport_airport_array as $airport_item)
61 61
 	{
62 62
 		$name = $airport_item['airport_departure_city'].', '.$airport_item['airport_departure_country'].' ('.$airport_item['airport_departure_icao'].')';
63 63
 		$name = str_replace("'", "", $name);
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	print '</thead>';
97 97
 	print '<tbody>';
98 98
 	$i = 1;
99
-	foreach($airport_airport_array as $airport_item)
99
+	foreach ($airport_airport_array as $airport_item)
100 100
 	{
101 101
 		print '<tr>';
102 102
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 if (!isset($_GET['aircraft_manufacturer'])) {
6
-        header('Location: '.$globalURL.'/manufacturer');
7
-        die();
6
+		header('Location: '.$globalURL.'/manufacturer');
7
+		die();
8 8
 }
9 9
 $Spotter = new Spotter();
10 10
 $manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING)));
Please login to merge, or discard this patch.
require/class.SpotterLive.php 3 patches
Indentation   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@  discard block
 block discarded – undo
11 11
 	}
12 12
 	    
13 13
 	/**
14
-	* Gets all the spotter information based on the latest data entry
15
-	*
16
-	* @return Array the spotter information
17
-	*
18
-	*/
14
+	 * Gets all the spotter information based on the latest data entry
15
+	 *
16
+	 * @return Array the spotter information
17
+	 *
18
+	 */
19 19
 	public function getLiveSpotterData($limit = '', $sort = '', $filter = array())
20 20
 	{
21 21
 		global $globalDBdriver, $globalLiveInterval;
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 		if ($globalDBdriver == 'mysql') {
59 59
 			//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
60 60
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query;
61
-                } else if ($globalDBdriver == 'pgsql') {
61
+				} else if ($globalDBdriver == 'pgsql') {
62 62
 			$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query.$orderby_query;
63 63
 		}
64 64
 		$spotter_array = $Spotter->getDataFromDB($query.$limit_query);
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
 	}
68 68
 
69 69
 	/**
70
-	* Gets Minimal Live Spotter data
71
-	*
72
-	* @return Array the spotter information
73
-	*
74
-	*/
70
+	 * Gets Minimal Live Spotter data
71
+	 *
72
+	 * @return Array the spotter information
73
+	 *
74
+	 */
75 75
 	public function getMinLiveSpotterData($filter = array())
76 76
 	{
77 77
 		global $globalDBdriver, $globalLiveInterval;
@@ -104,9 +104,9 @@  discard block
 block discarded – undo
104 104
 //			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date ORDER BY spotter_live.date GROUP BY spotter_live.flightaware_id'.$filter_query;
105 105
 
106 106
 			//$query = 'SELECT a.aircraft_shadow, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk  FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao';
107
-                } else if ($globalDBdriver == 'pgsql') {
108
-            		//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE NOW() AT TIME ZONE 'UTC' - '30 SECONDS'->INTERVAL <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
109
-            		//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE NOW() AT TIME ZONE 'UTC' - '".$globalLiveInterval." SECONDS'->INTERVAL <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate$orderby_query";
107
+				} else if ($globalDBdriver == 'pgsql') {
108
+					//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE NOW() AT TIME ZONE 'UTC' - '30 SECONDS'->INTERVAL <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
109
+					//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE NOW() AT TIME ZONE 'UTC' - '".$globalLiveInterval." SECONDS'->INTERVAL <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate$orderby_query";
110 110
 			//$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, a.aircraft_shadow FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_live.aircraft_icao = a.icao';
111 111
 			$query  = "SELECT a.aircraft_shadow, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date 
112 112
 			FROM spotter_live
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 //		$spotter_array = Spotter->getDataFromDB($query.$limit_query);
116 116
 		//echo $query;
117 117
 
118
-    		try {
118
+			try {
119 119
 			$sth = $this->db->prepare($query);
120 120
 			$sth->execute();
121 121
 		} catch(PDOException $e) {
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
 	}
128 128
 
129 129
 	/**
130
-	* Gets number of latest data entry
131
-	*
132
-	* @return String number of entry
133
-	*
134
-	*/
130
+	 * Gets number of latest data entry
131
+	 *
132
+	 * @return String number of entry
133
+	 *
134
+	 */
135 135
 	public function getLiveSpotterCount($filter = array())
136 136
 	{
137 137
 		global $globalDBdriver, $globalLiveInterval;
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
 
152 152
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
153 153
 		if ($globalDBdriver == 'mysql') {
154
-            		//$query  = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query;
154
+					//$query  = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query;
155 155
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'.$filter_query;
156
-            	} elseif ($globalDBdriver == 'pgsql') {
157
-	                //$query  = "SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE NOW() AT TIME ZONE 'UTC' - '".$globalLiveInterval." SECONDS'->INTERVAL <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query;
156
+				} elseif ($globalDBdriver == 'pgsql') {
157
+					//$query  = "SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE NOW() AT TIME ZONE 'UTC' - '".$globalLiveInterval." SECONDS'->INTERVAL <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query;
158 158
 			$query = "SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_live WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date".$filter_query;
159
-                }
160
-    		try {
159
+				}
160
+			try {
161 161
 			$sth = $this->db->prepare($query);
162 162
 			$sth->execute();
163 163
 		} catch(PDOException $e) {
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
 	}
169 169
 
170 170
 	/**
171
-	* Gets all the spotter information based on the latest data entry and coord
172
-	*
173
-	* @return Array the spotter information
174
-	*
175
-	*/
171
+	 * Gets all the spotter information based on the latest data entry and coord
172
+	 *
173
+	 * @return Array the spotter information
174
+	 *
175
+	 */
176 176
 	public function getLiveSpotterDatabyCoord($coord, $filter = array())
177 177
 	{
178 178
 		global $globalDBdriver, $globalLiveInterval;
@@ -193,140 +193,140 @@  discard block
 block discarded – undo
193 193
 		}
194 194
 
195 195
 		if (is_array($coord)) {
196
-                        $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
197
-                        $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
198
-                        $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
199
-                        $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
200
-                } else return array();
201
-                if ($globalDBdriver == 'mysql') {
202
-        		//$query  = "SELECT spotter_output.* FROM spotter_output WHERE spotter_output.flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
203
-        		$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query;
204
-        	} else if ($globalDBdriver == 'pgsql') {
205
-            		$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE NOW() at time zone 'UTC'  - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." GROUP BY spotter_live.flightaware_id".$filter_query;
206
-                }
207
-                $spotter_array = $Spotter->getDataFromDB($query);
208
-                return $spotter_array;
209
-        }
196
+						$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
197
+						$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
198
+						$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
199
+						$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
200
+				} else return array();
201
+				if ($globalDBdriver == 'mysql') {
202
+				//$query  = "SELECT spotter_output.* FROM spotter_output WHERE spotter_output.flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
203
+				$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query;
204
+			} else if ($globalDBdriver == 'pgsql') {
205
+					$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE NOW() at time zone 'UTC'  - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." GROUP BY spotter_live.flightaware_id".$filter_query;
206
+				}
207
+				$spotter_array = $Spotter->getDataFromDB($query);
208
+				return $spotter_array;
209
+		}
210 210
 
211 211
 	/**
212
-        * Gets all the spotter information based on a user's latitude and longitude
213
-        *
214
-        * @return Array the spotter information
215
-        *
216
-        */
217
-        public function getLatestSpotterForLayar($lat, $lng, $radius, $interval)
218
-        {
219
-    		$Spotter = new Spotter($this->db);
220
-                date_default_timezone_set('UTC');
221
-
222
-        if ($lat != '')
223
-                {
224
-                        if (!is_numeric($lat))
225
-                        {
226
-                                return false;
227
-                        }
228
-                }
212
+	 * Gets all the spotter information based on a user's latitude and longitude
213
+	 *
214
+	 * @return Array the spotter information
215
+	 *
216
+	 */
217
+		public function getLatestSpotterForLayar($lat, $lng, $radius, $interval)
218
+		{
219
+			$Spotter = new Spotter($this->db);
220
+				date_default_timezone_set('UTC');
221
+
222
+		if ($lat != '')
223
+				{
224
+						if (!is_numeric($lat))
225
+						{
226
+								return false;
227
+						}
228
+				}
229 229
         
230
-        if ($lng != '')
231
-                {
232
-                        if (!is_numeric($lng))
233
-                        {
234
-                                return false;
235
-                        }
236
-                }
237
-
238
-                if ($radius != '')
239
-                {
240
-                        if (!is_numeric($radius))
241
-                        {
242
-                                return false;
243
-                        }
244
-                }
230
+		if ($lng != '')
231
+				{
232
+						if (!is_numeric($lng))
233
+						{
234
+								return false;
235
+						}
236
+				}
237
+
238
+				if ($radius != '')
239
+				{
240
+						if (!is_numeric($radius))
241
+						{
242
+								return false;
243
+						}
244
+				}
245 245
         
246
-        if ($interval != '')
247
-                {
248
-                        if (!is_string($interval))
249
-                        {
250
-                                $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
251
-                return false;
252
-                        } else {
253
-                if ($interval == '1m')
254
-                {
255
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
256
-                } else if ($interval == '15m'){
257
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
258
-                } 
259
-            }
260
-                } else {
261
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
262
-        }
263
-
264
-                $query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
246
+		if ($interval != '')
247
+				{
248
+						if (!is_string($interval))
249
+						{
250
+								$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
251
+				return false;
252
+						} else {
253
+				if ($interval == '1m')
254
+				{
255
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
256
+				} else if ($interval == '15m'){
257
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
258
+				} 
259
+			}
260
+				} else {
261
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
262
+		}
263
+
264
+				$query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
265 265
                    WHERE spotter_live.latitude <> '' 
266 266
                                    AND spotter_live.longitude <> '' 
267 267
                    ".$additional_query."
268 268
                    HAVING distance < :radius  
269 269
                                    ORDER BY distance";
270 270
 
271
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius),$limit_query);
271
+				$spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius),$limit_query);
272 272
 
273
-                return $spotter_array;
274
-        }
273
+				return $spotter_array;
274
+		}
275 275
 
276 276
     
277
-        /**
278
-	* Gets all the spotter information based on a particular callsign
279
-	*
280
-	* @return Array the spotter information
281
-	*
282
-	*/
277
+		/**
278
+		 * Gets all the spotter information based on a particular callsign
279
+		 *
280
+		 * @return Array the spotter information
281
+		 *
282
+		 */
283 283
 	public function getLastLiveSpotterDataByIdent($ident)
284 284
 	{
285 285
 		$Spotter = new Spotter($this->db);
286 286
 		date_default_timezone_set('UTC');
287 287
 
288 288
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
289
-                $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 GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
289
+				$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 GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
290 290
 
291 291
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
292 292
 
293 293
 		return $spotter_array;
294 294
 	}
295 295
 
296
-        /**
297
-	* Gets last spotter information based on a particular callsign
298
-	*
299
-	* @return Array the spotter information
300
-	*
301
-	*/
296
+		/**
297
+		 * Gets last spotter information based on a particular callsign
298
+		 *
299
+		 * @return Array the spotter information
300
+		 *
301
+		 */
302 302
 	public function getLastLiveSpotterDataById($id)
303 303
 	{
304 304
 		$Spotter = new Spotter($this->db);
305 305
 		date_default_timezone_set('UTC');
306 306
 
307 307
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
308
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
308
+				$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
309 309
 
310 310
 		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
311 311
 
312 312
 		return $spotter_array;
313 313
 	}
314 314
 
315
-        /**
316
-	* Gets altitude information based on a particular callsign
317
-	*
318
-	* @return Array the spotter information
319
-	*
320
-	*/
315
+		/**
316
+		 * Gets altitude information based on a particular callsign
317
+		 *
318
+		 * @return Array the spotter information
319
+		 *
320
+		 */
321 321
 	public function getAltitudeLiveSpotterDataByIdent($ident)
322 322
 	{
323 323
 
324 324
 		date_default_timezone_set('UTC');
325 325
 
326 326
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
327
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
327
+				$query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
328 328
 
329
-    		try {
329
+			try {
330 330
 			
331 331
 			$sth = $this->db->prepare($query);
332 332
 			$sth->execute(array(':ident' => $ident));
@@ -338,12 +338,12 @@  discard block
 block discarded – undo
338 338
 		return $spotter_array;
339 339
 	}
340 340
 
341
-        /**
342
-	* Gets all the spotter information based on a particular id
343
-	*
344
-	* @return Array the spotter information
345
-	*
346
-	*/
341
+		/**
342
+		 * Gets all the spotter information based on a particular id
343
+		 *
344
+		 * @return Array the spotter information
345
+		 *
346
+		 */
347 347
 	public function getAllLiveSpotterDataById($id)
348 348
 	{
349 349
 		date_default_timezone_set('UTC');
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 		$query  = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date';
352 352
 //		$spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
353 353
 
354
-    		try {
354
+			try {
355 355
 			
356 356
 			$sth = $this->db->prepare($query);
357 357
 			$sth->execute(array(':id' => $id));
@@ -363,18 +363,18 @@  discard block
 block discarded – undo
363 363
 		return $spotter_array;
364 364
 	}
365 365
 
366
-        /**
367
-	* Gets all the spotter information based on a particular ident
368
-	*
369
-	* @return Array the spotter information
370
-	*
371
-	*/
366
+		/**
367
+		 * Gets all the spotter information based on a particular ident
368
+		 *
369
+		 * @return Array the spotter information
370
+		 *
371
+		 */
372 372
 	public function getAllLiveSpotterDataByIdent($ident)
373 373
 	{
374 374
 		date_default_timezone_set('UTC');
375 375
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
376 376
 		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
377
-    		try {
377
+			try {
378 378
 			
379 379
 			$sth = $this->db->prepare($query);
380 380
 			$sth->execute(array(':ident' => $ident));
@@ -387,24 +387,24 @@  discard block
 block discarded – undo
387 387
 
388 388
 
389 389
 	/**
390
-	* Deletes all info in the table
391
-	*
392
-	* @return String success or false
393
-	*
394
-	*/
390
+	 * Deletes all info in the table
391
+	 *
392
+	 * @return String success or false
393
+	 *
394
+	 */
395 395
 	public function deleteLiveSpotterData()
396 396
 	{
397 397
 		global $globalDBdriver;
398 398
 		if ($globalDBdriver == 'mysql') {
399 399
 			//$query  = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date";
400 400
 			$query  = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date';
401
-            		//$query  = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)";
401
+					//$query  = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)";
402 402
 
403 403
 		} elseif ($globalDBdriver == 'pgsql') {
404 404
 			$query  = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date";
405 405
 		}
406 406
         
407
-    		try {
407
+			try {
408 408
 			
409 409
 			$sth = $this->db->prepare($query);
410 410
 			$sth->execute();
@@ -416,18 +416,18 @@  discard block
 block discarded – undo
416 416
 	}
417 417
 
418 418
 	/**
419
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
420
-	*
421
-	* @return String success or false
422
-	*
423
-	*/
419
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
420
+	 *
421
+	 * @return String success or false
422
+	 *
423
+	 */
424 424
 	public function deleteLiveSpotterDataNotUpdated()
425 425
 	{
426 426
 		global $globalDBdriver, $globalDebug;
427 427
 		if ($globalDBdriver == 'mysql') {
428 428
 			//$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0';
429
-    			$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
430
-    			try {
429
+				$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
430
+				try {
431 431
 				
432 432
 				$sth = $this->db->prepare($query);
433 433
 				$sth->execute();
@@ -435,8 +435,8 @@  discard block
 block discarded – undo
435 435
 				return "error";
436 436
 			}
437 437
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
438
-                        $i = 0;
439
-                        $j =0;
438
+						$i = 0;
439
+						$j =0;
440 440
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
441 441
 			foreach($all as $row)
442 442
 			{
@@ -444,20 +444,20 @@  discard block
 block discarded – undo
444 444
 				$j++;
445 445
 				if ($j == 30) {
446 446
 					if ($globalDebug) echo ".";
447
-				    	try {
447
+						try {
448 448
 						
449 449
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
450 450
 						$sth->execute();
451 451
 					} catch(PDOException $e) {
452 452
 						return "error";
453 453
 					}
454
-                                	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
455
-                                	$j = 0;
454
+									$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
455
+									$j = 0;
456 456
 				}
457 457
 				$query_delete .= "'".$row['flightaware_id']."',";
458 458
 			}
459 459
 			if ($i > 0) {
460
-    				try {
460
+					try {
461 461
 					
462 462
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
463 463
 					$sth->execute();
@@ -468,9 +468,9 @@  discard block
 block discarded – undo
468 468
 			return "success";
469 469
 		} elseif ($globalDBdriver == 'pgsql') {
470 470
 			//$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0";
471
-    			//$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
472
-    			$query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
473
-    			try {
471
+				//$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
472
+				$query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
473
+				try {
474 474
 				
475 475
 				$sth = $this->db->prepare($query);
476 476
 				$sth->execute();
@@ -514,17 +514,17 @@  discard block
 block discarded – undo
514 514
 	}
515 515
 
516 516
 	/**
517
-	* Deletes all info in the table for an ident
518
-	*
519
-	* @return String success or false
520
-	*
521
-	*/
517
+	 * Deletes all info in the table for an ident
518
+	 *
519
+	 * @return String success or false
520
+	 *
521
+	 */
522 522
 	public function deleteLiveSpotterDataByIdent($ident)
523 523
 	{
524 524
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
525 525
 		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
526 526
         
527
-    		try {
527
+			try {
528 528
 			
529 529
 			$sth = $this->db->prepare($query);
530 530
 			$sth->execute(array(':ident' => $ident));
@@ -536,17 +536,17 @@  discard block
 block discarded – undo
536 536
 	}
537 537
 
538 538
 	/**
539
-	* Deletes all info in the table for an id
540
-	*
541
-	* @return String success or false
542
-	*
543
-	*/
539
+	 * Deletes all info in the table for an id
540
+	 *
541
+	 * @return String success or false
542
+	 *
543
+	 */
544 544
 	public function deleteLiveSpotterDataById($id)
545 545
 	{
546 546
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
547 547
 		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
548 548
         
549
-    		try {
549
+			try {
550 550
 			
551 551
 			$sth = $this->db->prepare($query);
552 552
 			$sth->execute(array(':id' => $id));
@@ -559,11 +559,11 @@  discard block
 block discarded – undo
559 559
 
560 560
 
561 561
 	/**
562
-	* Gets the aircraft ident within the last hour
563
-	*
564
-	* @return String the ident
565
-	*
566
-	*/
562
+	 * Gets the aircraft ident within the last hour
563
+	 *
564
+	 * @return String the ident
565
+	 *
566
+	 */
567 567
 	public function getIdentFromLastHour($ident)
568 568
 	{
569 569
 		global $globalDBdriver, $globalTimezone;
@@ -589,14 +589,14 @@  discard block
 block discarded – undo
589 589
 			$ident_result = $row['ident'];
590 590
 		}
591 591
 		return $ident_result;
592
-        }
592
+		}
593 593
 
594 594
 	/**
595
-	* Check recent aircraft
596
-	*
597
-	* @return String the ident
598
-	*
599
-	*/
595
+	 * Check recent aircraft
596
+	 *
597
+	 * @return String the ident
598
+	 *
599
+	 */
600 600
 	public function checkIdentRecent($ident)
601 601
 	{
602 602
 		global $globalDBdriver, $globalTimezone;
@@ -622,14 +622,14 @@  discard block
 block discarded – undo
622 622
 			$ident_result = $row['flightaware_id'];
623 623
 		}
624 624
 		return $ident_result;
625
-        }
625
+		}
626 626
 
627 627
 	/**
628
-	* Check recent aircraft by ModeS
629
-	*
630
-	* @return String the ModeS
631
-	*
632
-	*/
628
+	 * Check recent aircraft by ModeS
629
+	 *
630
+	 * @return String the ModeS
631
+	 *
632
+	 */
633 633
 	public function checkModeSRecent($modes)
634 634
 	{
635 635
 		global $globalDBdriver, $globalTimezone;
@@ -656,19 +656,19 @@  discard block
 block discarded – undo
656 656
 			$ident_result = $row['flightaware_id'];
657 657
 		}
658 658
 		return $ident_result;
659
-        }
659
+		}
660 660
 
661 661
 	/**
662
-	* Adds a new spotter data
663
-	*
664
-	* @param String $flightaware_id the ID from flightaware
665
-	* @param String $ident the flight ident
666
-	* @param String $aircraft_icao the aircraft type
667
-	* @param String $departure_airport_icao the departure airport
668
-	* @param String $arrival_airport_icao the arrival airport
669
-	* @return String success or false
670
-	*
671
-	*/
662
+	 * Adds a new spotter data
663
+	 *
664
+	 * @param String $flightaware_id the ID from flightaware
665
+	 * @param String $ident the flight ident
666
+	 * @param String $aircraft_icao the aircraft type
667
+	 * @param String $departure_airport_icao the departure airport
668
+	 * @param String $arrival_airport_icao the arrival airport
669
+	 * @return String success or false
670
+	 *
671
+	 */
672 672
 	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '')
673 673
 	{
674 674
 		global $globalURL, $globalArchive, $globalDebug;
@@ -894,10 +894,10 @@  discard block
 block discarded – undo
894 894
 			$arrival_airport_country = '';
895 895
 		}
896 896
             	
897
-            	if ($squawk == '' || $Common->isInteger($squawk) == false ) $squawk = NULL;
898
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) == false ) $verticalrate = NULL;
899
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) == false ) $groundspeed = 0;
900
-            	if ($heading == '' || $Common->isInteger($heading) == false ) $heading = 0;
897
+				if ($squawk == '' || $Common->isInteger($squawk) == false ) $squawk = NULL;
898
+				if ($verticalrate == '' || $Common->isInteger($verticalrate) == false ) $verticalrate = NULL;
899
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) == false ) $groundspeed = 0;
900
+				if ($heading == '' || $Common->isInteger($heading) == false ) $heading = 0;
901 901
             	
902 902
 		$query  = 'INSERT INTO spotter_live (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, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) 
903 903
 		VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)';
@@ -908,13 +908,13 @@  discard block
 block discarded – undo
908 908
 			
909 909
 			$sth = $this->db->prepare($query);
910 910
 			$sth->execute($query_values);
911
-                } catch(PDOException $e) {
912
-                	return "error : ".$e->getMessage();
913
-                }
911
+				} catch(PDOException $e) {
912
+					return "error : ".$e->getMessage();
913
+				}
914 914
 		if (isset($globalArchive) && $globalArchive && $putinarchive && !$noarchive) {
915
-		    if ($globalDebug) echo '(Add to SBS archive : ';
916
-		    $result =  $SpotterArchive->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, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
917
-		    if ($globalDebug) echo $result.')';
915
+			if ($globalDebug) echo '(Add to SBS archive : ';
916
+			$result =  $SpotterArchive->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, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
917
+			if ($globalDebug) echo $result.')';
918 918
 		}
919 919
 		return "success";
920 920
 
Please login to merge, or discard this patch.
Spacing   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -24,24 +24,24 @@  discard block
 block discarded – undo
24 24
 
25 25
 		$filter_query = '';
26 26
 		if (isset($filter['source']) && !empty($filter['source'])) {
27
-			$filter_query = " AND format_source IN ('".implode("','",$filter['source'])."')";
27
+			$filter_query = " AND format_source IN ('".implode("','", $filter['source'])."')";
28 28
 		}
29 29
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
30
-			$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_live.flightaware_id";
30
+			$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_live.flightaware_id";
31 31
 		}
32 32
 		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
33 33
 			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id ";
34 34
 		}
35 35
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
36
-			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
36
+			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
37 37
 		}
38 38
 		
39 39
 		$limit_query = '';
40 40
 		if ($limit != '')
41 41
 		{
42 42
 			$limit_array = explode(',', $limit);
43
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
44
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
43
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
44
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
45 45
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
46 46
 			{
47 47
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -79,16 +79,16 @@  discard block
 block discarded – undo
79 79
 
80 80
 		$filter_query = '';
81 81
 		if (isset($filter['source']) && !empty($filter['source'])) {
82
-			$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
82
+			$filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
83 83
 		}
84 84
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
85
-			$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_live.flightaware_id ";
85
+			$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_live.flightaware_id ";
86 86
 		}
87 87
 		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
88 88
 			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id ";
89 89
 		}
90 90
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
91
-			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
91
+			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
92 92
 		}
93 93
 
94 94
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 //			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, a.aircraft_shadow FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate INNER JOIN (SELECT * FROM aircraft) a on spotter_live.aircraft_icao = a.icao';
98 98
 //			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query;
99 99
 
100
-			$query  = 'SELECT a.aircraft_shadow, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date 
100
+			$query = 'SELECT a.aircraft_shadow, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date 
101 101
 			FROM spotter_live 
102 102
 			INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao';
103 103
 
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
             		//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE NOW() AT TIME ZONE 'UTC' - '30 SECONDS'->INTERVAL <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
109 109
             		//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE NOW() AT TIME ZONE 'UTC' - '".$globalLiveInterval." SECONDS'->INTERVAL <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate$orderby_query";
110 110
 			//$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, a.aircraft_shadow FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_live.aircraft_icao = a.icao';
111
-			$query  = "SELECT a.aircraft_shadow, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date 
111
+			$query = "SELECT a.aircraft_shadow, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date 
112 112
 			FROM spotter_live
113 113
 			INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ".$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao';
114 114
 		}
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
     		try {
119 119
 			$sth = $this->db->prepare($query);
120 120
 			$sth->execute();
121
-		} catch(PDOException $e) {
121
+		} catch (PDOException $e) {
122 122
 			return "error";
123 123
 		}
124 124
 		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -137,16 +137,16 @@  discard block
 block discarded – undo
137 137
 		global $globalDBdriver, $globalLiveInterval;
138 138
 		$filter_query = '';
139 139
 		if (isset($filter['source']) && !empty($filter['source'])) {
140
-			$filter_query = " AND format_source IN ('".implode("','",$filter['source'])."')";
140
+			$filter_query = " AND format_source IN ('".implode("','", $filter['source'])."')";
141 141
 		}
142 142
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
143
-			$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_live.flightaware_id";
143
+			$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_live.flightaware_id";
144 144
 		}
145 145
 		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
146 146
 			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id ";
147 147
 		}
148 148
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
149
-			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
149
+			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
150 150
 		}
151 151
 
152 152
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
     		try {
161 161
 			$sth = $this->db->prepare($query);
162 162
 			$sth->execute();
163
-		} catch(PDOException $e) {
163
+		} catch (PDOException $e) {
164 164
 			return "error";
165 165
 		}
166 166
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
@@ -180,29 +180,29 @@  discard block
 block discarded – undo
180 180
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
181 181
 		$filter_query = '';
182 182
 		if (isset($filter['source'])) {
183
-			$filter_query = " AND format_source IN ('".implode(',',$filter['source'])."')";
183
+			$filter_query = " AND format_source IN ('".implode(',', $filter['source'])."')";
184 184
 		}
185 185
 		if (isset($filter['airlines'])) {
186
-			$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_live.flightaware_id";
186
+			$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_live.flightaware_id";
187 187
 		}
188 188
 		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
189 189
 			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id ";
190 190
 		}
191 191
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
192
-			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
192
+			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
193 193
 		}
194 194
 
195 195
 		if (is_array($coord)) {
196
-                        $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
197
-                        $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
198
-                        $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
199
-                        $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
196
+                        $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
197
+                        $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
198
+                        $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
199
+                        $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
200 200
                 } else return array();
201 201
                 if ($globalDBdriver == 'mysql') {
202 202
         		//$query  = "SELECT spotter_output.* FROM spotter_output WHERE spotter_output.flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
203
-        		$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query;
203
+        		$query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query;
204 204
         	} else if ($globalDBdriver == 'pgsql') {
205
-            		$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE NOW() at time zone 'UTC'  - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." GROUP BY spotter_live.flightaware_id".$filter_query;
205
+            		$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE NOW() at time zone 'UTC'  - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." GROUP BY spotter_live.flightaware_id".$filter_query;
206 206
                 }
207 207
                 $spotter_array = $Spotter->getDataFromDB($query);
208 208
                 return $spotter_array;
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
                 if ($interval == '1m')
254 254
                 {
255 255
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
256
-                } else if ($interval == '15m'){
256
+                } else if ($interval == '15m') {
257 257
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
258 258
                 } 
259 259
             }
@@ -261,14 +261,14 @@  discard block
 block discarded – undo
261 261
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
262 262
         }
263 263
 
264
-                $query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
264
+                $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
265 265
                    WHERE spotter_live.latitude <> '' 
266 266
                                    AND spotter_live.longitude <> '' 
267 267
                    ".$additional_query."
268 268
                    HAVING distance < :radius  
269 269
                                    ORDER BY distance";
270 270
 
271
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius),$limit_query);
271
+                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius), $limit_query);
272 272
 
273 273
                 return $spotter_array;
274 274
         }
@@ -286,9 +286,9 @@  discard block
 block discarded – undo
286 286
 		date_default_timezone_set('UTC');
287 287
 
288 288
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
289
-                $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 GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
289
+                $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 GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
290 290
 
291
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
291
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident));
292 292
 
293 293
 		return $spotter_array;
294 294
 	}
@@ -305,9 +305,9 @@  discard block
 block discarded – undo
305 305
 		date_default_timezone_set('UTC');
306 306
 
307 307
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
308
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
308
+                $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
309 309
 
310
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
310
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id));
311 311
 
312 312
 		return $spotter_array;
313 313
 	}
@@ -324,13 +324,13 @@  discard block
 block discarded – undo
324 324
 		date_default_timezone_set('UTC');
325 325
 
326 326
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
327
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
327
+                $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
328 328
 
329 329
     		try {
330 330
 			
331 331
 			$sth = $this->db->prepare($query);
332 332
 			$sth->execute(array(':ident' => $ident));
333
-		} catch(PDOException $e) {
333
+		} catch (PDOException $e) {
334 334
 			return "error";
335 335
 		}
336 336
 		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -348,14 +348,14 @@  discard block
 block discarded – undo
348 348
 	{
349 349
 		date_default_timezone_set('UTC');
350 350
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
351
-		$query  = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date';
351
+		$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date';
352 352
 //		$spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
353 353
 
354 354
     		try {
355 355
 			
356 356
 			$sth = $this->db->prepare($query);
357 357
 			$sth->execute(array(':id' => $id));
358
-		} catch(PDOException $e) {
358
+		} catch (PDOException $e) {
359 359
 			return "error";
360 360
 		}
361 361
 		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -373,12 +373,12 @@  discard block
 block discarded – undo
373 373
 	{
374 374
 		date_default_timezone_set('UTC');
375 375
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
376
-		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
376
+		$query = self::$global_query.' WHERE spotter_live.ident = :ident';
377 377
     		try {
378 378
 			
379 379
 			$sth = $this->db->prepare($query);
380 380
 			$sth->execute(array(':ident' => $ident));
381
-		} catch(PDOException $e) {
381
+		} catch (PDOException $e) {
382 382
 			return "error";
383 383
 		}
384 384
 		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -397,18 +397,18 @@  discard block
 block discarded – undo
397 397
 		global $globalDBdriver;
398 398
 		if ($globalDBdriver == 'mysql') {
399 399
 			//$query  = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date";
400
-			$query  = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date';
400
+			$query = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date';
401 401
             		//$query  = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)";
402 402
 
403 403
 		} elseif ($globalDBdriver == 'pgsql') {
404
-			$query  = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date";
404
+			$query = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date";
405 405
 		}
406 406
         
407 407
     		try {
408 408
 			
409 409
 			$sth = $this->db->prepare($query);
410 410
 			$sth->execute();
411
-		} catch(PDOException $e) {
411
+		} catch (PDOException $e) {
412 412
 			return "error";
413 413
 		}
414 414
 
@@ -431,14 +431,14 @@  discard block
 block discarded – undo
431 431
 				
432 432
 				$sth = $this->db->prepare($query);
433 433
 				$sth->execute();
434
-			} catch(PDOException $e) {
434
+			} catch (PDOException $e) {
435 435
 				return "error";
436 436
 			}
437 437
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
438 438
                         $i = 0;
439
-                        $j =0;
439
+                        $j = 0;
440 440
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
441
-			foreach($all as $row)
441
+			foreach ($all as $row)
442 442
 			{
443 443
 				$i++;
444 444
 				$j++;
@@ -446,9 +446,9 @@  discard block
 block discarded – undo
446 446
 					if ($globalDebug) echo ".";
447 447
 				    	try {
448 448
 						
449
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
449
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
450 450
 						$sth->execute();
451
-					} catch(PDOException $e) {
451
+					} catch (PDOException $e) {
452 452
 						return "error";
453 453
 					}
454 454
                                 	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
@@ -459,9 +459,9 @@  discard block
 block discarded – undo
459 459
 			if ($i > 0) {
460 460
     				try {
461 461
 					
462
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
462
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
463 463
 					$sth->execute();
464
-				} catch(PDOException $e) {
464
+				} catch (PDOException $e) {
465 465
 					return "error";
466 466
 				}
467 467
 			}
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
 				
475 475
 				$sth = $this->db->prepare($query);
476 476
 				$sth->execute();
477
-			} catch(PDOException $e) {
477
+			} catch (PDOException $e) {
478 478
 				return "error";
479 479
 			}
480 480
 /*			$query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN (";
@@ -522,13 +522,13 @@  discard block
 block discarded – undo
522 522
 	public function deleteLiveSpotterDataByIdent($ident)
523 523
 	{
524 524
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
525
-		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
525
+		$query = 'DELETE FROM spotter_live WHERE ident = :ident';
526 526
         
527 527
     		try {
528 528
 			
529 529
 			$sth = $this->db->prepare($query);
530 530
 			$sth->execute(array(':ident' => $ident));
531
-		} catch(PDOException $e) {
531
+		} catch (PDOException $e) {
532 532
 			return "error";
533 533
 		}
534 534
 
@@ -544,13 +544,13 @@  discard block
 block discarded – undo
544 544
 	public function deleteLiveSpotterDataById($id)
545 545
 	{
546 546
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
547
-		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
547
+		$query = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
548 548
         
549 549
     		try {
550 550
 			
551 551
 			$sth = $this->db->prepare($query);
552 552
 			$sth->execute(array(':id' => $id));
553
-		} catch(PDOException $e) {
553
+		} catch (PDOException $e) {
554 554
 			return "error";
555 555
 		}
556 556
 
@@ -568,13 +568,13 @@  discard block
 block discarded – undo
568 568
 	{
569 569
 		global $globalDBdriver, $globalTimezone;
570 570
 		if ($globalDBdriver == 'mysql') {
571
-			$query  = 'SELECT spotter_live.ident FROM spotter_live 
571
+			$query = 'SELECT spotter_live.ident FROM spotter_live 
572 572
 				WHERE spotter_live.ident = :ident 
573 573
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
574 574
 				AND spotter_live.date < UTC_TIMESTAMP()';
575 575
 			$query_data = array(':ident' => $ident);
576 576
 		} elseif ($globalDBdriver == 'pgsql') {
577
-			$query  = "SELECT spotter_live.ident FROM spotter_live 
577
+			$query = "SELECT spotter_live.ident FROM spotter_live 
578 578
 				WHERE spotter_live.ident = :ident 
579 579
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
580 580
 				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -583,8 +583,8 @@  discard block
 block discarded – undo
583 583
 		
584 584
 		$sth = $this->db->prepare($query);
585 585
 		$sth->execute($query_data);
586
-		$ident_result='';
587
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
586
+		$ident_result = '';
587
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
588 588
 		{
589 589
 			$ident_result = $row['ident'];
590 590
 		}
@@ -601,13 +601,13 @@  discard block
 block discarded – undo
601 601
 	{
602 602
 		global $globalDBdriver, $globalTimezone;
603 603
 		if ($globalDBdriver == 'mysql') {
604
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
604
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
605 605
 				WHERE spotter_live.ident = :ident 
606 606
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
607 607
 //				AND spotter_live.date < UTC_TIMESTAMP()";
608 608
 			$query_data = array(':ident' => $ident);
609 609
 		} elseif ($globalDBdriver == 'pgsql') {
610
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
610
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
611 611
 				WHERE spotter_live.ident = :ident 
612 612
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
613 613
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -616,8 +616,8 @@  discard block
 block discarded – undo
616 616
 		
617 617
 		$sth = $this->db->prepare($query);
618 618
 		$sth->execute($query_data);
619
-		$ident_result='';
620
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
619
+		$ident_result = '';
620
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
621 621
 		{
622 622
 			$ident_result = $row['flightaware_id'];
623 623
 		}
@@ -634,13 +634,13 @@  discard block
 block discarded – undo
634 634
 	{
635 635
 		global $globalDBdriver, $globalTimezone;
636 636
 		if ($globalDBdriver == 'mysql') {
637
-			$query  = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
637
+			$query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
638 638
 				WHERE spotter_live.ModeS = :modes 
639 639
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
640 640
 //				AND spotter_live.date < UTC_TIMESTAMP()";
641 641
 			$query_data = array(':modes' => $modes);
642 642
 		} elseif ($globalDBdriver == 'pgsql') {
643
-			$query  = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
643
+			$query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
644 644
 				WHERE spotter_live.ModeS = :modes 
645 645
 				AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'";
646 646
 //			//	AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
@@ -649,8 +649,8 @@  discard block
 block discarded – undo
649 649
 		
650 650
 		$sth = $this->db->prepare($query);
651 651
 		$sth->execute($query_data);
652
-		$ident_result='';
653
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
652
+		$ident_result = '';
653
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
654 654
 		{
655 655
 			//$ident_result = $row['spotter_live_id'];
656 656
 			$ident_result = $row['flightaware_id'];
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
 	* @return String success or false
670 670
 	*
671 671
 	*/
672
-	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '')
672
+	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '')
673 673
 	{
674 674
 		global $globalURL, $globalArchive, $globalDebug;
675 675
 		$Common = new Common();
@@ -827,26 +827,26 @@  discard block
 block discarded – undo
827 827
 		}
828 828
   */
829 829
         
830
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
831
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
832
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
833
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
834
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
835
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
836
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
837
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
838
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
839
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
840
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
841
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
842
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
843
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
844
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
845
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
846
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
847
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
848
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
849
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
830
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
831
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
832
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
833
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
834
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
835
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
836
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
837
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
838
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
839
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
840
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
841
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
842
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
843
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
844
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
845
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
846
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
847
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
848
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
849
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
850 850
 
851 851
 /*
852 852
 		if (!isset($airline_array) || count($airline_array) == 0) {
@@ -894,26 +894,26 @@  discard block
 block discarded – undo
894 894
 			$arrival_airport_country = '';
895 895
 		}
896 896
             	
897
-            	if ($squawk == '' || $Common->isInteger($squawk) == false ) $squawk = NULL;
898
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) == false ) $verticalrate = NULL;
899
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) == false ) $groundspeed = 0;
900
-            	if ($heading == '' || $Common->isInteger($heading) == false ) $heading = 0;
897
+            	if ($squawk == '' || $Common->isInteger($squawk) == false) $squawk = NULL;
898
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) == false) $verticalrate = NULL;
899
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) == false) $groundspeed = 0;
900
+            	if ($heading == '' || $Common->isInteger($heading) == false) $heading = 0;
901 901
             	
902
-		$query  = 'INSERT INTO spotter_live (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, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) 
902
+		$query = 'INSERT INTO spotter_live (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, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) 
903 903
 		VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)';
904 904
 
905
-		$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_type' => $aircraft_type,':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,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk,':route_stop' => $route_stop,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country);
905
+		$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_type' => $aircraft_type, ':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, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country);
906 906
 		//$query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_array[0]['name'],':airline_icao' => $airline_array[0]['icao'],':airline_country' => $airline_array[0]['country'],':airline_type' => $airline_array[0]['type'],':aircraft_icao' => $aircraft_icao,':aircraft_type' => $aircraft_array[0]['type'],':aircraft_manufacturer' => $aircraft_array[0]['manufacturer'],':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date);
907 907
 		try {
908 908
 			
909 909
 			$sth = $this->db->prepare($query);
910 910
 			$sth->execute($query_values);
911
-                } catch(PDOException $e) {
911
+                } catch (PDOException $e) {
912 912
                 	return "error : ".$e->getMessage();
913 913
                 }
914 914
 		if (isset($globalArchive) && $globalArchive && $putinarchive && !$noarchive) {
915 915
 		    if ($globalDebug) echo '(Add to SBS archive : ';
916
-		    $result =  $SpotterArchive->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, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
916
+		    $result = $SpotterArchive->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, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country);
917 917
 		    if ($globalDebug) echo $result.')';
918 918
 		}
919 919
 		return "success";
@@ -922,7 +922,7 @@  discard block
 block discarded – undo
922 922
 
923 923
 	public function getOrderBy()
924 924
 	{
925
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC"));
925
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC"));
926 926
 		return $orderby;
927 927
 	}
928 928
 
Please login to merge, or discard this patch.
Braces   +42 added lines, -14 removed lines patch added patch discarded remove patch
@@ -54,7 +54,9 @@  discard block
 block discarded – undo
54 54
 			$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
55 55
 		}
56 56
 
57
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
57
+		if (!isset($globalLiveInterval)) {
58
+			$globalLiveInterval = '200';
59
+		}
58 60
 		if ($globalDBdriver == 'mysql') {
59 61
 			//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
60 62
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -91,7 +93,9 @@  discard block
 block discarded – undo
91 93
 			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
92 94
 		}
93 95
 
94
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
96
+		if (!isset($globalLiveInterval)) {
97
+			$globalLiveInterval = '200';
98
+		}
95 99
 		if ($globalDBdriver == 'mysql') {
96 100
 //			$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate$orderby_query";
97 101
 //			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, a.aircraft_shadow FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate INNER JOIN (SELECT * FROM aircraft) a on spotter_live.aircraft_icao = a.icao';
@@ -149,7 +153,9 @@  discard block
 block discarded – undo
149 153
 			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
150 154
 		}
151 155
 
152
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
156
+		if (!isset($globalLiveInterval)) {
157
+			$globalLiveInterval = '200';
158
+		}
153 159
 		if ($globalDBdriver == 'mysql') {
154 160
             		//$query  = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query;
155 161
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'.$filter_query;
@@ -177,7 +183,9 @@  discard block
 block discarded – undo
177 183
 	{
178 184
 		global $globalDBdriver, $globalLiveInterval;
179 185
 		$Spotter = new Spotter($this->db);
180
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
186
+		if (!isset($globalLiveInterval)) {
187
+			$globalLiveInterval = '200';
188
+		}
181 189
 		$filter_query = '';
182 190
 		if (isset($filter['source'])) {
183 191
 			$filter_query = " AND format_source IN ('".implode(',',$filter['source'])."')";
@@ -197,7 +205,9 @@  discard block
 block discarded – undo
197 205
                         $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
198 206
                         $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
199 207
                         $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
200
-                } else return array();
208
+                } else {
209
+                	return array();
210
+                }
201 211
                 if ($globalDBdriver == 'mysql') {
202 212
         		//$query  = "SELECT spotter_output.* FROM spotter_output WHERE spotter_output.flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
203 213
         		$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query;
@@ -443,7 +453,9 @@  discard block
 block discarded – undo
443 453
 				$i++;
444 454
 				$j++;
445 455
 				if ($j == 30) {
446
-					if ($globalDebug) echo ".";
456
+					if ($globalDebug) {
457
+						echo ".";
458
+					}
447 459
 				    	try {
448 460
 						
449 461
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -795,7 +807,9 @@  discard block
 block discarded – undo
795 807
 			{
796 808
 				return false;
797 809
 			}
798
-		} else $altitude = 0;
810
+		} else {
811
+			$altitude = 0;
812
+		}
799 813
 
800 814
 		if ($heading != '')
801 815
 		{
@@ -813,7 +827,9 @@  discard block
 block discarded – undo
813 827
 			}
814 828
 		}
815 829
 		date_default_timezone_set('UTC');
816
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
830
+		if ($date == '') {
831
+			$date = date("Y-m-d H:i:s", time());
832
+		}
817 833
 
818 834
 /*
819 835
 		//getting the aircraft image
@@ -894,10 +910,18 @@  discard block
 block discarded – undo
894 910
 			$arrival_airport_country = '';
895 911
 		}
896 912
             	
897
-            	if ($squawk == '' || $Common->isInteger($squawk) == false ) $squawk = NULL;
898
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) == false ) $verticalrate = NULL;
899
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) == false ) $groundspeed = 0;
900
-            	if ($heading == '' || $Common->isInteger($heading) == false ) $heading = 0;
913
+            	if ($squawk == '' || $Common->isInteger($squawk) == false ) {
914
+            		$squawk = NULL;
915
+            	}
916
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) == false ) {
917
+            		$verticalrate = NULL;
918
+            	}
919
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) == false ) {
920
+            		$groundspeed = 0;
921
+            	}
922
+            	if ($heading == '' || $Common->isInteger($heading) == false ) {
923
+            		$heading = 0;
924
+            	}
901 925
             	
902 926
 		$query  = 'INSERT INTO spotter_live (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, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) 
903 927
 		VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)';
@@ -912,9 +936,13 @@  discard block
 block discarded – undo
912 936
                 	return "error : ".$e->getMessage();
913 937
                 }
914 938
 		if (isset($globalArchive) && $globalArchive && $putinarchive && !$noarchive) {
915
-		    if ($globalDebug) echo '(Add to SBS archive : ';
939
+		    if ($globalDebug) {
940
+		    	echo '(Add to SBS archive : ';
941
+		    }
916 942
 		    $result =  $SpotterArchive->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, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
917
-		    if ($globalDebug) echo $result.')';
943
+		    if ($globalDebug) {
944
+		    	echo $result.')';
945
+		    }
918 946
 		}
919 947
 		return "success";
920 948
 
Please login to merge, or discard this patch.
require/settings.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 $globalLongitudeMin = '1.0'; //the minimum longitude (east)
30 30
 
31 31
 $globalCenterLatitude = '46.38'; //the latitude center of your coverage area
32
-$globalCenterLongitude = '5.29';//the longitude center of your coverage area
32
+$globalCenterLongitude = '5.29'; //the longitude center of your coverage area
33 33
 
34 34
 $globalLiveZoom = '9'; //default zoom on Live Map
35 35
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 $globalACARS = FALSE;
127 127
 $globalACARSHost = '0.0.0.0'; // Local IP to listen
128 128
 $globalACARSPort = '9999';
129
-$globalACARSArchive = array('10','80','81','82','3F'); // labels of messages to archive
129
+$globalACARSArchive = array('10', '80', '81', '82', '3F'); // labels of messages to archive
130 130
 $globalACARSArchiveKeepMonths = '0';
131 131
 
132 132
 //APRS configuration (for glidernet)
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 //Retrieve Image from externals sources
202 202
 $globalAircraftImageFetch = TRUE;
203 203
 //Sources for Aircraft image
204
-$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters','customsources');
204
+$globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters', 'customsources');
205 205
 // Custom source configuration {registration} will be replaced by aircraft registration (exif get copyright from exif data for each pic)
206 206
 // example of config : $globalAircraftImageCustomSources = array('thumbnail' => 'http://pics.myurl.com/thumbnail/{registration}.jpg','original' => 'http://myurl/original/{registration}.jpg','source_website' => 'https://www.myurl.com', 'source' => 'customsite', 'exif' => true);
207 207
 // ************************
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 //Retrieve schedules from externals sources (set to FALSE for IVAO or if $globalFork = FALSE)
210 210
 $globalSchedulesFetch = TRUE;
211 211
 //Sources for airline schedule if not official airline site
212
-$globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
212
+$globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
213 213
 
214 214
 //Retrieve translation from external sources (set to FALSE for IVAO)
215 215
 $globalTranslationFetch = TRUE;
Please login to merge, or discard this patch.
require/class.METAR.php 3 patches
Indentation   +257 added lines, -257 removed lines patch added patch discarded remove patch
@@ -7,107 +7,107 @@  discard block
 block discarded – undo
7 7
 	public $db;
8 8
 	
9 9
 	protected $texts = Array(
10
-	    'MI' => 'Shallow',
11
-	    'PR' => 'Partial',
12
-	    'BC' => 'Low drifting',
13
-	    'BL' => 'Blowing',
14
-	    'SH' => 'Showers',
15
-	    'TS' => 'Thunderstorm',
16
-	    'FZ' => 'Freezing',
17
-	    'DZ' => 'Drizzle',
18
-	    'RA' => 'Rain',
19
-	    'SN' => 'Snow',
20
-	    'SG' => 'Snow Grains',
21
-	    'IC' => 'Ice crystals',
22
-	    'PL' => 'Ice pellets',
23
-	    'GR' => 'Hail',
24
-	    'GS' => 'Small hail',
25
-	    'UP' => 'Unknown',
26
-	    'BR' => 'Mist',
27
-	    'FG' => 'Fog',
28
-	    'FU' => 'Smoke',
29
-	    'VA' => 'Volcanic ash',
30
-	    'DU' => 'Widespread dust',
31
-	    'SA' => 'Sand',
32
-	    'HZ' => 'Haze',
33
-	    'PY' => 'Spray',
34
-	    'PO' => 'Well developed dust / sand whirls',
35
-	    'SQ' => 'Squalls',
36
-	    'FC' => 'Funnel clouds inc tornadoes or waterspouts',
37
-	    'SS' => 'Sandstorm',
38
-	    'DS' => 'Duststorm'
10
+		'MI' => 'Shallow',
11
+		'PR' => 'Partial',
12
+		'BC' => 'Low drifting',
13
+		'BL' => 'Blowing',
14
+		'SH' => 'Showers',
15
+		'TS' => 'Thunderstorm',
16
+		'FZ' => 'Freezing',
17
+		'DZ' => 'Drizzle',
18
+		'RA' => 'Rain',
19
+		'SN' => 'Snow',
20
+		'SG' => 'Snow Grains',
21
+		'IC' => 'Ice crystals',
22
+		'PL' => 'Ice pellets',
23
+		'GR' => 'Hail',
24
+		'GS' => 'Small hail',
25
+		'UP' => 'Unknown',
26
+		'BR' => 'Mist',
27
+		'FG' => 'Fog',
28
+		'FU' => 'Smoke',
29
+		'VA' => 'Volcanic ash',
30
+		'DU' => 'Widespread dust',
31
+		'SA' => 'Sand',
32
+		'HZ' => 'Haze',
33
+		'PY' => 'Spray',
34
+		'PO' => 'Well developed dust / sand whirls',
35
+		'SQ' => 'Squalls',
36
+		'FC' => 'Funnel clouds inc tornadoes or waterspouts',
37
+		'SS' => 'Sandstorm',
38
+		'DS' => 'Duststorm'
39 39
 	);
40 40
 	
41 41
 	function __construct($dbc = null) {
42
-                $Connection = new Connection($dbc);
43
-                $this->db = $Connection->db;
44
-        }
42
+				$Connection = new Connection($dbc);
43
+				$this->db = $Connection->db;
44
+		}
45 45
 
46
-       public static function check_last_update() {
47
-    		global $globalDBdriver;
48
-    		if ($globalDBdriver == 'mysql') {
46
+	   public static function check_last_update() {
47
+			global $globalDBdriver;
48
+			if ($globalDBdriver == 'mysql') {
49 49
 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_metar' AND value > DATE_SUB(DATE(NOW()), INTERVAL 1 HOUR)";
50 50
 		} else {
51 51
 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_metar' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '1 HOURS'";
52 52
 		}
53
-                try {
54
-                        $Connection = new Connection();
55
-                        $sth = $Connection->db->prepare($query);
56
-                        $sth->execute();
57
-                } catch(PDOException $e) {
58
-                        return "error : ".$e->getMessage();
59
-                }
60
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
61
-                if ($row['nb'] > 0) return false;
62
-                else return true;
63
-        }
53
+				try {
54
+						$Connection = new Connection();
55
+						$sth = $Connection->db->prepare($query);
56
+						$sth->execute();
57
+				} catch(PDOException $e) {
58
+						return "error : ".$e->getMessage();
59
+				}
60
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
61
+				if ($row['nb'] > 0) return false;
62
+				else return true;
63
+		}
64 64
 
65
-        public static function insert_last_update() {
66
-                $query = "DELETE FROM config WHERE name = 'last_update_metar';
65
+		public static function insert_last_update() {
66
+				$query = "DELETE FROM config WHERE name = 'last_update_metar';
67 67
                         INSERT INTO config (name,value) VALUES ('last_update_metar',NOW());";
68
-                try {
69
-                        $Connection = new Connection();
70
-                        $sth = $Connection->db->prepare($query);
71
-                        $sth->execute();
72
-                } catch(PDOException $e) {
73
-                        return "error : ".$e->getMessage();
74
-                }
75
-        }
68
+				try {
69
+						$Connection = new Connection();
70
+						$sth = $Connection->db->prepare($query);
71
+						$sth->execute();
72
+				} catch(PDOException $e) {
73
+						return "error : ".$e->getMessage();
74
+				}
75
+		}
76 76
 
77 77
 
78 78
         
79
-        public function parse($data) {
80
-    		//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
81
-    		$codes = implode('|', array_keys($this->texts));
82
-    		$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
83
-    		//$pieces = explode(' ',$data);
84
-    		$pieces = preg_split('/\s/',$data);
85
-    		$pos = 0;
86
-    		if ($pieces[0] == 'METAR') $pos++;
87
-    		elseif ($pieces[0] == 'SPECI') $pos++;
88
-    		if (strlen($pieces[$pos]) != 4) $pos++;
89
-    		$result['location'] = $pieces[$pos];
90
-    		$pos++;
91
-    		$result['dayofmonth'] = substr($pieces[$pos],0,2);
92
-    		$result['time'] = substr($pieces[$pos],2,4);
93
-    		$c = count($pieces);
94
-    		for($pos++; $pos < $c; $pos++) {
95
-    			$piece = $pieces[$pos];
96
-    			if ($piece == 'RMK') break;
97
-    			if ($piece == 'AUTO') $result['auto'] = true;
98
-    			if ($piece == 'COR') $result['correction'] = true;
99
-    			// Wind Speed
100
-    			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
101
-    				$result['wind']['direction'] = (float)$matches[1];
79
+		public function parse($data) {
80
+			//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
81
+			$codes = implode('|', array_keys($this->texts));
82
+			$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
83
+			//$pieces = explode(' ',$data);
84
+			$pieces = preg_split('/\s/',$data);
85
+			$pos = 0;
86
+			if ($pieces[0] == 'METAR') $pos++;
87
+			elseif ($pieces[0] == 'SPECI') $pos++;
88
+			if (strlen($pieces[$pos]) != 4) $pos++;
89
+			$result['location'] = $pieces[$pos];
90
+			$pos++;
91
+			$result['dayofmonth'] = substr($pieces[$pos],0,2);
92
+			$result['time'] = substr($pieces[$pos],2,4);
93
+			$c = count($pieces);
94
+			for($pos++; $pos < $c; $pos++) {
95
+				$piece = $pieces[$pos];
96
+				if ($piece == 'RMK') break;
97
+				if ($piece == 'AUTO') $result['auto'] = true;
98
+				if ($piece == 'COR') $result['correction'] = true;
99
+				// Wind Speed
100
+				if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
101
+					$result['wind']['direction'] = (float)$matches[1];
102 102
 				$result['wind']['unit'] = $matches[4];
103
-    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
104
-    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
105
-    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
103
+					if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
104
+					elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
105
+					elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
106 106
 				$result['wind']['gust'] = (float)$matches[3];
107 107
 				$result['wind']['unit'] = $matches[4];
108 108
 				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
109 109
 				$result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0;
110
-    			}
110
+				}
111 111
 
112 112
 /*    			if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) {
113 113
     				$result['wind_direction'] = (float)$matches[1];
@@ -124,35 +124,35 @@  discard block
 block discarded – undo
124 124
     				}
125 125
     			}
126 126
     			*/
127
-    			// Temperature
128
-    			if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
129
-    				$temp = (float)$matches[1];
127
+				// Temperature
128
+				if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
129
+					$temp = (float)$matches[1];
130 130
 				if ($matches[1]{0} == 'M') {
131 131
 					$temp = ((float)substr($matches[1], 1)) * -1;
132 132
 				}
133
-    				$result['temperature'] = $temp;
134
-    				$dew = (float)$matches[2];
133
+					$result['temperature'] = $temp;
134
+					$dew = (float)$matches[2];
135 135
 				if ($matches[2]{0} == 'M') {
136 136
 					$dew = ((float)substr($matches[2], 1)) * -1;
137 137
 				}
138 138
 				$result['dew'] = $dew;
139
-    			}
140
-    			// QNH
141
-    			if (preg_match('#^(A|Q)([0-9]{4})$#', $piece, $matches)) {
142
-    			// #^(Q|A)(////|[0-9]{4})( )#
143
-    				if ($matches[1] == 'Q') {
144
-    					// hPa
145
-    					$result['QNH'] = $matches[2];
146
-    				} else {
147
-    					// inHg
148
-    					$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
149 139
 				}
150
-    				/*
140
+				// QNH
141
+				if (preg_match('#^(A|Q)([0-9]{4})$#', $piece, $matches)) {
142
+				// #^(Q|A)(////|[0-9]{4})( )#
143
+					if ($matches[1] == 'Q') {
144
+						// hPa
145
+						$result['QNH'] = $matches[2];
146
+					} else {
147
+						// inHg
148
+						$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
149
+				}
150
+					/*
151 151
     				$result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100);
152 152
     				$result['QNH_format'] = $matches[1] == 'Q' ? 'hPa' : 'inHg';
153 153
     				*/
154
-    			}
155
-                     /*
154
+				}
155
+					 /*
156 156
     			// Wind Direction
157 157
     			if (preg_match('#^([0-9]{3})V([0-9]{3})$#', $piece, $matches)) {
158 158
     				$result['wind_direction'] = $matches[1];
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
     				$result['speed_variable'] = $matches[1];
164 164
     			}
165 165
     			*/
166
-    			// Visibility
167
-    			if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
168
-    				if (isset($matches[3]) && strlen($matches[3]) > 0) {
166
+				// Visibility
167
+				if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
168
+					if (isset($matches[3]) && strlen($matches[3]) > 0) {
169 169
 					$result['visibility'] = (float)$matches[3] * 1609.34;
170 170
 				} else {
171 171
 					if ($matches[1] == '9999') {
@@ -178,26 +178,26 @@  discard block
 block discarded – undo
178 178
 					$result['visibility'] = '> 10000';
179 179
 					$result['weather'] = "CAVOK";
180 180
 				}
181
-    			}
182
-    			// Cloud Coverage
183
-    			if (preg_match('#^(SKC|CLR|FEW|SCT|BKN|OVC|VV)([0-9]{3})(CB|TCU|CU|CI)?$#', $piece, $matches)) {
184
-    				//$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : '');
185
-    				$type = $matches[1];
186
-    				if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear';
187
-    				elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)';
188
-    				elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud';
189
-    				elseif ($type == 'FEW') $cloud['type'] = 'Few';
190
-    				elseif ($type == 'SCT') $cloud['type'] = 'Scattered';
191
-    				elseif ($type == 'BKN') $cloud['type'] = 'Broken';
192
-    				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
193
-    				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
194
-    				$cloud['type_code'] = $type;
195
-    				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
196
-    				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
197
-    				$result['cloud'][] = $cloud;
198
-    			}
199
-    			// RVR
200
-    			 if (preg_match('#^(R.+)/([M|P])?(\d{4})(?:V(\d+)|[UDN])?(FT)?$#', $piece, $matches)) {
181
+				}
182
+				// Cloud Coverage
183
+				if (preg_match('#^(SKC|CLR|FEW|SCT|BKN|OVC|VV)([0-9]{3})(CB|TCU|CU|CI)?$#', $piece, $matches)) {
184
+					//$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : '');
185
+					$type = $matches[1];
186
+					if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear';
187
+					elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)';
188
+					elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud';
189
+					elseif ($type == 'FEW') $cloud['type'] = 'Few';
190
+					elseif ($type == 'SCT') $cloud['type'] = 'Scattered';
191
+					elseif ($type == 'BKN') $cloud['type'] = 'Broken';
192
+					elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
193
+					elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
194
+					$cloud['type_code'] = $type;
195
+					$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
196
+					$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
197
+					$result['cloud'][] = $cloud;
198
+				}
199
+				// RVR
200
+				 if (preg_match('#^(R.+)/([M|P])?(\d{4})(?:V(\d+)|[UDN])?(FT)?$#', $piece, $matches)) {
201 201
 				$rvr['runway'] = $matches[1];
202 202
 				$rvr['assessment'] = $matches[2];
203 203
 				$rvr['rvr'] = $matches[3];
@@ -206,33 +206,33 @@  discard block
 block discarded – undo
206 206
 				$result['RVR'] = $rvr;
207 207
 			}
208 208
     			
209
-    			//if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
210
-    			if (preg_match('#^R(\d{2}[LRC]?)/([\d/])([\d/])([\d/]{2})([\d/]{2})$#', $piece, $matches)) {
211
-    				//print_r($matches);
212
-    				// https://github.com/davidmegginson/metar-taf/blob/master/Metar.php
213
-    				$result['RVR']['runway'] = $matches[1];
214
-        			$result['RVR']['deposits'] = $matches[2];
215
-        			$result['RVR']['extent'] = $matches[3];
216
-        			$result['RVR']['depth'] = $matches[4];
217
-        			$result['RVR']['friction'] = $matches[5];
218
-    			}
219
-    			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
220
-    				//echo $piece;
221
-    				//print_r($matches);
222
-    				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
223
-    				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
209
+				//if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
210
+				if (preg_match('#^R(\d{2}[LRC]?)/([\d/])([\d/])([\d/]{2})([\d/]{2})$#', $piece, $matches)) {
211
+					//print_r($matches);
212
+					// https://github.com/davidmegginson/metar-taf/blob/master/Metar.php
213
+					$result['RVR']['runway'] = $matches[1];
214
+					$result['RVR']['deposits'] = $matches[2];
215
+					$result['RVR']['extent'] = $matches[3];
216
+					$result['RVR']['depth'] = $matches[4];
217
+					$result['RVR']['friction'] = $matches[5];
218
+				}
219
+				if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
220
+					//echo $piece;
221
+					//print_r($matches);
222
+					if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
223
+					else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
224 224
 				if (isset($matches[3])) {
225 225
 					$range = Array(
226
-					    'from' => (float)$matches[2],
227
-					    'to'   => (float)$matches[4],
228
-					    'unit' => $matches[5] ? 'FT' : 'M'
226
+						'from' => (float)$matches[2],
227
+						'to'   => (float)$matches[4],
228
+						'unit' => $matches[5] ? 'FT' : 'M'
229 229
 					);
230 230
 				}
231 231
 				$result['RVR'] = $matches[1];
232 232
 				$result['RVR_range'] = $range;
233
-    			}
234
-    			// Weather
235
-    			if (preg_match($regWeather, $piece, $matches)) {
233
+				}
234
+				// Weather
235
+				if (preg_match($regWeather, $piece, $matches)) {
236 236
 				$text = Array();
237 237
 				switch ($matches[1]) {
238 238
 					case '+':
@@ -255,35 +255,35 @@  discard block
 block discarded – undo
255 255
 				}
256 256
 				if (!isset($result['weather'])) $result['weather'] = implode(' ', $text);
257 257
 				else $result['weather'] = $result['weather'].' / '.implode(' ', $text);
258
-    			}
259
-    		}
260
-    		return $result;
258
+				}
259
+			}
260
+			return $result;
261 261
         
262
-        }
262
+		}
263 263
         
264 264
 	public function getMETAR($icao) {
265
-    		global $globalMETARcycle, $globalDBdriver;
266
-    		if (isset($globalMETARcycle) && $globalMETARcycle) {
267
-            		$query = "SELECT * FROM metar WHERE metar_location = :icao";
268
-                } else {
269
-            		if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
270
-            		elseif ($globalDBdriver == 'pgsql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
271
-                }
272
-                $query_values = array(':icao' => $icao);
273
-                 try {
274
-                        $sth = $this->db->prepare($query);
275
-                        $sth->execute($query_values);
276
-                } catch(PDOException $e) {
277
-                        return "error : ".$e->getMessage();
278
-                }
279
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
280
-                if ((!isset($globalMETARcyle) || $globalMETARcycle === false) && count($all) == 0) {
281
-            		$all = $this->downloadMETAR($icao);
282
-                }
283
-                return $all;
284
-        }
265
+			global $globalMETARcycle, $globalDBdriver;
266
+			if (isset($globalMETARcycle) && $globalMETARcycle) {
267
+					$query = "SELECT * FROM metar WHERE metar_location = :icao";
268
+				} else {
269
+					if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
270
+					elseif ($globalDBdriver == 'pgsql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
271
+				}
272
+				$query_values = array(':icao' => $icao);
273
+				 try {
274
+						$sth = $this->db->prepare($query);
275
+						$sth->execute($query_values);
276
+				} catch(PDOException $e) {
277
+						return "error : ".$e->getMessage();
278
+				}
279
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
280
+				if ((!isset($globalMETARcyle) || $globalMETARcycle === false) && count($all) == 0) {
281
+					$all = $this->downloadMETAR($icao);
282
+				}
283
+				return $all;
284
+		}
285 285
 
286
-       public function addMETAR($location,$metar,$date) {
286
+	   public function addMETAR($location,$metar,$date) {
287 287
 		global $globalDBdriver;
288 288
 		$date = date('Y-m-d H:i:s',strtotime($date));
289 289
 		if ($globalDBdriver == 'mysql') {
@@ -291,98 +291,98 @@  discard block
 block discarded – undo
291 291
 		} else {
292 292
 			$query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);";
293 293
 		}
294
-                $query_values = array(':location' => $location,':date' => $date,':metar' => $metar);
295
-                 try {
296
-                        $sth = $this->db->prepare($query);
297
-                        $sth->execute($query_values);
298
-                } catch(PDOException $e) {
299
-                        return "error : ".$e->getMessage();
300
-                }
301
-        }
294
+				$query_values = array(':location' => $location,':date' => $date,':metar' => $metar);
295
+				 try {
296
+						$sth = $this->db->prepare($query);
297
+						$sth->execute($query_values);
298
+				} catch(PDOException $e) {
299
+						return "error : ".$e->getMessage();
300
+				}
301
+		}
302 302
 
303
-       public function deleteMETAR($id) {
304
-                $query = "DELETE FROM metar WHERE id = :id";
305
-                $query_values = array(':id' => $id);
306
-                 try {
307
-                        $sth = $this->db->prepare($query);
308
-                        $sth->execute($query_values);
309
-                } catch(PDOException $e) {
310
-                        return "error : ".$e->getMessage();
311
-                }
312
-        }
313
-       public function deleteAllMETARLocation() {
314
-                $query = "DELETE FROM metar";
315
-                 try {
316
-                        $sth = $this->db->prepare($query);
317
-                        $sth->execute();
318
-                } catch(PDOException $e) {
319
-                        return "error : ".$e->getMessage();
320
-                }
321
-        }
303
+	   public function deleteMETAR($id) {
304
+				$query = "DELETE FROM metar WHERE id = :id";
305
+				$query_values = array(':id' => $id);
306
+				 try {
307
+						$sth = $this->db->prepare($query);
308
+						$sth->execute($query_values);
309
+				} catch(PDOException $e) {
310
+						return "error : ".$e->getMessage();
311
+				}
312
+		}
313
+	   public function deleteAllMETARLocation() {
314
+				$query = "DELETE FROM metar";
315
+				 try {
316
+						$sth = $this->db->prepare($query);
317
+						$sth->execute();
318
+				} catch(PDOException $e) {
319
+						return "error : ".$e->getMessage();
320
+				}
321
+		}
322 322
         
323
-        public function addMETARCycle() {
324
-    		global $globalDebug, $globalIVAO;
325
-    		if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle...";
326
-    		date_default_timezone_set("UTC");
327
-    		$Common = new Common();
328
-    		if (isset($globalIVAO) && $globalIVAO) {
329
-        		$cycle = $Common->getData('http://wx.ivao.aero/metar.php');
330
-    		} else {
323
+		public function addMETARCycle() {
324
+			global $globalDebug, $globalIVAO;
325
+			if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle...";
326
+			date_default_timezone_set("UTC");
327
+			$Common = new Common();
328
+			if (isset($globalIVAO) && $globalIVAO) {
329
+				$cycle = $Common->getData('http://wx.ivao.aero/metar.php');
330
+			} else {
331 331
 			$cycle = $Common->getData('http://weather.noaa.gov/pub/data/observations/metar/cycles/'.date('H').'Z.TXT');
332
-    		}
333
-    		if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
334
-    		$date = '';
335
-    		foreach(explode("\n",$cycle) as $line) {
336
-    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
337
-    				//echo "date : ".$line."\n";
338
-    				$date = $line;
339
-    			} elseif ($line != '') {
340
-    			    //$this->parse($line);
341
-    			    //echo $line;
342
-    			    if ($date == '') $date = date('Y/m/d H:m');
343
-    			    $pos = 0;
344
-    			    $pieces = preg_split('/\s/',$line);
345
-    			    if ($pieces[0] == 'METAR') $pos++;
346
-    			    if (strlen($pieces[$pos]) != 4) $pos++;
347
-	        	    $location = $pieces[$pos];
348
-	        	    echo $this->addMETAR($location,$line,$date);
349
-    			}
350
-    			//echo $line."\n";
351
-    		}
352
-    		if (isset($globalDebug) && $globalDebug) echo "Done\n";
332
+			}
333
+			if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
334
+			$date = '';
335
+			foreach(explode("\n",$cycle) as $line) {
336
+				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
337
+					//echo "date : ".$line."\n";
338
+					$date = $line;
339
+				} elseif ($line != '') {
340
+					//$this->parse($line);
341
+					//echo $line;
342
+					if ($date == '') $date = date('Y/m/d H:m');
343
+					$pos = 0;
344
+					$pieces = preg_split('/\s/',$line);
345
+					if ($pieces[0] == 'METAR') $pos++;
346
+					if (strlen($pieces[$pos]) != 4) $pos++;
347
+					$location = $pieces[$pos];
348
+					echo $this->addMETAR($location,$line,$date);
349
+				}
350
+				//echo $line."\n";
351
+			}
352
+			if (isset($globalDebug) && $globalDebug) echo "Done\n";
353 353
         
354
-        }
355
-        public function downloadMETAR($icao) {
356
-    		global $globalMETARurl;
357
-    		if ($globalMETARurl == '') return array();
358
-    		date_default_timezone_set("UTC");
359
-    		$Common = new Common();
360
-    		$url = str_replace('{icao}',$icao,$globalMETARurl);
361
-    		$cycle = $Common->getData($url);
362
-    		$date = '';
363
-    		foreach(explode("\n",$cycle) as $line) {
364
-    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
365
-    				echo "date : ".$line."\n";
366
-    				$date = $line;
367
-    			} elseif ($line != '') {
368
-    			    //$this->parse($line);
369
-    			    //echo $line;
370
-    			    if ($date == '') $date = date('Y/m/d H:m');
371
-    			    $pos = 0;
372
-    			    $pieces = preg_split('/\s/',$line);
373
-    			    if ($pieces[0] == 'METAR') $pos++;
374
-    			    if (strlen($pieces[$pos]) != 4) $pos++;
375
-	        	    $location = $pieces[$pos];
376
-	        	    if (strlen($location == 4)) {
377
-	        		$this->addMETAR($location,$line,$date);
378
-	        		return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
379
-	        	    } else return array();
380
-    			}
381
-    			//echo $line."\n";
382
-    		}
383
-    		return array();
354
+		}
355
+		public function downloadMETAR($icao) {
356
+			global $globalMETARurl;
357
+			if ($globalMETARurl == '') return array();
358
+			date_default_timezone_set("UTC");
359
+			$Common = new Common();
360
+			$url = str_replace('{icao}',$icao,$globalMETARurl);
361
+			$cycle = $Common->getData($url);
362
+			$date = '';
363
+			foreach(explode("\n",$cycle) as $line) {
364
+				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
365
+					echo "date : ".$line."\n";
366
+					$date = $line;
367
+				} elseif ($line != '') {
368
+					//$this->parse($line);
369
+					//echo $line;
370
+					if ($date == '') $date = date('Y/m/d H:m');
371
+					$pos = 0;
372
+					$pieces = preg_split('/\s/',$line);
373
+					if ($pieces[0] == 'METAR') $pos++;
374
+					if (strlen($pieces[$pos]) != 4) $pos++;
375
+					$location = $pieces[$pos];
376
+					if (strlen($location == 4)) {
377
+					$this->addMETAR($location,$line,$date);
378
+					return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
379
+					} else return array();
380
+				}
381
+				//echo $line."\n";
382
+			}
383
+			return array();
384 384
         
385
-        }
385
+		}
386 386
 }
387 387
 /*
388 388
 $METAR = new METAR();
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
                         $Connection = new Connection();
55 55
                         $sth = $Connection->db->prepare($query);
56 56
                         $sth->execute();
57
-                } catch(PDOException $e) {
57
+                } catch (PDOException $e) {
58 58
                         return "error : ".$e->getMessage();
59 59
                 }
60 60
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
                         $Connection = new Connection();
70 70
                         $sth = $Connection->db->prepare($query);
71 71
                         $sth->execute();
72
-                } catch(PDOException $e) {
72
+                } catch (PDOException $e) {
73 73
                         return "error : ".$e->getMessage();
74 74
                 }
75 75
         }
@@ -79,34 +79,34 @@  discard block
 block discarded – undo
79 79
         public function parse($data) {
80 80
     		//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
81 81
     		$codes = implode('|', array_keys($this->texts));
82
-    		$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
82
+    		$regWeather = '#^(\+|\-|VC)?('.$codes.')('.$codes.')?$#';
83 83
     		//$pieces = explode(' ',$data);
84
-    		$pieces = preg_split('/\s/',$data);
84
+    		$pieces = preg_split('/\s/', $data);
85 85
     		$pos = 0;
86 86
     		if ($pieces[0] == 'METAR') $pos++;
87 87
     		elseif ($pieces[0] == 'SPECI') $pos++;
88 88
     		if (strlen($pieces[$pos]) != 4) $pos++;
89 89
     		$result['location'] = $pieces[$pos];
90 90
     		$pos++;
91
-    		$result['dayofmonth'] = substr($pieces[$pos],0,2);
92
-    		$result['time'] = substr($pieces[$pos],2,4);
91
+    		$result['dayofmonth'] = substr($pieces[$pos], 0, 2);
92
+    		$result['time'] = substr($pieces[$pos], 2, 4);
93 93
     		$c = count($pieces);
94
-    		for($pos++; $pos < $c; $pos++) {
94
+    		for ($pos++; $pos < $c; $pos++) {
95 95
     			$piece = $pieces[$pos];
96 96
     			if ($piece == 'RMK') break;
97 97
     			if ($piece == 'AUTO') $result['auto'] = true;
98 98
     			if ($piece == 'COR') $result['correction'] = true;
99 99
     			// Wind Speed
100 100
     			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
101
-    				$result['wind']['direction'] = (float)$matches[1];
101
+    				$result['wind']['direction'] = (float) $matches[1];
102 102
 				$result['wind']['unit'] = $matches[4];
103
-    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
104
-    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
105
-    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
106
-				$result['wind']['gust'] = (float)$matches[3];
103
+    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float) $matches[2])*0.51444444444, 2);
104
+    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float) $matches[2])*1000, 2);
105
+    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float) $matches[2]), 2);
106
+				$result['wind']['gust'] = (float) $matches[3];
107 107
 				$result['wind']['unit'] = $matches[4];
108
-				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
109
-				$result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0;
108
+				$result['wind']['min_variation'] = array_key_exists(5, $matches) ? $matches[5] : 0;
109
+				$result['wind']['max_variation'] = array_key_exists(6, $matches) ? $matches[6] : 0;
110 110
     			}
111 111
 
112 112
 /*    			if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) {
@@ -126,14 +126,14 @@  discard block
 block discarded – undo
126 126
     			*/
127 127
     			// Temperature
128 128
     			if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
129
-    				$temp = (float)$matches[1];
129
+    				$temp = (float) $matches[1];
130 130
 				if ($matches[1]{0} == 'M') {
131
-					$temp = ((float)substr($matches[1], 1)) * -1;
131
+					$temp = ((float) substr($matches[1], 1))*-1;
132 132
 				}
133 133
     				$result['temperature'] = $temp;
134
-    				$dew = (float)$matches[2];
134
+    				$dew = (float) $matches[2];
135 135
 				if ($matches[2]{0} == 'M') {
136
-					$dew = ((float)substr($matches[2], 1)) * -1;
136
+					$dew = ((float) substr($matches[2], 1))*-1;
137 137
 				}
138 138
 				$result['dew'] = $dew;
139 139
     			}
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     					$result['QNH'] = $matches[2];
146 146
     				} else {
147 147
     					// inHg
148
-    					$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
148
+    					$result['QNH'] = round(($matches[2]/100)*33.86389, 2);
149 149
 				}
150 150
     				/*
151 151
     				$result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100);
@@ -166,12 +166,12 @@  discard block
 block discarded – undo
166 166
     			// Visibility
167 167
     			if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
168 168
     				if (isset($matches[3]) && strlen($matches[3]) > 0) {
169
-					$result['visibility'] = (float)$matches[3] * 1609.34;
169
+					$result['visibility'] = (float) $matches[3]*1609.34;
170 170
 				} else {
171 171
 					if ($matches[1] == '9999') {
172 172
 						$result['visibility'] = '> 10000';
173 173
 					} else {
174
-						$result['visibility'] = (float)$matches[1];
174
+						$result['visibility'] = (float) $matches[1];
175 175
 					}
176 176
 				}
177 177
 				if (preg_match('#^CAVOK$#', $piece, $matches)) {
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
     				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
193 193
     				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
194 194
     				$cloud['type_code'] = $type;
195
-    				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
195
+    				$cloud['level'] = round(((float) $matches[2])*100*0.3048);
196 196
     				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
197 197
     				$result['cloud'][] = $cloud;
198 198
     			}
@@ -201,8 +201,8 @@  discard block
 block discarded – undo
201 201
 				$rvr['runway'] = $matches[1];
202 202
 				$rvr['assessment'] = $matches[2];
203 203
 				$rvr['rvr'] = $matches[3];
204
-				$rvr['rvr_max'] = array_key_exists(4,$matches) ? $matches[4] : 0;
205
-				$rvr['unit'] = array_key_exists(5,$matches) ? $matches[5] : '';
204
+				$rvr['rvr_max'] = array_key_exists(4, $matches) ? $matches[4] : 0;
205
+				$rvr['unit'] = array_key_exists(5, $matches) ? $matches[5] : '';
206 206
 				$result['RVR'] = $rvr;
207 207
 			}
208 208
     			
@@ -219,12 +219,12 @@  discard block
 block discarded – undo
219 219
     			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
220 220
     				//echo $piece;
221 221
     				//print_r($matches);
222
-    				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
223
-    				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
222
+    				if (isset($matches[5])) $range = array('exact' => (float) $matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
223
+    				else $range = array('exact' => (float) $matches[2], 'unit' => 'M');
224 224
 				if (isset($matches[3])) {
225 225
 					$range = Array(
226
-					    'from' => (float)$matches[2],
227
-					    'to'   => (float)$matches[4],
226
+					    'from' => (float) $matches[2],
227
+					    'to'   => (float) $matches[4],
228 228
 					    'unit' => $matches[5] ? 'FT' : 'M'
229 229
 					);
230 230
 				}
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
                  try {
274 274
                         $sth = $this->db->prepare($query);
275 275
                         $sth->execute($query_values);
276
-                } catch(PDOException $e) {
276
+                } catch (PDOException $e) {
277 277
                         return "error : ".$e->getMessage();
278 278
                 }
279 279
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -283,19 +283,19 @@  discard block
 block discarded – undo
283 283
                 return $all;
284 284
         }
285 285
 
286
-       public function addMETAR($location,$metar,$date) {
286
+       public function addMETAR($location, $metar, $date) {
287 287
 		global $globalDBdriver;
288
-		$date = date('Y-m-d H:i:s',strtotime($date));
288
+		$date = date('Y-m-d H:i:s', strtotime($date));
289 289
 		if ($globalDBdriver == 'mysql') {
290 290
 			$query = "INSERT INTO metar (metar_location,metar_date,metar) VALUES (:location,:date,:metar) ON DUPLICATE KEY UPDATE metar_date = :date, metar = :metar";
291 291
 		} else {
292 292
 			$query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);";
293 293
 		}
294
-                $query_values = array(':location' => $location,':date' => $date,':metar' => $metar);
294
+                $query_values = array(':location' => $location, ':date' => $date, ':metar' => $metar);
295 295
                  try {
296 296
                         $sth = $this->db->prepare($query);
297 297
                         $sth->execute($query_values);
298
-                } catch(PDOException $e) {
298
+                } catch (PDOException $e) {
299 299
                         return "error : ".$e->getMessage();
300 300
                 }
301 301
         }
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
                  try {
307 307
                         $sth = $this->db->prepare($query);
308 308
                         $sth->execute($query_values);
309
-                } catch(PDOException $e) {
309
+                } catch (PDOException $e) {
310 310
                         return "error : ".$e->getMessage();
311 311
                 }
312 312
         }
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
                  try {
316 316
                         $sth = $this->db->prepare($query);
317 317
                         $sth->execute();
318
-                } catch(PDOException $e) {
318
+                } catch (PDOException $e) {
319 319
                         return "error : ".$e->getMessage();
320 320
                 }
321 321
         }
@@ -332,8 +332,8 @@  discard block
 block discarded – undo
332 332
     		}
333 333
     		if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
334 334
     		$date = '';
335
-    		foreach(explode("\n",$cycle) as $line) {
336
-    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
335
+    		foreach (explode("\n", $cycle) as $line) {
336
+    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
337 337
     				//echo "date : ".$line."\n";
338 338
     				$date = $line;
339 339
     			} elseif ($line != '') {
@@ -341,11 +341,11 @@  discard block
 block discarded – undo
341 341
     			    //echo $line;
342 342
     			    if ($date == '') $date = date('Y/m/d H:m');
343 343
     			    $pos = 0;
344
-    			    $pieces = preg_split('/\s/',$line);
344
+    			    $pieces = preg_split('/\s/', $line);
345 345
     			    if ($pieces[0] == 'METAR') $pos++;
346 346
     			    if (strlen($pieces[$pos]) != 4) $pos++;
347 347
 	        	    $location = $pieces[$pos];
348
-	        	    echo $this->addMETAR($location,$line,$date);
348
+	        	    echo $this->addMETAR($location, $line, $date);
349 349
     			}
350 350
     			//echo $line."\n";
351 351
     		}
@@ -357,11 +357,11 @@  discard block
 block discarded – undo
357 357
     		if ($globalMETARurl == '') return array();
358 358
     		date_default_timezone_set("UTC");
359 359
     		$Common = new Common();
360
-    		$url = str_replace('{icao}',$icao,$globalMETARurl);
360
+    		$url = str_replace('{icao}', $icao, $globalMETARurl);
361 361
     		$cycle = $Common->getData($url);
362 362
     		$date = '';
363
-    		foreach(explode("\n",$cycle) as $line) {
364
-    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
363
+    		foreach (explode("\n", $cycle) as $line) {
364
+    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
365 365
     				echo "date : ".$line."\n";
366 366
     				$date = $line;
367 367
     			} elseif ($line != '') {
@@ -369,12 +369,12 @@  discard block
 block discarded – undo
369 369
     			    //echo $line;
370 370
     			    if ($date == '') $date = date('Y/m/d H:m');
371 371
     			    $pos = 0;
372
-    			    $pieces = preg_split('/\s/',$line);
372
+    			    $pieces = preg_split('/\s/', $line);
373 373
     			    if ($pieces[0] == 'METAR') $pos++;
374 374
     			    if (strlen($pieces[$pos]) != 4) $pos++;
375 375
 	        	    $location = $pieces[$pos];
376 376
 	        	    if (strlen($location == 4)) {
377
-	        		$this->addMETAR($location,$line,$date);
377
+	        		$this->addMETAR($location, $line, $date);
378 378
 	        		return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
379 379
 	        	    } else return array();
380 380
     			}
Please login to merge, or discard this patch.
Braces   +94 added lines, -36 removed lines patch added patch discarded remove patch
@@ -58,8 +58,11 @@  discard block
 block discarded – undo
58 58
                         return "error : ".$e->getMessage();
59 59
                 }
60 60
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
61
-                if ($row['nb'] > 0) return false;
62
-                else return true;
61
+                if ($row['nb'] > 0) {
62
+                	return false;
63
+                } else {
64
+                	return true;
65
+                }
63 66
         }
64 67
 
65 68
         public static function insert_last_update() {
@@ -83,9 +86,14 @@  discard block
 block discarded – undo
83 86
     		//$pieces = explode(' ',$data);
84 87
     		$pieces = preg_split('/\s/',$data);
85 88
     		$pos = 0;
86
-    		if ($pieces[0] == 'METAR') $pos++;
87
-    		elseif ($pieces[0] == 'SPECI') $pos++;
88
-    		if (strlen($pieces[$pos]) != 4) $pos++;
89
+    		if ($pieces[0] == 'METAR') {
90
+    			$pos++;
91
+    		} elseif ($pieces[0] == 'SPECI') {
92
+    			$pos++;
93
+    		}
94
+    		if (strlen($pieces[$pos]) != 4) {
95
+    			$pos++;
96
+    		}
89 97
     		$result['location'] = $pieces[$pos];
90 98
     		$pos++;
91 99
     		$result['dayofmonth'] = substr($pieces[$pos],0,2);
@@ -93,16 +101,26 @@  discard block
 block discarded – undo
93 101
     		$c = count($pieces);
94 102
     		for($pos++; $pos < $c; $pos++) {
95 103
     			$piece = $pieces[$pos];
96
-    			if ($piece == 'RMK') break;
97
-    			if ($piece == 'AUTO') $result['auto'] = true;
98
-    			if ($piece == 'COR') $result['correction'] = true;
104
+    			if ($piece == 'RMK') {
105
+    				break;
106
+    			}
107
+    			if ($piece == 'AUTO') {
108
+    				$result['auto'] = true;
109
+    			}
110
+    			if ($piece == 'COR') {
111
+    				$result['correction'] = true;
112
+    			}
99 113
     			// Wind Speed
100 114
     			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
101 115
     				$result['wind']['direction'] = (float)$matches[1];
102 116
 				$result['wind']['unit'] = $matches[4];
103
-    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
104
-    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
105
-    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
117
+    				if ($result['wind']['unit'] == 'KT') {
118
+    					$result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
119
+    				} elseif ($result['wind']['unit'] == 'KPH') {
120
+    					$result['wind']['speed'] = round(((float)$matches[2])*1000,2);
121
+    				} elseif ($result['wind']['unit'] == 'MPS') {
122
+    					$result['wind']['speed'] = round(((float)$matches[2]),2);
123
+    				}
106 124
 				$result['wind']['gust'] = (float)$matches[3];
107 125
 				$result['wind']['unit'] = $matches[4];
108 126
 				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
@@ -183,14 +201,23 @@  discard block
 block discarded – undo
183 201
     			if (preg_match('#^(SKC|CLR|FEW|SCT|BKN|OVC|VV)([0-9]{3})(CB|TCU|CU|CI)?$#', $piece, $matches)) {
184 202
     				//$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : '');
185 203
     				$type = $matches[1];
186
-    				if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear';
187
-    				elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)';
188
-    				elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud';
189
-    				elseif ($type == 'FEW') $cloud['type'] = 'Few';
190
-    				elseif ($type == 'SCT') $cloud['type'] = 'Scattered';
191
-    				elseif ($type == 'BKN') $cloud['type'] = 'Broken';
192
-    				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
193
-    				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
204
+    				if ($type == 'SKC') {
205
+    					$cloud['type'] = 'No cloud/Sky clear';
206
+    				} elseif ($type == 'CLR') {
207
+    					$cloud['type'] = 'No cloud below 12,000ft (3700m)';
208
+    				} elseif ($type == 'NSC') {
209
+    					$cloud['type'] = 'No significant cloud';
210
+    				} elseif ($type == 'FEW') {
211
+    					$cloud['type'] = 'Few';
212
+    				} elseif ($type == 'SCT') {
213
+    					$cloud['type'] = 'Scattered';
214
+    				} elseif ($type == 'BKN') {
215
+    					$cloud['type'] = 'Broken';
216
+    				} elseif ($type == 'OVC') {
217
+    					$cloud['type'] = 'Overcast/Full cloud coverage';
218
+    				} elseif ($type == 'VV') {
219
+    					$cloud['type'] = 'Vertical visibility';
220
+    				}
194 221
     				$cloud['type_code'] = $type;
195 222
     				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
196 223
     				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
@@ -219,8 +246,11 @@  discard block
 block discarded – undo
219 246
     			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
220 247
     				//echo $piece;
221 248
     				//print_r($matches);
222
-    				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
223
-    				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
249
+    				if (isset($matches[5])) {
250
+    					$range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
251
+    				} else {
252
+    					$range = array('exact' => (float)$matches[2], 'unit' => 'M');
253
+    				}
224 254
 				if (isset($matches[3])) {
225 255
 					$range = Array(
226 256
 					    'from' => (float)$matches[2],
@@ -253,8 +283,11 @@  discard block
 block discarded – undo
253 283
 				if (isset($matches[3])) {
254 284
 					$text[] = $this->texts[$matches[3]];
255 285
 				}
256
-				if (!isset($result['weather'])) $result['weather'] = implode(' ', $text);
257
-				else $result['weather'] = $result['weather'].' / '.implode(' ', $text);
286
+				if (!isset($result['weather'])) {
287
+					$result['weather'] = implode(' ', $text);
288
+				} else {
289
+					$result['weather'] = $result['weather'].' / '.implode(' ', $text);
290
+				}
258 291
     			}
259 292
     		}
260 293
     		return $result;
@@ -266,8 +299,11 @@  discard block
 block discarded – undo
266 299
     		if (isset($globalMETARcycle) && $globalMETARcycle) {
267 300
             		$query = "SELECT * FROM metar WHERE metar_location = :icao";
268 301
                 } else {
269
-            		if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
270
-            		elseif ($globalDBdriver == 'pgsql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
302
+            		if ($globalDBdriver == 'mysql') {
303
+            			$query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
304
+            		} elseif ($globalDBdriver == 'pgsql') {
305
+            			$query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
306
+            		}
271 307
                 }
272 308
                 $query_values = array(':icao' => $icao);
273 309
                  try {
@@ -322,7 +358,9 @@  discard block
 block discarded – undo
322 358
         
323 359
         public function addMETARCycle() {
324 360
     		global $globalDebug, $globalIVAO;
325
-    		if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle...";
361
+    		if (isset($globalDebug) && $globalDebug) {
362
+    			echo "Downloading METAR cycle...";
363
+    		}
326 364
     		date_default_timezone_set("UTC");
327 365
     		$Common = new Common();
328 366
     		if (isset($globalIVAO) && $globalIVAO) {
@@ -330,7 +368,9 @@  discard block
 block discarded – undo
330 368
     		} else {
331 369
 			$cycle = $Common->getData('http://weather.noaa.gov/pub/data/observations/metar/cycles/'.date('H').'Z.TXT');
332 370
     		}
333
-    		if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
371
+    		if (isset($globalDebug) && $globalDebug) {
372
+    			echo "Done - Updating DB...";
373
+    		}
334 374
     		$date = '';
335 375
     		foreach(explode("\n",$cycle) as $line) {
336 376
     			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
@@ -339,22 +379,32 @@  discard block
 block discarded – undo
339 379
     			} elseif ($line != '') {
340 380
     			    //$this->parse($line);
341 381
     			    //echo $line;
342
-    			    if ($date == '') $date = date('Y/m/d H:m');
382
+    			    if ($date == '') {
383
+    			    	$date = date('Y/m/d H:m');
384
+    			    }
343 385
     			    $pos = 0;
344 386
     			    $pieces = preg_split('/\s/',$line);
345
-    			    if ($pieces[0] == 'METAR') $pos++;
346
-    			    if (strlen($pieces[$pos]) != 4) $pos++;
387
+    			    if ($pieces[0] == 'METAR') {
388
+    			    	$pos++;
389
+    			    }
390
+    			    if (strlen($pieces[$pos]) != 4) {
391
+    			    	$pos++;
392
+    			    }
347 393
 	        	    $location = $pieces[$pos];
348 394
 	        	    echo $this->addMETAR($location,$line,$date);
349 395
     			}
350 396
     			//echo $line."\n";
351 397
     		}
352
-    		if (isset($globalDebug) && $globalDebug) echo "Done\n";
398
+    		if (isset($globalDebug) && $globalDebug) {
399
+    			echo "Done\n";
400
+    		}
353 401
         
354 402
         }
355 403
         public function downloadMETAR($icao) {
356 404
     		global $globalMETARurl;
357
-    		if ($globalMETARurl == '') return array();
405
+    		if ($globalMETARurl == '') {
406
+    			return array();
407
+    		}
358 408
     		date_default_timezone_set("UTC");
359 409
     		$Common = new Common();
360 410
     		$url = str_replace('{icao}',$icao,$globalMETARurl);
@@ -367,16 +417,24 @@  discard block
 block discarded – undo
367 417
     			} elseif ($line != '') {
368 418
     			    //$this->parse($line);
369 419
     			    //echo $line;
370
-    			    if ($date == '') $date = date('Y/m/d H:m');
420
+    			    if ($date == '') {
421
+    			    	$date = date('Y/m/d H:m');
422
+    			    }
371 423
     			    $pos = 0;
372 424
     			    $pieces = preg_split('/\s/',$line);
373
-    			    if ($pieces[0] == 'METAR') $pos++;
374
-    			    if (strlen($pieces[$pos]) != 4) $pos++;
425
+    			    if ($pieces[0] == 'METAR') {
426
+    			    	$pos++;
427
+    			    }
428
+    			    if (strlen($pieces[$pos]) != 4) {
429
+    			    	$pos++;
430
+    			    }
375 431
 	        	    $location = $pieces[$pos];
376 432
 	        	    if (strlen($location == 4)) {
377 433
 	        		$this->addMETAR($location,$line,$date);
378 434
 	        		return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
379
-	        	    } else return array();
435
+	        	    } else {
436
+	        	    	return array();
437
+	        	    }
380 438
     			}
381 439
     			//echo $line."\n";
382 440
     		}
Please login to merge, or discard this patch.
require/class.Scheduler.php 3 patches
Spacing   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
 	/ @param String $source source of data
26 26
 	*/
27 27
 	
28
-	public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') {
28
+	public function addSchedule($ident, $departure_airport_icao, $departure_airport_time, $arrival_airport_icao, $arrival_airport_time, $source = 'website') {
29 29
 		date_default_timezone_set('UTC');
30
-		$date = date("Y-m-d H:i:s",time());
30
+		$date = date("Y-m-d H:i:s", time());
31 31
 	        //if ($departure_airport_time == '' && $arrival_airport_time == '') exit;
32 32
 	        //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident";
33 33
 	        $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident";
@@ -35,70 +35,70 @@  discard block
 block discarded – undo
35 35
 		 try {
36 36
 			$sth = $this->db->prepare($query);
37 37
 			$sth->execute($query_values);
38
-		} catch(PDOException $e) {
38
+		} catch (PDOException $e) {
39 39
 			return "error : ".$e->getMessage();
40 40
 		}
41 41
 		if ($sth->fetchColumn() > 0) {
42 42
 			if ($departure_airport_time == '' && $arrival_airport_time == '') {
43 43
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
44
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
44
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao);
45 45
 			} elseif ($arrival_airport_time == '') {
46 46
 			    $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";
47
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
47
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao);
48 48
 			} elseif ($departure_airport_time == '') {
49 49
 			    $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";
50
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
50
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time);
51 51
 			} else {
52 52
 			    //$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";
53 53
 			    $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";
54
-			    $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
+			    $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);
55 55
 			}
56 56
 			try {
57 57
 				$sth = $this->db->prepare($query);
58 58
 				$sth->execute($query_values);
59
-			} catch(PDOException $e) {
59
+			} catch (PDOException $e) {
60 60
 				return "error : ".$e->getMessage();
61 61
 			}
62 62
 			if ($sth->fetchColumn() == 0) {
63 63
 				//$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';
64 64
 				if ($departure_airport_time == '' && $arrival_airport_time == '') {
65 65
                             	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
66
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
66
+				    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
67 67
 				} elseif ($arrival_airport_time == '') {
68 68
                             	    $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';
69
-				    $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
+				    $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);
70 70
 				} elseif ($departure_airport_time == '') {
71 71
                             	    $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';
72
-				    $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
+				    $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);
73 73
 				} else {
74 74
                             	    $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';
75
-				    $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
+				    $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);
76 76
 				}
77 77
 				 try {
78 78
 					$sth = $this->db->prepare($query);
79 79
 					$sth->execute($query_values);
80
-				} catch(PDOException $e) {
80
+				} catch (PDOException $e) {
81 81
 					return "error : ".$e->getMessage();
82 82
 				}
83 83
 			} else {
84 84
 				//$query = 'UPDATE schedule SET date_lastseen = :date WHERE ident = :ident';
85 85
 				$query = 'UPDATE routes SET date_lastseen = :date WHERE CallSign = :ident';
86
-				$query_values = array(':ident' => $ident,':date' => $date);
86
+				$query_values = array(':ident' => $ident, ':date' => $date);
87 87
 				 try {
88 88
 					$sth = $this->db->prepare($query);
89 89
 					$sth->execute($query_values);
90
-				} catch(PDOException $e) {
90
+				} catch (PDOException $e) {
91 91
 					return "error : ".$e->getMessage();
92 92
 				}
93 93
 			}
94 94
 		} else {
95 95
 			//$query = 'INSERT INTO  schedule (ident,departure_airport_icao, departure_airport_time, arrival_airport_icao, arrival_airport_time,date_added,source)  VALUES (:ident,:departure_airport_icao,:departure_airport_time,:arrival_airport_icao,:arrival_airport_time,:date,:source)';
96 96
 			$query = 'INSERT INTO  routes (CallSign,FromAirport_ICAO, FromAirport_Time, ToAirport_ICAO, ToAirport_Time,date_added,source)  VALUES (:ident,:departure_airport_icao,:departure_airport_time,:arrival_airport_icao,:arrival_airport_time,:date,:source)';
97
-			$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);
97
+			$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);
98 98
 			 try {
99 99
 				$sth = $this->db->prepare($query);
100 100
 				$sth->execute($query_values);
101
-			} catch(PDOException $e) {
101
+			} catch (PDOException $e) {
102 102
 				return "error : ".$e->getMessage();
103 103
 			}
104 104
 			// FIXME : add to routes
@@ -109,10 +109,10 @@  discard block
 block discarded – undo
109 109
 	public function getSchedule($ident) {
110 110
 	        //$query = "SELECT * FROM schedule WHERE ident = :ident LIMIT 1";
111 111
 	        $Translation = new Translation($this->db);
112
-	        $operator = $Translation->checkTranslation($ident,false);
112
+	        $operator = $Translation->checkTranslation($ident, false);
113 113
 	        if ($ident != $operator) {
114 114
 	    		$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";
115
-	    		$query_values = array(':ident' => $ident,'operator' => $operator);
115
+	    		$query_values = array(':ident' => $ident, 'operator' => $operator);
116 116
 	    	} else {
117 117
 		        $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";
118 118
 	    		$query_values = array(':ident' => $ident);
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		 try {
121 121
 			$sth = $this->db->prepare($query);
122 122
 			$sth->execute($query_values);
123
-		} catch(PDOException $e) {
123
+		} catch (PDOException $e) {
124 124
 			return "error : ".$e->getMessage();
125 125
 		}
126 126
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		 try {
144 144
 			$sth = $this->db->prepare($query);
145 145
 			$sth->execute($query_values);
146
-		} catch(PDOException $e) {
146
+		} catch (PDOException $e) {
147 147
 			return "error : ".$e->getMessage();
148 148
 		}
149 149
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -157,16 +157,16 @@  discard block
 block discarded – undo
157 157
 	* @param String $carrier IATA code
158 158
 	* @return Flight departure and arrival airports and time
159 159
 	*/
160
-	private function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') {
160
+	private function getAirFrance($callsign, $date = 'NOW', $carrier = 'AF') {
161 161
 		$Common = new Common();
162 162
 		$check_date = new Datetime($date);
163
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
164
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
163
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
164
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
165 165
 		$url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym');
166 166
 		$json = $Common->getData($url);
167 167
 	
168 168
 		$parsed_json = json_decode($json);
169
-		if (property_exists($parsed_json,'errors') === false) {
169
+		if (property_exists($parsed_json, 'errors') === false) {
170 170
 			$originLong = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originLong'};
171 171
 			$originShort = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originShort'};
172 172
 			$departureDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'departureDateMedium'};
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
 			$arrivalDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalDateMedium'};
177 177
 			$arrivalTime = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalTime'};
178 178
 
179
-			preg_match('/\((.*?)\)/',$originShort,$originiata);
179
+			preg_match('/\((.*?)\)/', $originShort, $originiata);
180 180
 			$DepartureAirportIata = $originiata[1];
181
-			preg_match('/\((.*?)\)/',$destinationShort,$destinationiata);
181
+			preg_match('/\((.*?)\)/', $destinationShort, $destinationiata);
182 182
 			$ArrivalAirportIata = $destinationiata[1];
183 183
 
184 184
 			/*
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 			$arrivalTime = gmdate('H:i',strtotime($arrivalTime));
188 188
 			*/
189 189
 		
190
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance');
190
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airfrance');
191 191
 		} else return array();
192 192
 	}
193 193
 
@@ -202,8 +202,8 @@  discard block
 block discarded – undo
202 202
 		$Common = new Common();
203 203
 		date_default_timezone_set($globalTimezone);
204 204
 		$check_date = new Datetime($date);
205
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
206
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
205
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
206
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
207 207
 		$url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign;
208 208
 		$json = $Common->getData($url);
209 209
 		$parsed_json = json_decode($json);
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 			$departureTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fstd'};
216 216
 			$arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'};
217 217
 
218
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet');
218
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_easyjet');
219 219
 		} else return array();
220 220
 	}
221 221
 
@@ -226,12 +226,12 @@  discard block
 block discarded – undo
226 226
 	*/
227 227
 	private function getRyanair($callsign) {
228 228
 		$Common = new Common();
229
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
230
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
229
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
230
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
231 231
 		$url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/";
232 232
 		$post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}';
233
-		$headers = array('Content-Type: application/json','Content-Length: ' . strlen($post));
234
-		$json = $Common->getData($url,'post',$post,$headers);
233
+		$headers = array('Content-Type: application/json', 'Content-Length: '.strlen($post));
234
+		$json = $Common->getData($url, 'post', $post, $headers);
235 235
 		$parsed_json = json_decode($json);
236 236
 		if (isset($parsed_json->{'flightInfo'})) {
237 237
 			$flights = $parsed_json->{'flightInfo'};
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 				$ArrivalAirportIata = $parsed_json->{'flightInfo'}[0]->{'arrivalAirport'}->{'iata'}; //name
241 241
 				$departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'};
242 242
 				$arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'};
243
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
243
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
244 244
 			} else return array();
245 245
 		} else return array();
246 246
 	}
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 	*/
253 253
 	private function getSwiss($callsign) {
254 254
 		$Common = new Common();
255
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
256
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
255
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
256
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
257 257
 		$url = "http://www.world-of-swiss.com/fr/routenetwork.json";
258 258
 		$json = $Common->getData($url);
259 259
 		$parsed_json = json_decode($json);
@@ -265,12 +265,12 @@  discard block
 block discarded – undo
265 265
 				if ($flight->{'no'} == "Vol LX ".$numvol) {
266 266
 					$DepartureAirportIata = $flight->{'from'}->{'code'}; //city
267 267
 					$ArrivalAirportIata = $flight->{'to'}->{'code'}; //city
268
-					$departureTime = substr($flight->{'from'}->{'hour'},0,5);
269
-					$arrivalTime = substr($flight->{'to'}->{'hour'},0,5);
268
+					$departureTime = substr($flight->{'from'}->{'hour'},0, 5);
269
+					$arrivalTime = substr($flight->{'to'}->{'hour'},0, 5);
270 270
 				}
271 271
 			}
272 272
 			if (isset($DepartureAirportIata)) {
273
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss');
273
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_swiss');
274 274
 			} else return array();
275 275
 		} else return array();
276 276
 	}
@@ -285,21 +285,21 @@  discard block
 block discarded – undo
285 285
 		global $globalBritishAirwaysKey;
286 286
 		$Common = new Common();
287 287
 		$check_date = new Datetime($date);
288
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
289
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
288
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
289
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
290 290
 		if ($globalBritishAirwaysKey == '') return array();
291 291
 		$url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json";
292 292
 		$headers = array('Client-Key: '.$globalBritishAirwaysKey);
293
-		$json = $Common->getData($url,'get','',$headers);
293
+		$json = $Common->getData($url, 'get', '', $headers);
294 294
 		if ($json == '') return array();
295 295
 		$parsed_json = json_decode($json);
296 296
 		$flights = $parsed_json->{'FlightsResponse'};
297 297
 		if (count($flights) > 0) {
298 298
 			$DepartureAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'DepartureAirport'};
299 299
 			$ArrivalAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ArrivalAirport'};
300
-			$departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
301
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
302
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways');
300
+			$departureTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
301
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
302
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_britishairways');
303 303
 		} else return array();
304 304
 	}
305 305
 
@@ -313,27 +313,27 @@  discard block
 block discarded – undo
313 313
 		global $globalLufthansaKey;
314 314
 		$Common = new Common();
315 315
 		$check_date = new Datetime($date);
316
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
317
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
316
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
317
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
318 318
 		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array();
319 319
 		$url = "https://api.lufthansa.com/v1/oauth/token";
320
-		$post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials');
321
-		$data = $Common->getData($url,'post',$post);
320
+		$post = array('client_id' => $globalLufthansaKey['key'], 'client_secret' => $globalLufthansaKey['secret'], 'grant_type' => 'client_credentials');
321
+		$data = $Common->getData($url, 'post', $post);
322 322
 		$parsed_data = json_decode($data);
323 323
 		if (!isset($parsed_data->{'access_token'})) return array();
324 324
 		$token = $parsed_data->{'access_token'};
325 325
 		
326 326
 		$url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d');
327
-		$headers = array('Authorization: Bearer '.$token,'Accept: application/json');
328
-		$json = $Common->getData($url,'get','',$headers);
327
+		$headers = array('Authorization: Bearer '.$token, 'Accept: application/json');
328
+		$json = $Common->getData($url, 'get', '', $headers);
329 329
 		if ($json == '') return array();
330 330
 		$parsed_json = json_decode($json);
331 331
 		if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) {
332 332
 			$DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'};
333
-			$departureTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'}));
333
+			$departureTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'}));
334 334
 			$ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'};
335
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
336
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa');
335
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
336
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_lufthansa');
337 337
 		} else return array();
338 338
 	}
339 339
 
@@ -347,21 +347,21 @@  discard block
 block discarded – undo
347 347
 		global $globalTransaviaKey;
348 348
 		$Common = new Common();
349 349
 		$check_date = new Datetime($date);
350
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
351
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
350
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
351
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
352 352
 		if ($globalTransaviaKey == '') return array();
353 353
 		$url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
354 354
 		$headers = array('apikey: '.$globalTransaviaKey);
355
-		$json = $Common->getData($url,'get','',$headers);
355
+		$json = $Common->getData($url, 'get', '', $headers);
356 356
 		if ($json == '') return array();
357 357
 		$parsed_json = json_decode($json);
358 358
 		
359 359
 		if (isset($parsed_json->{'data'}[0])) {
360 360
 			$DepartureAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'departureAirport'}->{'locationCode'};
361
-			$departureTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'}));
361
+			$departureTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'}));
362 362
 			$ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'};
363
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
364
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia');
363
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
364
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_transavia');
365 365
 		} else return array();
366 366
 	}
367 367
 
@@ -372,14 +372,14 @@  discard block
 block discarded – undo
372 372
 	*/
373 373
 	private function getTunisair($callsign) {
374 374
 		$Common = new Common();
375
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
376
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
375
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
376
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
377 377
 		$url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp";
378 378
 		$data = $Common->getData($url);
379 379
 		$table = $Common->table2array($data);
380 380
 		foreach ($table as $flight) {
381
-			if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d',$numvol)) {
382
-				return array('DepartureAirportIATA' => $flight[2],'DepartureTime' => str_replace('.',':',$flight[5]),'ArrivalAirportIATA' => $flight[3],'ArrivalTime' => str_replace('.',':',$flight[6]),'Source' => 'website_tunisair');
381
+			if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d', $numvol)) {
382
+				return array('DepartureAirportIATA' => $flight[2], 'DepartureTime' => str_replace('.', ':', $flight[5]), 'ArrivalAirportIATA' => $flight[3], 'ArrivalTime' => str_replace('.', ':', $flight[6]), 'Source' => 'website_tunisair');
383 383
 			}
384 384
 		}
385 385
 		return array();
@@ -392,19 +392,19 @@  discard block
 block discarded – undo
392 392
 	*/
393 393
 	private function getVueling($callsign) {
394 394
 		$Common = new Common();
395
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
396
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
395
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
396
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
397 397
 		$url = "https://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=DailyFlights&OriginSelected=&DestinationSelected=&idioma=en-GB&pageid=30694&ItemsByPage=50&FlightNumberFilter=".$numvol;
398 398
 		$data = $Common->getData($url);
399 399
 		if ($data != '') {
400 400
 			$table = $Common->table2array($data);
401 401
 			foreach ($table as $flight) {
402 402
 				if (count($flight) > 0 && $flight[0] == "VY".$numvol && isset($flight[13])) {
403
-					preg_match('/flightOri=[A-Z]{3}/',$flight[13],$result);
404
-					$DepartureAirportIata = str_replace('flightOri=','',$result[0]);
405
-					preg_match('/flightDest=[A-Z]{3}/',$flight[13],$result);
406
-					$ArrivalAirportIata = str_replace('flightDest=','',$result[0]);
407
-					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $flight[3],'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $flight[4],'Source' => 'website_vueling');
403
+					preg_match('/flightOri=[A-Z]{3}/', $flight[13], $result);
404
+					$DepartureAirportIata = str_replace('flightOri=', '', $result[0]);
405
+					preg_match('/flightDest=[A-Z]{3}/', $flight[13], $result);
406
+					$ArrivalAirportIata = str_replace('flightDest=', '', $result[0]);
407
+					return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $flight[3], 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $flight[4], 'Source' => 'website_vueling');
408 408
 				}
409 409
 			}
410 410
 		}
@@ -419,27 +419,27 @@  discard block
 block discarded – undo
419 419
 	*/
420 420
 	private function getIberia($callsign, $date = 'NOW') {
421 421
 		$Common = new Common();
422
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
422
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
423 423
 		$check_date = new Datetime($date);
424
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
424
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
425 425
 		$url = "https://www.iberia.com/web/flightDetail.do";
426
-		$post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB');
427
-		$data = $Common->getData($url,'post',$post);
426
+		$post = array('numvuelo' => $numvol, 'fecha' => $check_date->format('Ymd'), 'airlineID' => 'IB');
427
+		$data = $Common->getData($url, 'post', $post);
428 428
 		if ($data != '') {
429 429
 			$table = $Common->table2array($data);
430 430
 			//print_r($table);
431 431
 			if (count($table) > 0) {
432 432
 				$flight = $table;
433
-				preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch);
434
-				preg_match('/([A-Z]{3})/',$flight[5][0],$ArrivalAirportIataMatch);
433
+				preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch);
434
+				preg_match('/([A-Z]{3})/', $flight[5][0], $ArrivalAirportIataMatch);
435 435
 				$DepartureAirportIata = $DepartureAirportIataMatch[0];
436 436
 				$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
437
-				$departureTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[3][2]))),0,5);
438
-				$arrivalTime = trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][1])));
437
+				$departureTime = substr(trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[3][2]))), 0, 5);
438
+				$arrivalTime = trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[5][1])));
439 439
 				if ($arrivalTime == 'Hora estimada de llegada') {
440
-					$arrivalTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][2]))),0,5);
441
-				} else $arrivalTime = substr($arrivalTime,0,5);
442
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia');
440
+					$arrivalTime = substr(trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[5][2]))), 0, 5);
441
+				} else $arrivalTime = substr($arrivalTime, 0, 5);
442
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_iberia');
443 443
 			}
444 444
 		}
445 445
 		return array();
@@ -451,11 +451,11 @@  discard block
 block discarded – undo
451 451
 	* @param String $date date we want flight number info
452 452
 	* @return Flight departure and arrival airports and time
453 453
 	*/
454
-	private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') {
454
+	private function getStarAlliance($callsign, $date = 'NOW', $carrier = '') {
455 455
 		$Common = new Common();
456
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
456
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
457 457
 		$check_date = new Datetime($date);
458
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
458
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
459 459
 		$url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y');
460 460
 		$data = $Common->getData($url);
461 461
 		if ($data != '') {
@@ -464,13 +464,13 @@  discard block
 block discarded – undo
464 464
 				$flight = $table;
465 465
 				//print_r($table);
466 466
 				if (isset($flight[25]) && isset($flight[29])) {
467
-					preg_match('/([A-Z]{3})/',$flight[25][1],$DepartureAirportIataMatch);
468
-					preg_match('/([A-Z]{3})/',$flight[25][3],$ArrivalAirportIataMatch);
467
+					preg_match('/([A-Z]{3})/', $flight[25][1], $DepartureAirportIataMatch);
468
+					preg_match('/([A-Z]{3})/', $flight[25][3], $ArrivalAirportIataMatch);
469 469
 					$DepartureAirportIata = $DepartureAirportIataMatch[0];
470 470
 					$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
471
-					$departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5);
472
-					$arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5);
473
-					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance');
471
+					$departureTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][0])), 0, 5);
472
+					$arrivalTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][1])), 0, 5);
473
+					return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_staralliance');
474 474
 				} else return array();
475 475
 			}
476 476
 			
@@ -487,10 +487,10 @@  discard block
 block discarded – undo
487 487
 	*/
488 488
 	private function getAlitalia($callsign, $date = 'NOW') {
489 489
 		$Common = new Common();
490
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
490
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
491 491
 		$check_date = new Datetime($date);
492
-		$url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
493
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
492
+		$url = "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
493
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
494 494
 		$data = $Common->getData($url);
495 495
 		if ($data != '') {
496 496
 			$table = $Common->text2array($data);
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
 			$ArrivalAirportIata = '';
499 499
 			$departureTime = $table[4];
500 500
 			$arrivalTime = $table[5];
501
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_alitalia');
501
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_alitalia');
502 502
 		}
503 503
 	}
504 504
 
@@ -510,11 +510,11 @@  discard block
 block discarded – undo
510 510
 	*/
511 511
 	private function getBrussels($callsign, $date = 'NOW') {
512 512
 		$Common = new Common();
513
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
513
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
514 514
 		$check_date = new Datetime($date);
515
-		$url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
515
+		$url = "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
516 516
 		//http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber";
517
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
517
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
518 518
 		$data = $Common->getData($url);
519 519
 		if ($data != '') {
520 520
 		    //echo $data;
@@ -522,9 +522,9 @@  discard block
 block discarded – undo
522 522
 		    if (isset($parsed_json[0]->FromAirportCode)) {
523 523
 			$DepartureAirportIata = $parsed_json[0]->FromAirportCode;
524 524
 			$ArrivalAirportIata = $parsed_json[0]->ToAirportCode;
525
-			$departureTime = date('H:i',strtotime($parsed_json[0]->ScheduledDepatureDate));
526
-			$arrivalTime = date('H:i',strtotime($parsed_json[0]->ScheduledArrivalDate));
527
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels');
525
+			$departureTime = date('H:i', strtotime($parsed_json[0]->ScheduledDepatureDate));
526
+			$arrivalTime = date('H:i', strtotime($parsed_json[0]->ScheduledArrivalDate));
527
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_brussels');
528 528
 		    }
529 529
 		}
530 530
 	}
@@ -602,21 +602,21 @@  discard block
 block discarded – undo
602 602
 	*/
603 603
 	private function getFlyTap($callsign, $date = 'NOW') {
604 604
 		$Common = new Common();
605
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
606
-		$url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
605
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
606
+		$url = "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
607 607
 		$check_date = new Datetime($date);
608
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
609
-		$post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1');
610
-		$data = $Common->getData($url,'post',$post);
608
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
609
+		$post = array('arrivalsdepartures_content' => 'number', 'arrivalsdepartures_tp' => $numvol, 'arrivalsdepartures_trk' => 'ARR', 'arrivalsdepartures_date_trk' => '1', 'aptCode' => '', 'arrivalsdepartures' => 'DEP', 'arrivalsdepartures_date' => '1', 'aptCodeFrom' => '', 'aptCodeTo' => '', 'arrivalsdepartures2' => 'DEP', 'arrivalsdepartures_date2' => '1');
610
+		$data = $Common->getData($url, 'post', $post);
611 611
 		if ($data != '') {
612 612
 			$table = $Common->table2array($data);
613
-			$departureTime = trim(substr($table[15][0],0,5));
614
-			$arrivalTime = trim(substr($table[35][0],0,5));
615
-			preg_match('/([A-Z]{3})/',$table[11][0],$DepartureAirportIataMatch);
616
-			preg_match('/([A-Z]{3})/',$table[31][0],$ArrivalAirportIataMatch);
613
+			$departureTime = trim(substr($table[15][0], 0, 5));
614
+			$arrivalTime = trim(substr($table[35][0], 0, 5));
615
+			preg_match('/([A-Z]{3})/', $table[11][0], $DepartureAirportIataMatch);
616
+			preg_match('/([A-Z]{3})/', $table[31][0], $ArrivalAirportIataMatch);
617 617
 			$DepartureAirportIata = $DepartureAirportIataMatch[0];
618 618
 			$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
619
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flytap');
619
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flytap');
620 620
 		}
621 621
 		return array();
622 622
 	}
@@ -637,22 +637,22 @@  discard block
 block discarded – undo
637 637
 				$airline_icao = substr($callsign, 0, 3);
638 638
 			} 
639 639
 		}
640
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
641
-		$url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
640
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
641
+		$url = "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
642 642
 		$check_date = new Datetime($date);
643
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
643
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
644 644
 		$data = $Common->getData($url);
645 645
 		if ($data != '') {
646 646
 			$table = $Common->table2array($data);
647 647
 			if (isset($table[5][0])) {
648 648
 				$sched = $table[5][0];
649
-				$n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr);
649
+				$n = sscanf($sched, '%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])', $dhour, $darr, $ahour, $aarr);
650 650
 				if ($n == 7) {
651 651
 				    $departureTime = $dhour;
652 652
 				    $arrivalTime = $ahour;
653
-				    $DepartureAirportIata = str_replace(array('(',')'),'',$darr);
654
-				    $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
655
-				    return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
653
+				    $DepartureAirportIata = str_replace(array('(', ')'), '', $darr);
654
+				    $ArrivalAirportIata = str_replace(array('(', ')'), '', $aarr);
655
+				    return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightmapper');
656 656
 				}
657 657
 			}
658 658
 		}
@@ -675,20 +675,20 @@  discard block
 block discarded – undo
675 675
 				$airline_icao = substr($callsign, 0, 3);
676 676
 			} 
677 677
 		}
678
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
679
-		$url= "http://fr.flightaware.com/live/flight/".$callsign;
678
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
679
+		$url = "http://fr.flightaware.com/live/flight/".$callsign;
680 680
 		$check_date = new Datetime($date);
681
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
681
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
682 682
 		$data = $Common->getData($url);
683 683
 		if ($data != '') {
684 684
 			$table = $Common->table2array($data);
685 685
 			if (isset($table[11][0])) {
686
-				$departureTime = str_replace('h',':',substr($table[5][0],0,5));
687
-				$arrivalTime = str_replace('h',':',substr($table[5][1],0,5));
686
+				$departureTime = str_replace('h', ':', substr($table[5][0], 0, 5));
687
+				$arrivalTime = str_replace('h', ':', substr($table[5][1], 0, 5));
688 688
 				echo $table[3][0];
689
-				sscanf($table[3][0],'%*[^(] (%3[A-Z] / %*4[A-Z])',$DepartureAirportIata);
690
-				sscanf($table[3][1],'%*[^(] (%3[A-Z] / %*4[A-Z])',$ArrivalAirportIata);
691
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightaware');
689
+				sscanf($table[3][0], '%*[^(] (%3[A-Z] / %*4[A-Z])', $DepartureAirportIata);
690
+				sscanf($table[3][1], '%*[^(] (%3[A-Z] / %*4[A-Z])', $ArrivalAirportIata);
691
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightaware');
692 692
 			}
693 693
 		}
694 694
 		return array();
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
 	*/
703 703
 	public function getCostToTravel($callsign, $date = 'NOW') {
704 704
 		$Common = new Common();
705
-		$url= "http://www.costtotravel.com/flight-number/".$callsign;
705
+		$url = "http://www.costtotravel.com/flight-number/".$callsign;
706 706
 		$check_date = new Datetime($date);
707 707
 		//if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
708 708
 		$data = $Common->getData($url);
@@ -710,11 +710,11 @@  discard block
 block discarded – undo
710 710
 			$table = $Common->table2array($data);
711 711
 			//print_r($table);
712 712
 			if (isset($table[11][1])) {
713
-				$departureTime = substr($table[11][1],0,5);
714
-				$arrivalTime = substr($table[17][1],0,5);
715
-				$DepartureAirportIata = substr($table[13][1],0,3);
716
-				$ArrivalAirportIata = substr($table[15][1],0,3);
717
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel');
713
+				$departureTime = substr($table[11][1], 0, 5);
714
+				$arrivalTime = substr($table[17][1], 0, 5);
715
+				$DepartureAirportIata = substr($table[13][1], 0, 3);
716
+				$ArrivalAirportIata = substr($table[15][1], 0, 3);
717
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_costtotravel');
718 718
 			}
719 719
 		}
720 720
 		return array();
@@ -726,13 +726,13 @@  discard block
 block discarded – undo
726 726
 	* @param String $date date we want flight number info
727 727
 	* @return Flight departure and arrival airports and time
728 728
 	*/
729
-	private function getAirCanada($callsign,$date = 'NOW') {
729
+	private function getAirCanada($callsign, $date = 'NOW') {
730 730
 		$Common = new Common();
731 731
 		date_default_timezone_set('UTC');
732 732
 		$check_date = new Datetime($date);
733
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
734
-		$url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
735
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
733
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
734
+		$url = "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
735
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
736 736
 		$data = $Common->getData($url);
737 737
 		$dom = new DomDocument();
738 738
 		$dom->loadXML($data);
@@ -740,11 +740,11 @@  discard block
 block discarded – undo
740 740
 		$departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0);
741 741
 		if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) {
742 742
 			$DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
743
-			$departureTime = date('H:i',strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
743
+			$departureTime = date('H:i', strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
744 744
 			$arrival = $dom->getElementsByTagName('ArrivalStationInfo')->item(0);
745 745
 			$ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
746
-			$arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
747
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada');
746
+			$arrivalTime = date('H:i', strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
747
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_aircanada');
748 748
 		} else return array();
749 749
 	}
750 750
 
@@ -756,21 +756,21 @@  discard block
 block discarded – undo
756 756
 	*/
757 757
 	private function getVietnamAirlines($callsign, $date = 'NOW') {
758 758
 		$Common = new Common();
759
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
759
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
760 760
 		$check_date = new Datetime($date);
761
-		$url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
762
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
761
+		$url = "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
762
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
763 763
 		$data = $Common->getData($url);
764 764
 		if ($data != '') {
765 765
 			$table = $Common->table2array($data);
766 766
 			$flight = $table;
767
-			preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch);
768
-			preg_match('/([A-Z]{3})/',$flight[21][0],$ArrivalAirportIataMatch);
767
+			preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch);
768
+			preg_match('/([A-Z]{3})/', $flight[21][0], $ArrivalAirportIataMatch);
769 769
 			$DepartureAirportIata = $DepartureAirportIataMatch[0];
770 770
 			$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
771 771
 			$departureTime = $flight[5][1];
772 772
 			$arrivalTime = $flight[23][1];
773
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_vietnamairlines');
773
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_vietnamairlines');
774 774
 		}
775 775
 	}
776 776
 
@@ -785,12 +785,12 @@  discard block
 block discarded – undo
785 785
 		$Common = new Common();
786 786
 		date_default_timezone_set('UTC');
787 787
 		//AB = airberlin, HG/NLY = NIKI, 4T/BHP = Belair 
788
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
788
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
789 789
 		$check_date = new Datetime($date);
790
-		$url= "http://www.airberlin.com/en-US/site/aims.php";
791
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
792
-		$post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
793
-		$data = $Common->getData($url,'post',$post);
790
+		$url = "http://www.airberlin.com/en-US/site/aims.php";
791
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
792
+		$post = array('type' => 'departure', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => 'AB');
793
+		$data = $Common->getData($url, 'post', $post);
794 794
 		//echo $data;
795 795
 		$DepartureAirportIata = '';
796 796
 		$ArrivalAirportIata = '';
@@ -803,8 +803,8 @@  discard block
 block discarded – undo
803 803
 			if (isset($flight[5][2])) $departureAirport = $flight[5][2];
804 804
 			else $departureAirport = '';
805 805
 		}
806
-		$post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
807
-		$data = $Common->getData($url,'post',$post);
806
+		$post = array('type' => 'arrival', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => 'AB');
807
+		$data = $Common->getData($url, 'post', $post);
808 808
 		if ($data != '') {
809 809
 			$table = $Common->table2array($data);
810 810
 			$flight = $table;
@@ -832,13 +832,13 @@  discard block
 block discarded – undo
832 832
 			}
833 833
 		}
834 834
 		if (isset($DepartureAirportIata)) {
835
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin');
835
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airberlin');
836 836
 		} else return array();
837 837
 	}
838 838
 
839 839
 
840 840
 	
841
-	public function fetchSchedule($ident,$date = 'NOW') {
841
+	public function fetchSchedule($ident, $date = 'NOW') {
842 842
 		global $globalSchedulesSources, $globalSchedulesFetch;
843 843
 		$Common = new Common();
844 844
 		if (!$globalSchedulesFetch) return array();
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
 				// Brussels Airlines
909 909
 				case "BEL":
910 910
 				case "SN":
911
-					return $this->getBrussels($ident,$date,'SN');
911
+					return $this->getBrussels($ident, $date, 'SN');
912 912
 					break;
913 913
 /*
914 914
 				// Copa Airlines
@@ -971,7 +971,7 @@  discard block
 block discarded – undo
971 971
 				// TAP Portugal
972 972
 				case "TAP":
973 973
 				case "TP":
974
-					return $this->getFlyTap($ident,$date);
974
+					return $this->getFlyTap($ident, $date);
975 975
 					break;
976 976
 /*
977 977
 				// Thai Airways International
@@ -993,19 +993,19 @@  discard block
 block discarded – undo
993 993
 				// Air France
994 994
 				case "AF":
995 995
 				case "AFR":
996
-					return $this->getAirFrance($ident,$date,'AF');
996
+					return $this->getAirFrance($ident, $date, 'AF');
997 997
 					break;
998 998
 				// HOP
999 999
 				case "A5":
1000 1000
 				case "HOP":
1001
-					return $this->getAirFrance($ident,$date,'A5');
1001
+					return $this->getAirFrance($ident, $date, 'A5');
1002 1002
 					break;
1003 1003
 				// EasyJet
1004 1004
 				case "U2":
1005 1005
 				case "DS":
1006 1006
 				case "EZY":
1007 1007
 				case "EZS":
1008
-					return $this->getEasyJet($ident,$date);
1008
+					return $this->getEasyJet($ident, $date);
1009 1009
 					break;
1010 1010
 				// Ryanair
1011 1011
 				case "FR":
@@ -1063,34 +1063,34 @@  discard block
 block discarded – undo
1063 1063
 					break;
1064 1064
 				// Vietnam Airlines
1065 1065
 				case "HVN":
1066
-					return $this->getVietnamAirlines($ident,$date);
1066
+					return $this->getVietnamAirlines($ident, $date);
1067 1067
 					break;
1068 1068
 				// Air Berlin
1069 1069
 				case "AB":
1070 1070
 				case "BER":
1071
-					return $this->getAirBerlin($ident,$date,'AB');
1071
+					return $this->getAirBerlin($ident, $date, 'AB');
1072 1072
 					break;
1073 1073
 				// NIKI
1074 1074
 				case "HG":
1075 1075
 				case "NLY":
1076
-					return $this->getAirBerlin($ident,$date,'HG');
1076
+					return $this->getAirBerlin($ident, $date, 'HG');
1077 1077
 					break;
1078 1078
 				// BelAir
1079 1079
 				case "4T":
1080 1080
 				case "BHP":
1081
-					return $this->getAirBerlin($ident,$date,'4T');
1081
+					return $this->getAirBerlin($ident, $date, '4T');
1082 1082
 					break;
1083 1083
 				default:
1084 1084
 					// Randomly use a generic function to get hours
1085 1085
 					if (strlen($airline_icao) == 2) {
1086
-						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1086
+						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
1087 1087
 						if (count($globalSchedulesSources) > 0) {
1088
-							$rand = mt_rand(0,count($globalSchedulesSources)-1);
1088
+							$rand = mt_rand(0, count($globalSchedulesSources) - 1);
1089 1089
 							$source = $globalSchedulesSources[$rand];
1090
-							if ($source == 'flightmapper') return $this->getFlightMapper($ident,$date);
1091
-							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident,$date);
1090
+							if ($source == 'flightmapper') return $this->getFlightMapper($ident, $date);
1091
+							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident, $date);
1092 1092
 							//elseif ($source == 'flightradar24') return $this->getFlightRadar24($ident,$date);
1093
-							elseif ($source == 'flightaware') return $this->getFlightAware($ident,$date);
1093
+							elseif ($source == 'flightaware') return $this->getFlightAware($ident, $date);
1094 1094
 						}
1095 1095
 					}
1096 1096
 			}
Please login to merge, or discard this patch.
Braces   +150 added lines, -51 removed lines patch added patch discarded remove patch
@@ -126,7 +126,9 @@  discard block
 block discarded – undo
126 126
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
127 127
 		if (count($row) > 0) {
128 128
 			return $row;
129
-		} else return array();
129
+		} else {
130
+			return array();
131
+		}
130 132
 	}
131 133
 
132 134
 	public function checkSchedule($ident) {
@@ -161,7 +163,9 @@  discard block
 block discarded – undo
161 163
 		$Common = new Common();
162 164
 		$check_date = new Datetime($date);
163 165
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
164
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
166
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
167
+			return array();
168
+		}
165 169
 		$url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym');
166 170
 		$json = $Common->getData($url);
167 171
 	
@@ -188,7 +192,9 @@  discard block
 block discarded – undo
188 192
 			*/
189 193
 		
190 194
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance');
191
-		} else return array();
195
+		} else {
196
+			return array();
197
+		}
192 198
 	}
193 199
 
194 200
 	/**
@@ -203,7 +209,9 @@  discard block
 block discarded – undo
203 209
 		date_default_timezone_set($globalTimezone);
204 210
 		$check_date = new Datetime($date);
205 211
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
206
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
212
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
213
+			return array();
214
+		}
207 215
 		$url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign;
208 216
 		$json = $Common->getData($url);
209 217
 		$parsed_json = json_decode($json);
@@ -216,7 +224,9 @@  discard block
 block discarded – undo
216 224
 			$arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'};
217 225
 
218 226
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet');
219
-		} else return array();
227
+		} else {
228
+			return array();
229
+		}
220 230
 	}
221 231
 
222 232
 	/**
@@ -227,7 +237,9 @@  discard block
 block discarded – undo
227 237
 	private function getRyanair($callsign) {
228 238
 		$Common = new Common();
229 239
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
230
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
240
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
241
+			return array();
242
+		}
231 243
 		$url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/";
232 244
 		$post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}';
233 245
 		$headers = array('Content-Type: application/json','Content-Length: ' . strlen($post));
@@ -241,8 +253,12 @@  discard block
 block discarded – undo
241 253
 				$departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'};
242 254
 				$arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'};
243 255
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
244
-			} else return array();
245
-		} else return array();
256
+			} else {
257
+				return array();
258
+			}
259
+		} else {
260
+			return array();
261
+		}
246 262
 	}
247 263
 
248 264
 	/**
@@ -253,7 +269,9 @@  discard block
 block discarded – undo
253 269
 	private function getSwiss($callsign) {
254 270
 		$Common = new Common();
255 271
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
256
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
272
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
273
+			return array();
274
+		}
257 275
 		$url = "http://www.world-of-swiss.com/fr/routenetwork.json";
258 276
 		$json = $Common->getData($url);
259 277
 		$parsed_json = json_decode($json);
@@ -271,8 +289,12 @@  discard block
 block discarded – undo
271 289
 			}
272 290
 			if (isset($DepartureAirportIata)) {
273 291
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss');
274
-			} else return array();
275
-		} else return array();
292
+			} else {
293
+				return array();
294
+			}
295
+		} else {
296
+			return array();
297
+		}
276 298
 	}
277 299
 	
278 300
 	/**
@@ -286,12 +308,18 @@  discard block
 block discarded – undo
286 308
 		$Common = new Common();
287 309
 		$check_date = new Datetime($date);
288 310
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
289
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
290
-		if ($globalBritishAirwaysKey == '') return array();
311
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
312
+			return array();
313
+		}
314
+		if ($globalBritishAirwaysKey == '') {
315
+			return array();
316
+		}
291 317
 		$url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json";
292 318
 		$headers = array('Client-Key: '.$globalBritishAirwaysKey);
293 319
 		$json = $Common->getData($url,'get','',$headers);
294
-		if ($json == '') return array();
320
+		if ($json == '') {
321
+			return array();
322
+		}
295 323
 		$parsed_json = json_decode($json);
296 324
 		$flights = $parsed_json->{'FlightsResponse'};
297 325
 		if (count($flights) > 0) {
@@ -300,7 +328,9 @@  discard block
 block discarded – undo
300 328
 			$departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
301 329
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
302 330
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways');
303
-		} else return array();
331
+		} else {
332
+			return array();
333
+		}
304 334
 	}
305 335
 
306 336
 	/**
@@ -314,19 +344,27 @@  discard block
 block discarded – undo
314 344
 		$Common = new Common();
315 345
 		$check_date = new Datetime($date);
316 346
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
317
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
318
-		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array();
347
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
348
+			return array();
349
+		}
350
+		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') {
351
+			return array();
352
+		}
319 353
 		$url = "https://api.lufthansa.com/v1/oauth/token";
320 354
 		$post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials');
321 355
 		$data = $Common->getData($url,'post',$post);
322 356
 		$parsed_data = json_decode($data);
323
-		if (!isset($parsed_data->{'access_token'})) return array();
357
+		if (!isset($parsed_data->{'access_token'})) {
358
+			return array();
359
+		}
324 360
 		$token = $parsed_data->{'access_token'};
325 361
 		
326 362
 		$url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d');
327 363
 		$headers = array('Authorization: Bearer '.$token,'Accept: application/json');
328 364
 		$json = $Common->getData($url,'get','',$headers);
329
-		if ($json == '') return array();
365
+		if ($json == '') {
366
+			return array();
367
+		}
330 368
 		$parsed_json = json_decode($json);
331 369
 		if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) {
332 370
 			$DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'};
@@ -334,7 +372,9 @@  discard block
 block discarded – undo
334 372
 			$ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'};
335 373
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
336 374
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa');
337
-		} else return array();
375
+		} else {
376
+			return array();
377
+		}
338 378
 	}
339 379
 
340 380
 	/**
@@ -348,12 +388,18 @@  discard block
 block discarded – undo
348 388
 		$Common = new Common();
349 389
 		$check_date = new Datetime($date);
350 390
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
351
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
352
-		if ($globalTransaviaKey == '') return array();
391
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
392
+			return array();
393
+		}
394
+		if ($globalTransaviaKey == '') {
395
+			return array();
396
+		}
353 397
 		$url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
354 398
 		$headers = array('apikey: '.$globalTransaviaKey);
355 399
 		$json = $Common->getData($url,'get','',$headers);
356
-		if ($json == '') return array();
400
+		if ($json == '') {
401
+			return array();
402
+		}
357 403
 		$parsed_json = json_decode($json);
358 404
 		
359 405
 		if (isset($parsed_json->{'data'}[0])) {
@@ -362,7 +408,9 @@  discard block
 block discarded – undo
362 408
 			$ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'};
363 409
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
364 410
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia');
365
-		} else return array();
411
+		} else {
412
+			return array();
413
+		}
366 414
 	}
367 415
 
368 416
 	/**
@@ -373,7 +421,9 @@  discard block
 block discarded – undo
373 421
 	private function getTunisair($callsign) {
374 422
 		$Common = new Common();
375 423
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
376
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
424
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
425
+			return array();
426
+		}
377 427
 		$url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp";
378 428
 		$data = $Common->getData($url);
379 429
 		$table = $Common->table2array($data);
@@ -393,7 +443,9 @@  discard block
 block discarded – undo
393 443
 	private function getVueling($callsign) {
394 444
 		$Common = new Common();
395 445
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
396
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
446
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
447
+			return array();
448
+		}
397 449
 		$url = "https://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=DailyFlights&OriginSelected=&DestinationSelected=&idioma=en-GB&pageid=30694&ItemsByPage=50&FlightNumberFilter=".$numvol;
398 450
 		$data = $Common->getData($url);
399 451
 		if ($data != '') {
@@ -421,7 +473,9 @@  discard block
 block discarded – undo
421 473
 		$Common = new Common();
422 474
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
423 475
 		$check_date = new Datetime($date);
424
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
476
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
477
+			return array();
478
+		}
425 479
 		$url = "https://www.iberia.com/web/flightDetail.do";
426 480
 		$post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB');
427 481
 		$data = $Common->getData($url,'post',$post);
@@ -438,7 +492,9 @@  discard block
 block discarded – undo
438 492
 				$arrivalTime = trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][1])));
439 493
 				if ($arrivalTime == 'Hora estimada de llegada') {
440 494
 					$arrivalTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][2]))),0,5);
441
-				} else $arrivalTime = substr($arrivalTime,0,5);
495
+				} else {
496
+					$arrivalTime = substr($arrivalTime,0,5);
497
+				}
442 498
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia');
443 499
 			}
444 500
 		}
@@ -455,7 +511,9 @@  discard block
 block discarded – undo
455 511
 		$Common = new Common();
456 512
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
457 513
 		$check_date = new Datetime($date);
458
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
514
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
515
+			return array();
516
+		}
459 517
 		$url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y');
460 518
 		$data = $Common->getData($url);
461 519
 		if ($data != '') {
@@ -471,7 +529,9 @@  discard block
 block discarded – undo
471 529
 					$departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5);
472 530
 					$arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5);
473 531
 					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance');
474
-				} else return array();
532
+				} else {
533
+					return array();
534
+				}
475 535
 			}
476 536
 			
477 537
 
@@ -490,7 +550,9 @@  discard block
 block discarded – undo
490 550
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
491 551
 		$check_date = new Datetime($date);
492 552
 		$url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
493
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
553
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
554
+			return array();
555
+		}
494 556
 		$data = $Common->getData($url);
495 557
 		if ($data != '') {
496 558
 			$table = $Common->text2array($data);
@@ -514,7 +576,9 @@  discard block
 block discarded – undo
514 576
 		$check_date = new Datetime($date);
515 577
 		$url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
516 578
 		//http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber";
517
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
579
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
580
+			return array();
581
+		}
518 582
 		$data = $Common->getData($url);
519 583
 		if ($data != '') {
520 584
 		    //echo $data;
@@ -605,7 +669,9 @@  discard block
 block discarded – undo
605 669
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
606 670
 		$url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
607 671
 		$check_date = new Datetime($date);
608
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
672
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
673
+			return array();
674
+		}
609 675
 		$post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1');
610 676
 		$data = $Common->getData($url,'post',$post);
611 677
 		if ($data != '') {
@@ -640,7 +706,9 @@  discard block
 block discarded – undo
640 706
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
641 707
 		$url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
642 708
 		$check_date = new Datetime($date);
643
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
709
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
710
+			return array();
711
+		}
644 712
 		$data = $Common->getData($url);
645 713
 		if ($data != '') {
646 714
 			$table = $Common->table2array($data);
@@ -678,7 +746,9 @@  discard block
 block discarded – undo
678 746
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
679 747
 		$url= "http://fr.flightaware.com/live/flight/".$callsign;
680 748
 		$check_date = new Datetime($date);
681
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
749
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
750
+			return array();
751
+		}
682 752
 		$data = $Common->getData($url);
683 753
 		if ($data != '') {
684 754
 			$table = $Common->table2array($data);
@@ -732,11 +802,15 @@  discard block
 block discarded – undo
732 802
 		$check_date = new Datetime($date);
733 803
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
734 804
 		$url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
735
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
805
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
806
+			return array();
807
+		}
736 808
 		$data = $Common->getData($url);
737 809
 		$dom = new DomDocument();
738 810
 		$dom->loadXML($data);
739
-		if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) return array();
811
+		if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) {
812
+			return array();
813
+		}
740 814
 		$departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0);
741 815
 		if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) {
742 816
 			$DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
@@ -745,7 +819,9 @@  discard block
 block discarded – undo
745 819
 			$ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
746 820
 			$arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
747 821
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada');
748
-		} else return array();
822
+		} else {
823
+			return array();
824
+		}
749 825
 	}
750 826
 
751 827
 	/**
@@ -759,7 +835,9 @@  discard block
 block discarded – undo
759 835
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
760 836
 		$check_date = new Datetime($date);
761 837
 		$url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
762
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
838
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
839
+			return array();
840
+		}
763 841
 		$data = $Common->getData($url);
764 842
 		if ($data != '') {
765 843
 			$table = $Common->table2array($data);
@@ -788,7 +866,9 @@  discard block
 block discarded – undo
788 866
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
789 867
 		$check_date = new Datetime($date);
790 868
 		$url= "http://www.airberlin.com/en-US/site/aims.php";
791
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
869
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
870
+			return array();
871
+		}
792 872
 		$post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
793 873
 		$data = $Common->getData($url,'post',$post);
794 874
 		//echo $data;
@@ -798,10 +878,16 @@  discard block
 block discarded – undo
798 878
 		if ($data != '') {
799 879
 			$table = $Common->table2array($data);
800 880
 			$flight = $table;
801
-			if (isset($flight[5][4])) $departureTime = $flight[5][4];
802
-			else $departureTime = '';
803
-			if (isset($flight[5][2])) $departureAirport = $flight[5][2];
804
-			else $departureAirport = '';
881
+			if (isset($flight[5][4])) {
882
+				$departureTime = $flight[5][4];
883
+			} else {
884
+				$departureTime = '';
885
+			}
886
+			if (isset($flight[5][2])) {
887
+				$departureAirport = $flight[5][2];
888
+			} else {
889
+				$departureAirport = '';
890
+			}
805 891
 		}
806 892
 		$post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
807 893
 		$data = $Common->getData($url,'post',$post);
@@ -818,7 +904,9 @@  discard block
 block discarded – undo
818 904
 		}
819 905
 		$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';
820 906
 		$json = $Common->getData($url);
821
-		if ($json == '') return array();
907
+		if ($json == '') {
908
+			return array();
909
+		}
822 910
 		$parsed_json = json_decode($json);
823 911
 		$airports = $parsed_json->{'suggestList'};
824 912
 		if (count($airports) > 0) {
@@ -833,7 +921,9 @@  discard block
 block discarded – undo
833 921
 		}
834 922
 		if (isset($DepartureAirportIata)) {
835 923
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin');
836
-		} else return array();
924
+		} else {
925
+			return array();
926
+		}
837 927
 	}
838 928
 
839 929
 
@@ -841,7 +931,9 @@  discard block
 block discarded – undo
841 931
 	public function fetchSchedule($ident,$date = 'NOW') {
842 932
 		global $globalSchedulesSources, $globalSchedulesFetch;
843 933
 		$Common = new Common();
844
-		if (!$globalSchedulesFetch) return array();
934
+		if (!$globalSchedulesFetch) {
935
+			return array();
936
+		}
845 937
 		$airline_icao = '';
846 938
 		if (!is_numeric(substr($ident, 0, 3)))
847 939
 		{
@@ -1083,14 +1175,21 @@  discard block
 block discarded – undo
1083 1175
 				default:
1084 1176
 					// Randomly use a generic function to get hours
1085 1177
 					if (strlen($airline_icao) == 2) {
1086
-						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1178
+						if (!isset($globalSchedulesSources)) {
1179
+							$globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1180
+						}
1087 1181
 						if (count($globalSchedulesSources) > 0) {
1088 1182
 							$rand = mt_rand(0,count($globalSchedulesSources)-1);
1089 1183
 							$source = $globalSchedulesSources[$rand];
1090
-							if ($source == 'flightmapper') return $this->getFlightMapper($ident,$date);
1091
-							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident,$date);
1184
+							if ($source == 'flightmapper') {
1185
+								return $this->getFlightMapper($ident,$date);
1186
+							} elseif ($source == 'costtotravel') {
1187
+								return $this->getCostToTravel($ident,$date);
1188
+							}
1092 1189
 							//elseif ($source == 'flightradar24') return $this->getFlightRadar24($ident,$date);
1093
-							elseif ($source == 'flightaware') return $this->getFlightAware($ident,$date);
1190
+							elseif ($source == 'flightaware') {
1191
+								return $this->getFlightAware($ident,$date);
1192
+							}
1094 1193
 						}
1095 1194
 					}
1096 1195
 			}
Please login to merge, or discard this 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.Source.php 2 patches
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -7,73 +7,73 @@
 block discarded – undo
7 7
 	function __construct($dbc = null) {
8 8
 		$Connection = new Connection($dbc);
9 9
 		$this->db = $Connection->db;
10
-        }
11
-       public function getAllLocationInfo() {
12
-                $query = "SELECT * FROM source_location";
13
-                $query_values = array();
14
-                 try {
15
-                        $sth = $this->db->prepare($query);
16
-                        $sth->execute($query_values);
17
-                } catch(PDOException $e) {
18
-                        return "error : ".$e->getMessage();
19
-                }
20
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
21
-                return $all;
22
-        }
23
-       public function getLocationInfobyName($name) {
24
-                $query = "SELECT * FROM source_location WHERE name = :name";
25
-                $query_values = array(':name' => $name);
26
-                 try {
27
-                        $sth = $this->db->prepare($query);
28
-                        $sth->execute($query_values);
29
-                } catch(PDOException $e) {
30
-                        return "error : ".$e->getMessage();
31
-                }
32
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
33
-                return $all;
34
-        }
35
-       public function getLocationInfobySourceName($name) {
36
-                $query = "SELECT * FROM source_location WHERE source = :name";
37
-                $query_values = array(':name' => $name);
38
-                 try {
39
-                        $sth = $this->db->prepare($query);
40
-                        $sth->execute($query_values);
41
-                } catch(PDOException $e) {
42
-                        return "error : ".$e->getMessage();
43
-                }
44
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
45
-                return $all;
46
-        }
10
+		}
11
+	   public function getAllLocationInfo() {
12
+				$query = "SELECT * FROM source_location";
13
+				$query_values = array();
14
+				 try {
15
+						$sth = $this->db->prepare($query);
16
+						$sth->execute($query_values);
17
+				} catch(PDOException $e) {
18
+						return "error : ".$e->getMessage();
19
+				}
20
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
21
+				return $all;
22
+		}
23
+	   public function getLocationInfobyName($name) {
24
+				$query = "SELECT * FROM source_location WHERE name = :name";
25
+				$query_values = array(':name' => $name);
26
+				 try {
27
+						$sth = $this->db->prepare($query);
28
+						$sth->execute($query_values);
29
+				} catch(PDOException $e) {
30
+						return "error : ".$e->getMessage();
31
+				}
32
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
33
+				return $all;
34
+		}
35
+	   public function getLocationInfobySourceName($name) {
36
+				$query = "SELECT * FROM source_location WHERE source = :name";
37
+				$query_values = array(':name' => $name);
38
+				 try {
39
+						$sth = $this->db->prepare($query);
40
+						$sth->execute($query_values);
41
+				} catch(PDOException $e) {
42
+						return "error : ".$e->getMessage();
43
+				}
44
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
45
+				return $all;
46
+		}
47 47
   
48
-       public function addLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png') {
49
-                $query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source)";
50
-                $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source);
51
-                 try {
52
-                        $sth = $this->db->prepare($query);
53
-                        $sth->execute($query_values);
54
-                } catch(PDOException $e) {
55
-                        return "error : ".$e->getMessage();
56
-                }
57
-        }
48
+	   public function addLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png') {
49
+				$query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source)";
50
+				$query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source);
51
+				 try {
52
+						$sth = $this->db->prepare($query);
53
+						$sth->execute($query_values);
54
+				} catch(PDOException $e) {
55
+						return "error : ".$e->getMessage();
56
+				}
57
+		}
58 58
 
59
-       public function deleteLocation($id) {
60
-                $query = "DELETE FROM source_location WHERE id = :id";
61
-                $query_values = array(':id' => $id);
62
-                 try {
63
-                        $sth = $this->db->prepare($query);
64
-                        $sth->execute($query_values);
65
-                } catch(PDOException $e) {
66
-                        return "error : ".$e->getMessage();
67
-                }
68
-        }
69
-       public function deleteAllLocation() {
70
-                $query = "DELETE FROM source_location";
71
-                 try {
72
-                        $sth = $this->db->prepare($query);
73
-                        $sth->execute();
74
-                } catch(PDOException $e) {
75
-                        return "error : ".$e->getMessage();
76
-                }
77
-        }
59
+	   public function deleteLocation($id) {
60
+				$query = "DELETE FROM source_location WHERE id = :id";
61
+				$query_values = array(':id' => $id);
62
+				 try {
63
+						$sth = $this->db->prepare($query);
64
+						$sth->execute($query_values);
65
+				} catch(PDOException $e) {
66
+						return "error : ".$e->getMessage();
67
+				}
68
+		}
69
+	   public function deleteAllLocation() {
70
+				$query = "DELETE FROM source_location";
71
+				 try {
72
+						$sth = $this->db->prepare($query);
73
+						$sth->execute();
74
+				} catch(PDOException $e) {
75
+						return "error : ".$e->getMessage();
76
+				}
77
+		}
78 78
 }
79 79
 ?>
80 80
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
                  try {
15 15
                         $sth = $this->db->prepare($query);
16 16
                         $sth->execute($query_values);
17
-                } catch(PDOException $e) {
17
+                } catch (PDOException $e) {
18 18
                         return "error : ".$e->getMessage();
19 19
                 }
20 20
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
                  try {
27 27
                         $sth = $this->db->prepare($query);
28 28
                         $sth->execute($query_values);
29
-                } catch(PDOException $e) {
29
+                } catch (PDOException $e) {
30 30
                         return "error : ".$e->getMessage();
31 31
                 }
32 32
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -38,20 +38,20 @@  discard block
 block discarded – undo
38 38
                  try {
39 39
                         $sth = $this->db->prepare($query);
40 40
                         $sth->execute($query_values);
41
-                } catch(PDOException $e) {
41
+                } catch (PDOException $e) {
42 42
                         return "error : ".$e->getMessage();
43 43
                 }
44 44
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
45 45
                 return $all;
46 46
         }
47 47
   
48
-       public function addLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png') {
48
+       public function addLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png') {
49 49
                 $query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source)";
50
-                $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source);
50
+                $query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source);
51 51
                  try {
52 52
                         $sth = $this->db->prepare($query);
53 53
                         $sth->execute($query_values);
54
-                } catch(PDOException $e) {
54
+                } catch (PDOException $e) {
55 55
                         return "error : ".$e->getMessage();
56 56
                 }
57 57
         }
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
                  try {
63 63
                         $sth = $this->db->prepare($query);
64 64
                         $sth->execute($query_values);
65
-                } catch(PDOException $e) {
65
+                } catch (PDOException $e) {
66 66
                         return "error : ".$e->getMessage();
67 67
                 }
68 68
         }
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
                  try {
72 72
                         $sth = $this->db->prepare($query);
73 73
                         $sth->execute();
74
-                } catch(PDOException $e) {
74
+                } catch (PDOException $e) {
75 75
                         return "error : ".$e->getMessage();
76 76
                 }
77 77
         }
Please login to merge, or discard this patch.
require/libs/geoPHP/tests/tests/20120702Test.php 2 patches
Indentation   +268 added lines, -268 removed lines patch added patch discarded remove patch
@@ -9,281 +9,281 @@
 block discarded – undo
9 9
   }
10 10
 
11 11
   function testMethods() {
12
-    $format = 'gpx';
13
-    $value = file_get_contents('./input/20120702.gpx');
14
-    $geometry = geoPHP::load($value, $format);
12
+	$format = 'gpx';
13
+	$value = file_get_contents('./input/20120702.gpx');
14
+	$geometry = geoPHP::load($value, $format);
15 15
 
16
-    $methods = array(
17
-      array('name' => 'area'),
18
-      array('name' => 'boundary'),
19
-      array('name' => 'getBBox'),
20
-      array('name' => 'centroid'),
21
-      array('name' => 'length'),
22
-      array('name' => 'greatCircleLength', 'argument' => 6378137),
23
-      array('name' => 'haversineLength'),
24
-      array('name' => 'y'),
25
-      array('name' => 'x'),
26
-      array('name' => 'numGeometries'),
27
-      array('name' => 'geometryN', 'argument' => '1'),
28
-      array('name' => 'startPoint'),
29
-      array('name' => 'endPoint'),
30
-      array('name' => 'isRing'),
31
-      array('name' => 'isClosed'),
32
-      array('name' => 'numPoints'),
33
-      array('name' => 'pointN', 'argument' => '1'),
34
-      array('name' => 'exteriorRing'),
35
-      array('name' => 'numInteriorRings'),
36
-      array('name' => 'interiorRingN', 'argument' => '1'),
37
-      array('name' => 'dimension'),
38
-      array('name' => 'geometryType'),
39
-      array('name' => 'SRID'),
40
-      array('name' => 'setSRID', 'argument' => '4326'),
41
-    );
16
+	$methods = array(
17
+	  array('name' => 'area'),
18
+	  array('name' => 'boundary'),
19
+	  array('name' => 'getBBox'),
20
+	  array('name' => 'centroid'),
21
+	  array('name' => 'length'),
22
+	  array('name' => 'greatCircleLength', 'argument' => 6378137),
23
+	  array('name' => 'haversineLength'),
24
+	  array('name' => 'y'),
25
+	  array('name' => 'x'),
26
+	  array('name' => 'numGeometries'),
27
+	  array('name' => 'geometryN', 'argument' => '1'),
28
+	  array('name' => 'startPoint'),
29
+	  array('name' => 'endPoint'),
30
+	  array('name' => 'isRing'),
31
+	  array('name' => 'isClosed'),
32
+	  array('name' => 'numPoints'),
33
+	  array('name' => 'pointN', 'argument' => '1'),
34
+	  array('name' => 'exteriorRing'),
35
+	  array('name' => 'numInteriorRings'),
36
+	  array('name' => 'interiorRingN', 'argument' => '1'),
37
+	  array('name' => 'dimension'),
38
+	  array('name' => 'geometryType'),
39
+	  array('name' => 'SRID'),
40
+	  array('name' => 'setSRID', 'argument' => '4326'),
41
+	);
42 42
 
43
-    foreach($methods as $method) {
44
-      $argument = NULL;
45
-      $method_name = $method['name'];
46
-      if (isset($method['argument'])) {
47
-        $argument = $method['argument'];
48
-      }
49
-      $this->_methods_tester($geometry, $method_name, $argument);
50
-    }
43
+	foreach($methods as $method) {
44
+	  $argument = NULL;
45
+	  $method_name = $method['name'];
46
+	  if (isset($method['argument'])) {
47
+		$argument = $method['argument'];
48
+	  }
49
+	  $this->_methods_tester($geometry, $method_name, $argument);
50
+	}
51 51
   }
52 52
 
53 53
   function _methods_tester($geometry, $method_name, $argument) {
54 54
 
55
-    if (!method_exists($geometry, $method_name)) {
56
-      $this->fail("Method ".$method_name.'() doesn\'t exists.');
57
-      return;
58
-    }
55
+	if (!method_exists($geometry, $method_name)) {
56
+	  $this->fail("Method ".$method_name.'() doesn\'t exists.');
57
+	  return;
58
+	}
59 59
 
60
-    switch ($method_name) {
61
-      case 'y':
62
-      case 'x':
63
-        if ($geometry->geometryType() == 'Point') {
64
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
65
-        }
66
-        if ($geometry->geometryType() == 'LineString') {
67
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
68
-        }
69
-        if ($geometry->geometryType() == 'MultiLineString') {
70
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
71
-        }
72
-        break;
73
-      case 'geometryN':
74
-        if ($geometry->geometryType() == 'Point') {
75
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
76
-        }
77
-        if ($geometry->geometryType() == 'LineString') {
78
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
79
-        }
80
-        if ($geometry->geometryType() == 'MultiLineString') {
81
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
82
-        }
83
-        break;
84
-      case 'startPoint':
85
-        if ($geometry->geometryType() == 'Point') {
86
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
87
-        }
88
-        if ($geometry->geometryType() == 'LineString') {
89
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
90
-        }
91
-        if ($geometry->geometryType() == 'MultiLineString') {
92
-          //TODO: Add a method startPoint() to MultiLineString.
93
-          //$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
94
-        }
95
-        break;
96
-      case 'endPoint':
97
-        if ($geometry->geometryType() == 'Point') {
98
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
99
-        }
100
-        if ($geometry->geometryType() == 'LineString') {
101
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
102
-        }
103
-        if ($geometry->geometryType() == 'MultiLineString') {
104
-          //TODO: Add a method endPoint() to MultiLineString.
105
-          //$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
106
-        }
107
-        break;
108
-      case 'isRing':
109
-        if ($geometry->geometryType() == 'Point') {
110
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
111
-        }
112
-        if ($geometry->geometryType() == 'LineString') {
113
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
114
-        }
115
-        if ($geometry->geometryType() == 'MultiLineString') {
116
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
117
-        }
118
-        break;
119
-      case 'isClosed':
120
-        if ($geometry->geometryType() == 'Point') {
121
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
122
-        }
123
-        if ($geometry->geometryType() == 'LineString') {
124
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
125
-        }
126
-        if ($geometry->geometryType() == 'MultiLineString') {
127
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
128
-        }
129
-        break;
130
-      case 'pointN':
131
-        if ($geometry->geometryType() == 'Point') {
132
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
133
-        }
134
-        if ($geometry->geometryType() == 'LineString') {
135
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
136
-        }
137
-        if ($geometry->geometryType() == 'MultiLineString') {
138
-          //TODO: Add a method pointN() to MultiLineString.
139
-          //$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
140
-        }
141
-        break;
142
-      case 'exteriorRing':
143
-        if ($geometry->geometryType() == 'Point') {
144
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
145
-        }
146
-        if ($geometry->geometryType() == 'LineString') {
147
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
148
-        }
149
-        if ($geometry->geometryType() == 'MultiLineString') {
150
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
151
-        }
152
-        break;
153
-      case 'numInteriorRings':
154
-        if ($geometry->geometryType() == 'Point') {
155
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
156
-        }
157
-        if ($geometry->geometryType() == 'LineString') {
158
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
159
-        }
160
-        if ($geometry->geometryType() == 'MultiLineString') {
161
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
162
-        }
163
-        break;
164
-      case 'interiorRingN':
165
-        if ($geometry->geometryType() == 'Point') {
166
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
167
-        }
168
-        if ($geometry->geometryType() == 'LineString') {
169
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
170
-        }
171
-        if ($geometry->geometryType() == 'MultiLineString') {
172
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
173
-        }
174
-        break;
175
-      case 'setSRID':
176
-        //TODO: The method setSRID() should return TRUE.
177
-        break;
178
-      case 'SRID':
179
-        if ($geometry->geometryType() == 'Point') {
180
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
181
-        }
182
-        if ($geometry->geometryType() == 'LineString') {
183
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
184
-        }
185
-        if ($geometry->geometryType() == 'MultiLineString') {
186
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
187
-        }
188
-        break;
189
-      case 'getBBox':
190
-        if ($geometry->geometryType() == 'Point') {
191
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
192
-        }
193
-        if ($geometry->geometryType() == 'LineString') {
194
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
195
-        }
196
-        if ($geometry->geometryType() == 'MultiLineString') {
197
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
198
-        }
199
-        break;
200
-      case 'centroid':
201
-        if ($geometry->geometryType() == 'Point') {
202
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
203
-        }
204
-        if ($geometry->geometryType() == 'LineString') {
205
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
206
-        }
207
-        if ($geometry->geometryType() == 'MultiLineString') {
208
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
209
-        }
210
-        break;
211
-      case 'length':
212
-        if ($geometry->geometryType() == 'Point') {
213
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
214
-        }
215
-        if ($geometry->geometryType() == 'LineString') {
216
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
217
-        }
218
-        if ($geometry->geometryType() == 'MultiLineString') {
219
-          $this->assertEquals($geometry->$method_name($argument), (float) '0.11624637315233', 'Failed on ' . $method_name);
220
-        }
221
-        break;
222
-      case 'numGeometries':
223
-        if ($geometry->geometryType() == 'Point') {
224
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
225
-        }
226
-        if ($geometry->geometryType() == 'LineString') {
227
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
228
-        }
229
-        if ($geometry->geometryType() == 'MultiLineString') {
230
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
231
-        }
232
-        break;
233
-      case 'numPoints':
234
-        if ($geometry->geometryType() == 'Point') {
235
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
236
-        }
237
-        if ($geometry->geometryType() == 'LineString') {
238
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
239
-        }
240
-        if ($geometry->geometryType() == 'MultiLineString') {
241
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
242
-        }
243
-        break;
244
-      case 'dimension':
245
-        if ($geometry->geometryType() == 'Point') {
246
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
247
-        }
248
-        if ($geometry->geometryType() == 'LineString') {
249
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
250
-        }
251
-        if ($geometry->geometryType() == 'MultiLineString') {
252
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
253
-        }
254
-        break;
255
-      case 'boundary':
256
-        if ($geometry->geometryType() == 'Point') {
257
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
258
-        }
259
-        if ($geometry->geometryType() == 'LineString') {
260
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
261
-        }
262
-        if ($geometry->geometryType() == 'MultiLineString') {
263
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
264
-        }
265
-        break;
266
-      case 'greatCircleLength':
267
-        if ($geometry->geometryType() == 'Point') {
268
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
269
-        }
270
-        if ($geometry->geometryType() == 'LineString') {
271
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
272
-        }
273
-        if ($geometry->geometryType() == 'MultiLineString') {
274
-          $this->assertNotEquals($geometry->$method_name($argument), '9500.9359867418', 'Failed on ' . $method_name);
275
-        }
276
-        break;
277
-      case 'haversineLength':
278
-      case 'area':
279
-        $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
280
-        break;
281
-      case 'geometryType':
282
-        $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
283
-        break;
284
-      default:
285
-        $this->assertTrue($geometry->$method_name($argument), 'Failed on ' . $method_name);
286
-    }
60
+	switch ($method_name) {
61
+	  case 'y':
62
+	  case 'x':
63
+		if ($geometry->geometryType() == 'Point') {
64
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
65
+		}
66
+		if ($geometry->geometryType() == 'LineString') {
67
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
68
+		}
69
+		if ($geometry->geometryType() == 'MultiLineString') {
70
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
71
+		}
72
+		break;
73
+	  case 'geometryN':
74
+		if ($geometry->geometryType() == 'Point') {
75
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
76
+		}
77
+		if ($geometry->geometryType() == 'LineString') {
78
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
79
+		}
80
+		if ($geometry->geometryType() == 'MultiLineString') {
81
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
82
+		}
83
+		break;
84
+	  case 'startPoint':
85
+		if ($geometry->geometryType() == 'Point') {
86
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
87
+		}
88
+		if ($geometry->geometryType() == 'LineString') {
89
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
90
+		}
91
+		if ($geometry->geometryType() == 'MultiLineString') {
92
+		  //TODO: Add a method startPoint() to MultiLineString.
93
+		  //$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
94
+		}
95
+		break;
96
+	  case 'endPoint':
97
+		if ($geometry->geometryType() == 'Point') {
98
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
99
+		}
100
+		if ($geometry->geometryType() == 'LineString') {
101
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
102
+		}
103
+		if ($geometry->geometryType() == 'MultiLineString') {
104
+		  //TODO: Add a method endPoint() to MultiLineString.
105
+		  //$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
106
+		}
107
+		break;
108
+	  case 'isRing':
109
+		if ($geometry->geometryType() == 'Point') {
110
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
111
+		}
112
+		if ($geometry->geometryType() == 'LineString') {
113
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
114
+		}
115
+		if ($geometry->geometryType() == 'MultiLineString') {
116
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
117
+		}
118
+		break;
119
+	  case 'isClosed':
120
+		if ($geometry->geometryType() == 'Point') {
121
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
122
+		}
123
+		if ($geometry->geometryType() == 'LineString') {
124
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
125
+		}
126
+		if ($geometry->geometryType() == 'MultiLineString') {
127
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
128
+		}
129
+		break;
130
+	  case 'pointN':
131
+		if ($geometry->geometryType() == 'Point') {
132
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
133
+		}
134
+		if ($geometry->geometryType() == 'LineString') {
135
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
136
+		}
137
+		if ($geometry->geometryType() == 'MultiLineString') {
138
+		  //TODO: Add a method pointN() to MultiLineString.
139
+		  //$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
140
+		}
141
+		break;
142
+	  case 'exteriorRing':
143
+		if ($geometry->geometryType() == 'Point') {
144
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
145
+		}
146
+		if ($geometry->geometryType() == 'LineString') {
147
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
148
+		}
149
+		if ($geometry->geometryType() == 'MultiLineString') {
150
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
151
+		}
152
+		break;
153
+	  case 'numInteriorRings':
154
+		if ($geometry->geometryType() == 'Point') {
155
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
156
+		}
157
+		if ($geometry->geometryType() == 'LineString') {
158
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
159
+		}
160
+		if ($geometry->geometryType() == 'MultiLineString') {
161
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
162
+		}
163
+		break;
164
+	  case 'interiorRingN':
165
+		if ($geometry->geometryType() == 'Point') {
166
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
167
+		}
168
+		if ($geometry->geometryType() == 'LineString') {
169
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
170
+		}
171
+		if ($geometry->geometryType() == 'MultiLineString') {
172
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
173
+		}
174
+		break;
175
+	  case 'setSRID':
176
+		//TODO: The method setSRID() should return TRUE.
177
+		break;
178
+	  case 'SRID':
179
+		if ($geometry->geometryType() == 'Point') {
180
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
181
+		}
182
+		if ($geometry->geometryType() == 'LineString') {
183
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
184
+		}
185
+		if ($geometry->geometryType() == 'MultiLineString') {
186
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
187
+		}
188
+		break;
189
+	  case 'getBBox':
190
+		if ($geometry->geometryType() == 'Point') {
191
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
192
+		}
193
+		if ($geometry->geometryType() == 'LineString') {
194
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
195
+		}
196
+		if ($geometry->geometryType() == 'MultiLineString') {
197
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
198
+		}
199
+		break;
200
+	  case 'centroid':
201
+		if ($geometry->geometryType() == 'Point') {
202
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
203
+		}
204
+		if ($geometry->geometryType() == 'LineString') {
205
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
206
+		}
207
+		if ($geometry->geometryType() == 'MultiLineString') {
208
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
209
+		}
210
+		break;
211
+	  case 'length':
212
+		if ($geometry->geometryType() == 'Point') {
213
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
214
+		}
215
+		if ($geometry->geometryType() == 'LineString') {
216
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
217
+		}
218
+		if ($geometry->geometryType() == 'MultiLineString') {
219
+		  $this->assertEquals($geometry->$method_name($argument), (float) '0.11624637315233', 'Failed on ' . $method_name);
220
+		}
221
+		break;
222
+	  case 'numGeometries':
223
+		if ($geometry->geometryType() == 'Point') {
224
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
225
+		}
226
+		if ($geometry->geometryType() == 'LineString') {
227
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
228
+		}
229
+		if ($geometry->geometryType() == 'MultiLineString') {
230
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
231
+		}
232
+		break;
233
+	  case 'numPoints':
234
+		if ($geometry->geometryType() == 'Point') {
235
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
236
+		}
237
+		if ($geometry->geometryType() == 'LineString') {
238
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
239
+		}
240
+		if ($geometry->geometryType() == 'MultiLineString') {
241
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
242
+		}
243
+		break;
244
+	  case 'dimension':
245
+		if ($geometry->geometryType() == 'Point') {
246
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
247
+		}
248
+		if ($geometry->geometryType() == 'LineString') {
249
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
250
+		}
251
+		if ($geometry->geometryType() == 'MultiLineString') {
252
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
253
+		}
254
+		break;
255
+	  case 'boundary':
256
+		if ($geometry->geometryType() == 'Point') {
257
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
258
+		}
259
+		if ($geometry->geometryType() == 'LineString') {
260
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
261
+		}
262
+		if ($geometry->geometryType() == 'MultiLineString') {
263
+		  $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
264
+		}
265
+		break;
266
+	  case 'greatCircleLength':
267
+		if ($geometry->geometryType() == 'Point') {
268
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
269
+		}
270
+		if ($geometry->geometryType() == 'LineString') {
271
+		  $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
272
+		}
273
+		if ($geometry->geometryType() == 'MultiLineString') {
274
+		  $this->assertNotEquals($geometry->$method_name($argument), '9500.9359867418', 'Failed on ' . $method_name);
275
+		}
276
+		break;
277
+	  case 'haversineLength':
278
+	  case 'area':
279
+		$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
280
+		break;
281
+	  case 'geometryType':
282
+		$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
283
+		break;
284
+	  default:
285
+		$this->assertTrue($geometry->$method_name($argument), 'Failed on ' . $method_name);
286
+	}
287 287
   }
288 288
 }
289 289
 
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
       array('name' => 'setSRID', 'argument' => '4326'),
41 41
     );
42 42
 
43
-    foreach($methods as $method) {
43
+    foreach ($methods as $method) {
44 44
       $argument = NULL;
45 45
       $method_name = $method['name'];
46 46
       if (isset($method['argument'])) {
@@ -61,32 +61,32 @@  discard block
 block discarded – undo
61 61
       case 'y':
62 62
       case 'x':
63 63
         if ($geometry->geometryType() == 'Point') {
64
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
64
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
65 65
         }
66 66
         if ($geometry->geometryType() == 'LineString') {
67
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
67
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
68 68
         }
69 69
         if ($geometry->geometryType() == 'MultiLineString') {
70
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
70
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
71 71
         }
72 72
         break;
73 73
       case 'geometryN':
74 74
         if ($geometry->geometryType() == 'Point') {
75
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
75
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
76 76
         }
77 77
         if ($geometry->geometryType() == 'LineString') {
78
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
78
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
79 79
         }
80 80
         if ($geometry->geometryType() == 'MultiLineString') {
81
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
81
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
82 82
         }
83 83
         break;
84 84
       case 'startPoint':
85 85
         if ($geometry->geometryType() == 'Point') {
86
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
86
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
87 87
         }
88 88
         if ($geometry->geometryType() == 'LineString') {
89
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
89
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
90 90
         }
91 91
         if ($geometry->geometryType() == 'MultiLineString') {
92 92
           //TODO: Add a method startPoint() to MultiLineString.
@@ -95,10 +95,10 @@  discard block
 block discarded – undo
95 95
         break;
96 96
       case 'endPoint':
97 97
         if ($geometry->geometryType() == 'Point') {
98
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
98
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
99 99
         }
100 100
         if ($geometry->geometryType() == 'LineString') {
101
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
101
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
102 102
         }
103 103
         if ($geometry->geometryType() == 'MultiLineString') {
104 104
           //TODO: Add a method endPoint() to MultiLineString.
@@ -107,32 +107,32 @@  discard block
 block discarded – undo
107 107
         break;
108 108
       case 'isRing':
109 109
         if ($geometry->geometryType() == 'Point') {
110
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
110
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
111 111
         }
112 112
         if ($geometry->geometryType() == 'LineString') {
113
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
113
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
114 114
         }
115 115
         if ($geometry->geometryType() == 'MultiLineString') {
116
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
116
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
117 117
         }
118 118
         break;
119 119
       case 'isClosed':
120 120
         if ($geometry->geometryType() == 'Point') {
121
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
121
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
122 122
         }
123 123
         if ($geometry->geometryType() == 'LineString') {
124
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
124
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
125 125
         }
126 126
         if ($geometry->geometryType() == 'MultiLineString') {
127
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
127
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
128 128
         }
129 129
         break;
130 130
       case 'pointN':
131 131
         if ($geometry->geometryType() == 'Point') {
132
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
132
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
133 133
         }
134 134
         if ($geometry->geometryType() == 'LineString') {
135
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
135
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
136 136
         }
137 137
         if ($geometry->geometryType() == 'MultiLineString') {
138 138
           //TODO: Add a method pointN() to MultiLineString.
@@ -141,35 +141,35 @@  discard block
 block discarded – undo
141 141
         break;
142 142
       case 'exteriorRing':
143 143
         if ($geometry->geometryType() == 'Point') {
144
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
144
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
145 145
         }
146 146
         if ($geometry->geometryType() == 'LineString') {
147
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
147
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
148 148
         }
149 149
         if ($geometry->geometryType() == 'MultiLineString') {
150
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
150
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
151 151
         }
152 152
         break;
153 153
       case 'numInteriorRings':
154 154
         if ($geometry->geometryType() == 'Point') {
155
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
155
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
156 156
         }
157 157
         if ($geometry->geometryType() == 'LineString') {
158
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
158
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
159 159
         }
160 160
         if ($geometry->geometryType() == 'MultiLineString') {
161
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
161
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
162 162
         }
163 163
         break;
164 164
       case 'interiorRingN':
165 165
         if ($geometry->geometryType() == 'Point') {
166
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
166
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
167 167
         }
168 168
         if ($geometry->geometryType() == 'LineString') {
169
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
169
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
170 170
         }
171 171
         if ($geometry->geometryType() == 'MultiLineString') {
172
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
172
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
173 173
         }
174 174
         break;
175 175
       case 'setSRID':
@@ -177,112 +177,112 @@  discard block
 block discarded – undo
177 177
         break;
178 178
       case 'SRID':
179 179
         if ($geometry->geometryType() == 'Point') {
180
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
180
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
181 181
         }
182 182
         if ($geometry->geometryType() == 'LineString') {
183
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
183
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
184 184
         }
185 185
         if ($geometry->geometryType() == 'MultiLineString') {
186
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
186
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
187 187
         }
188 188
         break;
189 189
       case 'getBBox':
190 190
         if ($geometry->geometryType() == 'Point') {
191
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
191
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
192 192
         }
193 193
         if ($geometry->geometryType() == 'LineString') {
194
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
194
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
195 195
         }
196 196
         if ($geometry->geometryType() == 'MultiLineString') {
197
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
197
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
198 198
         }
199 199
         break;
200 200
       case 'centroid':
201 201
         if ($geometry->geometryType() == 'Point') {
202
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
202
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
203 203
         }
204 204
         if ($geometry->geometryType() == 'LineString') {
205
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
205
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
206 206
         }
207 207
         if ($geometry->geometryType() == 'MultiLineString') {
208
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
208
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
209 209
         }
210 210
         break;
211 211
       case 'length':
212 212
         if ($geometry->geometryType() == 'Point') {
213
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
213
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
214 214
         }
215 215
         if ($geometry->geometryType() == 'LineString') {
216
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
216
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
217 217
         }
218 218
         if ($geometry->geometryType() == 'MultiLineString') {
219
-          $this->assertEquals($geometry->$method_name($argument), (float) '0.11624637315233', 'Failed on ' . $method_name);
219
+          $this->assertEquals($geometry->$method_name($argument), (float) '0.11624637315233', 'Failed on '.$method_name);
220 220
         }
221 221
         break;
222 222
       case 'numGeometries':
223 223
         if ($geometry->geometryType() == 'Point') {
224
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
224
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
225 225
         }
226 226
         if ($geometry->geometryType() == 'LineString') {
227
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
227
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
228 228
         }
229 229
         if ($geometry->geometryType() == 'MultiLineString') {
230
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
230
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
231 231
         }
232 232
         break;
233 233
       case 'numPoints':
234 234
         if ($geometry->geometryType() == 'Point') {
235
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
235
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
236 236
         }
237 237
         if ($geometry->geometryType() == 'LineString') {
238
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
238
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
239 239
         }
240 240
         if ($geometry->geometryType() == 'MultiLineString') {
241
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
241
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
242 242
         }
243 243
         break;
244 244
       case 'dimension':
245 245
         if ($geometry->geometryType() == 'Point') {
246
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
246
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
247 247
         }
248 248
         if ($geometry->geometryType() == 'LineString') {
249
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
249
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
250 250
         }
251 251
         if ($geometry->geometryType() == 'MultiLineString') {
252
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
252
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
253 253
         }
254 254
         break;
255 255
       case 'boundary':
256 256
         if ($geometry->geometryType() == 'Point') {
257
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
257
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
258 258
         }
259 259
         if ($geometry->geometryType() == 'LineString') {
260
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
260
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
261 261
         }
262 262
         if ($geometry->geometryType() == 'MultiLineString') {
263
-          $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
263
+          $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
264 264
         }
265 265
         break;
266 266
       case 'greatCircleLength':
267 267
         if ($geometry->geometryType() == 'Point') {
268
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
268
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
269 269
         }
270 270
         if ($geometry->geometryType() == 'LineString') {
271
-          $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
271
+          $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
272 272
         }
273 273
         if ($geometry->geometryType() == 'MultiLineString') {
274
-          $this->assertNotEquals($geometry->$method_name($argument), '9500.9359867418', 'Failed on ' . $method_name);
274
+          $this->assertNotEquals($geometry->$method_name($argument), '9500.9359867418', 'Failed on '.$method_name);
275 275
         }
276 276
         break;
277 277
       case 'haversineLength':
278 278
       case 'area':
279
-        $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
279
+        $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
280 280
         break;
281 281
       case 'geometryType':
282
-        $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
282
+        $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
283 283
         break;
284 284
       default:
285
-        $this->assertTrue($geometry->$method_name($argument), 'Failed on ' . $method_name);
285
+        $this->assertTrue($geometry->$method_name($argument), 'Failed on '.$method_name);
286 286
     }
287 287
   }
288 288
 }
Please login to merge, or discard this patch.
require/libs/geoPHP/tests/tests/geosTest.php 2 patches
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -9,78 +9,78 @@
 block discarded – undo
9 9
   }
10 10
 
11 11
   function testGeos() {
12
-    foreach (scandir('./input') as $file) {
13
-      $parts = explode('.',$file);
14
-      if ($parts[0]) {
15
-        $format = $parts[1];
16
-        $value = file_get_contents('./input/'.$file);
17
-        $geometry = geoPHP::load($value, $format);
12
+	foreach (scandir('./input') as $file) {
13
+	  $parts = explode('.',$file);
14
+	  if ($parts[0]) {
15
+		$format = $parts[1];
16
+		$value = file_get_contents('./input/'.$file);
17
+		$geometry = geoPHP::load($value, $format);
18 18
 
19
-        $geosMethods = array(
20
-          array('name' => 'geos'),
21
-          array('name' => 'setGeos', 'argument' => $geometry->geos()),
22
-          array('name' => 'PointOnSurface'),
23
-          array('name' => 'equals', 'argument' => $geometry),
24
-          array('name' => 'equalsExact', 'argument' => $geometry),
25
-          array('name' => 'relate', 'argument' => $geometry),
26
-          array('name' => 'checkValidity'),
27
-          array('name' => 'isSimple'),
28
-          array('name' => 'buffer', 'argument' => '10'),
29
-          array('name' => 'intersection', 'argument' => $geometry),
30
-          array('name' => 'convexHull'),
31
-          array('name' => 'difference', 'argument' => $geometry),
32
-          array('name' => 'symDifference', 'argument' => $geometry),
33
-          array('name' => 'union', 'argument' => $geometry),
34
-          array('name' => 'simplify', 'argument' => '0'),
35
-          array('name' => 'disjoint', 'argument' => $geometry),
36
-          array('name' => 'touches', 'argument' => $geometry),
37
-          array('name' => 'intersects', 'argument' => $geometry),
38
-          array('name' => 'crosses', 'argument' => $geometry),
39
-          array('name' => 'within', 'argument' => $geometry),
40
-          array('name' => 'contains', 'argument' => $geometry),
41
-          array('name' => 'overlaps', 'argument' => $geometry),
42
-          array('name' => 'covers', 'argument' => $geometry),
43
-          array('name' => 'coveredBy', 'argument' => $geometry),
44
-          array('name' => 'distance', 'argument' => $geometry),
45
-          array('name' => 'hausdorffDistance', 'argument' => $geometry),
46
-        );
19
+		$geosMethods = array(
20
+		  array('name' => 'geos'),
21
+		  array('name' => 'setGeos', 'argument' => $geometry->geos()),
22
+		  array('name' => 'PointOnSurface'),
23
+		  array('name' => 'equals', 'argument' => $geometry),
24
+		  array('name' => 'equalsExact', 'argument' => $geometry),
25
+		  array('name' => 'relate', 'argument' => $geometry),
26
+		  array('name' => 'checkValidity'),
27
+		  array('name' => 'isSimple'),
28
+		  array('name' => 'buffer', 'argument' => '10'),
29
+		  array('name' => 'intersection', 'argument' => $geometry),
30
+		  array('name' => 'convexHull'),
31
+		  array('name' => 'difference', 'argument' => $geometry),
32
+		  array('name' => 'symDifference', 'argument' => $geometry),
33
+		  array('name' => 'union', 'argument' => $geometry),
34
+		  array('name' => 'simplify', 'argument' => '0'),
35
+		  array('name' => 'disjoint', 'argument' => $geometry),
36
+		  array('name' => 'touches', 'argument' => $geometry),
37
+		  array('name' => 'intersects', 'argument' => $geometry),
38
+		  array('name' => 'crosses', 'argument' => $geometry),
39
+		  array('name' => 'within', 'argument' => $geometry),
40
+		  array('name' => 'contains', 'argument' => $geometry),
41
+		  array('name' => 'overlaps', 'argument' => $geometry),
42
+		  array('name' => 'covers', 'argument' => $geometry),
43
+		  array('name' => 'coveredBy', 'argument' => $geometry),
44
+		  array('name' => 'distance', 'argument' => $geometry),
45
+		  array('name' => 'hausdorffDistance', 'argument' => $geometry),
46
+		);
47 47
 
48
-        foreach($geosMethods as $method) {
49
-          $argument = NULL;
50
-          $method_name = $method['name'];
51
-          if (isset($method['argument'])) {
52
-            $argument = $method['argument'];
53
-          }
48
+		foreach($geosMethods as $method) {
49
+		  $argument = NULL;
50
+		  $method_name = $method['name'];
51
+		  if (isset($method['argument'])) {
52
+			$argument = $method['argument'];
53
+		  }
54 54
 
55
-          switch ($method_name) {
56
-            case 'isSimple':
57
-            case 'equals':
58
-            case 'geos':
59
-              if ($geometry->geometryType() == 'Point') {
60
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
61
-              }
62
-              if ($geometry->geometryType() == 'LineString') {
63
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
64
-              }
65
-              if ($geometry->geometryType() == 'MultiLineString') {
66
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
67
-              }
68
-              break;
69
-            default:
70
-              if ($geometry->geometryType() == 'Point') {
71
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
72
-              }
73
-              if ($geometry->geometryType() == 'LineString') {
74
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
75
-              }
76
-              if ($geometry->geometryType() == 'MultiLineString') {
77
-                $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
78
-              }
79
-          }
80
-        }
55
+		  switch ($method_name) {
56
+			case 'isSimple':
57
+			case 'equals':
58
+			case 'geos':
59
+			  if ($geometry->geometryType() == 'Point') {
60
+				$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
61
+			  }
62
+			  if ($geometry->geometryType() == 'LineString') {
63
+				$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
64
+			  }
65
+			  if ($geometry->geometryType() == 'MultiLineString') {
66
+				$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
67
+			  }
68
+			  break;
69
+			default:
70
+			  if ($geometry->geometryType() == 'Point') {
71
+				$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
72
+			  }
73
+			  if ($geometry->geometryType() == 'LineString') {
74
+				$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
75
+			  }
76
+			  if ($geometry->geometryType() == 'MultiLineString') {
77
+				$this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
78
+			  }
79
+		  }
80
+		}
81 81
 
82
-      }
83
-    }
82
+	  }
83
+	}
84 84
   }
85 85
 
86 86
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
   function testGeos() {
12 12
     foreach (scandir('./input') as $file) {
13
-      $parts = explode('.',$file);
13
+      $parts = explode('.', $file);
14 14
       if ($parts[0]) {
15 15
         $format = $parts[1];
16 16
         $value = file_get_contents('./input/'.$file);
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
           array('name' => 'hausdorffDistance', 'argument' => $geometry),
46 46
         );
47 47
 
48
-        foreach($geosMethods as $method) {
48
+        foreach ($geosMethods as $method) {
49 49
           $argument = NULL;
50 50
           $method_name = $method['name'];
51 51
           if (isset($method['argument'])) {
@@ -57,24 +57,24 @@  discard block
 block discarded – undo
57 57
             case 'equals':
58 58
             case 'geos':
59 59
               if ($geometry->geometryType() == 'Point') {
60
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
60
+                $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
61 61
               }
62 62
               if ($geometry->geometryType() == 'LineString') {
63
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
63
+                $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
64 64
               }
65 65
               if ($geometry->geometryType() == 'MultiLineString') {
66
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
66
+                $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
67 67
               }
68 68
               break;
69 69
             default:
70 70
               if ($geometry->geometryType() == 'Point') {
71
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
71
+                $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
72 72
               }
73 73
               if ($geometry->geometryType() == 'LineString') {
74
-                $this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
74
+                $this->assertNotNull($geometry->$method_name($argument), 'Failed on '.$method_name);
75 75
               }
76 76
               if ($geometry->geometryType() == 'MultiLineString') {
77
-                $this->assertNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
77
+                $this->assertNull($geometry->$method_name($argument), 'Failed on '.$method_name);
78 78
               }
79 79
           }
80 80
         }
Please login to merge, or discard this patch.