Completed
Push — master ( 96dddc...6410c5 )
by Yannick
43:23 queued 15:28
created
require/class.SpotterArchive.php 1 patch
Braces   +40 added lines, -14 removed lines patch added patch discarded remove patch
@@ -6,7 +6,9 @@  discard block
 block discarded – undo
6 6
 	public function __construct($dbc = null) {
7 7
 		$Connection = new Connection($dbc);
8 8
 		$this->db = $Connection->db;
9
-		if ($this->db === null) die('Error: No DB connection.');
9
+		if ($this->db === null) {
10
+			die('Error: No DB connection.');
11
+		}
10 12
 	}
11 13
 
12 14
     /**
@@ -27,7 +29,9 @@  discard block
 block discarded – undo
27 29
 	if (isset($filter[0]['source'])) {
28 30
 		$filters = array_merge($filters,$filter);
29 31
 	}
30
-	if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+	if (is_array($globalFilter)) {
33
+		$filter = array_merge($filter,$globalFilter);
34
+	}
31 35
 	$filter_query_join = '';
32 36
 	$filter_query_where = '';
33 37
 	foreach($filters as $flt) {
@@ -114,8 +118,11 @@  discard block
 block discarded – undo
114 118
 	    }
115 119
 	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
116 120
 	}
117
-	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
118
-	elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
121
+	if ($filter_query_where == '' && $where) {
122
+		$filter_query_where = ' WHERE';
123
+	} elseif ($filter_query_where != '' && $and) {
124
+		$filter_query_where .= ' AND';
125
+	}
119 126
 	if ($filter_query_where != '') {
120 127
 		$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
121 128
 	}
@@ -129,10 +136,17 @@  discard block
 block discarded – undo
129 136
 		if ($over_country == '') {
130 137
 			$Spotter = new Spotter($this->db);
131 138
 			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
132
-			if (!empty($data_country)) $country = $data_country['iso2'];
133
-			else $country = '';
134
-		} else $country = $over_country;
135
-		if ($airline_type === NULL) $airline_type ='';
139
+			if (!empty($data_country)) {
140
+				$country = $data_country['iso2'];
141
+			} else {
142
+				$country = '';
143
+			}
144
+		} else {
145
+			$country = $over_country;
146
+		}
147
+		if ($airline_type === NULL) {
148
+			$airline_type ='';
149
+		}
136 150
 	
137 151
 		//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n";
138 152
 		//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n";
@@ -639,7 +653,9 @@  discard block
 block discarded – undo
639 653
 		    $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
640 654
 		    $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
641 655
 		    $translate = $Translation->ident2icao($q_item);
642
-		    if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
656
+		    if ($translate != $q_item) {
657
+		    	$additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
658
+		    }
643 659
 		    $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
644 660
 		    $additional_query .= ")";
645 661
 		}
@@ -855,7 +871,9 @@  discard block
 block discarded – undo
855 871
 			date_default_timezone_set($globalTimezone);
856 872
 			$datetime = new DateTime();
857 873
 			$offset = $datetime->format('P');
858
-		} else $offset = '+00:00';
874
+		} else {
875
+			$offset = '+00:00';
876
+		}
859 877
 		if ($date_array[1] != "")
860 878
 		{                
861 879
 			$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
@@ -1121,9 +1139,13 @@  discard block
 block discarded – undo
1121 1139
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1122 1140
 			}
1123 1141
 		}
1124
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1142
+                if ($sincedate != '') {
1143
+                	$query .= "AND date > '".$sincedate."' ";
1144
+                }
1125 1145
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1126
-	if ($limit) $query .= " LIMIT 0,10";
1146
+	if ($limit) {
1147
+		$query .= " LIMIT 0,10";
1148
+	}
1127 1149
       
1128 1150
 	
1129 1151
 	$sth = $this->db->prepare($query);
@@ -1167,9 +1189,13 @@  discard block
 block discarded – undo
1167 1189
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1168 1190
 			}
1169 1191
 		}
1170
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1192
+                if ($sincedate != '') {
1193
+                	$query .= "AND s.date > '".$sincedate."' ";
1194
+                }
1171 1195
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1172
-	if ($limit) $query .= " LIMIT 0,10";
1196
+	if ($limit) {
1197
+		$query .= " LIMIT 0,10";
1198
+	}
1173 1199
       
1174 1200
 	
1175 1201
 	$sth = $this->db->prepare($query);
Please login to merge, or discard this patch.