Completed
Push — master ( 83aaff...7b298e )
by Yannick
32:28
created

statistics.php (1 issue)

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
} 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 Vessel was inside"); ?></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
                <div class="more">
457
                    <a href="<?php print $globalURL; ?>/marine/statistics/country" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
458
                </div>
459
            </div>
460
        </div>
461
462
<?php
463
	}
464
?>
465
<?php
466
	if ($type == 'tracker') {
467
		$flightover_array = $Tracker->countAllTrackerOverCountries(true);
468
?>
469
    <div class="row column">
470
	<div class="col-md-6">
471
            <h2><?php echo _("Top 20 Most Common Country a Tracker was inside"); ?></h2>
472
<?php
473
		if (count($flightover_array) == 0) print _("No data available");
474
		else {
475
			print '<div id="chart10" class="chart" width="100%"></div><script>';
476
			print 'var series = [';
477
			$flightover_data = '';
478
			foreach($flightover_array as $flightover_item)
479
			{
480
				$flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
481
			}
482
			$flightover_data = substr($flightover_data, 0, -1);
483
			print $flightover_data;
484
			print '];';
485
			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);';
486
			print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
487
			print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
488
			print 'new Datamap({
489
			    element: document.getElementById("chart10"),
490
			    projection: "mercator", // big world map
491
			    fills: { defaultFill: "#F5F5F5" },
492
			    data: dataset,
493
			    responsive: true,
494
			    geographyConfig: {
495
				borderColor: "#DEDEDE",
496
				highlightBorderWidth: 2,
497
				highlightFillColor: function(geo) {
498
				    return geo["fillColor"] || "#F5F5F5";
499
				},
500
				highlightBorderColor: "#B7B7B7",
501
				done: function(datamap) {
502
				    datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
503
				    function redraw() {
504
					datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
505
				    }
506
				},
507
				popupTemplate: function(geo, data) {
508
				    if (!data) { return ; }
509
				    return ['."'".'<div class="hoverinfo">'."','<strong>', geo.properties.name, '</strong>','<br>Count: <strong>', data.numberOfThings, '</strong>','</div>'].join('');
510
				}
511
			    }
512
			});";
513
			print '</script>';
514
		}
515
?>
516
                <div class="more">
517
                    <a href="<?php print $globalURL; ?>/tracker/statistics/country" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
518
                </div>
519
            </div>
520
        </div>
521
522
<?php
523
	}
524
?>
525
<?php
526
	if ($type == 'aircraft') {
527
?>
528
        <div class="row column">
529
            <div class="col-md-6">
530
<?php
531
		$airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
532
		if (count($airport_airport_array) > 0) {
533
			print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
534
			print '<div id="chart3" class="chart" width="100%"></div><script>';
535
			print "\n";
536
			print 'var series = [';
537
			$airport_data = '';
538
			foreach($airport_airport_array as $airport_item)
539
			{
540
				$airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],';
541
			}
542
			$airport_data = substr($airport_data, 0, -1);
543
			print $airport_data;
544
			print '];'."\n";
545
			print 'var onlyValues = series.map(function(obj){ return obj[0]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'."\n";
546
			print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'."\n";
547
			print 'var radiusScale = d3.scale.log().domain([minValue,maxValue]).range([0,10]);'."\n";
548
			print 'var dataset = [];'."\n";
549
			print 'var colorset = [];'."\n";
550
			print 'colorset["defaultFill"] = "#F5F5F5";';
551
			print 'series.forEach(function(item){'."\n";
552
			print 'var cnt = item[0], nm = item[1], lat = item[2], long = item[3];'."\n";
553
			print 'colorset[nm] = paletteScale(cnt);';
554
			print 'dataset.push({ count: cnt, name: nm, radius: Math.floor(radiusScale(cnt)), latitude: lat, longitude: long, fillKey: nm });'."\n";
555
			print '});'."\n";
556
			print 'var bbl = new Datamap({
557
			    element: document.getElementById("chart3"),
558
			    projection: "mercator", // big world map
559
			    fills: colorset,
560
			    responsive: true,
561
			    geographyConfig: {
562
				borderColor: "#DEDEDE",
563
				highlightBorderWidth: 2,
564
				highlightFillColor: function(geo) {
565
				    return geo["fillColor"] || "#F5F5F5";
566
				},
567
				highlightBorderColor: "#B7B7B7"
568
			    },
569
			    done: function(datamap) {
570
				datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
571
				function redraw() {
572
				    datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
573
				}
574
			    }
575
			});
576
			bbl.bubbles(dataset,{
577
			    popupTemplate: function(geo, data) {
578
				if (!data) { return ; }
579
				return ['."'".'<div class="hoverinfo">'."','<strong>', data.name, '</strong>','<br>Count: <strong>', data.count, '</strong>','</div>'].join('');
580
			    }
581
			});";
582
			print '</script>';
583
			print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
584
			if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
585
			print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
586
		}
587
?>
588
            </div>
589
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
590
591
            <div class="col-md-6">
592
<?php
593
		$airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
594
		if (count($airport_airport_array2) > 0) {
595
			print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
596
			print '<div id="chart4" class="chart" width="100%"></div><script>';
597
			print "\n";
598
			print 'var series = [';
599
			$airport_data = '';
600
			foreach($airport_airport_array2 as $airport_item)
601
			{
602
				$airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
603
			}
604
			$airport_data = substr($airport_data, 0, -1);
605
			print $airport_data;
606
			print '];'."\n";
607
			print 'var onlyValues = series.map(function(obj){ return obj[0]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'."\n";
608
			print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'."\n";
609
			print 'var radiusScale = d3.scale.log().domain([minValue,maxValue]).range([0,10]);'."\n";
610
			print 'var dataset = [];'."\n";
611
			print 'var colorset = [];'."\n";
612
			print 'colorset["defaultFill"] = "#F5F5F5";';
613
			print 'series.forEach(function(item){'."\n";
614
			print 'var cnt = item[0], nm = item[1], lat = item[2], long = item[3];'."\n";
615
			print 'colorset[nm] = paletteScale(cnt);';
616
			print 'dataset.push({ count: cnt, name: nm, radius: Math.floor(radiusScale(cnt)), latitude: lat, longitude: long, fillKey: nm });'."\n";
617
			print '});'."\n";
618
			print 'var bbl = new Datamap({
619
			    element: document.getElementById("chart4"),
620
			    projection: "mercator", // big world map
621
			    fills: colorset,
622
			    responsive: true,
623
			    geographyConfig: {
624
				borderColor: "#DEDEDE",
625
				highlightBorderWidth: 2,
626
				highlightFillColor: function(geo) {
627
				    return geo["fillColor"] || "#F5F5F5";
628
				},
629
				highlightBorderColor: "#B7B7B7"
630
			    },
631
			    done: function(datamap) {
632
				datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
633
				function redraw() {
634
				    datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
635
				}
636
			    }
637
			});
638
			bbl.bubbles(dataset,{
639
			    popupTemplate: function(geo, data) {
640
				if (!data) { return ; }
641
				return ['."'".'<div class="hoverinfo">'."','<strong>', data.name, '</strong>','<br>Count: <strong>', data.count, '</strong>','</div>'].join('');
642
			    }
643
			});";
644
			print '</script>';
645
			print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
646
			if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
647
			print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
648
		}
649
?>
650
            </div>
651
        </div>
652
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
653
<?php 
654
	}
655
?>
656
<?php
657
	if ($type == 'aircraft') {
658
?>
659
<?php
660
		if ($year == '' && $month == '') {
661
?>
662
        <div class="row column">
663
            <div class="col-md-6">
664
                <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
665
<?php
666
			$year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
667
			if (count($year_array) == 0) print _("No data available");
668
			else {
669
				print '<div id="chart8" class="chart" width="100%"></div><script>';
670
				$year_data = '';
671
				$year_cnt = '';
672
				foreach($year_array as $year_item)
673
				{
674
					$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
675
					$year_cnt .= $year_item['date_count'].',';
676
				}
677
				$year_data = "['x',".substr($year_data, 0, -1)."]";
678
				$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
679
				print 'c3.generate({
680
				    bindto: "#chart8",
681
				    data: { x: "x",
682
				     columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
683
				     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "# of Flights"}},legend: { show: false }});';
684
				print '</script>';
685
			}
686
?>
687
                <div class="more">
688
                    <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>
689
                </div>
690
            </div>
691
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
692
            <div class="col-md-6">
693
                <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
694
<?php
695
			$month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
696
			if (count($month_array) == 0) print _("No data available");
697
			else {
698
				print '<div id="chart9" class="chart" width="100%"></div><script>';
699
				$month_data = '';
700
				$month_cnt = '';
701
				foreach($month_array as $month_item)
702
				{
703
					$month_data .= '"'.$month_item['date_name'].'",';
704
					$month_cnt .= $month_item['date_count'].',';
705
				}
706
				$month_data = "['x',".substr($month_data, 0, -1)."]";
707
				$month_cnt = "['flights',".substr($month_cnt,0,-1)."]";
708
				print 'c3.generate({
709
				    bindto: "#chart9",
710
				    data: { x: "x",
711
				     columns: ['.$month_data.','.$month_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
712
				     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m-%d"}}, y: { label: "# of Flights"}},legend: { show: false }});';
713
				print '</script>';
714
			}
715
?>
716
                <div class="more">
717
                    <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>
718
                </div>
719
            </div>
720
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
721
722
            <div class="col-md-6">
723
                <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
724
<?php
725
			$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
726
			if (empty($date_array)) print _("No data available");
727
			else {
728
				print '<div id="chart5" class="chart" width="100%"></div><script>';
729
				$date_data = '';
730
				$date_cnt = '';
731
				foreach($date_array as $date_item)
732
				{
733
					$date_data .= '"'.$date_item['date_name'].'",';
734
					$date_cnt .= $date_item['date_count'].',';
735
				}
736
				$date_data = "['x',".substr($date_data, 0, -1)."]";
737
				$date_cnt = "['flights',".substr($date_cnt,0,-1)."]";
738
				print 'c3.generate({
739
				    bindto: "#chart5",
740
				    data: { x: "x",
741
				     columns: ['.$date_data.','.$date_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
742
				     axis: { x: { type: "timeseries",tick: { format: "%Y-%m-%d"}}, y: { label: "# of Flights"}},legend: { show: false }});';
743
				print '</script>';
744
			}
745
?>
746
                <div class="more">
747
                    <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>
748
                </div>
749
            </div>
750
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
751
            <div class="col-md-6">
752
                <h2><?php echo _("Busiest Time of the Day"); ?></h2>
753
<?php
754
			$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
755
			if (empty($hour_array)) print _("No data available");
756
			else {
757
				print '<div id="chart6" class="chart" width="100%"></div><script>';
758
				$hour_data = '';
759
				$hour_cnt = '';
760
				foreach($hour_array as $hour_item)
761
				{
762
					$hour_data .= '"'.$hour_item['hour_name'].':00",';
763
					$hour_cnt .= $hour_item['hour_count'].',';
764
				}
765
				$hour_data = "[".substr($hour_data, 0, -1)."]";
766
				$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
767
				print 'c3.generate({
768
				    bindto: "#chart6",
769
				    data: {
770
				     columns: ['.$hour_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
771
				     axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Flights"}},legend: { show: false }});';
772
				print '</script>';
773
			}
774
?>
775
                <div class="more">
776
                    <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>
777
                </div>
778
            </div>
779
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
780
        </div>
781
<?php
782
		}
783
?>
784
<?php
785
	}
786
?>
787
<?php
788
	if ($type == 'marine') {
789
?>
790
<?php
791
		if ($year == '' && $month == '') {
792
?>
793
        <div class="row column">
794
            <div class="col-md-6">
795
                <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
796
<?php
797
			$year_array = $Marine->countAllMonthsLastYear(true,$airline_icao,$filter_name);
798
			if (count($year_array) == 0) print _("No data available");
799
			else {
800
				print '<div id="chart8" class="chart" width="100%"></div><script>';
801
				$year_data = '';
802
				$year_cnt = '';
803
				foreach($year_array as $year_item)
804
				{
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 = "['vessels',".substr($year_cnt,0,-1)."]";
810
				print 'c3.generate({
811
				    bindto: "#chart8",
812
				    data: { x: "x",
813
				     columns: ['.$year_data.','.$year_cnt.'], types: { vessels: "area"}, colors: { vessels: "#1a3151"}},
814
				     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "# of Vessels"}},legend: { show: false }});';
815
				print '</script>';
816
			}
817
?>
818
                <div class="more">
819
                    <a href="<?php print $globalURL; ?>/marine/statistics/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
820
                </div>
821
            </div>
822
            
823
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
824
            <div class="col-md-6">
825
                <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
826
<?php
827
			$month_array = $Marine->countAllDatesLastMonth($airline_icao,$filter_name);
828
			if (count($month_array) == 0) print _("No data available");
829
			else {
830
				print '<div id="chart9" class="chart" width="100%"></div><script>';
831
				$month_data = '';
832
				$month_cnt = '';
833
				foreach($month_array as $month_item)
834
				{
835
					$month_data .= '"'.$month_item['date_name'].'",';
836
					$month_cnt .= $month_item['date_count'].',';
837
				}
838
				$month_data = "['x',".substr($month_data, 0, -1)."]";
839
				$month_cnt = "['vessels',".substr($month_cnt,0,-1)."]";
840
				print 'c3.generate({
841
				    bindto: "#chart9",
842
				    data: { x: "x",
843
				     columns: ['.$month_data.','.$month_cnt.'], types: { vessels: "area"}, colors: { vessels: "#1a3151"}},
844
				     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m-%d"}}, y: { label: "# of Vessels"}},legend: { show: false }});';
845
				print '</script>';
846
			}
847
?>
848
                <div class="more">
849
                    <a href="<?php print $globalURL; ?>/marine/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
850
                </div>
851
            </div>
852
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
853
854
            <div class="col-md-6">
855
                <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
856
<?php
857
			$date_array = $Marine->countAllDatesLast7Days($airline_icao,$filter_name);
858
			if (empty($date_array)) print _("No data available");
859
			else {
860
				print '<div id="chart5" class="chart" width="100%"></div><script>';
861
				$date_data = '';
862
				$date_cnt = '';
863
				foreach($date_array as $date_item)
864
				{
865
					$date_data .= '"'.$date_item['date_name'].'",';
866
					$date_cnt .= $date_item['date_count'].',';
867
				}
868
				$date_data = "['x',".substr($date_data, 0, -1)."]";
869
				$date_cnt = "['vessels',".substr($date_cnt,0,-1)."]";
870
				print 'c3.generate({
871
				    bindto: "#chart5",
872
				    data: { x: "x",
873
				     columns: ['.$date_data.','.$date_cnt.'], types: { vessels: "area"}, colors: { vessels: "#1a3151"}},
874
				     axis: { x: { type: "timeseries",tick: { format: "%Y-%m-%d"}}, y: { label: "# of Vessels"}},legend: { show: false }});';
875
				print '</script>';
876
			}
877
?>
878
                <div class="more">
879
                    <a href="<?php print $globalURL; ?>/marine/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
880
                </div>
881
            </div>
882
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
883
            <div class="col-md-6">
884
                <h2><?php echo _("Busiest Time of the Day"); ?></h2>
885
<?php
886
			$hour_array = $Marine->countAllHours('hour',true,$airline_icao,$filter_name);
887
			if (empty($hour_array)) print _("No data available");
888
			else {
889
				print '<div id="chart6" class="chart" width="100%"></div><script>';
890
				$hour_data = '';
891
				$hour_cnt = '';
892
				foreach($hour_array as $hour_item)
893
				{
894
					$hour_data .= '"'.$hour_item['hour_name'].':00",';
895
					$hour_cnt .= $hour_item['hour_count'].',';
896
				}
897
				$hour_data = "[".substr($hour_data, 0, -1)."]";
898
				$hour_cnt = "['vessels',".substr($hour_cnt,0,-1)."]";
899
				print 'c3.generate({
900
				    bindto: "#chart6",
901
				    data: {
902
				     columns: ['.$hour_cnt.'], types: { vessels: "area"}, colors: { vessels: "#1a3151"}},
903
				     axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Vessels"}},legend: { show: false }});';
904
				print '</script>';
905
			}
906
?>
907
                <div class="more">
908
                    <a href="<?php print $globalURL; ?>/marine/statistics/time" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
909
                </div>
910
            </div>
911
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
912
        </div>
913
<?php
914
		}
915
?>
916
<?php
917
	}
918
?>
919
<?php
920
	if ($type == 'tracker') {
921
?>
922
<?php
923
		if ($year == '' && $month == '') {
924
?>
925
        <div class="row column">
926
            <div class="col-md-6">
927
                <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
928
<?php
929
			$year_array = $Tracker->countAllMonthsLastYear(true);
930
			if (count($year_array) == 0) print _("No data available");
931
			else {
932
				print '<div id="chart8" class="chart" width="100%"></div><script>';
933
				$year_data = '';
934
				$year_cnt = '';
935
				foreach($year_array as $year_item)
936
				{
937
					$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
938
					$year_cnt .= $year_item['date_count'].',';
939
				}
940
				$year_data = "['x',".substr($year_data, 0, -1)."]";
941
				$year_cnt = "['trackers',".substr($year_cnt,0,-1)."]";
942
				print 'c3.generate({
943
				    bindto: "#chart8",
944
				    data: { x: "x",
945
				     columns: ['.$year_data.','.$year_cnt.'], types: { trackers: "area"}, colors: { trackers: "#1a3151"}},
946
				     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "# of Trackers"}},legend: { show: false }});';
947
				print '</script>';
948
			}
949
?>
950
                <div class="more">
951
                    <a href="<?php print $globalURL; ?>/tracker/statistics/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
952
                </div>
953
            </div>
954
            
955
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
956
            <div class="col-md-6">
957
                <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
958
<?php
959
			$month_array = $Tracker->countAllDatesLastMonth();
960
			if (count($month_array) == 0) print _("No data available");
961
			else {
962
				print '<div id="chart9" class="chart" width="100%"></div><script>';
963
				$month_data = '';
964
				$month_cnt = '';
965
				foreach($month_array as $month_item)
966
				{
967
					$month_data .= '"'.$month_item['date_name'].'",';
968
					$month_cnt .= $month_item['date_count'].',';
969
				}
970
				$month_data = "['x',".substr($month_data, 0, -1)."]";
971
				$month_cnt = "['trackers',".substr($month_cnt,0,-1)."]";
972
				print 'c3.generate({
973
				    bindto: "#chart9",
974
				    data: { x: "x",
975
				     columns: ['.$month_data.','.$month_cnt.'], types: { trackers: "area"}, colors: { trackers: "#1a3151"}},
976
				     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m-%d"}}, y: { label: "# of Trackers"}},legend: { show: false }});';
977
				print '</script>';
978
			}
979
?>
980
                <div class="more">
981
                    <a href="<?php print $globalURL; ?>/tracker/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
982
                </div>
983
            </div>
984
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
985
986
            <div class="col-md-6">
987
                <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
988
<?php
989
			$date_array = $Tracker->countAllDatesLast7Days();
990
			if (empty($date_array)) print _("No data available");
991
			else {
992
				print '<div id="chart5" class="chart" width="100%"></div><script>';
993
				$date_data = '';
994
				$date_cnt = '';
995
				foreach($date_array as $date_item)
996
				{
997
					$date_data .= '"'.$date_item['date_name'].'",';
998
					$date_cnt .= $date_item['date_count'].',';
999
				}
1000
				$date_data = "['x',".substr($date_data, 0, -1)."]";
1001
				$date_cnt = "['trackers',".substr($date_cnt,0,-1)."]";
1002
				print 'c3.generate({
1003
				    bindto: "#chart5",
1004
				    data: { x: "x",
1005
				     columns: ['.$date_data.','.$date_cnt.'], types: { trackers: "area"}, colors: { trackers: "#1a3151"}},
1006
				     axis: { x: { type: "timeseries",tick: { format: "%Y-%m-%d"}}, y: { label: "# of Trackers"}},legend: { show: false }});';
1007
				print '</script>';
1008
			}
1009
?>
1010
                <div class="more">
1011
                    <a href="<?php print $globalURL; ?>/marine/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1012
                </div>
1013
            </div>
1014
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1015
            <div class="col-md-6">
1016
                <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1017
<?php
1018
			$hour_array = $Tracker->countAllHours('hour',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...
1019
			if (empty($hour_array)) print _("No data available");
1020
			else {
1021
				print '<div id="chart6" class="chart" width="100%"></div><script>';
1022
				$hour_data = '';
1023
				$hour_cnt = '';
1024
				foreach($hour_array as $hour_item)
1025
				{
1026
					$hour_data .= '"'.$hour_item['hour_name'].':00",';
1027
					$hour_cnt .= $hour_item['hour_count'].',';
1028
				}
1029
				$hour_data = "[".substr($hour_data, 0, -1)."]";
1030
				$hour_cnt = "['trackers',".substr($hour_cnt,0,-1)."]";
1031
				print 'c3.generate({
1032
				    bindto: "#chart6",
1033
				    data: {
1034
				     columns: ['.$hour_cnt.'], types: { trackers: "area"}, colors: { trackers: "#1a3151"}},
1035
				     axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Trackers"}},legend: { show: false }});';
1036
				print '</script>';
1037
			}
1038
?>
1039
                <div class="more">
1040
                    <a href="<?php print $globalURL; ?>/tracker/statistics/time" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1041
                </div>
1042
            </div>
1043
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1044
        </div>
1045
<?php
1046
		}
1047
?>
1048
<?php
1049
	}
1050
?>
1051
<?php
1052
	if ($type == 'aircraft') {
1053
?>
1054
<?php
1055
		if (($airline_icao == '' || $airline_icao == 'all') && $year == '' && $month == '' && isset($globalAccidents) && $globalAccidents) {
1056
?>
1057
        <div class="row column">
1058
            <div class="col-md-6">
1059
                <h2><?php echo _("Fatalities by Years"); ?></h2>
1060
<?php
1061
			$year_array = $Stats->countFatalitiesByYear();
1062
			if (count($year_array) == 0) print _("No data available");
1063
			else {
1064
				print '<div id="chart32" class="chart" width="100%"></div><script>';
1065
				$year_data = '';
1066
				$year_cnt = '';
1067
				foreach($year_array as $year_item)
1068
				{
1069
					$year_data .= '"'.$year_item['year'].'-01-01",';
1070
					$year_cnt .= $year_item['count'].',';
1071
				}
1072
				$year_data = "['x',".substr($year_data, 0, -1)."]";
1073
				$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
1074
				print 'c3.generate({
1075
				    bindto: "#chart32",
1076
				    data: { x: "x",
1077
				     columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
1078
				     axis: { x: { type: "timeseries",tick: { format: "%Y"}}, y: { label: "# of Fatalities"}},legend: { show: false }});';
1079
				print '</script>';
1080
			}
1081
?>
1082
                <div class="more">
1083
                    <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1084
                </div>
1085
            </div>
1086
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1087
1088
        <div class="row column">
1089
            <div class="col-md-6">
1090
                <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
1091
<?php
1092
			$year_array = $Stats->countFatalitiesLast12Months();
1093
			if (count($year_array) == 0) print _("No data available");
1094
			else {
1095
				print '<div id="chart33" class="chart" width="100%"></div><script>';
1096
				$year_data = '';
1097
				$year_cnt = '';
1098
				foreach($year_array as $year_item)
1099
				{
1100
					$year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",';
1101
					$year_cnt .= $year_item['count'].',';
1102
				}
1103
				$year_data = "['x',".substr($year_data, 0, -1)."]";
1104
				$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
1105
				print 'c3.generate({
1106
				    bindto: "#chart33",
1107
				    data: { x: "x",
1108
				     columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
1109
				     axis: { x: { type: "timeseries",tick: { format: "%Y-%m"}}, y: { label: "# of Fatalities"}},legend: { show: false }});';
1110
				print '</script>';
1111
			}
1112
?>
1113
                <div class="more">
1114
                    <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1115
                </div>
1116
            </div>
1117
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1118
<br/>
1119
<?php
1120
		}
1121
?>
1122
<?php
1123
	}
1124
?>
1125
<?php
1126
	if ($type == 'aircraft') {
1127
?>
1128
<?php
1129
		if (($airline_icao == '' || $airline_icao == 'all') && $filter_name == '' && $year == '' && $month == '') {
1130
?>
1131
        <div class="row column">
1132
<?php
1133
			//$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
1134
			if ($year == '' && $month == '') {
1135
				$polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
1136
			} else {
1137
				$polar = $Stats->getStatsSource('polar',$year,$month);
1138
			}
1139
			if (!empty($polar)) {
1140
				print '<h2>'._("Coverage pattern").'</h2>';
1141
				foreach ($polar as $eachpolar) {
1142
					unset($polar_data);
1143
					$Spotter = new Spotter();
1144
					$data = json_decode($eachpolar['source_data']);
1145
					foreach($data as $value => $key) {
1146
						$direction = $Spotter->parseDirection(($value*22.5));
1147
						$distance = $key;
1148
						$unit = 'km';
1149
						if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1150
							$distance = round($distance*0.539957);
1151
							$unit = 'nm';
1152
						} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
1153
							$distance = round($distance*0.621371);
1154
							$unit = 'mi';
1155
						} elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
1156
							$distance = $distance;
1157
							$unit = 'km';
1158
						}
1159
						if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1160
						else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1161
					}
1162
?>
1163
            <div class="col-md-6">
1164
                <h4><?php print $eachpolar['source_name']; ?></h4>
1165
        	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
1166
        	<script>
1167
        	    (function() {
1168
        	    var margin = {top: 100, right: 100, bottom: 100, left: 100},
1169
			width = Math.min(700, window.innerWidth - 10) - margin.left - margin.right,
1170
			height = Math.min(width, window.innerHeight - margin.top - margin.bottom - 20);
1171
		    var data = [
1172
				    [
1173
				    <?php print $polar_data; ?>
1174
				    ]
1175
				];
1176
		    var color = d3.scale.ordinal().range(["#EDC951","#CC333F","#00A0B0"]);
1177
		    //var color = d3.scaleOrdinal().range(["#EDC951","#CC333F","#00A0B0"]);
1178
		
1179
		    var radarChartOptions = {
1180
		      w: width,
1181
		      h: height,
1182
		      margin: margin,
1183
		      maxValue: 0.5,
1184
		      levels: 5,
1185
		      roundStrokes: true,
1186
		      color: color,
1187
		      unit: '<?php echo $unit; ?>'
1188
		    };
1189
		    RadarChart("#polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
1190
		    })();
1191
		</script>
1192
            </div>
1193
            <?php
1194
				}
1195
			}
1196
?>
1197
        </div>
1198
        <div class="row column">
1199
            <div class="col-md-6">
1200
<?php
1201
			//$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
1202
			if ($year == '' && $month == '') {
1203
				$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
1204
			} else {
1205
				$msg = $Stats->getStatsSource('msg',$year,$month);
1206
			}
1207
			if (!empty($msg)) {
1208
				print '<h2>'._("Messages received").'</h2>';
1209
				foreach ($msg as $eachmsg) {
1210
					//$eachmsg = $msg[0];
1211
					$data = $eachmsg['source_data'];
1212
					if ($data > 500) $max = (round(($data+100)/100))*100;
1213
					else $max = 500;
1214
?>
1215
        	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1216
        	<script>
1217
		      var g = new JustGage({
1218
			    id: "msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>",
1219
			    value: <?php echo $data; ?>,
1220
			    min: 0,
1221
			    max: <?php print $max; ?>,
1222
			    valueMinFontSize: 10,
1223
			    height: 120,
1224
			    width: 220,
1225
			    symbol: ' msg/s',
1226
			    title: "<?php print $eachmsg['source_name']; ?>"
1227
			  });
1228
		</script>
1229
<?php
1230
				}
1231
			}
1232
?>
1233
            </div>
1234
        </div>
1235
        <div class="row column">
1236
<?php
1237
		//$hist = $Stats->getStatsSource(date('Y-m-d'),'hist');
1238
			if ($year == '' && $month == '') {
1239
				$hist = $Stats->getStatsSource('hist',date('Y'),date('m'),date('d'));
1240
			} else {
1241
				$hist = $Stats->getStatsSource('hist',$year,$month);
1242
			}
1243
			foreach ($hist as $hists) {
1244
				//$hist_data = '';
1245
				$distance_data = '';
1246
				$nb_data = '';
1247
				$source = $hists['source_name'];
1248
				$hist_array = json_decode($hists['source_data']);
1249
				$unit = 'km';
1250
				foreach($hist_array as $distance => $nb)
1251
				{
1252
					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1253
						$distance = round($distance*0.539957);
1254
						$unit = 'nm';
1255
					} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
1256
						$distance = round($distance*0.621371);
1257
						$unit = 'mi';
1258
					} elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
1259
						$distance = $distance;
1260
						$unit = 'km';
1261
					}
1262
					//$hist_data .= '[ "'.$distance.'",'.$nb.'],';
1263
					$distance_data .= '"'.$distance.'",';
1264
					$nb_data .= $nb.',';
1265
				}
1266
				//$hist_data = substr($hist_data, 0, -1);
1267
				$distance_data = "['x',".substr($distance_data, 0, -1)."]";
1268
				$nb_data = "['flights',".substr($nb_data, 0, -1)."]";
1269
?>
1270
            <div class="col-md-6">
1271
                <h2><?php echo sprintf(_("Flights Distance for %s"),$source); ?></h2>
1272
<?php
1273
				print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>';
1274
				print 'c3.generate({
1275
				    bindto: "#charthist-'.str_replace(' ','_',strtolower($source)).'",
1276
				    data: { x: "x",
1277
				    columns: ['.$distance_data.','.$nb_data.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
1278
				    axis: { x: {label : { text: "Distance in '.$unit.'", position: "outer-right"}}, y: { label: "# of Flights"}},legend: { show: false }});';
1279
				print '</script>';
1280
?>
1281
    	    </div>
1282
	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1283
<?php
1284
			}
1285
?>
1286
        </div>
1287
<?php
1288
		}
1289
?>
1290
<?php
1291
	}
1292
?>
1293
    </div>
1294
</div>  
1295
1296
<?php
1297
require_once('footer.php');
1298
?>