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