Completed
Push — master ( 2c5525...528bd8 )
by Yannick
32:59
created

captain-detailed.php (2 issues)

Labels
Severity

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.Marine.php');
4
require_once('require/class.Stats.php');
5
require_once('require/class.Language.php');
6
require_once('require/class.MarineArchive.php');
7
8
if (!isset($_GET['captain'])){
9
	header('Location: '.$globalURL.'/');
10
} else {
11
	$type = 'marine';
12
	$Marine = new Marine();
13
	$MarineArchive = new MarineArchive();
14
	//calculuation for the pagination
15
	if(!isset($_GET['limit']))
16
	{
17
		$limit_start = 0;
18
		$limit_end = 25;
19
		$absolute_difference = 25;
20
	} else {
21
		$limit_explode = explode(",", $_GET['limit']);
22
		$limit_start = $limit_explode[0];
23
		$limit_end = $limit_explode[1];
24
		if (!ctype_digit(strval($limit_start)) || !ctype_digit(strval($limit_end))) {
25
			$limit_start = 0;
26
			$limit_end = 25;
27
		}
28
	}
29
	$absolute_difference = abs($limit_start - $limit_end);
30
	$limit_next = $limit_end + $absolute_difference;
31
	$limit_previous_1 = $limit_start - $absolute_difference;
32
	$limit_previous_2 = $limit_end - $absolute_difference;
33
	
34
	$page_url = $globalURL.'/captain/'.$_GET['captain'];
35
	
36
	$captain = filter_input(INPUT_GET,'captain',FILTER_SANITIZE_STRING);
37
	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
38
	$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
39
	$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
40
	$filter = array();
41
	if ($year != '') $filter = array_merge($filter,array('year' => $year));
42
	if ($month != '') $filter = array_merge($filter,array('month' => $month));
43
	if ($sort != '') 
44
	{
45
		$spotter_array = $Marine->getMarineDataByCaptain($captain,$limit_start.",".$absolute_difference, $sort,$filter);
46
		if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
47
			$spotter_array = $MarineArchive->getMarineDataByCaptain($captain,$limit_start.",".$absolute_difference, $sort,$filter);
0 ignored issues
show
The method getMarineDataByCaptain() does not seem to exist on object<MarineArchive>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
48
		}
49
	} else {
50
		$spotter_array = $Marine->getMarineDataByCaptain($captain,$limit_start.",".$absolute_difference,'',$filter);
51
		if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
52
			$spotter_array = $MarineArchive->getMarineDataByCaptain($captain,$limit_start.",".$absolute_difference,'',$filter);
0 ignored issues
show
The method getMarineDataByCaptain() does not seem to exist on object<MarineArchive>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
53
		}
54
	}
55
56
	if (!empty($spotter_array))
57
	{
58
		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['captain_name']);
59
		$ident = $spotter_array[0]['ident'];
60
		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
61
		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
62
		require_once('header.php');
63
		/*
64
		if (isset($globalArchive) && $globalArchive) {
65
			// Requirement for altitude graph
66
			print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>';
67
			$all_data = $MarineArchive->getAltitudeSpeedArchiveMarineDataById($spotter_array[0]['flightaware_id']);
68
			if (isset($globalTimezone)) {
69
				date_default_timezone_set($globalTimezone);
70
			} else date_default_timezone_set('UTC');
71
			if (count($all_data) > 0) {
72
				print '<div id="chart6" class="chart" width="100%"></div>
73
                    <script> 
74
                        google.load("visualization", "1.1", {packages:["line","corechart"]});
75
                      google.setOnLoadCallback(drawChart6);
76
                      function drawChart6() {
77
                        var data = google.visualization.arrayToDataTable([
78
                            ["Hour","'._("Altitude").'","'._("Speed").'"], ';
79
                            $altitude_data = '';
80
				foreach($all_data as $data)
81
				{
82
					$altitude_data .= '[ "'.date("G:i",strtotime($data['date']." UTC")).'",'.$data['altitude'].','.$data['ground_speed'].'],';
83
				}
84
				$altitude_data = substr($altitude_data, 0, -1);
85
				print $altitude_data.']);
86
87
                        var options = {
88
                            legend: {position: "none"},
89
                            series: {
90
                                0: {axis: "Altitude"},
91
                                1: {axis: "Speed"}
92
                            },
93
                            axes: {
94
                                y: {
95
                                    Altitude: {label: "'._("Altitude (FL)").'"},
96
                                    Speed: {label: "'._("Speed (knots)").'"},
97
                                }
98
                            },
99
                            height:210
100
                        };
101
102
                        var chart = new google.charts.Line(document.getElementById("chart6"));
103
                        chart.draw(data, options);
104
                      }
105
                      $(window).resize(function(){
106
                              drawChart6();
107
                            });
108
				 </script>';
109
  			}
110
		}
111
		*/
112
		print '<div class="info column">';
113
		print '<h1>'.$spotter_array[0]['captain_name'].'</h1>';
114
		if (isset($spotter_array[0]['captain_id']) && $spotter_array[0]['captain_id'] != '') print '<div><span class="label">'._("Captain ID").'</span>'.$spotter_array[0]['captain_id'].'</div>';
115
		/*
116
		if ($year == '' && $month == '') {
117
			$Stats = new Stats();
118
			$flights = $Stats->getStatsCaptain($captain);
119
		} else $flights = 0;
120
		if ($flights == 0)
121
		*/
122
		$flights = $Marine->countRacesByCaptain($captain,$filter);
123
		print '<div><span class="label">'._("Races").'</span>'.$flights.'</div>';
124
		$aircraft_type = count($Marine->countAllBoatTypesByCaptain($captain,$filter));
125
		print '<div><span class="label">'._("Boat type").'</span>'.$aircraft_type.'</div>';
126
		//$aircraft_registration = count($Marine->countAllAircraftRegistrationByCaptain($captain,$filter));
127
		//print '<div><span class="label">'._("Aircraft").'</span>'.$aircraft_registration.'</div>';
128
		//$aircraft_manufacturer = count($Marine->countAllAircraftManufacturerByCaptain($captain,$filter));
129
		//print '<div><span class="label">'._("Manufacturers").'</span>'.$aircraft_manufacturer.'</div>';
130
		//$airlines = count($Marine->countAllAirlinesByCaptain($captain,$filter));
131
		//print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
132
		$duration = $Marine->getRaceDurationByCaptain($captain,$filter);
133
		if ($duration != '0') print '<div><span class="label">'._("Total races spotted duration").'</span>'.$duration.'</div>';
134
		print '</div>';
135
	
136
		//include('captain-sub-menu.php');
137
		print '<div class="table column">';
138
		print '<p>'.sprintf(_("The table below shows the detailed information of all races with the captain <strong>%s</strong>."),$spotter_array[0]['captain_name']).'</p>';
139
140
		include('table-output.php'); 
141
		print '<div class="pagination">';
142
		if ($limit_previous_1 >= 0)
143
		{
144
			print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'/'.$sort.'">&laquo;'._("Previous Page").'</a>';
145
		}
146
		if ($spotter_array[0]['query_number_rows'] == $absolute_difference)
147
		{
148
			print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'/'.$sort.'">'._("Next Page").'&raquo;</a>';
149
		}
150
		print '</div>';
151
		print '</div>';
152
	} else {
153
		$title = _("Owner");
154
		require_once('header.php');
155
		print '<h1>'._("Error").'</h1>';
156
		print '<p>'._("Sorry, this owner is not in the database. :(").'</p>'; 
157
	}
158
}
159
require_once('footer.php');
160
?>