Completed
Push — master ( f037be...aee2fd )
by Yannick
37:44
created
search-csv.php 2 patches
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -6,53 +6,53 @@  discard block
 block discarded – undo
6 6
 
7 7
 if (isset($_GET['start_date'])) {
8 8
 	//for the date manipulation into the query
9
-	if($_GET['start_date'] != "" && $_GET['end_date'] != ""){
10
-		$start_date = date("Y-m-d",strtotime($_GET['start_date']))." 00:00:00";
11
-		$end_date = date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
9
+	if ($_GET['start_date'] != "" && $_GET['end_date'] != "") {
10
+		$start_date = date("Y-m-d", strtotime($_GET['start_date']))." 00:00:00";
11
+		$end_date = date("Y-m-d", strtotime($_GET['end_date']))." 00:00:00";
12 12
 		$sql_date = $start_date.",".$end_date;
13
-	} else if($_GET['start_date'] != ""){
14
-		$start_date = date("Y-m-d",strtotime($_GET['start_date']))." 00:00:00";
13
+	} else if ($_GET['start_date'] != "") {
14
+		$start_date = date("Y-m-d", strtotime($_GET['start_date']))." 00:00:00";
15 15
 		$sql_date = $start_date;
16
-	} else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
17
-		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
16
+	} else if ($_GET['start_date'] == "" && $_GET['end_date'] != "") {
17
+		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d", strtotime($_GET['end_date']))." 00:00:00";
18 18
 		$sql_date = $end_date;
19 19
 	} else $sql_date = '';
20 20
 } else $sql_date = '';
21 21
 
22 22
 if (isset($_GET['highest_altitude'])) {
23 23
 	//for altitude manipulation
24
-	if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){
24
+	if ($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != "") {
25 25
 		$end_altitude = $_GET['highest_altitude'];
26 26
 		$start_altitude = $_GET['lowest_altitude'];
27 27
 		$sql_altitude = $start_altitude.",".$end_altitude;
28
-	} else if($_GET['highest_altitude'] != ""){
28
+	} else if ($_GET['highest_altitude'] != "") {
29 29
 		$end_altitude = $_GET['highest_altitude'];
30 30
 		$sql_altitude = $end_altitude;
31
-	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
31
+	} else if ($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != "") {
32 32
 		$start_altitude = $_GET['lowest_altitude'].",60000";
33 33
 		$sql_altitude = $start_altitude;
34 34
 	} else $sql_altitude = '';
35 35
 } else $sql_altitude = '';
36 36
 
37 37
 //calculuation for the pagination
38
-if(!isset($_GET['limit']))
38
+if (!isset($_GET['limit']))
39 39
 {
40 40
 	if (!isset($_GET['number_results'])) {
41 41
 		$limit_start = 0;
42 42
 		$limit_end = 25;
43 43
 		$absolute_difference = 25;
44 44
 	} else {
45
-		if ($_GET['number_results'] > 1000){
45
+		if ($_GET['number_results'] > 1000) {
46 46
 			$_GET['number_results'] = 1000;
47 47
 		}
48 48
 		$limit_start = 0;
49
-		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
50
-		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
49
+		$limit_end = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT);
50
+		$absolute_difference = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT);
51 51
 	}
52
-}  else {
52
+} else {
53 53
 	$limit_explode = explode(",", $_GET['limit']);
54
-	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
55
-	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
54
+	$limit_start = filter_var($limit_explode[0], FILTER_SANITIZE_NUMBER_INT);
55
+	$limit_end = filter_var($limit_explode[1], FILTER_SANITIZE_NUMBER_INT);
56 56
 }
57 57
 $absolute_difference = abs($limit_start - $limit_end);
58 58
 $limit_next = $limit_end + $absolute_difference;
@@ -69,33 +69,33 @@  discard block
 block discarded – undo
69 69
 if (isset($_GET['sort'])) $sort = $_GET['sort'];
70 70
 else $sort = '';
71 71
 
72
-$q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
73
-$id = filter_input(INPUT_GET,'id',FILTER_SANITIZE_NUMBER_INT);
74
-$registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING);
75
-$aircraft = filter_input(INPUT_GET,'aircraft',FILTER_SANITIZE_STRING);
76
-$manufacturer = filter_input(INPUT_GET,'manufacturer',FILTER_SANITIZE_STRING);
77
-$highlights = filter_input(INPUT_GET,'highlights',FILTER_SANITIZE_STRING);
78
-$airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
79
-$airline_country = filter_input(INPUT_GET,'airline_country',FILTER_SANITIZE_STRING);
80
-$airline_type = filter_input(INPUT_GET,'airline_type',FILTER_SANITIZE_STRING);
81
-$airport = filter_input(INPUT_GET,'airport',FILTER_SANITIZE_STRING);
82
-$airport_country = filter_input(INPUT_GET,'airport_country',FILTER_SANITIZE_STRING);
83
-$callsign = filter_input(INPUT_GET,'callsign',FILTER_SANITIZE_STRING);
84
-$pilot_id = filter_input(INPUT_GET,'pilot_id',FILTER_SANITIZE_STRING);
85
-$pilot_name = filter_input(INPUT_GET,'pilot_name',FILTER_SANITIZE_STRING);
86
-$owner = filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING);
87
-$departure_airport_route = filter_input(INPUT_GET,'departure_airport_route',FILTER_SANITIZE_STRING);
88
-$arrival_airport_route = filter_input(INPUT_GET,'arrival_airport_route',FILTER_SANITIZE_STRING);
72
+$q = filter_input(INPUT_GET, 'q', FILTER_SANITIZE_STRING);
73
+$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
74
+$registration = filter_input(INPUT_GET, 'registratrion', FILTER_SANITIZE_STRING);
75
+$aircraft = filter_input(INPUT_GET, 'aircraft', FILTER_SANITIZE_STRING);
76
+$manufacturer = filter_input(INPUT_GET, 'manufacturer', FILTER_SANITIZE_STRING);
77
+$highlights = filter_input(INPUT_GET, 'highlights', FILTER_SANITIZE_STRING);
78
+$airline = filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
79
+$airline_country = filter_input(INPUT_GET, 'airline_country', FILTER_SANITIZE_STRING);
80
+$airline_type = filter_input(INPUT_GET, 'airline_type', FILTER_SANITIZE_STRING);
81
+$airport = filter_input(INPUT_GET, 'airport', FILTER_SANITIZE_STRING);
82
+$airport_country = filter_input(INPUT_GET, 'airport_country', FILTER_SANITIZE_STRING);
83
+$callsign = filter_input(INPUT_GET, 'callsign', FILTER_SANITIZE_STRING);
84
+$pilot_id = filter_input(INPUT_GET, 'pilot_id', FILTER_SANITIZE_STRING);
85
+$pilot_name = filter_input(INPUT_GET, 'pilot_name', FILTER_SANITIZE_STRING);
86
+$owner = filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING);
87
+$departure_airport_route = filter_input(INPUT_GET, 'departure_airport_route', FILTER_SANITIZE_STRING);
88
+$arrival_airport_route = filter_input(INPUT_GET, 'arrival_airport_route', FILTER_SANITIZE_STRING);
89 89
 if ($id != '') {
90 90
 	$spotter_array = $Spotter->getSpotterDataByID($id);
91 91
 } else {
92
-	$spotter_array = $Spotter->searchSpotterData($q,$registration,$aircraft,strtolower(str_replace("-", " ", $manufacturer)),$highlights,$airline,$airline_country,$airline_type,$airport,$airport_country,$callsign,$departure_airport_route,$arrival_airport_route,$owner,$pilot_id,$pilot_name,$sql_altitude,$sql_date,$limit_start.",".$absolute_difference,$sort,'');
92
+	$spotter_array = $Spotter->searchSpotterData($q, $registration, $aircraft, strtolower(str_replace("-", " ", $manufacturer)), $highlights, $airline, $airline_country, $airline_type, $airport, $airport_country, $callsign, $departure_airport_route, $arrival_airport_route, $owner, $pilot_id, $pilot_name, $sql_altitude, $sql_date, $limit_start.",".$absolute_difference, $sort, '');
93 93
 } 
94 94
 
95 95
 $output = "id,ident,registration,aircraft_icao,aircraft_name,aircraft_manufacturer,airline,airline_icao,airline_iata,airline_country,airline_callsign,airline_type,departure_airport_city,departure_airport_country,departure_airport_iata,departure_airport_icao,departure_airport_latitude,departure_airport_longitude,departure_airport_altitude,arrival_airport_city,arrival_airport_country,arrival_airport_iata,arrival_airport_icao,arrival_airport_latitude,arrival_airport_longitude,arrival_airport_altitude,latitude,longitude,altitude,ground_speed,heading,heading_name,waypoints,date\n";
96 96
 
97 97
 if (!empty($spotter_array)) {
98
-	foreach($spotter_array as $spotter_item) {
98
+	foreach ($spotter_array as $spotter_item) {
99 99
 		$output .= $spotter_item['spotter_id'].',';
100 100
 		$output .= $spotter_item['ident'].',';
101 101
 		$output .= $spotter_item['registration'].',';
Please login to merge, or discard this patch.
Braces   +18 added lines, -7 removed lines patch added patch discarded remove patch
@@ -16,8 +16,12 @@  discard block
 block discarded – undo
16 16
 	} else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
17 17
 		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
18 18
 		$sql_date = $end_date;
19
-	} else $sql_date = '';
20
-} else $sql_date = '';
19
+	} else {
20
+		$sql_date = '';
21
+	}
22
+	} else {
23
+	$sql_date = '';
24
+}
21 25
 
22 26
 if (isset($_GET['highest_altitude'])) {
23 27
 	//for altitude manipulation
@@ -31,8 +35,12 @@  discard block
 block discarded – undo
31 35
 	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
32 36
 		$start_altitude = $_GET['lowest_altitude'].",60000";
33 37
 		$sql_altitude = $start_altitude;
34
-	} else $sql_altitude = '';
35
-} else $sql_altitude = '';
38
+	} else {
39
+		$sql_altitude = '';
40
+	}
41
+	} else {
42
+	$sql_altitude = '';
43
+}
36 44
 
37 45
 //calculuation for the pagination
38 46
 if(!isset($_GET['limit']))
@@ -49,7 +57,7 @@  discard block
 block discarded – undo
49 57
 		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
50 58
 		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
51 59
 	}
52
-}  else {
60
+} else {
53 61
 	$limit_explode = explode(",", $_GET['limit']);
54 62
 	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
55 63
 	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
@@ -66,8 +74,11 @@  discard block
 block discarded – undo
66 74
 
67 75
 header("Content-type: text/csv");
68 76
 
69
-if (isset($_GET['sort'])) $sort = $_GET['sort'];
70
-else $sort = '';
77
+if (isset($_GET['sort'])) {
78
+	$sort = $_GET['sort'];
79
+} else {
80
+	$sort = '';
81
+}
71 82
 
72 83
 $q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
73 84
 $id = filter_input(INPUT_GET,'id',FILTER_SANITIZE_NUMBER_INT);
Please login to merge, or discard this patch.