Completed
Push — master ( 553331...19ae00 )
by Yannick
07:35
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.Spotter.php');
5
require_once('require/class.Language.php');
6
$beginpage = microtime(true);
7
$Stats = new Stats();
8
9
if (!isset($filter_name)) $filter_name = '';
10
$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
11
if ($airline_icao == '' && isset($globalFilter)) {
12
	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
13
}
14
if ($airline_icao != '' && $airline_icao != 'all') {
15
	$Spotter = new Spotter();
16
	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
17
	$airline_name = $airline_info[0]['name'];
18
}
19
if (isset($airline_name)) {
20
	$title = _("Statistics").' - '.$airline_name;
21
} else {
22
	$title = _("Statistics");
23
}
24
25
$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
26
$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
27
28
require_once('header.php');
29
30
?>
31
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
32
<!--<script type="text/javascript" src="https://d3js.org/d3.v4.min.js"></script>-->
33
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script>
34
<script type="text/javascript" src="<?php echo $globalURL; ?>/js/radarChart.js"></script>
35
<script type="text/javascript" src="<?php echo $globalURL; ?>/js/raphael-2.1.4.min.js"></script>
36
<script type="text/javascript" src="<?php echo $globalURL; ?>/js/justgage.js"></script>
37
<div class="column">
38
    <div class="info">
39
            <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1>
40
    <?php 
41
	$last_update = $Stats->getLastStatsUpdate();
42
	//if (isset($last_update[0]['value'])) print '<!-- Last update : '.$last_update[0]['value'].' -->';
43
	if (isset($last_update[0]['value'])) {
44
		date_default_timezone_set('UTC');
45
		$lastupdate = strtotime($last_update[0]['value']);
46
		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
47
		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
48
	}
49
    ?>
50
    </div>
51
    <?php include('statistics-sub-menu.php'); ?>
52
    <p class="global-stats">
53
        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Flights"); ?></span>
54
	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
55
        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
56
        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
57
	<?php
58
	    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
59
	?>
60
    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span>
61
	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
62
        <?php
63
    	    } else {
64
    	?>
65
    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span>
66
	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
67
    	<?php
68
    	    }
69
    	?>
70
        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
71
        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
72
        <?php
73
    		if ($airline_icao == '') {
74
    	?>
75
        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span>
76
	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
77
	<?php
78
		}
79
	?>
80
	<?php
81
		if (!(isset($globalIVAO) && $globalIVAO) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalphpVMS) && $globalphpVMS)) {
82
			if ($airline_icao == '' || $airline_icao == 'all') {
83
	?>
84
        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name,$year,$month)); ?></span> <?php echo _("Military"); ?></span>
85
	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
86
	<?php
87
			}
88
		}
89
	?>
90
    </p>
91
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
92
    <div class="specific-stats">
93
        <div class="row column">
94
            <div class="col-md-6">
95
                <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
96
                 <?php
97
                  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
98
		    if (count($aircraft_array) == 0) print _("No data available");
99
		    else {
100
101
                    print '<div id="chart1" class="chart" width="100%"></div>
102
                    <script> 
103
                        google.load("visualization", "1", {packages:["corechart"]});
104
                      google.setOnLoadCallback(drawChart1);
105
                      function drawChart1() {
106
                        var data = google.visualization.arrayToDataTable([
107
                            ["'._("Aircraft").'", "'._("# of times").'"], ';
108
                            $aircraft_data = '';
109
                          foreach($aircraft_array as $aircraft_item)
110
                                    {
111
                                            $aircraft_data .= '[ "'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
112
                                    }
113
                                    $aircraft_data = substr($aircraft_data, 0, -1);
114
                                    print $aircraft_data;
115
                        print ']);
116
117
                        var options = {
118
                            chartArea: {"width": "80%", "height": "60%"},
119
                            height:300,
120
                             is3D: true
121
                        };
122
123
                        var chart = new google.visualization.PieChart(document.getElementById("chart1"));
124
                        chart.draw(data, options);
125
                      }
126
                      $(window).resize(function(){
127
                              drawChart1();
128
                            });
129
                  </script>';
130
                  }
131
                  ?>
132
                <div class="more">
133
            	    <?php
134
            		if ($year != '' && $month != '') {
135
            	    ?>
136
            	    <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>
137
            	    <?php
138
            		} else {
139
            	    ?>
140
            	    <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>
141
            	    <?php
142
            		}
143
            	    ?>
144
                </div>
145
            </div>
146
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
147
<?php
148
//    echo $airline_icao;
149
    if ($airline_icao == '' || $airline_icao == 'all') {
150
	$airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month);
151
	if (count($airline_array) > 0) {
152
            print '<div class="col-md-6">';
153
	    print '<h2>'._("Top 10 Most Common Airline").'</h2>';
154
	    print '<div id="chart2" class="chart" width="100%"></div>
155
                    <script> 
156
                        google.load("visualization", "1", {packages:["corechart"]});
157
                      google.setOnLoadCallback(drawChart2);
158
                      function drawChart2() {
159
                        var data = google.visualization.arrayToDataTable([
160
                            ["'._("Airline").'", "'._("# of times").'"], ';
161
	    $airline_data = '';
162
	    foreach($airline_array as $airline_item)
163
	    {
164
		$airline_data .= '[ "'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
165
	    }
166
	    $airline_data = substr($airline_data, 0, -1);
167
	    print $airline_data;
168
	    print ']);
169
170
                        var options = {
171
                            chartArea: {"width": "80%", "height": "60%"},
172
                            height:300,
173
                             is3D: true
174
                        };
175
176
                        var chart = new google.visualization.PieChart(document.getElementById("chart2"));
177
                        chart.draw(data, options);
178
                      }
179
                      $(window).resize(function(){
180
                              drawChart2();
181
                            });
182
                  </script>';
183
	    if ($year != '' && $month != '') {
184
		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
185
		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
186
		print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
187
	    } else {
188
		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
189
		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
190
		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
191
	    }
192
    	    print '</div>';
193
	}
194
?>
195
        </div>
196
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
197
<?php
198
    }
199
?>
200
        <div class="row column">
201
<?php
202
    $flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
203
    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
204
	if (empty($flightover_array)) {
205
	    print '<div class="col-md-12">';
206
	} else {
207
            print '<div class="col-md-6">';
208
	}
209
?>
210
                <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
211
<?php
212
	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
213
	if (count($pilot_array) == 0) print _("No data available");
214
	else {
215
	    print '<div id="chart7" class="chart" width="100%"></div>
216
                    <script> 
217
                        google.load("visualization", "1", {packages:["corechart"]});
218
                      google.setOnLoadCallback(drawChart7);
219
                      function drawChart7() {
220
                        var data = google.visualization.arrayToDataTable([
221
                            ["'._("Pilots").'", "'._("# of times").'"], ';
222
	    $pilot_data = '';
223
	    foreach($pilot_array as $pilot_item)
224
	    {
225
		$pilot_data .= '[ "'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
226
	    }
227
	    $pilot_data = substr($pilot_data, 0, -1);
228
	    print $pilot_data;
229
	    print ']);
230
231
                        var options = {
232
                            chartArea: {"width": "80%", "height": "60%"},
233
                            height:300,
234
                             is3D: true
235
                        };
236
237
                        var chart = new google.visualization.PieChart(document.getElementById("chart7"));
238
                        chart.draw(data, options);
239
                      }
240
                      $(window).resize(function(){
241
                              drawChart7();
242
                            });
243
                  </script>';
244
        }
245
        print '<div class="more">';
246
	print '<a href="'.$globalURL.'/statistics/pilot'; 
247
	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
248
	print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
249
	print '</div>';
250
?>
251
            </div>
252
        
253
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
254
<?php
255
    } else {
256
?>
257
            <div class="col-md-6">
258
                <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
259
<?php
260
	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
261
	if (count($owner_array) == 0) print _("No data available");
262
	else {
263
	    print '<div id="chart7" class="chart" width="100%"></div>
264
                    <script> 
265
                        google.load("visualization", "1", {packages:["corechart"]});
266
                      google.setOnLoadCallback(drawChart7);
267
                      function drawChart7() {
268
                        var data = google.visualization.arrayToDataTable([
269
                            ["'._("Owner").'", "'._("# of times").'"], ';
270
                            $owner_data = '';
271
	    foreach($owner_array as $owner_item)
272
	    {
273
		$owner_data .= '[ "'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
274
	    }
275
	    $owner_data = substr($owner_data, 0, -1);
276
	    print $owner_data;
277
	    print ']);
278
279
                        var options = {
280
                            chartArea: {"width": "80%", "height": "60%"},
281
                            height:300,
282
                             is3D: true
283
                        };
284
285
                        var chart = new google.visualization.PieChart(document.getElementById("chart7"));
286
                        chart.draw(data, options);
287
                      }
288
                      $(window).resize(function(){
289
                              drawChart7();
290
                            });
291
                  </script>';
292
	}
293
?>
294
                <div class="more">
295
                    <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>
296
                </div>
297
            </div>
298
        
299
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
300
<?php
301
    }
302
    if (!empty($flightover_array)) {
303
?>
304
            <div class="col-md-6">
305
                <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
306
<?php
307
	 //$flightover_array = $Stats->countAllFlightOverCountries();
308
	if (count($flightover_array) == 0) print _("No data available");
309
	else {
310
	    print '<div id="chart10" class="chart" width="100%"></div>
311
                    <script> 
312
                        google.load("visualization", "1", {packages:["corechart"]});
313
                      google.setOnLoadCallback(drawChart10);
314
                      function drawChart10() {
315
                        var data = google.visualization.arrayToDataTable([
316
                            ["'._("Country").'", "'._("# of times").'"], ';
317
                            $flightover_data = '';
318
	    foreach($flightover_array as $flightover_item)
319
	    {
320
		$flightover_data .= '[ "'.$flightover_item['flight_country'].' ('.$flightover_item['flight_country_iso2'].')",'.$flightover_item['flight_count'].'],';
321
	    }
322
	    $flightover_data = substr($flightover_data, 0, -1);
323
	    print $flightover_data;
324
	    print ']);
325
326
                        var options = {
327
                            chartArea: {"width": "80%", "height": "60%"},
328
                            height:300,
329
                             is3D: true,
330
	                    colors: ["#8BA9D0","#1a3151"]
331
                        };
332
333
                        //var chart = new google.visualization.PieChart(document.getElementById("chart10"));
334
            		var chart = new google.visualization.GeoChart(document.getElementById("chart10"));
335
                        chart.draw(data, options);
336
                      }
337
                      $(window).resize(function(){
338
                              drawChart10();
339
                            });
340
                  </script>';
341
	}
342
?>
343
                <div class="more">
344
                    <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>
345
                </div>
346
            </div>
347
<?php
348
    }
349
?>
350
        </div>
351
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
352
353
    	
354
        </div>
355
        <div class="row column">
356
            <div class="col-md-6">
357
<?php
358
    $airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
359
    if (count($airport_airport_array) > 0) {
360
	print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
361
	print '<div id="chart3" class="chart" width="100%"></div>
362
                <script>
363
                google.load("visualization", "1", {packages:["geochart"]});
364
                google.setOnLoadCallback(drawCharts3);
365
                $(window).resize(function(){
366
                    drawCharts3();
367
                });
368
                function drawCharts3() {
369
370
                var data = google.visualization.arrayToDataTable([ 
371
                    ["'._("Airport").'", "'._("# of times").'"],';
372
                    $airport_data = '';
373
	foreach($airport_airport_array as $airport_item)
374
	{
375
	    $name = $airport_item['airport_departure_city'].', '.$airport_item['airport_departure_country'].' ('.$airport_item['airport_departure_icao'].')';
376
	    $name = str_replace("'", "", $name);
377
	    $name = str_replace('"', "", $name);
378
	    $airport_data .= '[ "'.$name.'",'.$airport_item['airport_departure_icao_count'].'],';
379
	}
380
	$airport_data = substr($airport_data, 0, -1);
381
	print $airport_data;
382
	print ']);
383
384
                var options = {
385
                    legend: {position: "none"},
386
                    chartArea: {"width": "80%", "height": "60%"},
387
                    height:300,
388
                    displayMode: "markers",
389
                    colors: ["#8BA9D0","#1a3151"]
390
                };
391
392
                var chart = new google.visualization.GeoChart(document.getElementById("chart3"));
393
                chart.draw(data, options);
394
              }
395
                </script>';
396
	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
397
	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
398
	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
399
    }
400
?>
401
            </div>
402
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
403
404
            <div class="col-md-6">
405
<?php
406
    $airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
407
    if (count($airport_airport_array2) > 0) {
408
	print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
409
	print '<div id="chart4" class="chart" width="100%"></div>
410
                <script>
411
                google.load("visualization", "1", {packages:["geochart"]});
412
                google.setOnLoadCallback(drawCharts4);
413
                $(window).resize(function(){
414
                    drawCharts4();
415
                });
416
                function drawCharts4() {
417
418
                var data = google.visualization.arrayToDataTable([ 
419
                    ["'._("Airport").'", "'._("# of times").'"],';
420
	$airport_data2 = '';
421
	foreach($airport_airport_array2 as $airport_item2)
422
	{
423
	    $name2 = $airport_item2['airport_arrival_city'].', '.$airport_item2['airport_arrival_country'].' ('.$airport_item2['airport_arrival_icao'].')';
424
	    $name2 = str_replace(array("'",'"'), '', $name2);
425
	    $airport_data2 .= '[ "'.$name2.'",'.$airport_item2['airport_arrival_icao_count'].'],';
426
	}
427
	$airport_data2 = substr($airport_data2, 0, -1);
428
	print $airport_data2;
429
	print ']);
430
431
                var options = {
432
                    legend: {position: "none"},
433
                    chartArea: {"width": "80%", "height": "60%"},
434
                    height:300,
435
                    displayMode: "markers",
436
                    colors: ["#8BA9D0","#1a3151"]
437
                };
438
439
                var chart = new google.visualization.GeoChart(document.getElementById("chart4"));
440
                chart.draw(data, options);
441
              }
442
                </script>';
443
	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
444
	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
445
	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
446
    }
447
?>
448
            </div>
449
        </div>
450
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
451
<?php
452
    if ($year == '' && $month == '') {
453
?>
454
        <div class="row column">
455
            <div class="col-md-6">
456
                <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
457
                <?php
458
                  $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
459
		    if (count($year_array) == 0) print _("No data available");
460
		    else {
461
                  print '<div id="chart8" class="chart" width="100%"></div>
462
                    <script> 
463
                        google.load("visualization", "1", {packages:["corechart"]});
464
                      google.setOnLoadCallback(drawChart8);
465
                      function drawChart8() {
466
                        var data = google.visualization.arrayToDataTable([
467
                            ["'._("Month").'", "'._("# of Flights").'"], ';
468
                            $year_data = '';
469
                          foreach($year_array as $year_item)
470
                                    {
471
                                        $year_data .= '[ "'.date('F, Y',strtotime($year_item['year_name'].'-'.$year_item['month_name'].'-01')).'",'.$year_item['date_count'].'],';
472
                                    }
473
                                    $year_data = substr($year_data, 0, -1);
474
                                    print $year_data;
475
                        print ']);
476
477
                        var options = {
478
                            legend: {position: "none"},
479
                            chartArea: {"width": "80%", "height": "60%"},
480
                            vAxis: {title: "'._("# of Flights").'"},
481
                            hAxis: {showTextEvery: 2},
482
                            height:300,
483
                            colors: ["#1a3151"]
484
                        };
485
486
                        var chart = new google.visualization.AreaChart(document.getElementById("chart8"));
487
                        chart.draw(data, options);
488
                      }
489
                      $(window).resize(function(){
490
                              drawChart8();
491
                            });
492
                  </script>';
493
                  }
494
                  ?>
495
                <div class="more">
496
                    <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>
497
                </div>
498
            </div>
499
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
500
            <div class="col-md-6">
501
                <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
502
                <?php
503
                  $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
504
		    if (count($month_array) == 0) print _("No data available");
505
		    else {
506
                  print '<div id="chart9" class="chart" width="100%"></div>
507
                    <script> 
508
                        google.load("visualization", "1", {packages:["corechart"]});
509
                      google.setOnLoadCallback(drawChart9);
510
                      function drawChart9() {
511
                        var data = google.visualization.arrayToDataTable([
512
                            ["'._("Day").'", "'._("# of Flights").'"], ';
513
                            $month_data = '';
514
                          foreach($month_array as $month_item)
515
                                    {
516
                                        $month_data .= '[ "'.date('F j, Y',strtotime($month_item['date_name'])).'",'.$month_item['date_count'].'],';
517
                                    }
518
                                    $month_data = substr($month_data, 0, -1);
519
                                    print $month_data;
520
                        print ']);
521
522
                        var options = {
523
                            legend: {position: "none"},
524
                            chartArea: {"width": "80%", "height": "60%"},
525
                            vAxis: {title: "'._("# of Flights").'"},
526
                            hAxis: {showTextEvery: 2},
527
                            height:300,
528
                            colors: ["#1a3151"]
529
                        };
530
531
                        var chart = new google.visualization.AreaChart(document.getElementById("chart9"));
532
                        chart.draw(data, options);
533
                      }
534
                      $(window).resize(function(){
535
                              drawChart9();
536
                            });
537
                  </script>';
538
                  }
539
                  ?>
540
                <div class="more">
541
                    <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>
542
                </div>
543
            </div>
544
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
545
546
            <div class="col-md-6">
547
                <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
548
                <?php
549
                    $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
550
		    if (empty($date_array)) print _("No data available");
551
		    else {
552
                  print '<div id="chart5" class="chart" width="100%"></div>
553
                    <script> 
554
                        google.load("visualization", "1", {packages:["corechart"]});
555
                      google.setOnLoadCallback(drawChart5);
556
                      function drawChart5() {
557
                        var data = google.visualization.arrayToDataTable([
558
                            ["'._("Date").'", "'._("# of Flights").'"], ';
559
                            $date_data = '';
560
                        
561
                          foreach($date_array as $date_item)
562
                                    {
563
                                        $date_data .= '[ "'.date("F j, Y", strtotime($date_item['date_name'])).'",'.$date_item['date_count'].'],';
564
                                    }
565
                                    $date_data = substr($date_data, 0, -1);
566
                                    print $date_data;
567
                        print ']);
568
569
                        var options = {
570
                            legend: {position: "none"},
571
                            chartArea: {"width": "80%", "height": "60%"},
572
                            vAxis: {title: "'._("# of Flights").'"},
573
                            hAxis: {showTextEvery: 2},
574
                            height:300,
575
                            colors: ["#1a3151"]
576
                        };
577
578
                        var chart = new google.visualization.AreaChart(document.getElementById("chart5"));
579
                        chart.draw(data, options);
580
                      }
581
                      $(window).resize(function(){
582
                              drawChart5();
583
                            });
584
                  </script>';
585
                  }
586
                  ?>
587
                <div class="more">
588
                    <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>
589
                </div>
590
            </div>
591
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
592
            <div class="col-md-6">
593
                <h2><?php echo _("Busiest Time of the Day"); ?></h2>
594
                <?php
595
                  $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
596
		    if (empty($hour_array)) print _("No data available");
597
		    else {
598
599
                  print '<div id="chart6" class="chart" width="100%"></div>
600
                    <script> 
601
                        google.load("visualization", "1", {packages:["corechart"]});
602
                      google.setOnLoadCallback(drawChart6);
603
                      function drawChart6() {
604
                        var data = google.visualization.arrayToDataTable([
605
                            ["'._("Hour").'", "'._("# of Flights").'"], ';
606
                            $hour_data = '';
607
                          foreach($hour_array as $hour_item)
608
                                    {
609
                                        $hour_data .= '[ "'.$hour_item['hour_name'].':00",'.$hour_item['hour_count'].'],';
610
                                    }
611
                                    $hour_data = substr($hour_data, 0, -1);
612
                                    print $hour_data;
613
                        print ']);
614
615
                        var options = {
616
                            legend: {position: "none"},
617
                            chartArea: {"width": "80%", "height": "60%"},
618
                            vAxis: {title: "'._("# of Flights").'"},
619
                            hAxis: {showTextEvery: 2},
620
                            height:300,
621
                            colors: ["#1a3151"]
622
                        };
623
624
                        var chart = new google.visualization.AreaChart(document.getElementById("chart6"));
625
                        chart.draw(data, options);
626
                      }
627
                      $(window).resize(function(){
628
                              drawChart6();
629
                            });
630
                  </script>';
631
                  }
632
                ?>
633
                <div class="more">
634
                    <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>
635
                </div>
636
            </div>
637
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
638
        </div>
639
<?php
640
    }
641
?>
642
643
<?php
644
    if (($airline_icao == '' || $airline_icao == 'all') && $year == '' && $month == '' && isset($globalAccidents) && $globalAccidents) {
645
?>
646
        <div class="row column">
647
            <div class="col-md-6">
648
                <h2><?php echo _("Fatalities by Years"); ?></h2>
649
                <?php
650
                  $year_array = $Stats->countFatalitiesByYear($filter_name);
0 ignored issues
show
The call to Stats::countFatalitiesByYear() has too many arguments starting with $filter_name.

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

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

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

Loading history...
651
		    if (count($year_array) == 0) print _("No data available");
652
		    else {
653
                  print '<div id="chart32" class="chart" width="100%"></div>
654
                    <script> 
655
                        google.load("visualization", "1", {packages:["corechart"]});
656
                      google.setOnLoadCallback(drawChart32);
657
                      function drawChart32() {
658
                        var data = google.visualization.arrayToDataTable([
659
                            ["'._("Year").'", "'._("# of Fatalities").'"], ';
660
                            $year_data = '';
661
                          foreach($year_array as $year_item)
662
                                    {
663
                                        $year_data .= '[ "'.$year_item['year'].'",'.$year_item['count'].'],';
664
                                    }
665
                                    $year_data = substr($year_data, 0, -1);
666
                                    print $year_data;
667
                        print ']);
668
669
                        var options = {
670
                            legend: {position: "none"},
671
                            chartArea: {"width": "80%", "height": "60%"},
672
                            vAxis: {title: "'._("# of Fatalities").'"},
673
                            hAxis: {showTextEvery: 2},
674
                            height:300,
675
                            colors: ["#1a3151"]
676
                        };
677
678
                        var chart = new google.visualization.AreaChart(document.getElementById("chart32"));
679
                        chart.draw(data, options);
680
                      }
681
                      $(window).resize(function(){
682
                              drawChart32();
683
                            });
684
                  </script>';
685
                  }
686
                  ?>
687
                <div class="more">
688
                    <a href="<?php print $globalURL; ?>/statistics/fatalities/year" 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
693
        <div class="row column">
694
            <div class="col-md-6">
695
                <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
696
                <?php
697
                  $year_array = $Stats->countFatalitiesLast12Months($filter_name);
0 ignored issues
show
The call to Stats::countFatalitiesLast12Months() has too many arguments starting with $filter_name.

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

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

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

Loading history...
698
		    if (count($year_array) == 0) print _("No data available");
699
		    else {
700
                  print '<div id="chart33" class="chart" width="100%"></div>
701
                    <script> 
702
                        google.load("visualization", "1", {packages:["corechart"]});
703
                      google.setOnLoadCallback(drawChart33);
704
                      function drawChart33() {
705
                        var data = google.visualization.arrayToDataTable([
706
                            ["'._("Month").'", "'._("# of Fatalities").'"], ';
707
                            $year_data = '';
708
                          foreach($year_array as $year_item)
709
                                    {
710
                                        $year_data .= '[ "'.date('F, Y',strtotime($year_item['year'].'-'.$year_item['month'].'-01')).'",'.$year_item['count'].'],';
711
                                    }
712
                                    $year_data = substr($year_data, 0, -1);
713
                                    print $year_data;
714
                        print ']);
715
716
                        var options = {
717
                            legend: {position: "none"},
718
                            chartArea: {"width": "80%", "height": "60%"},
719
                            vAxis: {title: "'._("# of Fatalities").'"},
720
                            hAxis: {showTextEvery: 2},
721
                            height:300,
722
                            colors: ["#1a3151"]
723
                        };
724
725
                        var chart = new google.visualization.AreaChart(document.getElementById("chart33"));
726
                        chart.draw(data, options);
727
                      }
728
                      $(window).resize(function(){
729
                              drawChart33();
730
                            });
731
                  </script>';
732
                  }
733
                  ?>
734
                <div class="more">
735
                    <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
736
                </div>
737
            </div>
738
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
739
<br/>
740
<?php
741
    }
742
?>
743
744
<?php
745
    if (($airline_icao == '' || $airline_icao == 'all') && $filter_name == '' && $year == '' && $month == '') {
746
?>
747
        <div class="row column">
748
        	<?php
749
        	    //$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
750
        	    if ($year == '' && $month == '') {
751
		        $polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
752
		    } else {
753
        		$polar = $Stats->getStatsSource('polar',$year,$month);
754
        	    }
755
        	    if (!empty($polar)) {
756
            		print '<h2>'._("Coverage pattern").'</h2>';
757
        		foreach ($polar as $eachpolar) {
758
        		    unset($polar_data);
759
	        	    $Spotter = new Spotter();
760
        		    $data = json_decode($eachpolar['source_data']);
761
        		    foreach($data as $value => $key) {
762
        			$direction = $Spotter->parseDirection(($value*22.5));
763
        			$distance = $key;
764
        			$unit = 'km';
765
				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
766
					$distance = round($distance*0.539957);
767
					$unit = 'nm';
768
				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
769
					$distance = round($distance*0.621371);
770
					$unit = 'mi';
771
				} elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
772
					$distance = $distance;
773
					$unit = 'km';
774
				}
775
        			if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
776
        	    		else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
777
        		    }
778
        	?>
779
            <div class="col-md-6">
780
                <h4><?php print $eachpolar['source_name']; ?></h4>
781
        	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
782
        	<script>
783
        	    (function() {
784
        	    var margin = {top: 100, right: 100, bottom: 100, left: 100},
785
			width = Math.min(700, window.innerWidth - 10) - margin.left - margin.right,
786
			height = Math.min(width, window.innerHeight - margin.top - margin.bottom - 20);
787
		    var data = [
788
				    [
789
				    <?php print $polar_data; ?>
790
				    ]
791
				];
792
		    var color = d3.scale.ordinal().range(["#EDC951","#CC333F","#00A0B0"]);
793
		    //var color = d3.scaleOrdinal().range(["#EDC951","#CC333F","#00A0B0"]);
794
		
795
		    var radarChartOptions = {
796
		      w: width,
797
		      h: height,
798
		      margin: margin,
799
		      maxValue: 0.5,
800
		      levels: 5,
801
		      roundStrokes: true,
802
		      color: color,
803
		      unit: '<?php echo $unit; ?>'
804
		    };
805
		    RadarChart("#polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
806
		    })();
807
		</script>
808
            </div>
809
            <?php
810
        	    }
811
        	}
812
            ?>
813
        </div>
814
        <div class="row column">
815
            <div class="col-md-6">
816
        	<?php
817
        	    //$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
818
        	    if ($year == '' && $month == '') {
819
        		$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
820
        	    } else {
821
        		$msg = $Stats->getStatsSource('msg',$year,$month);
822
        	    }
823
        	    if (!empty($msg)) {
824
            		print '<h2>'._("Messages received").'</h2>';
825
        		foreach ($msg as $eachmsg) {
826
        		    //$eachmsg = $msg[0];
827
        		    $data = $eachmsg['source_data'];
828
        		    if ($data > 500) $max = (round(($data+100)/100))*100;
829
        		    else $max = 500;
830
        	?>
831
        	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
832
        	<script>
833
		      var g = new JustGage({
834
			    id: "msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>",
835
			    value: <?php echo $data; ?>,
836
			    min: 0,
837
			    max: <?php print $max; ?>,
838
			    valueMinFontSize: 10,
839
			    height: 120,
840
			    width: 220,
841
			    symbol: ' msg/s',
842
			    title: "<?php print $eachmsg['source_name']; ?>"
843
			  });
844
		</script>
845
            <?php
846
        	   }
847
        	}
848
            ?>
849
            </div>
850
        </div>
851
        <div class="row column">
852
853
            <?php
854
		//$hist = $Stats->getStatsSource(date('Y-m-d'),'hist');
855
		if ($year == '' && $month == '') {
856
			$hist = $Stats->getStatsSource('hist',date('Y'),date('m'),date('d'));
857
		} else {
858
			$hist = $Stats->getStatsSource('hist',$year,$month);
859
		}
860
		foreach ($hist as $hists) {
861
			$hist_data = '';
862
			$source = $hists['source_name'];
863
			$hist_array = json_decode($hists['source_data']);
864
			foreach($hist_array as $distance => $nb)
865
			{
866
				$unit = 'km';
867
				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
868
					$distance = round($distance*0.539957);
869
					$unit = 'nm';
870
				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
871
					$distance = round($distance*0.621371);
872
					$unit = 'mi';
873
				} elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
874
					$distance = $distance;
875
					$unit = 'km';
876
				}
877
				$hist_data .= '[ "'.$distance.'",'.$nb.'],';
878
			}
879
			$hist_data = substr($hist_data, 0, -1);
880
            ?>
881
            <div class="col-md-6">
882
                <h2><?php echo sprintf(_("Flights Distance for %s"),$source); ?></h2>
883
                <?php
884
                  print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div>
885
                    <script> 
886
                        google.load("visualization", "1", {packages:["corechart"]});
887
                      google.setOnLoadCallback(drawCharthist_'.str_replace(' ','_',strtolower($source)).');
888
                      function drawCharthist_'.str_replace(' ','_',strtolower($source)).'() {
889
                        var data = google.visualization.arrayToDataTable([
890
                            ["'._("Distance").'", "'._("# of Flights").'"], ';
891
                            print $hist_data;
892
                        print ']);
893
894
                        var options = {
895
                            legend: {position: "none"},
896
                            chartArea: {"width": "80%", "height": "60%"},
897
                            vAxis: {title: "'._("# of Flights").'"},
898
                            hAxis: {showTextEvery: 2,title: "'._("Distance").' ('.$unit.')"},
899
                            height:300,
900
                            colors: ["#1a3151"]
901
                        };
902
903
                        var chart = new google.visualization.AreaChart(document.getElementById("charthist-'.str_replace(' ','_',strtolower($source)).'"));
904
                        chart.draw(data, options);
905
                      }
906
                      $(window).resize(function(){
907
                              drawCharthist_'.str_replace(' ','_',strtolower($source)).'();
908
                            });
909
                  </script>';
910
        	?>
911
    	    </div>
912
	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
913
        	<?php
914
                  }
915
                ?>
916
        </div>
917
<?php
918
    }
919
?>
920
    </div>
921
</div>  
922
923
<?php
924
require_once('footer.php');
925
?>