Completed
Push — master ( 81ed4a...f9d220 )
by Yannick
97:00 queued 67:59
created

statistics.php (2 issues)

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.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
} elseif (isset($_GET['satellite'])) {
18
	require_once('require/class.Satellite.php');
19
	$Satellite = new Satellite();
20
	$type = 'satellite';
21
} else {
22
	require_once('require/class.Spotter.php');
23
}
24
25
if (!isset($filter_name)) $filter_name = '';
26
$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
27
if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) {
28
	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
29
}
30
if ($type == 'aircraft' && $airline_icao != '' && $airline_icao != 'all') {
31
	$Spotter = new Spotter();
32
	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
33
	if (isset($airline_info[0]['name'])) {
34
		$airline_name = $airline_info[0]['name'];
35
	} elseif (strpos($airline_icao,'alliance_') !== FALSE) {
36
		$alliance_name = $airline_icao;
37
	}
38
}
39
if ($type == 'aircraft' && isset($airline_name)) {
40
	$title = _("Statistics").' - '.$airline_name;
41
} else {
42
	$title = _("Statistics");
43
}
44
45
$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
46
$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
47
48
require_once('header.php');
49
50
?>
51
<link href="<?php echo $globalURL; ?>/css/c3.min.css" rel="stylesheet" type="text/css">
52
<!--<script type="text/javascript" src="https://d3js.org/d3.v4.min.js"></script>-->
53
<!--<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script>-->
54
<script type="text/javascript" src="<?php echo $globalURL; ?>/js/d3.min.js"></script>
55
<script type="text/javascript" src="<?php echo $globalURL; ?>/js/c3.min.js"></script>
56
<script type="text/javascript" src="<?php echo $globalURL; ?>/js/d3pie.min.js"></script>
57
<script type="text/javascript" src="<?php echo $globalURL; ?>/js/radarChart.js"></script>
58
<script type="text/javascript" src="<?php echo $globalURL; ?>/js/raphael-2.1.4.min.js"></script>
59
<script type="text/javascript" src="<?php echo $globalURL; ?>/js/justgage.js"></script>
60
<script type="text/javascript" src="<?php echo $globalURL; ?>/js/topojson.v2.min.js"></script>
61
<script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script>
62
<div class="column">
63
    <div class="info">
64
            <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1>
65
<?php 
66
if ($type == 'aircraft') {
67
	$last_update = $Stats->getLastStatsUpdate();
68
	//if (isset($last_update[0]['value'])) print '<!-- Last update : '.$last_update[0]['value'].' -->';
69
	if (isset($last_update[0]['value'])) {
70
		date_default_timezone_set('UTC');
71
		$lastupdate = strtotime($last_update[0]['value']);
72
		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
73
		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
74
	}
75
}
76
?>
77
    </div>
78
<?php 
79
include('statistics-sub-menu.php'); 
80
?>
81
    <p class="global-stats">
82
<?php
83
if ($type == 'aircraft') {
84
?>
85
        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Flights"); ?></span>
86
	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
87
        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
88
        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
89
<?php
90
	if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
91
?>
92
    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span>
93
	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
94
<?php
95
	}
96
	if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) {
97
?>
98
    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span>
99
	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
100
<?php
101
	}
102
?>
103
        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
104
        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
105
<?php
106
	if ($airline_icao == '') {
107
?>
108
        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span>
109
	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
110
<?php
111
	}
112
?>
113
<?php
114
	if (!(isset($globalVA) && $globalVA) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalphpVMS) && $globalphpVMS) && !(isset($globalVAM) && $globalVAM)) {
115
		if ($airline_icao == '' || $airline_icao == 'all') {
116
?>
117
        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name,$year,$month)); ?></span> <?php echo _("Military"); ?></span>
118
	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
119
<?php
120
		}
121
	}
122
	?>
123
<?php
124
} elseif ($type == 'marine') {
125
?>
126
	<span><span class="badge"><?php print number_format($Marine->countOverallMarine(array(),$year,$month)); ?></span> <?php echo _("Vessels"); ?></span>
127
	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
128
	<span><span class="badge"><?php print number_format($Marine->countOverallMarineTypes(array(),$year,$month)); ?></span> <?php echo _("Types"); ?></span>
129
	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
130
<?php
131
} elseif ($type == 'tracker') {
132
?>
133
	<span><span class="badge"><?php print number_format($Tracker->countOverallTracker(array(),$year,$month)); ?></span> <?php echo _("Trackers"); ?></span>
134
	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
135
	<span><span class="badge"><?php print number_format($Tracker->countOverallTrackerTypes(array(),$year,$month)); ?></span> <?php echo _("Types"); ?></span>
136
	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
137
<?php
138
}
139
?>
140
    </p>
141
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
142
    <div class="specific-stats">
143
<?php
144
if ($type == 'aircraft') {
145
?>
146
        <div class="row column">
147
            <div class="col-md-6">
148
                <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
149
<?php
150
	$aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
151
	if (count($aircraft_array) == 0) {
152
		print _("No data available");
153
	} else {
154
		print '<div id="chart1" class="chart" width="100%"></div><script>';
155
		$aircraft_data = '';
156
		foreach($aircraft_array as $aircraft_item) {
157
			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
158
			else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
159
		}
160
		$aircraft_data = substr($aircraft_data, 0, -1);
161
		print 'var series = ['.$aircraft_data.'];';
162
		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);';
163
		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);';
164
		print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
165
		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":';
166
		print 'dataset';
167
		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}}});';
168
		print '</script>';
169
	}
170
?>
171
                <div class="more">
172
<?php
173
	if ($year != '' && $month != '') {
174
?>
175
            	    <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>
176
<?php
177
	} else {
178
?>
179
            	    <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>
180
<?php
181
	}
182
?>
183
                </div>
184
            </div>
185
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
186
<?php
187
	if ($airline_icao == '' || $airline_icao == 'all') {
188
		$airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month);
189
		if (count($airline_array) > 0) {
190
			print '<div class="col-md-6">';
191
			print '<h2>'._("Top 10 Most Common Airline").'</h2>';
192
			print '<div id="chart2" class="chart" width="100%"></div><script>';
193
			$airline_data = '';
194
			foreach($airline_array as $airline_item) {
195
				$airline_data .= '["'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
196
			}
197
			$airline_data = substr($airline_data, 0, -1);
198
			print 'var series = ['.$airline_data.'];';
199
			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);';
200
			print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
201
			print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
202
			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":';
203
			print 'dataset';
204
			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}}});';
205
			print '</script>';
206
			if ($year != '' && $month != '') {
207
				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
208
				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
209
				print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
210
			} else {
211
				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
212
				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
213
				print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
214
			}
215
			print '</div>';
216
		}
217
?>
218
        </div>
219
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
220
<?php
221
	}
222
}
223
?>
224
<?php
225
if ($type == 'marine') {
226
?>
227
        <div class="row column">
228
            <div class="col-md-6">
229
                <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2>
230
<?php
231
	$marine_array = $Marine->countAllMarineTypes(true,0,'',array(),$year,$month);
232
	if (count($marine_array) == 0) print _("No data available");
233
	else {
234
		print '<div id="chart1" class="chart" width="100%"></div><script>';
235
		$marine_data = '';
236
		foreach($marine_array as $marine_item) {
237
			$marine_data .= '["'.$marine_item['marine_type'].'",'.$marine_item['marine_type_count'].'],';
238
		}
239
		$marine_data = substr($marine_data, 0, -1);
240
		print 'var series = ['.$marine_data.'];';
241
		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);';
242
		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);';
243
		print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
244
		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":';
245
		print 'dataset';
246
		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}}});';
247
		print '</script>';
248
	}
249
?>
250
                <div class="more">
251
            	    <?php
252
            	    /*
253
            		if ($year != '' && $month != '') {
254
            	    ?>
255
            	    <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>
256
            	    <?php
257
            		} else {
258
            	    ?>
259
            	    <a href="<?php print $globalURL; ?>/marine/statistics/type" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
260
            	    <?php
261
            		}
262
            		*/
263
            	    ?>
264
                </div>
265
            </div>
266
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
267
<!--	</div>-->
268
<?php
269
}
270
if ($type == 'tracker') {
271
?>
272
        <div class="row column">
273
            <div class="col-md-6">
274
                <h2><?php echo _("Top 10 Most Common Tracker Type"); ?></h2>
275
<?php
276
	$tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month);
277
	if (count($tracker_array) == 0) print _("No data available");
278
	else {
279
		print '<div id="chart1" class="chart" width="100%"></div><script>';
280
		$tracker_data = '';
281
		foreach($tracker_array as $tracker_item) {
282
			$tracker_data .= '["'.$tracker_item['tracker_type'].'",'.$tracker_item['tracker_type_count'].'],';
283
		}
284
		$tracker_data = substr($tracker_data, 0, -1);
285
		print 'var series = ['.$tracker_data.'];';
286
		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);';
287
		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);';
288
		print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
289
		print 'var trackertype = 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":';
290
		print 'dataset';
291
		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}}});';
292
		print '</script>';
293
	}
294
?>
295
                <div class="more">
296
            	    <?php
297
            	    /*
298
            		if ($year != '' && $month != '') {
299
            	    ?>
300
            	    <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>
301
            	    <?php
302
            		} else {
303
            	    ?>
304
            	    <a href="<?php print $globalURL; ?>/marine/statistics/type" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
305
            	    <?php
306
            		}
307
            		*/
308
            	    ?>
309
                </div>
310
            </div>
311
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
312
<!--	</div>-->
313
<?php
314
}
315
if ($type == 'satellite') {
316
?>
317
        <div class="row column">
318
            <div class="col-md-6">
319
                <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
320
<?php
321
		$owner_array = $Satellite->countAllOwners(true);
322
		if (count($owner_array) == 0) print _("No data available");
323
		else {
324
			print '<div id="chart7" class="chart" width="100%"></div><script>';
325
			$owner_data = '';
326
			foreach($owner_array as $owner_item) {
327
				$owner_data .= '["'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
328
			}
329
			$owner_data = substr($owner_data, 0, -1);
330
			print 'var series = ['.$owner_data.'];';
331
			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);';
332
			print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
333
			print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
334
			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":';
335
			print 'dataset';
336
			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}}});';
337
			print '</script>';
338
		}
339
?>
340
               <!--
341
                <div class="more">
342
                    <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>
343
                </div>
344
                -->
345
            </div>
346
	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
347
            <div class="col-md-6">
348
                <h2><?php echo _("Top 10 Most Common Countries Owners"); ?></h2>
349
<?php
350
		$countries_array = $Satellite->countAllCountriesOwners(true);
351
		if (count($countries_array) == 0) print _("No data available");
352
		else {
353
			print '<div id="chart8" class="chart" width="100%"></div><script>';
354
			$owner_data = '';
355
			foreach($countries_array as $owner_item) {
356
				$owner_data .= '["'.$owner_item['country_name'].'",'.$owner_item['country_count'].'],';
357
			}
358
			$owner_data = substr($owner_data, 0, -1);
359
			print 'var series = ['.$owner_data.'];';
360
			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);';
361
			print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
362
			print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
363
			print 'var ownercnt = new d3pie("chart8",{"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":';
364
			print 'dataset';
365
			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}}});';
366
			print '</script>';
367
		}
368
?>
369
	    <!--
370
                <div class="more">
371
                    <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>
372
                </div>
373
                -->
374
            </div>
375
            
376
	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
377
²	</div>
378
        <div class="row column">
379
            <div class="col-md-6">
380
                <h2><?php echo _("Top 10 Most Common Launch Sites"); ?></h2>
381
<?php
382
		$launch_site_array = $Satellite->countAllLaunchSite(true);
383
		if (count($launch_site_array) == 0) print _("No data available");
384
		else {
385
			print '<div id="chart9" class="chart" width="100%"></div><script>';
386
			$launch_site_data = '';
387
			foreach($launch_site_array as $launch_site_item) {
388
				$launch_site_data .= '["'.$launch_site_item['launch_site'].'",'.$launch_site_item['launch_site_count'].'],';
389
			}
390
			$launch_site_data = substr($launch_site_data, 0, -1);
391
			print 'var series = ['.$launch_site_data.'];';
392
			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);';
393
			print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
394
			print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
395
			print 'var ownercnt = new d3pie("chart9",{"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":';
396
			print 'dataset';
397
			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}}});';
398
			print '</script>';
399
		}
400
?>
401
               <!--
402
                <div class="more">
403
                    <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>
404
                </div>
405
                -->
406
            </div>
407
        </div>
408
<?php
409
}
410
if ($type == 'aircraft') {
411
?>
412
        <div class="row column">
413
<?php
414
	$flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
415
	//if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
416
	if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
417
		if (empty($flightover_array)) {
418
			print '<div class="col-md-12">';
419
		} else {
420
			print '<div class="col-md-6">';
421
		}
422
?>
423
                <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
424
<?php
425
		$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
426
		if (count($pilot_array) == 0) print _("No data available");
427
		else {
428
			print '<div id="chart7" class="chart" width="100%"></div><script>';
429
			$pilot_data = '';
430
			foreach($pilot_array as $pilot_item) {
431
				$pilot_data .= '["'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
432
			}
433
			$pilot_data = substr($pilot_data, 0, -1);
434
			print 'var series = ['.$pilot_data.'];';
435
			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);';
436
			print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
437
			print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
438
			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":';
439
			print 'dataset';
440
			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}}});';
441
			print '</script>';
442
		}
443
		print '<div class="more">';
444
		print '<a href="'.$globalURL.'/statistics/pilot'; 
445
		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
446
		print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
447
		print '</div>';
448
?>
449
            </div>
450
451
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
452
<?php
453
	}
454
	// else {
455
	if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) {
456
?>
457
            <div class="col-md-6">
458
                <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
459
<?php
460
		$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
461
		if (count($owner_array) == 0) print _("No data available");
462
		else {
463
			print '<div id="chart7" class="chart" width="100%"></div><script>';
464
			$owner_data = '';
465
			foreach($owner_array as $owner_item) {
466
				$owner_data .= '["'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
467
			}
468
			$owner_data = substr($owner_data, 0, -1);
469
			print 'var series = ['.$owner_data.'];';
470
			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);';
471
			print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
472
			print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
473
			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":';
474
			print 'dataset';
475
			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}}});';
476
			print '</script>';
477
		}
478
?>
479
                <div class="more">
480
                    <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>
481
                </div>
482
            </div>
483
        
484
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
485
<?php
486
	}
487
	if (!empty($flightover_array)) {
488
?>
489
            <div class="col-md-6">
490
                <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
491
<?php
492
	 //$flightover_array = $Stats->countAllFlightOverCountries();
493
		if (count($flightover_array) == 0) print _("No data available");
494
		else {
495
			print '<div id="chart10" class="chart" width="100%"></div><script>';
496
			print 'var series = [';
497
			$flightover_data = '';
498
			foreach($flightover_array as $flightover_item) {
499
				$flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
500
			}
501
			$flightover_data = substr($flightover_data, 0, -1);
502
			print $flightover_data;
503
			print '];';
504
			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);';
505
			print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
506
			print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
507
			print 'new Datamap({
508
			    element: document.getElementById("chart10"),
509
			    projection: "mercator", // big world map
510
			    fills: { defaultFill: "#F5F5F5" },
511
			    data: dataset,
512
			    responsive: true,
513
			    geographyConfig: {
514
				borderColor: "#DEDEDE",
515
				highlightBorderWidth: 2,
516
				highlightFillColor: function(geo) {
517
				    return geo["fillColor"] || "#F5F5F5";
518
				},
519
				highlightBorderColor: "#B7B7B7",
520
				done: function(datamap) {
521
				    datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
522
				    function redraw() {
523
					datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
524
				    }
525
				},
526
				popupTemplate: function(geo, data) {
527
				    if (!data) { return ; }
528
				    return ['."'".'<div class="hoverinfo">'."','<strong>', geo.properties.name, '</strong>','<br>Count: <strong>', data.numberOfThings, '</strong>','</div>'].join('');
529
				}
530
			    }
531
			});";
532
			print '</script>';
533
		}
534
?>
535
                <div class="more">
536
                    <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>
537
                </div>
538
            </div>
539
<?php
540
	}
541
?>
542
        </div>
543
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
544
        </div>
545
<?php
546
}
547
if ($type == 'marine') {
548
	$flightover_array = $Marine->countAllMarineOverCountries(true);
549
?>
550
<!--    <div class="row column">-->
551
	<div class="col-md-6">
552
            <h2><?php echo _("Top 20 Most Common Country a Vessel was inside"); ?></h2>
553
<?php
554
	if (count($flightover_array) == 0) print _("No data available");
555
	else {
556
		print '<div id="chart10" class="chart" width="100%"></div><script>';
557
		print 'var series = [';
558
		$flightover_data = '';
559
		foreach($flightover_array as $flightover_item) {
560
			$flightover_data .= '[ "'.$flightover_item['marine_country_iso3'].'",'.$flightover_item['marine_count'].'],';
561
		}
562
		$flightover_data = substr($flightover_data, 0, -1);
563
		print $flightover_data;
564
		print '];';
565
		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);';
566
		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
567
		print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
568
		print 'new Datamap({
569
		    element: document.getElementById("chart10"),
570
		    projection: "mercator", // big world map
571
		    fills: { defaultFill: "#F5F5F5" },
572
		    data: dataset,
573
		    responsive: true,
574
		    geographyConfig: {
575
			borderColor: "#DEDEDE",
576
			highlightBorderWidth: 2,
577
			highlightFillColor: function(geo) {
578
			    return geo["fillColor"] || "#F5F5F5";
579
			},
580
			highlightBorderColor: "#B7B7B7",
581
			done: function(datamap) {
582
			    datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
583
			    function redraw() {
584
				datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
585
			    }
586
			},
587
			popupTemplate: function(geo, data) {
588
			    if (!data) { return ; }
589
			    return ['."'".'<div class="hoverinfo">'."','<strong>', geo.properties.name, '</strong>','<br>Count: <strong>', data.numberOfThings, '</strong>','</div>'].join('');
590
			}
591
		    }
592
		});";
593
		print '</script>';
594
	}
595
?>
596
                <div class="more">
597
                    <a href="<?php print $globalURL; ?>/marine/statistics/country" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
598
                </div>
599
            </div>
600
        </div>
601
602
<?php
603
}
604
if ($type == 'tracker') {
605
	$flightover_array = $Tracker->countAllTrackerOverCountries(true);
606
?>
607
<!--    <div class="row column">-->
608
	<div class="col-md-6">
609
            <h2><?php echo _("Top 20 Most Common Country a Tracker was inside"); ?></h2>
610
<?php
611
	if (count($flightover_array) == 0) print _("No data available");
612
	else {
613
		print '<div id="chart10" class="chart" width="100%"></div><script>';
614
		print 'var series = [';
615
		$flightover_data = '';
616
		foreach($flightover_array as $flightover_item) {
617
			$flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
618
		}
619
		$flightover_data = substr($flightover_data, 0, -1);
620
		print $flightover_data;
621
		print '];';
622
		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);';
623
		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
624
		print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
625
		print 'new Datamap({
626
		    element: document.getElementById("chart10"),
627
		    projection: "mercator", // big world map
628
		    fills: { defaultFill: "#F5F5F5" },
629
		    data: dataset,
630
		    responsive: true,
631
		    geographyConfig: {
632
			borderColor: "#DEDEDE",
633
			highlightBorderWidth: 2,
634
			highlightFillColor: function(geo) {
635
			    return geo["fillColor"] || "#F5F5F5";
636
			},
637
			highlightBorderColor: "#B7B7B7",
638
			done: function(datamap) {
639
			    datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
640
			    function redraw() {
641
				datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
642
			    }
643
			},
644
			popupTemplate: function(geo, data) {
645
			    if (!data) { return ; }
646
			    return ['."'".'<div class="hoverinfo">'."','<strong>', geo.properties.name, '</strong>','<br>Count: <strong>', data.numberOfThings, '</strong>','</div>'].join('');
647
			}
648
		    }
649
		});";
650
		print '</script>';
651
	}
652
?>
653
                <div class="more">
654
                    <a href="<?php print $globalURL; ?>/tracker/statistics/country" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
655
                </div>
656
            </div>
657
        </div>
658
659
<?php
660
}
661
if ($type == 'aircraft') {
662
?>
663
        <div class="row column">
664
            <div class="col-md-6">
665
<?php
666
	$airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
667
	if (count($airport_airport_array) > 0) {
668
		print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
669
		print '<div id="chart3" class="chart" width="100%"></div><script>';
670
		print "\n";
671
		print 'var series = [';
672
		$airport_data = '';
673
		foreach($airport_airport_array as $airport_item) {
674
			$airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],';
675
		}
676
		$airport_data = substr($airport_data, 0, -1);
677
		print $airport_data;
678
		print '];'."\n";
679
		print 'var onlyValues = series.map(function(obj){ return obj[0]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'."\n";
680
		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'."\n";
681
		print 'var radiusScale = d3.scale.log().domain([minValue,maxValue]).range([0,10]);'."\n";
682
		print 'var dataset = [];'."\n";
683
		print 'var colorset = [];'."\n";
684
		print 'colorset["defaultFill"] = "#F5F5F5";';
685
		print 'series.forEach(function(item){'."\n";
686
		print 'var cnt = item[0], nm = item[1], lat = item[2], long = item[3];'."\n";
687
		print 'colorset[nm] = paletteScale(cnt);';
688
		print 'dataset.push({ count: cnt, name: nm, radius: Math.floor(radiusScale(cnt)), latitude: lat, longitude: long, fillKey: nm });'."\n";
689
		print '});'."\n";
690
		print 'var bbl = new Datamap({
691
		    element: document.getElementById("chart3"),
692
		    projection: "mercator", // big world map
693
		    fills: colorset,
694
		    responsive: true,
695
		    geographyConfig: {
696
			borderColor: "#DEDEDE",
697
			highlightBorderWidth: 2,
698
			highlightFillColor: function(geo) {
699
			    return geo["fillColor"] || "#F5F5F5";
700
			},
701
			highlightBorderColor: "#B7B7B7"
702
		    },
703
		    done: function(datamap) {
704
			datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
705
			function redraw() {
706
			    datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
707
			}
708
		    }
709
		});
710
		bbl.bubbles(dataset,{
711
		    popupTemplate: function(geo, data) {
712
			if (!data) { return ; }
713
			return ['."'".'<div class="hoverinfo">'."','<strong>', data.name, '</strong>','<br>Count: <strong>', data.count, '</strong>','</div>'].join('');
714
		    }
715
		});";
716
		print '</script>';
717
		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
718
		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
719
		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
720
	}
721
?>
722
            </div>
723
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
724
725
            <div class="col-md-6">
726
<?php
727
	$airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
728
	if (count($airport_airport_array2) > 0) {
729
		print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
730
		print '<div id="chart4" class="chart" width="100%"></div><script>';
731
		print "\n";
732
		print 'var series = [';
733
		$airport_data = '';
734
		foreach($airport_airport_array2 as $airport_item)
735
		{
736
			$airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
737
		}
738
		$airport_data = substr($airport_data, 0, -1);
739
		print $airport_data;
740
		print '];'."\n";
741
		print 'var onlyValues = series.map(function(obj){ return obj[0]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'."\n";
742
		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'."\n";
743
		print 'var radiusScale = d3.scale.log().domain([minValue,maxValue]).range([0,10]);'."\n";
744
		print 'var dataset = [];'."\n";
745
		print 'var colorset = [];'."\n";
746
		print 'colorset["defaultFill"] = "#F5F5F5";';
747
		print 'series.forEach(function(item){'."\n";
748
		print 'var cnt = item[0], nm = item[1], lat = item[2], long = item[3];'."\n";
749
		print 'colorset[nm] = paletteScale(cnt);';
750
		print 'dataset.push({ count: cnt, name: nm, radius: Math.floor(radiusScale(cnt)), latitude: lat, longitude: long, fillKey: nm });'."\n";
751
		print '});'."\n";
752
		print 'var bbl = new Datamap({
753
		    element: document.getElementById("chart4"),
754
		    projection: "mercator", // big world map
755
		    fills: colorset,
756
		    responsive: true,
757
		    geographyConfig: {
758
			borderColor: "#DEDEDE",
759
			highlightBorderWidth: 2,
760
			highlightFillColor: function(geo) {
761
			    return geo["fillColor"] || "#F5F5F5";
762
			},
763
			highlightBorderColor: "#B7B7B7"
764
		    },
765
		    done: function(datamap) {
766
			datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
767
			function redraw() {
768
			    datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
769
			}
770
		    }
771
		});
772
		bbl.bubbles(dataset,{
773
		    popupTemplate: function(geo, data) {
774
			if (!data) { return ; }
775
			return ['."'".'<div class="hoverinfo">'."','<strong>', data.name, '</strong>','<br>Count: <strong>', data.count, '</strong>','</div>'].join('');
776
		    }
777
		});";
778
		print '</script>';
779
		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
780
		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
781
		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
782
	}
783
?>
784
            </div>
785
        </div>
786
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
787
<?php 
788
}
789
if ($type == 'aircraft') {
790
?>
791
<?php
792
	if ($year == '' && $month == '') {
793
?>
794
        <div class="row column">
795
            <div class="col-md-6">
796
                <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
797
<?php
798
		$year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
799
		if (count($year_array) == 0) print _("No data available");
800
		else {
801
			print '<div id="chart8" class="chart" width="100%"></div><script>';
802
			$year_data = '';
803
			$year_cnt = '';
804
			foreach($year_array as $year_item) {
805
				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
806
				$year_cnt .= $year_item['date_count'].',';
807
			}
808
			$year_data = "['x',".substr($year_data, 0, -1)."]";
809
			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
810
			print 'c3.generate({
811
			    bindto: "#chart8",
812
			    data: { x: "x",
813
			     columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
814
			     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "# of Flights"}},legend: { show: false }});';
815
			print '</script>';
816
		}
817
?>
818
                <div class="more">
819
                    <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>
820
                </div>
821
            </div>
822
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
823
            <div class="col-md-6">
824
                <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
825
<?php
826
		$month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
827
		if (count($month_array) == 0) print _("No data available");
828
		else {
829
			print '<div id="chart9" class="chart" width="100%"></div><script>';
830
			$month_data = '';
831
			$month_cnt = '';
832
			foreach($month_array as $month_item) {
833
				$month_data .= '"'.$month_item['date_name'].'",';
834
				$month_cnt .= $month_item['date_count'].',';
835
			}
836
			$month_data = "['x',".substr($month_data, 0, -1)."]";
837
			$month_cnt = "['flights',".substr($month_cnt,0,-1)."]";
838
			print 'c3.generate({
839
			    bindto: "#chart9",
840
			    data: { x: "x",
841
			     columns: ['.$month_data.','.$month_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
842
			     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m-%d"}}, y: { label: "# of Flights"}},legend: { show: false }});';
843
			print '</script>';
844
		}
845
?>
846
                <div class="more">
847
                    <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>
848
                </div>
849
            </div>
850
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
851
852
            <div class="col-md-6">
853
                <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
854
<?php
855
		$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
856
		if (empty($date_array)) print _("No data available");
857
		else {
858
			print '<div id="chart5" class="chart" width="100%"></div><script>';
859
			$date_data = '';
860
			$date_cnt = '';
861
			foreach($date_array as $date_item) {
862
				$date_data .= '"'.$date_item['date_name'].'",';
863
				$date_cnt .= $date_item['date_count'].',';
864
			}
865
			$date_data = "['x',".substr($date_data, 0, -1)."]";
866
			$date_cnt = "['flights',".substr($date_cnt,0,-1)."]";
867
			print 'c3.generate({
868
			    bindto: "#chart5",
869
			    data: { x: "x",
870
			     columns: ['.$date_data.','.$date_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
871
			     axis: { x: { type: "timeseries",tick: { format: "%Y-%m-%d"}}, y: { label: "# of Flights"}},legend: { show: false }});';
872
			print '</script>';
873
		}
874
?>
875
                <div class="more">
876
                    <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>
877
                </div>
878
            </div>
879
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
880
            <div class="col-md-6">
881
                <h2><?php echo _("Busiest Time of the Day"); ?></h2>
882
<?php
883
		$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
884
		if (empty($hour_array)) print _("No data available");
885
		else {
886
			print '<div id="chart6" class="chart" width="100%"></div><script>';
887
			$hour_data = '';
888
			$hour_cnt = '';
889
			foreach($hour_array as $hour_item) {
890
				$hour_data .= '"'.$hour_item['hour_name'].':00",';
891
				$hour_cnt .= $hour_item['hour_count'].',';
892
			}
893
			$hour_data = "[".substr($hour_data, 0, -1)."]";
894
			$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
895
			print 'c3.generate({
896
			    bindto: "#chart6",
897
			    data: {
898
			     columns: ['.$hour_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
899
			     axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Flights"}},legend: { show: false }});';
900
			print '</script>';
901
		}
902
?>
903
                <div class="more">
904
                    <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>
905
                </div>
906
            </div>
907
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
908
        </div>
909
<?php
910
	}
911
}
912
?>
913
<?php
914
if ($type == 'marine') {
915
?>
916
<?php
917
	if ($year == '' && $month == '') {
918
?>
919
        <div class="row column">
920
            <div class="col-md-6">
921
                <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
922
<?php
923
		$year_array = $Marine->countAllMonthsLastYear(true,$airline_icao,$filter_name);
924
		if (count($year_array) == 0) print _("No data available");
925
		else {
926
			print '<div id="chart8" class="chart" width="100%"></div><script>';
927
			$year_data = '';
928
			$year_cnt = '';
929
			foreach($year_array as $year_item) {
930
				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
931
				$year_cnt .= $year_item['date_count'].',';
932
			}
933
			$year_data = "['x',".substr($year_data, 0, -1)."]";
934
			$year_cnt = "['vessels',".substr($year_cnt,0,-1)."]";
935
			print 'c3.generate({
936
			    bindto: "#chart8",
937
			    data: { x: "x",
938
			     columns: ['.$year_data.','.$year_cnt.'], types: { vessels: "area"}, colors: { vessels: "#1a3151"}},
939
			     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "# of Vessels"}},legend: { show: false }});';
940
			print '</script>';
941
		}
942
?>
943
                <div class="more">
944
                    <a href="<?php print $globalURL; ?>/marine/statistics/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
945
                </div>
946
            </div>
947
            
948
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
949
            <div class="col-md-6">
950
                <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
951
<?php
952
		$month_array = $Marine->countAllDatesLastMonth($airline_icao,$filter_name);
953
		if (count($month_array) == 0) print _("No data available");
954
		else {
955
			print '<div id="chart9" class="chart" width="100%"></div><script>';
956
			$month_data = '';
957
			$month_cnt = '';
958
			foreach($month_array as $month_item) {
959
				$month_data .= '"'.$month_item['date_name'].'",';
960
				$month_cnt .= $month_item['date_count'].',';
961
			}
962
			$month_data = "['x',".substr($month_data, 0, -1)."]";
963
			$month_cnt = "['vessels',".substr($month_cnt,0,-1)."]";
964
			print 'c3.generate({
965
			    bindto: "#chart9",
966
			    data: { x: "x",
967
			     columns: ['.$month_data.','.$month_cnt.'], types: { vessels: "area"}, colors: { vessels: "#1a3151"}},
968
			     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m-%d"}}, y: { label: "# of Vessels"}},legend: { show: false }});';
969
			print '</script>';
970
		}
971
?>
972
                <div class="more">
973
                    <a href="<?php print $globalURL; ?>/marine/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
974
                </div>
975
            </div>
976
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
977
978
            <div class="col-md-6">
979
                <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
980
<?php
981
		$date_array = $Marine->countAllDatesLast7Days($airline_icao,$filter_name);
982
		if (empty($date_array)) print _("No data available");
983
		else {
984
			print '<div id="chart5" class="chart" width="100%"></div><script>';
985
			$date_data = '';
986
			$date_cnt = '';
987
			foreach($date_array as $date_item) {
988
				$date_data .= '"'.$date_item['date_name'].'",';
989
				$date_cnt .= $date_item['date_count'].',';
990
			}
991
			$date_data = "['x',".substr($date_data, 0, -1)."]";
992
			$date_cnt = "['vessels',".substr($date_cnt,0,-1)."]";
993
			print 'c3.generate({
994
			    bindto: "#chart5",
995
			    data: { x: "x",
996
			     columns: ['.$date_data.','.$date_cnt.'], types: { vessels: "area"}, colors: { vessels: "#1a3151"}},
997
			     axis: { x: { type: "timeseries",tick: { format: "%Y-%m-%d"}}, y: { label: "# of Vessels"}},legend: { show: false }});';
998
			print '</script>';
999
		}
1000
?>
1001
                <div class="more">
1002
                    <a href="<?php print $globalURL; ?>/marine/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1003
                </div>
1004
            </div>
1005
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1006
            <div class="col-md-6">
1007
                <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1008
<?php
1009
		$hour_array = $Marine->countAllHours('hour',true,$airline_icao,$filter_name);
1010
		if (empty($hour_array)) print _("No data available");
1011
		else {
1012
			print '<div id="chart6" class="chart" width="100%"></div><script>';
1013
			$hour_data = '';
1014
			$hour_cnt = '';
1015
			foreach($hour_array as $hour_item) {
1016
				$hour_data .= '"'.$hour_item['hour_name'].':00",';
1017
				$hour_cnt .= $hour_item['hour_count'].',';
1018
			}
1019
			$hour_data = "[".substr($hour_data, 0, -1)."]";
1020
			$hour_cnt = "['vessels',".substr($hour_cnt,0,-1)."]";
1021
			print 'c3.generate({
1022
			    bindto: "#chart6",
1023
			    data: {
1024
			     columns: ['.$hour_cnt.'], types: { vessels: "area"}, colors: { vessels: "#1a3151"}},
1025
			     axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Vessels"}},legend: { show: false }});';
1026
			print '</script>';
1027
		}
1028
?>
1029
                <div class="more">
1030
                    <a href="<?php print $globalURL; ?>/marine/statistics/time" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1031
                </div>
1032
            </div>
1033
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1034
        </div>
1035
<?php
1036
	}
1037
}
1038
?>
1039
<?php
1040
if ($type == 'tracker') {
1041
?>
1042
<?php
1043
	if ($year == '' && $month == '') {
1044
?>
1045
        <div class="row column">
1046
            <div class="col-md-6">
1047
                <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
1048
<?php
1049
		$year_array = $Tracker->countAllMonthsLastYear(true);
1050
		if (count($year_array) == 0) print _("No data available");
1051
		else {
1052
			print '<div id="chart8" class="chart" width="100%"></div><script>';
1053
			$year_data = '';
1054
			$year_cnt = '';
1055
			foreach($year_array as $year_item) {
1056
				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
1057
				$year_cnt .= $year_item['date_count'].',';
1058
			}
1059
			$year_data = "['x',".substr($year_data, 0, -1)."]";
1060
			$year_cnt = "['trackers',".substr($year_cnt,0,-1)."]";
1061
			print 'c3.generate({
1062
			    bindto: "#chart8",
1063
			    data: { x: "x",
1064
			     columns: ['.$year_data.','.$year_cnt.'], types: { trackers: "area"}, colors: { trackers: "#1a3151"}},
1065
			     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "# of Trackers"}},legend: { show: false }});';
1066
			print '</script>';
1067
		}
1068
?>
1069
                <div class="more">
1070
                    <a href="<?php print $globalURL; ?>/tracker/statistics/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1071
                </div>
1072
            </div>
1073
            
1074
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1075
            <div class="col-md-6">
1076
                <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
1077
<?php
1078
		$month_array = $Tracker->countAllDatesLastMonth();
1079
		if (count($month_array) == 0) print _("No data available");
1080
		else {
1081
			print '<div id="chart9" class="chart" width="100%"></div><script>';
1082
			$month_data = '';
1083
			$month_cnt = '';
1084
			foreach($month_array as $month_item) {
1085
				$month_data .= '"'.$month_item['date_name'].'",';
1086
				$month_cnt .= $month_item['date_count'].',';
1087
			}
1088
			$month_data = "['x',".substr($month_data, 0, -1)."]";
1089
			$month_cnt = "['trackers',".substr($month_cnt,0,-1)."]";
1090
			print 'c3.generate({
1091
			    bindto: "#chart9",
1092
			    data: { x: "x",
1093
			     columns: ['.$month_data.','.$month_cnt.'], types: { trackers: "area"}, colors: { trackers: "#1a3151"}},
1094
			     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m-%d"}}, y: { label: "# of Trackers"}},legend: { show: false }});';
1095
			print '</script>';
1096
		}
1097
?>
1098
                <div class="more">
1099
                    <a href="<?php print $globalURL; ?>/tracker/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1100
                </div>
1101
            </div>
1102
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1103
1104
            <div class="col-md-6">
1105
                <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
1106
<?php
1107
		$date_array = $Tracker->countAllDatesLast7Days();
1108
		if (empty($date_array)) print _("No data available");
1109
		else {
1110
			print '<div id="chart5" class="chart" width="100%"></div><script>';
1111
			$date_data = '';
1112
			$date_cnt = '';
1113
			foreach($date_array as $date_item) {
1114
				$date_data .= '"'.$date_item['date_name'].'",';
1115
				$date_cnt .= $date_item['date_count'].',';
1116
			}
1117
			$date_data = "['x',".substr($date_data, 0, -1)."]";
1118
			$date_cnt = "['trackers',".substr($date_cnt,0,-1)."]";
1119
			print 'c3.generate({
1120
			    bindto: "#chart5",
1121
			    data: { x: "x",
1122
			     columns: ['.$date_data.','.$date_cnt.'], types: { trackers: "area"}, colors: { trackers: "#1a3151"}},
1123
			     axis: { x: { type: "timeseries",tick: { format: "%Y-%m-%d"}}, y: { label: "# of Trackers"}},legend: { show: false }});';
1124
			print '</script>';
1125
		}
1126
?>
1127
                <div class="more">
1128
                    <a href="<?php print $globalURL; ?>/marine/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1129
                </div>
1130
            </div>
1131
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1132
            <div class="col-md-6">
1133
                <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1134
<?php
1135
		$hour_array = $Tracker->countAllHours('hour',true);
1136
		if (empty($hour_array)) print _("No data available");
1137
		else {
1138
			print '<div id="chart6" class="chart" width="100%"></div><script>';
1139
			$hour_data = '';
1140
			$hour_cnt = '';
1141
			foreach($hour_array as $hour_item) {
1142
				$hour_data .= '"'.$hour_item['hour_name'].':00",';
1143
				$hour_cnt .= $hour_item['hour_count'].',';
1144
			}
1145
			$hour_data = "[".substr($hour_data, 0, -1)."]";
1146
			$hour_cnt = "['trackers',".substr($hour_cnt,0,-1)."]";
1147
			print 'c3.generate({
1148
			    bindto: "#chart6",
1149
			    data: {
1150
			     columns: ['.$hour_cnt.'], types: { trackers: "area"}, colors: { trackers: "#1a3151"}},
1151
			     axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Trackers"}},legend: { show: false }});';
1152
			print '</script>';
1153
		}
1154
?>
1155
                <div class="more">
1156
                    <a href="<?php print $globalURL; ?>/tracker/statistics/time" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1157
                </div>
1158
            </div>
1159
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1160
        </div>
1161
<?php
1162
	}
1163
}
1164
?>
1165
<?php
1166
if ($type == 'satellite') {
1167
?>
1168
<?php
1169
	if ($year == '' && $month == '') {
1170
?>
1171
        <div class="row column">
1172
            <div class="col-md-6">
1173
                <h2><?php echo _("Busiest Launch Months of the last 12 Months"); ?></h2>
1174
<?php
1175
		$year_array = $Satellite->countAllMonthsLastYear(true);
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...
1176
		if (count($year_array) == 0) print _("No data available");
1177
		else {
1178
			print '<div id="chart21" class="chart" width="100%"></div><script>';
1179
			$year_data = '';
1180
			$year_cnt = '';
1181
			foreach($year_array as $year_item) {
1182
				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
1183
				$year_cnt .= $year_item['date_count'].',';
1184
			}
1185
			$year_data = "['x',".substr($year_data, 0, -1)."]";
1186
			$year_cnt = "['satellite',".substr($year_cnt,0,-1)."]";
1187
			print 'c3.generate({
1188
			    bindto: "#chart21",
1189
			    data: { x: "x",
1190
			     columns: ['.$year_data.','.$year_cnt.'], types: { trackers: "area"}, colors: { satellite: "#1a3151"}},
1191
			     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "# of Satellite"}},legend: { show: false }});';
1192
			print '</script>';
1193
		}
1194
?>
1195
	    <!--
1196
                <div class="more">
1197
                    <a href="<?php print $globalURL; ?>/tracker/statistics/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1198
                </div>
1199
            -->
1200
            </div>
1201
            
1202
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1203
            <div class="col-md-6">
1204
                <h2><?php echo _("Busiest Launch Years of the last 10 Years"); ?></h2>
1205
<?php
1206
		$year_array = $Satellite->countAllYears(true);
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...
1207
		if (count($year_array) == 0) print _("No data available");
1208
		else {
1209
			print '<div id="chart22" class="chart" width="100%"></div><script>';
1210
			$year_data = '';
1211
			$year_cnt = '';
1212
			foreach($year_array as $year_item) {
1213
				$year_data .= '"'.$year_item['year_name'].'-01-01'.'",';
1214
				$year_cnt .= $year_item['date_count'].',';
1215
			}
1216
			$year_data = "['x',".substr($year_data, 0, -1)."]";
1217
			$year_cnt = "['satellite',".substr($year_cnt,0,-1)."]";
1218
			print 'c3.generate({
1219
			    bindto: "#chart22",
1220
			    data: { x: "x",
1221
			     columns: ['.$year_data.','.$year_cnt.'], types: { trackers: "area"}, colors: { satellite: "#1a3151"}},
1222
			     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y"}}, y: { label: "# of Satellite"}},legend: { show: false }});';
1223
			print '</script>';
1224
		}
1225
?>
1226
	    <!--
1227
                <div class="more">
1228
                    <a href="<?php print $globalURL; ?>/tracker/statistics/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1229
                </div>
1230
            -->
1231
            </div>
1232
            
1233
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1234
        </div>
1235
<?php
1236
	}
1237
}
1238
?>
1239
<?php
1240
if ($type == 'aircraft') {
1241
?>
1242
<?php
1243
	if (($airline_icao == '' || $airline_icao == 'all') && $year == '' && $month == '' && isset($globalAccidents) && $globalAccidents) {
1244
?>
1245
        <div class="row column">
1246
            <div class="col-md-6">
1247
                <h2><?php echo _("Fatalities by Years"); ?></h2>
1248
<?php
1249
		$year_array = $Stats->countFatalitiesByYear();
1250
		if (count($year_array) == 0) print _("No data available");
1251
		else {
1252
			print '<div id="chart32" class="chart" width="100%"></div><script>';
1253
			$year_data = '';
1254
			$year_cnt = '';
1255
			foreach($year_array as $year_item) {
1256
				$year_data .= '"'.$year_item['year'].'-01-01",';
1257
				$year_cnt .= $year_item['count'].',';
1258
			}
1259
			$year_data = "['x',".substr($year_data, 0, -1)."]";
1260
			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
1261
			print 'c3.generate({
1262
			    bindto: "#chart32",
1263
			    data: { x: "x",
1264
			     columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
1265
			     axis: { x: { type: "timeseries",tick: { format: "%Y"}}, y: { label: "# of Fatalities"}},legend: { show: false }});';
1266
			print '</script>';
1267
		}
1268
?>
1269
                <div class="more">
1270
                    <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1271
                </div>
1272
            </div>
1273
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1274
1275
        <div class="row column">
1276
            <div class="col-md-6">
1277
                <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
1278
<?php
1279
		$year_array = $Stats->countFatalitiesLast12Months();
1280
		if (count($year_array) == 0) print _("No data available");
1281
		else {
1282
			print '<div id="chart33" class="chart" width="100%"></div><script>';
1283
			$year_data = '';
1284
			$year_cnt = '';
1285
			foreach($year_array as $year_item) {
1286
				$year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",';
1287
				$year_cnt .= $year_item['count'].',';
1288
			}
1289
			$year_data = "['x',".substr($year_data, 0, -1)."]";
1290
			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
1291
			print 'c3.generate({
1292
			    bindto: "#chart33",
1293
			    data: { x: "x",
1294
			     columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
1295
			     axis: { x: { type: "timeseries",tick: { format: "%Y-%m"}}, y: { label: "# of Fatalities"}},legend: { show: false }});';
1296
			print '</script>';
1297
		}
1298
?>
1299
                <div class="more">
1300
                    <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1301
                </div>
1302
            </div>
1303
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1304
<br/>
1305
<?php
1306
	}
1307
}
1308
?>
1309
<?php
1310
if (($airline_icao == '' || $airline_icao == 'all') && $filter_name == '' && $year == '' && $month == '' && (!isset($globalSatellite) || $globalSatellite === FALSE)) {
1311
?>
1312
        <div class="row column">
1313
<?php
1314
	//$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
1315
	if ($year == '' && $month == '') {
1316
		if ($type == 'aircraft') {
1317
			$polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
1318
		} elseif ($type == 'marine') {
1319
			$polar = $Stats->getStatsSource('polar_marine',date('Y'),date('m'),date('d'));
1320
		} elseif ($type == 'tracker') {
1321
			$polar = $Stats->getStatsSource('polar_tracker',date('Y'),date('m'),date('d'));
1322
		}
1323
	} else {
1324
		if ($type == 'aircraft') {
1325
			$polar = $Stats->getStatsSource('polar',$year,$month);
1326
		} elseif ($type == 'marine') {
1327
			$polar = $Stats->getStatsSource('polar_marine',$year,$month);
1328
		} elseif ($type == 'tracker') {
1329
			$polar = $Stats->getStatsSource('polar_tracker',$year,$month);
1330
		}
1331
	}
1332
	if (!empty($polar)) {
1333
		print '<h2>'._("Coverage pattern").'</h2>';
1334
		foreach ($polar as $eachpolar) {
1335
			unset($polar_data);
1336
			$Spotter = new Spotter();
1337
			$data = json_decode($eachpolar['source_data']);
1338
			foreach($data as $value => $key) {
1339
				$direction = $Spotter->parseDirection(($value*22.5));
1340
				$distance = $key;
1341
				$unit = 'km';
1342
				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1343
					$distance = round($distance*0.539957);
1344
					$unit = 'nm';
1345
				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
1346
					$distance = round($distance*0.621371);
1347
					$unit = 'mi';
1348
				} elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
1349
					$distance = $distance;
1350
					$unit = 'km';
1351
				}
1352
				if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1353
				else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1354
			}
1355
?>
1356
            <div class="col-md-6">
1357
                <h4><?php print $eachpolar['source_name']; ?></h4>
1358
        	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
1359
        	<script>
1360
        	    (function() {
1361
        	    var margin = {top: 100, right: 100, bottom: 100, left: 100},
1362
			width = Math.min(700, window.innerWidth - 10) - margin.left - margin.right,
1363
			height = Math.min(width, window.innerHeight - margin.top - margin.bottom - 20);
1364
		    var data = [
1365
				    [
1366
				    <?php print $polar_data; ?>
1367
				    ]
1368
				];
1369
		    var color = d3.scale.ordinal().range(["#EDC951","#CC333F","#00A0B0"]);
1370
		    //var color = d3.scaleOrdinal().range(["#EDC951","#CC333F","#00A0B0"]);
1371
		
1372
		    var radarChartOptions = {
1373
		      w: width,
1374
		      h: height,
1375
		      margin: margin,
1376
		      maxValue: 0.5,
1377
		      levels: 5,
1378
		      roundStrokes: true,
1379
		      color: color,
1380
		      unit: '<?php echo $unit; ?>'
1381
		    };
1382
		    RadarChart("#polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
1383
		    })();
1384
		</script>
1385
            </div>
1386
            <?php
1387
		}
1388
	}
1389
?>
1390
        </div>
1391
        <div class="row column">
1392
            <div class="col-md-6">
1393
<?php
1394
	//$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
1395
	if ($year == '' && $month == '') {
1396
		if ($type == 'aircraft') {
1397
			$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
1398
		} elseif ($type == 'marine') {
1399
			$msg = $Stats->getStatsSource('msg_marine',date('Y'),date('m'),date('d'));
1400
		} elseif ($type == 'tracker') {
1401
			$msg = $Stats->getStatsSource('msg_tracker',date('Y'),date('m'),date('d'));
1402
		}
1403
	} else {
1404
		if ($type == 'aircraft') {
1405
			$msg = $Stats->getStatsSource('msg',$year,$month);
1406
		} elseif ($type == 'marine') {
1407
			$msg = $Stats->getStatsSource('msg_marine',$year,$month);
1408
		} elseif ($type == 'tracker') {
1409
			$msg = $Stats->getStatsSource('msg_tracker',$year,$month);
1410
		}
1411
	}
1412
	if (!empty($msg)) {
1413
		print '<h2>'._("Messages received").'</h2>';
1414
		foreach ($msg as $eachmsg) {
1415
			//$eachmsg = $msg[0];
1416
			$data = $eachmsg['source_data'];
1417
			if ($data > 500) $max = (round(($data+100)/100))*100;
1418
			else $max = 500;
1419
?>
1420
        	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1421
        	<script>
1422
		      var g = new JustGage({
1423
			    id: "msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>",
1424
			    value: <?php echo $data; ?>,
1425
			    min: 0,
1426
			    max: <?php print $max; ?>,
1427
			    valueMinFontSize: 10,
1428
			    height: 120,
1429
			    width: 220,
1430
			    symbol: ' msg/s',
1431
			    title: "<?php print $eachmsg['source_name']; ?>"
1432
			  });
1433
		</script>
1434
<?php
1435
		}
1436
	}
1437
?>
1438
            </div>
1439
        </div>
1440
        <div class="row column">
1441
<?php
1442
	//$hist = $Stats->getStatsSource(date('Y-m-d'),'hist');
1443
	if ($year == '' && $month == '') {
1444
		if ($type == 'aircraft') {
1445
			$hist = $Stats->getStatsSource('hist',date('Y'),date('m'),date('d'));
1446
		} elseif ($type == 'marine') {
1447
			$hist = $Stats->getStatsSource('hist_marine',date('Y'),date('m'),date('d'));
1448
		} elseif ($type == 'tracker') {
1449
			$hist = $Stats->getStatsSource('hist_tracker',date('Y'),date('m'),date('d'));
1450
		}
1451
	} else {
1452
		if ($type == 'aircraft') {
1453
			$hist = $Stats->getStatsSource('hist',$year,$month);
1454
		} elseif ($type == 'marine') {
1455
			$hist = $Stats->getStatsSource('hist_marine',$year,$month);
1456
		} elseif ($type == 'tracker') {
1457
			$hist = $Stats->getStatsSource('hist_tracker',$year,$month);
1458
		}
1459
	}
1460
	foreach ($hist as $hists) {
1461
		//$hist_data = '';
1462
		$distance_data = '';
1463
		$nb_data = '';
1464
		$source = $hists['source_name'];
1465
		$hist_array = json_decode($hists['source_data']);
1466
		$unit = 'km';
1467
		foreach($hist_array as $distance => $nb) {
1468
			if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1469
				$distance = round($distance*0.539957);
1470
				$unit = 'nm';
1471
			} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
1472
				$distance = round($distance*0.621371);
1473
				$unit = 'mi';
1474
			} elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
1475
				$distance = $distance;
1476
				$unit = 'km';
1477
			}
1478
			//$hist_data .= '[ "'.$distance.'",'.$nb.'],';
1479
			$distance_data .= '"'.$distance.'",';
1480
			$nb_data .= $nb.',';
1481
		}
1482
		//$hist_data = substr($hist_data, 0, -1);
1483
		$distance_data = "['x',".substr($distance_data, 0, -1)."]";
1484
		$nb_data = "['flights',".substr($nb_data, 0, -1)."]";
1485
?>
1486
            <div class="col-md-6">
1487
                <h2><?php echo sprintf(_("Distance for %s"),$source); ?></h2>
1488
<?php
1489
		print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>';
1490
		print 'c3.generate({
1491
		    bindto: "#charthist-'.str_replace(' ','_',strtolower($source)).'",
1492
		    data: { x: "x",
1493
		    columns: ['.$distance_data.','.$nb_data.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
1494
		    axis: { x: {label : { text: "Distance in '.$unit.'", position: "outer-right"}}, y: { label: "# of Flights"}},legend: { show: false }});';
1495
		print '</script>';
1496
?>
1497
    	    </div>
1498
	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1499
<?php
1500
	}
1501
?>
1502
        </div>
1503
<?php
1504
}
1505
?>
1506
    </div>
1507
</div>  
1508
1509
<?php
1510
require_once('footer.php');
1511
?>