Completed
Push — master ( 7bb360...c01d59 )
by Yannick
22:07
created

statistics.php (5 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.Stats.php');
4
require_once('require/class.Language.php');
5
$beginpage = microtime(true);
6
$Stats = new Stats();
7
8
$type = 'aircraft';
9
if (isset($_GET['tracker'])) {
10
	require_once('require/class.Tracker.php');
11
	$Tracker = new Tracker();
12
	$type = 'tracker';
13
} elseif (isset($_GET['marine'])) {
14
	require_once('require/class.Marine.php');
15
	$Marine = new Marine();
16
	$type = 'marine';
17
} else {
18
	require_once('require/class.Spotter.php');
19
}
20
21
if (!isset($filter_name)) $filter_name = '';
22
$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
23
if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) {
24
	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
25
}
26
if ($type == 'aircraft' && $airline_icao != '' && $airline_icao != 'all') {
27
	$Spotter = new Spotter();
28
	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
29
	$airline_name = $airline_info[0]['name'];
30
}
31
if ($type == 'aircraft' && isset($airline_name)) {
32
	$title = _("Statistics").' - '.$airline_name;
33
} else {
34
	$title = _("Statistics");
35
}
36
37
$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
38
$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
39
40
require_once('header.php');
41
42
?>
43
<link href="<?php echo $globalURL; ?>/css/c3.min.css" rel="stylesheet" type="text/css">
44
<!--<script type="text/javascript" src="https://d3js.org/d3.v4.min.js"></script>-->
45
<!--<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script>-->
46
<script type="text/javascript" src="<?php echo $globalURL; ?>/js/d3.min.js"></script>
47
<script type="text/javascript" src="<?php echo $globalURL; ?>/js/c3.min.js"></script>
48
<script type="text/javascript" src="<?php echo $globalURL; ?>/js/d3pie.min.js"></script>
49
<script type="text/javascript" src="<?php echo $globalURL; ?>/js/radarChart.js"></script>
50
<script type="text/javascript" src="<?php echo $globalURL; ?>/js/raphael-2.1.4.min.js"></script>
51
<script type="text/javascript" src="<?php echo $globalURL; ?>/js/justgage.js"></script>
52
<script type="text/javascript" src="<?php echo $globalURL; ?>/js/topojson.v2.min.js"></script>
53
<script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script>
54
<div class="column">
55
    <div class="info">
56
            <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1>
57
<?php 
58
	if ($type == 'aircraft') {
59
		$last_update = $Stats->getLastStatsUpdate();
60
		//if (isset($last_update[0]['value'])) print '<!-- Last update : '.$last_update[0]['value'].' -->';
61
		if (isset($last_update[0]['value'])) {
62
			date_default_timezone_set('UTC');
63
			$lastupdate = strtotime($last_update[0]['value']);
64
			if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
65
			print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
66
		}
67
	}
68
?>
69
    </div>
70
<?php 
71
	if ($type == 'aircraft') {
72
		include('statistics-sub-menu.php'); 
73
	}
74
?>
75
    <p class="global-stats">
76
<?php
77
	if ($type == 'aircraft') {
78
?>
79
        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Flights"); ?></span>
80
	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
81
        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
82
        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
83
	<?php
84
	    if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
85
	?>
86
    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span>
87
	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
88
        <?php
89
    	    } else {
90
    	?>
91
    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span>
92
	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
93
    	<?php
94
    	    }
95
    	?>
96
        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
97
        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
98
        <?php
99
    		if ($airline_icao == '') {
100
    	?>
101
        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span>
102
	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
103
	<?php
104
		}
105
	?>
106
	<?php
107
		if (!(isset($globalIVAO) && $globalIVAO) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalphpVMS) && $globalphpVMS)) {
108
			if ($airline_icao == '' || $airline_icao == 'all') {
109
	?>
110
        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name,$year,$month)); ?></span> <?php echo _("Military"); ?></span>
111
	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
112
	<?php
113
			}
114
		}
115
	?>
116
<?php
117
	} elseif ($type == 'marine') {
118
?>
119
	<span><span class="badge"><?php print number_format($Marine->countOverallMarine($filter_name,$year,$month)); ?></span> <?php echo _("Vessels"); ?></span>
120
	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
121
<?php
122
	} elseif ($type == 'tracker') {
123
?>
124
	<span><span class="badge"><?php print number_format($Tracker->countOverallTracker($filter_name,$year,$month)); ?></span> <?php echo _("Trackers"); ?></span>
125
	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
126
<?php
127
	}
128
?>
129
    </p>
130
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
131
    <div class="specific-stats">
132
<?php
133
	if ($type == 'aircraft') {
134
?>
135
        <div class="row column">
136
            <div class="col-md-6">
137
                <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
138
                 <?php
139
                  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
140
		    if (count($aircraft_array) == 0) print _("No data available");
141
		    else {
142
                    print '<div id="chart1" class="chart" width="100%"></div><script>';
143
                    $aircraft_data = '';
144
                    foreach($aircraft_array as $aircraft_item)
145
                    {
146
                        $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
147
                    }
148
                    $aircraft_data = substr($aircraft_data, 0, -1);
149
		    print 'var series = ['.$aircraft_data.'];';
150
		    print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
151
		    print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);';
152
		    print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
153
                    print 'var aircraftype = new d3pie("chart1",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
154
                    print 'dataset';
155
                    print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
156
                    print '</script>';
157
                  }
158
                  ?>
159
                <div class="more">
160
            	    <?php
161
            		if ($year != '' && $month != '') {
162
            	    ?>
163
            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
164
            	    <?php
165
            		} else {
166
            	    ?>
167
            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
168
            	    <?php
169
            		}
170
            	    ?>
171
                </div>
172
            </div>
173
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
174
<?php
175
//    echo $airline_icao;
176
		if ($airline_icao == '' || $airline_icao == 'all') {
177
			$airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month);
178
			if (count($airline_array) > 0) {
179
				print '<div class="col-md-6">';
180
				print '<h2>'._("Top 10 Most Common Airline").'</h2>';
181
				print '<div id="chart2" class="chart" width="100%"></div><script>';
182
				$airline_data = '';
183
				foreach($airline_array as $airline_item)
184
				{
185
					$airline_data .= '["'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
186
				}
187
				$airline_data = substr($airline_data, 0, -1);
188
				print 'var series = ['.$airline_data.'];';
189
				print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
190
				print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
191
				print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
192
				print 'var airlinescnt = new d3pie("chart2",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
193
				print 'dataset';
194
				print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
195
				print '</script>';
196
				if ($year != '' && $month != '') {
197
					print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
198
					if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
199
					print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
200
				} else {
201
					print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
202
					if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
203
					print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
204
				}
205
				print '</div>';
206
			}
207
?>
208
        </div>
209
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
210
<?php
211
		}
212
?>
213
<?php
214
	}
215
?>
216
<?php
217
	if ($type == 'marine') {
218
?>
219
        <div class="row column">
220
            <div class="col-md-6">
221
                <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2>
222
                 <?php
223
                  $marine_array = $Marine->countAllMarineTypes();
224
		    if (count($marine_array) == 0) print _("No data available");
225
		    else {
226
                    print '<div id="chart1" class="chart" width="100%"></div><script>';
227
                    $marine_data = '';
228
                    foreach($marine_array as $marine_item)
229
                    {
230
                        $marine_data .= '["'.$marine_item['marine_type'].'",'.$marine_item['marine_type_count'].'],';
231
                    }
232
                    $marine_data = substr($marine_data, 0, -1);
233
		    print 'var series = ['.$marine_data.'];';
234
		    print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
235
		    print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);';
236
		    print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
237
                    print 'var marinetype = new d3pie("chart1",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
238
                    print 'dataset';
239
                    print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
240
                    print '</script>';
241
                  }
242
                  ?>
243
                <div class="more">
244
            	    <?php
245
            	    /*
246
            		if ($year != '' && $month != '') {
247
            	    ?>
248
            	    <a href="<?php print $globalURL; ?>/marine/statistics/type/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
249
            	    <?php
250
            		} else {
251
            	    ?>
252
            	    <a href="<?php print $globalURL; ?>/marine/statistics/type" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
253
            	    <?php
254
            		}
255
            		*/
256
            	    ?>
257
                </div>
258
            </div>
259
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
260
	</div>
261
<?php
262
	}
263
?>
264
<?php
265
	if ($type == 'aircraft') {
266
?>
267
        <div class="row column">
268
<?php
269
		$flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
270
		if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
271
			if (empty($flightover_array)) {
272
				print '<div class="col-md-12">';
273
			} else {
274
				print '<div class="col-md-6">';
275
			}
276
?>
277
                <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
278
<?php
279
			$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
280
			if (count($pilot_array) == 0) print _("No data available");
281
			else {
282
				print '<div id="chart7" class="chart" width="100%"></div><script>';
283
				$pilot_data = '';
284
				foreach($pilot_array as $pilot_item)
285
				{
286
					$pilot_data .= '["'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
287
				}
288
				$pilot_data = substr($pilot_data, 0, -1);
289
				print 'var series = ['.$pilot_data.'];';
290
				print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
291
				print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
292
				print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
293
				print 'var pilotcnt = new d3pie("chart7",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
294
				print 'dataset';
295
				print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
296
				print '</script>';
297
			}
298
			print '<div class="more">';
299
			print '<a href="'.$globalURL.'/statistics/pilot'; 
300
			if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
301
			print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
302
			print '</div>';
303
?>
304
            </div>
305
        
306
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
307
<?php
308
		} else {
309
?>
310
            <div class="col-md-6">
311
                <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
312
<?php
313
			$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
314
			if (count($owner_array) == 0) print _("No data available");
315
			else {
316
				print '<div id="chart7" class="chart" width="100%"></div><script>';
317
				$owner_data = '';
318
				foreach($owner_array as $owner_item)
319
				{
320
					$owner_data .= '["'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
321
				}
322
				$owner_data = substr($owner_data, 0, -1);
323
				print 'var series = ['.$owner_data.'];';
324
				print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
325
				print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
326
				print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
327
				print 'var ownercnt = new d3pie("chart7",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
328
				print 'dataset';
329
				print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
330
				print '</script>';
331
			}
332
?>
333
                <div class="more">
334
                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
335
                </div>
336
            </div>
337
        
338
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
339
<?php
340
		}
341
		if (!empty($flightover_array)) {
342
?>
343
            <div class="col-md-6">
344
                <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
345
<?php
346
	 //$flightover_array = $Stats->countAllFlightOverCountries();
347
			if (count($flightover_array) == 0) print _("No data available");
348
			else {
349
				print '<div id="chart10" class="chart" width="100%"></div><script>';
350
				print 'var series = [';
351
				$flightover_data = '';
352
				foreach($flightover_array as $flightover_item)
353
				{
354
					$flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
355
				}
356
				$flightover_data = substr($flightover_data, 0, -1);
357
				print $flightover_data;
358
				print '];';
359
				print 'var dataset = {};var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
360
				print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
361
				print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
362
				print 'new Datamap({
363
				    element: document.getElementById("chart10"),
364
				    projection: "mercator", // big world map
365
				    fills: { defaultFill: "#F5F5F5" },
366
				    data: dataset,
367
				    responsive: true,
368
				    geographyConfig: {
369
					borderColor: "#DEDEDE",
370
					highlightBorderWidth: 2,
371
					highlightFillColor: function(geo) {
372
					    return geo["fillColor"] || "#F5F5F5";
373
					},
374
					highlightBorderColor: "#B7B7B7",
375
					done: function(datamap) {
376
					    datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
377
					    function redraw() {
378
						datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
379
					    }
380
					},
381
					popupTemplate: function(geo, data) {
382
					    if (!data) { return ; }
383
					    return ['."'".'<div class="hoverinfo">'."','<strong>', geo.properties.name, '</strong>','<br>Count: <strong>', data.numberOfThings, '</strong>','</div>'].join('');
384
					}
385
				    }
386
				});";
387
				print '</script>';
388
			}
389
?>
390
                <div class="more">
391
                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
392
                </div>
393
            </div>
394
<?php
395
		}
396
?>
397
        </div>
398
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
399
400
    	
401
        </div>
402
<?php
403
	}
404
?>
405
<?php
406
	if ($type == 'marine') {
407
		$flightover_array = $Marine->countAllMarineOverCountries(true);
408
?>
409
    <div class="row column">
410
	<div class="col-md-6">
411
            <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
412
<?php
413
		if (count($flightover_array) == 0) print _("No data available");
414
		else {
415
			print '<div id="chart10" class="chart" width="100%"></div><script>';
416
			print 'var series = [';
417
			$flightover_data = '';
418
			foreach($flightover_array as $flightover_item)
419
			{
420
				$flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
421
			}
422
			$flightover_data = substr($flightover_data, 0, -1);
423
			print $flightover_data;
424
			print '];';
425
			print 'var dataset = {};var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
426
			print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
427
			print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
428
			print 'new Datamap({
429
			    element: document.getElementById("chart10"),
430
			    projection: "mercator", // big world map
431
			    fills: { defaultFill: "#F5F5F5" },
432
			    data: dataset,
433
			    responsive: true,
434
			    geographyConfig: {
435
				borderColor: "#DEDEDE",
436
				highlightBorderWidth: 2,
437
				highlightFillColor: function(geo) {
438
				    return geo["fillColor"] || "#F5F5F5";
439
				},
440
				highlightBorderColor: "#B7B7B7",
441
				done: function(datamap) {
442
				    datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
443
				    function redraw() {
444
					datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
445
				    }
446
				},
447
				popupTemplate: function(geo, data) {
448
				    if (!data) { return ; }
449
				    return ['."'".'<div class="hoverinfo">'."','<strong>', geo.properties.name, '</strong>','<br>Count: <strong>', data.numberOfThings, '</strong>','</div>'].join('');
450
				}
451
			    }
452
			});";
453
			print '</script>';
454
		}
455
?>
456
                <!--
457
                <div class="more">
458
                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
459
                </div>
460
                -->
461
            </div>
462
        </div>
463
464
<?php
465
	}
466
?>
467
<?php
468
	if ($type == 'aircraft') {
469
?>
470
        <div class="row column">
471
            <div class="col-md-6">
472
<?php
473
		$airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
474
		if (count($airport_airport_array) > 0) {
475
			print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
476
			print '<div id="chart3" class="chart" width="100%"></div><script>';
477
			print "\n";
478
			print 'var series = [';
479
			$airport_data = '';
480
			foreach($airport_airport_array as $airport_item)
481
			{
482
				$airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],';
483
			}
484
			$airport_data = substr($airport_data, 0, -1);
485
			print $airport_data;
486
			print '];'."\n";
487
			print 'var onlyValues = series.map(function(obj){ return obj[0]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'."\n";
488
			print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'."\n";
489
			print 'var radiusScale = d3.scale.log().domain([minValue,maxValue]).range([0,10]);'."\n";
490
			print 'var dataset = [];'."\n";
491
			print 'var colorset = [];'."\n";
492
			print 'colorset["defaultFill"] = "#F5F5F5";';
493
			print 'series.forEach(function(item){'."\n";
494
			print 'var cnt = item[0], nm = item[1], lat = item[2], long = item[3];'."\n";
495
			print 'colorset[nm] = paletteScale(cnt);';
496
			print 'dataset.push({ count: cnt, name: nm, radius: Math.floor(radiusScale(cnt)), latitude: lat, longitude: long, fillKey: nm });'."\n";
497
			print '});'."\n";
498
			print 'var bbl = new Datamap({
499
			    element: document.getElementById("chart3"),
500
			    projection: "mercator", // big world map
501
			    fills: colorset,
502
			    responsive: true,
503
			    geographyConfig: {
504
				borderColor: "#DEDEDE",
505
				highlightBorderWidth: 2,
506
				highlightFillColor: function(geo) {
507
				    return geo["fillColor"] || "#F5F5F5";
508
				},
509
				highlightBorderColor: "#B7B7B7"
510
			    },
511
			    done: function(datamap) {
512
				datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
513
				function redraw() {
514
				    datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
515
				}
516
			    }
517
			});
518
			bbl.bubbles(dataset,{
519
			    popupTemplate: function(geo, data) {
520
				if (!data) { return ; }
521
				return ['."'".'<div class="hoverinfo">'."','<strong>', data.name, '</strong>','<br>Count: <strong>', data.count, '</strong>','</div>'].join('');
522
			    }
523
			});";
524
			print '</script>';
525
			print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
526
			if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
527
			print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
528
		}
529
?>
530
            </div>
531
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
532
533
            <div class="col-md-6">
534
<?php
535
		$airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
536
		if (count($airport_airport_array2) > 0) {
537
			print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
538
			print '<div id="chart4" class="chart" width="100%"></div><script>';
539
			print "\n";
540
			print 'var series = [';
541
			$airport_data = '';
542
			foreach($airport_airport_array2 as $airport_item)
543
			{
544
				$airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
545
			}
546
			$airport_data = substr($airport_data, 0, -1);
547
			print $airport_data;
548
			print '];'."\n";
549
			print 'var onlyValues = series.map(function(obj){ return obj[0]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'."\n";
550
			print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'."\n";
551
			print 'var radiusScale = d3.scale.log().domain([minValue,maxValue]).range([0,10]);'."\n";
552
			print 'var dataset = [];'."\n";
553
			print 'var colorset = [];'."\n";
554
			print 'colorset["defaultFill"] = "#F5F5F5";';
555
			print 'series.forEach(function(item){'."\n";
556
			print 'var cnt = item[0], nm = item[1], lat = item[2], long = item[3];'."\n";
557
			print 'colorset[nm] = paletteScale(cnt);';
558
			print 'dataset.push({ count: cnt, name: nm, radius: Math.floor(radiusScale(cnt)), latitude: lat, longitude: long, fillKey: nm });'."\n";
559
			print '});'."\n";
560
			print 'var bbl = new Datamap({
561
			    element: document.getElementById("chart4"),
562
			    projection: "mercator", // big world map
563
			    fills: colorset,
564
			    responsive: true,
565
			    geographyConfig: {
566
				borderColor: "#DEDEDE",
567
				highlightBorderWidth: 2,
568
				highlightFillColor: function(geo) {
569
				    return geo["fillColor"] || "#F5F5F5";
570
				},
571
				highlightBorderColor: "#B7B7B7"
572
			    },
573
			    done: function(datamap) {
574
				datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
575
				function redraw() {
576
				    datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
577
				}
578
			    }
579
			});
580
			bbl.bubbles(dataset,{
581
			    popupTemplate: function(geo, data) {
582
				if (!data) { return ; }
583
				return ['."'".'<div class="hoverinfo">'."','<strong>', data.name, '</strong>','<br>Count: <strong>', data.count, '</strong>','</div>'].join('');
584
			    }
585
			});";
586
			print '</script>';
587
			print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
588
			if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
589
			print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
590
		}
591
?>
592
            </div>
593
        </div>
594
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
595
<?php 
596
	}
597
?>
598
<?php
599
	if ($type == 'aircraft') {
600
?>
601
<?php
602
		if ($year == '' && $month == '') {
603
?>
604
        <div class="row column">
605
            <div class="col-md-6">
606
                <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
607
<?php
608
			$year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
609
			if (count($year_array) == 0) print _("No data available");
610
			else {
611
				print '<div id="chart8" class="chart" width="100%"></div><script>';
612
				$year_data = '';
613
				$year_cnt = '';
614
				foreach($year_array as $year_item)
615
				{
616
					$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
617
					$year_cnt .= $year_item['date_count'].',';
618
				}
619
				$year_data = "['x',".substr($year_data, 0, -1)."]";
620
				$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
621
				print 'c3.generate({
622
				    bindto: "#chart8",
623
				    data: { x: "x",
624
				     columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
625
				     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "# of Flights"}},legend: { show: false }});';
626
				print '</script>';
627
			}
628
?>
629
                <div class="more">
630
                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
631
                </div>
632
            </div>
633
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
634
            <div class="col-md-6">
635
                <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
636
<?php
637
			$month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
638
			if (count($month_array) == 0) print _("No data available");
639
			else {
640
				print '<div id="chart9" class="chart" width="100%"></div><script>';
641
				$month_data = '';
642
				$month_cnt = '';
643
				foreach($month_array as $month_item)
644
				{
645
					$month_data .= '"'.$month_item['date_name'].'",';
646
					$month_cnt .= $month_item['date_count'].',';
647
				}
648
				$month_data = "['x',".substr($month_data, 0, -1)."]";
649
				$month_cnt = "['flights',".substr($month_cnt,0,-1)."]";
650
				print 'c3.generate({
651
				    bindto: "#chart9",
652
				    data: { x: "x",
653
				     columns: ['.$month_data.','.$month_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
654
				     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m-%d"}}, y: { label: "# of Flights"}},legend: { show: false }});';
655
				print '</script>';
656
			}
657
?>
658
                <div class="more">
659
                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
660
                </div>
661
            </div>
662
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
663
664
            <div class="col-md-6">
665
                <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
666
<?php
667
			$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
668
			if (empty($date_array)) print _("No data available");
669
			else {
670
				print '<div id="chart5" class="chart" width="100%"></div><script>';
671
				$date_data = '';
672
				$date_cnt = '';
673
				foreach($date_array as $date_item)
674
				{
675
					$date_data .= '"'.$date_item['date_name'].'",';
676
					$date_cnt .= $date_item['date_count'].',';
677
				}
678
				$date_data = "['x',".substr($date_data, 0, -1)."]";
679
				$date_cnt = "['flights',".substr($date_cnt,0,-1)."]";
680
				print 'c3.generate({
681
				    bindto: "#chart5",
682
				    data: { x: "x",
683
				     columns: ['.$date_data.','.$date_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
684
				     axis: { x: { type: "timeseries",tick: { format: "%Y-%m-%d"}}, y: { label: "# of Flights"}},legend: { show: false }});';
685
				print '</script>';
686
			}
687
?>
688
                <div class="more">
689
                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
690
                </div>
691
            </div>
692
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
693
            <div class="col-md-6">
694
                <h2><?php echo _("Busiest Time of the Day"); ?></h2>
695
<?php
696
			$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
697
			if (empty($hour_array)) print _("No data available");
698
			else {
699
				print '<div id="chart6" class="chart" width="100%"></div><script>';
700
				$hour_data = '';
701
				$hour_cnt = '';
702
				foreach($hour_array as $hour_item)
703
				{
704
					$hour_data .= '"'.$hour_item['hour_name'].':00",';
705
					$hour_cnt .= $hour_item['hour_count'].',';
706
				}
707
				$hour_data = "[".substr($hour_data, 0, -1)."]";
708
				$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
709
				print 'c3.generate({
710
				    bindto: "#chart6",
711
				    data: {
712
				     columns: ['.$hour_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
713
				     axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Flights"}},legend: { show: false }});';
714
				print '</script>';
715
			}
716
?>
717
                <div class="more">
718
                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
719
                </div>
720
            </div>
721
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
722
        </div>
723
<?php
724
		}
725
?>
726
<?php
727
	}
728
?>
729
<?php
730
	if ($type == 'marine') {
731
?>
732
<?php
733
		if ($year == '' && $month == '') {
734
?>
735
        <div class="row column">
736
            <div class="col-md-6">
737
                <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
738
<?php
739
			$year_array = $Marine->countAllMonthsLastYear(true,$airline_icao,$filter_name);
0 ignored issues
show
The call to Marine::countAllMonthsLastYear() has too many arguments starting with $airline_icao.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
740
			if (count($year_array) == 0) print _("No data available");
741
			else {
742
				print '<div id="chart8" class="chart" width="100%"></div><script>';
743
				$year_data = '';
744
				$year_cnt = '';
745
				foreach($year_array as $year_item)
746
				{
747
					$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
748
					$year_cnt .= $year_item['date_count'].',';
749
				}
750
				$year_data = "['x',".substr($year_data, 0, -1)."]";
751
				$year_cnt = "['vessels',".substr($year_cnt,0,-1)."]";
752
				print 'c3.generate({
753
				    bindto: "#chart8",
754
				    data: { x: "x",
755
				     columns: ['.$year_data.','.$year_cnt.'], types: { vessels: "area"}, colors: { vessels: "#1a3151"}},
756
				     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "# of Vessels"}},legend: { show: false }});';
757
				print '</script>';
758
			}
759
?>
760
	    <!--
761
                <div class="more">
762
                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
763
                </div>
764
                -->
765
            </div>
766
            
767
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
768
            <div class="col-md-6">
769
                <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
770
<?php
771
			$month_array = $Marine->countAllDatesLastMonth($airline_icao,$filter_name);
0 ignored issues
show
The call to Marine::countAllDatesLastMonth() has too many arguments starting with $filter_name.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
772
			if (count($month_array) == 0) print _("No data available");
773
			else {
774
				print '<div id="chart9" class="chart" width="100%"></div><script>';
775
				$month_data = '';
776
				$month_cnt = '';
777
				foreach($month_array as $month_item)
778
				{
779
					$month_data .= '"'.$month_item['date_name'].'",';
780
					$month_cnt .= $month_item['date_count'].',';
781
				}
782
				$month_data = "['x',".substr($month_data, 0, -1)."]";
783
				$month_cnt = "['vessels',".substr($month_cnt,0,-1)."]";
784
				print 'c3.generate({
785
				    bindto: "#chart9",
786
				    data: { x: "x",
787
				     columns: ['.$month_data.','.$month_cnt.'], types: { vessels: "area"}, colors: { vessels: "#1a3151"}},
788
				     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m-%d"}}, y: { label: "# of Vessels"}},legend: { show: false }});';
789
				print '</script>';
790
			}
791
?>
792
               <!--
793
                <div class="more">
794
                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
795
                </div>
796
                -->
797
                
798
            </div>
799
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
800
801
            <div class="col-md-6">
802
                <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
803
<?php
804
			$date_array = $Marine->countAllDatesLast7Days($airline_icao,$filter_name);
0 ignored issues
show
The call to Marine::countAllDatesLast7Days() has too many arguments starting with $filter_name.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
805
			if (empty($date_array)) print _("No data available");
806
			else {
807
				print '<div id="chart5" class="chart" width="100%"></div><script>';
808
				$date_data = '';
809
				$date_cnt = '';
810
				foreach($date_array as $date_item)
811
				{
812
					$date_data .= '"'.$date_item['date_name'].'",';
813
					$date_cnt .= $date_item['date_count'].',';
814
				}
815
				$date_data = "['x',".substr($date_data, 0, -1)."]";
816
				$date_cnt = "['vessels',".substr($date_cnt,0,-1)."]";
817
				print 'c3.generate({
818
				    bindto: "#chart5",
819
				    data: { x: "x",
820
				     columns: ['.$date_data.','.$date_cnt.'], types: { vessels: "area"}, colors: { vessels: "#1a3151"}},
821
				     axis: { x: { type: "timeseries",tick: { format: "%Y-%m-%d"}}, y: { label: "# of Vessels"}},legend: { show: false }});';
822
				print '</script>';
823
			}
824
?>
825
                <!--
826
                <div class="more">
827
                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
828
                </div>
829
                -->
830
            </div>
831
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
832
            <div class="col-md-6">
833
                <h2><?php echo _("Busiest Time of the Day"); ?></h2>
834
<?php
835
			$hour_array = $Marine->countAllHours('hour',true,$airline_icao,$filter_name);
0 ignored issues
show
true is of type boolean, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
The call to Marine::countAllHours() has too many arguments starting with $airline_icao.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
836
			if (empty($hour_array)) print _("No data available");
837
			else {
838
				print '<div id="chart6" class="chart" width="100%"></div><script>';
839
				$hour_data = '';
840
				$hour_cnt = '';
841
				foreach($hour_array as $hour_item)
842
				{
843
					$hour_data .= '"'.$hour_item['hour_name'].':00",';
844
					$hour_cnt .= $hour_item['hour_count'].',';
845
				}
846
				$hour_data = "[".substr($hour_data, 0, -1)."]";
847
				$hour_cnt = "['vessels',".substr($hour_cnt,0,-1)."]";
848
				print 'c3.generate({
849
				    bindto: "#chart6",
850
				    data: {
851
				     columns: ['.$hour_cnt.'], types: { vessels: "area"}, colors: { vessels: "#1a3151"}},
852
				     axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Vessels"}},legend: { show: false }});';
853
				print '</script>';
854
			}
855
?>
856
                <!--
857
                <div class="more">
858
                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
859
                </div>
860
                -->
861
            </div>
862
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
863
        </div>
864
<?php
865
		}
866
?>
867
<?php
868
	}
869
?>
870
<?php
871
	if ($type == 'aircraft') {
872
?>
873
<?php
874
		if (($airline_icao == '' || $airline_icao == 'all') && $year == '' && $month == '' && isset($globalAccidents) && $globalAccidents) {
875
?>
876
        <div class="row column">
877
            <div class="col-md-6">
878
                <h2><?php echo _("Fatalities by Years"); ?></h2>
879
<?php
880
			$year_array = $Stats->countFatalitiesByYear();
881
			if (count($year_array) == 0) print _("No data available");
882
			else {
883
				print '<div id="chart32" class="chart" width="100%"></div><script>';
884
				$year_data = '';
885
				$year_cnt = '';
886
				foreach($year_array as $year_item)
887
				{
888
					$year_data .= '"'.$year_item['year'].'-01-01",';
889
					$year_cnt .= $year_item['count'].',';
890
				}
891
				$year_data = "['x',".substr($year_data, 0, -1)."]";
892
				$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
893
				print 'c3.generate({
894
				    bindto: "#chart32",
895
				    data: { x: "x",
896
				     columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
897
				     axis: { x: { type: "timeseries",tick: { format: "%Y"}}, y: { label: "# of Fatalities"}},legend: { show: false }});';
898
				print '</script>';
899
			}
900
?>
901
                <div class="more">
902
                    <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
903
                </div>
904
            </div>
905
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
906
907
        <div class="row column">
908
            <div class="col-md-6">
909
                <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
910
<?php
911
			$year_array = $Stats->countFatalitiesLast12Months();
912
			if (count($year_array) == 0) print _("No data available");
913
			else {
914
				print '<div id="chart33" class="chart" width="100%"></div><script>';
915
				$year_data = '';
916
				$year_cnt = '';
917
				foreach($year_array as $year_item)
918
				{
919
					$year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",';
920
					$year_cnt .= $year_item['count'].',';
921
				}
922
				$year_data = "['x',".substr($year_data, 0, -1)."]";
923
				$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
924
				print 'c3.generate({
925
				    bindto: "#chart33",
926
				    data: { x: "x",
927
				     columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
928
				     axis: { x: { type: "timeseries",tick: { format: "%Y-%m"}}, y: { label: "# of Fatalities"}},legend: { show: false }});';
929
				print '</script>';
930
			}
931
?>
932
                <div class="more">
933
                    <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
934
                </div>
935
            </div>
936
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
937
<br/>
938
<?php
939
		}
940
?>
941
<?php
942
	}
943
?>
944
<?php
945
	if ($type == 'aircraft') {
946
?>
947
<?php
948
		if (($airline_icao == '' || $airline_icao == 'all') && $filter_name == '' && $year == '' && $month == '') {
949
?>
950
        <div class="row column">
951
<?php
952
			//$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
953
			if ($year == '' && $month == '') {
954
				$polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
955
			} else {
956
				$polar = $Stats->getStatsSource('polar',$year,$month);
957
			}
958
			if (!empty($polar)) {
959
				print '<h2>'._("Coverage pattern").'</h2>';
960
				foreach ($polar as $eachpolar) {
961
					unset($polar_data);
962
					$Spotter = new Spotter();
963
					$data = json_decode($eachpolar['source_data']);
964
					foreach($data as $value => $key) {
965
						$direction = $Spotter->parseDirection(($value*22.5));
966
						$distance = $key;
967
						$unit = 'km';
968
						if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
969
							$distance = round($distance*0.539957);
970
							$unit = 'nm';
971
						} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
972
							$distance = round($distance*0.621371);
973
							$unit = 'mi';
974
						} elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
975
							$distance = $distance;
976
							$unit = 'km';
977
						}
978
						if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
979
						else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
980
					}
981
?>
982
            <div class="col-md-6">
983
                <h4><?php print $eachpolar['source_name']; ?></h4>
984
        	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
985
        	<script>
986
        	    (function() {
987
        	    var margin = {top: 100, right: 100, bottom: 100, left: 100},
988
			width = Math.min(700, window.innerWidth - 10) - margin.left - margin.right,
989
			height = Math.min(width, window.innerHeight - margin.top - margin.bottom - 20);
990
		    var data = [
991
				    [
992
				    <?php print $polar_data; ?>
993
				    ]
994
				];
995
		    var color = d3.scale.ordinal().range(["#EDC951","#CC333F","#00A0B0"]);
996
		    //var color = d3.scaleOrdinal().range(["#EDC951","#CC333F","#00A0B0"]);
997
		
998
		    var radarChartOptions = {
999
		      w: width,
1000
		      h: height,
1001
		      margin: margin,
1002
		      maxValue: 0.5,
1003
		      levels: 5,
1004
		      roundStrokes: true,
1005
		      color: color,
1006
		      unit: '<?php echo $unit; ?>'
1007
		    };
1008
		    RadarChart("#polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
1009
		    })();
1010
		</script>
1011
            </div>
1012
            <?php
1013
				}
1014
			}
1015
?>
1016
        </div>
1017
        <div class="row column">
1018
            <div class="col-md-6">
1019
<?php
1020
			//$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
1021
			if ($year == '' && $month == '') {
1022
				$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
1023
			} else {
1024
				$msg = $Stats->getStatsSource('msg',$year,$month);
1025
			}
1026
			if (!empty($msg)) {
1027
				print '<h2>'._("Messages received").'</h2>';
1028
				foreach ($msg as $eachmsg) {
1029
					//$eachmsg = $msg[0];
1030
					$data = $eachmsg['source_data'];
1031
					if ($data > 500) $max = (round(($data+100)/100))*100;
1032
					else $max = 500;
1033
?>
1034
        	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1035
        	<script>
1036
		      var g = new JustGage({
1037
			    id: "msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>",
1038
			    value: <?php echo $data; ?>,
1039
			    min: 0,
1040
			    max: <?php print $max; ?>,
1041
			    valueMinFontSize: 10,
1042
			    height: 120,
1043
			    width: 220,
1044
			    symbol: ' msg/s',
1045
			    title: "<?php print $eachmsg['source_name']; ?>"
1046
			  });
1047
		</script>
1048
<?php
1049
				}
1050
			}
1051
?>
1052
            </div>
1053
        </div>
1054
        <div class="row column">
1055
<?php
1056
		//$hist = $Stats->getStatsSource(date('Y-m-d'),'hist');
1057
			if ($year == '' && $month == '') {
1058
				$hist = $Stats->getStatsSource('hist',date('Y'),date('m'),date('d'));
1059
			} else {
1060
				$hist = $Stats->getStatsSource('hist',$year,$month);
1061
			}
1062
			foreach ($hist as $hists) {
1063
				//$hist_data = '';
1064
				$distance_data = '';
1065
				$nb_data = '';
1066
				$source = $hists['source_name'];
1067
				$hist_array = json_decode($hists['source_data']);
1068
				$unit = 'km';
1069
				foreach($hist_array as $distance => $nb)
1070
				{
1071
					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1072
						$distance = round($distance*0.539957);
1073
						$unit = 'nm';
1074
					} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
1075
						$distance = round($distance*0.621371);
1076
						$unit = 'mi';
1077
					} elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
1078
						$distance = $distance;
1079
						$unit = 'km';
1080
					}
1081
					//$hist_data .= '[ "'.$distance.'",'.$nb.'],';
1082
					$distance_data .= '"'.$distance.'",';
1083
					$nb_data .= $nb.',';
1084
				}
1085
				//$hist_data = substr($hist_data, 0, -1);
1086
				$distance_data = "['x',".substr($distance_data, 0, -1)."]";
1087
				$nb_data = "['flights',".substr($nb_data, 0, -1)."]";
1088
?>
1089
            <div class="col-md-6">
1090
                <h2><?php echo sprintf(_("Flights Distance for %s"),$source); ?></h2>
1091
<?php
1092
				print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>';
1093
				print 'c3.generate({
1094
				    bindto: "#charthist-'.str_replace(' ','_',strtolower($source)).'",
1095
				    data: { x: "x",
1096
				    columns: ['.$distance_data.','.$nb_data.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
1097
				    axis: { x: {label : { text: "Distance in '.$unit.'", position: "outer-right"}}, y: { label: "# of Flights"}},legend: { show: false }});';
1098
				print '</script>';
1099
?>
1100
    	    </div>
1101
	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1102
<?php
1103
			}
1104
?>
1105
        </div>
1106
<?php
1107
		}
1108
?>
1109
<?php
1110
	}
1111
?>
1112
    </div>
1113
</div>  
1114
1115
<?php
1116
require_once('footer.php');
1117
?>