Completed
Push — master ( d8c574...a11679 )
by Yannick
07:12
created

search-rss.php (4 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
require_once('require/class.Connection.php');
3
require_once('require/class.Spotter.php');
4
require_once('require/class.Language.php');
5
$Spotter = new Spotter();
6 View Code Duplication
if (isset($_GET['start_date'])) {
1 ignored issue
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
7
        //for the date manipulation into the query
8
        if($_GET['start_date'] != "" && $_GET['end_date'] != ""){
9
                $start_date = $_GET['start_date'].":00";
10
                $end_date = $_GET['end_date'].":00";
11
                $sql_date = $start_date.",".$end_date;
12
        } else if($_GET['start_date'] != ""){
13
                $start_date = $_GET['start_date'].":00";
14
                $sql_date = $start_date;
15
        } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
16
                $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00";
17
                $sql_date = $end_date;
18
        } else $sql_date = '';
19
} else $sql_date = '';
20
21 View Code Duplication
if (isset($_GET['highest_altitude'])) {
1 ignored issue
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
        //for altitude manipulation
23
        if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){
24
                $end_altitude = $_GET['highest_altitude'];
25
                $start_altitude = $_GET['lowest_altitude'];
26
                $sql_altitude = $start_altitude.",".$end_altitude;
27
        } else if($_GET['highest_altitude'] != ""){
28
                $end_altitude = $_GET['highest_altitude'];
29
                $sql_altitude = $end_altitude;
30
        } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
31
                $start_altitude = $_GET['lowest_altitude'].",60000";
32
                $sql_altitude = $start_altitude;
33
        } else $sql_altitude = '';
34
} else $sql_altitude = '';
35
36
//calculuation for the pagination
37 View Code Duplication
if(!isset($_GET['limit']))
1 ignored issue
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
{
39
        if (!isset($_GET['number_results']))
40
        {
41
                $limit_start = 0;
42
                $limit_end = 25;
43
                $absolute_difference = 25;
44
        } else {
45
                if ($_GET['number_results'] > 1000){
46
                        $_GET['number_results'] = 1000;
47
                }
48
                $limit_start = 0;
49
                $limit_end = $_GET['number_results'];
50
                $absolute_difference = $_GET['number_results'];
51
        }
52
}  else {
53
        $limit_explode = explode(",", $_GET['limit']);
54
        $limit_start = $limit_explode[0];
55
        $limit_end = $limit_explode[1];
56
}
57
58
$absolute_difference = abs($limit_start - $limit_end);
59
$limit_next = $limit_end + $absolute_difference;
60
$limit_previous_1 = $limit_start - $absolute_difference;
61
$limit_previous_2 = $limit_end - $absolute_difference;
62
63
if ($_GET['download'] == "true")
64
{
65
	header('Content-disposition: attachment; filename="flightairmap.rss"');
66
}
67
68
header('Content-Type: application/rss+xml; charset=utf-8');
69
70
71
$date = date("D, d M Y H:i:s T", time());
72
73
if (isset($_GET['sort'])) $sort = $_GET['sort'];
74
else $sort = '';
75
$q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
76
$registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING);
77
$aircraft = filter_input(INPUT_GET,'aircraft',FILTER_SANITIZE_STRING);
78
$manufacturer = filter_input(INPUT_GET,'manufacturer',FILTER_SANITIZE_STRING);
79
$highlights = filter_input(INPUT_GET,'highlights',FILTER_SANITIZE_STRING);
80
$airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
81
$airline_country = filter_input(INPUT_GET,'airline_country',FILTER_SANITIZE_STRING);
82
$airline_type = filter_input(INPUT_GET,'airline_type',FILTER_SANITIZE_STRING);
83
$airport = filter_input(INPUT_GET,'airport',FILTER_SANITIZE_STRING);
84
$airport_country = filter_input(INPUT_GET,'airport_country',FILTER_SANITIZE_STRING);
85
$callsign = filter_input(INPUT_GET,'callsign',FILTER_SANITIZE_STRING);
86
$owner = filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING);
87
$pilot_id = filter_input(INPUT_GET,'pilot_id',FILTER_SANITIZE_STRING);
88
$pilot_name = filter_input(INPUT_GET,'pilot_name',FILTER_SANITIZE_STRING);
89
$departure_airport_route = filter_input(INPUT_GET,'departure_airport_route',FILTER_SANITIZE_STRING);
90
$arrival_airport_route = filter_input(INPUT_GET,'arrival_airport_route',FILTER_SANITIZE_STRING);
91
$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
 
93
print '<?xml version="1.0" encoding="UTF-8" ?>';
94
print '<rss xmlns:flightairmap="http://'.$_SERVER['HTTP_HOST'].''.htmlentities($_SERVER['REQUEST_URI']).'" version="2.0">';
95
96
print '<channel>';
97
  print '<title>FlightAirMap RSS Feed</title>';
98
  print '<link>http://www.flightairmap.fr/</link>';
99
  print '<description>The latest airplanes</description>';
100
  print '<language>en-ca</language>';
101
  print '<lastBuildDate>'.$date.'</lastBuildDate>';
102
  
103
  if (!empty($spotter_array))
104
  {
105
    foreach($spotter_array as $spotter_item)
106
    {
107
108
          
109
		  print '<item>';
110
		    print '<title>'.$spotter_item['ident'].' '.$spotter_item['airline_name'].' | '.$spotter_item['registration'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].') | '.$spotter_item['departure_airport'].' - '.$spotter_item['arrival_airport'].'</title>';
111
		    print '<link>http://www.flightairmap.fr/flightid/'.$spotter_item['spotter_id'].'</link>';
112
		    print '<guid isPermaLink="false">http://www.flightairmap.fr/flightid/'.$spotter_item['spotter_id'].'</guid>';
113
		    print '<description>Ident: '.$spotter_item['ident'].' | Registration: '.$spotter_item['registration'].' | Aircraft: '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].') | Airline: '.$spotter_item['airline_name'].' | Coming From: '.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_name'].', '.$spotter_item['departure_airport_country'].' ('.$spotter_item['departure_airport'].') | Flying to: '.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_name'].', '.$spotter_item['arrival_airport_country'].' ('.$spotter_item['arrival_airport'].') | Flew nearby on: '.date("M j, Y, g:i a T", strtotime($spotter_item['date_iso_8601'])).'</description>';
114
		    print '<pubDate>'.$date.'</pubDate>';
115
		  print '</item>';
116
		    
117
		 }
118
	}
119
  
120
print '</channel>';
121
122
print '</rss>';
123
124
?>
1 ignored issue
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...